diff --git a/lib/compat/wordpress-5.9/block-template-utils.php b/lib/compat/wordpress-5.9/block-template-utils.php index 2ecc53b121ade..37ae365ccc4f0 100644 --- a/lib/compat/wordpress-5.9/block-template-utils.php +++ b/lib/compat/wordpress-5.9/block-template-utils.php @@ -462,6 +462,7 @@ function _inject_theme_attribute_in_block_template_content( $template_content ) */ function _remove_theme_attribute_in_block_template_content( $template_content ) { $has_updated_content = false; + $new_content = ''; $template_blocks = parse_blocks( $template_content ); $blocks = _flatten_blocks( $template_blocks ); @@ -476,7 +477,11 @@ function _remove_theme_attribute_in_block_template_content( $template_content ) return $template_content; } - return $template_content; + foreach ( $template_blocks as $block ) { + $new_content .= serialize_block( $block ); + } + + return $new_content; } }