Preprocess transactional email newsletter
[MAILPOET-2286]
This commit is contained in:
committed by
Jack Kitterhing
parent
f56ced0ef5
commit
e1a8883935
@ -4,6 +4,7 @@ namespace MailPoet\Newsletter\Renderer;
|
||||
|
||||
use MailPoet\Newsletter\Editor\LayoutHelper;
|
||||
use MailPoet\Newsletter\Renderer\Blocks\Renderer as BlocksRenderer;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class Preprocessor {
|
||||
const WC_HEADING_PLACEHOLDER = '[mailpet_woocommerce_heading_placeholder]';
|
||||
@ -12,8 +13,12 @@ class Preprocessor {
|
||||
/** @var BlocksRenderer */
|
||||
private $blocks_renderer;
|
||||
|
||||
public function __construct(BlocksRenderer $blocks_renderer) {
|
||||
/** @var WPFunctions */
|
||||
private $wp;
|
||||
|
||||
public function __construct(BlocksRenderer $blocks_renderer, WPFunctions $wp) {
|
||||
$this->blocks_renderer = $blocks_renderer;
|
||||
$this->wp = $wp;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,7 +46,10 @@ class Preprocessor {
|
||||
case 'automatedLatestContentLayout':
|
||||
return $this->blocks_renderer->automatedLatestContentTransformedPosts($block);
|
||||
case 'woocommerceHeading':
|
||||
return $this->placeholder(self::WC_HEADING_PLACEHOLDER);
|
||||
$base_color = $this->wp->getOption('woocommerce_email_base_color');
|
||||
$text_color = $this->wp->getOption('woocommerce_email_text_color');
|
||||
$content = '<h1 style="color:' . $text_color . ';">' . self::WC_HEADING_PLACEHOLDER . '</h1>';
|
||||
return $this->placeholder($content, ['backgroundColor' => $base_color]);
|
||||
case 'woocommerceContent':
|
||||
return $this->placeholder(self::WC_CONTENT_PLACEHOLDER);
|
||||
}
|
||||
@ -49,17 +57,17 @@ class Preprocessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $block
|
||||
* @param string $text
|
||||
* @return array
|
||||
*/
|
||||
private function placeholder($text) {
|
||||
private function placeholder($text, $styles = []) {
|
||||
return [
|
||||
LayoutHelper::row([
|
||||
LayoutHelper::col([[
|
||||
'type' => 'text',
|
||||
'text' => $text,
|
||||
]]),
|
||||
]),
|
||||
], $styles),
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user