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/tests/phpunit/tests/rest-api/rest-block-type-controller.php

    r57493 r57521  
    208208            'parent'           => 'invalid_parent',
    209209            'ancestor'         => 'invalid_ancestor',
     210            'allowed_blocks'   => 'invalid_allowed_blocks',
    210211            'icon'             => true,
    211212            'description'      => true,
     
    238239        $this->assertSameSets( array( 'invalid_parent' ), $data['parent'] );
    239240        $this->assertSameSets( array( 'invalid_ancestor' ), $data['ancestor'] );
     241        $this->assertSameSets( array( 'invalid_allowed_blocks' ), $data['allowed_blocks'] );
    240242        $this->assertNull( $data['icon'] );
    241243        $this->assertSame( '1', $data['description'] );
     
    284286            'parent'           => false,
    285287            'ancestor'         => false,
     288            'allowed_blocks'   => false,
    286289            'icon'             => false,
    287290            'description'      => false,
     
    314317        $this->assertSameSets( array(), $data['parent'] );
    315318        $this->assertSameSets( array(), $data['ancestor'] );
     319        $this->assertSameSets( array(), $data['allowed_blocks'] );
    316320        $this->assertNull( $data['icon'] );
    317321        $this->assertSame( '', $data['description'] );
     
    551555     * @ticket 57585
    552556     * @ticket 59346
     557     * @ticket 60403
    553558     */
    554559    public function test_get_item_schema() {
     
    558563        $data       = $response->get_data();
    559564        $properties = $data['schema']['properties'];
    560         $this->assertCount( 31, $properties );
     565        $this->assertCount( 32, $properties );
    561566        $this->assertArrayHasKey( 'api_version', $properties );
    562567        $this->assertArrayHasKey( 'name', $properties );
     
    565570        $this->assertArrayHasKey( 'parent', $properties );
    566571        $this->assertArrayHasKey( 'ancestor', $properties );
     572        $this->assertArrayHasKey( 'allowed_blocks', $properties );
    567573        $this->assertArrayHasKey( 'icon', $properties );
    568574        $this->assertArrayHasKey( 'description', $properties );
     
    697703            'parent',
    698704            'ancestor',
     705            'allowedBlocks',
    699706            'icon',
    700707            'description',
Note: See TracChangeset for help on using the changeset viewer.