PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.8.14.1
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.8.14.1
7.8.14 7.8.14.1 7.8.13 7.8.13.1 trunk 3.0 3.1 3.1.1 3.1.2 3.1.3 3.1.4 4.3.2 4.4.4 4.4.5 4.4.5.1 4.4.5.4 4.6 4.6.1.1 4.6.1.4 4.7.0.2 4.7.0.3 4.7.0.7 4.7.0.9 4.7.1.0 4.7.1.1 4.8.0.0 5.0.0 5.0.1 5.0.1.1 5.0.1.2 5.1 5.1.1 5.1.2 5.1.3 5.1.3.1 5.1.3.2 5.1.4 5.1.5 6.0 6.0.1 6.0.2 6.0.3 6.0.4.2 6.0.5 6.0.6.1 6.0.7 6.0.8.1 6.0.9 7.0.0.1 7.0.2 7.0.3 7.0.4 7.1.0 7.1.1 7.2.0 7.2.1 7.3.0 7.3.1 7.3.3 7.3.5 7.3.6 7.3.7 7.4.0 7.4.1 7.4.11 7.4.13 7.4.13.1 7.4.2 7.4.3 7.4.4 7.4.5 7.4.5.1 7.4.5.2 7.4.6 7.4.7 7.5.0 7.6.0 7.6.1 7.6.3 7.6.4 7.6.6 7.7.0 7.7.1 7.8.0 7.8.1 7.8.10 7.8.10.1 7.8.10.2 7.8.11 7.8.12 7.8.12.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.8.9.1 7.8.9.2 7.8.9.3
wordpress-popup / views / admin / commons / options.php
wordpress-popup / views / admin / commons Last commit date
sui-listing 1 month ago sui-wizard 1 month ago wizard 3 years ago modal-template.php 3 years ago options.php 5 months ago pagination.php 3 years ago view-documentation.php 5 years ago
options.php
436 lines
1 <?php
2 /**
3 * Templates for different field types and elements.
4 * Markup for us, frontend dummies.
5 * These are the variables that are used in most of the elements this file:
6 *
7 * $type string The field/element type.
8 * select|checkboxes|checkbox|{anything else as a regular input}
9 * $is_template bool Whether the field is used in an underscore template. Default: false.
10 * $id string ID property of the field.
11 * $class string Classes of the field.
12 * $name string Name of the field. For $is_template, it should
13 * have the same name as the js property that contains its value.
14 * $attributes array Associative array with other properties for the field. @see Hustle_Layout_Helper::render_attributes().
15 *
16 *
17 * $options array Set of options for rendering the element. Used by select|checkboxes|side_tabs.
18 * For select and checkboxes, it's an associative array where the key of the pair is the
19 * option's "value" property, and the value of the pair is the displayed label of the option. .
20 * For side_tabs, read more on the element's section.
21 *
22 * $selected string Used only if ! $is_template. The current stored value of the field. Must match the
23 * |array 'key' of its respective option pair in the $options array.
24 * Used by select|checkboxes|checkbox|checkbox_toggle|side_tabs.
25 *
26 *
27 * $value string Value of the field.
28 * Make sure it's properly escaped when rendering 'inline_notice'.
29 *
30 * $label string Label for the input. Used by checkbox|checkbox_toggle.
31 * $description string Description for the input. Used by checkbox|checkbox_toggle.
32 *
33 * $placeholder string TO BE DEPRECATED favoring accessibility. Placeholder of the field.
34 * $icon string Name of the icon as per SUI names. Used by text|number.
35 * $icon_position string Whether the icon goes before or after the input. Allowed values: before|after.
36 *
37 * $elements array Array with the options to render withing the wrapper. Used by wrapper.
38 *
39 * $tag string Tag name for inline HTML elements. Used by inline_element.
40 *
41 * NOTE: enable phpcs when editing stuff. Make sure what's left is okay. Disable it again afterwards.
42 *
43 * @package Hustle
44 * @since 4.2.0
45 */
46
47 // Flag for when the option is used in underscore template files.
48 $is_template = isset( $is_template ) ? $is_template : false;
49 $attributes = isset( $attributes ) ? $attributes : array();
50
51 $label_attributes = isset( $label_attributes ) ? $label_attributes : array();
52
53 switch ( $type ) :
54
55 // ELEMENT: Wrapper div.
56 case 'wrapper':
57 ?>
58 <div
59 <?php echo empty( $id ) ? '' : 'id="' . esc_attr( $id ) . '"'; ?>
60 <?php echo empty( $class ) ? '' : 'class="' . esc_attr( $class ) . '"'; ?>
61 <?php $this->render_attributes( $attributes ); ?>
62 >
63 <?php
64 foreach ( $elements as $element ) {
65 $this->render( 'admin/commons/options', $element );
66 }
67 ?>
68 </div>
69
70 <?php
71 break;
72
73 // ELEMENT: Select.
74 case 'select':
75 if ( self::$dont_init_selects &&
76 0 !== strpos( $name, 'custom_height_unit' ) && 0 !== strpos( $name, 'custom_width_unit' ) ) {
77 $new_class = ' none-sui';
78 $class = empty( $class ) ? $new_class : $class . $new_class;
79 }
80 ?>
81 <select
82 id="<?php echo empty( $id ) ? 'hustle-select-' . esc_attr( $name ) : esc_attr( $id ); ?>"
83 name="<?php echo esc_attr( $name ); ?>"
84 <?php echo empty( $class ) ? '' : 'class="' . esc_attr( $class ) . '"'; ?>
85 <?php echo empty( $placeholder ) ? '' : 'data-placeholder="' . esc_attr( $placeholder ) . '"'; ?>
86 <?php $this->render_attributes( $attributes ); ?>
87 tabindex="-1"
88 aria-hidden="true"
89 >
90
91 <?php if ( ! empty( $placeholder ) ) : ?>
92 <option></option>
93 <?php
94 endif;
95
96 // Fully server's side rendered field.
97 if ( ! $is_template ) :
98
99 foreach ( $options as $value => $label ) :
100 $label = ! empty( $label ) ? $label : '&#8205;';
101 $_selected = is_array( $selected ) && empty( $selected ) ? '' : $selected;
102 ?>
103 <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $_selected, $value ); ?>>
104 <?php echo esc_html( $label ); ?>
105 </option>
106 <?php
107 endforeach;
108
109 else :
110
111 foreach ( $options as $value => $label ) :
112 ?>
113 <option value="<?php echo esc_attr( $value ); ?>" {{ _.selected( <?php echo esc_attr( $name ); ?>, '<?php echo esc_attr( $value ); ?>' ) }}>
114 <?php echo esc_html( $label ); ?>
115 </option>
116 <?php
117 endforeach;
118
119 endif;
120 ?>
121
122 </select>
123
124 <?php
125 break;
126
127 // ELEMENT: Multiple checkboxes.
128 case 'checkboxes':
129 // Fully server's side rendered field.
130 if ( ! $is_template ) :
131
132 $_selected = isset( $selected ) ? $selected : array();
133 if ( ! is_array( $_selected ) ) {
134 $_selected = array( $_selected );
135 }
136
137 foreach ( $options as $value => $label ) :
138 ?>
139
140 <label class="sui-checkbox <?php echo isset( $class ) ? esc_attr( $class ) : ''; ?>">
141
142 <input
143 type="checkbox"
144 name="<?php echo esc_attr( $name ); ?>"
145 value="<?php echo esc_attr( $value ); ?>"
146 <?php echo isset( $id ) ? 'id="' . esc_attr( $id . '-' . $value ) . '"' : ''; ?>
147 <?php $this->render_attributes( $attributes ); ?>
148 <?php checked( in_array( $value, $_selected, true ) ); ?>
149 />
150
151 <span aria-hidden="true"></span>
152
153 <span><?php echo esc_html( $label ); ?></span>
154
155 </label>
156
157 <?php
158 endforeach;
159
160 else : // Field expecting parameters from underscore templating.
161
162 foreach ( $options as $value => $label ) :
163 ?>
164
165 <label class="sui-checkbox <?php echo isset( $class ) ? esc_attr( $class ) : ''; ?>">
166
167 <input
168 type="checkbox"
169 name="<?php echo esc_attr( $name ); ?>"
170 value="<?php echo esc_attr( $value ); ?>"
171 <?php echo isset( $id ) ? 'id="' . esc_attr( $id . '-' . $value ) . '"' : ''; ?>
172 <?php $this->render_attributes( $attributes ); ?>
173 {{ _.checked( <?php echo esc_attr( $name ); ?>.includes( '<?php echo esc_attr( $value ); ?>' ), true ) }}
174 />
175
176 <span aria-hidden="true"></span>
177 <span><?php echo esc_html( $label ); ?></span>
178
179 </label>
180
181 <?php
182 endforeach;
183
184 endif;
185 break;
186
187 // ELEMENT: Checkbox.
188 case 'checkbox':
189 $selected_value = isset( $value ) ? $value : '1';
190 ?>
191
192 <label class="sui-checkbox <?php echo isset( $class ) ? esc_attr( $class ) : ''; ?>" <?php $this->render_attributes( $label_attributes ); ?>>
193
194 <input
195 type="checkbox"
196 name="<?php echo esc_attr( $name ); ?>"
197 <?php echo isset( $value ) ? 'value="' . esc_attr( $value ) . '"' : ''; ?>
198 <?php echo isset( $id ) ? 'id="' . esc_attr( $id . '-' . $value ) . '"' : ''; ?>
199 aria-labelledby="hustle-checkbox-<?php echo esc_attr( $name ); ?>-label"
200 <?php echo empty( $description ) ? '' : 'aria-describedby="hustle-checkbox-' . esc_attr( $name ) . '-description"'; ?>
201 <?php $this->render_attributes( $attributes ); ?>
202 <?php
203 // If $value is not set, this is an on/off checkbox.
204 if ( ! $is_template ) {
205 checked( $selected_value, $selected );
206 } else {
207 echo '{{ _.checked( "' . esc_attr( $value ) . '", ' . esc_attr( $name ) . ' ) }}';
208 }
209 ?>
210 />
211 <span aria-hidden="true"></span>
212 <span id="hustle-checkbox-<?php echo esc_attr( $name ); ?>-label"><?php echo wp_kses_post( $label ); ?></span>
213
214 <?php if ( ! empty( $description ) ) : ?>
215 <span id="hustle-checkbox-<?php echo esc_attr( $name ); ?>-description" class="sui-description"><?php echo esc_html( $description ); ?></span>
216 <?php endif; ?>
217
218 </label>
219
220 <?php
221 break;
222
223 // ELEMENT: Toggle checkbox.
224 case 'checkbox_toggle':
225 ?>
226
227 <label
228 class="sui-toggle <?php echo isset( $class ) ? esc_attr( $class ) : ''; ?>"
229 <?php echo empty( $id ) ? '' : 'id="' . esc_attr( $id ) . '"'; ?>
230 <?php $this->render_attributes( $label_attributes ); ?>
231 >
232 <input
233 type="checkbox"
234 name="<?php echo esc_attr( $name ); ?>"
235 aria-labelledby="hustle-toggle-<?php echo esc_attr( $name ); ?>-label"
236 <?php echo empty( $value ) ? '' : 'value="' . esc_attr( $value ) . '"'; ?>
237 <?php echo empty( $description ) ? '' : 'aria-describedby="hustle-toggle-' . esc_attr( $name ) . '-description"'; ?>
238 <?php $this->render_attributes( $attributes ); ?>
239 <?php
240 if ( is_array( $selected ) ) {
241 checked( in_array( $value, $selected, true ) );
242 } elseif ( ! $is_template ) {
243 checked( $value, $selected );
244 } else {
245 echo '{{ _.checked( "' . esc_attr( $value ) . '", ' . esc_attr( $name ) . ' ) }}';
246 }
247 ?>
248 />
249 <span class="sui-toggle-slider" aria-hidden="true"></span>
250
251 <span id="hustle-toggle-<?php echo esc_attr( $name ); ?>-label" class="sui-toggle-label"><?php echo esc_html( $label ); ?></span>
252
253 <?php if ( ! empty( $description ) ) : ?>
254 <span id="hustle-toggle-<?php echo esc_attr( $name ); ?>-description" class="sui-description"><?php echo esc_html( $description ); ?></span>
255 <?php endif; ?>
256 </label>
257
258 <?php
259 break;
260
261 case 'side_tabs':
262 /**
263 * $options is an array, containing another array for each tab.
264 * This is the structure for each tab's array:
265 *
266 * Array(
267 * 'value' => string Input's value.
268 * 'label' => string Tab's label.
269 * 'has_content' => bool Optional. Default: false. Whether the tab has dependent content.
270 * 'content_id' => string Optional. ID of the dependent content IF 'content_htlm' isn't provided.
271 * 'content_html' => string Optional. Markup for the dependent content. Skip if 'content_id' is provided.
272 * 'content_label' => string Optional. Screen reader label for the content when 'content_html' is specified.
273 * )
274 */
275 $tabs_attributes = empty( $tabs_attributes ) ? array() : $tabs_attributes;
276 ?>
277 <div class="sui-tabs sui-side-tabs <?php echo empty( $class ) ? '' : esc_attr( $class ); ?>">
278
279 <?php foreach ( $options as $data ) { ?>
280 <input
281 type="radio"
282 name="<?php echo esc_attr( $name ); ?>"
283 value="<?php echo esc_attr( $data['value'] ); ?>"
284 id="hustle-<?php echo esc_attr( $name ); ?>--<?php echo esc_attr( $data['value'] ); ?>"
285 class="sui-screen-reader-text hustle-tabs-option"
286 aria-hidden="true"
287 tabindex="-1"
288 <?php $this->render_attributes( $attributes ); ?>
289 <?php
290 if ( ! $is_template ) {
291 checked( $data['value'], $selected );
292 } else {
293 echo '{{ _.checked( "' . esc_attr( $data['value'] ) . '", ' . esc_attr( $name ) . ' ) }}';
294 }
295 ?>
296 />
297
298 <?php } ?>
299
300 <div role="tablist" class="sui-tabs-menu">
301
302 <?php foreach ( $options as $data ) { ?>
303 <?php
304 if ( $data['has_content'] ) {
305 $tab_content_id = ! empty( $data['content_id'] ) ? $data['content_id'] : 'tab-content-' . $name . '-' . $data['value'] . '-settings';
306 }
307 ?>
308
309 <button
310 role="tab"
311 type="button"
312 id="tab-<?php echo esc_attr( $name ); ?>--<?php echo esc_attr( $data['value'] ); ?>"
313 class="sui-tab-item"
314 data-label-for="hustle-<?php echo esc_attr( $name ); ?>--<?php echo esc_attr( $data['value'] ); ?>"
315 <?php echo empty( $tab_content_id ) ? '' : ' aria-controls="' . esc_attr( $tab_content_id ) . '"'; ?>
316 aria-selected="false"
317 tabindex="-1"
318 ><?php echo esc_html( $data['label'] ); ?></button>
319
320 <?php } ?>
321
322 </div>
323
324 <div class="sui-tabs-content">
325
326 <?php
327 foreach ( $options as $data ) :
328
329 if ( empty( $data['content_html'] ) || empty( $data['has_content'] ) ) {
330 continue;
331 }
332
333 $tab_content_id = ! empty( $data['content_id'] ) ? $data['content_id'] : 'tab-content-' . $name . '-' . $data['value'] . '-settings';
334 ?>
335 <div
336 role="tabpanel"
337 tabindex="-1"
338 id="<?php echo esc_attr( $tab_content_id ); ?>"
339 class="sui-tab-content"
340 aria-label="<?php echo esc_attr( $data['content_label'] ); ?>"
341 <?php $this->render_attributes( $tabs_attributes ); ?>
342 >
343 <?php echo wp_kses_post( $data['content_html'] ); ?>
344 </div>
345
346 <?php endforeach; ?>
347
348 </div>
349
350 </div>
351
352 <?php
353 break;
354
355 // ELEMENT: Simple inline element.
356 case 'inline_element':
357 ?>
358 <<?php echo esc_attr( $tag ); ?>
359 <?php echo empty( $id ) ? '' : 'id="' . esc_attr( $id ) . '"'; ?>
360 <?php echo empty( $class ) ? '' : 'class="' . esc_attr( $class ) . '"'; ?>
361 <?php $this->render_attributes( $attributes ); ?>
362 >
363 <?php echo wp_kses_post( $value ); ?>
364 </<?php echo esc_attr( $tag ); ?>>
365 <?php
366 break;
367
368 // ELEMENT: Inline notice.
369 case 'inline_notice':
370 // We're assuming that if there's no value, this is an inline alert notice, not a static one.
371 $is_alert = empty( $value );
372 ?>
373
374 <div
375 <?php echo ! $is_alert ? '' : 'role="alert" aria-live="assertive"'; ?>
376 <?php echo ! empty( $id ) ? 'id="' . esc_attr( $id ) . '"' : ''; ?>
377 class="sui-notice <?php echo isset( $class ) ? esc_attr( $class ) : ''; ?>"
378 <?php $this->render_attributes( $attributes ); ?>
379 >
380
381 <?php if ( ! $is_alert ) : ?>
382
383 <div class="sui-notice-content">
384
385 <div class="sui-notice-message">
386
387 <?php if ( ! empty( $icon ) ) : ?>
388 <span class="sui-notice-icon sui-icon-<?php echo esc_attr( $icon ); ?> sui-md" aria-hidden="true"></span>
389 <?php endif; ?>
390 <p><?php echo wp_kses_post( $value ); ?></p>
391
392 </div>
393
394 </div>
395
396 <?php endif; ?>
397
398 </div>
399
400 <?php
401 break;
402
403 // ELEMENT: Simple input.
404 default:
405 $_value = ! $is_template ? $value : '{{' . $name . '}}';
406
407 if ( isset( $icon ) ) :
408 ?>
409 <div class="sui-control-with-icon">
410 <?php if ( 'before' === $icon_position ) : ?>
411 <span class="sui-icon-<?php echo esc_attr( $icon ); ?>" aria-hidden="true"></span>
412 <?php endif; ?>
413 <?php endif; ?>
414
415 <input
416 type="<?php echo esc_attr( $type ); ?>"
417 name="<?php echo esc_attr( $name ); ?>"
418 value="<?php echo esc_attr( $_value ); ?>"
419 <?php echo ( 'number' === $type && isset( $min ) && '' !== $min ) ? 'min="' . esc_attr( $min ) . '"' : ''; ?>
420 <?php echo ( 'number' === $type && isset( $max ) && '' !== $max ) ? 'max="' . esc_attr( $max ) . '"' : ''; ?>
421 class="sui-form-control<?php echo isset( $class ) ? ' ' . esc_attr( $class ) : ''; ?>"
422 <?php $this->render_attributes( $attributes ); ?>
423 <?php echo isset( $id ) ? 'id="' . esc_attr( $id ) . '"' : ''; ?>
424 <?php echo isset( $placeholder ) ? 'placeholder="' . esc_attr( $placeholder ) . '"' : ''; ?>
425 />
426
427 <?php if ( isset( $icon ) ) : ?>
428 <?php if ( 'after' === $icon_position ) : ?>
429 <i class="sui-icon-<?php echo esc_attr( $icon ); ?>" aria-hidden="true"></i>
430 <?php endif; ?>
431 </div>
432 <?php endif; ?>
433
434 <?php
435 endswitch;
436