-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] Theme Export: Use a better method to determine the theme name #40829
Conversation
👍 Themes without text domain in style.css should be valid, not all block themes will have translatable strings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
I only have a nitpick about alignment of the =
signs (I believe it's also part of WPCS), but other than that this looks good.
lib/compat/wordpress-6.0/class-gutenberg-rest-edit-site-export-controller.php
Outdated
Show resolved
Hide resolved
…-controller.php Co-authored-by: Ari Stathopoulos <aristath@gmail.com>
I cherry-picked this PR for WordPress 6.0 RC2 with 4ee2055. |
…40829) * Theme Export: Use a better method to determine the theme name * Update lib/compat/wordpress-6.0/class-gutenberg-rest-edit-site-export-controller.php Co-authored-by: Ari Stathopoulos <aristath@gmail.com> Co-authored-by: Ari Stathopoulos <aristath@gmail.com>
@gziolo It looks like
Is there still a chance this can be merged before 6.0-RC3? Thanks! |
@peterwilsoncc, @hellofromtonya - it looks like I cherry-picked this change to
Sure, we will take care of it. Thank you for the ping 👍🏻 |
@@ -76,7 +76,10 @@ public function export() { | |||
return $filename; | |||
} | |||
|
|||
$theme_name = wp_get_theme()->get( 'TextDomain' ); | |||
$stylesheet = get_stylesheet(); | |||
$stylesheet_directories = explode( '/', $stylesheet ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pardon my ignorance and for jumping in here, but is there any reason why basename
couldn't be used instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. It might be even better because basename
can handle both slash (/) and backslash () which often is an issue on Windows machines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done here: https://github.com/WordPress/gutenberg/pull/41058/files
See the same change in the Gutenberg plugin: WordPress/gutenberg#40829. Props scruffian, davidbaumwald, jeremyfelt. See #55567. git-svn-id: https://develop.svn.wordpress.org/trunk@53402 602fd350-edb4-49c9-b593-d223f7449a82
See the same change in the Gutenberg plugin: WordPress/gutenberg#40829. Props scruffian, davidbaumwald, jeremyfelt. See #55567. Built from https://develop.svn.wordpress.org/trunk@53402 git-svn-id: http://core.svn.wordpress.org/trunk@52991 1a063a9b-81f0-0310-95a4-ce76da25c4cd
I committed the changes in WordPress core with https://core.trac.wordpress.org/changeset/53402. It still needs to be backported to |
See the same change in the Gutenberg plugin: WordPress/gutenberg#40829. Props scruffian, davidbaumwald, jeremyfelt. See #55567. Built from https://develop.svn.wordpress.org/trunk@53402 git-svn-id: https://core.svn.wordpress.org/trunk@52991 1a063a9b-81f0-0310-95a4-ce76da25c4cd
See the same change in the Gutenberg plugin: WordPress/gutenberg#40829. Props scruffian, davidbaumwald, jeremyfelt. See #55567. Built from https://develop.svn.wordpress.org/trunk@53402
What?
When a theme doesn't define a TextDomain, the export fails, and we get this error message:
![Screenshot 2022-05-05 at 10 41 01](https://user-images.githubusercontent.com/275961/166898475-be1e64aa-312b-45fa-a8fc-a907f1c80da2.png)
This changes the method for getting the theme name so that it just uses the folder name, which is safer.
Why?
So that themes can still be exported without defining a TextDomain.
How?
This has to use a bit of string manipulation as we don't store the theme slug anywhere, but I think the logic is sound.
Testing Instructions
@WordPress/block-themers