get_stylesheet example

// 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. */
case 'version':
                return $this->get( 'Version' );
            case 'parent_theme':
                return $this->parent() ? $this->parent()->get( 'Name' ) : '';
            case 'template_dir':
                return $this->get_template_directory();
            case 'stylesheet_dir':
                return $this->get_stylesheet_directory();
            case 'template':
                return $this->get_template();
            case 'stylesheet':
                return $this->get_stylesheet();
            case 'screenshot':
                return $this->get_screenshot( 'relative' );
            // 'author' and 'description' did not previously return translated data.             case 'description':
                return $this->display( 'Description' );
            case 'author':
                return $this->display( 'Author' );
            case 'tags':
                return $this->get( 'Tags' );
            case 'theme_root':
                return $this->get_theme_root();
            
return false;
    }

    if ( ! isset( $themes_update ) ) {
        $themes_update = get_site_transient( 'update_themes' );
    }

    if ( ! ( $theme instanceof WP_Theme ) ) {
        return false;
    }

    $stylesheet = $theme->get_stylesheet();

    $html = '';

    if ( isset( $themes_update->response[ $stylesheet ] ) ) {
        $update      = $themes_update->response[ $stylesheet ];
        $theme_name  = $theme->display( 'Name' );
        $details_url = add_query_arg(
            array(
                'TB_iframe' => 'true',
                'width'     => 1024,
                'height'    => 800,
            ),
// 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;
            }
        }

        foreach ( $all_themes as $theme_slug => $theme ) {
            $themes_total++;

            if ( array_key_exists( $theme_slug$theme_updates ) ) {
                
'<p>' . __( '<a href="https://wordpress.org/documentation/article/appearance-theme-file-editor-screen/">Documentation on Editing Themes</a>' ) . '</p>' .
    '<p>' . __( '<a href="https://wordpress.org/documentation/article/editing-files/">Documentation on Editing Files</a>' ) . '</p>' .
    '<p>' . __( '<a href="https://developer.wordpress.org/themes/basics/template-tags/">Documentation on Template Tags</a>' ) . '</p>' .
    '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
);

wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) );

if ( $theme ) {
    $stylesheet = $theme;
} else {
    $stylesheet = get_stylesheet();
}

$theme = wp_get_theme( $stylesheet );

if ( ! $theme->exists() ) {
    wp_die( __( 'The requested theme does not exist.' ) );
}

if ( $theme->errors() && 'theme_no_stylesheet' === $theme->errors()->get_error_code() ) {
    wp_die( __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() );
}

break;
            }
        }

        // Compare based on relative paths.         if ( 0 !== validate_file( $filearray_keys( $allowed_files ) ) ) {
            return new WP_Error( 'disallowed_theme_file', __( 'Sorry, that file cannot be edited.' ) );
        }

        $real_file = $theme->get_stylesheet_directory() . '/' . $file;

        $is_active = ( get_stylesheet() === $stylesheet || get_template() === $stylesheet );

    } else {
        return new WP_Error( 'missing_theme_or_plugin' );
    }

    // Ensure file is real.     if ( ! is_file( $real_file ) ) {
        return new WP_Error( 'file_does_not_exist', __( 'File does not exist! Please double check the name and try again.' ) );
    }

    // Ensure file extension is allowed.
if ( ! $theme instanceof WP_Theme ) {
            $theme = wp_get_theme();
        }

        /* * Bail early if the theme does not support a theme.json. * * Since wp_theme_has_theme_json() only supports the active * theme, the extra condition for whether $theme is the active theme is * present here. */
        if ( $theme->get_stylesheet() === get_stylesheet() && ! wp_theme_has_theme_json() ) {
            return array();
        }

        $user_cpt         = array();
        $post_type_filter = 'wp_global_styles';
        $stylesheet       = $theme->get_stylesheet();
        $args             = array(
            'posts_per_page'         => 1,
            'orderby'                => 'date',
            'order'                  => 'desc',
            'post_type'              => $post_type_filter,
            

            'tryAgain'            => __( 'Try Again' ),
            /* translators: %d: Number of themes. */
            'themesFound'         => __( 'Number of Themes found: %d' ),
            'noThemesFound'       => __( 'No themes found. Try a different search.' ),
            'collapseSidebar'     => __( 'Collapse Sidebar' ),
            'expandSidebar'       => __( 'Expand Sidebar' ),
            /* translators: Hidden accessibility text. */
            'selectFeatureFilter' => __( 'Select one or more Theme features to filter by' ),
        ),
        'installedThemes' => array_keys( $installed_themes ),
        'activeTheme'     => get_stylesheet(),
    )
);

wp_enqueue_script( 'theme' );
wp_enqueue_script( 'updates' );

if ( $tab ) {
    /** * Fires before each of the tabs are rendered on the Install Themes page. * * The dynamic portion of the hook name, `$tab`, refers to the current * theme installation tab. * * Possible hook names include: * * - `install_themes_pre_block-themes` * - `install_themes_pre_dashboard` * - `install_themes_pre_featured` * - `install_themes_pre_new` * - `install_themes_pre_search` * - `install_themes_pre_updated` * - `install_themes_pre_upload` * * @since 2.8.0 * @since 6.1.0 Added the `install_themes_pre_block-themes` hook name. */

    $styles_variables = '';
    if ( in_array( 'variables', $types, true ) ) {
        /* * Only use the default, theme, and custom origins. Why? * Because styles for `blocks` origin are added at a later phase * (i.e. in the render cycle). Here, only the ones in use are rendered. * @see wp_add_global_styles_for_blocks */
        $origins          = array( 'default', 'theme', 'custom' );
        $styles_variables = $tree->get_stylesheet( array( 'variables' )$origins );
        $types            = array_diff( $types, array( 'variables' ) );
    }

    /* * For the remaining types (presets, styles), we do consider origins: * * - themes without theme.json: only the classes for the presets defined by core * - themes with theme.json: the presets and styles classes, both from core and the theme */
    $styles_rest = '';
    if ( ! empty( $types ) ) {
        

        );

        $choices = array( '0' => __( '&mdash; Select &mdash;' ) );
        foreach ( $menus as $menu ) {
            $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '&hellip;' );
        }

        // Attempt to re-map the nav menu location assignments when previewing a theme switch.         $mapped_nav_menu_locations = array();
        if ( ! $this->manager->is_theme_active() ) {
            $theme_mods = get_option( 'theme_mods_' . $this->manager->get_stylesheet(), array() );

            // If there is no data from a previous activation, start fresh.             if ( empty( $theme_mods['nav_menu_locations'] ) ) {
                $theme_mods['nav_menu_locations'] = array();
            }

            $mapped_nav_menu_locations = wp_map_nav_menu_locations( $theme_mods['nav_menu_locations']$this->original_nav_menu_locations );
        }

        foreach ( $locations as $location => $description ) {
            $setting_id = "nav_menu_locations[{$location}]";

            
function wp_get_theme_preview_path( $current_stylesheet = null ) {
    if ( ! current_user_can( 'switch_themes' ) ) {
        return $current_stylesheet;
    }

    $preview_stylesheet = ! empty( $_GET['wp_theme_preview'] ) ? sanitize_text_field( wp_unslash( $_GET['wp_theme_preview'] ) ) : null;
    $wp_theme           = wp_get_theme( $preview_stylesheet );
    if ( ! is_wp_error( $wp_theme->errors() ) ) {
        if ( current_filter() === 'template' ) {
            $theme_path = $wp_theme->get_template();
        } else {
            $theme_path = $wp_theme->get_stylesheet();
        }

        return sanitize_text_field( $theme_path );
    }

    return $current_stylesheet;
}

/** * Adds a middleware to `apiFetch` to set the theme for the preview. * This adds a `wp_theme_preview` URL parameter to API requests from the Site Editor, so they also respond as if the theme is set to the value of the parameter. * * @since 6.3.0 */
/** */
    public function display_rows() {
        $themes = $this->items;

        foreach ( $themes as $theme ) :
            ?> <div class="available-theme"> <?php
            $template   = $theme->get_template();
            $stylesheet = $theme->get_stylesheet();
            $title      = $theme->display( 'Name' );
            $version    = $theme->display( 'Version' );
            $author     = $theme->display( 'Author' );

            $activate_link = wp_nonce_url( 'themes.php?action=activate&amp;template=' . urlencode( $template ) . '&amp;stylesheet=' . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet );

            $actions             = array();
            $actions['activate'] = sprintf(
                '<a href="%s" class="activatelink" title="%s">%s</a>',
                $activate_link,
                /* translators: %s: Theme name. */
                
'blog_id' => 0,
    );
    $args     = wp_parse_args( $args$defaults );

    $theme_directories = search_theme_directories();

    if ( is_array( $wp_theme_directories ) && count( $wp_theme_directories ) > 1 ) {
        /* * Make sure the active theme wins out, in case search_theme_directories() picks the wrong * one in the case of a conflict. (Normally, last registered theme root wins.) */
        $current_theme = get_stylesheet();
        if ( isset( $theme_directories[ $current_theme ] ) ) {
            $root_of_current_theme = get_raw_theme_root( $current_theme );
            if ( ! in_array( $root_of_current_theme$wp_theme_directories, true ) ) {
                $root_of_current_theme = WP_CONTENT_DIR . $root_of_current_theme;
            }
            $theme_directories[ $current_theme ]['theme_root'] = $root_of_current_theme;
        }
    }

    if ( empty( $theme_directories ) ) {
        return array();
    }
$choice['url'] = sanitize_url( $choice['url'] );

            $header_image_data = (object) array(
                'attachment_id' => $choice['attachment_id'],
                'url'           => $choice['url'],
                'thumbnail_url' => $choice['url'],
                'height'        => $choice['height'],
                'width'         => $choice['width'],
            );

            update_post_meta( $choice['attachment_id'], '_wp_attachment_is_custom_header', get_stylesheet() );

            set_theme_mod( 'header_image', $choice['url'] );
            set_theme_mod( 'header_image_data', $header_image_data );

            return;
        }

        if ( in_array( $choice, array( 'remove-header', 'random-default-image', 'random-uploaded-image' ), true ) ) {
            set_theme_mod( 'header_image', $choice );
            remove_theme_mod( 'header_image_data' );

            

function render_block_core_template_part( $attributes ) {
    static $seen_ids = array();

    $template_part_id = null;
    $content          = null;
    $area             = WP_TEMPLATE_PART_AREA_UNCATEGORIZED;

    if (
        isset( $attributes['slug'] ) &&
        isset( $attributes['theme'] ) &&
        get_stylesheet() === $attributes['theme']
    ) {
        $template_part_id    = $attributes['theme'] . '//' . $attributes['slug'];
        $template_part_query = new WP_Query(
            array(
                'post_type'           => 'wp_template_part',
                'post_status'         => 'publish',
                'post_name__in'       => array( $attributes['slug'] ),
                'tax_query'           => array(
                    array(
                        'taxonomy' => 'wp_theme',
                        'field'    => 'name',
                        
Home | Imprint | This part of the site doesn't use cookies.