Skip to content

Commit

Permalink
Fix the template parts included in patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto committed Feb 16, 2023
1 parent fe9a6cf commit 6f00002
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions admin/class-create-block-theme-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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'] ) ) {
Expand Down

0 comments on commit 6f00002

Please sign in to comment.