@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; // Exit if accessed directly |
5 | 5 | } |
6 | 6 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return string The rendered component. |
20 | 20 | */ |
21 | - public static function input($args = array()){ |
|
21 | + public static function input($args = array()) { |
|
22 | 22 | $defaults = array( |
23 | 23 | 'type' => 'text', |
24 | 24 | 'name' => '', |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * Parse incoming $args into an array and merge it with $defaults |
54 | 54 | */ |
55 | - $args = wp_parse_args( $args, $defaults ); |
|
55 | + $args = wp_parse_args($args, $defaults); |
|
56 | 56 | $output = ''; |
57 | - if ( ! empty( $args['type'] ) ) { |
|
57 | + if (!empty($args['type'])) { |
|
58 | 58 | // hidden label option needs to be empty |
59 | 59 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
60 | 60 | |
61 | - $type = sanitize_html_class( $args['type'] ); |
|
61 | + $type = sanitize_html_class($args['type']); |
|
62 | 62 | |
63 | 63 | $help_text = ''; |
64 | 64 | $label = ''; |
@@ -66,24 +66,24 @@ discard block |
||
66 | 66 | $label_args = array( |
67 | 67 | 'title'=> $args['label'], |
68 | 68 | 'for'=> $args['id'], |
69 | - 'class' => $args['label_class']." ", |
|
69 | + 'class' => $args['label_class'] . " ", |
|
70 | 70 | 'label_type' => $args['label_type'] |
71 | 71 | ); |
72 | 72 | |
73 | 73 | // floating labels need label after |
74 | - if( $args['label_type'] == 'floating' && $type != 'checkbox' ){ |
|
74 | + if ($args['label_type'] == 'floating' && $type != 'checkbox') { |
|
75 | 75 | $label_after = true; |
76 | 76 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
77 | 77 | } |
78 | 78 | |
79 | 79 | // Some special sauce for files |
80 | - if($type=='file' ){ |
|
80 | + if ($type == 'file') { |
|
81 | 81 | $label_after = true; // if type file we need the label after |
82 | 82 | $args['class'] .= ' custom-file-input '; |
83 | - }elseif($type=='checkbox'){ |
|
83 | + }elseif ($type == 'checkbox') { |
|
84 | 84 | $label_after = true; // if type file we need the label after |
85 | 85 | $args['class'] .= ' custom-control-input '; |
86 | - }elseif($type=='datepicker' || $type=='timepicker'){ |
|
86 | + }elseif ($type == 'datepicker' || $type == 'timepicker') { |
|
87 | 87 | $type = 'text'; |
88 | 88 | //$args['class'] .= ' aui-flatpickr bg-initial '; |
89 | 89 | $args['class'] .= ' bg-initial '; |
@@ -99,65 +99,65 @@ discard block |
||
99 | 99 | $output .= '<input type="' . $type . '" '; |
100 | 100 | |
101 | 101 | // name |
102 | - if(!empty($args['name'])){ |
|
103 | - $output .= ' name="'.esc_attr($args['name']).'" '; |
|
102 | + if (!empty($args['name'])) { |
|
103 | + $output .= ' name="' . esc_attr($args['name']) . '" '; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // id |
107 | - if(!empty($args['id'])){ |
|
108 | - $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
107 | + if (!empty($args['id'])) { |
|
108 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // placeholder |
112 | - if(isset($args['placeholder']) && '' != $args['placeholder'] ){ |
|
113 | - $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
112 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
113 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // title |
117 | - if(!empty($args['title'])){ |
|
118 | - $output .= ' title="'.esc_attr($args['title']).'" '; |
|
117 | + if (!empty($args['title'])) { |
|
118 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | // value |
122 | - if(!empty($args['value'])){ |
|
123 | - $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
122 | + if (!empty($args['value'])) { |
|
123 | + $output .= ' value="' . sanitize_text_field($args['value']) . '" '; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // checked, for radio and checkboxes |
127 | - if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){ |
|
127 | + if (($type == 'checkbox' || $type == 'radio') && $args['checked']) { |
|
128 | 128 | $output .= ' checked '; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // validation text |
132 | - if(!empty($args['validation_text'])){ |
|
133 | - $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
132 | + if (!empty($args['validation_text'])) { |
|
133 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" '; |
|
134 | 134 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
135 | 135 | } |
136 | 136 | |
137 | 137 | // validation_pattern |
138 | - if(!empty($args['validation_pattern'])){ |
|
139 | - $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
138 | + if (!empty($args['validation_pattern'])) { |
|
139 | + $output .= ' pattern="' . $args['validation_pattern'] . '" '; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | // step (for numbers) |
143 | - if(!empty($args['step'])){ |
|
144 | - $output .= ' step="'.$args['step'].'" '; |
|
143 | + if (!empty($args['step'])) { |
|
144 | + $output .= ' step="' . $args['step'] . '" '; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | // required |
148 | - if(!empty($args['required'])){ |
|
148 | + if (!empty($args['required'])) { |
|
149 | 149 | $output .= ' required '; |
150 | 150 | } |
151 | 151 | |
152 | 152 | // class |
153 | - $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
154 | - $output .= ' class="form-control '.$class.'" '; |
|
153 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
154 | + $output .= ' class="form-control ' . $class . '" '; |
|
155 | 155 | |
156 | 156 | // data-attributes |
157 | 157 | $output .= AUI_Component_Helper::data_attributes($args); |
158 | 158 | |
159 | 159 | // extra attributes |
160 | - if(!empty($args['extra_attributes'])){ |
|
160 | + if (!empty($args['extra_attributes'])) { |
|
161 | 161 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
162 | 162 | } |
163 | 163 | |
@@ -166,40 +166,40 @@ discard block |
||
166 | 166 | |
167 | 167 | |
168 | 168 | // label |
169 | - if(!empty($args['label'])){ |
|
170 | - if($type == 'file'){$label_args['class'] .= 'custom-file-label';} |
|
171 | - elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';} |
|
172 | - $label = self::label( $label_args, $type ); |
|
169 | + if (!empty($args['label'])) { |
|
170 | + if ($type == 'file') {$label_args['class'] .= 'custom-file-label'; } |
|
171 | + elseif ($type == 'checkbox') {$label_args['class'] .= 'custom-control-label'; } |
|
172 | + $label = self::label($label_args, $type); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | // help text |
176 | - if(!empty($args['help_text'])){ |
|
176 | + if (!empty($args['help_text'])) { |
|
177 | 177 | $help_text = AUI_Component_Helper::help_text($args['help_text']); |
178 | 178 | } |
179 | 179 | |
180 | 180 | |
181 | 181 | // set help text in the correct possition |
182 | - if($label_after){ |
|
182 | + if ($label_after) { |
|
183 | 183 | $output .= $label . $help_text; |
184 | 184 | } |
185 | 185 | |
186 | 186 | // some input types need a separate wrap |
187 | - if($type == 'file') { |
|
188 | - $output = self::wrap( array( |
|
187 | + if ($type == 'file') { |
|
188 | + $output = self::wrap(array( |
|
189 | 189 | 'content' => $output, |
190 | 190 | 'class' => 'form-group custom-file' |
191 | - ) ); |
|
192 | - }elseif($type == 'checkbox'){ |
|
191 | + )); |
|
192 | + }elseif ($type == 'checkbox') { |
|
193 | 193 | $wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox'; |
194 | - $output = self::wrap( array( |
|
194 | + $output = self::wrap(array( |
|
195 | 195 | 'content' => $output, |
196 | - 'class' => 'custom-control '.$wrap_class |
|
197 | - ) ); |
|
196 | + 'class' => 'custom-control ' . $wrap_class |
|
197 | + )); |
|
198 | 198 | |
199 | - if($args['label_type']=='horizontal'){ |
|
199 | + if ($args['label_type'] == 'horizontal') { |
|
200 | 200 | $output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>'; |
201 | 201 | } |
202 | - }elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){ |
|
202 | + }elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) { |
|
203 | 203 | |
204 | 204 | |
205 | 205 | // allow password field to toggle view |
@@ -213,49 +213,49 @@ discard block |
||
213 | 213 | } |
214 | 214 | |
215 | 215 | // input group wraps |
216 | - if($args['input_group_left'] || $args['input_group_right']){ |
|
216 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
217 | 217 | $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
218 | - if($args['input_group_left']){ |
|
219 | - $output = self::wrap( array( |
|
218 | + if ($args['input_group_left']) { |
|
219 | + $output = self::wrap(array( |
|
220 | 220 | 'content' => $output, |
221 | - 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
221 | + 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
222 | 222 | 'input_group_left' => $args['input_group_left'], |
223 | 223 | 'input_group_left_inside' => $args['input_group_left_inside'] |
224 | - ) ); |
|
224 | + )); |
|
225 | 225 | } |
226 | - if($args['input_group_right']){ |
|
227 | - $output = self::wrap( array( |
|
226 | + if ($args['input_group_right']) { |
|
227 | + $output = self::wrap(array( |
|
228 | 228 | 'content' => $output, |
229 | - 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
229 | + 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
230 | 230 | 'input_group_right' => $args['input_group_right'], |
231 | 231 | 'input_group_right_inside' => $args['input_group_right_inside'] |
232 | - ) ); |
|
232 | + )); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | } |
236 | 236 | |
237 | - if(!$label_after){ |
|
237 | + if (!$label_after) { |
|
238 | 238 | $output .= $help_text; |
239 | 239 | } |
240 | 240 | |
241 | 241 | |
242 | - if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
243 | - $output = self::wrap( array( |
|
242 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
243 | + $output = self::wrap(array( |
|
244 | 244 | 'content' => $output, |
245 | 245 | 'class' => 'col-sm-10', |
246 | - ) ); |
|
246 | + )); |
|
247 | 247 | } |
248 | 248 | |
249 | - if(!$label_after){ |
|
249 | + if (!$label_after) { |
|
250 | 250 | $output = $label . $output; |
251 | 251 | } |
252 | 252 | |
253 | 253 | // wrap |
254 | - if(!$args['no_wrap']){ |
|
254 | + if (!$args['no_wrap']) { |
|
255 | 255 | |
256 | - $form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
|
257 | - $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
258 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
256 | + $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
|
257 | + $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
258 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
259 | 259 | $output = self::wrap(array( |
260 | 260 | 'content' => $output, |
261 | 261 | 'class' => $wrap_class, |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return string The rendered component. |
280 | 280 | */ |
281 | - public static function textarea($args = array()){ |
|
281 | + public static function textarea($args = array()) { |
|
282 | 282 | $defaults = array( |
283 | 283 | 'name' => '', |
284 | 284 | 'class' => '', |
@@ -306,43 +306,43 @@ discard block |
||
306 | 306 | /** |
307 | 307 | * Parse incoming $args into an array and merge it with $defaults |
308 | 308 | */ |
309 | - $args = wp_parse_args( $args, $defaults ); |
|
309 | + $args = wp_parse_args($args, $defaults); |
|
310 | 310 | $output = ''; |
311 | 311 | |
312 | 312 | // hidden label option needs to be empty |
313 | 313 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
314 | 314 | |
315 | 315 | // floating labels don't work with wysiwyg so set it as top |
316 | - if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){ |
|
316 | + if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) { |
|
317 | 317 | $args['label_type'] = 'top'; |
318 | 318 | } |
319 | 319 | |
320 | 320 | $label_after = $args['label_after']; |
321 | 321 | |
322 | 322 | // floating labels need label after |
323 | - if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){ |
|
323 | + if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) { |
|
324 | 324 | $label_after = true; |
325 | 325 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
326 | 326 | } |
327 | 327 | |
328 | 328 | // label |
329 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
330 | - }elseif(!empty($args['label']) && !$label_after){ |
|
329 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
330 | + }elseif (!empty($args['label']) && !$label_after) { |
|
331 | 331 | $label_args = array( |
332 | 332 | 'title'=> $args['label'], |
333 | 333 | 'for'=> $args['id'], |
334 | - 'class' => $args['label_class']." ", |
|
334 | + 'class' => $args['label_class'] . " ", |
|
335 | 335 | 'label_type' => $args['label_type'] |
336 | 336 | ); |
337 | - $output .= self::label( $label_args ); |
|
337 | + $output .= self::label($label_args); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | // maybe horizontal label |
341 | - if($args['label_type']=='horizontal'){ |
|
341 | + if ($args['label_type'] == 'horizontal') { |
|
342 | 342 | $output .= '<div class="col-sm-10">'; |
343 | 343 | } |
344 | 344 | |
345 | - if(!empty($args['wysiwyg'])){ |
|
345 | + if (!empty($args['wysiwyg'])) { |
|
346 | 346 | ob_start(); |
347 | 347 | $content = $args['value']; |
348 | 348 | $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor'; |
@@ -356,65 +356,65 @@ discard block |
||
356 | 356 | ); |
357 | 357 | |
358 | 358 | // maybe set settings if array |
359 | - if(is_array($args['wysiwyg'])){ |
|
360 | - $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
359 | + if (is_array($args['wysiwyg'])) { |
|
360 | + $settings = wp_parse_args($args['wysiwyg'], $settings); |
|
361 | 361 | } |
362 | 362 | |
363 | - wp_editor( $content, $editor_id, $settings ); |
|
363 | + wp_editor($content, $editor_id, $settings); |
|
364 | 364 | $output .= ob_get_clean(); |
365 | - }else{ |
|
365 | + } else { |
|
366 | 366 | |
367 | 367 | // open |
368 | 368 | $output .= '<textarea '; |
369 | 369 | |
370 | 370 | // name |
371 | - if(!empty($args['name'])){ |
|
372 | - $output .= ' name="'.sanitize_html_class($args['name']).'" '; |
|
371 | + if (!empty($args['name'])) { |
|
372 | + $output .= ' name="' . sanitize_html_class($args['name']) . '" '; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | // id |
376 | - if(!empty($args['id'])){ |
|
377 | - $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
376 | + if (!empty($args['id'])) { |
|
377 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | // placeholder |
381 | - if(isset($args['placeholder']) && '' != $args['placeholder']){ |
|
382 | - $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
381 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
382 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | // title |
386 | - if(!empty($args['title'])){ |
|
387 | - $output .= ' title="'.esc_attr($args['title']).'" '; |
|
386 | + if (!empty($args['title'])) { |
|
387 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | // validation text |
391 | - if(!empty($args['validation_text'])){ |
|
392 | - $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
391 | + if (!empty($args['validation_text'])) { |
|
392 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" '; |
|
393 | 393 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
394 | 394 | } |
395 | 395 | |
396 | 396 | // validation_pattern |
397 | - if(!empty($args['validation_pattern'])){ |
|
398 | - $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
397 | + if (!empty($args['validation_pattern'])) { |
|
398 | + $output .= ' pattern="' . $args['validation_pattern'] . '" '; |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | // required |
402 | - if(!empty($args['required'])){ |
|
402 | + if (!empty($args['required'])) { |
|
403 | 403 | $output .= ' required '; |
404 | 404 | } |
405 | 405 | |
406 | 406 | // rows |
407 | - if(!empty($args['rows'])){ |
|
408 | - $output .= ' rows="'.absint($args['rows']).'" '; |
|
407 | + if (!empty($args['rows'])) { |
|
408 | + $output .= ' rows="' . absint($args['rows']) . '" '; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | |
412 | 412 | // class |
413 | 413 | $class = !empty($args['class']) ? $args['class'] : ''; |
414 | - $output .= ' class="form-control '.$class.'" '; |
|
414 | + $output .= ' class="form-control ' . $class . '" '; |
|
415 | 415 | |
416 | 416 | // extra attributes |
417 | - if(!empty($args['extra_attributes'])){ |
|
417 | + if (!empty($args['extra_attributes'])) { |
|
418 | 418 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
419 | 419 | } |
420 | 420 | |
@@ -422,11 +422,11 @@ discard block |
||
422 | 422 | $output .= ' >'; |
423 | 423 | |
424 | 424 | // value |
425 | - if ( ! empty( $args['value'] ) ) { |
|
426 | - if ( ! empty( $args['allow_tags'] ) ) { |
|
427 | - $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
425 | + if (!empty($args['value'])) { |
|
426 | + if (!empty($args['allow_tags'])) { |
|
427 | + $output .= AUI_Component_Helper::sanitize_html_field($args['value'], $args); // Sanitize HTML. |
|
428 | 428 | } else { |
429 | - $output .= sanitize_textarea_field( $args['value'] ); |
|
429 | + $output .= sanitize_textarea_field($args['value']); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
@@ -435,32 +435,32 @@ discard block |
||
435 | 435 | |
436 | 436 | } |
437 | 437 | |
438 | - if(!empty($args['label']) && $label_after){ |
|
438 | + if (!empty($args['label']) && $label_after) { |
|
439 | 439 | $label_args = array( |
440 | 440 | 'title'=> $args['label'], |
441 | 441 | 'for'=> $args['id'], |
442 | - 'class' => $args['label_class']." ", |
|
442 | + 'class' => $args['label_class'] . " ", |
|
443 | 443 | 'label_type' => $args['label_type'] |
444 | 444 | ); |
445 | - $output .= self::label( $label_args ); |
|
445 | + $output .= self::label($label_args); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | // help text |
449 | - if(!empty($args['help_text'])){ |
|
449 | + if (!empty($args['help_text'])) { |
|
450 | 450 | $output .= AUI_Component_Helper::help_text($args['help_text']); |
451 | 451 | } |
452 | 452 | |
453 | 453 | // maybe horizontal label |
454 | - if($args['label_type']=='horizontal'){ |
|
454 | + if ($args['label_type'] == 'horizontal') { |
|
455 | 455 | $output .= '</div>'; |
456 | 456 | } |
457 | 457 | |
458 | 458 | |
459 | 459 | // wrap |
460 | - if(!$args['no_wrap']){ |
|
461 | - $form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group'; |
|
462 | - $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
463 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
460 | + if (!$args['no_wrap']) { |
|
461 | + $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group'; |
|
462 | + $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
463 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
464 | 464 | $output = self::wrap(array( |
465 | 465 | 'content' => $output, |
466 | 466 | 'class' => $wrap_class, |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | return $output; |
474 | 474 | } |
475 | 475 | |
476 | - public static function label($args = array(), $type = ''){ |
|
476 | + public static function label($args = array(), $type = '') { |
|
477 | 477 | //<label for="exampleInputEmail1">Email address</label> |
478 | 478 | $defaults = array( |
479 | 479 | 'title' => 'div', |
@@ -485,20 +485,20 @@ discard block |
||
485 | 485 | /** |
486 | 486 | * Parse incoming $args into an array and merge it with $defaults |
487 | 487 | */ |
488 | - $args = wp_parse_args( $args, $defaults ); |
|
488 | + $args = wp_parse_args($args, $defaults); |
|
489 | 489 | $output = ''; |
490 | 490 | |
491 | - if($args['title']){ |
|
491 | + if ($args['title']) { |
|
492 | 492 | |
493 | 493 | // maybe hide labels //@todo set a global option for visibility class |
494 | - if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){ |
|
494 | + if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) { |
|
495 | 495 | $class = $args['class']; |
496 | - }else{ |
|
497 | - $class = 'sr-only '.$args['class']; |
|
496 | + } else { |
|
497 | + $class = 'sr-only ' . $args['class']; |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | // maybe horizontal |
501 | - if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
501 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
502 | 502 | $class .= ' col-sm-2 col-form-label'; |
503 | 503 | } |
504 | 504 | |
@@ -506,20 +506,20 @@ discard block |
||
506 | 506 | $output .= '<label '; |
507 | 507 | |
508 | 508 | // for |
509 | - if(!empty($args['for'])){ |
|
510 | - $output .= ' for="'.sanitize_text_field($args['for']).'" '; |
|
509 | + if (!empty($args['for'])) { |
|
510 | + $output .= ' for="' . sanitize_text_field($args['for']) . '" '; |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | // class |
514 | - $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
515 | - $output .= ' class="'.$class.'" '; |
|
514 | + $class = $class ? AUI_Component_Helper::esc_classes($class) : ''; |
|
515 | + $output .= ' class="' . $class . '" '; |
|
516 | 516 | |
517 | 517 | // close |
518 | 518 | $output .= '>'; |
519 | 519 | |
520 | 520 | |
521 | 521 | // title, don't escape fully as can contain html |
522 | - if(!empty($args['title'])){ |
|
522 | + if (!empty($args['title'])) { |
|
523 | 523 | $output .= wp_kses_post($args['title']); |
524 | 524 | } |
525 | 525 | |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return string |
542 | 542 | */ |
543 | - public static function wrap($args = array()){ |
|
543 | + public static function wrap($args = array()) { |
|
544 | 544 | $defaults = array( |
545 | 545 | 'type' => 'div', |
546 | 546 | 'class' => 'form-group', |
@@ -556,55 +556,55 @@ discard block |
||
556 | 556 | /** |
557 | 557 | * Parse incoming $args into an array and merge it with $defaults |
558 | 558 | */ |
559 | - $args = wp_parse_args( $args, $defaults ); |
|
559 | + $args = wp_parse_args($args, $defaults); |
|
560 | 560 | $output = ''; |
561 | - if($args['type']){ |
|
561 | + if ($args['type']) { |
|
562 | 562 | |
563 | 563 | // open |
564 | - $output .= '<'.sanitize_html_class($args['type']); |
|
564 | + $output .= '<' . sanitize_html_class($args['type']); |
|
565 | 565 | |
566 | 566 | // element require |
567 | - if(!empty($args['element_require'])){ |
|
567 | + if (!empty($args['element_require'])) { |
|
568 | 568 | $output .= AUI_Component_Helper::element_require($args['element_require']); |
569 | 569 | $args['class'] .= " aui-conditional-field"; |
570 | 570 | } |
571 | 571 | |
572 | 572 | // argument_id |
573 | - if( !empty($args['argument_id']) ){ |
|
574 | - $output .= ' data-argument="'.esc_attr($args['argument_id']).'"'; |
|
573 | + if (!empty($args['argument_id'])) { |
|
574 | + $output .= ' data-argument="' . esc_attr($args['argument_id']) . '"'; |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | // class |
578 | - $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
579 | - $output .= ' class="'.$class.'" '; |
|
578 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
579 | + $output .= ' class="' . $class . '" '; |
|
580 | 580 | |
581 | 581 | // close wrap |
582 | 582 | $output .= ' >'; |
583 | 583 | |
584 | 584 | |
585 | 585 | // Input group left |
586 | - if(!empty($args['input_group_left'])){ |
|
586 | + if (!empty($args['input_group_left'])) { |
|
587 | 587 | $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
588 | - $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>'; |
|
589 | - $output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>'; |
|
588 | + $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
589 | + $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | // content |
593 | 593 | $output .= $args['content']; |
594 | 594 | |
595 | 595 | // Input group right |
596 | - if(!empty($args['input_group_right'])){ |
|
596 | + if (!empty($args['input_group_right'])) { |
|
597 | 597 | $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
598 | - $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>'; |
|
599 | - $output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>'; |
|
598 | + $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
599 | + $output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>'; |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | |
603 | 603 | // close wrap |
604 | - $output .= '</'.sanitize_html_class($args['type']).'>'; |
|
604 | + $output .= '</' . sanitize_html_class($args['type']) . '>'; |
|
605 | 605 | |
606 | 606 | |
607 | - }else{ |
|
607 | + } else { |
|
608 | 608 | $output = $args['content']; |
609 | 609 | } |
610 | 610 | |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | * |
619 | 619 | * @return string The rendered component. |
620 | 620 | */ |
621 | - public static function select($args = array()){ |
|
621 | + public static function select($args = array()) { |
|
622 | 622 | $defaults = array( |
623 | 623 | 'class' => '', |
624 | 624 | 'wrap_class' => '', |
@@ -644,11 +644,11 @@ discard block |
||
644 | 644 | /** |
645 | 645 | * Parse incoming $args into an array and merge it with $defaults |
646 | 646 | */ |
647 | - $args = wp_parse_args( $args, $defaults ); |
|
647 | + $args = wp_parse_args($args, $defaults); |
|
648 | 648 | $output = ''; |
649 | 649 | |
650 | 650 | // for now lets hide floating labels |
651 | - if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';} |
|
651 | + if ($args['label_type'] == 'floating') {$args['label_type'] = 'hidden'; } |
|
652 | 652 | |
653 | 653 | // hidden label option needs to be empty |
654 | 654 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
@@ -657,85 +657,85 @@ discard block |
||
657 | 657 | $label_after = $args['label_after']; |
658 | 658 | |
659 | 659 | // floating labels need label after |
660 | - if( $args['label_type'] == 'floating' ){ |
|
660 | + if ($args['label_type'] == 'floating') { |
|
661 | 661 | $label_after = true; |
662 | 662 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
663 | 663 | } |
664 | 664 | |
665 | 665 | // Maybe setup select2 |
666 | 666 | $is_select2 = false; |
667 | - if(!empty($args['select2'])){ |
|
667 | + if (!empty($args['select2'])) { |
|
668 | 668 | $args['class'] .= ' aui-select2'; |
669 | 669 | $is_select2 = true; |
670 | - }elseif( strpos($args['class'], 'aui-select2') !== false){ |
|
670 | + }elseif (strpos($args['class'], 'aui-select2') !== false) { |
|
671 | 671 | $is_select2 = true; |
672 | 672 | } |
673 | 673 | |
674 | 674 | // select2 tags |
675 | - if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason |
|
675 | + if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason |
|
676 | 676 | $args['data-tags'] = 'true'; |
677 | 677 | $args['data-token-separators'] = "[',']"; |
678 | 678 | $args['multiple'] = true; |
679 | 679 | } |
680 | 680 | |
681 | 681 | // select2 placeholder |
682 | - if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){ |
|
682 | + if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) { |
|
683 | 683 | $args['data-placeholder'] = esc_attr($args['placeholder']); |
684 | 684 | $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true; |
685 | 685 | } |
686 | 686 | |
687 | 687 | // label |
688 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
689 | - }elseif(!empty($args['label']) && !$label_after){ |
|
688 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
689 | + }elseif (!empty($args['label']) && !$label_after) { |
|
690 | 690 | $label_args = array( |
691 | 691 | 'title'=> $args['label'], |
692 | 692 | 'for'=> $args['id'], |
693 | - 'class' => $args['label_class']." ", |
|
693 | + 'class' => $args['label_class'] . " ", |
|
694 | 694 | 'label_type' => $args['label_type'] |
695 | 695 | ); |
696 | 696 | $output .= self::label($label_args); |
697 | 697 | } |
698 | 698 | |
699 | 699 | // maybe horizontal label |
700 | - if($args['label_type']=='horizontal'){ |
|
700 | + if ($args['label_type'] == 'horizontal') { |
|
701 | 701 | $output .= '<div class="col-sm-10">'; |
702 | 702 | } |
703 | 703 | |
704 | 704 | // Set hidden input to save empty value for multiselect. |
705 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) { |
|
706 | - $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>'; |
|
705 | + if (!empty($args['multiple']) && !empty($args['name'])) { |
|
706 | + $output .= '<input type="hidden" ' . AUI_Component_Helper::name($args['name']) . ' value=""/>'; |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | // open/type |
710 | 710 | $output .= '<select '; |
711 | 711 | |
712 | 712 | // style |
713 | - if($is_select2){ |
|
713 | + if ($is_select2) { |
|
714 | 714 | $output .= " style='width:100%;' "; |
715 | 715 | } |
716 | 716 | |
717 | 717 | // element require |
718 | - if(!empty($args['element_require'])){ |
|
718 | + if (!empty($args['element_require'])) { |
|
719 | 719 | $output .= AUI_Component_Helper::element_require($args['element_require']); |
720 | 720 | $args['class'] .= " aui-conditional-field"; |
721 | 721 | } |
722 | 722 | |
723 | 723 | // class |
724 | 724 | $class = !empty($args['class']) ? $args['class'] : ''; |
725 | - $output .= AUI_Component_Helper::class_attr('custom-select '.$class); |
|
725 | + $output .= AUI_Component_Helper::class_attr('custom-select ' . $class); |
|
726 | 726 | |
727 | 727 | // name |
728 | - if(!empty($args['name'])){ |
|
729 | - $output .= AUI_Component_Helper::name($args['name'],$args['multiple']); |
|
728 | + if (!empty($args['name'])) { |
|
729 | + $output .= AUI_Component_Helper::name($args['name'], $args['multiple']); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | // id |
733 | - if(!empty($args['id'])){ |
|
733 | + if (!empty($args['id'])) { |
|
734 | 734 | $output .= AUI_Component_Helper::id($args['id']); |
735 | 735 | } |
736 | 736 | |
737 | 737 | // title |
738 | - if(!empty($args['title'])){ |
|
738 | + if (!empty($args['title'])) { |
|
739 | 739 | $output .= AUI_Component_Helper::title($args['title']); |
740 | 740 | } |
741 | 741 | |
@@ -746,17 +746,17 @@ discard block |
||
746 | 746 | $output .= AUI_Component_Helper::aria_attributes($args); |
747 | 747 | |
748 | 748 | // extra attributes |
749 | - if(!empty($args['extra_attributes'])){ |
|
749 | + if (!empty($args['extra_attributes'])) { |
|
750 | 750 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
751 | 751 | } |
752 | 752 | |
753 | 753 | // required |
754 | - if(!empty($args['required'])){ |
|
754 | + if (!empty($args['required'])) { |
|
755 | 755 | $output .= ' required '; |
756 | 756 | } |
757 | 757 | |
758 | 758 | // multiple |
759 | - if(!empty($args['multiple'])){ |
|
759 | + if (!empty($args['multiple'])) { |
|
760 | 760 | $output .= ' multiple '; |
761 | 761 | } |
762 | 762 | |
@@ -764,21 +764,21 @@ discard block |
||
764 | 764 | $output .= ' >'; |
765 | 765 | |
766 | 766 | // placeholder |
767 | - if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){ |
|
768 | - $output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>'; |
|
769 | - }elseif($is_select2 && !empty($args['placeholder'])){ |
|
767 | + if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) { |
|
768 | + $output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>'; |
|
769 | + }elseif ($is_select2 && !empty($args['placeholder'])) { |
|
770 | 770 | $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
771 | 771 | } |
772 | 772 | |
773 | 773 | // Options |
774 | - if(!empty($args['options'])){ |
|
774 | + if (!empty($args['options'])) { |
|
775 | 775 | |
776 | - if(!is_array($args['options'])){ |
|
776 | + if (!is_array($args['options'])) { |
|
777 | 777 | $output .= $args['options']; // not the preferred way but an option |
778 | - }else{ |
|
779 | - foreach($args['options'] as $val => $name){ |
|
778 | + } else { |
|
779 | + foreach ($args['options'] as $val => $name) { |
|
780 | 780 | $selected = ''; |
781 | - if(is_array($name)){ |
|
781 | + if (is_array($name)) { |
|
782 | 782 | if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) { |
783 | 783 | $option_label = isset($name['label']) ? $name['label'] : ''; |
784 | 784 | |
@@ -786,23 +786,23 @@ discard block |
||
786 | 786 | } else { |
787 | 787 | $option_label = isset($name['label']) ? $name['label'] : ''; |
788 | 788 | $option_value = isset($name['value']) ? $name['value'] : ''; |
789 | - if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){ |
|
789 | + if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) { |
|
790 | 790 | $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : ""; |
791 | - } elseif(!empty($args['value'])) { |
|
792 | - $selected = selected($option_value,stripslashes_deep($args['value']), false); |
|
791 | + } elseif (!empty($args['value'])) { |
|
792 | + $selected = selected($option_value, stripslashes_deep($args['value']), false); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; |
796 | 796 | } |
797 | - }else{ |
|
798 | - if(!empty($args['value'])){ |
|
799 | - if(is_array($args['value'])){ |
|
800 | - $selected = in_array($val,$args['value']) ? 'selected="selected"' : ''; |
|
801 | - } elseif(!empty($args['value'])) { |
|
802 | - $selected = selected( $args['value'], $val, false); |
|
797 | + } else { |
|
798 | + if (!empty($args['value'])) { |
|
799 | + if (is_array($args['value'])) { |
|
800 | + $selected = in_array($val, $args['value']) ? 'selected="selected"' : ''; |
|
801 | + } elseif (!empty($args['value'])) { |
|
802 | + $selected = selected($args['value'], $val, false); |
|
803 | 803 | } |
804 | 804 | } |
805 | - $output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>'; |
|
805 | + $output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>'; |
|
806 | 806 | } |
807 | 807 | } |
808 | 808 | } |
@@ -812,31 +812,31 @@ discard block |
||
812 | 812 | // closing tag |
813 | 813 | $output .= '</select>'; |
814 | 814 | |
815 | - if(!empty($args['label']) && $label_after){ |
|
815 | + if (!empty($args['label']) && $label_after) { |
|
816 | 816 | $label_args = array( |
817 | 817 | 'title'=> $args['label'], |
818 | 818 | 'for'=> $args['id'], |
819 | - 'class' => $args['label_class']." ", |
|
819 | + 'class' => $args['label_class'] . " ", |
|
820 | 820 | 'label_type' => $args['label_type'] |
821 | 821 | ); |
822 | 822 | $output .= self::label($label_args); |
823 | 823 | } |
824 | 824 | |
825 | 825 | // help text |
826 | - if(!empty($args['help_text'])){ |
|
826 | + if (!empty($args['help_text'])) { |
|
827 | 827 | $output .= AUI_Component_Helper::help_text($args['help_text']); |
828 | 828 | } |
829 | 829 | |
830 | 830 | // maybe horizontal label |
831 | - if($args['label_type']=='horizontal'){ |
|
831 | + if ($args['label_type'] == 'horizontal') { |
|
832 | 832 | $output .= '</div>'; |
833 | 833 | } |
834 | 834 | |
835 | 835 | |
836 | 836 | // wrap |
837 | - if(!$args['no_wrap']){ |
|
838 | - $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
839 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
837 | + if (!$args['no_wrap']) { |
|
838 | + $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
|
839 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
840 | 840 | $output = self::wrap(array( |
841 | 841 | 'content' => $output, |
842 | 842 | 'class' => $wrap_class, |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | * |
857 | 857 | * @return string The rendered component. |
858 | 858 | */ |
859 | - public static function radio($args = array()){ |
|
859 | + public static function radio($args = array()) { |
|
860 | 860 | $defaults = array( |
861 | 861 | 'class' => '', |
862 | 862 | 'wrap_class' => '', |
@@ -880,14 +880,14 @@ discard block |
||
880 | 880 | /** |
881 | 881 | * Parse incoming $args into an array and merge it with $defaults |
882 | 882 | */ |
883 | - $args = wp_parse_args( $args, $defaults ); |
|
883 | + $args = wp_parse_args($args, $defaults); |
|
884 | 884 | |
885 | 885 | // for now lets use horizontal for floating |
886 | - if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';} |
|
886 | + if ($args['label_type'] == 'floating') {$args['label_type'] = 'horizontal'; } |
|
887 | 887 | |
888 | 888 | $label_args = array( |
889 | 889 | 'title'=> $args['label'], |
890 | - 'class' => $args['label_class']." pt-0 ", |
|
890 | + 'class' => $args['label_class'] . " pt-0 ", |
|
891 | 891 | 'label_type' => $args['label_type'] |
892 | 892 | ); |
893 | 893 | |
@@ -896,39 +896,39 @@ discard block |
||
896 | 896 | |
897 | 897 | |
898 | 898 | // label before |
899 | - if(!empty($args['label'])){ |
|
900 | - $output .= self::label( $label_args, 'radio' ); |
|
899 | + if (!empty($args['label'])) { |
|
900 | + $output .= self::label($label_args, 'radio'); |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | // maybe horizontal label |
904 | - if($args['label_type']=='horizontal'){ |
|
904 | + if ($args['label_type'] == 'horizontal') { |
|
905 | 905 | $output .= '<div class="col-sm-10">'; |
906 | 906 | } |
907 | 907 | |
908 | - if(!empty($args['options'])){ |
|
908 | + if (!empty($args['options'])) { |
|
909 | 909 | $count = 0; |
910 | - foreach($args['options'] as $value => $label){ |
|
910 | + foreach ($args['options'] as $value => $label) { |
|
911 | 911 | $option_args = $args; |
912 | 912 | $option_args['value'] = $value; |
913 | 913 | $option_args['label'] = $label; |
914 | 914 | $option_args['checked'] = $value == $args['value'] ? true : false; |
915 | - $output .= self::radio_option($option_args,$count); |
|
915 | + $output .= self::radio_option($option_args, $count); |
|
916 | 916 | $count++; |
917 | 917 | } |
918 | 918 | } |
919 | 919 | |
920 | 920 | // help text |
921 | - $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
921 | + $help_text = !empty($args['help_text']) ? AUI_Component_Helper::help_text($args['help_text']) : ''; |
|
922 | 922 | $output .= $help_text; |
923 | 923 | |
924 | 924 | // maybe horizontal label |
925 | - if($args['label_type']=='horizontal'){ |
|
925 | + if ($args['label_type'] == 'horizontal') { |
|
926 | 926 | $output .= '</div>'; |
927 | 927 | } |
928 | 928 | |
929 | 929 | // wrap |
930 | - $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
931 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
930 | + $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
|
931 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
932 | 932 | $output = self::wrap(array( |
933 | 933 | 'content' => $output, |
934 | 934 | 'class' => $wrap_class, |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | * |
948 | 948 | * @return string The rendered component. |
949 | 949 | */ |
950 | - public static function radio_option($args = array(),$count = ''){ |
|
950 | + public static function radio_option($args = array(), $count = '') { |
|
951 | 951 | $defaults = array( |
952 | 952 | 'class' => '', |
953 | 953 | 'id' => '', |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | /** |
966 | 966 | * Parse incoming $args into an array and merge it with $defaults |
967 | 967 | */ |
968 | - $args = wp_parse_args( $args, $defaults ); |
|
968 | + $args = wp_parse_args($args, $defaults); |
|
969 | 969 | |
970 | 970 | $output = ''; |
971 | 971 | |
@@ -976,27 +976,27 @@ discard block |
||
976 | 976 | $output .= ' class="form-check-input" '; |
977 | 977 | |
978 | 978 | // name |
979 | - if(!empty($args['name'])){ |
|
979 | + if (!empty($args['name'])) { |
|
980 | 980 | $output .= AUI_Component_Helper::name($args['name']); |
981 | 981 | } |
982 | 982 | |
983 | 983 | // id |
984 | - if(!empty($args['id'])){ |
|
985 | - $output .= AUI_Component_Helper::id($args['id'].$count); |
|
984 | + if (!empty($args['id'])) { |
|
985 | + $output .= AUI_Component_Helper::id($args['id'] . $count); |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | // title |
989 | - if(!empty($args['title'])){ |
|
989 | + if (!empty($args['title'])) { |
|
990 | 990 | $output .= AUI_Component_Helper::title($args['title']); |
991 | 991 | } |
992 | 992 | |
993 | 993 | // value |
994 | - if(isset($args['value'])){ |
|
995 | - $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
994 | + if (isset($args['value'])) { |
|
995 | + $output .= ' value="' . sanitize_text_field($args['value']) . '" '; |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | // checked, for radio and checkboxes |
999 | - if( $args['checked'] ){ |
|
999 | + if ($args['checked']) { |
|
1000 | 1000 | $output .= ' checked '; |
1001 | 1001 | } |
1002 | 1002 | |
@@ -1007,12 +1007,12 @@ discard block |
||
1007 | 1007 | $output .= AUI_Component_Helper::aria_attributes($args); |
1008 | 1008 | |
1009 | 1009 | // extra attributes |
1010 | - if(!empty($args['extra_attributes'])){ |
|
1010 | + if (!empty($args['extra_attributes'])) { |
|
1011 | 1011 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | // required |
1015 | - if(!empty($args['required'])){ |
|
1015 | + if (!empty($args['required'])) { |
|
1016 | 1016 | $output .= ' required '; |
1017 | 1017 | } |
1018 | 1018 | |
@@ -1020,13 +1020,13 @@ discard block |
||
1020 | 1020 | $output .= ' >'; |
1021 | 1021 | |
1022 | 1022 | // label |
1023 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
1024 | - }elseif(!empty($args['label'])){ |
|
1025 | - $output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio'); |
|
1023 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
1024 | + }elseif (!empty($args['label'])) { |
|
1025 | + $output .= self::label(array('title'=>$args['label'], 'for'=>$args['id'] . $count, 'class'=>'form-check-label'), 'radio'); |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | // wrap |
1029 | - if(!$args['no_wrap']){ |
|
1029 | + if (!$args['no_wrap']) { |
|
1030 | 1030 | $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
1031 | 1031 | $output = self::wrap(array( |
1032 | 1032 | 'content' => $output, |
@@ -6,39 +6,39 @@ |
||
6 | 6 | /** |
7 | 7 | * Bail if we are not in WP. |
8 | 8 | */ |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Set the version only if its the current newest while loading. |
15 | 15 | */ |
16 | -add_action('after_setup_theme', function () { |
|
17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
16 | +add_action('after_setup_theme', function() { |
|
17 | + global $ayecode_ui_version, $ayecode_ui_file_key; |
|
18 | 18 | $this_version = "0.1.49"; |
19 | - if(version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | - $ayecode_ui_version = $this_version ; |
|
21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
19 | + if (version_compare($this_version, $ayecode_ui_version, '>')) { |
|
20 | + $ayecode_ui_version = $this_version; |
|
21 | + $ayecode_ui_file_key = wp_hash(__FILE__); |
|
22 | 22 | } |
23 | 23 | },0); |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
27 | 27 | */ |
28 | -add_action('after_setup_theme', function () { |
|
28 | +add_action('after_setup_theme', function() { |
|
29 | 29 | global $ayecode_ui_file_key; |
30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
30 | + if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) { |
|
31 | + include_once(dirname(__FILE__) . '/includes/class-aui.php'); |
|
32 | + include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php'); |
|
33 | 33 | } |
34 | 34 | },1); |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Add the function that calls the class. |
38 | 38 | */ |
39 | -if(!function_exists('aui')){ |
|
40 | - function aui(){ |
|
41 | - if(!class_exists("AUI",false)){ |
|
39 | +if (!function_exists('aui')) { |
|
40 | + function aui() { |
|
41 | + if (!class_exists("AUI", false)) { |
|
42 | 42 | return false; |
43 | 43 | } |
44 | 44 | return AUI::instance(); |
@@ -11,93 +11,93 @@ |
||
11 | 11 | |
12 | 12 | class InstalledVersions |
13 | 13 | { |
14 | -private static $installed = array ( |
|
14 | +private static $installed = array( |
|
15 | 15 | 'root' => |
16 | - array ( |
|
16 | + array( |
|
17 | 17 | 'pretty_version' => 'dev-master', |
18 | 18 | 'version' => 'dev-master', |
19 | 19 | 'aliases' => |
20 | - array ( |
|
20 | + array( |
|
21 | 21 | ), |
22 | 22 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
23 | 23 | 'name' => 'ayecode/invoicing', |
24 | 24 | ), |
25 | 25 | 'versions' => |
26 | - array ( |
|
26 | + array( |
|
27 | 27 | 'ayecode/ayecode-connect-helper' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | 'pretty_version' => '1.0.3', |
30 | 30 | 'version' => '1.0.3.0', |
31 | 31 | 'aliases' => |
32 | - array ( |
|
32 | + array( |
|
33 | 33 | ), |
34 | 34 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
35 | 35 | ), |
36 | 36 | 'ayecode/invoicing' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | 'pretty_version' => 'dev-master', |
39 | 39 | 'version' => 'dev-master', |
40 | 40 | 'aliases' => |
41 | - array ( |
|
41 | + array( |
|
42 | 42 | ), |
43 | 43 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
44 | 44 | ), |
45 | 45 | 'ayecode/wp-ayecode-ui' => |
46 | - array ( |
|
46 | + array( |
|
47 | 47 | 'pretty_version' => '0.1.49', |
48 | 48 | 'version' => '0.1.49.0', |
49 | 49 | 'aliases' => |
50 | - array ( |
|
50 | + array( |
|
51 | 51 | ), |
52 | 52 | 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
53 | 53 | ), |
54 | 54 | 'ayecode/wp-font-awesome-settings' => |
55 | - array ( |
|
55 | + array( |
|
56 | 56 | 'pretty_version' => '1.0.12', |
57 | 57 | 'version' => '1.0.12.0', |
58 | 58 | 'aliases' => |
59 | - array ( |
|
59 | + array( |
|
60 | 60 | ), |
61 | 61 | 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
62 | 62 | ), |
63 | 63 | 'ayecode/wp-super-duper' => |
64 | - array ( |
|
64 | + array( |
|
65 | 65 | 'pretty_version' => '1.0.26', |
66 | 66 | 'version' => '1.0.26.0', |
67 | 67 | 'aliases' => |
68 | - array ( |
|
68 | + array( |
|
69 | 69 | ), |
70 | 70 | 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
71 | 71 | ), |
72 | 72 | 'composer/installers' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | 'pretty_version' => 'v1.11.0', |
75 | 75 | 'version' => '1.11.0.0', |
76 | 76 | 'aliases' => |
77 | - array ( |
|
77 | + array( |
|
78 | 78 | ), |
79 | 79 | 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
80 | 80 | ), |
81 | 81 | 'maxmind-db/reader' => |
82 | - array ( |
|
82 | + array( |
|
83 | 83 | 'pretty_version' => 'v1.6.0', |
84 | 84 | 'version' => '1.6.0.0', |
85 | 85 | 'aliases' => |
86 | - array ( |
|
86 | + array( |
|
87 | 87 | ), |
88 | 88 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
89 | 89 | ), |
90 | 90 | 'roundcube/plugin-installer' => |
91 | - array ( |
|
91 | + array( |
|
92 | 92 | 'replaced' => |
93 | - array ( |
|
93 | + array( |
|
94 | 94 | 0 => '*', |
95 | 95 | ), |
96 | 96 | ), |
97 | 97 | 'shama/baton' => |
98 | - array ( |
|
98 | + array( |
|
99 | 99 | 'replaced' => |
100 | - array ( |
|
100 | + array( |
|
101 | 101 | 0 => '*', |
102 | 102 | ), |
103 | 103 | ), |
@@ -1,90 +1,90 @@ |
||
1 | -<?php return array ( |
|
1 | +<?php return array( |
|
2 | 2 | 'root' => |
3 | - array ( |
|
3 | + array( |
|
4 | 4 | 'pretty_version' => 'dev-master', |
5 | 5 | 'version' => 'dev-master', |
6 | 6 | 'aliases' => |
7 | - array ( |
|
7 | + array( |
|
8 | 8 | ), |
9 | 9 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
10 | 10 | 'name' => 'ayecode/invoicing', |
11 | 11 | ), |
12 | 12 | 'versions' => |
13 | - array ( |
|
13 | + array( |
|
14 | 14 | 'ayecode/ayecode-connect-helper' => |
15 | - array ( |
|
15 | + array( |
|
16 | 16 | 'pretty_version' => '1.0.3', |
17 | 17 | 'version' => '1.0.3.0', |
18 | 18 | 'aliases' => |
19 | - array ( |
|
19 | + array( |
|
20 | 20 | ), |
21 | 21 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
22 | 22 | ), |
23 | 23 | 'ayecode/invoicing' => |
24 | - array ( |
|
24 | + array( |
|
25 | 25 | 'pretty_version' => 'dev-master', |
26 | 26 | 'version' => 'dev-master', |
27 | 27 | 'aliases' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | ), |
30 | 30 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
31 | 31 | ), |
32 | 32 | 'ayecode/wp-ayecode-ui' => |
33 | - array ( |
|
33 | + array( |
|
34 | 34 | 'pretty_version' => '0.1.49', |
35 | 35 | 'version' => '0.1.49.0', |
36 | 36 | 'aliases' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | ), |
39 | 39 | 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
40 | 40 | ), |
41 | 41 | 'ayecode/wp-font-awesome-settings' => |
42 | - array ( |
|
42 | + array( |
|
43 | 43 | 'pretty_version' => '1.0.12', |
44 | 44 | 'version' => '1.0.12.0', |
45 | 45 | 'aliases' => |
46 | - array ( |
|
46 | + array( |
|
47 | 47 | ), |
48 | 48 | 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
49 | 49 | ), |
50 | 50 | 'ayecode/wp-super-duper' => |
51 | - array ( |
|
51 | + array( |
|
52 | 52 | 'pretty_version' => '1.0.26', |
53 | 53 | 'version' => '1.0.26.0', |
54 | 54 | 'aliases' => |
55 | - array ( |
|
55 | + array( |
|
56 | 56 | ), |
57 | 57 | 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
58 | 58 | ), |
59 | 59 | 'composer/installers' => |
60 | - array ( |
|
60 | + array( |
|
61 | 61 | 'pretty_version' => 'v1.11.0', |
62 | 62 | 'version' => '1.11.0.0', |
63 | 63 | 'aliases' => |
64 | - array ( |
|
64 | + array( |
|
65 | 65 | ), |
66 | 66 | 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
67 | 67 | ), |
68 | 68 | 'maxmind-db/reader' => |
69 | - array ( |
|
69 | + array( |
|
70 | 70 | 'pretty_version' => 'v1.6.0', |
71 | 71 | 'version' => '1.6.0.0', |
72 | 72 | 'aliases' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | ), |
75 | 75 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
76 | 76 | ), |
77 | 77 | 'roundcube/plugin-installer' => |
78 | - array ( |
|
78 | + array( |
|
79 | 79 | 'replaced' => |
80 | - array ( |
|
80 | + array( |
|
81 | 81 | 0 => '*', |
82 | 82 | ), |
83 | 83 | ), |
84 | 84 | 'shama/baton' => |
85 | - array ( |
|
85 | + array( |
|
86 | 86 | 'replaced' => |
87 | - array ( |
|
87 | + array( |
|
88 | 88 | 0 => '*', |
89 | 89 | ), |
90 | 90 | ), |