get_block_editor_theme_styles example

$indexed_template_types = array();
foreach ( get_default_block_template_types() as $slug => $template_type ) {
    $template_type['slug']    = (string) $slug;
    $indexed_template_types[] = $template_type;
}

$block_editor_context = new WP_Block_Editor_Context( array( 'name' => 'core/edit-site' ) );
$custom_settings      = array(
    'siteUrl'                   => site_url(),
    'postsPerPage'              => get_option( 'posts_per_page' ),
    'styles'                    => get_block_editor_theme_styles(),
    'defaultTemplateTypes'      => $indexed_template_types,
    'defaultTemplatePartAreas'  => get_allowed_block_template_part_areas(),
    'supportsLayout'            => wp_theme_has_theme_json(),
    'supportsTemplatePartsMode' => ! wp_is_block_theme() && current_theme_supports( 'block-template-parts' ),
);

// Add additional back-compat patterns registered by `current_screen` et al. $custom_settings['__experimentalAdditionalBlockPatterns']          = WP_Block_Patterns_Registry::get_instance()->get_all_registered( true );
$custom_settings['__experimentalAdditionalBlockPatternCategories'] = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered( true );

$editor_settings = get_block_editor_settings( $custom_settings$block_editor_context );

$block_editor_context = new WP_Block_Editor_Context( array( 'name' => 'core/edit-widgets' ) );

$preload_paths = array(
    array( rest_get_route_for_post_type_items( 'attachment' ), 'OPTIONS' ),
    '/wp/v2/widget-types?context=edit&per_page=-1',
    '/wp/v2/sidebars?context=edit&per_page=-1',
    '/wp/v2/widgets?context=edit&per_page=-1&_embed=about',
);
block_editor_rest_api_preload( $preload_paths$block_editor_context );

$editor_settings = get_block_editor_settings(
    array_merge( get_legacy_widget_block_editor_settings(), array( 'styles' => get_block_editor_theme_styles() ) ),
    $block_editor_context
);

// The widgets editor does not support the Block Directory, so don't load any of // its assets. This also prevents 'wp-editor' from being enqueued which we // cannot load in the widgets screen because many widget scripts rely on `wp.editor`. remove_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' );

wp_add_inline_script(
    'wp-edit-widgets',
    sprintf(
        
'css'            => 'base-layout-styles',
            '__unstableType' => 'base-layout',
            'isGlobalStyles' => true,
        );
        $actual_css    = wp_get_global_stylesheet( array( $block_classes['css'] ) );
        if ( '' !== $actual_css ) {
            $block_classes['css'] = $actual_css;
            $global_styles[]      = $block_classes;
        }
    }

    $editor_settings['styles'] = array_merge( $global_stylesget_block_editor_theme_styles() );

    $editor_settings['__experimentalFeatures'] = wp_get_global_settings();
    // These settings may need to be updated based on data coming from theme.json sources.     if ( isset( $editor_settings['__experimentalFeatures']['color']['palette'] ) ) {
        $colors_by_origin          = $editor_settings['__experimentalFeatures']['color']['palette'];
        $editor_settings['colors'] = isset( $colors_by_origin['custom'] ) ?
            $colors_by_origin['custom'] : (
                isset( $colors_by_origin['theme'] ) ?
                    $colors_by_origin['theme'] :
                    $colors_by_origin['default']
            );
    }
Home | Imprint | This part of the site doesn't use cookies.