Skip to content

Commit 166e042

Browse files
committed
Templates: Move old theme attr injection function to deprecated.php.
Move the now-deprecated function `_inject_theme_attribute_in_block_template_content` from `wp-includes/block-template-utils.php` to `wp-includes/deprecated.php`. Follow-up [56719]. Props spacedmonkey, davidbaumwald, mukesh27. See #59452. git-svn-id: https://develop.svn.wordpress.org/trunk@56722 602fd350-edb4-49c9-b593-d223f7449a82
1 parent b5cb86a commit 166e042

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

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

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -470,50 +470,6 @@ function _flatten_blocks( &$blocks ) {
470470
return $all_blocks;
471471
}
472472

473-
/**
474-
* Parses wp_template content and injects the active theme's
475-
* stylesheet as a theme attribute into each wp_template_part
476-
*
477-
* @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.
479-
* @access private
480-
*
481-
* @param string $template_content serialized wp_template content.
482-
* @return string Updated 'wp_template' content.
483-
*/
484-
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-
491-
$has_updated_content = false;
492-
$new_content = '';
493-
$template_blocks = parse_blocks( $template_content );
494-
495-
$blocks = _flatten_blocks( $template_blocks );
496-
foreach ( $blocks as &$block ) {
497-
if (
498-
'core/template-part' === $block['blockName'] &&
499-
! isset( $block['attrs']['theme'] )
500-
) {
501-
$block['attrs']['theme'] = get_stylesheet();
502-
$has_updated_content = true;
503-
}
504-
}
505-
506-
if ( $has_updated_content ) {
507-
foreach ( $template_blocks as &$block ) {
508-
$new_content .= serialize_block( $block );
509-
}
510-
511-
return $new_content;
512-
}
513-
514-
return $template_content;
515-
}
516-
517473
/**
518474
* Injects the active theme's stylesheet as a `theme` attribute
519475
* into a given template part block.

src/wp-includes/deprecated.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6040,3 +6040,47 @@ function wp_img_tag_add_decoding_attr( $image, $context ) {
60406040

60416041
return $image;
60426042
}
6043+
6044+
/**
6045+
* Parses wp_template content and injects the active theme's
6046+
* stylesheet as a theme attribute into each wp_template_part
6047+
*
6048+
* @since 5.9.0
6049+
* @deprecated 6.4.0 Use traverse_and_serialize_blocks( parse_blocks( $template_content ), '_inject_theme_attribute_in_template_part_block' ) instead.
6050+
* @access private
6051+
*
6052+
* @param string $template_content serialized wp_template content.
6053+
* @return string Updated 'wp_template' content.
6054+
*/
6055+
function _inject_theme_attribute_in_block_template_content( $template_content ) {
6056+
_deprecated_function(
6057+
__FUNCTION__,
6058+
'6.4.0',
6059+
'traverse_and_serialize_blocks( parse_blocks( $template_content ), "_inject_theme_attribute_in_template_part_block" )'
6060+
);
6061+
6062+
$has_updated_content = false;
6063+
$new_content = '';
6064+
$template_blocks = parse_blocks( $template_content );
6065+
6066+
$blocks = _flatten_blocks( $template_blocks );
6067+
foreach ( $blocks as &$block ) {
6068+
if (
6069+
'core/template-part' === $block['blockName'] &&
6070+
! isset( $block['attrs']['theme'] )
6071+
) {
6072+
$block['attrs']['theme'] = get_stylesheet();
6073+
$has_updated_content = true;
6074+
}
6075+
}
6076+
6077+
if ( $has_updated_content ) {
6078+
foreach ( $template_blocks as &$block ) {
6079+
$new_content .= serialize_block( $block );
6080+
}
6081+
6082+
return $new_content;
6083+
}
6084+
6085+
return $template_content;
6086+
}

0 commit comments

Comments
 (0)