From 6c83a133cbee9a7bbb22d9fb5080e2d73a4c7ba1 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Tue, 26 Sep 2023 14:04:38 +0200 Subject: [PATCH 1/4] Templates: Deprecate _inject_theme_attribute_in_template_part_block(). --- src/wp-includes/block-template-utils.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wp-includes/block-template-utils.php b/src/wp-includes/block-template-utils.php index 87ad50634c108..64129e90bbffd 100644 --- a/src/wp-includes/block-template-utils.php +++ b/src/wp-includes/block-template-utils.php @@ -475,12 +475,15 @@ function _flatten_blocks( &$blocks ) { * stylesheet as a theme attribute into each wp_template_part * * @since 5.9.0 + * @deprecated 6.4.0 Use _inject_theme_attribute_in_template_part_block() with traverse_and_serialize_blocks() instead. * @access private * * @param string $template_content serialized wp_template content. * @return string Updated 'wp_template' content. */ function _inject_theme_attribute_in_block_template_content( $template_content ) { + _deprecated_function( __FUNCTION__, '6.4.0' ); + $has_updated_content = false; $new_content = ''; $template_blocks = parse_blocks( $template_content ); From 8cd9350eb7631a8e7b361491f8fff0661d4d5a31 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Tue, 26 Sep 2023 14:38:45 +0200 Subject: [PATCH 2/4] Add expectedDeprecated --- tests/phpunit/tests/block-template-utils.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/phpunit/tests/block-template-utils.php b/tests/phpunit/tests/block-template-utils.php index e7ee300062b3e..d3cff8dddec79 100644 --- a/tests/phpunit/tests/block-template-utils.php +++ b/tests/phpunit/tests/block-template-utils.php @@ -311,6 +311,9 @@ public function test_not_inject_theme_attribute_non_template_part_block() { ); } + /** + * @expectedDeprecated _inject_theme_attribute_in_block_template_content + */ public function test_inject_theme_attribute_in_block_template_content() { $theme = get_stylesheet(); $content_without_theme_attribute = ''; From 5572a1d71957c109e4644909ed3551006acc08bd Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Tue, 26 Sep 2023 17:24:02 +0200 Subject: [PATCH 3/4] Add 3rd arg to deprecation notice --- src/wp-includes/block-template-utils.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/block-template-utils.php b/src/wp-includes/block-template-utils.php index 64129e90bbffd..bc69c153d736d 100644 --- a/src/wp-includes/block-template-utils.php +++ b/src/wp-includes/block-template-utils.php @@ -475,14 +475,18 @@ function _flatten_blocks( &$blocks ) { * stylesheet as a theme attribute into each wp_template_part * * @since 5.9.0 - * @deprecated 6.4.0 Use _inject_theme_attribute_in_template_part_block() with traverse_and_serialize_blocks() instead. + * @deprecated 6.4.0 Use traverse_and_serialize_blocks( parse_blocks( $template_content ), '_inject_theme_attribute_in_template_part_block' ) instead. * @access private * * @param string $template_content serialized wp_template content. * @return string Updated 'wp_template' content. */ function _inject_theme_attribute_in_block_template_content( $template_content ) { - _deprecated_function( __FUNCTION__, '6.4.0' ); + _deprecated_function( + __FUNCTION__, + '6.4.0', + 'traverse_and_serialize_blocks( parse_blocks( $template_content ), "_inject_theme_attribute_in_template_part_block" )' + ); $has_updated_content = false; $new_content = ''; From eef705625c5ecb6df02cad848347e14112e94169 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Tue, 26 Sep 2023 17:33:41 +0200 Subject: [PATCH 4/4] More PHPDoc --- tests/phpunit/tests/block-template-utils.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/phpunit/tests/block-template-utils.php b/tests/phpunit/tests/block-template-utils.php index d3cff8dddec79..e5d4a7cdc8cd3 100644 --- a/tests/phpunit/tests/block-template-utils.php +++ b/tests/phpunit/tests/block-template-utils.php @@ -312,6 +312,10 @@ public function test_not_inject_theme_attribute_non_template_part_block() { } /** + * @ticket 59452 + * + * @covers ::_inject_theme_attribute_in_block_template_content + * * @expectedDeprecated _inject_theme_attribute_in_block_template_content */ public function test_inject_theme_attribute_in_block_template_content() {