Add WP_Block_Editor_Context::$name

Adds a new `WP_Block_Editor_Context::$name` and field. This allows plugin
developers to tell which block editor is being loaded when using filters such as
`allowed_block_types_all` and `block_editor_rest_api_preload_paths`.

Fixes #55301.
Props talldanwp, gziolo, andraganescu.

Built from https://develop.svn.wordpress.org/trunk@52942


git-svn-id: http://core.svn.wordpress.org/trunk@52531 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
noisysocks
2022-03-17 03:37:05 +00:00
parent 7e6d939911
commit d2c2dc1c10
5 changed files with 29 additions and 10 deletions

View File

@@ -49,7 +49,7 @@ foreach ( get_default_block_template_types() as $slug => $template_type ) {
$indexed_template_types[] = $template_type;
}
$block_editor_context = new WP_Block_Editor_Context();
$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' ),

View File

@@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) {
$current_screen = get_current_screen();
$current_screen->is_block_editor( true );
$block_editor_context = new WP_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' ),