Make WordPress Core


Ignore:
Timestamp:
04/26/2022 09:48:20 AM (4 years ago)
Author:
gziolo
Message:

Editor: Register 'lock' attribute for every block on the server

Backports changes from https://github.com/WordPress/gutenberg/pull/40468.

The lock attribute needs to be supported by every block, but currently, it is only done on the client site. As a result, it was causing block rendered API requests to fail when blocks are locked.

Props mamaduka, peterwilsoncc.
See #55567.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/blocks/wpBlockType.php

    r52010 r53268  
    8383                $this->assertSame( $args['render_callback'], $block_type->render_callback );
    8484                $this->assertSame( $args['foo'], $block_type->foo );
     85        }
     86
     87        /*
     88         * @ticket 55567
     89         * @covers WP_Block_Type::set_props
     90         */
     91        public function test_core_attributes() {
     92                $block_type = new WP_Block_Type( 'core/fake', array() );
     93
     94                $this->assertSameSetsWithIndex(
     95                        array(
     96                                'lock' => array( 'type' => 'object' ),
     97                        ),
     98                        $block_type->attributes
     99                );
     100        }
     101
     102        /*
     103         * @ticket 55567
     104         * @covers WP_Block_Type::set_props
     105         */
     106        public function test_core_attributes_matches_custom() {
     107                $block_type = new WP_Block_Type(
     108                        'core/fake',
     109                        array(
     110                                'attributes' => array(
     111                                        'lock' => array(
     112                                                'type' => 'string',
     113                                        ),
     114                                ),
     115                        )
     116                );
     117
     118                // Backward compatibility: Don't override attributes with the same name.
     119                $this->assertSameSetsWithIndex(
     120                        array(
     121                                'lock' => array( 'type' => 'string' ),
     122                        ),
     123                        $block_type->attributes
     124                );
    85125        }
    86126
Note: See TracChangeset for help on using the changeset viewer.