Make WordPress Core


Ignore:
Timestamp:
02/13/2024 03:10:21 PM (3 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/getHookedBlocks.php

    r57172 r57627  
    137137     * @ticket 59313
    138138     * @ticket 60008
     139     * @ticket 60506
    139140     *
    140141     * @covers ::get_hooked_blocks
     
    151152        );
    152153        $this->assertStringContainsString(
    153             '<!-- wp:post-content {"layout":{"type":"constrained"},"metadata":{"ignoredHookedBlocks":["tests/hooked-after"]}} /-->'
     154            '<!-- wp:post-content {"layout":{"type":"constrained"}} /-->'
    154155            . '<!-- wp:tests/hooked-after /-->',
    155156            $template->content
     
    168169     * @ticket 59313
    169170     * @ticket 60008
     171     * @ticket 60506
    170172     *
    171173     * @covers ::get_hooked_blocks
     
    179181        $this->assertStringContainsString(
    180182            '<!-- wp:tests/hooked-before /-->'
    181             . '<!-- wp:navigation {"layout":{"type":"flex","setCascadingProperties":true,"justifyContent":"right"},"metadata":{"ignoredHookedBlocks":["tests/hooked-before"]}} /-->',
     183            . '<!-- wp:navigation {"layout":{"type":"flex","setCascadingProperties":true,"justifyContent":"right"}} /-->',
    182184            $template->content
    183185        );
     
    199201     * @ticket 59313
    200202     * @ticket 60008
     203     * @ticket 60506
    201204     *
    202205     * @covers ::get_hooked_blocks
     
    219222        );
    220223        $this->assertStringContainsString(
    221             '<!-- wp:comments {"metadata":{"ignoredHookedBlocks":["tests/hooked-first-child"]}} -->'
     224            '<!-- wp:comments -->'
    222225            . '<div class="wp-block-comments">'
    223226            . '<!-- wp:tests/hooked-first-child /-->',
Note: See TracChangeset for help on using the changeset viewer.