Make WordPress Core


Ignore:
Timestamp:
04/21/2023 10:41:58 AM (13 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/class-wp-block-type.php

    r54895 r55673  
    117117     */
    118118    public $variations = array();
     119
     120    /**
     121     * Custom CSS selectors for theme.json style generation.
     122     *
     123     * @since 6.3.0
     124     * @var array
     125     */
     126    public $selectors = array();
    119127
    120128    /**
     
    246254     *              `editor_style_handles`, and `style_handles` properties.
    247255     *              Deprecated the `editor_script`, `script`, `view_script`, `editor_style`, and `style` properties.
     256     * @since 6.3.0 Added the `selectors` property.
    248257     *
    249258     * @see register_block_type()
     
    269278     *     @type array[]       $styles                   Alternative block styles.
    270279     *     @type array[]       $variations               Block variations.
     280     *     @type array         $selectors                Custom CSS selectors for theme.json style generation.
    271281     *     @type array|null    $supports                 Supported features.
    272282     *     @type array|null    $example                  Structured data for the block preview.
Note: See TracChangeset for help on using the changeset viewer.