PluginProbe
MailPoet – Newsletters, Email Marketing, and Automation / 5.37.0
MailPoet – Newsletters, Email Marketing, and Automation v5.37.0
5.38.0 5.37.0 5.36.1 5.36.0 5.35.1 5.35.0 5.34.3 5.34.2 5.34.1 5.34.0 5.33.1 5.33.0 5.32.0 5.31.0 5.30.0 5.29.0 5.28.1 5.28.0 5.27.0 5.26.0 5.26.1 5.25.0 5.24.0 4.43.0 4.43.1 All 542 releases
mailpoet / lib / EmailEditor / Integrations / MailPoet / MailPoetCssInliner.php
MailPoetCssInliner.php
36 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types = 1);
2
3 namespace MailPoet\EmailEditor\Integrations\MailPoet;
4
5 if (!defined('ABSPATH')) exit;
6
7
8 use Automattic\WooCommerce\EmailEditor\Engine\Renderer\Css_Inliner;
9 use MailPoetVendor\Pelago\Emogrifier\CssInliner;
10
11 class MailPoetCssInliner implements Css_Inliner {
12 private CssInliner $inliner;
13
14 public function from_html(string $unprocessed_html): self { // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- we need to match the interface
15 $that = new self();
16 $that->inliner = CssInliner::fromHtml($unprocessed_html);
17 /** @phpstan-ignore-next-line return.type - Interface has static in PHP docs but it goes against coding standards in this repo */
18 return $that;
19 }
20
21 public function inline_css(string $css = ''): self {// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- we need to match the interface
22 if (!isset($this->inliner)) {
23 throw new \LogicException('You must call from_html before calling inline_css');
24 }
25 $this->inliner->inlineCss($css);
26 return $this;
27 }
28
29 public function render(): string {
30 if (!isset($this->inliner)) {
31 throw new \LogicException('You must call from_html before calling inline_css');
32 }
33 return $this->inliner->render();
34 }
35 }
36