PluginProbe
Sendy / 3.4.7
Sendy v3.4.7
3.4.6 3.4.7 trunk 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 All 32 releases
sendy / lib / Utils / View.php

View.php in Sendy 3.4.7, at lib/Utils/View.php

186 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sendy\WooCommerce\Utils;
4
5 use InvalidArgumentException;
6
7 class View
8 {
9 private string $filename;
10
11 private const VIEW_PATH = '/resources/views/';
12
13 public const ALLOWED_TAGS = [
14 'a' => [
15 'class' => [],
16 'href' => [],
17 'rel' => [],
18 'title' => [],
19 'target' => [],
20 ],
21 'abbr' => [
22 'title' => [],
23 ],
24 'b' => [],
25 'blockquote' => [
26 'cite' => [],
27 ],
28 'br' => [],
29 'button' => [
30 'class' => [],
31 'id' => [],
32 'disabled' => [],
33 'data-carrier' => [],
34 ],
35 'cite' => [
36 'title' => [],
37 ],
38 'code' => [],
39 'del' => [
40 'datetime' => [],
41 'title' => [],
42 ],
43 'dd' => [],
44 'div' => [
45 'class' => [],
46 'id' => [],
47 'title' => [],
48 'style' => [],
49 ],
50 'dl' => [],
51 'dt' => [],
52 'em' => [],
53 'form' => [
54 'action' => [],
55 'method' => [],
56 ],
57 'h1' => [],
58 'h2' => [],
59 'h3' => [],
60 'h4' => [],
61 'h5' => [],
62 'h6' => [],
63 'hr' => [
64 'class' => [],
65 ],
66 'i' => [
67 'class' => [],
68 ],
69 'img' => [
70 'alt' => [],
71 'class' => [],
72 'height' => [],
73 'src' => [],
74 'width' => [],
75 ],
76 'input' => [
77 'id' => [],
78 'class' => [],
79 'name' => [],
80 'value' => [],
81 'type' => [],
82 'style' => [],
83 'step' => [],
84 'checked' => [],
85 ],
86 'li' => [
87 'class' => [],
88 ],
89 'label' => [],
90 'mark' => [
91 'class' => [],
92 ],
93 'ol' => [
94 'class' => [],
95 ],
96 'option' => [
97 'value' => [],
98 'selected' => [],
99 ],
100 'p' => [
101 'class' => [],
102 ],
103 'path' => [
104 'fill' => [],
105 'd' => [],
106 'class' => [],
107 'data-v-19c3f3ae' => [],
108 ],
109 'q' => [
110 'cite' => [],
111 'title' => [],
112 ],
113 'script' => [
114 'type' => [],
115 'id' => [],
116 ],
117 'span' => [
118 'class' => [],
119 'title' => [],
120 'style' => [],
121 'data-tip' => [],
122 'data-target' => [],
123 ],
124 'select' => [
125 'id' => [],
126 'class' => [],
127 'name' => [],
128 'style' => [],
129 ],
130 'strike' => [],
131 'strong' => [],
132 'table' => [
133 'class' => [],
134 ],
135 'tbody' => [
136 'class' => [],
137 ],
138 'thead' => [
139 'class' => [],
140 ],
141 'tr' => [
142 'class' => [],
143 'data-name' => [],
144 ],
145 'th' => [
146 'class' => [],
147 'colspan' => [],
148 ],
149 'td' => [
150 'class' => [],
151 'colspan' => [],
152 ],
153 'ul' => [
154 'id' => [],
155 'class' => [],
156 ],
157 ];
158
159 public function __construct(string $filename)
160 {
161 $this->filename = $filename;
162 }
163
164 public static function fromTemplate(string $template): self
165 {
166 $file = SENDY_WC_PLUGIN_DIR_PATH . self::VIEW_PATH . $template;
167
168 if (file_exists($file)) {
169 return new self($file);
170 }
171
172 throw new InvalidArgumentException('Cannot find template: ' . esc_html($template));
173 }
174
175 public function render($data = []): string
176 {
177 ob_start();
178
179 extract($data);
180
181 require $this->filename;
182
183 return ob_get_clean();
184 }
185 }
186