Deprecate get_theme_data(). Use wp_get_theme() instead. see #20103.
git-svn-id: http://svn.automattic.com/wordpress/trunk@20269 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8c46a71af6
commit
2c016a5a1c
|
@ -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;
|
||||
}
|
|
@ -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 <b>'a'</b> element with the <em>href</em> and <em>title</em>
|
||||
* attributes. The <b>abbr</b> element with the <em>title</em> attribute. The
|
||||
* <b>acronym</b> element with the <em>title</em> attribute allowed. The
|
||||
* <b>code</b>, <b>em</b>, and <b>strong</b> 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( '<a href="%1$s" title="%2$s">%3$s</a>', $theme_data['AuthorURI'], esc_attr__( 'Visit author homepage' ), $theme_data['AuthorName'] );
|
||||
}
|
||||
}
|
||||
|
||||
return $theme_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve theme roots.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue