Make WordPress Core


Ignore:
Timestamp:
02/19/2025 02:50:08 PM (15 months ago)
Author:
Bernhard Reiter
Message:

Block Hooks: Add function to encapsulate wrapping in ad-hoc parent.

Introduce a new function, apply_block_hooks_to_content_from_post_object, to colocate the logic used to temporarily wrap content in a parent block (with ignoredHookedBlocks information fetched from post meta) alongside the call to apply_block_hooks_to_content. Fetching that information from post meta is required for all block types that get their content from post objects, i.e. Post Content, Synced Pattern, and Navigation blocks.

Additionally, the newly introduced function contains logic to ensure that insertion of a hooked block into the first_child or last_child position of a given Post Content block works, even if that block only contains "classic" markup (i.e. no blocks).

Props bernhard-reiter, gziolo, mamaduka.
Fixes #61074, #62716.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r59837 r59838  
    198198add_filter( 'the_title', 'trim' );
    199199
    200 add_filter( 'the_content', 'apply_block_hooks_to_content', 8 ); // BEFORE do_blocks().
     200add_filter( 'the_content', 'apply_block_hooks_to_content_from_post_object', 8 ); // BEFORE do_blocks().
    201201add_filter( 'the_content', 'do_blocks', 9 );
    202202add_filter( 'the_content', 'wptexturize' );
Note: See TracChangeset for help on using the changeset viewer.