PluginProbe
Wp-Insert / trunk
Wp-Insert vtrunk
trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.3.0 1.3.1 1.3.3 1.4 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 2.0 All 63 releases
wp-insert / includes / modules / core / controls / module.php

module.php in Wp-Insert trunk, at includes/modules/core/controls/module.php

662 lines 38.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class smartlogixControls {
3 private $type;
4 private $plainHTML;
5 private $useParagraph;
6 private $helpText;
7 private $id;
8 private $name;
9 private $value;
10 private $label;
11 private $className;
12 private $style;
13 private $required;
14 private $options;
15
16 private $optionName;
17 private $optionIdentifier;
18
19
20 private $pages;
21 private $posts;
22 private $categories;
23
24 public $values;
25 public $HTML;
26 public $JS;
27
28 public function __construct( $args = null ) {
29 $this->HTML = '';
30 $this->JS = '';
31
32 $this->type = 'text';
33 $this->plainHTML = false;
34 $this->useParagraph = true;
35 $this->helpText = '';
36 $this->id = '';
37 $this->name = '';
38 $this->value = '';
39 $this->label = '';
40 $this->className = 'input widefat';
41 $this->style = '';
42 $this->required = '';
43 $this->options = null;
44
45 $this->optionName = '';
46 $this->optionIdentifier = '';
47 $this->values = '';
48
49 if ( isset( $args ) && is_array( $args ) ) {
50 if ( isset( $args['type'] ) && ( $args['type'] != '' ) ) {
51 $this->type = $args['type'];
52 }
53 if ( isset( $args['plainHTML'] ) && ( $args['plainHTML'] != '' ) ) {
54 $this->plainHTML = $args['plainHTML'];
55 }
56 if ( isset( $args['useParagraph'] ) && ( $args['useParagraph'] != '' ) ) {
57 $this->useParagraph = $args['useParagraph'];
58 }
59 if ( isset( $args['helpText'] ) && ( $args['helpText'] != '' ) ) {
60 $this->helpText = $args['helpText'];
61 }
62 if ( isset( $args['id'] ) && ( $args['id'] != '' ) ) {
63 $this->id = $args['id'];
64 }
65 if ( isset( $args['name'] ) && ( $args['name'] != '' ) ) {
66 $this->name = $args['name'];
67 }
68 if ( isset( $args['value'] ) && ( $args['value'] != '' ) ) {
69 $this->value = $args['value'];
70 }
71 if ( isset( $args['label'] ) && ( $args['label'] != '' ) ) {
72 $this->label = $args['label'];
73 }
74 if ( isset( $args['className'] ) && ( $args['className'] != '' ) ) {
75 $this->className = $args['className'];
76 }
77 if ( isset( $args['style'] ) && ( $args['style'] != '' ) ) {
78 $this->style = $args['style'];
79 }
80 if ( isset( $args['required'] ) && ( $args['required'] != '' ) ) {
81 $this->required = $args['required'];
82 }
83 if ( isset( $args['options'] ) && is_array( $args['options'] ) ) {
84 $this->options = $args['options'];
85 }
86
87 if ( isset( $args['optionIdentifier'] ) && ( $args['optionIdentifier'] != '' ) ) {
88 $this->optionIdentifier = $args['optionIdentifier'];
89 }
90 if ( isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) {
91 $this->optionName = $args['optionName'];
92 }
93 if ( isset( $args['values'] ) && ( $args['values'] != '' ) ) {
94 $this->values = $args['values'];
95 }
96
97 if ( isset( $args['optionIdentifier'] ) && ( $args['optionIdentifier'] != '' ) && isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) {
98 $this->id = str_replace( [ '[', ']' ], [ '_', '' ], $args['optionIdentifier'] ) . '_' . $args['optionName'];
99 $this->name = $args['optionIdentifier'] . '[' . $args['optionName'] . ']';
100 } elseif ( isset( $this->optionIdentifier ) && ( $this->optionIdentifier != '' ) && isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) {
101 $this->id = str_replace( [ '[', ']' ], [ '_', '' ], $this->optionIdentifier ) . '_' . $args['optionName'];
102 $this->name = $this->optionIdentifier . '[' . $args['optionName'] . ']';
103 } elseif ( isset( $args['optionIdentifier'] ) && ( $args['optionIdentifier'] != '' ) && isset( $this->optionName ) && ( $this->optionName != '' ) ) {
104 $this->id = str_replace( [ '[', ']' ], [ '_', '' ], $args['optionIdentifier'] ) . '_' . $this->optionName;
105 $this->name = $args['optionIdentifier'] . '[' . $this->optionName . ']';
106 } elseif ( isset( $this->optionIdentifier ) && ( $this->optionIdentifier != '' ) && isset( $this->optionName ) && ( $this->optionName != '' ) ) {
107 $this->id = str_replace( [ '[', ']' ], [ '_', '' ], $this->optionIdentifier ) . '_' . $this->optionName;
108 $this->name = $this->optionIdentifier . '[' . $this->optionName . ']';
109 }
110
111 if ( isset( $args['values'] ) && is_array( $args['values'] ) ) {
112 if ( isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) {
113 $this->value = $args['values'][ $args['optionName'] ];
114 } elseif ( isset( $this->optionName ) && ( $this->optionName != '' ) ) {
115 $this->value = $args['values'][ $this->optionName ];
116 }
117 } elseif ( isset( $this->values ) && is_array( $this->values ) ) {
118 if ( isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) {
119 $this->value = $this->values[ $args['optionName'] ];
120 } elseif ( isset( $this->optionName ) && ( $this->optionName != '' ) ) {
121 $this->value = $this->values[ $this->optionName ];
122 }
123 }
124 }
125 }
126
127 private function sync_args( $args ) {
128 $syncedArgs = [];
129 if ( is_array( $args ) ) {
130 $syncedArgs = $args;
131 }
132
133 if ( isset( $args['type'] ) && ( $args['type'] != '' ) ) {
134 $syncedArgs['type'] = $args['type'];
135 } else {
136 $syncedArgs['type'] = $this->type;
137 }
138
139 if ( isset( $args['plainHTML'] ) && is_bool( $args['plainHTML'] ) ) {
140 $syncedArgs['plainHTML'] = $args['plainHTML'];
141 } else {
142 $syncedArgs['plainHTML'] = $this->plainHTML;
143 }
144
145 if ( isset( $args['useParagraph'] ) && is_bool( $args['useParagraph'] ) ) {
146 $syncedArgs['useParagraph'] = $args['useParagraph'];
147 } else {
148 $syncedArgs['useParagraph'] = $this->useParagraph;
149 }
150
151 if ( isset( $args['helpText'] ) && ( $args['helpText'] != '' ) ) {
152 $syncedArgs['helpText'] = $args['helpText'];
153 } else {
154 $syncedArgs['helpText'] = $this->helpText;
155 }
156
157 if ( isset( $args['id'] ) && ( $args['id'] != '' ) ) {
158 $syncedArgs['id'] = $args['id'];
159 } else {
160 $syncedArgs['id'] = $this->id;
161 }
162
163 if ( isset( $args['name'] ) && ( $args['name'] != '' ) ) {
164 $syncedArgs['name'] = $args['name'];
165 } else {
166 $syncedArgs['name'] = $this->name;
167 }
168
169 if ( isset( $args['label'] ) && ( $args['label'] != '' ) ) {
170 $syncedArgs['label'] = $args['label'];
171 } else {
172 $syncedArgs['label'] = $this->label;
173 }
174
175 if ( isset( $args['className'] ) && ( $args['className'] != '' ) ) {
176 $syncedArgs['className'] = $args['className'];
177 } else {
178 $syncedArgs['className'] = $this->className;
179 }
180
181 if ( isset( $args['style'] ) && ( $args['style'] != '' ) ) {
182 $syncedArgs['style'] = $args['style'];
183 } else {
184 $syncedArgs['style'] = $this->style;
185 }
186
187 if ( isset( $args['required'] ) && ( $args['required'] != '' ) ) {
188 $syncedArgs['required'] = $args['required'];
189 } else {
190 $syncedArgs['required'] = $this->required;
191 }
192
193 if ( isset( $args['options'] ) && is_array( $args['options'] ) ) {
194 $syncedArgs['options'] = $args['options'];
195 } else {
196 $syncedArgs['options'] = $this->options;
197 }
198
199 if ( isset( $args['optionIdentifier'] ) && ( $args['optionIdentifier'] != '' ) && isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) {
200 $syncedArgs['id'] = str_replace( [ '[', ']' ], [ '_', '' ], $args['optionIdentifier'] ) . '_' . $args['optionName'];
201 $syncedArgs['name'] = $args['optionIdentifier'] . '[' . $args['optionName'] . ']';
202 } elseif ( isset( $this->optionIdentifier ) && ( $this->optionIdentifier != '' ) && isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) {
203 $syncedArgs['id'] = str_replace( [ '[', ']' ], [ '_', '' ], $this->optionIdentifier ) . '_' . $args['optionName'];
204 $syncedArgs['name'] = $this->optionIdentifier . '[' . $args['optionName'] . ']';
205 } elseif ( isset( $args['optionIdentifier'] ) && ( $args['optionIdentifier'] != '' ) && isset( $this->optionName ) && ( $this->optionName != '' ) ) {
206 $syncedArgs['id'] = str_replace( [ '[', ']' ], [ '_', '' ], $args['optionIdentifier'] ) . '_' . $this->optionName;
207 $syncedArgs['name'] = $args['optionIdentifier'] . '[' . $this->optionName . ']';
208 } elseif ( isset( $this->optionIdentifier ) && ( $this->optionIdentifier != '' ) && isset( $this->optionName ) && ( $this->optionName != '' ) ) {
209 $syncedArgs['id'] = str_replace( [ '[', ']' ], [ '_', '' ], $this->optionIdentifier ) . '_' . $this->optionName;
210 $syncedArgs['name'] = $this->optionIdentifier . '[' . $this->optionName . ']';
211 }
212
213 if ( isset( $args['value'] ) && ( $args['value'] != '' ) ) {
214 $syncedArgs['value'] = $args['value'];
215 } elseif ( isset( $args['values'] ) && is_array( $args['values'] ) ) {
216 if ( isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) {
217 $syncedArgs['value'] = $args['values'][ $args['optionName'] ];
218 } elseif ( isset( $this->optionName ) && ( $this->optionName != '' ) ) {
219 $syncedArgs['value'] = $args['values'][ $this->optionName ];
220 }
221 } elseif ( isset( $this->values ) && is_array( $this->values ) ) {
222 if ( isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) {
223 $syncedArgs['value'] = $this->values[ $args['optionName'] ];
224 } elseif ( isset( $this->optionName ) && ( $this->optionName != '' ) ) {
225 $syncedArgs['value'] = $this->values[ $this->optionName ];
226 }
227 } else {
228 $syncedArgs['value'] = $this->value;
229 }
230
231 return $syncedArgs;
232 }
233
234 public function add_control( $args = null ) {
235 $control = $this->get_control( $args, true );
236 $this->HTML .= $control['HTML'];
237 $this->JS .= $control['JS'];
238 }
239
240 public function get_control( $args = null, $ignorePlainHTML = false ) {
241 $HTML = '';
242 $JS = '';
243 $args = $this->sync_args( $args );
244
245 switch ( $args['type'] ) {
246 case 'hidden':
247 $HTML .= '<input type="hidden" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['value'] != '' ) ? 'value="' . esc_attr( sanitize_text_field( $args['value'] ) ) . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' />';
248 break;
249 case 'text':
250 if ( $args['useParagraph'] ) {
251 $HTML .= '<p>'; }
252 if ( $args['label'] != '' ) {
253 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
254 $HTML .= '<input type="text" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['value'] != '' ) ? 'value="' . esc_attr( sanitize_text_field( $args['value'] ) ) . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . ' />';
255 if ( $args['helpText'] != '' ) {
256 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
257 if ( $args['useParagraph'] ) {
258 $HTML .= '</p>'; }
259 break;
260 case 'number':
261 if ( $args['useParagraph'] ) {
262 $HTML .= '<p>'; }
263 if ( $args['label'] != '' ) {
264 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
265 $HTML .= '<input type="number" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['value'] != '' ) ? 'value="' . esc_attr( sanitize_text_field( $args['value'] ) ) . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . ' />';
266 if ( $args['helpText'] != '' ) {
267 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
268 if ( $args['useParagraph'] ) {
269 $HTML .= '</p>'; }
270 break;
271 case 'password':
272 if ( $args['useParagraph'] ) {
273 $HTML .= '<p>'; }
274 if ( $args['label'] != '' ) {
275 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
276 $HTML .= '<input type="password" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['value'] != '' ) ? 'value="' . esc_attr( sanitize_text_field( $args['value'] ) ) . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . ' />';
277 if ( $args['helpText'] != '' ) {
278 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
279 if ( $args['useParagraph'] ) {
280 $HTML .= '</p>'; }
281 break;
282 case 'textarea':
283 if ( $args['useParagraph'] ) {
284 $HTML .= '<p>'; }
285 if ( $args['label'] != '' ) {
286 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
287 $HTML .= '<textarea ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . '>' . stripslashes( ( ( $args['value'] != '' ) ? $args['value'] : '' ) ) . '</textarea>';
288 if ( $args['helpText'] != '' ) {
289 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
290 if ( $args['useParagraph'] ) {
291 $HTML .= '</p>'; }
292 break;
293 case 'checkbox':
294 if ( $args['useParagraph'] ) {
295 $HTML .= '<p>'; }
296 if ( isset( $args['value'] ) && ( filter_var( $args['value'], FILTER_VALIDATE_BOOLEAN ) ) ) {
297 $HTML .= '<input type="checkbox" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' value="1" ' . checked( true, true, false ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . ' />';
298 } else {
299 $HTML .= '<input type="checkbox" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' value="1" ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . ' />';
300 }
301 if ( $args['label'] != '' ) {
302 $HTML .= '&nbsp;<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label>'; }
303 if ( $args['helpText'] != '' ) {
304 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
305 if ( $args['useParagraph'] ) {
306 $HTML .= '</p>'; }
307 break;
308 case 'radio':
309 if ( $args['useParagraph'] ) {
310 $HTML .= '<p>'; }
311 if ( isset( $args['value'] ) && ( filter_var( $args['value'], FILTER_VALIDATE_BOOLEAN ) ) ) {
312 $HTML .= '<input type="radio" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' value="1" ' . checked( true, true, false ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . ' />';
313 } else {
314 $HTML .= '<input type="radio" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' value="1" ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . ' />';
315 }
316 if ( $args['label'] != '' ) {
317 $HTML .= '&nbsp;<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label>'; }
318 if ( $args['helpText'] != '' ) {
319 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
320 if ( $args['useParagraph'] ) {
321 $HTML .= '</p>'; }
322 break;
323 case 'select':
324 if ( $args['useParagraph'] ) {
325 $HTML .= '<p>'; }
326 if ( $args['label'] != '' ) {
327 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
328 $HTML .= '<select ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . '>';
329 if ( is_array( $args['options'] ) ) {
330 foreach ( $args['options'] as $option ) {
331 $metadata = '';
332 if ( isset( $option['metadata'] ) && is_array( $option['metadata'] ) ) {
333 foreach ( $option['metadata'] as $key => $value ) {
334 $metadata .= 'data-' . $key . '="' . $value . '"';
335 }
336 }
337 $HTML .= '<option ' . $metadata . '' . ( ( $option['value'] != '' ) ? 'value="' . $option['value'] . '"' : '' ) . ' ' . selected( ( ( $args['value'] != '' ) ? $args['value'] : '' ), ( ( $option['value'] != '' ) ? $option['value'] : '' ), false ) . '>' . ( ( $option['text'] != '' ) ? $option['text'] : '' ) . '</option>';
338 }
339 }
340 $HTML .= '</select>';
341 if ( $args['helpText'] != '' ) {
342 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
343 if ( $args['useParagraph'] ) {
344 $HTML .= '</p>'; }
345 break;
346 case 'choosen-multiselect':
347 if ( $args['useParagraph'] ) {
348 $HTML .= '<p>'; }
349 if ( $args['label'] != '' ) {
350 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
351 $HTML .= '<select data-placeholder="' . ( ( $args['label'] != '' ) ? $args['label'] : 'Select Your Options' ) . '" multiple ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['value'] != '' ) ? 'value="' . $args['value'] . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . '>';
352 if ( is_array( $args['options'] ) ) {
353 foreach ( $args['options'] as $option ) {
354 if ( in_array( ( ( $option['value'] != '' ) ? $option['value'] : '' ), ( ( is_array( $args['value'] ) ) ? $args['value'] : [] ) ) ) {
355 $HTML .= '<option ' . ( ( $option['value'] != '' ) ? 'value="' . $option['value'] . '"' : '' ) . ' ' . selected( 1, 1, false ) . '>' . ( ( $option['text'] != '' ) ? $option['text'] : '' ) . '</option>';
356 } else {
357 $HTML .= '<option ' . ( ( $option['value'] != '' ) ? 'value="' . $option['value'] . '"' : '' ) . '>' . ( ( $option['text'] != '' ) ? $option['text'] : '' ) . '</option>';
358 }
359 }
360 }
361 $HTML .= '</select>';
362 if ( $args['helpText'] != '' ) {
363 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
364 if ( $args['useParagraph'] ) {
365 $HTML .= '</p>'; }
366 $JS .= 'jQuery("#' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '").chosen({ width: "100%" }).on("change", function(evt, params) { jQuery("#' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '_chosen .search-field input").click(); }).trigger("chosen:open");';
367 break;
368 case 'radio-group':
369 if ( $args['useParagraph'] ) {
370 $HTML .= '<p>'; }
371 if ( $args['label'] != '' ) {
372 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
373 if ( is_array( $args['options'] ) ) {
374 $index = 1;
375 foreach ( $args['options'] as $option ) {
376 $HTML .= '<input type="radio" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '_' . $index . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $option['value'] != '' ) ? 'value="' . $option['value'] . '"' : '' ) . ' ' . checked( ( ( isset( $args['value'] ) ) ? $args['value'] : '' ), ( ( isset( $option['value'] ) ) ? $option['value'] : '' ), false ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' />';
377 if ( $option['text'] != '' ) {
378 $HTML .= '&nbsp;<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . '>' . ( ( $option['text'] != '' ) ? $option['text'] : '' ) . '</label><br />'; }
379 ++$index;
380 }
381 }
382 if ( $args['helpText'] != '' ) {
383 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
384 if ( $args['useParagraph'] ) {
385 $HTML .= '</p>'; }
386 break;
387 case 'ipCheckbox':
388 if ( $args['useParagraph'] ) {
389 $HTML .= '<p>'; }
390 if ( isset( $args['value'] ) && ( filter_var( $args['value'], FILTER_VALIDATE_BOOLEAN ) ) ) {
391 $HTML .= '<input type="checkbox" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' value="true" ' . checked( true, true, false ) . ' ' . ( ( $args['className'] != '' ) ? 'class="ipCheckbox ' . $args['className'] . '"' : 'class="ipCheckbox"' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . ' />';
392 } else {
393 $HTML .= '<input type="checkbox" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' value="true" ' . ( ( $args['className'] != '' ) ? 'class="ipCheckbox ' . $args['className'] . '"' : 'class="ipCheckbox"' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . ' />';
394 }
395 if ( $args['label'] != '' ) {
396 $HTML .= '&nbsp;<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label>'; }
397 if ( $args['helpText'] != '' ) {
398 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
399 if ( $args['useParagraph'] ) {
400 $HTML .= '</p>'; }
401 $JS .= 'jQuery("#' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '").ipCheckbox();';
402 break;
403 case 'minicolors':
404 if ( $args['useParagraph'] ) {
405 $HTML .= '<p>'; }
406 if ( $args['label'] != '' ) {
407 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
408 $HTML .= '<input type="text" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['value'] != '' ) ? 'value="' . $args['value'] . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . ' />';
409 if ( $args['helpText'] != '' ) {
410 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
411 if ( $args['useParagraph'] ) {
412 $HTML .= '</p>'; }
413 $JS .= 'jQuery("#' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '").minicolors();';
414 break;
415 case 'textarea-wysiwyg':
416 if ( $args['useParagraph'] ) {
417 $HTML .= '<p>'; }
418 if ( $args['label'] != '' ) {
419 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
420 $HTML .= '<textarea ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . '>' . stripslashes( ( ( $args['value'] != '' ) ? $args['value'] : '' ) ) . '</textarea>';
421 if ( $args['helpText'] != '' ) {
422 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
423 if ( $args['useParagraph'] ) {
424 $HTML .= '</p>'; }
425 $JS .= 'jQuery("#' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '").jqte();';
426 break;
427 case 'checkbox-button':
428 if ( $args['useParagraph'] ) {
429 $HTML .= '<p>'; }
430 if ( isset( $args['value'] ) && ( filter_var( $args['value'], FILTER_VALIDATE_BOOLEAN ) ) ) {
431 $HTML .= '<input type="checkbox" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' value="true" ' . checked( true, true, false ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . ' />';
432 } else {
433 $HTML .= '<input type="checkbox" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' value="true" ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . ' />';
434 }
435 if ( $args['label'] != '' ) {
436 $HTML .= '<label for="' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '">' . $args['label'] . '</label>'; }
437 if ( $args['helpText'] != '' ) {
438 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
439 if ( $args['useParagraph'] ) {
440 $HTML .= '</p>'; }
441 $JS .= 'jQuery("#' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '").button({ create: function(event, ui) { jQuery(this).button("option", "label", (jQuery(this).is(":checked")?"' . ( ( $args['checkedLabel'] != '' ) ? $args['checkedLabel'] : '' ) . '":"' . ( ( $args['uncheckedLabel'] != '' ) ? $args['uncheckedLabel'] : '' ) . '")) }}).change(function () { jQuery(this).button("option", "label", (jQuery(this).is(":checked")?"' . ( ( $args['checkedLabel'] != '' ) ? $args['checkedLabel'] : '' ) . '":"' . ( ( $args['uncheckedLabel'] != '' ) ? $args['uncheckedLabel'] : '' ) . '")); });';
442 break;
443 case 'pages-select':
444 $this->load_data( 'pages' );
445 if ( $args['useParagraph'] ) {
446 $HTML .= '<p>'; }
447 if ( $args['label'] != '' ) {
448 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
449 $HTML .= '<select ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['value'] != '' ) ? 'value="' . $args['value'] . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . '>';
450 if ( is_array( $this->pages ) ) {
451 foreach ( $this->pages as $option ) {
452 $HTML .= '<option ' . ( ( $option['value'] != '' ) ? 'value="' . $option['value'] . '"' : '' ) . ' ' . selected( ( ( $args['value'] != '' ) ? $args['value'] : '' ), ( ( $option['value'] != '' ) ? $option['value'] : '' ), false ) . '>' . ( ( $option['text'] != '' ) ? $option['text'] : '' ) . '</option>';
453 }
454 }
455 $HTML .= '</select>';
456 if ( $args['helpText'] != '' ) {
457 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
458 if ( $args['useParagraph'] ) {
459 $HTML .= '</p>'; }
460 break;
461 case 'pages-chosen-multiselect':
462 $this->load_data( 'pages' );
463 if ( $args['useParagraph'] ) {
464 $HTML .= '<p>'; }
465 if ( $args['label'] != '' ) {
466 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
467 $HTML .= '<select multiple data-placeholder="' . ( ( $args['label'] != '' ) ? $args['label'] : 'Select Your Options' ) . '" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['value'] != '' ) ? 'value="' . $args['value'] . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . '>';
468 if ( is_array( $this->pages ) ) {
469 foreach ( $this->pages as $option ) {
470 if ( in_array( ( ( $option['value'] != '' ) ? $option['value'] : '' ), ( ( is_array( $args['value'] ) ) ? $args['value'] : [] ) ) ) {
471 $HTML .= '<option ' . ( ( $option['value'] != '' ) ? 'value="' . $option['value'] . '"' : '' ) . ' ' . selected( 1, 1, false ) . '>' . ( ( $option['text'] != '' ) ? $option['text'] : '' ) . '</option>';
472 } else {
473 $HTML .= '<option ' . ( ( $option['value'] != '' ) ? 'value="' . $option['value'] . '"' : '' ) . '>' . ( ( $option['text'] != '' ) ? $option['text'] : '' ) . '</option>';
474 }
475 }
476 }
477 $HTML .= '</select>';
478 if ( $args['helpText'] != '' ) {
479 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
480 if ( $args['useParagraph'] ) {
481 $HTML .= '</p>'; }
482 $JS .= 'jQuery("#' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '").chosen({ width: "100%" }).on("change", function(evt, params) { jQuery("#' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '_chosen .search-field input").click(); }).trigger("chosen:open");';
483 break;
484 case 'posts-select':
485 $this->load_data( 'posts' );
486 if ( $args['useParagraph'] ) {
487 $HTML .= '<p>'; }
488 if ( $args['label'] != '' ) {
489 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
490 $HTML .= '<select ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['value'] != '' ) ? 'value="' . $args['value'] . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . '>';
491 if ( is_array( $this->posts ) ) {
492 foreach ( $this->posts as $option ) {
493 $HTML .= '<option ' . ( ( $option['value'] != '' ) ? 'value="' . $option['value'] . '"' : '' ) . ' ' . selected( ( ( $args['value'] != '' ) ? $args['value'] : '' ), ( ( $option['value'] != '' ) ? $option['value'] : '' ), false ) . '>' . ( ( $option['text'] != '' ) ? $option['text'] : '' ) . '</option>';
494 }
495 }
496 $HTML .= '</select>';
497 if ( $args['helpText'] != '' ) {
498 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
499 if ( $args['useParagraph'] ) {
500 $HTML .= '</p>'; }
501 break;
502 case 'posts-chosen-multiselect':
503 $this->load_data( 'posts' );
504 if ( $args['useParagraph'] ) {
505 $HTML .= '<p>'; }
506 if ( $args['label'] != '' ) {
507 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
508 $HTML .= '<select multiple data-placeholder="' . ( ( $args['label'] != '' ) ? $args['label'] : 'Select Your Options' ) . '" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['value'] != '' ) ? 'value="' . $args['value'] . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . '>';
509 if ( is_array( $this->posts ) ) {
510 foreach ( $this->posts as $option ) {
511 if ( in_array( ( ( $option['value'] != '' ) ? $option['value'] : '' ), ( ( is_array( $args['value'] ) ) ? $args['value'] : [] ) ) ) {
512 $HTML .= '<option ' . ( ( $option['value'] != '' ) ? 'value="' . $option['value'] . '"' : '' ) . ' ' . selected( 1, 1, false ) . '>' . ( ( $option['text'] != '' ) ? $option['text'] : '' ) . '</option>';
513 } else {
514 $HTML .= '<option ' . ( ( $option['value'] != '' ) ? 'value="' . $option['value'] . '"' : '' ) . '>' . ( ( $option['text'] != '' ) ? $option['text'] : '' ) . '</option>';
515 }
516 }
517 }
518 $HTML .= '</select>';
519 if ( $args['helpText'] != '' ) {
520 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
521 if ( $args['useParagraph'] ) {
522 $HTML .= '</p>'; }
523 $JS .= 'jQuery("#' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '").chosen({ width: "100%" }).on("change", function(evt, params) { jQuery("#' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '_chosen .search-field input").click(); }).trigger("chosen:open");';
524 break;
525 case 'categories-select':
526 $this->load_data( 'categories' );
527 if ( $args['useParagraph'] ) {
528 $HTML .= '<p>'; }
529 if ( $args['label'] != '' ) {
530 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
531 $HTML .= '<select ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['value'] != '' ) ? 'value="' . $args['value'] . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . '>';
532 if ( is_array( $this->categories ) ) {
533 foreach ( $this->categories as $option ) {
534 $HTML .= '<option ' . ( ( $option['value'] != '' ) ? 'value="' . $option['value'] . '"' : '' ) . ' ' . selected( ( ( $args['value'] != '' ) ? $args['value'] : '' ), ( ( $option['value'] != '' ) ? $option['value'] : '' ), false ) . '>' . ( ( $option['text'] != '' ) ? $option['text'] : '' ) . '</option>';
535 }
536 }
537 $HTML .= '</select>';
538 if ( $args['helpText'] != '' ) {
539 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
540 if ( $args['useParagraph'] ) {
541 $HTML .= '</p>'; }
542 break;
543 case 'categories-chosen-multiselect':
544 $this->load_data( 'categories' );
545 if ( $args['useParagraph'] ) {
546 $HTML .= '<p>'; }
547 if ( $args['label'] != '' ) {
548 $HTML .= '<label ' . ( ( $args['name'] != '' ) ? 'for="' . $args['name'] . '"' : '' ) . '>' . $args['label'] . '</label><br />'; }
549 $HTML .= '<select multiple data-placeholder="' . ( ( $args['label'] != '' ) ? $args['label'] : 'Select Your Options' ) . '" ' . ( ( $args['id'] != '' ) ? 'id="' . $args['id'] . '"' : '' ) . ' ' . ( ( $args['name'] != '' ) ? 'name="' . $args['name'] . '"' : '' ) . ' ' . ( ( $args['value'] != '' ) ? 'value="' . $args['value'] . '"' : '' ) . ' ' . ( ( $args['className'] != '' ) ? 'class="' . $args['className'] . '"' : '' ) . ' ' . ( ( $args['style'] != '' ) ? 'style="' . $args['style'] . '"' : '' ) . ' ' . ( ( $args['required'] ) ? 'required' : '' ) . '>';
550 if ( is_array( $this->categories ) ) {
551 foreach ( $this->categories as $option ) {
552 if ( in_array( ( ( $option['value'] != '' ) ? $option['value'] : '' ), ( ( is_array( $args['value'] ) ) ? $args['value'] : [] ) ) ) {
553 $HTML .= '<option ' . ( ( $option['value'] != '' ) ? 'value="' . $option['value'] . '"' : '' ) . ' ' . selected( 1, 1, false ) . '>' . ( ( $option['text'] != '' ) ? $option['text'] : '' ) . '</option>';
554 } else {
555 $HTML .= '<option ' . ( ( $option['value'] != '' ) ? 'value="' . $option['value'] . '"' : '' ) . '>' . ( ( $option['text'] != '' ) ? $option['text'] : '' ) . '</option>';
556 }
557 }
558 }
559 $HTML .= '</select>';
560 if ( $args['helpText'] != '' ) {
561 $HTML .= '<small>' . $args['helpText'] . '</small>'; }
562 if ( $args['useParagraph'] ) {
563 $HTML .= '</p>'; }
564 $JS .= 'jQuery("#' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '").chosen({ width: "100%" }).on("change", function(evt, params) { jQuery("#' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '_chosen .search-field input").click(); }).trigger("chosen:open");';
565 break;
566 }
567
568 if ( $args['plainHTML'] && ! $ignorePlainHTML ) {
569 return $HTML;
570 } else {
571 return [
572 'HTML' => $HTML,
573 'JS' => $JS,
574 ];
575 }
576 }
577
578 private function load_data( $type ) {
579 switch ( $type ) {
580 case 'pages':
581 if ( ! is_array( $this->pages ) ) {
582 $pages = get_pages( 'numberposts=100' );
583 if ( isset( $pages ) && is_array( $pages ) ) {
584 $this->pages = [];
585 foreach ( $pages as $page ) {
586 $this->pages[] = [
587 'text' => ( ( $page->post_title != '' ) ? $page->post_title : 'Untitled Page (' . $page->ID . ')' ),
588 'value' => $page->ID,
589 ];
590 }
591 }
592 }
593 break;
594 case 'posts':
595 if ( ! is_array( $this->posts ) ) {
596 $posts = get_posts( 'numberposts=100' );
597 if ( isset( $posts ) && is_array( $posts ) ) {
598 $this->posts = [];
599 foreach ( $posts as $post ) {
600 $this->posts[] = [
601 'text' => $post->post_title,
602 'value' => $post->ID,
603 ];
604 }
605 }
606 }
607 break;
608 case 'categories':
609 if ( ! is_array( $this->categories ) ) {
610 $categories = get_categories( 'number=200&hide_empty=0' );
611 if ( isset( $categories ) && is_array( $categories ) ) {
612 $this->categories = [];
613 foreach ( $categories as $category ) {
614 $this->categories[] = [
615 'text' => $category->name,
616 'value' => $category->term_id,
617 ];
618 }
619 }
620 }
621 break;
622 }
623 }
624
625 public function create_section( $sectionTitle = '', $includeBlock = true ) {
626 $wrapperHTML = '<div class="smartlogixControlsSectionWrapper">';
627 if ( $sectionTitle != '' ) {
628 $wrapperHTML .= '<label class="smartlogixControlsSectionTitle">' . $sectionTitle . '</label>';
629 }
630 if ( $includeBlock ) {
631 $wrapperHTML .= $this->create_block();
632 }
633 $wrapperHTML .= $this->HTML;
634 $wrapperHTML .= '</div>';
635 $this->HTML = $wrapperHTML;
636 }
637
638 public function create_block() {
639 $this->HTML = '<div class="smartlogixControlsSectionInner">' . $this->HTML . '</div>';
640 }
641
642 public function set_HTML( $HTML ) {
643 $this->HTML = $HTML;
644 }
645
646 public function clear_controls( $clearHTML = true, $clearJS = false ) {
647 if ( $clearHTML ) {
648 $this->HTML = '';
649 }
650 if ( $clearJS ) {
651 $this->JS = '';
652 }
653 }
654
655 public static function enqueue_assets( $path, $version = '1' ) {
656 wp_register_style( 'smartlogix-controls-css', $path . '/css/controls.css', [], $version );
657 wp_enqueue_style( 'smartlogix-controls-css' );
658 wp_register_script( 'smartlogix-controls-js', $path . '/js/controls.js', [ 'jquery', 'jquery-ui-core' ], $version, true );
659 wp_enqueue_script( 'smartlogix-controls-js' );
660 }
661 }
662