get_theme_data()通过主题文件获取主题信息

目录

描述

译文

返回关于主题文件信息的数组

原文

Returns an array of information about a theme file.

This function has been replaced with wp_get_theme in WordPress 3.4

get_theme_data() 描述

用法

 <?php get_theme_data$theme_filename ); ?> 

Use wp_get_theme instead.

get_theme_data() 用法

参数

$theme_filename

(string) (必填) Path and filename of the theme's style.css.

默认值: None

get_theme_data() 参数

源文件

get_theme_data() 函数的代码位于 wp-includes/deprecated.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * 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->get('Author'),
	);

	foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) {
		if ( ! isset( $theme_data[ $extra_header ] ) )
			$theme_data[ $extra_header ] = $theme->get( $extra_header );
	}

	return $theme_data;
}

get_theme_data() 源文件