diff --git a/lib/global-styles.php b/lib/global-styles.php index d14fdaad531d5..166d84df01bad 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -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; } @@ -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: //