From c193c9936bf18a15c512596108985efe09fb2b86 Mon Sep 17 00:00:00 2001 From: Bernhard Reiter Date: Mon, 12 Feb 2024 13:15:09 +0000 Subject: [PATCH] Block Hooks: Inject hooked blocks into modified templates and parts. Using the new technique introduced in [57157] of using a `metadata.ignoredHookedBlocks` attribute in the anchor block to store information about whether or not a hooked block should be considered for injection, extend said injection to encompass ''modified'' templates and parts. Fixes #59646. Props gziolo, matveb. Built from https://develop.svn.wordpress.org/trunk@57594 git-svn-id: http://core.svn.wordpress.org/trunk@57095 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/block-template-utils.php | 8 ++++++++ wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/wp-includes/block-template-utils.php b/wp-includes/block-template-utils.php index 3f912ad061..9237d1339d 100644 --- a/wp-includes/block-template-utils.php +++ b/wp-includes/block-template-utils.php @@ -901,6 +901,14 @@ function _build_block_template_result_from_post( $post ) { } } + $hooked_blocks = get_hooked_blocks(); + if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) { + $before_block_visitor = make_before_block_visitor( $hooked_blocks, $template ); + $after_block_visitor = make_after_block_visitor( $hooked_blocks, $template ); + $blocks = parse_blocks( $template->content ); + $template->content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor ); + } + return $template; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 24d2664786..af95c11b41 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5-alpha-57593'; +$wp_version = '6.5-alpha-57594'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.