mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-07 18:50:12 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@52942 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -7,17 +7,29 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class representing a current block editor context.
|
||||
*
|
||||
* The expectation is that block editor can have a different set
|
||||
* of requirements on every screen where it is used. This class
|
||||
* allows to define supporting settings that can be used with filters.
|
||||
* Contains information about a block editor being rendered.
|
||||
*
|
||||
* @since 5.8.0
|
||||
*/
|
||||
final class WP_Block_Editor_Context {
|
||||
/**
|
||||
* Post being edited. Optional.
|
||||
* String that identifies the block editor being rendered. Can be one of:
|
||||
*
|
||||
* - `'core/edit-post'` - The post editor at `/wp-admin/edit.php`.
|
||||
* - `'core/edit-widgets'` - The widgets editor at `/wp-admin/widgets.php`.
|
||||
* - `'core/customize-widgets'` - The widgets editor at `/wp-admin/customize.php`.
|
||||
* - `'core/edit-site'` - The site editor at `/wp-admin/site-editor.php`.
|
||||
*
|
||||
* Defaults to 'core/edit-post'.
|
||||
*
|
||||
* @since 6.0.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name = 'core/edit-post';
|
||||
|
||||
/**
|
||||
* The post being edited by the block editor. Optional.
|
||||
*
|
||||
* @since 5.8.0
|
||||
*
|
||||
@@ -35,6 +47,9 @@ final class WP_Block_Editor_Context {
|
||||
* @param array $settings The list of optional settings to expose in a given context.
|
||||
*/
|
||||
public function __construct( array $settings = array() ) {
|
||||
if ( isset( $settings['name'] ) ) {
|
||||
$this->name = $settings['name'];
|
||||
}
|
||||
if ( isset( $settings['post'] ) ) {
|
||||
$this->post = $settings['post'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user