wp_get_active_and_valid_themes

The timeline below displays how wordpress function wp_get_active_and_valid_themes has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * Retrieves an array of active and valid themes.
 *
 * While upgrading or installing WordPress, no themes are returned.
 *
 * @since 5.1.0
 * @access private
 *
 * @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.
 *
 * @return string[] Array of absolute paths to theme directories.
 */
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;
}

WordPress Version: 6.4

/**
 * Retrieves an array of active and valid themes.
 *
 * While upgrading or installing WordPress, no themes are returned.
 *
 * @since 5.1.0
 * @access private
 *
 * @global string $pagenow The filename of the current screen.
 *
 * @return string[] Array of absolute paths to theme directories.
 */
function wp_get_active_and_valid_themes()
{
    global $pagenow;
    $themes = array();
    if (wp_installing() && 'wp-activate.php' !== $pagenow) {
        return $themes;
    }
    $stylesheet_path = get_stylesheet_directory();
    $template_path = get_template_directory();
    if ($template_path !== $stylesheet_path) {
        $themes[] = $stylesheet_path;
    }
    $themes[] = $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;
}

WordPress Version: 6.1

/**
 * Retrieves an array of active and valid themes.
 *
 * While upgrading or installing WordPress, no themes are returned.
 *
 * @since 5.1.0
 * @access private
 *
 * @global string $pagenow The filename of the current screen.
 *
 * @return string[] Array of absolute paths to theme directories.
 */
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;
}

WordPress Version: 5.4

/**
 * Retrieves an array of active and valid themes.
 *
 * While upgrading or installing WordPress, no themes are returned.
 *
 * @since 5.1.0
 * @access private
 *
 * @return string[] Array of absolute paths to theme directories.
 */
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;
}

WordPress Version: 5.2

/**
 * Retrieves an array of active and valid themes.
 *
 * While upgrading or installing WordPress, no themes are returned.
 *
 * @since 5.1.0
 * @access private
 *
 * @return array Array of paths to theme directories.
 */
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;
}

WordPress Version: 5.1

/**
 * Retrieves an array of active and valid themes.
 *
 * While upgrading or installing WordPress, no themes are returned.
 *
 * @since 5.1.0
 * @access private
 *
 * @return array Array of paths to theme directories.
 */
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;
    return $themes;
}