Blocks
10 months ago
Coupons
1 month ago
Endpoints
2 months ago
Patterns
1 month ago
PersonalizationTags
3 days ago
ProductCollection
1 month ago
Templates
2 months ago
AutomationEmailContextProvider.php
1 month ago
AutomationEmailPreviewOrderProvider.php
1 month ago
BlockEmailContentDetector.php
1 month ago
Cli.php
2 weeks ago
DependencyNotice.php
10 months ago
EditorPageRenderer.php
1 week ago
EmailApiController.php
1 week ago
EmailEditor.php
2 months ago
EmailEditorPreviewEmail.php
9 months ago
Logger.php
10 months ago
MailPoetCssInliner.php
8 months ago
MailpoetCssInlinerFactory.php
1 year ago
PersonalizationTagManager.php
4 days ago
index.php
2 years ago
MailPoetCssInliner.php
36 lines
| 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 |