Make WordPress Core


Ignore:
Timestamp:
03/17/2022 03:35:13 AM (3 years ago)
Author:
noisysocks
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block-editor-context.php

    r50957 r52942  
    88
    99/**
    10  * Class representing a current block editor context.
    11  *
    12  * The expectation is that block editor can have a different set
    13  * of requirements on every screen where it is used. This class
    14  * allows to define supporting settings that can be used with filters.
     10 * Contains information about a block editor being rendered.
    1511 *
    1612 * @since 5.8.0
     
    1814final class WP_Block_Editor_Context {
    1915    /**
    20      * Post being edited. Optional.
     16     * String that identifies the block editor being rendered. Can be one of:
     17     *
     18     * - `'core/edit-post'`         - The post editor at `/wp-admin/edit.php`.
     19     * - `'core/edit-widgets'`      - The widgets editor at `/wp-admin/widgets.php`.
     20     * - `'core/customize-widgets'` - The widgets editor at `/wp-admin/customize.php`.
     21     * - `'core/edit-site'`         - The site editor at `/wp-admin/site-editor.php`.
     22     *
     23     * Defaults to 'core/edit-post'.
     24     *
     25     * @since 6.0.0
     26     *
     27     * @var string
     28     */
     29    public $name = 'core/edit-post';
     30
     31    /**
     32     * The post being edited by the block editor. Optional.
    2133     *
    2234     * @since 5.8.0
     
    3648     */
    3749    public function __construct( array $settings = array() ) {
     50        if ( isset( $settings['name'] ) ) {
     51            $this->name = $settings['name'];
     52        }
    3853        if ( isset( $settings['post'] ) ) {
    3954            $this->post = $settings['post'];
Note: See TracChangeset for help on using the changeset viewer.