Make WordPress Core

Changeset 20269


Ignore:
Timestamp:
03/23/2012 10:21:24 AM (13 years ago)
Author:
nacin
Message:

Deprecate get_theme_data(). Use wp_get_theme() instead. see #20103.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/deprecated.php

    r20265 r20269  
    30583058    return remove_theme_support( 'custom-background' );
    30593059}
     3060
     3061/**
     3062 * Retrieve theme data from parsed theme file.
     3063 *
     3064 * @since 1.5.0
     3065 * @deprecated @3.4.0
     3066 * @deprecated Use wp_get_theme()
     3067 * @see wp_get_theme()
     3068 *
     3069 * @param string $theme_file Theme file path.
     3070 * @return array Theme data.
     3071 */
     3072function get_theme_data( $theme_file ) {
     3073    _deprecated_function( __FUNCTION__, 3.4, 'wp_get_theme()' );
     3074    $theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) );
     3075
     3076    $theme_data = array(
     3077        'Name' => $theme->get('Name'),
     3078        'URI' => $theme->display('ThemeURI', true, false),
     3079        'Description' => $theme->display('Description', true, false),
     3080        'Author' => $theme->display('Author', true, false),
     3081        'AuthorURI' => $theme->display('AuthorURI', true, false),
     3082        'Version' => $theme->get('Version'),
     3083        'Template' => $theme->get('Template'),
     3084        'Status' => $theme->get('Status'),
     3085        'Tags' => $theme->get('Tags'),
     3086        'Title' => $theme->get('Name'),
     3087        'AuthorName' => $theme->display('Author', false, false),
     3088    );
     3089
     3090    return $theme_data;
     3091}
  • trunk/wp-includes/theme.php

    r20240 r20269  
    257257
    258258    return apply_filters( 'template_directory_uri', $template_dir_uri, $template, $theme_root_uri );
    259 }
    260 
    261 /**
    262  * Retrieve theme data from parsed theme file.
    263  *
    264  * The description will have the tags filtered with the following HTML elements
    265  * whitelisted. The <b>'a'</b> element with the <em>href</em> and <em>title</em>
    266  * attributes. The <b>abbr</b> element with the <em>title</em> attribute. The
    267  * <b>acronym</b> element with the <em>title</em> attribute allowed. The
    268  * <b>code</b>, <b>em</b>, and <b>strong</b> elements also allowed.
    269  *
    270  * The style.css file must contain theme name, theme URI, and description. The
    271  * data can also contain author URI, author, template (parent template),
    272  * version, status, and finally tags. Some of these are not used by WordPress
    273  * administration panels, but are used by theme directory web sites which list
    274  * the theme.
    275  *
    276  * @since 1.5.0
    277  *
    278  * @param string $theme_file Theme file path.
    279  * @return array Theme data.
    280  */
    281 function get_theme_data( $theme_file ) {
    282     $default_headers = array(
    283         'Name' => 'Theme Name',
    284         'URI' => 'Theme URI',
    285         'Description' => 'Description',
    286         'Author' => 'Author',
    287         'AuthorURI' => 'Author URI',
    288         'Version' => 'Version',
    289         'Template' => 'Template',
    290         'Status' => 'Status',
    291         'Tags' => 'Tags'
    292         );
    293 
    294     $themes_allowed_tags = array(
    295         'a' => array(
    296             'href' => array(),'title' => array()
    297             ),
    298         'abbr' => array(
    299             'title' => array()
    300             ),
    301         'acronym' => array(
    302             'title' => array()
    303             ),
    304         'code' => array(),
    305         'em' => array(),
    306         'strong' => array()
    307     );
    308 
    309     $theme_data = get_file_data( $theme_file, $default_headers, 'theme' );
    310 
    311     $theme_data['Name'] = $theme_data['Title'] = wp_kses( $theme_data['Name'], $themes_allowed_tags );
    312 
    313     $theme_data['URI'] = esc_url( $theme_data['URI'] );
    314 
    315     $theme_data['Description'] = wptexturize( wp_kses( $theme_data['Description'], $themes_allowed_tags ) );
    316 
    317     $theme_data['AuthorURI'] = esc_url( $theme_data['AuthorURI'] );
    318 
    319     $theme_data['Template'] = wp_kses( $theme_data['Template'], $themes_allowed_tags );
    320 
    321     $theme_data['Version'] = wp_kses( $theme_data['Version'], $themes_allowed_tags );
    322 
    323     if ( $theme_data['Status'] == '' )
    324         $theme_data['Status'] = 'publish';
    325     else
    326         $theme_data['Status'] = wp_kses( $theme_data['Status'], $themes_allowed_tags );
    327 
    328     if ( $theme_data['Tags'] == '' )
    329         $theme_data['Tags'] = array();
    330     else
    331         $theme_data['Tags'] = array_map( 'trim', explode( ',', wp_kses( $theme_data['Tags'], array() ) ) );
    332 
    333     if ( $theme_data['Author'] == '' ) {
    334         $theme_data['Author'] = $theme_data['AuthorName'] = __('Anonymous');
    335     } else {
    336         $theme_data['AuthorName'] = wp_kses( $theme_data['Author'], $themes_allowed_tags );
    337         if ( empty( $theme_data['AuthorURI'] ) ) {
    338             $theme_data['Author'] = $theme_data['AuthorName'];
    339         } else {
    340             $theme_data['Author'] = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $theme_data['AuthorURI'], esc_attr__( 'Visit author homepage' ), $theme_data['AuthorName'] );
    341         }
    342     }
    343 
    344     return $theme_data;
    345259}
    346260
Note: See TracChangeset for help on using the changeset viewer.