get_core_default_theme example

$has_unused_themes   = false;
        $show_unused_themes  = true;
        $using_default_theme = false;

        // Populate a list of all themes available in the install.         $all_themes   = wp_get_themes();
        $active_theme = wp_get_theme();

        // If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme.         $default_theme = wp_get_theme( WP_DEFAULT_THEME );
        if ( ! $default_theme->exists() ) {
            $default_theme = WP_Theme::get_core_default_theme();
        }

        if ( $default_theme ) {
            $has_default_theme = true;

            if (
                $active_theme->get_stylesheet() === $default_theme->get_stylesheet()
            ||
                is_child_theme() && $active_theme->get_template() === $default_theme->get_template()
            ) {
                $using_default_theme = true;
            }

    do_action( 'populate_options' );

    // If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme.     $stylesheet = WP_DEFAULT_THEME;
    $template   = WP_DEFAULT_THEME;
    $theme      = wp_get_theme( WP_DEFAULT_THEME );
    if ( ! $theme->exists() ) {
        $theme = WP_Theme::get_core_default_theme();
    }

    // If we can't find a core default theme, WP_DEFAULT_THEME is the best we can do.     if ( $theme ) {
        $stylesheet = $theme->get_stylesheet();
        $template   = $theme->get_template();
    }

    $timezone_string = '';
    $gmt_offset      = 0;
    /* * translators: default GMT offset or timezone string. Must be either a valid offset (-12 to 14) * or a valid timezone string (America/New_York). See https://www.php.net/manual/en/timezones.php * for all timezone strings currently supported by PHP. * * Important: When a previous timezone string, like `Europe/Kiev`, has been superseded by an * updated one, like `Europe/Kyiv`, as a rule of thumb, the **old** timezone name should be used * in the "translation" to allow for the default timezone setting to be PHP cross-version compatible, * as old timezone names will be recognized in new PHP versions, while new timezone names cannot * be recognized in old PHP versions. * * To verify which timezone strings are available in the _oldest_ PHP version supported, you can * use https://3v4l.org/6YQAt#v5.6.20 and replace the "BR" (Brazil) in the code line with the * country code for which you want to look up the supported timezone names. */
/** * If we're in an invalid state but WP_DEFAULT_THEME doesn't exist, * switch to the latest core default theme that's installed. * * If it turns out that this latest core default theme is our current * theme, then there's nothing we can do about that, so we have to bail, * rather than going into an infinite loop. (This is why there are * checks against WP_DEFAULT_THEME above, also.) We also can't do anything * if it turns out there is no default theme installed. (That's `false`.) */
    $default = WP_Theme::get_core_default_theme();
    if ( false === $default || get_stylesheet() == $default->get_stylesheet() ) {
        return true;
    }

    switch_theme( $default->get_stylesheet() );
    return false;
}

/** * Validates the theme requirements for WordPress version and PHP version. * * Uses the information from `Requires at least` and `Requires PHP` headers * defined in the theme's `style.css` file. * * @since 5.5.0 * @since 5.8.0 Removed support for using `readme.txt` as a fallback. * * @param string $stylesheet Directory name for the theme. * @return true|WP_Error True if requirements are met, WP_Error on failure. */
Home | Imprint | This part of the site doesn't use cookies.