Make WordPress Core


Ignore:
Timestamp:
09/12/2022 01:12:21 PM (4 years ago)
Author:
gziolo
Message:

Blocks: Add new render property in block.json for block types

New render field in block.json file that accepts a string value. It allows to pass a path to the PHP file that is going to be used to render the block on the server. Related PR in Gutenberg: ​https://github.com/WordPress/gutenberg/pull/42430.

Props spacedmonkey, luisherranz, welcher, noisysocks, matveb, fabiankaegy, aristath, zieladam.
Fixes #53148.

File:
1 edited

Legend:

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

    r53157 r54132  
    4848                        $registry->unregister( 'core/dynamic' );
    4949                }
     50                if ( $registry->is_registered( 'tests/notice' ) ) {
     51                        $registry->unregister( 'tests/notice' );
     52                }
    5053
    5154                parent::tear_down();
    … …  
    237240                );
    238241        }
     242
     243        /**
     244         * @ticket 53148
     245         */
     246        public function test_render_field_in_block_json() {
     247                $result = register_block_type(
     248                        DIR_TESTDATA . '/blocks/notice'
     249                );
     250
     251                $actual_content = do_blocks( '<!-- wp:tests/notice {"message":"Hello from the test"} --><!-- /wp:tests/notice -->' );
     252                $this->assertSame( '<p class="wp-block-tests-notice">Hello from the test</p>', trim( $actual_content ) );
     253        }
     254
    239255
    240256        /**
Note: See TracChangeset for help on using the changeset viewer.