Fix rendering issues in form blocks
[MAILPOET-3415]
This commit is contained in:
committed by
Veljko V
parent
6e911ffd1d
commit
c1aef842d2
@@ -2,7 +2,16 @@
|
||||
|
||||
namespace MailPoet\Form\Block;
|
||||
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class Divider {
|
||||
/** @var WPFunctions */
|
||||
private $wp;
|
||||
|
||||
public function __construct(WPFunctions $wp) {
|
||||
$this->wp = $wp;
|
||||
}
|
||||
|
||||
const DEFAULT_ATTRIBUTES = [
|
||||
'height' => 1,
|
||||
'type' => 'divider',
|
||||
@@ -20,8 +29,8 @@ class Divider {
|
||||
if (!empty($block['params']['class_name'])) {
|
||||
$classes[] = $block['params']['class_name'];
|
||||
}
|
||||
$classAttr = join(' ', $classes);
|
||||
$height = $block['params']['height'] ?? self::DEFAULT_ATTRIBUTES['height'];
|
||||
$classAttr = $this->wp->escAttr(join(' ', $classes));
|
||||
$height = $this->wp->escAttr($block['params']['height'] ?? self::DEFAULT_ATTRIBUTES['height']);
|
||||
return "<div class='{$classAttr}' style='height: {$height}px;'>"
|
||||
. $this->renderDivider($block)
|
||||
. '</div>';
|
||||
@@ -43,7 +52,7 @@ class Divider {
|
||||
"height: {$dividerHeight}px",
|
||||
"width: $width%",
|
||||
];
|
||||
$style = implode(";", $dividerStyles);
|
||||
$style = $this->wp->escAttr(implode(";", $dividerStyles));
|
||||
return "<div class='mailpoet_divider' data-automation-id='form_divider' style='$style'></div>";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user