mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-31 13:37:51 +01:00
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
This commit is contained in:
parent
0543b6216a
commit
c44e5163b6
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user