Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
I would like to reference this discussion https://core.trac.wordpress.org/ticket/61605 which brings up reworking the registry |
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Thanks for putting this together @scruffian 👍
As @carolinan noted there's some other discussion over on https://core.trac.wordpress.org/ticket/61605 that might impact the general direction here.
The test failures are also related to this PR and appear due to not passing the $scope parameter through. When testing this PR, we'll need to ensure block style variations defined within the theme's /styles directory continue to work.
Some test instructions for block style variations can be found on #62712. Those could be worked into the instructions for this PR.
Example block style variation partial
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 3,
"title": "Section A",
"slug": "section-a",
"blockTypes": [ "core/group" ],
"styles": {
"color": {
"background": "slategrey",
"text": "snow"
},
"blocks": {
"core/group": {
"color": {
"background": "darkslategrey",
"text": "whitesmoke"
}
}
}
}
}… style variations from other themes
1cdd6be to
d544da8
Compare
|
Flaky tests detected in 3ee41e8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/10008202053
|
|
Size Change: +354 B (+0.02%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Thanks for your patience on this one @scruffian 👍
I've now had a chance to give this more of a test and it is working as advertised for me.
✅ Browsing and switching theme style variations works as before
✅ Block style variations continue to work
✅ Unit tests are passing
Screen.Recording.2024-07-31.at.5.19.48.PM.mp4
Add this patch to your repo
For others coming to test this, I've tested using the following:
diff --git a/lib/class-wp-theme-json-resolver-gutenberg.php b/lib/class-wp-theme-json-resolver-gutenberg.php
index 2231cb0f11..20cb477c32 100644
--- a/lib/class-wp-theme-json-resolver-gutenberg.php
+++ b/lib/class-wp-theme-json-resolver-gutenberg.php
@@ -764,7 +764,9 @@ class WP_Theme_JSON_Resolver_Gutenberg {
* @return array
*/
public static function get_style_variations( $scope = 'theme' ) {
- return static::get_style_variations_from_directory( get_stylesheet_directory(), $scope );
+ $stylesheet = get_stylesheet();
+ $theme_root = get_theme_root( $stylesheet );
+ return static::get_style_variations_from_directory( $theme_root, $scope );
}
/**
After applying the above patch, extra style variations are displayed under Appearance > Styles and in the Site Editor under Global Styles > Browse Styles.
At this point though the editor really starts to grind to a halt. Applying variations, colorways and typesets all seems to become hit and miss. Especially with color palettes that appear to be duplicates. The sidebar jumps as it tries to scroll both into view it seems.
I appreciate the scope of this PR is just to provide a function that can be used in future work to expand the style variation options in the editor but I just wanted to flag potential future issues or required considerations.
This PR achieves what it sets out to, so I'm happy to give it an approval.
|
Thank you. It would be great to get a tutorial out on how to use it once 19.0 is released. |
|
Hey @scruffian 👋 Would you be able to help write a dev note for this for the 6.7 release? We are planning to have this as part of a larger Miscellaneous Editor Updates note. We are hoping to get all drafts in by October 13th to leave some time for reviews before the RC1. All Dev Notes get tracked in #65784 so feel free to leave a note there or ping me directly :) Please let us know if you can assist with that. Thanks in advance :) |
What?
In #45371 we want to expose style variations from other themes. This makes that possible by creating a new function in
WP_Theme_JSON_Resolver_Gutenbergcalledget_style_variations_from_directory.Why?
This gives us freedom to load style variations from sources outside the currently active theme.
How?
get_style_variations_from_directoryget_style_variationsand pass the theme directory (get_stylesheet_directory())get_style_variation_files_from_current_themewhich specifically gets the variation files from the currently active theme. This is used insideget_style_variations_from_directoryto get the variation files from the active theme.Testing Instructions
###Testing for no regressions
0. Open the Site Editor
Testing the new functionality
Notes
The main concern I can see with this approach is that it exposes a new public function, which increases the area that we need to maintain going forward.