Skip to content
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

Apply ! important to user preset styles for theme.json themes only #39660

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/compat/wordpress-5.9/class-wp-theme-json-5-9.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,9 @@ class WP_Theme_JSON_5_9 {
* @var array
*/
const VALID_SETTINGS = array(
'appearanceTools' => null,
'border' => array(
'appearanceTools' => null,
'prioritiseUserPresets' => null,
'border' => array(
'color' => null,
'radius' => null,
'style' => null,
Expand Down Expand Up @@ -953,12 +954,13 @@ protected static function compute_preset_classes( $settings, $selector, $origins
foreach ( $slugs as $slug ) {
$css_var = static::replace_slug_in_string( $preset_metadata['css_vars'], $slug );
$class_name = static::replace_slug_in_string( $class, $slug );
$prioritise_user_presets = ( WP_Theme_JSON_Resolver_Gutenberg::theme_has_support() && true === $settings['prioritiseUserPresets'] ) ? '!important' : '';
glendaviesnz marked this conversation as resolved.
Show resolved Hide resolved
$stylesheet .= static::to_ruleset(
static::append_to_selector( $selector, $class_name ),
array(
array(
'name' => $property,
'value' => 'var(' . $css_var . ') !important',
'value' => 'var(' . $css_var . ')' . $prioritise_user_presets,
),
)
);
Expand Down
1 change: 1 addition & 0 deletions lib/compat/wordpress-5.9/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"version": 2,
"settings": {
"appearanceTools": false,
"prioritiseUserPresets": true,
"border": {
"color": false,
"radius": false,
Expand Down