--- a/wp/wp-includes/class-wp-block-type.php Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/class-wp-block-type.php Tue Sep 27 16:37:53 2022 +0200
@@ -59,6 +59,15 @@
public $parent = null;
/**
+ * Setting ancestor makes a block available only inside the specified
+ * block types at any position of the ancestor's block subtree.
+ *
+ * @since 6.0.0
+ * @var array|null
+ */
+ public $ancestor = null;
+
+ /**
* Block type icon.
*
* @since 5.5.0
@@ -79,7 +88,7 @@
* in search interfaces.
*
* @since 5.5.0
- * @var array
+ * @var string[]
*/
public $keywords = array();
@@ -156,7 +165,7 @@
public $provides_context = null;
/**
- * Block type editor script handle.
+ * Block type editor only script handle.
*
* @since 5.0.0
* @var string|null
@@ -164,7 +173,7 @@
public $editor_script = null;
/**
- * Block type front end script handle.
+ * Block type front end and editor script handle.
*
* @since 5.0.0
* @var string|null
@@ -172,7 +181,15 @@
public $script = null;
/**
- * Block type editor style handle.
+ * Block type front end only script handle.
+ *
+ * @since 5.9.0
+ * @var string|null
+ */
+ public $view_script = null;
+
+ /**
+ * Block type editor only style handle.
*
* @since 5.0.0
* @var string|null
@@ -180,7 +197,7 @@
public $editor_style = null;
/**
- * Block type front end style handle.
+ * Block type front end and editor style handle.
*
* @since 5.0.0
* @var string|null
@@ -188,6 +205,16 @@
public $style = null;
/**
+ * Attributes supported by every block.
+ *
+ * @since 6.0.0
+ * @var array
+ */
+ const GLOBAL_ATTRIBUTES = array(
+ 'lock' => array( 'type' => 'object' ),
+ );
+
+ /**
* Constructor.
*
* Will populate object properties from the provided arguments.
@@ -198,6 +225,8 @@
* `uses_context`, and `provides_context` properties.
* @since 5.6.0 Added the `api_version` property.
* @since 5.8.0 Added the `variations` property.
+ * @since 5.9.0 Added the `view_script` property.
+ * @since 6.0.0 Added the `ancestor` property.
*
* @see register_block_type()
*
@@ -212,9 +241,11 @@
* search interfaces to arrange block types by category.
* @type array|null $parent Setting parent lets a block require that it is only
* available when nested within the specified blocks.
+ * @type array|null $ancestor Setting ancestor makes a block available only inside the specified
+ * block types at any position of the ancestor's block subtree.
* @type string|null $icon Block type icon.
* @type string $description A detailed block type description.
- * @type array $keywords Additional keywords to produce block type as
+ * @type string[] $keywords Additional keywords to produce block type as
* result in search interfaces.
* @type string|null $textdomain The translation textdomain.
* @type array $styles Alternative block styles.
@@ -225,10 +256,11 @@
* @type array|null $attributes Block type attributes property schemas.
* @type array $uses_context Context values inherited by blocks of this type.
* @type array|null $provides_context Context provided by blocks of this type.
- * @type string|null $editor_script Block type editor script handle.
- * @type string|null $script Block type front end script handle.
- * @type string|null $editor_style Block type editor style handle.
- * @type string|null $style Block type front end style handle.
+ * @type string|null $editor_script Block type editor only script handle.
+ * @type string|null $script Block type front end and editor script handle.
+ * @type string|null $view_script Block type front end only script handle.
+ * @type string|null $editor_style Block type editor only style handle.
+ * @type string|null $style Block type front end and editor style handle.
* }
*/
public function __construct( $block_type, $args = array() ) {
@@ -333,6 +365,18 @@
$args['name'] = $this->name;
+ // Setup attributes if needed.
+ if ( ! isset( $args['attributes'] ) || ! is_array( $args['attributes'] ) ) {
+ $args['attributes'] = array();
+ }
+
+ // Register core attributes.
+ foreach ( static::GLOBAL_ATTRIBUTES as $attr_key => $attr_schema ) {
+ if ( ! array_key_exists( $attr_key, $args['attributes'] ) ) {
+ $args['attributes'][ $attr_key ] = $attr_schema;
+ }
+ }
+
/**
* Filters the arguments for registering a block type.
*