summaryrefslogtreecommitdiffstats
path: root/wp-includes/class-wp-block-editor-context.php
blob: bb2d44e5a19c69d41712350cd46b8e6eed7c20cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
 * Blocks API: WP_Block_Editor_Context class
 *
 * @package WordPress
 * @since 5.8.0
 */

/**
 * Contains information about a block editor being rendered.
 *
 * @since 5.8.0
 */
#[AllowDynamicProperties]
final class WP_Block_Editor_Context {
	/**
	 * 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
	 *
	 * @var WP_Post|null
	 */
	public $post = null;

	/**
	 * Constructor.
	 *
	 * Populates optional properties for a given block editor context.
	 *
	 * @since 5.8.0
	 *
	 * @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'];
		}
	}
}