Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

wp_get_active_and_valid_themes() WordPress Function

The wp_get_active_and_valid_themes() function is used to retrieve an array of all the active and valid themes on a WordPress site. This function is useful for theme developers who need to programmatically determine which themes are currently active and valid.

wp_get_active_and_valid_themes() #

Retrieves an array of active and valid themes.


Description

While upgrading or installing WordPress, no themes are returned.


Top ↑

Return

(string[]) Array of absolute paths to theme directories.


Top ↑

Source

File: wp-includes/load.php

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;
}


Top ↑

Changelog

Changelog
VersionDescription
5.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.