PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.4.6
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.4.6
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 4 years ago sui-wizard 4 years ago wizard 5 years ago modal-template.php 5 years ago options.php 5 years ago pagination.php 5 years ago view-documentation.php 5 years ago
options.php
428 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 * @phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
46 */
47
48 // Flag for when the option is used in underscore template files.
49 $is_template = isset( $is_template ) ? $is_template : false;
50 $attributes = isset( $attributes ) ? $attributes : array();
51
52 $label_attributes = isset( $label_attributes ) ? $label_attributes : array();
53
54 switch ( $type ) :
55
56 // ELEMENT: Wrapper div.
57 case 'wrapper':
58 ?>
59 <div
60 <?php echo empty( $id ) ? '' : 'id="' . esc_attr( $id ) . '"'; ?>
61 <?php echo empty( $class ) ? '' : 'class="' . esc_attr( $class ) . '"'; ?>
62 <?php $this->render_attributes( $attributes ); ?>
63 >
64 <?php
65 foreach ( $elements as $element ) {
66 $this->render( 'admin/commons/options', $element );
67 }
68 ?>
69 </div>
70
71 <?php
72 break;
73
74 // ELEMENT: Select.
75 case 'select':
76 if ( self::$dont_init_selects &&
77 0 !== strpos( $name, 'custom_height_unit' ) && 0 !== strpos( $name, 'custom_width_unit' ) ) {
78 $new_class = ' none-sui';
79 $class = empty( $class ) ? $new_class : $class . $new_class;
80 }
81 ?>
82 <select
83 id="<?php echo empty( $id ) ? 'hustle-select-' . esc_attr( $name ) : esc_attr( $id ); ?>"
84 name="<?php echo esc_attr( $name ); ?>"
85 <?php echo empty( $class ) ? '' : 'class="' . esc_attr( $class ) . '"'; ?>
86 <?php echo empty( $placeholder ) ? '' : 'data-placeholder="' . esc_attr( $placeholder ) . '"'; ?>
87 <?php $this->render_attributes( $attributes ); ?>
88 tabindex="-1"
89 aria-hidden="true"
90 >
91
92 <?php if ( ! empty( $placeholder ) ) : ?>
93 <option></option>
94 <?php
95 endif;
96
97 // Fully server's side rendered field.
98 if ( ! $is_template ) :
99
100 foreach ( $options as $value => $label ) :
101 $label = ! empty( $label ) ? $label : '&#8205;';
102 $_selected = is_array( $selected ) && empty( $selected ) ? '' : $selected;
103 ?>
104 <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $_selected, $value ); ?>>
105 <?php echo esc_html( $label ); ?>
106 </option>
107 <?php
108 endforeach;
109
110 else :
111
112 foreach ( $options as $value => $label ) :
113 ?>
114 <option value="<?php echo esc_attr( $value ); ?>" {{ _.selected( <?php echo $name; ?>, '<?php echo $value; ?>' ) }}>
115 <?php echo esc_html( $label ); ?>
116 </option>
117 <?php
118 endforeach;
119
120 endif;
121 ?>
122
123 </select>
124
125 <?php
126 break;
127
128 // ELEMENT: Multiple checkboxes.
129 case 'checkboxes':
130 // Fully server's side rendered field.
131 if ( ! $is_template ) :
132
133 $_selected = isset( $selected ) ? $selected : array();
134 if ( ! is_array( $_selected ) ) {
135 $_selected = array( $_selected );
136 }
137
138 foreach ( $options as $value => $label ) :
139 ?>
140
141 <label class="sui-checkbox <?php echo isset( $class ) ? esc_attr( $class ) : ''; ?>">
142
143 <input
144 type="checkbox"
145 name="<?php echo esc_attr( $name ); ?>"
146 value="<?php echo esc_attr( $value ); ?>"
147 <?php echo isset( $id ) ? 'id="' . esc_attr( $id . '-' . $value ) . '"' : ''; ?>
148 <?php $this->render_attributes( $attributes ); ?>
149 <?php checked( in_array( $value, $_selected, true ) ); ?>
150 />
151
152 <span aria-hidden="true"></span>
153
154 <span><?php echo esc_html( $label ); ?></span>
155
156 </label>
157
158 <?php
159 endforeach;
160
161 else : // Field expecting parameters from underscore templating.
162
163 foreach ( $options as $value => $label ) :
164 ?>
165
166 <label class="sui-checkbox <?php echo isset( $class ) ? esc_attr( $class ) : ''; ?>">
167
168 <input
169 type="checkbox"
170 name="<?php echo esc_attr( $name ); ?>"
171 value="<?php echo esc_attr( $value ); ?>"
172 <?php echo isset( $id ) ? 'id="' . esc_attr( $id . '-' . $value ) . '"' : ''; ?>
173 <?php $this->render_attributes( $attributes ); ?>
174 {{ _.checked( <?php echo $name; ?>.includes( '<?php echo $value; ?>' ), true ) }}
175 />
176
177 <span aria-hidden="true"></span>
178 <span><?php echo esc_html( $label ); ?></span>
179
180 </label>
181
182 <?php
183 endforeach;
184
185 endif;
186 break;
187
188 // ELEMENT: Checkbox.
189 case 'checkbox':
190 // If $value is not set, this is an on/off checkbox.
191 if ( ! isset( $value ) ) {
192 $_checked = ! $is_template ? checked( '1', $selected, false ) : '{{ _.checked( "1", ' . $name . ' ) }}';
193 } else {
194 $_checked = ! $is_template ? checked( $value, $selected, false ) : '{{ _.checked( "' . $value . '", ' . $name . ' ) }}';
195 }
196 ?>
197
198 <label class="sui-checkbox <?php echo isset( $class ) ? esc_attr( $class ) : ''; ?>" <?php $this->render_attributes( $label_attributes ); ?>>
199
200 <input
201 type="checkbox"
202 name="<?php echo esc_attr( $name ); ?>"
203 <?php echo isset( $value ) ? 'value="' . esc_attr( $value ) . '"' : ''; ?>
204 <?php echo isset( $id ) ? 'id="' . esc_attr( $id . '-' . $value ) . '"' : ''; ?>
205 aria-labelledby="hustle-checkbox-<?php echo esc_attr( $name ); ?>-label"
206 <?php echo empty( $description ) ? '' : 'aria-describedby="hustle-checkbox-' . esc_attr( $name ) . '-description"'; ?>
207 <?php $this->render_attributes( $attributes ); ?>
208 <?php echo $_checked; ?>
209 />
210 <span aria-hidden="true"></span>
211 <span id="hustle-checkbox-<?php echo esc_attr( $name ); ?>-label"><?php echo wp_kses_post( $label ); ?></span>
212
213 <?php if ( ! empty( $description ) ) : ?>
214 <span id="hustle-checkbox-<?php echo esc_attr( $name ); ?>-description" class="sui-description"><?php echo esc_html( $description ); ?></span>
215 <?php endif; ?>
216
217 </label>
218
219 <?php
220 break;
221
222 // ELEMENT: Toggle checkbox.
223 case 'checkbox_toggle':
224 if ( is_array( $selected ) ) {
225 $_checked = checked( in_array( $value, $selected, true ), true, false );
226 } else {
227 $_checked = ! $is_template ? checked( $value, $selected, false ) : '{{ _.checked( "' . $value . '", ' . $name . ' ) }}';
228 }
229 ?>
230
231 <label
232 class="sui-toggle <?php echo isset( $class ) ? esc_attr( $class ) : ''; ?>"
233 <?php echo empty( $id ) ? '' : 'id="' . esc_attr( $id ) . '"'; ?>
234 <?php $this->render_attributes( $label_attributes ); ?>
235 >
236 <input
237 type="checkbox"
238 name="<?php echo esc_attr( $name ); ?>"
239 aria-labelledby="hustle-toggle-<?php echo esc_attr( $name ); ?>-label"
240 <?php echo empty( $value ) ? '' : 'value="' . esc_attr( $value ) . '"'; ?>
241 <?php echo empty( $description ) ? '' : 'aria-describedby="hustle-toggle-' . esc_attr( $name ) . '-description"'; ?>
242 <?php $this->render_attributes( $attributes ); ?>
243 <?php echo $_checked; ?>
244 />
245 <span class="sui-toggle-slider" aria-hidden="true"></span>
246
247 <span id="hustle-toggle-<?php echo esc_attr( $name ); ?>-label" class="sui-toggle-label"><?php echo esc_html( $label ); ?></span>
248
249 <?php if ( ! empty( $description ) ) : ?>
250 <span id="hustle-toggle-<?php echo esc_attr( $name ); ?>-description" class="sui-description"><?php echo esc_html( $description ); ?></span>
251 <?php endif; ?>
252 </label>
253
254 <?php
255 break;
256
257 case 'side_tabs':
258 /**
259 * $options is an array, containing another array for each tab.
260 * This is the structure for each tab's array:
261 *
262 * Array(
263 * 'value' => string Input's value.
264 * 'label' => string Tab's label.
265 * 'has_content' => bool Optional. Default: false. Whether the tab has dependent content.
266 * 'content_id' => string Optional. ID of the dependent content IF 'content_htlm' isn't provided.
267 * 'content_html' => string Optional. Markup for the dependent content. Skip if 'content_id' is provided.
268 * 'content_label' => string Optional. Screen reader label for the content when 'content_html' is specified.
269 * )
270 */
271 $tabs_attributes = empty( $tabs_attributes ) ? array() : $tabs_attributes;
272 ?>
273 <div class="sui-tabs sui-side-tabs <?php echo empty( $class ) ? '' : esc_attr( $class ); ?>">
274
275 <?php foreach ( $options as $data ) { ?>
276 <?php $_checked = ! $is_template ? checked( $data['value'], $selected, false ) : '{{ _.checked( "' . $data['value'] . '", ' . $name . ' ) }}'; ?>
277
278 <input
279 type="radio"
280 name="<?php echo esc_attr( $name ); ?>"
281 value="<?php echo esc_attr( $data['value'] ); ?>"
282 id="hustle-<?php echo esc_attr( $name ); ?>--<?php echo esc_attr( $data['value'] ); ?>"
283 class="sui-screen-reader-text hustle-tabs-option"
284 aria-hidden="true"
285 tabindex="-1"
286 <?php $this->render_attributes( $attributes ); ?>
287 <?php echo $_checked; ?>
288 />
289
290 <?php } ?>
291
292 <div role="tablist" class="sui-tabs-menu">
293
294 <?php foreach ( $options as $data ) { ?>
295 <?php
296 if ( $data['has_content'] ) {
297 $tab_content_id = ! empty( $data['content_id'] ) ? $data['content_id'] : 'tab-content-' . $name . '-' . $data['value'] . '-settings';
298 }
299 ?>
300
301 <button
302 role="tab"
303 type="button"
304 id="tab-<?php echo esc_attr( $name ); ?>--<?php echo esc_attr( $data['value'] ); ?>"
305 class="sui-tab-item"
306 data-label-for="hustle-<?php echo esc_attr( $name ); ?>--<?php echo esc_attr( $data['value'] ); ?>"
307 <?php echo empty( $tab_content_id ) ? '' : ' aria-controls="' . esc_attr( $tab_content_id ) . '"'; ?>
308 aria-selected="false"
309 tabindex="-1"
310 ><?php echo esc_html( $data['label'] ); ?></button>
311
312 <?php } ?>
313
314 </div>
315
316 <div class="sui-tabs-content">
317
318 <?php
319 foreach ( $options as $data ) :
320
321 if ( empty( $data['content_html'] ) || empty( $data['has_content'] ) ) {
322 continue;
323 }
324
325 $tab_content_id = ! empty( $data['content_id'] ) ? $data['content_id'] : 'tab-content-' . $name . '-' . $data['value'] . '-settings';
326 ?>
327 <div
328 role="tabpanel"
329 tabindex="-1"
330 id="<?php echo esc_attr( $tab_content_id ); ?>"
331 class="sui-tab-content"
332 aria-label="<?php echo esc_attr( $data['content_label'] ); ?>"
333 <?php $this->render_attributes( $tabs_attributes ); ?>
334 >
335 <?php echo $data['content_html']; ?>
336 </div>
337
338 <?php endforeach; ?>
339
340 </div>
341
342 </div>
343
344 <?php
345 break;
346
347 // ELEMENT: Simple inline element.
348 case 'inline_element':
349 ?>
350 <<?php echo esc_attr( $tag ); ?>
351 <?php echo empty( $id ) ? '' : 'id="' . esc_attr( $id ) . '"'; ?>
352 <?php echo empty( $class ) ? '' : 'class="' . esc_attr( $class ) . '"'; ?>
353 <?php $this->render_attributes( $attributes ); ?>
354 >
355 <?php echo wp_kses_post( $value ); ?>
356 </<?php echo esc_attr( $tag ); ?>>
357 <?php
358 break;
359
360 // ELEMENT: Inline notice.
361 case 'inline_notice':
362 // We're assuming that if there's no value, this is an inline alert notice, not a static one.
363 $is_alert = empty( $value );
364 ?>
365
366 <div
367 <?php echo ! $is_alert ? '' : 'role="alert" aria-live="assertive"'; ?>
368 <?php echo ! empty( $id ) ? 'id="' . esc_attr( $id ) . '"' : ''; ?>
369 class="sui-notice <?php echo isset( $class ) ? esc_attr( $class ) : ''; ?>"
370 <?php $this->render_attributes( $attributes ); ?>
371 >
372
373 <?php if ( ! $is_alert ) : ?>
374
375 <div class="sui-notice-content">
376
377 <div class="sui-notice-message">
378
379 <?php if ( ! empty( $icon ) ) : ?>
380 <span class="sui-notice-icon sui-icon-<?php echo esc_attr( $icon ); ?> sui-md" aria-hidden="true"></span>
381 <?php endif; ?>
382 <p><?php echo $value; // Make sure $value is properly escaped! We're not escaping it in here. ?></p>
383
384 </div>
385
386 </div>
387
388 <?php endif; ?>
389
390 </div>
391
392 <?php
393 break;
394
395 // ELEMENT: Simple input.
396 default:
397 $_value = ! $is_template ? $value : '{{' . $name . '}}';
398
399 if ( isset( $icon ) ) :
400 ?>
401 <div class="sui-control-with-icon">
402 <?php if ( 'before' === $icon_position ) : ?>
403 <span class="sui-icon-<?php echo esc_attr( $icon ); ?>" aria-hidden="true"></span>
404 <?php endif; ?>
405 <?php endif; ?>
406
407 <input
408 type="<?php echo esc_attr( $type ); ?>"
409 name="<?php echo esc_attr( $name ); ?>"
410 value="<?php echo esc_attr( $_value ); ?>"
411 <?php echo ( 'number' === $type && isset( $min ) && '' !== $min ) ? 'min="' . esc_attr( $min ) . '"' : ''; ?>
412 <?php echo ( 'number' === $type && isset( $max ) && '' !== $max ) ? 'max="' . esc_attr( $max ) . '"' : ''; ?>
413 class="sui-form-control<?php echo isset( $class ) ? ' ' . esc_attr( $class ) : ''; ?>"
414 <?php $this->render_attributes( $attributes ); ?>
415 <?php echo isset( $id ) ? 'id="' . esc_attr( $id ) . '"' : ''; ?>
416 <?php echo isset( $placeholder ) ? 'placeholder="' . esc_attr( $placeholder ) . '"' : ''; ?>
417 />
418
419 <?php if ( isset( $icon ) ) : ?>
420 <?php if ( 'after' === $icon_position ) : ?>
421 <i class="sui-icon-<?php echo esc_attr( $icon ); ?>" aria-hidden="true"></i>
422 <?php endif; ?>
423 </div>
424 <?php endif; ?>
425
426 <?php
427 endswitch;
428