mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Editor: Add selectors field to block type definition
Adds support for the new selectors property for block types. It adds it to the allowed metadata when registering a block type, makes the WP_Block_Type class aware of it, exposes it through the block types REST API, and the get_block_editor_server_block_settings function. Corresponding work in the Gutenberg plugin: https://github.com/WordPress/gutenberg/pull/46496. Fixes #57585. Props aaronrobertshaw, hellofromTonya. git-svn-id: https://develop.svn.wordpress.org/trunk@55673 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -237,6 +237,7 @@ class WP_REST_Block_Types_Controller extends WP_REST_Controller {
|
||||
*
|
||||
* @since 5.5.0
|
||||
* @since 5.9.0 Renamed `$block_type` to `$item` to match parent class for PHP 8 named parameter support.
|
||||
* @since 6.3.0 Added `selectors` field.
|
||||
*
|
||||
* @param WP_Block_Type $item Block type data.
|
||||
* @param WP_REST_Request $request Full details about the request.
|
||||
@@ -278,6 +279,7 @@ class WP_REST_Block_Types_Controller extends WP_REST_Controller {
|
||||
'ancestor',
|
||||
'provides_context',
|
||||
'uses_context',
|
||||
'selectors',
|
||||
'supports',
|
||||
'styles',
|
||||
'textdomain',
|
||||
@@ -379,6 +381,7 @@ class WP_REST_Block_Types_Controller extends WP_REST_Controller {
|
||||
* Retrieves the block type' schema, conforming to JSON Schema.
|
||||
*
|
||||
* @since 5.5.0
|
||||
* @since 6.3.0 Added `selectors` field.
|
||||
*
|
||||
* @return array Item schema data.
|
||||
*/
|
||||
@@ -518,6 +521,14 @@ class WP_REST_Block_Types_Controller extends WP_REST_Controller {
|
||||
'context' => array( 'embed', 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'selectors' => array(
|
||||
'description' => __( 'Custom CSS selectors.' ),
|
||||
'type' => 'object',
|
||||
'default' => array(),
|
||||
'properties' => array(),
|
||||
'context' => array( 'embed', 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'supports' => array(
|
||||
'description' => __( 'Block supports.' ),
|
||||
'type' => 'object',
|
||||
|
||||
Reference in New Issue
Block a user