Skip to content

Commit 5e09e5e

Browse files
committed
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
1 parent 2e86337 commit 5e09e5e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/wp-includes/block-template-utils.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,19 @@ function _flatten_blocks( &$blocks ) {
475475
* stylesheet as a theme attribute into each wp_template_part
476476
*
477477
* @since 5.9.0
478+
* @deprecated 6.4.0 Use traverse_and_serialize_blocks( parse_blocks( $template_content ), '_inject_theme_attribute_in_template_part_block' ) instead.
478479
* @access private
479480
*
480481
* @param string $template_content serialized wp_template content.
481482
* @return string Updated 'wp_template' content.
482483
*/
483484
function _inject_theme_attribute_in_block_template_content( $template_content ) {
485+
_deprecated_function(
486+
__FUNCTION__,
487+
'6.4.0',
488+
'traverse_and_serialize_blocks( parse_blocks( $template_content ), "_inject_theme_attribute_in_template_part_block" )'
489+
);
490+
484491
$has_updated_content = false;
485492
$new_content = '';
486493
$template_blocks = parse_blocks( $template_content );

tests/phpunit/tests/block-template-utils.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,13 @@ public function test_not_inject_theme_attribute_non_template_part_block() {
311311
);
312312
}
313313

314+
/**
315+
* @ticket 59452
316+
*
317+
* @covers ::_inject_theme_attribute_in_block_template_content
318+
*
319+
* @expectedDeprecated _inject_theme_attribute_in_block_template_content
320+
*/
314321
public function test_inject_theme_attribute_in_block_template_content() {
315322
$theme = get_stylesheet();
316323
$content_without_theme_attribute = '<!-- wp:template-part {"slug":"header","align":"full", "tagName":"header","className":"site-header"} /-->';

0 commit comments

Comments
 (0)