From 3b78c439ca8db7f6f8c89416dbc1d56c71d6a825 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Tue, 28 Nov 2023 17:46:23 +0100 Subject: [PATCH] Inject hooked blocks into modified templates and parts --- src/wp-includes/block-template-utils.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wp-includes/block-template-utils.php b/src/wp-includes/block-template-utils.php index 3f912ad0611b6..9237d1339d02d 100644 --- a/src/wp-includes/block-template-utils.php +++ b/src/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; }