-
Notifications
You must be signed in to change notification settings - Fork 45
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
Try: refactor clone to copy theme to current site #294
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 tested this out using the latest version of GB with Archeo and Iotix.
Verify the cloned theme appears as expected in Appearance > Themes
The cloned theme appears with the correct edits (screenshot, name) in Themes ✅
However, when I view the cloned theme in the Site Editor, I'm not seeing most of the content:
I think this is because of the way I named the theme. I was testing with Archeo here and I named the clone, "Archeo clone 2". The textdomain has come through as archeoclone2clone2
, and the template parts and patterns are usingarcheoclone2
as a theme slug. I'm guessing this mismatch has caused these references to fail.
I also tried with a single word name, "ClonedArcheo", but the textdomain came through as clonedclonedarcheo
, so I saw the same issue with the parts and patterns.
Verify that the export and overwrite options still work as expected
Yes! ✅
I think this is a great idea! |
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.
Hi 👋
This looks very good :)
Could we add some theme name/slug validation? I ask this because if, for example, there is already a theme with that name in the themes folder, the plugin fails silently. Let's say I export a "TT3" clone with the name "hola," and after that, I activate the "Disco" theme, and I clone it with the same name ("hola"). The resulting folder /themes/hola have the TT3 content.
We could get a list of the themes/directories in the themes folder to know if the name/slug is valid.
Apart from that, having the option to edit the theme data when you export seems important; otherwise, the user could not get a zip of a theme with a name and data.
Using this branch, I get 0-byte zip files when using the "export" option. |
Thanks for the reviews @mikachan @matiasbenedetto !
@mikachan you're right, there was a bug in the
This should be fixed with the latest commit f4c3f2c |
Good idea, I will add this to the PR. |
With the very latest commit, I see this error when I try to clone: 'Theme name already exists, please choose a different name.' If I use f4c3f2c, it looks like the name of the theme does prevent it from being cloned, but I'm struggling to find a pattern. I'm using Archeo again, and these names didn't seem to work: 'ArcheoClone', 'Clone Archeo', 'New Archeo'. But these did: 'Archeos', 'Theme', 'New Theme', 'Archeo2'. |
861dc5b
to
c1797be
Compare
Okay I rebased this PR. Since #292 was merged, it made sense to also solve #186 at the same time.
Sorry there was a bug in this, I think I fixed it in c1797be. If you wouldn't mind testing the following flows again, that would be greatly appreciated:
|
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 tested with Archeo again. I've added a custom image to the home template and changed the headings in global styles to a different colour (red).
Clone:
I cloned the theme and named it 'Oak':
- I get a cloned theme with the correct name
- The change to global styles is correctly included in the clone
I'm seeing intermittent problems with the custom image. Sometimes the image is included in the cloned theme assets folder, but on other attempts, the image is added to the existing version of Archeo (e.g. when I check my themes directory with git status
).
I'm not sure what's triggering the differences - the only difference in my testing is different theme names, but I've seen both happen on the same theme name.
Export:
- Works well if I don't change the name of the theme
- If I change the name from Archeo (I tried 'Export', 'Oak', 'Test') I get the following warning from the
add_media_to_zip
function:
Warning: file() expects parameter 1 to be a valid path, object given in /admin/create-theme/theme-zip.php on line 106
Edit: I've just been testing out something else and I'm still seeing this warning, so I don't think it's related to this PR. It seems to consistently happen with Archeo but not any other theme - so I've either messed up my local version of Archeo or there's a bug in that theme...
Export from the site editor:
- Works well 👍
- I get a zip file that includes my custom image and my change to global styles
I'm sorry that I'm still seeing errors with export - does it sound like I'm testing correctly? I feel like I'm doing something particularly awkward. Let me know if you need more info!
c1797be
to
5372045
Compare
Thanks for the thorough test and reporting @mikachan ! I am not sure what's going on with the Export there, I tried with Archeo and it seems to be working after I rebased this branch. What is not working for me is the Export from Site Editor option. I narrowed it down fail when I include a media asset in the template, and the |
Clone from the Site Admin has a similar issue; the resulting theme does not include custom fonts, although it fails silently. |
This sounds like the same error I was seeing with |
I created a PR with fixes for the Export/download_url problem. #338 |
Closing this one as outdated. |
This PR is an attempt to address #284 #288 and #186, by modifying the behavior of the Clone option.
Instead of generating a zip, Clone creates a copy of the currently active theme, along with any user modifications, to the current site — providing a convenient way for users to effectively fork an existing theme.
Export was updated to work like Clone did — allowing users to edit the metadata for an export.
notes
To test