Skip to content

Commit

Permalink
fixing theme slug in template part linked from a pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto committed Feb 16, 2023
1 parent 6f00002 commit def9cb4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion admin/class-create-block-theme-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ 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()
? strtolower( wp_get_theme()->get( 'Name' ) )
: $_POST['theme']['name'];
}
return $block;
Expand Down

1 comment on commit def9cb4

@coderaaron
Copy link

@coderaaron coderaaron commented on def9cb4 Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been causing me issues today when I overwrite the existing theme because Gutenberg uses get_stylesheet()
https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/template-part/index.php#L25

running the two functions on my dev site I get different values

var_dump(get_stylesheet());
string(21) "kalamazooanimalrescue"
var_dump(wp_get_theme()->get( 'Name' ));
string(23) "Kalamazoo Animal Rescue"

Please sign in to comment.