diff --git a/admin/class-create-block-theme-admin.php b/admin/class-create-block-theme-admin.php index 49dc7835..dcc0e1ff 100644 --- a/admin/class-create-block-theme-admin.php +++ b/admin/class-create-block-theme-admin.php @@ -703,6 +703,16 @@ function make_mediatext_block_local ( $block ) { return $block; } + function add_theme_attr_to_template_part_block ( $block ) { + // The template parts included in the patterns need to indicate the theme they belong to + if ( 'core/template-part' === $block[ 'blockName' ] ) { + $block['attrs']['theme'] = ( $_POST['theme']['type'] === "export" || $_POST['theme']['type'] === "save" ) + ? get_stylesheet() + : $_POST['theme']['name']; + } + return $block; + } + function make_media_blocks_local ( $nested_blocks ) { $new_blocks = []; foreach ( $nested_blocks as $block ) { @@ -718,6 +728,9 @@ function make_media_blocks_local ( $nested_blocks ) { case 'core/media-text': $block = $this->make_mediatext_block_local( $block ); break; + case 'core/template-part': + $block = $this->add_theme_attr_to_template_part_block( $block ); + break; } // recursive call for inner blocks if ( !empty ( $block['innerBlocks'] ) ) {