Skip to content

Commit

Permalink
Add style rule once (#23025)
Browse files Browse the repository at this point in the history
  • Loading branch information
nosolosw committed Jun 9, 2020
1 parent c9bffda commit aa46f40
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,16 @@ function gutenberg_experimental_global_styles_resolver( $tree ) {
)
);
}

if ( gutenberg_experimental_global_styles_has_theme_json_support() ) {
// To support all themes, we added in the block-library stylesheet
// a style rule such as .has-link-color a { color: var(--wp--style--color--link, #00e); }
// so that existing link colors themes used didn't break.
// We add this here to make it work for themes that opt-in to theme.json
// In the future, we may do this differently.
$stylesheet .= 'a { color: var(--wp--style--color--link, #00e); }';
}

return $stylesheet;
}

Expand All @@ -455,15 +465,6 @@ function gutenberg_experimental_global_styles_resolver_styles( $block_selector,
$css_rule = '';
$css_declarations = '';

if ( gutenberg_experimental_global_styles_has_theme_json_support() ) {
// To support all themes, we added in the block-library stylesheet
// a style rule such as .has-link-color a { color: var(--wp--style--color--link, #00e); }
// so that existing link colors themes used didn't break.
// We add this here to make it work for themes that opt-in to theme.json
// In the future, we may do this differently.
$css_rule = 'a { color: var(--wp--style--color--link, #00e); }';
}

foreach ( $block_styles as $property => $value ) {
// Only convert to CSS:
//
Expand Down

0 comments on commit aa46f40

Please sign in to comment.