Use WP's style engine for formatting style arrays to string
[MAILPOET-5798]
This commit is contained in:
committed by
Rostislav Wolný
parent
50df6c3d4e
commit
15e0c3fa4d
@@ -27,7 +27,7 @@ class FlexLayoutRenderer {
|
|||||||
if ($key > 0) {
|
if ($key > 0) {
|
||||||
$styles['padding-left'] = $flexGap;
|
$styles['padding-left'] = $flexGap;
|
||||||
}
|
}
|
||||||
$outputHtml .= '<td class="layout-flex-item" style="' . esc_html($settingsController->convertStylesToString($styles)) . '">' . render_block($block) . '</td>';
|
$outputHtml .= '<td class="layout-flex-item" style="' . esc_html(\WP_Style_Engine::compile_css($styles, '')) . '">' . render_block($block) . '</td>';
|
||||||
}
|
}
|
||||||
$outputHtml .= '</tr></table></div>
|
$outputHtml .= '</tr></table></div>
|
||||||
<!--[if mso | IE]></td></tr></table><![endif]-->';
|
<!--[if mso | IE]></td></tr></table><![endif]-->';
|
||||||
|
@@ -62,7 +62,7 @@ class Heading extends AbstractBlockRenderer {
|
|||||||
width="100%"
|
width="100%"
|
||||||
>
|
>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="' . esc_attr($classes) . '" style="' . $settingsController->convertStylesToString($styles) . '">
|
<td class="' . esc_attr($classes) . '" style="' . \WP_Style_Engine::compile_css($styles, '') . '">
|
||||||
{heading_content}
|
{heading_content}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@@ -70,7 +70,7 @@ class Image extends AbstractBlockRenderer {
|
|||||||
$borderStyles['box-sizing'] = 'border-box';
|
$borderStyles['box-sizing'] = 'border-box';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->addStyleToElement($blockContent, ['tag_name' => 'img'], $settingsController->convertStylesToString($borderStyles));
|
return $this->addStyleToElement($blockContent, ['tag_name' => 'img'], \WP_Style_Engine::compile_css($borderStyles, ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,7 +110,7 @@ class Image extends AbstractBlockRenderer {
|
|||||||
];
|
];
|
||||||
|
|
||||||
$styles['font-size'] = $parsedBlock['email_attrs']['font-size'] ?? $themeData['styles']['typography']['fontSize'];
|
$styles['font-size'] = $parsedBlock['email_attrs']['font-size'] ?? $themeData['styles']['typography']['fontSize'];
|
||||||
return $settingsController->convertStylesToString($styles);
|
return \WP_Style_Engine::compile_css($styles, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,7 +142,7 @@ class Image extends AbstractBlockRenderer {
|
|||||||
border="0"
|
border="0"
|
||||||
cellpadding="0"
|
cellpadding="0"
|
||||||
cellspacing="0"
|
cellspacing="0"
|
||||||
style="' . $settingsController->convertStylesToString($styles) . '"
|
style="' . \WP_Style_Engine::compile_css($styles, '') . '"
|
||||||
width="100%"
|
width="100%"
|
||||||
>
|
>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -152,7 +152,7 @@ class Image extends AbstractBlockRenderer {
|
|||||||
border="0"
|
border="0"
|
||||||
cellpadding="0"
|
cellpadding="0"
|
||||||
cellspacing="0"
|
cellspacing="0"
|
||||||
style="' . $settingsController->convertStylesToString($wrapperStyles) . '"
|
style="' . \WP_Style_Engine::compile_css($wrapperStyles, '') . '"
|
||||||
width="' . $wrapperWidth . '"
|
width="' . $wrapperWidth . '"
|
||||||
>
|
>
|
||||||
<tr>
|
<tr>
|
||||||
|
@@ -22,13 +22,13 @@ class ListBlock extends AbstractBlockRenderer {
|
|||||||
$styles['font-size'] = $themeData['styles']['typography']['fontSize'];
|
$styles['font-size'] = $themeData['styles']['typography']['fontSize'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$html->set_attribute('style', $settingsController->convertStylesToString($styles));
|
$html->set_attribute('style', \WP_Style_Engine::compile_css($styles, ''));
|
||||||
$blockContent = $html->get_updated_html();
|
$blockContent = $html->get_updated_html();
|
||||||
}
|
}
|
||||||
|
|
||||||
$wrapperStyle = $settingsController->convertStylesToString([
|
$wrapperStyle = \WP_Style_Engine::compile_css([
|
||||||
'margin-top' => $parsedBlock['email_attrs']['margin-top'] ?? '0px',
|
'margin-top' => $parsedBlock['email_attrs']['margin-top'] ?? '0px',
|
||||||
]);
|
], '');
|
||||||
|
|
||||||
// \WP_HTML_Tag_Processor escapes the content, so we have to replace it back
|
// \WP_HTML_Tag_Processor escapes the content, so we have to replace it back
|
||||||
$blockContent = str_replace(''', "'", $blockContent);
|
$blockContent = str_replace(''', "'", $blockContent);
|
||||||
|
@@ -52,7 +52,7 @@ class Paragraph extends AbstractBlockRenderer {
|
|||||||
<!--[if mso | IE]><table align="left" role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><![endif]-->
|
<!--[if mso | IE]><table align="left" role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><![endif]-->
|
||||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;"width="100%">
|
<table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;"width="100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="' . esc_attr($classes) . '" style="' . $settingsController->convertStylesToString($styles) . '" align="' . $align . '">
|
<td class="' . esc_attr($classes) . '" style="' . \WP_Style_Engine::compile_css($styles, '') . '" align="' . $align . '">
|
||||||
{paragraph_content}
|
{paragraph_content}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Reference in New Issue
Block a user