wp_get_active_and_valid_themes()
Retrieves an array of active and valid themes.
While upgrading or installing WordPress, no themes are returned.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Return
String[]
. Array of absolute paths to theme directories.
Usage
wp_get_active_and_valid_themes();
Notes
- Global. String. $pagenow The filename of the current screen.
- Global. String. $wp_stylesheet_path Path to current theme's stylesheet directory.
- Global. String. $wp_template_path Path to current theme's template directory.
Changelog
Since 5.1.0 | Introduced. |
wp_get_active_and_valid_themes() wp get active and valid themes code WP 6.5.2
function wp_get_active_and_valid_themes() { global $pagenow, $wp_stylesheet_path, $wp_template_path; $themes = array(); if ( wp_installing() && 'wp-activate.php' !== $pagenow ) { return $themes; } if ( is_child_theme() ) { $themes[] = $wp_stylesheet_path; } $themes[] = $wp_template_path; /* * 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; }