Skip to content

Copy changes for theme export back to core#2534

Closed
scruffian wants to merge 23 commits intoWordPress:trunkfrom
scruffian:update/theme-export-for-6.0
Closed

Copy changes for theme export back to core#2534
scruffian wants to merge 23 commits intoWordPress:trunkfrom
scruffian:update/theme-export-for-6.0

Conversation

@scruffian
Copy link
Contributor

@scruffian scruffian commented Apr 7, 2022

Part of WordPress/gutenberg#39889

This bring across changes to theme export functionality, and related code, and tests.

Includes also changes from WordPress/gutenberg#38132.

Trac ticket: https://core.trac.wordpress.org/ticket/55505

@ajlende
Copy link

ajlende commented Apr 7, 2022

With the introduction of get_metadata_boolean in class-wp-theme-json.php, should_override_preset can be deprecated.

https://github.com/WordPress/wordpress-develop/pull/2526/files#diff-e12c3008d747d1bec5be9927c5e7b1ced0a88641abe52c278d495da936714817R1633-R1648

$has_block_templates_dir = $zip->locateName( 'theme/templates/' ) !== false;
$has_block_template_parts_dir = $zip->locateName( 'theme/parts/' ) !== false;
$this->assertTrue( $has_theme_dir, 'theme directory exists' );
$has_theme_json = $zip->locateName( 'theme.json' ) !== false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change that's not in Gutenberg

@scruffian
Copy link
Contributor Author

With the introduction of get_metadata_boolean in class-wp-theme-json.php, should_override_preset can be deprecated.

Done in 800e223

Copy link

@ajlende ajlende left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add-defaultduotone-docs.patch

I didn't have push access, so here's a patch for the defaultDutone notes.

@scruffian
Copy link
Contributor Author

add-defaultduotone-docs.patch

Thanks, I have pushed these to the PR

* @return Bool Whether this file is in an ignored directory.
*/
function wp_is_theme_directory_ignored( $path ) {
$directories_to_ignore = array( '.git', 'node_modules', 'vendor' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to look for other VCS'? We check for array( '.svn', '.git', '.hg', '.bzr' ) in WP_Automatic_Updater.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're now including the whole theme in the export, excluding vendor may be incorrect. It isn't always/only for development dependencies. So excluding it here would preclude using runtime composer dependencies.

This is something the WP Theme Review Team is doing, though maybe this would never happen for FSE themes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to look for other VCS'? We check for array( '.svn', '.git', '.hg', '.bzr' ) in WP_Automatic_Updater.

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this would never happen for FSE themes.

This is my hunch but I'm happy to remove it. The main motivation here is that TT2 has a vendor folder which is very large (30MB) so if people are using that as a base theme (which seems fairly likely), they will end up copying that every time. Happy to remove it though if you prefer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I definitely think we don't want to be zipping up 30MB here. I think your intuition is probably the best way to go. Maybe make the ignore directories list filterable?

* @return WP_Theme_JSON Entity that holds theme data.
*/
public static function get_theme_data( $deprecated = array() ) {
public static function get_theme_data( $deprecated = array(), $settings = array( 'with_supports' => true ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't typically follow this pattern in Core. Traditionally this would be an empty array and use wp_parse_args to set defaults.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 2529def

@TimothyBJacobs
Copy link
Member

Left what ended up as general feedback, REST API changes look fine to me.

Co-authored-by: Timothy Jacobs <timothy@ironbounddesigns.com>
Copy link

@ajlende ajlende left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes for defaultDuotone look good to me. Thanks for taking care of that @scruffian!

Copy link
Member

@oandregal oandregal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Export works as expected (appearanceTools and schema included) and code looks good.

@gziolo
Copy link
Member

gziolo commented Apr 11, 2022

I only wanted to mention that this patch includes also changes from WordPress/gutenberg#38132 and WordPress/gutenberg#40149 that were listed as requiring to backport to WP core.

@gziolo
Copy link
Member

gziolo commented Apr 11, 2022

Committed with https://core.trac.wordpress.org/changeset/53129. Thank you everyone for the collaboration on this one ❤️

@gziolo gziolo closed this Apr 11, 2022
@scruffian scruffian deleted the update/theme-export-for-6.0 branch April 11, 2022 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants