-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix regression with theme.json settings.shadow.defaultPresets
#6295
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
Changes from all commits
e1dd97f
f838ba3
4cc07b0
43bddac
9006ad2
ce570a5
3845b40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -312,6 +312,19 @@ public static function get_theme_data( $deprecated = array(), $options = array() | |
} | ||
$theme_support_data['settings']['color']['defaultGradients'] = $default_gradients; | ||
|
||
if ( ! isset( $theme_support_data['settings']['shadow'] ) ) { | ||
$theme_support_data['settings']['shadow'] = array(); | ||
} | ||
$default_shadows = false; | ||
if ( current_theme_supports( 'default-shadow-presets' ) ) { | ||
$default_shadows = true; | ||
} | ||
if ( ! isset( $theme_support_data['settings']['shadow']['presets'] ) ) { | ||
// If the theme does not have any shadows, we still want to show the core ones. | ||
$default_shadows = true; | ||
} | ||
Comment on lines
+322
to
+325
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a quick comment, as I haven't looked at this change in detail, but this line stood out to me while passing by. Does this check mean that if the theme doesn't add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's correct. I think from all of the discussions that I read, the desire was to go for consistency with other settings, so I copied the behavior from colors and gradients just above. However, I know that behavior is different from what you had talked about in WordPress/gutenberg#58908. If we want to match the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't feel too strongly about it, but mostly trying to follow the general discussion from WordPress/gutenberg#58908. My impression was that shadows / effects are a bit of a special case, so guarding behind There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And fair warning, I haven't really tested any of this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is often a point of confusion for global styles, but setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, gotcha.
I suppose that's the question then: whether shadows are like colors or font sizes, or whether they're more like duotone in that respect. It might be worth getting more opinions on this? I don't feel strongly either way, my main hope is that whichever way it works feels natural and not unexpected to folks. Maybe @madhusudhand might have some thoughts, too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The only reason duotone is different is because of the large SVGs that were also being generated WordPress/gutenberg#38299. Changing it was not an easy feat—we had to essentially rewrite duotone from scratch to do all the things that the global styles classes give you for free. And there are still unresolved issues from making that change WordPress/gutenberg#53662 and WordPress/gutenberg#49293. For something small like a few lines of shadow presets, I promise it isn't worth it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to know, thanks! |
||
$theme_support_data['settings']['shadow']['defaultPresets'] = $default_shadows; | ||
|
||
// Allow themes to enable link color setting via theme_support. | ||
if ( current_theme_supports( 'link-color' ) ) { | ||
$theme_support_data['settings']['color']['link'] = true; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2642,6 +2642,7 @@ function get_theme_starter_content() { | |
* @since 6.3.0 The `border` feature allows themes without theme.json to add border styles to blocks. | ||
* @since 6.5.0 The `appearance-tools` feature enables a few design tools for blocks, | ||
* see `WP_Theme_JSON::APPEARANCE_TOOLS_OPT_INS` for a complete list. | ||
* @since 6.5.0 The `editor-shadow-presets` feature is added for adding custom shadow presets to the editor. | ||
* | ||
* @global array $_wp_theme_features | ||
* | ||
|
@@ -2668,6 +2669,7 @@ function get_theme_starter_content() { | |
* - 'disable-layout-styles' | ||
* - 'editor-color-palette' | ||
* - 'editor-gradient-presets' | ||
* - 'editor-shadow-presets' | ||
* - 'editor-font-sizes' | ||
* - 'editor-styles' | ||
* - 'featured-content' | ||
|
@@ -4220,6 +4222,31 @@ function create_initial_theme_features() { | |
), | ||
) | ||
); | ||
register_theme_feature( | ||
'editor-shadow-presets', | ||
array( | ||
'type' => 'array', | ||
'description' => __( 'Custom shadow presets if defined by the theme.' ), | ||
'show_in_rest' => array( | ||
'schema' => array( | ||
'items' => array( | ||
'type' => 'object', | ||
'properties' => array( | ||
'name' => array( | ||
'type' => 'string', | ||
), | ||
'shadow' => array( | ||
'type' => 'string', | ||
), | ||
'slug' => array( | ||
'type' => 'string', | ||
), | ||
), | ||
), | ||
), | ||
), | ||
) | ||
); | ||
Comment on lines
+4225
to
+4249
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bonus support for custom shadows in classic themes to match other presets. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is great 🌟 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was required in order to support these lines and match the behavior of colors/gradients. if ( ! isset( $theme_support_data['settings']['shadow']['presets'] ) ) {
// If the theme does not have any shadows, we still want to show the core ones.
$default_shadows = true;
} If we decide to diverge from the colors/gradients behavior like we're discussing in https://github.com/WordPress/wordpress-develop/pull/6295/files#r1533015533 and in WordPress/gutenberg#59989 (comment), we could remove it from here and add it to a follow-up. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I opened an alternative PR (#6303) with shadows enabled by default in classic themes (like colors/gradients) but without the option to opt-out with Both PRs fix the regression that I'm concerned with. |
||
register_theme_feature( | ||
'editor-styles', | ||
array( | ||
|
Uh oh!
There was an error while loading. Please reload this page.