Make WordPress Core


Ignore:
Timestamp:
09/14/2023 01:23:13 PM (3 years ago)
Author:
Bernhard Reiter
Message:

General: Add block_hooks field to block type registration, REST API.

In order to implement Block Hooks, we need to add a new block_hooks field to the WP_Block_Type class, as well as to block registration related functions, the block types REST API controller, etc.

Props gziolo.
Fixes #59346. See #59313.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block-type.php

    r56414 r56587  
    173173         */
    174174        public $provides_context = null;
     175
     176        /**
     177         * Block hooks for this block type.
     178         *
     179         * A block hook is specified by a block type and a relative position.
     180         * The hooked block will be automatically inserted in the given position
     181         * next to the "anchor" block whenever the latter is encountered.
     182         *
     183         * @since 6.4.0
     184         * @var array[]
     185         */
     186        public $block_hooks = array();
    175187
    176188        /**
    … …  
    255267         *              Deprecated the `editor_script`, `script`, `view_script`, `editor_style`, and `style` properties.
    256268         * @since 6.3.0 Added the `selectors` property.
     269         * @since 6.4.0 Added the `block_hooks` property.
    257270         *
    258271         * @see register_block_type()
    … …  
    285298         *     @type string[]      $uses_context             Context values inherited by blocks of this type.
    286299         *     @type string[]|null $provides_context         Context provided by blocks of this type.
     300         *     @type array[]       $block_hooks              Block hooks.
    287301         *     @type string[]      $editor_script_handles    Block type editor only script handles.
    288302         *     @type string[]      $script_handles           Block type front end and editor script handles.
Note: See TracChangeset for help on using the changeset viewer.