Fix renderer styles

This commit is contained in:
Mike Jolley
2024-05-03 15:03:36 +01:00
committed by Aschepikov
parent 4100991354
commit c3dcc13f2c
3 changed files with 25 additions and 14 deletions

View File

@ -170,17 +170,21 @@ class ThemeController {
foreach ($elementsStyles as $key => $elementsStyle) {
$selector = $key;
if ($key === 'heading') {
$selector = 'h1, h2, h3, h4, h5, h6';
}
if ($key === 'link') {
// Target direct decendants of blocks to avoid styling buttons. :not() is not supported by the inliner.
$selector = 'p > a, div > a, li > a';
}
if ($key === 'button') {
$selector = '.wp-block-button';
$cssElements .= wp_style_engine_get_styles($elementsStyle, ['selector' => '.wp-block-button'])['css'];
// Add color to link element.
$cssElements .= wp_style_engine_get_styles(['color' => ['text' => $elementsStyle['color']['text'] ?? '']], ['selector' => '.wp-block-button a'])['css'];
continue;
}
switch ($key) {
case 'heading':
$selector = 'h1, h2, h3, h4, h5, h6';
break;
case 'link':
$selector = 'a:not(.button-link)';
break;
}
$cssElements .= wp_style_engine_get_styles($elementsStyle, ['selector' => $selector])['css'];