-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Theme Export: Export the whole theme #39202
Conversation
Size Change: +9 B (0%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
I think it is a very useful tool, of course. The question in my head is whether we want to have it as an always on option for any theme, and have their variations exportable as a fully bundled theme, or do we want this enabled only for "framework" style themes? The diff can also be exported as a child theme which requires the original. That would also be an option for a smaller default export. Ideally we should not change the lightness of themes and their self contained nature, so my take, in case of a full theme export, would be to not ignore any folder: a user importing will not go and run Alternatively, like #39194 suggests we could enable this only when a development flag is set to on. |
1df476f
to
08af4d0
Compare
My first thought is:
but you could also consider things like |
I added a filter to ignore all files within |
This is very interesting! I think this might be a decent first approach. I also worry a bit about exporting all the templates, even if they haven't been edited. For many themes, that's probably totally fine, but I wonder if we should have an easy way to opt out of this feature if (for example) you're running a custom-made corporate theme. Also, if templates and styles have been updated, I wonder if we need to rename the theme and its slugs? Should that be a part of the export flow? I guess these issues exist no matter which export path we take though, so I'm not sure that they're specifically related to this PR. |
@kjellr yeah, these are all good questions and definitely something I want to keep iterating on in future PRs... |
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 think this would be useful to theme developers, that way I can get a whole functioning theme and delete / rewrite / rename as necessary.
Like others have mentioned, having the ability to rename the theme, and choose exactly what to export, would be nice but could be addressed in a follow up.
$zip->addFile( $file_path, $theme_name . '/' . $relative_path ); | ||
} | ||
} | ||
} | ||
|
||
// Load templates into the zip file. | ||
$templates = gutenberg_get_block_templates(); | ||
foreach ( $templates as $template ) { | ||
$template->content = _remove_theme_attribute_in_block_template_content( $template->content ); |
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.
Template parts can also reference other template parts, is there a way to remove the theme attribute from those also?
@@ -26,21 +43,46 @@ function gutenberg_generate_block_templates_export_file() { | |||
$filename = get_temp_dir() . 'edit-site-export-' . $obscura . '.zip'; |
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.
Should the zip still be named this, or can it be the $theme_name
?
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.
Yea, I second @jffng we should name the zip $theme_name
IMO.
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'll do this in a followup
* @since 6.0.0 | ||
* @return Bool Whether this file is in an ignored directory. | ||
*/ | ||
function gutenberg_directory_ignored( $path ) { |
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.
Nitpick, could we name it gutenberg_is_directory_ignored
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.
IMO this is a good start. It'd be useful to land this and start seeing in practice if there are problems with it.
6d9825e
to
1b02408
Compare
I created a PR to export the zip with the theme name: #39471 |
Description
Following on from #39173 this is a proposal to export the whole theme in the zip, and simply update the templates and theme.json file.
This approach has the advantage that all of the necessary things to make the theme work are included by default. The downside is that the export can be very large, and its not so clear what files have diverged from the original theme.
I'm looking for feedback on this approach:
Testing Instructions
Types of changes
New feature (non-breaking change which adds functionality)
Checklist:
*.native.js
files for terms that need renaming or removal).