blocks_renderer = $blocks_renderer; $this->wp = $wp; } /** * @param array $content * @return array */ public function process($content) { if (!array_key_exists('blocks', $content)) { return $content; } $blocks = []; foreach ($content['blocks'] as $block) { $blocks = array_merge($blocks, $this->processBlock($block)); } $content['blocks'] = $blocks; return $content; } /** * @param array $block * @return array */ public function processBlock($block) { switch ($block['type']) { case 'automatedLatestContentLayout': return $this->blocks_renderer->automatedLatestContentTransformedPosts($block); case 'woocommerceHeading': $base_color = $this->wp->getOption('woocommerce_email_base_color'); $text_color = $this->wp->getOption('woocommerce_email_text_color'); $content = '

' . self::WC_HEADING_PLACEHOLDER . '

'; return $this->placeholder($content, ['backgroundColor' => $base_color]); case 'woocommerceContent': return $this->placeholder(self::WC_CONTENT_PLACEHOLDER); } return [$block]; } /** * @param string $text * @return array */ private function placeholder($text, $styles = []) { return [ LayoutHelper::row([ LayoutHelper::col([[ 'type' => 'text', 'text' => $text, ]]), ], $styles), ]; } }