-
Notifications
You must be signed in to change notification settings - Fork 57
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
Fix/un transposed patterns #567
Conversation
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.
I've just given this a test using Programme, naming the cloned theme Programme Two, but I'm seeing a few issues:
- The cloned theme's slug used in patterns is
programme-two-two
, I think it should beprogramme-two
- I saw this error in the editor after the page reload: Cloning a theme causes critical error #566 -
Parse error: syntax error, unexpected token "-", expecting "(" in /themes/programme-two/functions.php on line 21
Looks like programme-two
is being used as the theme name in the functions.php file, when I guess it should be programme_two
:
This has been updated to address what you mentioned here:
which was reported in #566 This is ready for another test. |
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.
Thanks! I've given this another test.
I'm now seeing programmetwotwo
as the theme slug in the pattern block:
I was expecting this to be programme-two
or programmetwo
. I can see the new theme directory name is programmetwo
, which looks correct.
The issue with the function names in functions.php has been fixed 🎉
I noticed that the hyphen has been removed rather than replaced with an underscore. I think this is fine, just wanted to check if this was the expected behaviour.
Yes, though it's unfortunate. It's impossible (difficult? outside of my ability?) to determine which strings get the - and which get the _ so we just have to use neither. :( This was the original behavior of CBT. It would be nice to improve it in the future though. |
This was weird. The problem was because the NEW slug (programmetwo) contained the OLD slug (programme). And the "paternize" function happened BEFORE the namespace swap so when doing a string replace of programme>programmetwo the slug that was in the paternized template programmetwo became programmetwotwo. I fixed it by making sure that the patternization of the template happens LAST (after the namespace swap). |
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.
Tested:
✅ Fix for the problem with themes such as "Program Two"
✅ Spaces don't create broken function names
Something to keep an eye out for is that if the theme is given a name that includes an actual underscore, those are not being replaced with dashes, creating Text Domains with underscores.
eg. this theme was given the name "Alter_2"
This is important because the text domain has to match the Theme's slug in the wp.org theme directory.
ff1b364
to
adeebad
Compare
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.
Looks like this is working well for me now:
I used slightly different testing steps, as since the rebase I think most of the patternisation is done optionally. So instead of just cloning the theme, I saved the theme with all save options selected, and then cloned it. I think this is ready to bring in.
When a pattern is created during the cloning action (for example if the source theme has templates with text content and the template is processed to localize the text) then the patterns that are created have the SOURCE theme's namespace rather than the new theme.
This change passes that new slug value when creating the pattern so that it is used instead.
To test:
Also the slug generated from the new theme name is no longer using -'s to fix the issue noted below. Fixes: #566