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时,不会返回任何主题。

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
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 19:32:59

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: