From b44637c00c905c51c096bbe271c61d1c1c479945 Mon Sep 17 00:00:00 2001 From: Bernhard Reiter Date: Tue, 10 Oct 2023 13:21:22 +0000 Subject: [PATCH] Patterns: Inject `theme` attribute into Template Part blocks. [56805] introduced a regression: The `theme` attribute was no longer injected into Template Part blocks inside of patterns. This caused errors on the frontend, where instead of a given template part, an error message such as `Template part has been deleted or is unavailable: header` was seen. This changeset rectifies that problem, and adds unit test coverage to guard against future regressions. Follow-up to [56805]. Props scruffian, gziolo. Fixes #59583. Built from https://develop.svn.wordpress.org/trunk@56818 git-svn-id: http://core.svn.wordpress.org/trunk@56330 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-block-patterns-registry.php | 7 +++++-- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-block-patterns-registry.php b/wp-includes/class-wp-block-patterns-registry.php index d1ef2ad422..e516277e42 100644 --- a/wp-includes/class-wp-block-patterns-registry.php +++ b/wp-includes/class-wp-block-patterns-registry.php @@ -164,12 +164,15 @@ final class WP_Block_Patterns_Registry { */ private function prepare_content( $pattern, $hooked_blocks ) { $content = $pattern['content']; + + $before_block_visitor = '_inject_theme_attribute_in_template_part_block'; + $after_block_visitor = null; if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) { - $blocks = parse_blocks( $content ); $before_block_visitor = make_before_block_visitor( $hooked_blocks, $pattern ); $after_block_visitor = make_after_block_visitor( $hooked_blocks, $pattern ); - $content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor ); } + $blocks = parse_blocks( $content ); + $content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor ); return $content; } diff --git a/wp-includes/version.php b/wp-includes/version.php index aa4d904018..f4fc6ae597 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-beta2-56817'; +$wp_version = '6.4-beta2-56818'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.