diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index 0523ffbe4a..aa8271f157 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -3056,4 +3056,36 @@ function add_custom_background( $wp_head_callback = '', $admin_head_callback = ' function remove_custom_background() { _deprecated_function( __FUNCTION__, '3.4', 'remove_theme_support( \'custom-background\' )' ); return remove_theme_support( 'custom-background' ); +} + +/** + * Retrieve theme data from parsed theme file. + * + * @since 1.5.0 + * @deprecated @3.4.0 + * @deprecated Use wp_get_theme() + * @see wp_get_theme() + * + * @param string $theme_file Theme file path. + * @return array Theme data. + */ +function get_theme_data( $theme_file ) { + _deprecated_function( __FUNCTION__, 3.4, 'wp_get_theme()' ); + $theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) ); + + $theme_data = array( + 'Name' => $theme->get('Name'), + 'URI' => $theme->display('ThemeURI', true, false), + 'Description' => $theme->display('Description', true, false), + 'Author' => $theme->display('Author', true, false), + 'AuthorURI' => $theme->display('AuthorURI', true, false), + 'Version' => $theme->get('Version'), + 'Template' => $theme->get('Template'), + 'Status' => $theme->get('Status'), + 'Tags' => $theme->get('Tags'), + 'Title' => $theme->get('Name'), + 'AuthorName' => $theme->display('Author', false, false), + ); + + return $theme_data; } \ No newline at end of file diff --git a/wp-includes/theme.php b/wp-includes/theme.php index d3ff396b7a..5824195f11 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -258,92 +258,6 @@ function get_template_directory_uri() { return apply_filters( 'template_directory_uri', $template_dir_uri, $template, $theme_root_uri ); } -/** - * Retrieve theme data from parsed theme file. - * - * The description will have the tags filtered with the following HTML elements - * whitelisted. The 'a' element with the href and title - * attributes. The abbr element with the title attribute. The - * acronym element with the title attribute allowed. The - * code, em, and strong elements also allowed. - * - * The style.css file must contain theme name, theme URI, and description. The - * data can also contain author URI, author, template (parent template), - * version, status, and finally tags. Some of these are not used by WordPress - * administration panels, but are used by theme directory web sites which list - * the theme. - * - * @since 1.5.0 - * - * @param string $theme_file Theme file path. - * @return array Theme data. - */ -function get_theme_data( $theme_file ) { - $default_headers = array( - 'Name' => 'Theme Name', - 'URI' => 'Theme URI', - 'Description' => 'Description', - 'Author' => 'Author', - 'AuthorURI' => 'Author URI', - 'Version' => 'Version', - 'Template' => 'Template', - 'Status' => 'Status', - 'Tags' => 'Tags' - ); - - $themes_allowed_tags = array( - 'a' => array( - 'href' => array(),'title' => array() - ), - 'abbr' => array( - 'title' => array() - ), - 'acronym' => array( - 'title' => array() - ), - 'code' => array(), - 'em' => array(), - 'strong' => array() - ); - - $theme_data = get_file_data( $theme_file, $default_headers, 'theme' ); - - $theme_data['Name'] = $theme_data['Title'] = wp_kses( $theme_data['Name'], $themes_allowed_tags ); - - $theme_data['URI'] = esc_url( $theme_data['URI'] ); - - $theme_data['Description'] = wptexturize( wp_kses( $theme_data['Description'], $themes_allowed_tags ) ); - - $theme_data['AuthorURI'] = esc_url( $theme_data['AuthorURI'] ); - - $theme_data['Template'] = wp_kses( $theme_data['Template'], $themes_allowed_tags ); - - $theme_data['Version'] = wp_kses( $theme_data['Version'], $themes_allowed_tags ); - - if ( $theme_data['Status'] == '' ) - $theme_data['Status'] = 'publish'; - else - $theme_data['Status'] = wp_kses( $theme_data['Status'], $themes_allowed_tags ); - - if ( $theme_data['Tags'] == '' ) - $theme_data['Tags'] = array(); - else - $theme_data['Tags'] = array_map( 'trim', explode( ',', wp_kses( $theme_data['Tags'], array() ) ) ); - - if ( $theme_data['Author'] == '' ) { - $theme_data['Author'] = $theme_data['AuthorName'] = __('Anonymous'); - } else { - $theme_data['AuthorName'] = wp_kses( $theme_data['Author'], $themes_allowed_tags ); - if ( empty( $theme_data['AuthorURI'] ) ) { - $theme_data['Author'] = $theme_data['AuthorName']; - } else { - $theme_data['Author'] = sprintf( '%3$s', $theme_data['AuthorURI'], esc_attr__( 'Visit author homepage' ), $theme_data['AuthorName'] ); - } - } - - return $theme_data; -} - /** * Retrieve theme roots. *