PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.21
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.21
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
fluent-cart / app / Services / Libs / Emogrifier / Emogrifier.php

Emogrifier.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.3.21, at app/Services/Libs/Emogrifier/Emogrifier.php

54 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Services\Libs\Emogrifier;
4
5 class Emogrifier
6 {
7 private $html = '';
8
9 private $disableInvisibleNode = false;
10
11 public function __construct($html)
12 {
13 $this->html = (string) $html;
14 }
15
16 public function disableInvisibleNodeRemoval()
17 {
18 $this->disableInvisibleNode = true;
19 return $this;
20 }
21
22 public function emogrify()
23 {
24 // check if php version is less than 8.1
25 if (version_compare(phpversion(), '8.1', '<')) {
26 return $this->handleLegacy();
27 }
28
29 if (!class_exists('\FluentEmogrifier\Vendor\Pelago\Emogrifier\CssInliner')) {
30 require_once __DIR__ . '/scoped-vendor/autoload.php';
31 }
32
33 if (!class_exists('\FluentEmogrifier\Vendor\Pelago\Emogrifier\CssInliner')) {
34 return $this->handleLegacy();
35 }
36
37 // check if css inlines is available or not
38 return \FluentEmogrifier\Vendor\Pelago\Emogrifier\CssInliner::fromHtml($this->html)
39 ->inlineCss()
40 ->render();
41 }
42
43 private function handleLegacy()
44 {
45 $emogrifier = new EmogrifierPhp7($this->html);
46 if ($this->disableInvisibleNode) {
47 $emogrifier->disableInvisibleNodeRemoval();
48 }
49
50 return $emogrifier->emogrify();
51 }
52
53 }
54