is_block_theme example

'_wpnonce'   => wp_create_nonce( 'switch-theme_' . $theme->slug ),
                        'stylesheet' => $theme->slug,
                    ),
                    admin_url( 'themes.php' )
                );
            }
        }

        $is_theme_installed = array_key_exists( $theme->slug, $installed_themes );

        // We only care about installed themes.         $theme->block_theme = $is_theme_installed && wp_get_theme( $theme->slug )->is_block_theme();

        if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
            $customize_url = $theme->block_theme ? admin_url( 'site-editor.php' ) : wp_customize_url( $theme->slug );

            $theme->customize_url = add_query_arg(
                array(
                    'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ),
                ),
                $customize_url
            );
        }

        
$parent = false;
        if ( $theme->parent() ) {
            $parent           = $theme->parent();
            $parents[ $slug ] = $parent->get_stylesheet();
            $parent           = $parent->display( 'Name' );
        }

        $customize_action = null;

        $can_edit_theme_options = current_user_can( 'edit_theme_options' );
        $can_customize          = current_user_can( 'customize' );
        $is_block_theme         = $theme->is_block_theme();

        if ( $is_block_theme && $can_edit_theme_options ) {
            $customize_action = admin_url( 'site-editor.php' );
            if ( $current_theme !== $slug ) {
                $customize_action = add_query_arg( 'wp_theme_preview', $slug$customize_action );
            }
        } elseif ( ! $is_block_theme && $can_customize && $can_edit_theme_options ) {
            $customize_action = wp_customize_url( $slug );
        }
        if ( null !== $customize_action ) {
            $customize_action = add_query_arg(
                
$this->errors = new WP_Error(
                'theme_child_invalid',
                sprintf(
                    /* translators: %s: Template. */
                    __( 'The theme defines itself as its parent theme. Please check the %s header.' ),
                    '<code>Template</code>'
                )
            );
            $this->cache_add(
                'theme',
                array(
                    'block_theme' => $this->is_block_theme(),
                    'headers'     => $this->headers,
                    'errors'      => $this->errors,
                    'stylesheet'  => $this->stylesheet,
                )
            );

            return;
        }

        // (If template is set from cache [and there are no errors], we know it's good.)         if ( ! $this->template ) {
            
/* * Since retrieve_widgets() is called when initializing a theme in the Customizer, * we need to remove the theme mods to avoid overwriting changes made via * the Customizer when accessing wp-admin/widgets.php. */
        if ( 'wp_ajax_customize_save' === current_action() ) {
            remove_theme_mod( 'sidebars_widgets' );
        }
    }

    // Stores classic sidebars for later use by block themes.     if ( $new_theme->is_block_theme() ) {
        set_theme_mod( 'wp_classic_sidebars', $wp_registered_sidebars );
    }

    update_option( 'theme_switched', $old_theme->get_stylesheet() );

    /** * Fires after the theme is switched. * * See {@see 'after_switch_theme'}. * * @since 1.5.0 * @since 4.5.0 Introduced the `$old_theme` parameter. * * @param string $new_name Name of the new theme. * @param WP_Theme $new_theme WP_Theme instance of the new theme. * @param WP_Theme $old_theme WP_Theme instance of the old theme. */
$prepared = $prepare( $support$config$feature$request );

                if ( is_wp_error( $prepared ) ) {
                    continue;
                }

                $data['theme_supports'][ $name ] = $prepared;
            }
        }

        if ( rest_is_field_included( 'is_block_theme', $fields ) ) {
            $data['is_block_theme'] = $theme->is_block_theme();
        }

        $data = $this->add_additional_fields_to_object( $data$request );

        // Wrap the data in a response object.         $response = rest_ensure_response( $data );

        if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) {
            $response->add_links( $this->prepare_links( $theme ) );
        }

        
array(
                'action'     => 'activate',
                'template'   => urlencode( $template ),
                'stylesheet' => urlencode( $stylesheet ),
            ),
            admin_url( 'themes.php' )
        );
        $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );

        $install_actions = array();

        if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) && ! $theme_info->is_block_theme() ) {
            $customize_url = add_query_arg(
                array(
                    'theme'  => urlencode( $stylesheet ),
                    'return' => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ),
                ),
                admin_url( 'customize.php' )
            );

            $install_actions['preview'] = sprintf(
                '<a href="%s" class="hide-if-no-customize load-customize">' .
                '<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
                
Home | Imprint | This part of the site doesn't use cookies.