Make WordPress Core


Ignore:
Timestamp:
02/02/2024 12:59:21 PM (16 months ago)
Author:
gziolo
Message:

Editor: Add allowed_blocks field to block registration and REST API

There is a new block.json field called allowedBlocks, added in Gutenberg in https://github.com/WordPress/gutenberg/pull/58262. This adds support for this new field also on the server.

Props: gziolo, jsnajdr.
Fixes #60403.

File:
1 edited

Legend:

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

    r57493 r57521  
    281281                'parent',
    282282                'ancestor',
     283                'allowed_blocks',
    283284                'provides_context',
    284285                'uses_context',
     
    724725                    'readonly'    => true,
    725726                ),
     727                'allowed_blocks'        => array(
     728                    'description' => __( 'Allowed child block types.' ),
     729                    'type'        => array( 'array', 'null' ),
     730                    'items'       => array(
     731                        'type'    => 'string',
     732                        'pattern' => self::NAME_PATTERN,
     733                    ),
     734                    'default'     => null,
     735                    'context'     => array( 'embed', 'view', 'edit' ),
     736                    'readonly'    => true,
     737                ),
    726738                'keywords'              => $keywords_definition,
    727739                'example'               => $example_definition,
Note: See TracChangeset for help on using the changeset viewer.