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
檢視更多 >