Skip to content

Commit

Permalink
Inject hooked blocks into modified templates and parts
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Jan 30, 2024
1 parent 0e0b100 commit d99cd43
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/wp-includes/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit d99cd43

Please sign in to comment.