Make WordPress Core


Ignore:
Timestamp:
02/13/2024 03:10:21 PM (4 months ago)
Author:
Bernhard Reiter
Message:

Block Hooks: Set ignoredHookedBlocks metadata upon saving.

Decouple hooked blocks insertion from setting the metadata.ignoredHookedBlocks attribute on anchor blocks, and perform the latter step upon saving a template or template part to the database. This ensures that anchor blocks that have been newly added to a template (or part) on the client side will also get ignoredHookedBlocks metadata set correctly, thus preserving editor/front-end parity. Hooked block insertion, on the other hand, will continue to happen upon reading a template (or part).

Props gziolo, tomjcafferkey.
Fixes #60506.

File:
1 edited

Legend:

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

    r57172 r57627  
    345345     * @ticket 59476
    346346     * @ticket 60008
     347     * @ticket 60506
    347348     *
    348349     * @covers WP_Block_Patterns_Registry::register
     
    386387        $this->assertCount( 3, $registered );
    387388        $this->assertStringEndsWith( '<!-- wp:tests/my-block /-->', $registered[1]['content'] );
    388         $this->assertStringContainsString( '"metadata":{"ignoredHookedBlocks":["tests/my-block"]}', $registered[1]['content'] );
    389389        $this->assertStringEndsWith( '<!-- wp:tests/my-block /-->', $registered[2]['content'] );
    390         $this->assertStringContainsString( '"metadata":{"ignoredHookedBlocks":["tests/my-block"]}', $registered[2]['content'] );
    391390    }
    392391
     
    419418     * @ticket 59476
    420419     * @ticket 60008
     420     * @ticket 60506
    421421     *
    422422     * @covers WP_Block_Patterns_Registry::register
     
    447447        $pattern = $this->registry->get_registered( 'test/one' );
    448448        $this->assertStringStartsWith( '<!-- wp:tests/my-block /-->', $pattern['content'] );
    449         $this->assertStringContainsString( '"metadata":{"ignoredHookedBlocks":["tests/my-block"]}', $pattern['content'] );
    450449    }
    451450
Note: See TracChangeset for help on using the changeset viewer.