wp_get_active_and_valid_themes

函数
wp_get_active_and_valid_themes ( No parameters )
Access
Private
返回值
  • (string[]) Array of absolute paths to theme directories.
定义位置
相关方法
wp_get_active_and_valid_pluginsget_site_allowed_themeswpmu_get_blog_allowedthemeswp_get_themes_wp_relative_upload_path
引入
5.1.0
弃用
-

wp_get_active_and_valid_themes: 这个函数返回一个活跃和有效主题的数组。它扫描主题目录并检索所有以”style.css”结尾的文件的列表。然后它检查每个文件以确保它有一个有效的主题头。

检索一个活跃和有效的主题数组。

在升级或安装WordPress时,不会返回任何主题。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_get_active_and_valid_themes() {
global $pagenow;
$themes = array();
if ( wp_installing() && 'wp-activate.php' !== $pagenow ) {
return $themes;
}
if ( TEMPLATEPATH !== STYLESHEETPATH ) {
$themes[] = STYLESHEETPATH;
}
$themes[] = TEMPLATEPATH;
/*
* Remove themes from the list of active themes when we're on an endpoint
* that should be protected against WSODs and the theme is paused.
*/
if ( wp_is_recovery_mode() ) {
$themes = wp_skip_paused_themes( $themes );
// If no active and valid themes exist, skip loading themes.
if ( empty( $themes ) ) {
add_filter( 'wp_using_themes', '__return_false' );
}
}
return $themes;
}
function wp_get_active_and_valid_themes() { global $pagenow; $themes = array(); if ( wp_installing() && 'wp-activate.php' !== $pagenow ) { return $themes; } if ( TEMPLATEPATH !== STYLESHEETPATH ) { $themes[] = STYLESHEETPATH; } $themes[] = TEMPLATEPATH; /* * Remove themes from the list of active themes when we're on an endpoint * that should be protected against WSODs and the theme is paused. */ if ( wp_is_recovery_mode() ) { $themes = wp_skip_paused_themes( $themes ); // If no active and valid themes exist, skip loading themes. if ( empty( $themes ) ) { add_filter( 'wp_using_themes', '__return_false' ); } } return $themes; }
function wp_get_active_and_valid_themes() {
	global $pagenow;

	$themes = array();

	if ( wp_installing() && 'wp-activate.php' !== $pagenow ) {
		return $themes;
	}

	if ( TEMPLATEPATH !== STYLESHEETPATH ) {
		$themes[] = STYLESHEETPATH;
	}

	$themes[] = TEMPLATEPATH;

	/*
	 * Remove themes from the list of active themes when we're on an endpoint
	 * that should be protected against WSODs and the theme is paused.
	 */
	if ( wp_is_recovery_mode() ) {
		$themes = wp_skip_paused_themes( $themes );

		// If no active and valid themes exist, skip loading themes.
		if ( empty( $themes ) ) {
			add_filter( 'wp_using_themes', '__return_false' );
		}
	}

	return $themes;
}

常见问题

FAQs
查看更多 >