get_themes()获取所有的主题信息

目录

描述

译文

在主题目录中检索含有主题数据的 主题列表。

若主题不具备父主题且丢失style.css或index.php文件,将该主题视为以损坏。若主题具备父主题但丢失style.css文件,将该主题视为已损坏;index.php可选。已损坏主题保存在$wp_broken_themes全局变量中,显示在管理栏的主题列表中。

原文

Retrieve list of themes with theme data in theme directory.

The theme is broken if it doesn't have a parent theme and is missing either style.css or index.php. If the theme has a parent theme, it is broken if it is missing style.css; index.php is optional. The broken theme list is saved in the $wp_broken_themes global, which is displayed on the theme list in the administration panels.

get_themes() 描述

用法

<?php get_themes() ?>

get_themes() 用法

参数

None.

get_themes() 参数

返回值

(array) 

Theme list with theme data.

get_themes() 返回值

注意

  • 使用到 global: (array) $wp_themes holds working themes list.

get_themes() 注意

历史

添加于 版本: 1.5.0. Deprecated since 3.4.0.

get_themes() 历史

源文件

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

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Retrieve list of themes with theme data in theme directory.
 *
 * The theme is broken, if it doesn't have a parent theme and is missing either
 * style.css and, or index.php. If the theme has a parent theme then it is
 * broken, if it is missing style.css; index.php is optional.
 *
 * @since 1.5.0
 * @deprecated 3.4.0
 * @deprecated Use wp_get_themes()
 * @see wp_get_themes()
 *
 * @return array Theme list with theme data.
 */
function get_themes() {
	_deprecated_function( __FUNCTION__, '3.4', 'wp_get_themes()' );

	global $wp_themes;
	if ( isset( $wp_themes ) )
		return $wp_themes;

	$themes = wp_get_themes();
	$wp_themes = array();

	foreach ( $themes as $theme ) {
		$name = $theme->get('Name');
		if ( isset( $wp_themes[ $name ] ) )
			$wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme;
		else
			$wp_themes[ $name ] = $theme;
	}

	return $wp_themes;
}

get_themes() 源文件

相关