Make WordPress Core


Ignore:
Timestamp:
04/21/2023 10:41:58 AM (18 months ago)
Author:
gziolo
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php

    r54670 r55673  
    238238     * @since 5.5.0
    239239     * @since 5.9.0 Renamed `$block_type` to `$item` to match parent class for PHP 8 named parameter support.
     240     * @since 6.3.0 Added `selectors` field.
    240241     *
    241242     * @param WP_Block_Type   $item    Block type data.
     
    279280                'provides_context',
    280281                'uses_context',
     282                'selectors',
    281283                'supports',
    282284                'styles',
     
    380382     *
    381383     * @since 5.5.0
     384     * @since 6.3.0 Added `selectors` field.
    382385     *
    383386     * @return array Item schema data.
     
    516519                        'type' => 'string',
    517520                    ),
     521                    'context'     => array( 'embed', 'view', 'edit' ),
     522                    'readonly'    => true,
     523                ),
     524                'selectors'             => array(
     525                    'description' => __( 'Custom CSS selectors.' ),
     526                    'type'        => 'object',
     527                    'default'     => array(),
     528                    'properties'  => array(),
    518529                    'context'     => array( 'embed', 'view', 'edit' ),
    519530                    'readonly'    => true,
Note: See TracChangeset for help on using the changeset viewer.