Editor: Make block type aware of the ancestor field

The `ancestor` field was recently added to the `block.json` schema in Gutenberg. See: https://github.com/WordPress/gutenberg/pull/39894.

Props darerodz.
Fixes #55531.


Built from https://develop.svn.wordpress.org/trunk@53084


git-svn-id: http://core.svn.wordpress.org/trunk@52673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
gziolo 2022-04-06 09:47:09 +00:00
parent d7d9102b06
commit a9008e6cc5
4 changed files with 25 additions and 1 deletions

View File

@ -2232,6 +2232,7 @@ function get_block_editor_server_block_settings() {
'styles' => 'styles',
'textdomain' => 'textdomain',
'parent' => 'parent',
'ancestor' => 'ancestor',
'keywords' => 'keywords',
'example' => 'example',
'variations' => 'variations',

View File

@ -58,6 +58,15 @@ class WP_Block_Type {
*/
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.
*
@ -207,6 +216,7 @@ class WP_Block_Type {
* @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()
*
@ -221,6 +231,8 @@ class WP_Block_Type {
* 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 string[] $keywords Additional keywords to produce block type as

View File

@ -266,6 +266,7 @@ class WP_REST_Block_Types_Controller extends WP_REST_Controller {
'category',
'keywords',
'parent',
'ancestor',
'provides_context',
'uses_context',
'supports',
@ -645,6 +646,16 @@ class WP_REST_Block_Types_Controller extends WP_REST_Controller {
'context' => array( 'embed', 'view', 'edit' ),
'readonly' => true,
),
'ancestor' => array(
'description' => __( 'Ancestor blocks.' ),
'type' => array( 'array', 'null' ),
'items' => array(
'type' => 'string',
),
'default' => null,
'context' => array( 'embed', 'view', 'edit' ),
'readonly' => true,
),
'keywords' => $keywords_definition,
'example' => $example_definition,
),

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.0-alpha-53083';
$wp_version = '6.0-alpha-53084';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.