equal
deleted
inserted
replaced
5 * @package WordPress |
5 * @package WordPress |
6 * @since 5.8.0 |
6 * @since 5.8.0 |
7 */ |
7 */ |
8 |
8 |
9 /** |
9 /** |
10 * Class representing a current block editor context. |
10 * Contains information about a block editor being rendered. |
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. |
|
15 * |
11 * |
16 * @since 5.8.0 |
12 * @since 5.8.0 |
17 */ |
13 */ |
18 final class WP_Block_Editor_Context { |
14 final class WP_Block_Editor_Context { |
19 /** |
15 /** |
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. |
21 * |
33 * |
22 * @since 5.8.0 |
34 * @since 5.8.0 |
23 * |
35 * |
24 * @var WP_Post|null |
36 * @var WP_Post|null |
25 */ |
37 */ |
33 * @since 5.8.0 |
45 * @since 5.8.0 |
34 * |
46 * |
35 * @param array $settings The list of optional settings to expose in a given context. |
47 * @param array $settings The list of optional settings to expose in a given context. |
36 */ |
48 */ |
37 public function __construct( array $settings = array() ) { |
49 public function __construct( array $settings = array() ) { |
|
50 if ( isset( $settings['name'] ) ) { |
|
51 $this->name = $settings['name']; |
|
52 } |
38 if ( isset( $settings['post'] ) ) { |
53 if ( isset( $settings['post'] ) ) { |
39 $this->post = $settings['post']; |
54 $this->post = $settings['post']; |
40 } |
55 } |
41 } |
56 } |
42 } |
57 } |