-
Notifications
You must be signed in to change notification settings - Fork 46
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
![image](https://private-user-images.githubusercontent.com/1645628/323275008-b922a3ec-b170-417a-bcc1-2dff4fe2e2c2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQxMzYxMDIsIm5iZiI6MTcyNDEzNTgwMiwicGF0aCI6Ii8xNjQ1NjI4LzMyMzI3NTAwOC1iOTIyYTNlYy1iMTcwLTQxN2EtYmNjMS0yZGZmNGZlMmUyYzIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjBUMDYzNjQyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OGYyYWE0ODM2MTUwYjgwNmVmNmUwZmRmNGEwOWYxOTU1MDM1ZWJiYzQxODQ3NWRlMWY2NmUzMmVjNmRmMjVjMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.i9uiQ3P6vTpWHVVRmPFxwBkBGrurFWnW5bIressSS78)
- 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
:
![image](https://private-user-images.githubusercontent.com/1645628/323277165-48cb38fe-2ae9-422f-8487-58a96e630f3f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQxMzYxMDIsIm5iZiI6MTcyNDEzNTgwMiwicGF0aCI6Ii8xNjQ1NjI4LzMyMzI3NzE2NS00OGNiMzhmZS0yYWU5LTQyMmYtODQ4Ny01OGE5NmU2MzBmM2YucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjBUMDYzNjQyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Zjc1YmE2M2M4MzI5YTkyMzUzODQzYjViMDE4ODVmNTI2ZDFhODIwMGIzM2M0MmJhOGRhYzFkNGNhYzA2NmViZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.E2nspDyuznSWmxU7S_uOrg9EHEFLtZoQ8Gx8HjIlYsg)
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.
![image](https://private-user-images.githubusercontent.com/1645628/323610363-206dfc6e-4776-48c8-a7ab-7ef9063fa217.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQxMzYxMDIsIm5iZiI6MTcyNDEzNTgwMiwicGF0aCI6Ii8xNjQ1NjI4LzMyMzYxMDM2My0yMDZkZmM2ZS00Nzc2LTQ4YzgtYTdhYi03ZWY5MDYzZmEyMTcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjBUMDYzNjQyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YWZhZDNmODE0NDdmNTg2ODU4OWU5ZmMzMGUyZDVjMDkxY2NhOGM5MzcwYjFkN2VlNzBiOGE1Y2RlZDEyOTczNyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.40k0v-oaQg4mOM8ib1sF9cQ17xZkTWsMe3KddbP6-nY)
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:
![image](https://private-user-images.githubusercontent.com/1645628/323696321-4f41394a-ba2b-4edc-972d-ff824728eedc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQxMzYxMDIsIm5iZiI6MTcyNDEzNTgwMiwicGF0aCI6Ii8xNjQ1NjI4LzMyMzY5NjMyMS00ZjQxMzk0YS1iYTJiLTRlZGMtOTcyZC1mZjgyNDcyOGVlZGMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjBUMDYzNjQyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MjA1ZmY0OTY0OWE3YzFjZjU4NTk0MzMxZWQ1MjY2NDgyYjFhZTVjMjRiNzc0Mzk5M2RjOTFhMmU1OGU5MDNkNiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.4nQBPV3xaU7NTPzGCPX-GsmET88oMdMFlD1VZTPGvN4)
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