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/block-templates/base.php

    r57594 r57627  
    4040                'post_name'    => 'my_template',
    4141                'post_title'   => 'My Template',
    42                 'post_content' => '<!-- wp:heading {"level":1} --><h1>Template</h1><!-- /wp:heading -->',
     42                'post_content' => '<!-- wp:heading {"level":1,"metadata":{"ignoredHookedBlocks":["tests/ignored"]}} --><h1>Template</h1><!-- /wp:heading -->',
    4343                'post_excerpt' => 'Description of my template',
    4444                'tax_input'    => array(
     
    5858                'post_name'    => 'my_template_part',
    5959                'post_title'   => 'My Template Part',
    60                 'post_content' => '<!-- wp:heading {"level":2} --><h2>Template Part</h2><!-- /wp:heading -->',
     60                'post_content' => '<!-- wp:heading {"level":2,"metadata":{"ignoredHookedBlocks":["tests/ignored"]}} --><h2>Template Part</h2><!-- /wp:heading -->',
    6161                'post_excerpt' => 'Description of my template part',
    6262                'tax_input'    => array(
Note: See TracChangeset for help on using the changeset viewer.