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