get_block_editor_settings example



        if ( wp_use_widgets_block_editor() ) {
            $block_editor_context = new WP_Block_Editor_Context(
                array(
                    'name' => 'core/customize-widgets',
                )
            );

            $editor_settings = get_block_editor_settings(
                get_legacy_widget_block_editor_settings(),
                $block_editor_context
            );

            wp_add_inline_script(
                'wp-customize-widgets',
                sprintf(
                    'wp.domReady( function() { wp.customizeWidgets.initialize( "widgets-customizer", %s ); } );',
                    wp_json_encode( $editor_settings )
                )
// In order to duplicate classic meta box behavior, we need to run the classic meta box actions. require_once ABSPATH . 'wp-admin/includes/meta-boxes.php';
register_and_do_post_meta_boxes( $post );

// Check if the Custom Fields meta box has been removed at some point. $core_meta_boxes = $wp_meta_boxes[ $current_screen->id ]['normal']['core'];
if ( ! isset( $core_meta_boxes['postcustom'] ) || ! $core_meta_boxes['postcustom'] ) {
    unset( $editor_settings['enableCustomFields'] );
}

$editor_settings = get_block_editor_settings( $editor_settings$block_editor_context );

$init_script = <<<JS ( function() { window._wpLoadBlockEditor = new Promise( function( resolve ) { wp.domReady( function() { resolve( wp.editPost.initializeEditor( 'editor', "%s", %d, %s, %s ) ); } ); } ); } )(); JS;

$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',
    
'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 );

if ( isset( $_GET['postType'] ) && ! isset( $_GET['postId'] ) ) {
    $post_type = get_post_type_object( $_GET['postType'] );
    if ( ! $post_type ) {
        wp_die( __( 'Invalid post type.' ) );
    }
}

$active_global_styles_id = WP_Theme_JSON_Resolver::get_user_global_styles_post_id();
$active_theme            = get_stylesheet();

Home | Imprint | This part of the site doesn't use cookies.