From 5e09e5e18e6742222f05eea92ed25a90546a307a Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Tue, 26 Sep 2023 16:17:18 +0000 Subject: [PATCH] Templates: Deprecate _inject_theme_attribute_in_block_template_content. It can be replaced by passing `_inject_theme_attribute_in_template_part_block` as second argument to `traverse_and_serialize_blocks()`. Per WordPress 6.4 Beta 1, there aren't going to be any more calls in Core to `_inject_theme_attribute_in_block_template_content()`. Note that `_inject_theme_attribute_in_block_template_content` has always had `@access private` set in its PHPDoc. Props gziolo. Fixes #59452. git-svn-id: https://develop.svn.wordpress.org/trunk@56719 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/block-template-utils.php | 7 +++++++ tests/phpunit/tests/block-template-utils.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/wp-includes/block-template-utils.php b/src/wp-includes/block-template-utils.php index 87ad50634c..bc69c153d7 100644 --- a/src/wp-includes/block-template-utils.php +++ b/src/wp-includes/block-template-utils.php @@ -475,12 +475,19 @@ function _flatten_blocks( &$blocks ) { * stylesheet as a theme attribute into each wp_template_part * * @since 5.9.0 + * @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', + 'traverse_and_serialize_blocks( parse_blocks( $template_content ), "_inject_theme_attribute_in_template_part_block" )' + ); + $has_updated_content = false; $new_content = ''; $template_blocks = parse_blocks( $template_content ); diff --git a/tests/phpunit/tests/block-template-utils.php b/tests/phpunit/tests/block-template-utils.php index e7ee300062..e5d4a7cdc8 100644 --- a/tests/phpunit/tests/block-template-utils.php +++ b/tests/phpunit/tests/block-template-utils.php @@ -311,6 +311,13 @@ class Tests_Block_Template_Utils extends WP_UnitTestCase { ); } + /** + * @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() { $theme = get_stylesheet(); $content_without_theme_attribute = '';