From c44e5163b6b758ee4792602e84528feb3f8af181 Mon Sep 17 00:00:00 2001 From: Bernhard Reiter Date: Tue, 26 Sep 2023 16:49:21 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@56722 git-svn-id: http://core.svn.wordpress.org/trunk@56234 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/block-template-utils.php | 44 ---------------------------- wp-includes/deprecated.php | 44 ++++++++++++++++++++++++++++ wp-includes/version.php | 2 +- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/wp-includes/block-template-utils.php b/wp-includes/block-template-utils.php index bc69c153d7..065cfcc037 100644 --- a/wp-includes/block-template-utils.php +++ b/wp-includes/block-template-utils.php @@ -470,50 +470,6 @@ function _flatten_blocks( &$blocks ) { return $all_blocks; } -/** - * Parses wp_template content and injects the active theme's - * 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 ); - - $blocks = _flatten_blocks( $template_blocks ); - foreach ( $blocks as &$block ) { - if ( - 'core/template-part' === $block['blockName'] && - ! isset( $block['attrs']['theme'] ) - ) { - $block['attrs']['theme'] = get_stylesheet(); - $has_updated_content = true; - } - } - - if ( $has_updated_content ) { - foreach ( $template_blocks as &$block ) { - $new_content .= serialize_block( $block ); - } - - return $new_content; - } - - return $template_content; -} - /** * Injects the active theme's stylesheet as a `theme` attribute * into a given template part block. diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index 4cde85f42a..0375d69b4f 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -6040,3 +6040,47 @@ function wp_img_tag_add_decoding_attr( $image, $context ) { return $image; } + +/** + * Parses wp_template content and injects the active theme's + * 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 ); + + $blocks = _flatten_blocks( $template_blocks ); + foreach ( $blocks as &$block ) { + if ( + 'core/template-part' === $block['blockName'] && + ! isset( $block['attrs']['theme'] ) + ) { + $block['attrs']['theme'] = get_stylesheet(); + $has_updated_content = true; + } + } + + if ( $has_updated_content ) { + foreach ( $template_blocks as &$block ) { + $new_content .= serialize_block( $block ); + } + + return $new_content; + } + + return $template_content; +} diff --git a/wp-includes/version.php b/wp-includes/version.php index 0545f2b563..6f7079084b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-alpha-56721'; +$wp_version = '6.4-alpha-56722'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.