Geen omschrijving

class-wp-block-editor-context.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Blocks API: WP_Block_Editor_Context class
  4. *
  5. * @package WordPress
  6. * @since 5.8.0
  7. */
  8. /**
  9. * Contains information about a block editor being rendered.
  10. *
  11. * @since 5.8.0
  12. */
  13. final class WP_Block_Editor_Context {
  14. /**
  15. * String that identifies the block editor being rendered. Can be one of:
  16. *
  17. * - `'core/edit-post'` - The post editor at `/wp-admin/edit.php`.
  18. * - `'core/edit-widgets'` - The widgets editor at `/wp-admin/widgets.php`.
  19. * - `'core/customize-widgets'` - The widgets editor at `/wp-admin/customize.php`.
  20. * - `'core/edit-site'` - The site editor at `/wp-admin/site-editor.php`.
  21. *
  22. * Defaults to 'core/edit-post'.
  23. *
  24. * @since 6.0.0
  25. *
  26. * @var string
  27. */
  28. public $name = 'core/edit-post';
  29. /**
  30. * The post being edited by the block editor. Optional.
  31. *
  32. * @since 5.8.0
  33. *
  34. * @var WP_Post|null
  35. */
  36. public $post = null;
  37. /**
  38. * Constructor.
  39. *
  40. * Populates optional properties for a given block editor context.
  41. *
  42. * @since 5.8.0
  43. *
  44. * @param array $settings The list of optional settings to expose in a given context.
  45. */
  46. public function __construct( array $settings = array() ) {
  47. if ( isset( $settings['name'] ) ) {
  48. $this->name = $settings['name'];
  49. }
  50. if ( isset( $settings['post'] ) ) {
  51. $this->post = $settings['post'];
  52. }
  53. }
  54. }