PluginProbe
EmailKit – Email Customizer for WooCommerce & WP / 1.2.0
EmailKit – Email Customizer for WooCommerce & WP v1.2.0
1.6.9 1.6.8 1.6.7 trunk 1.0.0 1.2.0 1.4.0 1.4.5 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6
emailkit / includes / Admin / Emails / Helpers / Utils.php

Utils.php in EmailKit – Email Customizer for WooCommerce & WP 1.2.0, at includes/Admin/Emails/Helpers/Utils.php

240 lines 8.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace EmailKit\Admin\Emails\Helpers;
4
5 defined("ABSPATH") || exit;
6
7 class Utils
8 {
9 public static function get_kses_array()
10 {
11 return array(
12 'html' => array(),
13 'head' => array(),
14 'body' => array(),
15 'hr' => array(),
16 'address' => array(),
17 'a' => array(
18 'class' => array(),
19 'href' => array(),
20 'rel' => array(),
21 'title' => array(),
22 'target' => array(),
23 'style' => array(),
24 ),
25 'abbr' => array(
26 'title' => array(),
27 'style' => array(),
28 ),
29 'b' => array(
30 'class' => array(),
31 'style' => array(),
32 ),
33 'blockquote' => array(
34 'cite' => array(),
35 'style' => array(),
36 ),
37 'cite' => array(
38 'title' => array(),
39 'style' => array(),
40 ),
41 'code' => array(
42 'style' => array(),
43 ),
44 'pre' => array(
45 'style' => array(),
46 ),
47 'del' => array(
48 'datetime' => array(),
49 'title' => array(),
50 'style' => array(),
51 ),
52 'dd' => array(
53 'style' => array(),
54 ),
55 'div' => array(
56 'class' => array(),
57 'title' => array(),
58 'style' => array(),
59 ),
60 'dl' => array(
61 'style' => array(),
62 ),
63 'dt' => array(
64 'style' => array(),
65 ),
66 'em' => array(
67 'style' => array(),
68 ),
69 'strong' => array(
70 'style' => array(),
71 ),
72 'h1' => array(
73 'class' => array(),
74 'style' => array(),
75 ),
76 'h2' => array(
77 'class' => array(),
78 'style' => array(),
79 ),
80 'h3' => array(
81 'class' => array(),
82 'style' => array(),
83 ),
84 'h4' => array(
85 'class' => array(),
86 'style' => array(),
87 ),
88 'h5' => array(
89 'class' => array(),
90 'style' => array(),
91 ),
92 'h6' => array(
93 'class' => array(),
94 'style' => array(),
95 ),
96 'i' => array(
97 'class' => array(),
98 'style' => array(),
99 ),
100 'img' => array(
101 'alt' => array(),
102 'class' => array(),
103 'height' => array(),
104 'src' => array(),
105 'width' => array(),
106 'style' => array(),
107 'title' => array(),
108 'srcset' => array(),
109 'loading' => array(),
110 'sizes' => array(),
111 'style' => array(),
112 ),
113 'figure' => array(
114 'class' => array(),
115 'style' => array(),
116 ),
117 'li' => array(
118 'class' => array(),
119 'style' => array(),
120 ),
121 'ol' => array(
122 'class' => array(),
123 'style' => array(),
124 ),
125 'p' => array(
126 'class' => array(),
127 'style' => array(),
128 ),
129 'q' => array(
130 'cite' => array(),
131 'title' => array(),
132 'style' => array(),
133 ),
134 'span' => array(
135 'class' => array(),
136 'title' => array(),
137 'style' => array(),
138 ),
139 'iframe' => array(
140 'width' => array(),
141 'height' => array(),
142 'scrolling' => array(),
143 'frameborder' => array(),
144 'allow' => array(),
145 'src' => array(),
146 'style' => array(),
147 ),
148 'strike' => array(),
149 'br' => array(),
150 'table' => array(),
151 'thead' => array(),
152 'tbody' => array(
153 'width' => array(),
154 'height' => array(),
155 'scrolling' => array(),
156 'frameborder' => array(),
157 'allow' => array(),
158 'src' => array(),
159 'style' => array()
160 ),
161 'tfoot' => array(),
162 'tr' => array(
163 'width' => array(),
164 'height' => array(),
165 'scrolling' => array(),
166 'frameborder' => array(),
167 'allow' => array(),
168 'src' => array(),
169 'style' => array()
170 ),
171 'th' => array(),
172 'td' => array(),
173 'colgroup' => array(),
174 'col' => array(),
175 'strong' => array(),
176 'data-wow-duration' => array(),
177 'data-wow-delay' => array(),
178 'data-wallpaper-options' => array(),
179 'data-stellar-background-ratio' => array(),
180 'ul' => array(
181 'class' => array(),
182 ),
183 'svg' => array(
184 'class' => true,
185 'aria-hidden' => true,
186 'aria-labelledby' => true,
187 'role' => true,
188 'xmlns' => true,
189 'width' => true,
190 'height' => true,
191 'viewbox' => true, // <= Must be lower case!
192 'preserveaspectratio' => true,
193 ),
194 'g' => array('fill' => true),
195 'title' => array('title' => true),
196 'path' => array(
197 'd' => true,
198 'fill' => true,
199 ),
200 'input' => array(
201 'class' => array(),
202 'type' => array(),
203 'value' => array()
204 )
205 );
206 }
207
208 public static function kses($raw)
209 {
210
211 $allowed_tags = self::get_kses_array();
212
213 if (function_exists('wp_kses')) { // WP is here
214 return wp_kses($raw, $allowed_tags);
215 } else {
216 return $raw;
217 }
218 }
219
220 public static function mail_shortcode_filter(string $input) : string {
221
222 // find the shortcode
223 $pattern = '/<span data-shortcode="{{([\w]+)}}">([\w]+)<\/span>/';
224
225 // getting all shortcode matches from mail content
226 preg_match_all($pattern, $input, $matches, PREG_SET_ORDER);
227
228 // Loop through each match and replace the content inside the span tag
229 foreach ($matches as $match) {
230 $shortcode = $match[1]; // Content inside the data-shortcode attribute
231 $oldContent = $match[2]; // Content inside the span tag
232
233 // replaceing the shortcode
234 $replacement = '<span>{{' . $shortcode . '}}</span>';
235 $input = str_replace($match[0], $replacement, $input);
236 }
237
238 return $input;
239 }
240 }