Passed
Push — master ( 1ce22f...41fbb9 )
by Brian
09:44 queued 04:28
created
ayecode/wp-ayecode-ui/includes/components/class-aui-component-input.php 3 patches
Indentation   +1002 added lines, -1002 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,1012 +11,1012 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Input {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function input($args = array()){
22
-		$defaults = array(
23
-			'type'       => 'text',
24
-			'name'       => '',
25
-			'class'      => '',
26
-			'wrap_class' => '',
27
-			'id'         => '',
28
-			'placeholder'=> '',
29
-			'title'      => '',
30
-			'value'      => '',
31
-			'required'   => false,
32
-			'label'      => '',
33
-			'label_after'=> false,
34
-			'label_class'=> '',
35
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
36
-			'help_text'  => '',
37
-			'validation_text'   => '',
38
-			'validation_pattern' => '',
39
-			'no_wrap'    => false,
40
-			'input_group_right' => '',
41
-			'input_group_left' => '',
42
-			'input_group_right_inside' => false, // forces the input group inside the input
43
-			'input_group_left_inside' => false, // forces the input group inside the input
44
-			'step'       => '',
45
-			'switch'     => false, // to show checkbox as a switch
46
-			'checked'   => false, // set a checkbox or radio as selected
47
-			'password_toggle' => true, // toggle view/hide password
48
-			'element_require'   => '', // [%element_id%] == "1"
49
-			'extra_attributes'  => array() // an array of extra attributes
50
-		);
51
-
52
-		/**
53
-		 * Parse incoming $args into an array and merge it with $defaults
54
-		 */
55
-		$args   = wp_parse_args( $args, $defaults );
56
-		$output = '';
57
-		if ( ! empty( $args['type'] ) ) {
58
-			// hidden label option needs to be empty
59
-			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
60
-
61
-			$type = sanitize_html_class( $args['type'] );
62
-
63
-			$help_text = '';
64
-			$label = '';
65
-			$label_after = $args['label_after'];
66
-			$label_args = array(
67
-				'title'=> $args['label'],
68
-				'for'=> $args['id'],
69
-				'class' => $args['label_class']." ",
70
-				'label_type' => $args['label_type']
71
-			);
72
-
73
-			// floating labels need label after
74
-			if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
75
-				$label_after = true;
76
-				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
77
-			}
78
-
79
-			// Some special sauce for files
80
-			if($type=='file' ){
81
-				$label_after = true; // if type file we need the label after
82
-				$args['class'] .= ' custom-file-input ';
83
-			}elseif($type=='checkbox'){
84
-				$label_after = true; // if type file we need the label after
85
-				$args['class'] .= ' custom-control-input ';
86
-			}elseif($type=='datepicker' || $type=='timepicker'){
87
-				$type = 'text';
88
-				//$args['class'] .= ' aui-flatpickr bg-initial ';
89
-				$args['class'] .= ' bg-initial ';
90
-
91
-				$args['extra_attributes']['data-aui-init'] = 'flatpickr';
92
-				// enqueue the script
93
-				$aui_settings = AyeCode_UI_Settings::instance();
94
-				$aui_settings->enqueue_flatpickr();
95
-			}
96
-
97
-
98
-			// open/type
99
-			$output .= '<input type="' . $type . '" ';
100
-
101
-			// name
102
-			if(!empty($args['name'])){
103
-				$output .= ' name="'.esc_attr($args['name']).'" ';
104
-			}
105
-
106
-			// id
107
-			if(!empty($args['id'])){
108
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
109
-			}
110
-
111
-			// placeholder
112
-			if(isset($args['placeholder']) && '' != $args['placeholder'] ){
113
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
114
-			}
115
-
116
-			// title
117
-			if(!empty($args['title'])){
118
-				$output .= ' title="'.esc_attr($args['title']).'" ';
119
-			}
120
-
121
-			// value
122
-			if(!empty($args['value'])){
123
-				$output .= ' value="'.sanitize_text_field($args['value']).'" ';
124
-			}
125
-
126
-			// checked, for radio and checkboxes
127
-			if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
128
-				$output .= ' checked ';
129
-			}
130
-
131
-			// validation text
132
-			if(!empty($args['validation_text'])){
133
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
134
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
135
-			}
136
-
137
-			// validation_pattern
138
-			if(!empty($args['validation_pattern'])){
139
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
140
-			}
141
-
142
-			// step (for numbers)
143
-			if(!empty($args['step'])){
144
-				$output .= ' step="'.$args['step'].'" ';
145
-			}
146
-
147
-			// required
148
-			if(!empty($args['required'])){
149
-				$output .= ' required ';
150
-			}
151
-
152
-			// class
153
-			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
154
-			$output .= ' class="form-control '.$class.'" ';
155
-
156
-			// data-attributes
157
-			$output .= AUI_Component_Helper::data_attributes($args);
158
-
159
-			// extra attributes
160
-			if(!empty($args['extra_attributes'])){
161
-				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
162
-			}
163
-
164
-			// close
165
-			$output .= ' >';
166
-
167
-
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 );
173
-			}
174
-
175
-			// help text
176
-			if(!empty($args['help_text'])){
177
-				$help_text = AUI_Component_Helper::help_text($args['help_text']);
178
-			}
179
-
180
-
181
-			// set help text in the correct possition
182
-			if($label_after){
183
-				$output .= $label . $help_text;
184
-			}
185
-
186
-			// some input types need a separate wrap
187
-			if($type == 'file') {
188
-				$output = self::wrap( array(
189
-					'content' => $output,
190
-					'class'   => 'form-group custom-file'
191
-				) );
192
-			}elseif($type == 'checkbox'){
193
-				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
194
-				$output = self::wrap( array(
195
-					'content' => $output,
196
-					'class'   => 'custom-control '.$wrap_class
197
-				) );
198
-
199
-				if($args['label_type']=='horizontal'){
200
-					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
201
-				}
202
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
203
-
204
-
205
-				// allow password field to toggle view
206
-				$args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function input($args = array()){
22
+        $defaults = array(
23
+            'type'       => 'text',
24
+            'name'       => '',
25
+            'class'      => '',
26
+            'wrap_class' => '',
27
+            'id'         => '',
28
+            'placeholder'=> '',
29
+            'title'      => '',
30
+            'value'      => '',
31
+            'required'   => false,
32
+            'label'      => '',
33
+            'label_after'=> false,
34
+            'label_class'=> '',
35
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
36
+            'help_text'  => '',
37
+            'validation_text'   => '',
38
+            'validation_pattern' => '',
39
+            'no_wrap'    => false,
40
+            'input_group_right' => '',
41
+            'input_group_left' => '',
42
+            'input_group_right_inside' => false, // forces the input group inside the input
43
+            'input_group_left_inside' => false, // forces the input group inside the input
44
+            'step'       => '',
45
+            'switch'     => false, // to show checkbox as a switch
46
+            'checked'   => false, // set a checkbox or radio as selected
47
+            'password_toggle' => true, // toggle view/hide password
48
+            'element_require'   => '', // [%element_id%] == "1"
49
+            'extra_attributes'  => array() // an array of extra attributes
50
+        );
51
+
52
+        /**
53
+         * Parse incoming $args into an array and merge it with $defaults
54
+         */
55
+        $args   = wp_parse_args( $args, $defaults );
56
+        $output = '';
57
+        if ( ! empty( $args['type'] ) ) {
58
+            // hidden label option needs to be empty
59
+            $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
60
+
61
+            $type = sanitize_html_class( $args['type'] );
62
+
63
+            $help_text = '';
64
+            $label = '';
65
+            $label_after = $args['label_after'];
66
+            $label_args = array(
67
+                'title'=> $args['label'],
68
+                'for'=> $args['id'],
69
+                'class' => $args['label_class']." ",
70
+                'label_type' => $args['label_type']
71
+            );
72
+
73
+            // floating labels need label after
74
+            if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
75
+                $label_after = true;
76
+                $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
77
+            }
78
+
79
+            // Some special sauce for files
80
+            if($type=='file' ){
81
+                $label_after = true; // if type file we need the label after
82
+                $args['class'] .= ' custom-file-input ';
83
+            }elseif($type=='checkbox'){
84
+                $label_after = true; // if type file we need the label after
85
+                $args['class'] .= ' custom-control-input ';
86
+            }elseif($type=='datepicker' || $type=='timepicker'){
87
+                $type = 'text';
88
+                //$args['class'] .= ' aui-flatpickr bg-initial ';
89
+                $args['class'] .= ' bg-initial ';
90
+
91
+                $args['extra_attributes']['data-aui-init'] = 'flatpickr';
92
+                // enqueue the script
93
+                $aui_settings = AyeCode_UI_Settings::instance();
94
+                $aui_settings->enqueue_flatpickr();
95
+            }
96
+
97
+
98
+            // open/type
99
+            $output .= '<input type="' . $type . '" ';
100
+
101
+            // name
102
+            if(!empty($args['name'])){
103
+                $output .= ' name="'.esc_attr($args['name']).'" ';
104
+            }
105
+
106
+            // id
107
+            if(!empty($args['id'])){
108
+                $output .= ' id="'.sanitize_html_class($args['id']).'" ';
109
+            }
110
+
111
+            // placeholder
112
+            if(isset($args['placeholder']) && '' != $args['placeholder'] ){
113
+                $output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
114
+            }
115
+
116
+            // title
117
+            if(!empty($args['title'])){
118
+                $output .= ' title="'.esc_attr($args['title']).'" ';
119
+            }
120
+
121
+            // value
122
+            if(!empty($args['value'])){
123
+                $output .= ' value="'.sanitize_text_field($args['value']).'" ';
124
+            }
125
+
126
+            // checked, for radio and checkboxes
127
+            if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
128
+                $output .= ' checked ';
129
+            }
130
+
131
+            // validation text
132
+            if(!empty($args['validation_text'])){
133
+                $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
134
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
135
+            }
136
+
137
+            // validation_pattern
138
+            if(!empty($args['validation_pattern'])){
139
+                $output .= ' pattern="'.$args['validation_pattern'].'" ';
140
+            }
141
+
142
+            // step (for numbers)
143
+            if(!empty($args['step'])){
144
+                $output .= ' step="'.$args['step'].'" ';
145
+            }
146
+
147
+            // required
148
+            if(!empty($args['required'])){
149
+                $output .= ' required ';
150
+            }
151
+
152
+            // class
153
+            $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
154
+            $output .= ' class="form-control '.$class.'" ';
155
+
156
+            // data-attributes
157
+            $output .= AUI_Component_Helper::data_attributes($args);
158
+
159
+            // extra attributes
160
+            if(!empty($args['extra_attributes'])){
161
+                $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
162
+            }
163
+
164
+            // close
165
+            $output .= ' >';
166
+
167
+
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 );
173
+            }
174
+
175
+            // help text
176
+            if(!empty($args['help_text'])){
177
+                $help_text = AUI_Component_Helper::help_text($args['help_text']);
178
+            }
179
+
180
+
181
+            // set help text in the correct possition
182
+            if($label_after){
183
+                $output .= $label . $help_text;
184
+            }
185
+
186
+            // some input types need a separate wrap
187
+            if($type == 'file') {
188
+                $output = self::wrap( array(
189
+                    'content' => $output,
190
+                    'class'   => 'form-group custom-file'
191
+                ) );
192
+            }elseif($type == 'checkbox'){
193
+                $wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
194
+                $output = self::wrap( array(
195
+                    'content' => $output,
196
+                    'class'   => 'custom-control '.$wrap_class
197
+                ) );
198
+
199
+                if($args['label_type']=='horizontal'){
200
+                    $output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
201
+                }
202
+            }elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
203
+
204
+
205
+                // allow password field to toggle view
206
+                $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
207 207
 onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\');
208 208
 var $eli = jQuery(this).parent().parent().find(\'input\');
209 209
 if($el.hasClass(\'fa-eye\'))
210 210
 {$eli.attr(\'type\',\'text\');}
211 211
 else{$eli.attr(\'type\',\'password\');}"
212 212
 ><i class="far fa-fw fa-eye-slash"></i></span>';
213
-			}
214
-
215
-			// input group wraps
216
-			if($args['input_group_left'] || $args['input_group_right']){
217
-				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
218
-				if($args['input_group_left']){
219
-					$output = self::wrap( array(
220
-						'content' => $output,
221
-						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
222
-						'input_group_left' => $args['input_group_left'],
223
-						'input_group_left_inside'    => $args['input_group_left_inside']
224
-					) );
225
-				}
226
-				if($args['input_group_right']){
227
-					$output = self::wrap( array(
228
-						'content' => $output,
229
-						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
230
-						'input_group_right' => $args['input_group_right'],
231
-						'input_group_right_inside'    => $args['input_group_right_inside']
232
-					) );
233
-				}
234
-
235
-			}
236
-
237
-			if(!$label_after){
238
-				$output .= $help_text;
239
-			}
240
-
241
-
242
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
243
-				$output = self::wrap( array(
244
-					'content' => $output,
245
-					'class'   => 'col-sm-10',
246
-				) );
247
-			}
248
-
249
-			if(!$label_after){
250
-				$output = $label . $output;
251
-			}
252
-
253
-			// wrap
254
-			if(!$args['no_wrap']){
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;
259
-				$output = self::wrap(array(
260
-					'content' => $output,
261
-					'class'   => $wrap_class,
262
-					'element_require'   => $args['element_require'],
263
-					'argument_id'  => $args['id']
264
-				));
265
-			}
266
-
267
-
268
-
269
-		}
270
-
271
-		return $output;
272
-	}
273
-
274
-	/**
275
-	 * Build the component.
276
-	 *
277
-	 * @param array $args
278
-	 *
279
-	 * @return string The rendered component.
280
-	 */
281
-	public static function textarea($args = array()){
282
-		$defaults = array(
283
-			'name'       => '',
284
-			'class'      => '',
285
-			'wrap_class' => '',
286
-			'id'         => '',
287
-			'placeholder'=> '',
288
-			'title'      => '',
289
-			'value'      => '',
290
-			'required'   => false,
291
-			'label'      => '',
292
-			'label_after'=> false,
293
-			'label_class'      => '',
294
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
295
-			'help_text'  => '',
296
-			'validation_text'   => '',
297
-			'validation_pattern' => '',
298
-			'no_wrap'    => false,
299
-			'rows'      => '',
300
-			'wysiwyg'   => false,
301
-			'element_require'   => '', // [%element_id%] == "1"
302
-		);
303
-
304
-		/**
305
-		 * Parse incoming $args into an array and merge it with $defaults
306
-		 */
307
-		$args   = wp_parse_args( $args, $defaults );
308
-		$output = '';
309
-
310
-		// hidden label option needs to be empty
311
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
312
-
313
-		// floating labels don't work with wysiwyg so set it as top
314
-		if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
315
-			$args['label_type'] = 'top';
316
-		}
317
-
318
-		$label_after = $args['label_after'];
319
-
320
-		// floating labels need label after
321
-		if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
322
-			$label_after = true;
323
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
324
-		}
325
-
326
-		// label
327
-		if(!empty($args['label']) && is_array($args['label'])){
328
-		}elseif(!empty($args['label']) && !$label_after){
329
-			$label_args = array(
330
-				'title'=> $args['label'],
331
-				'for'=> $args['id'],
332
-				'class' => $args['label_class']." ",
333
-				'label_type' => $args['label_type']
334
-			);
335
-			$output .= self::label( $label_args );
336
-		}
337
-
338
-		// maybe horizontal label
339
-		if($args['label_type']=='horizontal'){
340
-			$output .= '<div class="col-sm-10">';
341
-		}
342
-
343
-		if(!empty($args['wysiwyg'])){
344
-			ob_start();
345
-			$content = $args['value'];
346
-			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
347
-			$settings = array(
348
-				'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
349
-				'quicktags'     => false,
350
-				'media_buttons' => false,
351
-				'editor_class'  => 'form-control',
352
-				'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
353
-				'teeny'         => true,
354
-			);
355
-
356
-			// maybe set settings if array
357
-			if(is_array($args['wysiwyg'])){
358
-				$settings  = wp_parse_args( $args['wysiwyg'], $settings );
359
-			}
360
-
361
-			wp_editor( $content, $editor_id, $settings );
362
-			$output .= ob_get_clean();
363
-		}else{
364
-
365
-			// open
366
-			$output .= '<textarea ';
367
-
368
-			// name
369
-			if(!empty($args['name'])){
370
-				$output .= ' name="'.sanitize_html_class($args['name']).'" ';
371
-			}
372
-
373
-			// id
374
-			if(!empty($args['id'])){
375
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
376
-			}
377
-
378
-			// placeholder
379
-			if(isset($args['placeholder']) && '' != $args['placeholder']){
380
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
381
-			}
382
-
383
-			// title
384
-			if(!empty($args['title'])){
385
-				$output .= ' title="'.esc_attr($args['title']).'" ';
386
-			}
387
-
388
-			// validation text
389
-			if(!empty($args['validation_text'])){
390
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
391
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
392
-			}
393
-
394
-			// validation_pattern
395
-			if(!empty($args['validation_pattern'])){
396
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
397
-			}
398
-
399
-			// required
400
-			if(!empty($args['required'])){
401
-				$output .= ' required ';
402
-			}
403
-
404
-			// rows
405
-			if(!empty($args['rows'])){
406
-				$output .= ' rows="'.absint($args['rows']).'" ';
407
-			}
408
-
409
-
410
-			// class
411
-			$class = !empty($args['class']) ? $args['class'] : '';
412
-			$output .= ' class="form-control '.$class.'" ';
413
-
414
-
415
-			// close tag
416
-			$output .= ' >';
417
-
418
-			// value
419
-			if(!empty($args['value'])){
420
-				$output .= sanitize_textarea_field($args['value']);
421
-			}
422
-
423
-			// closing tag
424
-			$output .= '</textarea>';
425
-
426
-		}
427
-
428
-		if(!empty($args['label']) && $label_after){
429
-			$label_args = array(
430
-				'title'=> $args['label'],
431
-				'for'=> $args['id'],
432
-				'class' => $args['label_class']." ",
433
-				'label_type' => $args['label_type']
434
-			);
435
-			$output .= self::label( $label_args );
436
-		}
437
-
438
-		// help text
439
-		if(!empty($args['help_text'])){
440
-			$output .= AUI_Component_Helper::help_text($args['help_text']);
441
-		}
442
-
443
-		// maybe horizontal label
444
-		if($args['label_type']=='horizontal'){
445
-			$output .= '</div>';
446
-		}
447
-
448
-
449
-		// wrap
450
-		if(!$args['no_wrap']){
451
-			$form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
452
-			$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
453
-			$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
454
-			$output = self::wrap(array(
455
-				'content' => $output,
456
-				'class'   => $wrap_class,
457
-				'element_require'   => $args['element_require'],
458
-				'argument_id'  => $args['id']
459
-			));
460
-		}
461
-
462
-
463
-		return $output;
464
-	}
465
-
466
-	public static function label($args = array(), $type = ''){
467
-		//<label for="exampleInputEmail1">Email address</label>
468
-		$defaults = array(
469
-			'title'       => 'div',
470
-			'for'      => '',
471
-			'class'      => '',
472
-			'label_type'    => '', // empty = hidden, top, horizontal
473
-		);
474
-
475
-		/**
476
-		 * Parse incoming $args into an array and merge it with $defaults
477
-		 */
478
-		$args   = wp_parse_args( $args, $defaults );
479
-		$output = '';
480
-
481
-		if($args['title']){
482
-
483
-			// maybe hide labels //@todo set a global option for visibility class
484
-			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
485
-				$class = $args['class'];
486
-			}else{
487
-				$class = 'sr-only '.$args['class'];
488
-			}
489
-
490
-			// maybe horizontal
491
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
492
-				$class .= ' col-sm-2 col-form-label';
493
-			}
494
-
495
-			// open
496
-			$output .= '<label ';
497
-
498
-			// for
499
-			if(!empty($args['for'])){
500
-				$output .= ' for="'.sanitize_text_field($args['for']).'" ';
501
-			}
502
-
503
-			// class
504
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
505
-			$output .= ' class="'.$class.'" ';
506
-
507
-			// close
508
-			$output .= '>';
509
-
510
-
511
-			// title, don't escape fully as can contain html
512
-			if(!empty($args['title'])){
513
-				$output .= wp_kses_post($args['title']);
514
-			}
515
-
516
-			// close wrap
517
-			$output .= '</label>';
518
-
519
-
520
-		}
521
-
522
-
523
-		return $output;
524
-	}
525
-
526
-	/**
527
-	 * Wrap some content in a HTML wrapper.
528
-	 *
529
-	 * @param array $args
530
-	 *
531
-	 * @return string
532
-	 */
533
-	public static function wrap($args = array()){
534
-		$defaults = array(
535
-			'type'       => 'div',
536
-			'class'      => 'form-group',
537
-			'content'   => '',
538
-			'input_group_left' => '',
539
-			'input_group_right' => '',
540
-			'input_group_left_inside' => false,
541
-			'input_group_right_inside' => false,
542
-			'element_require'   => '',
543
-			'argument_id'   => '',
544
-		);
545
-
546
-		/**
547
-		 * Parse incoming $args into an array and merge it with $defaults
548
-		 */
549
-		$args   = wp_parse_args( $args, $defaults );
550
-		$output = '';
551
-		if($args['type']){
552
-
553
-			// open
554
-			$output .= '<'.sanitize_html_class($args['type']);
555
-
556
-			// element require
557
-			if(!empty($args['element_require'])){
558
-				$output .= AUI_Component_Helper::element_require($args['element_require']);
559
-				$args['class'] .= " aui-conditional-field";
560
-			}
561
-
562
-			// argument_id
563
-			if( !empty($args['argument_id']) ){
564
-				$output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
565
-			}
566
-
567
-			// class
568
-			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
569
-			$output .= ' class="'.$class.'" ';
570
-
571
-			// close wrap
572
-			$output .= ' >';
573
-
574
-
575
-			// Input group left
576
-			if(!empty($args['input_group_left'])){
577
-				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
578
-				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
579
-				$output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
580
-			}
581
-
582
-			// content
583
-			$output .= $args['content'];
584
-
585
-			// Input group right
586
-			if(!empty($args['input_group_right'])){
587
-				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
588
-				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
589
-				$output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
590
-			}
591
-
592
-
593
-			// close wrap
594
-			$output .= '</'.sanitize_html_class($args['type']).'>';
595
-
596
-
597
-		}else{
598
-			$output = $args['content'];
599
-		}
600
-
601
-		return $output;
602
-	}
603
-
604
-	/**
605
-	 * Build the component.
606
-	 *
607
-	 * @param array $args
608
-	 *
609
-	 * @return string The rendered component.
610
-	 */
611
-	public static function select($args = array()){
612
-		$defaults = array(
613
-			'class'      => '',
614
-			'wrap_class' => '',
615
-			'id'         => '',
616
-			'title'      => '',
617
-			'value'      => '', // can be an array or a string
618
-			'required'   => false,
619
-			'label'      => '',
620
-			'label_after'=> false,
621
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
622
-			'label_class'      => '',
623
-			'help_text'  => '',
624
-			'placeholder'=> '',
625
-			'options'    => array(), // array or string
626
-			'icon'       => '',
627
-			'multiple'   => false,
628
-			'select2'    => false,
629
-			'no_wrap'    => false,
630
-			'element_require'   => '', // [%element_id%] == "1"
631
-			'extra_attributes'  => array(), // an array of extra attributes
632
-		);
633
-
634
-		/**
635
-		 * Parse incoming $args into an array and merge it with $defaults
636
-		 */
637
-		$args   = wp_parse_args( $args, $defaults );
638
-		$output = '';
639
-
640
-		// for now lets hide floating labels
641
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
642
-
643
-		// hidden label option needs to be empty
644
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
645
-
646
-
647
-		$label_after = $args['label_after'];
648
-
649
-		// floating labels need label after
650
-		if( $args['label_type'] == 'floating' ){
651
-			$label_after = true;
652
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
653
-		}
654
-
655
-		// Maybe setup select2
656
-		$is_select2 = false;
657
-		if(!empty($args['select2'])){
658
-			$args['class'] .= ' aui-select2';
659
-			$is_select2 = true;
660
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
661
-			$is_select2 = true;
662
-		}
663
-
664
-		// select2 tags
665
-		if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
666
-			$args['data-tags'] = 'true';
667
-			$args['data-token-separators'] = "[',']";
668
-			$args['multiple'] = true;
669
-		}
670
-
671
-		// select2 placeholder
672
-		if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){
673
-			$args['data-placeholder'] = esc_attr($args['placeholder']);
674
-			$args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true;
675
-		}
676
-
677
-		// label
678
-		if(!empty($args['label']) && is_array($args['label'])){
679
-		}elseif(!empty($args['label']) && !$label_after){
680
-			$label_args = array(
681
-				'title'=> $args['label'],
682
-				'for'=> $args['id'],
683
-				'class' => $args['label_class']." ",
684
-				'label_type' => $args['label_type']
685
-			);
686
-			$output .= self::label($label_args);
687
-		}
688
-
689
-		// maybe horizontal label
690
-		if($args['label_type']=='horizontal'){
691
-			$output .= '<div class="col-sm-10">';
692
-		}
693
-
694
-		// open/type
695
-		$output .= '<select ';
696
-
697
-		// style
698
-		if($is_select2){
699
-			$output .= " style='width:100%;' ";
700
-		}
701
-
702
-		// element require
703
-		if(!empty($args['element_require'])){
704
-			$output .= AUI_Component_Helper::element_require($args['element_require']);
705
-			$args['class'] .= " aui-conditional-field";
706
-		}
707
-
708
-		// class
709
-		$class = !empty($args['class']) ? $args['class'] : '';
710
-		$output .= AUI_Component_Helper::class_attr('custom-select '.$class);
711
-
712
-		// name
713
-		if(!empty($args['name'])){
714
-			$output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
715
-		}
716
-
717
-		// id
718
-		if(!empty($args['id'])){
719
-			$output .= AUI_Component_Helper::id($args['id']);
720
-		}
721
-
722
-		// title
723
-		if(!empty($args['title'])){
724
-			$output .= AUI_Component_Helper::title($args['title']);
725
-		}
726
-
727
-		// data-attributes
728
-		$output .= AUI_Component_Helper::data_attributes($args);
729
-
730
-		// aria-attributes
731
-		$output .= AUI_Component_Helper::aria_attributes($args);
732
-
733
-		// extra attributes
734
-		if(!empty($args['extra_attributes'])){
735
-			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
736
-		}
737
-
738
-		// required
739
-		if(!empty($args['required'])){
740
-			$output .= ' required ';
741
-		}
742
-
743
-		// multiple
744
-		if(!empty($args['multiple'])){
745
-			$output .= ' multiple ';
746
-		}
747
-
748
-		// close opening tag
749
-		$output .= ' >';
750
-
751
-		// placeholder
752
-		if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){
753
-			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
754
-		}elseif($is_select2 && !empty($args['placeholder'])){
755
-			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
756
-		}
757
-
758
-		// Options
759
-		if(!empty($args['options'])){
760
-
761
-			if(!is_array($args['options'])){
762
-				$output .= $args['options']; // not the preferred way but an option
763
-			}else{
764
-				foreach($args['options'] as $val => $name){
765
-					$selected = '';
766
-					if(is_array($name)){
767
-						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
768
-							$option_label = isset($name['label']) ? $name['label'] : '';
769
-
770
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
771
-						} else {
772
-							$option_label = isset($name['label']) ? $name['label'] : '';
773
-							$option_value = isset($name['value']) ? $name['value'] : '';
774
-							if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){
775
-								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
776
-							} elseif(!empty($args['value'])) {
777
-								$selected = selected($option_value,stripslashes_deep($args['value']), false);
778
-							}
779
-
780
-							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
781
-						}
782
-					}else{
783
-						if(!empty($args['value'])){
784
-							if(is_array($args['value'])){
785
-								$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
786
-							} elseif(!empty($args['value'])) {
787
-								$selected = selected( $args['value'], $val, false);
788
-							}
789
-						}
790
-						$output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
791
-					}
792
-				}
793
-			}
794
-
795
-		}
796
-
797
-		// closing tag
798
-		$output .= '</select>';
799
-
800
-		if(!empty($args['label']) && $label_after){
801
-			$label_args = array(
802
-				'title'=> $args['label'],
803
-				'for'=> $args['id'],
804
-				'class' => $args['label_class']." ",
805
-				'label_type' => $args['label_type']
806
-			);
807
-			$output .= self::label($label_args);
808
-		}
809
-
810
-		// help text
811
-		if(!empty($args['help_text'])){
812
-			$output .= AUI_Component_Helper::help_text($args['help_text']);
813
-		}
814
-
815
-		// maybe horizontal label
816
-		if($args['label_type']=='horizontal'){
817
-			$output .= '</div>';
818
-		}
819
-
820
-
821
-		// wrap
822
-		if(!$args['no_wrap']){
823
-			$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
824
-			$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
825
-			$output = self::wrap(array(
826
-				'content' => $output,
827
-				'class'   => $wrap_class,
828
-				'element_require'   => $args['element_require'],
829
-				'argument_id'  => $args['id']
830
-			));
831
-		}
832
-
833
-
834
-		return $output;
835
-	}
836
-
837
-	/**
838
-	 * Build the component.
839
-	 *
840
-	 * @param array $args
841
-	 *
842
-	 * @return string The rendered component.
843
-	 */
844
-	public static function radio($args = array()){
845
-		$defaults = array(
846
-			'class'      => '',
847
-			'wrap_class' => '',
848
-			'id'         => '',
849
-			'title'      => '',
850
-			'horizontal' => false, // sets the lable horizontal
851
-			'value'      => '',
852
-			'label'      => '',
853
-			'label_class'=> '',
854
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
855
-			'inline'     => true,
856
-			'required'   => false,
857
-			'options'    => array(),
858
-			'icon'       => '',
859
-			'no_wrap'    => false,
860
-			'element_require'   => '', // [%element_id%] == "1"
861
-			'extra_attributes'  => array() // an array of extra attributes
862
-		);
863
-
864
-		/**
865
-		 * Parse incoming $args into an array and merge it with $defaults
866
-		 */
867
-		$args   = wp_parse_args( $args, $defaults );
868
-
869
-		// for now lets use horizontal for floating
870
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';}
871
-
872
-		$label_args = array(
873
-			'title'=> $args['label'],
874
-			'class' => $args['label_class']." pt-0 ",
875
-			'label_type' => $args['label_type']
876
-		);
877
-
878
-		$output = '';
879
-
880
-
881
-
882
-		// label before
883
-		if(!empty($args['label'])){
884
-			$output .= self::label( $label_args, 'radio' );
885
-		}
886
-
887
-		// maybe horizontal label
888
-		if($args['label_type']=='horizontal'){
889
-			$output .= '<div class="col-sm-10">';
890
-		}
891
-
892
-		if(!empty($args['options'])){
893
-			$count = 0;
894
-			foreach($args['options'] as $value => $label){
895
-				$option_args = $args;
896
-				$option_args['value'] = $value;
897
-				$option_args['label'] = $label;
898
-				$option_args['checked'] = $value == $args['value'] ? true : false;
899
-				$output .= self::radio_option($option_args,$count);
900
-				$count++;
901
-			}
902
-		}
903
-
904
-		// maybe horizontal label
905
-		if($args['label_type']=='horizontal'){
906
-			$output .= '</div>';
907
-		}
908
-
909
-
910
-		// wrap
911
-		$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
912
-		$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
913
-		$output = self::wrap(array(
914
-			'content' => $output,
915
-			'class'   => $wrap_class,
916
-			'element_require'   => $args['element_require'],
917
-			'argument_id'  => $args['id']
918
-		));
919
-
920
-
921
-		return $output;
922
-	}
923
-
924
-	/**
925
-	 * Build the component.
926
-	 *
927
-	 * @param array $args
928
-	 *
929
-	 * @return string The rendered component.
930
-	 */
931
-	public static function radio_option($args = array(),$count = ''){
932
-		$defaults = array(
933
-			'class'      => '',
934
-			'id'         => '',
935
-			'title'      => '',
936
-			'value'      => '',
937
-			'required'   => false,
938
-			'inline'     => true,
939
-			'label'      => '',
940
-			'options'    => array(),
941
-			'icon'       => '',
942
-			'no_wrap'    => false,
943
-			'extra_attributes'  => array() // an array of extra attributes
944
-		);
945
-
946
-		/**
947
-		 * Parse incoming $args into an array and merge it with $defaults
948
-		 */
949
-		$args   = wp_parse_args( $args, $defaults );
950
-
951
-		$output = '';
952
-
953
-		// open/type
954
-		$output .= '<input type="radio"';
955
-
956
-		// class
957
-		$output .= ' class="form-check-input" ';
958
-
959
-		// name
960
-		if(!empty($args['name'])){
961
-			$output .= AUI_Component_Helper::name($args['name']);
962
-		}
963
-
964
-		// id
965
-		if(!empty($args['id'])){
966
-			$output .= AUI_Component_Helper::id($args['id'].$count);
967
-		}
968
-
969
-		// title
970
-		if(!empty($args['title'])){
971
-			$output .= AUI_Component_Helper::title($args['title']);
972
-		}
973
-
974
-		// value
975
-		if(isset($args['value'])){
976
-			$output .= ' value="'.sanitize_text_field($args['value']).'" ';
977
-		}
978
-
979
-		// checked, for radio and checkboxes
980
-		if( $args['checked'] ){
981
-			$output .= ' checked ';
982
-		}
983
-
984
-		// data-attributes
985
-		$output .= AUI_Component_Helper::data_attributes($args);
986
-
987
-		// aria-attributes
988
-		$output .= AUI_Component_Helper::aria_attributes($args);
989
-
990
-		// extra attributes
991
-		if(!empty($args['extra_attributes'])){
992
-			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
993
-		}
994
-
995
-		// required
996
-		if(!empty($args['required'])){
997
-			$output .= ' required ';
998
-		}
999
-
1000
-		// close opening tag
1001
-		$output .= ' >';
1002
-
1003
-		// label
1004
-		if(!empty($args['label']) && is_array($args['label'])){
1005
-		}elseif(!empty($args['label'])){
1006
-			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
1007
-		}
1008
-
1009
-		// wrap
1010
-		if(!$args['no_wrap']){
1011
-			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1012
-			$output = self::wrap(array(
1013
-				'content' => $output,
1014
-				'class' => $wrap_class
1015
-			));
1016
-		}
1017
-
1018
-
1019
-		return $output;
1020
-	}
213
+            }
214
+
215
+            // input group wraps
216
+            if($args['input_group_left'] || $args['input_group_right']){
217
+                $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
218
+                if($args['input_group_left']){
219
+                    $output = self::wrap( array(
220
+                        'content' => $output,
221
+                        'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
222
+                        'input_group_left' => $args['input_group_left'],
223
+                        'input_group_left_inside'    => $args['input_group_left_inside']
224
+                    ) );
225
+                }
226
+                if($args['input_group_right']){
227
+                    $output = self::wrap( array(
228
+                        'content' => $output,
229
+                        'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
230
+                        'input_group_right' => $args['input_group_right'],
231
+                        'input_group_right_inside'    => $args['input_group_right_inside']
232
+                    ) );
233
+                }
234
+
235
+            }
236
+
237
+            if(!$label_after){
238
+                $output .= $help_text;
239
+            }
240
+
241
+
242
+            if($args['label_type']=='horizontal' && $type != 'checkbox'){
243
+                $output = self::wrap( array(
244
+                    'content' => $output,
245
+                    'class'   => 'col-sm-10',
246
+                ) );
247
+            }
248
+
249
+            if(!$label_after){
250
+                $output = $label . $output;
251
+            }
252
+
253
+            // wrap
254
+            if(!$args['no_wrap']){
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;
259
+                $output = self::wrap(array(
260
+                    'content' => $output,
261
+                    'class'   => $wrap_class,
262
+                    'element_require'   => $args['element_require'],
263
+                    'argument_id'  => $args['id']
264
+                ));
265
+            }
266
+
267
+
268
+
269
+        }
270
+
271
+        return $output;
272
+    }
273
+
274
+    /**
275
+     * Build the component.
276
+     *
277
+     * @param array $args
278
+     *
279
+     * @return string The rendered component.
280
+     */
281
+    public static function textarea($args = array()){
282
+        $defaults = array(
283
+            'name'       => '',
284
+            'class'      => '',
285
+            'wrap_class' => '',
286
+            'id'         => '',
287
+            'placeholder'=> '',
288
+            'title'      => '',
289
+            'value'      => '',
290
+            'required'   => false,
291
+            'label'      => '',
292
+            'label_after'=> false,
293
+            'label_class'      => '',
294
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
295
+            'help_text'  => '',
296
+            'validation_text'   => '',
297
+            'validation_pattern' => '',
298
+            'no_wrap'    => false,
299
+            'rows'      => '',
300
+            'wysiwyg'   => false,
301
+            'element_require'   => '', // [%element_id%] == "1"
302
+        );
303
+
304
+        /**
305
+         * Parse incoming $args into an array and merge it with $defaults
306
+         */
307
+        $args   = wp_parse_args( $args, $defaults );
308
+        $output = '';
309
+
310
+        // hidden label option needs to be empty
311
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
312
+
313
+        // floating labels don't work with wysiwyg so set it as top
314
+        if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
315
+            $args['label_type'] = 'top';
316
+        }
317
+
318
+        $label_after = $args['label_after'];
319
+
320
+        // floating labels need label after
321
+        if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
322
+            $label_after = true;
323
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
324
+        }
325
+
326
+        // label
327
+        if(!empty($args['label']) && is_array($args['label'])){
328
+        }elseif(!empty($args['label']) && !$label_after){
329
+            $label_args = array(
330
+                'title'=> $args['label'],
331
+                'for'=> $args['id'],
332
+                'class' => $args['label_class']." ",
333
+                'label_type' => $args['label_type']
334
+            );
335
+            $output .= self::label( $label_args );
336
+        }
337
+
338
+        // maybe horizontal label
339
+        if($args['label_type']=='horizontal'){
340
+            $output .= '<div class="col-sm-10">';
341
+        }
342
+
343
+        if(!empty($args['wysiwyg'])){
344
+            ob_start();
345
+            $content = $args['value'];
346
+            $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
347
+            $settings = array(
348
+                'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
349
+                'quicktags'     => false,
350
+                'media_buttons' => false,
351
+                'editor_class'  => 'form-control',
352
+                'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
353
+                'teeny'         => true,
354
+            );
355
+
356
+            // maybe set settings if array
357
+            if(is_array($args['wysiwyg'])){
358
+                $settings  = wp_parse_args( $args['wysiwyg'], $settings );
359
+            }
360
+
361
+            wp_editor( $content, $editor_id, $settings );
362
+            $output .= ob_get_clean();
363
+        }else{
364
+
365
+            // open
366
+            $output .= '<textarea ';
367
+
368
+            // name
369
+            if(!empty($args['name'])){
370
+                $output .= ' name="'.sanitize_html_class($args['name']).'" ';
371
+            }
372
+
373
+            // id
374
+            if(!empty($args['id'])){
375
+                $output .= ' id="'.sanitize_html_class($args['id']).'" ';
376
+            }
377
+
378
+            // placeholder
379
+            if(isset($args['placeholder']) && '' != $args['placeholder']){
380
+                $output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
381
+            }
382
+
383
+            // title
384
+            if(!empty($args['title'])){
385
+                $output .= ' title="'.esc_attr($args['title']).'" ';
386
+            }
387
+
388
+            // validation text
389
+            if(!empty($args['validation_text'])){
390
+                $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
391
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
392
+            }
393
+
394
+            // validation_pattern
395
+            if(!empty($args['validation_pattern'])){
396
+                $output .= ' pattern="'.$args['validation_pattern'].'" ';
397
+            }
398
+
399
+            // required
400
+            if(!empty($args['required'])){
401
+                $output .= ' required ';
402
+            }
403
+
404
+            // rows
405
+            if(!empty($args['rows'])){
406
+                $output .= ' rows="'.absint($args['rows']).'" ';
407
+            }
408
+
409
+
410
+            // class
411
+            $class = !empty($args['class']) ? $args['class'] : '';
412
+            $output .= ' class="form-control '.$class.'" ';
413
+
414
+
415
+            // close tag
416
+            $output .= ' >';
417
+
418
+            // value
419
+            if(!empty($args['value'])){
420
+                $output .= sanitize_textarea_field($args['value']);
421
+            }
422
+
423
+            // closing tag
424
+            $output .= '</textarea>';
425
+
426
+        }
427
+
428
+        if(!empty($args['label']) && $label_after){
429
+            $label_args = array(
430
+                'title'=> $args['label'],
431
+                'for'=> $args['id'],
432
+                'class' => $args['label_class']." ",
433
+                'label_type' => $args['label_type']
434
+            );
435
+            $output .= self::label( $label_args );
436
+        }
437
+
438
+        // help text
439
+        if(!empty($args['help_text'])){
440
+            $output .= AUI_Component_Helper::help_text($args['help_text']);
441
+        }
442
+
443
+        // maybe horizontal label
444
+        if($args['label_type']=='horizontal'){
445
+            $output .= '</div>';
446
+        }
447
+
448
+
449
+        // wrap
450
+        if(!$args['no_wrap']){
451
+            $form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
452
+            $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
453
+            $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
454
+            $output = self::wrap(array(
455
+                'content' => $output,
456
+                'class'   => $wrap_class,
457
+                'element_require'   => $args['element_require'],
458
+                'argument_id'  => $args['id']
459
+            ));
460
+        }
461
+
462
+
463
+        return $output;
464
+    }
465
+
466
+    public static function label($args = array(), $type = ''){
467
+        //<label for="exampleInputEmail1">Email address</label>
468
+        $defaults = array(
469
+            'title'       => 'div',
470
+            'for'      => '',
471
+            'class'      => '',
472
+            'label_type'    => '', // empty = hidden, top, horizontal
473
+        );
474
+
475
+        /**
476
+         * Parse incoming $args into an array and merge it with $defaults
477
+         */
478
+        $args   = wp_parse_args( $args, $defaults );
479
+        $output = '';
480
+
481
+        if($args['title']){
482
+
483
+            // maybe hide labels //@todo set a global option for visibility class
484
+            if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
485
+                $class = $args['class'];
486
+            }else{
487
+                $class = 'sr-only '.$args['class'];
488
+            }
489
+
490
+            // maybe horizontal
491
+            if($args['label_type']=='horizontal' && $type != 'checkbox'){
492
+                $class .= ' col-sm-2 col-form-label';
493
+            }
494
+
495
+            // open
496
+            $output .= '<label ';
497
+
498
+            // for
499
+            if(!empty($args['for'])){
500
+                $output .= ' for="'.sanitize_text_field($args['for']).'" ';
501
+            }
502
+
503
+            // class
504
+            $class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
505
+            $output .= ' class="'.$class.'" ';
506
+
507
+            // close
508
+            $output .= '>';
509
+
510
+
511
+            // title, don't escape fully as can contain html
512
+            if(!empty($args['title'])){
513
+                $output .= wp_kses_post($args['title']);
514
+            }
515
+
516
+            // close wrap
517
+            $output .= '</label>';
518
+
519
+
520
+        }
521
+
522
+
523
+        return $output;
524
+    }
525
+
526
+    /**
527
+     * Wrap some content in a HTML wrapper.
528
+     *
529
+     * @param array $args
530
+     *
531
+     * @return string
532
+     */
533
+    public static function wrap($args = array()){
534
+        $defaults = array(
535
+            'type'       => 'div',
536
+            'class'      => 'form-group',
537
+            'content'   => '',
538
+            'input_group_left' => '',
539
+            'input_group_right' => '',
540
+            'input_group_left_inside' => false,
541
+            'input_group_right_inside' => false,
542
+            'element_require'   => '',
543
+            'argument_id'   => '',
544
+        );
545
+
546
+        /**
547
+         * Parse incoming $args into an array and merge it with $defaults
548
+         */
549
+        $args   = wp_parse_args( $args, $defaults );
550
+        $output = '';
551
+        if($args['type']){
552
+
553
+            // open
554
+            $output .= '<'.sanitize_html_class($args['type']);
555
+
556
+            // element require
557
+            if(!empty($args['element_require'])){
558
+                $output .= AUI_Component_Helper::element_require($args['element_require']);
559
+                $args['class'] .= " aui-conditional-field";
560
+            }
561
+
562
+            // argument_id
563
+            if( !empty($args['argument_id']) ){
564
+                $output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
565
+            }
566
+
567
+            // class
568
+            $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
569
+            $output .= ' class="'.$class.'" ';
570
+
571
+            // close wrap
572
+            $output .= ' >';
573
+
574
+
575
+            // Input group left
576
+            if(!empty($args['input_group_left'])){
577
+                $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
578
+                $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
579
+                $output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
580
+            }
581
+
582
+            // content
583
+            $output .= $args['content'];
584
+
585
+            // Input group right
586
+            if(!empty($args['input_group_right'])){
587
+                $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
588
+                $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
589
+                $output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
590
+            }
591
+
592
+
593
+            // close wrap
594
+            $output .= '</'.sanitize_html_class($args['type']).'>';
595
+
596
+
597
+        }else{
598
+            $output = $args['content'];
599
+        }
600
+
601
+        return $output;
602
+    }
603
+
604
+    /**
605
+     * Build the component.
606
+     *
607
+     * @param array $args
608
+     *
609
+     * @return string The rendered component.
610
+     */
611
+    public static function select($args = array()){
612
+        $defaults = array(
613
+            'class'      => '',
614
+            'wrap_class' => '',
615
+            'id'         => '',
616
+            'title'      => '',
617
+            'value'      => '', // can be an array or a string
618
+            'required'   => false,
619
+            'label'      => '',
620
+            'label_after'=> false,
621
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
622
+            'label_class'      => '',
623
+            'help_text'  => '',
624
+            'placeholder'=> '',
625
+            'options'    => array(), // array or string
626
+            'icon'       => '',
627
+            'multiple'   => false,
628
+            'select2'    => false,
629
+            'no_wrap'    => false,
630
+            'element_require'   => '', // [%element_id%] == "1"
631
+            'extra_attributes'  => array(), // an array of extra attributes
632
+        );
633
+
634
+        /**
635
+         * Parse incoming $args into an array and merge it with $defaults
636
+         */
637
+        $args   = wp_parse_args( $args, $defaults );
638
+        $output = '';
639
+
640
+        // for now lets hide floating labels
641
+        if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
642
+
643
+        // hidden label option needs to be empty
644
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
645
+
646
+
647
+        $label_after = $args['label_after'];
648
+
649
+        // floating labels need label after
650
+        if( $args['label_type'] == 'floating' ){
651
+            $label_after = true;
652
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
653
+        }
654
+
655
+        // Maybe setup select2
656
+        $is_select2 = false;
657
+        if(!empty($args['select2'])){
658
+            $args['class'] .= ' aui-select2';
659
+            $is_select2 = true;
660
+        }elseif( strpos($args['class'], 'aui-select2') !== false){
661
+            $is_select2 = true;
662
+        }
663
+
664
+        // select2 tags
665
+        if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
666
+            $args['data-tags'] = 'true';
667
+            $args['data-token-separators'] = "[',']";
668
+            $args['multiple'] = true;
669
+        }
670
+
671
+        // select2 placeholder
672
+        if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){
673
+            $args['data-placeholder'] = esc_attr($args['placeholder']);
674
+            $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true;
675
+        }
676
+
677
+        // label
678
+        if(!empty($args['label']) && is_array($args['label'])){
679
+        }elseif(!empty($args['label']) && !$label_after){
680
+            $label_args = array(
681
+                'title'=> $args['label'],
682
+                'for'=> $args['id'],
683
+                'class' => $args['label_class']." ",
684
+                'label_type' => $args['label_type']
685
+            );
686
+            $output .= self::label($label_args);
687
+        }
688
+
689
+        // maybe horizontal label
690
+        if($args['label_type']=='horizontal'){
691
+            $output .= '<div class="col-sm-10">';
692
+        }
693
+
694
+        // open/type
695
+        $output .= '<select ';
696
+
697
+        // style
698
+        if($is_select2){
699
+            $output .= " style='width:100%;' ";
700
+        }
701
+
702
+        // element require
703
+        if(!empty($args['element_require'])){
704
+            $output .= AUI_Component_Helper::element_require($args['element_require']);
705
+            $args['class'] .= " aui-conditional-field";
706
+        }
707
+
708
+        // class
709
+        $class = !empty($args['class']) ? $args['class'] : '';
710
+        $output .= AUI_Component_Helper::class_attr('custom-select '.$class);
711
+
712
+        // name
713
+        if(!empty($args['name'])){
714
+            $output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
715
+        }
716
+
717
+        // id
718
+        if(!empty($args['id'])){
719
+            $output .= AUI_Component_Helper::id($args['id']);
720
+        }
721
+
722
+        // title
723
+        if(!empty($args['title'])){
724
+            $output .= AUI_Component_Helper::title($args['title']);
725
+        }
726
+
727
+        // data-attributes
728
+        $output .= AUI_Component_Helper::data_attributes($args);
729
+
730
+        // aria-attributes
731
+        $output .= AUI_Component_Helper::aria_attributes($args);
732
+
733
+        // extra attributes
734
+        if(!empty($args['extra_attributes'])){
735
+            $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
736
+        }
737
+
738
+        // required
739
+        if(!empty($args['required'])){
740
+            $output .= ' required ';
741
+        }
742
+
743
+        // multiple
744
+        if(!empty($args['multiple'])){
745
+            $output .= ' multiple ';
746
+        }
747
+
748
+        // close opening tag
749
+        $output .= ' >';
750
+
751
+        // placeholder
752
+        if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){
753
+            $output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
754
+        }elseif($is_select2 && !empty($args['placeholder'])){
755
+            $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
756
+        }
757
+
758
+        // Options
759
+        if(!empty($args['options'])){
760
+
761
+            if(!is_array($args['options'])){
762
+                $output .= $args['options']; // not the preferred way but an option
763
+            }else{
764
+                foreach($args['options'] as $val => $name){
765
+                    $selected = '';
766
+                    if(is_array($name)){
767
+                        if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
768
+                            $option_label = isset($name['label']) ? $name['label'] : '';
769
+
770
+                            $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
771
+                        } else {
772
+                            $option_label = isset($name['label']) ? $name['label'] : '';
773
+                            $option_value = isset($name['value']) ? $name['value'] : '';
774
+                            if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){
775
+                                $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
776
+                            } elseif(!empty($args['value'])) {
777
+                                $selected = selected($option_value,stripslashes_deep($args['value']), false);
778
+                            }
779
+
780
+                            $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
781
+                        }
782
+                    }else{
783
+                        if(!empty($args['value'])){
784
+                            if(is_array($args['value'])){
785
+                                $selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
786
+                            } elseif(!empty($args['value'])) {
787
+                                $selected = selected( $args['value'], $val, false);
788
+                            }
789
+                        }
790
+                        $output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
791
+                    }
792
+                }
793
+            }
794
+
795
+        }
796
+
797
+        // closing tag
798
+        $output .= '</select>';
799
+
800
+        if(!empty($args['label']) && $label_after){
801
+            $label_args = array(
802
+                'title'=> $args['label'],
803
+                'for'=> $args['id'],
804
+                'class' => $args['label_class']." ",
805
+                'label_type' => $args['label_type']
806
+            );
807
+            $output .= self::label($label_args);
808
+        }
809
+
810
+        // help text
811
+        if(!empty($args['help_text'])){
812
+            $output .= AUI_Component_Helper::help_text($args['help_text']);
813
+        }
814
+
815
+        // maybe horizontal label
816
+        if($args['label_type']=='horizontal'){
817
+            $output .= '</div>';
818
+        }
819
+
820
+
821
+        // wrap
822
+        if(!$args['no_wrap']){
823
+            $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
824
+            $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
825
+            $output = self::wrap(array(
826
+                'content' => $output,
827
+                'class'   => $wrap_class,
828
+                'element_require'   => $args['element_require'],
829
+                'argument_id'  => $args['id']
830
+            ));
831
+        }
832
+
833
+
834
+        return $output;
835
+    }
836
+
837
+    /**
838
+     * Build the component.
839
+     *
840
+     * @param array $args
841
+     *
842
+     * @return string The rendered component.
843
+     */
844
+    public static function radio($args = array()){
845
+        $defaults = array(
846
+            'class'      => '',
847
+            'wrap_class' => '',
848
+            'id'         => '',
849
+            'title'      => '',
850
+            'horizontal' => false, // sets the lable horizontal
851
+            'value'      => '',
852
+            'label'      => '',
853
+            'label_class'=> '',
854
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
855
+            'inline'     => true,
856
+            'required'   => false,
857
+            'options'    => array(),
858
+            'icon'       => '',
859
+            'no_wrap'    => false,
860
+            'element_require'   => '', // [%element_id%] == "1"
861
+            'extra_attributes'  => array() // an array of extra attributes
862
+        );
863
+
864
+        /**
865
+         * Parse incoming $args into an array and merge it with $defaults
866
+         */
867
+        $args   = wp_parse_args( $args, $defaults );
868
+
869
+        // for now lets use horizontal for floating
870
+        if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';}
871
+
872
+        $label_args = array(
873
+            'title'=> $args['label'],
874
+            'class' => $args['label_class']." pt-0 ",
875
+            'label_type' => $args['label_type']
876
+        );
877
+
878
+        $output = '';
879
+
880
+
881
+
882
+        // label before
883
+        if(!empty($args['label'])){
884
+            $output .= self::label( $label_args, 'radio' );
885
+        }
886
+
887
+        // maybe horizontal label
888
+        if($args['label_type']=='horizontal'){
889
+            $output .= '<div class="col-sm-10">';
890
+        }
891
+
892
+        if(!empty($args['options'])){
893
+            $count = 0;
894
+            foreach($args['options'] as $value => $label){
895
+                $option_args = $args;
896
+                $option_args['value'] = $value;
897
+                $option_args['label'] = $label;
898
+                $option_args['checked'] = $value == $args['value'] ? true : false;
899
+                $output .= self::radio_option($option_args,$count);
900
+                $count++;
901
+            }
902
+        }
903
+
904
+        // maybe horizontal label
905
+        if($args['label_type']=='horizontal'){
906
+            $output .= '</div>';
907
+        }
908
+
909
+
910
+        // wrap
911
+        $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
912
+        $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
913
+        $output = self::wrap(array(
914
+            'content' => $output,
915
+            'class'   => $wrap_class,
916
+            'element_require'   => $args['element_require'],
917
+            'argument_id'  => $args['id']
918
+        ));
919
+
920
+
921
+        return $output;
922
+    }
923
+
924
+    /**
925
+     * Build the component.
926
+     *
927
+     * @param array $args
928
+     *
929
+     * @return string The rendered component.
930
+     */
931
+    public static function radio_option($args = array(),$count = ''){
932
+        $defaults = array(
933
+            'class'      => '',
934
+            'id'         => '',
935
+            'title'      => '',
936
+            'value'      => '',
937
+            'required'   => false,
938
+            'inline'     => true,
939
+            'label'      => '',
940
+            'options'    => array(),
941
+            'icon'       => '',
942
+            'no_wrap'    => false,
943
+            'extra_attributes'  => array() // an array of extra attributes
944
+        );
945
+
946
+        /**
947
+         * Parse incoming $args into an array and merge it with $defaults
948
+         */
949
+        $args   = wp_parse_args( $args, $defaults );
950
+
951
+        $output = '';
952
+
953
+        // open/type
954
+        $output .= '<input type="radio"';
955
+
956
+        // class
957
+        $output .= ' class="form-check-input" ';
958
+
959
+        // name
960
+        if(!empty($args['name'])){
961
+            $output .= AUI_Component_Helper::name($args['name']);
962
+        }
963
+
964
+        // id
965
+        if(!empty($args['id'])){
966
+            $output .= AUI_Component_Helper::id($args['id'].$count);
967
+        }
968
+
969
+        // title
970
+        if(!empty($args['title'])){
971
+            $output .= AUI_Component_Helper::title($args['title']);
972
+        }
973
+
974
+        // value
975
+        if(isset($args['value'])){
976
+            $output .= ' value="'.sanitize_text_field($args['value']).'" ';
977
+        }
978
+
979
+        // checked, for radio and checkboxes
980
+        if( $args['checked'] ){
981
+            $output .= ' checked ';
982
+        }
983
+
984
+        // data-attributes
985
+        $output .= AUI_Component_Helper::data_attributes($args);
986
+
987
+        // aria-attributes
988
+        $output .= AUI_Component_Helper::aria_attributes($args);
989
+
990
+        // extra attributes
991
+        if(!empty($args['extra_attributes'])){
992
+            $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
993
+        }
994
+
995
+        // required
996
+        if(!empty($args['required'])){
997
+            $output .= ' required ';
998
+        }
999
+
1000
+        // close opening tag
1001
+        $output .= ' >';
1002
+
1003
+        // label
1004
+        if(!empty($args['label']) && is_array($args['label'])){
1005
+        }elseif(!empty($args['label'])){
1006
+            $output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
1007
+        }
1008
+
1009
+        // wrap
1010
+        if(!$args['no_wrap']){
1011
+            $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1012
+            $output = self::wrap(array(
1013
+                'content' => $output,
1014
+                'class' => $wrap_class
1015
+            ));
1016
+        }
1017
+
1018
+
1019
+        return $output;
1020
+    }
1021 1021
 
1022 1022
 }
1023 1023
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'      => '',
@@ -304,43 +304,43 @@  discard block
 block discarded – undo
304 304
 		/**
305 305
 		 * Parse incoming $args into an array and merge it with $defaults
306 306
 		 */
307
-		$args   = wp_parse_args( $args, $defaults );
307
+		$args   = wp_parse_args($args, $defaults);
308 308
 		$output = '';
309 309
 
310 310
 		// hidden label option needs to be empty
311 311
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
312 312
 
313 313
 		// floating labels don't work with wysiwyg so set it as top
314
-		if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
314
+		if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) {
315 315
 			$args['label_type'] = 'top';
316 316
 		}
317 317
 
318 318
 		$label_after = $args['label_after'];
319 319
 
320 320
 		// floating labels need label after
321
-		if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
321
+		if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) {
322 322
 			$label_after = true;
323 323
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
324 324
 		}
325 325
 
326 326
 		// label
327
-		if(!empty($args['label']) && is_array($args['label'])){
328
-		}elseif(!empty($args['label']) && !$label_after){
327
+		if (!empty($args['label']) && is_array($args['label'])) {
328
+		}elseif (!empty($args['label']) && !$label_after) {
329 329
 			$label_args = array(
330 330
 				'title'=> $args['label'],
331 331
 				'for'=> $args['id'],
332
-				'class' => $args['label_class']." ",
332
+				'class' => $args['label_class'] . " ",
333 333
 				'label_type' => $args['label_type']
334 334
 			);
335
-			$output .= self::label( $label_args );
335
+			$output .= self::label($label_args);
336 336
 		}
337 337
 
338 338
 		// maybe horizontal label
339
-		if($args['label_type']=='horizontal'){
339
+		if ($args['label_type'] == 'horizontal') {
340 340
 			$output .= '<div class="col-sm-10">';
341 341
 		}
342 342
 
343
-		if(!empty($args['wysiwyg'])){
343
+		if (!empty($args['wysiwyg'])) {
344 344
 			ob_start();
345 345
 			$content = $args['value'];
346 346
 			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
@@ -354,69 +354,69 @@  discard block
 block discarded – undo
354 354
 			);
355 355
 
356 356
 			// maybe set settings if array
357
-			if(is_array($args['wysiwyg'])){
358
-				$settings  = wp_parse_args( $args['wysiwyg'], $settings );
357
+			if (is_array($args['wysiwyg'])) {
358
+				$settings = wp_parse_args($args['wysiwyg'], $settings);
359 359
 			}
360 360
 
361
-			wp_editor( $content, $editor_id, $settings );
361
+			wp_editor($content, $editor_id, $settings);
362 362
 			$output .= ob_get_clean();
363
-		}else{
363
+		} else {
364 364
 
365 365
 			// open
366 366
 			$output .= '<textarea ';
367 367
 
368 368
 			// name
369
-			if(!empty($args['name'])){
370
-				$output .= ' name="'.sanitize_html_class($args['name']).'" ';
369
+			if (!empty($args['name'])) {
370
+				$output .= ' name="' . sanitize_html_class($args['name']) . '" ';
371 371
 			}
372 372
 
373 373
 			// id
374
-			if(!empty($args['id'])){
375
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
374
+			if (!empty($args['id'])) {
375
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
376 376
 			}
377 377
 
378 378
 			// placeholder
379
-			if(isset($args['placeholder']) && '' != $args['placeholder']){
380
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
379
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
380
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
381 381
 			}
382 382
 
383 383
 			// title
384
-			if(!empty($args['title'])){
385
-				$output .= ' title="'.esc_attr($args['title']).'" ';
384
+			if (!empty($args['title'])) {
385
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
386 386
 			}
387 387
 
388 388
 			// validation text
389
-			if(!empty($args['validation_text'])){
390
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
389
+			if (!empty($args['validation_text'])) {
390
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
391 391
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
392 392
 			}
393 393
 
394 394
 			// validation_pattern
395
-			if(!empty($args['validation_pattern'])){
396
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
395
+			if (!empty($args['validation_pattern'])) {
396
+				$output .= ' pattern="' . $args['validation_pattern'] . '" ';
397 397
 			}
398 398
 
399 399
 			// required
400
-			if(!empty($args['required'])){
400
+			if (!empty($args['required'])) {
401 401
 				$output .= ' required ';
402 402
 			}
403 403
 
404 404
 			// rows
405
-			if(!empty($args['rows'])){
406
-				$output .= ' rows="'.absint($args['rows']).'" ';
405
+			if (!empty($args['rows'])) {
406
+				$output .= ' rows="' . absint($args['rows']) . '" ';
407 407
 			}
408 408
 
409 409
 
410 410
 			// class
411 411
 			$class = !empty($args['class']) ? $args['class'] : '';
412
-			$output .= ' class="form-control '.$class.'" ';
412
+			$output .= ' class="form-control ' . $class . '" ';
413 413
 
414 414
 
415 415
 			// close tag
416 416
 			$output .= ' >';
417 417
 
418 418
 			// value
419
-			if(!empty($args['value'])){
419
+			if (!empty($args['value'])) {
420 420
 				$output .= sanitize_textarea_field($args['value']);
421 421
 			}
422 422
 
@@ -425,32 +425,32 @@  discard block
 block discarded – undo
425 425
 
426 426
 		}
427 427
 
428
-		if(!empty($args['label']) && $label_after){
428
+		if (!empty($args['label']) && $label_after) {
429 429
 			$label_args = array(
430 430
 				'title'=> $args['label'],
431 431
 				'for'=> $args['id'],
432
-				'class' => $args['label_class']." ",
432
+				'class' => $args['label_class'] . " ",
433 433
 				'label_type' => $args['label_type']
434 434
 			);
435
-			$output .= self::label( $label_args );
435
+			$output .= self::label($label_args);
436 436
 		}
437 437
 
438 438
 		// help text
439
-		if(!empty($args['help_text'])){
439
+		if (!empty($args['help_text'])) {
440 440
 			$output .= AUI_Component_Helper::help_text($args['help_text']);
441 441
 		}
442 442
 
443 443
 		// maybe horizontal label
444
-		if($args['label_type']=='horizontal'){
444
+		if ($args['label_type'] == 'horizontal') {
445 445
 			$output .= '</div>';
446 446
 		}
447 447
 
448 448
 
449 449
 		// wrap
450
-		if(!$args['no_wrap']){
451
-			$form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
452
-			$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
453
-			$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
450
+		if (!$args['no_wrap']) {
451
+			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
452
+			$wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
453
+			$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
454 454
 			$output = self::wrap(array(
455 455
 				'content' => $output,
456 456
 				'class'   => $wrap_class,
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 		return $output;
464 464
 	}
465 465
 
466
-	public static function label($args = array(), $type = ''){
466
+	public static function label($args = array(), $type = '') {
467 467
 		//<label for="exampleInputEmail1">Email address</label>
468 468
 		$defaults = array(
469 469
 			'title'       => 'div',
@@ -475,20 +475,20 @@  discard block
 block discarded – undo
475 475
 		/**
476 476
 		 * Parse incoming $args into an array and merge it with $defaults
477 477
 		 */
478
-		$args   = wp_parse_args( $args, $defaults );
478
+		$args   = wp_parse_args($args, $defaults);
479 479
 		$output = '';
480 480
 
481
-		if($args['title']){
481
+		if ($args['title']) {
482 482
 
483 483
 			// maybe hide labels //@todo set a global option for visibility class
484
-			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
484
+			if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) {
485 485
 				$class = $args['class'];
486
-			}else{
487
-				$class = 'sr-only '.$args['class'];
486
+			} else {
487
+				$class = 'sr-only ' . $args['class'];
488 488
 			}
489 489
 
490 490
 			// maybe horizontal
491
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
491
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
492 492
 				$class .= ' col-sm-2 col-form-label';
493 493
 			}
494 494
 
@@ -496,20 +496,20 @@  discard block
 block discarded – undo
496 496
 			$output .= '<label ';
497 497
 
498 498
 			// for
499
-			if(!empty($args['for'])){
500
-				$output .= ' for="'.sanitize_text_field($args['for']).'" ';
499
+			if (!empty($args['for'])) {
500
+				$output .= ' for="' . sanitize_text_field($args['for']) . '" ';
501 501
 			}
502 502
 
503 503
 			// class
504
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
505
-			$output .= ' class="'.$class.'" ';
504
+			$class = $class ? AUI_Component_Helper::esc_classes($class) : '';
505
+			$output .= ' class="' . $class . '" ';
506 506
 
507 507
 			// close
508 508
 			$output .= '>';
509 509
 
510 510
 
511 511
 			// title, don't escape fully as can contain html
512
-			if(!empty($args['title'])){
512
+			if (!empty($args['title'])) {
513 513
 				$output .= wp_kses_post($args['title']);
514 514
 			}
515 515
 
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 	 *
531 531
 	 * @return string
532 532
 	 */
533
-	public static function wrap($args = array()){
533
+	public static function wrap($args = array()) {
534 534
 		$defaults = array(
535 535
 			'type'       => 'div',
536 536
 			'class'      => 'form-group',
@@ -546,55 +546,55 @@  discard block
 block discarded – undo
546 546
 		/**
547 547
 		 * Parse incoming $args into an array and merge it with $defaults
548 548
 		 */
549
-		$args   = wp_parse_args( $args, $defaults );
549
+		$args   = wp_parse_args($args, $defaults);
550 550
 		$output = '';
551
-		if($args['type']){
551
+		if ($args['type']) {
552 552
 
553 553
 			// open
554
-			$output .= '<'.sanitize_html_class($args['type']);
554
+			$output .= '<' . sanitize_html_class($args['type']);
555 555
 
556 556
 			// element require
557
-			if(!empty($args['element_require'])){
557
+			if (!empty($args['element_require'])) {
558 558
 				$output .= AUI_Component_Helper::element_require($args['element_require']);
559 559
 				$args['class'] .= " aui-conditional-field";
560 560
 			}
561 561
 
562 562
 			// argument_id
563
-			if( !empty($args['argument_id']) ){
564
-				$output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
563
+			if (!empty($args['argument_id'])) {
564
+				$output .= ' data-argument="' . esc_attr($args['argument_id']) . '"';
565 565
 			}
566 566
 
567 567
 			// class
568
-			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
569
-			$output .= ' class="'.$class.'" ';
568
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
569
+			$output .= ' class="' . $class . '" ';
570 570
 
571 571
 			// close wrap
572 572
 			$output .= ' >';
573 573
 
574 574
 
575 575
 			// Input group left
576
-			if(!empty($args['input_group_left'])){
576
+			if (!empty($args['input_group_left'])) {
577 577
 				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
578
-				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
579
-				$output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
578
+				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
579
+				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
580 580
 			}
581 581
 
582 582
 			// content
583 583
 			$output .= $args['content'];
584 584
 
585 585
 			// Input group right
586
-			if(!empty($args['input_group_right'])){
586
+			if (!empty($args['input_group_right'])) {
587 587
 				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
588
-				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
589
-				$output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
588
+				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
589
+				$output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
590 590
 			}
591 591
 
592 592
 
593 593
 			// close wrap
594
-			$output .= '</'.sanitize_html_class($args['type']).'>';
594
+			$output .= '</' . sanitize_html_class($args['type']) . '>';
595 595
 
596 596
 
597
-		}else{
597
+		} else {
598 598
 			$output = $args['content'];
599 599
 		}
600 600
 
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	 *
609 609
 	 * @return string The rendered component.
610 610
 	 */
611
-	public static function select($args = array()){
611
+	public static function select($args = array()) {
612 612
 		$defaults = array(
613 613
 			'class'      => '',
614 614
 			'wrap_class' => '',
@@ -634,11 +634,11 @@  discard block
 block discarded – undo
634 634
 		/**
635 635
 		 * Parse incoming $args into an array and merge it with $defaults
636 636
 		 */
637
-		$args   = wp_parse_args( $args, $defaults );
637
+		$args   = wp_parse_args($args, $defaults);
638 638
 		$output = '';
639 639
 
640 640
 		// for now lets hide floating labels
641
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
641
+		if ($args['label_type'] == 'floating') {$args['label_type'] = 'hidden'; }
642 642
 
643 643
 		// hidden label option needs to be empty
644 644
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
@@ -647,47 +647,47 @@  discard block
 block discarded – undo
647 647
 		$label_after = $args['label_after'];
648 648
 
649 649
 		// floating labels need label after
650
-		if( $args['label_type'] == 'floating' ){
650
+		if ($args['label_type'] == 'floating') {
651 651
 			$label_after = true;
652 652
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
653 653
 		}
654 654
 
655 655
 		// Maybe setup select2
656 656
 		$is_select2 = false;
657
-		if(!empty($args['select2'])){
657
+		if (!empty($args['select2'])) {
658 658
 			$args['class'] .= ' aui-select2';
659 659
 			$is_select2 = true;
660
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
660
+		}elseif (strpos($args['class'], 'aui-select2') !== false) {
661 661
 			$is_select2 = true;
662 662
 		}
663 663
 
664 664
 		// select2 tags
665
-		if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
665
+		if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason
666 666
 			$args['data-tags'] = 'true';
667 667
 			$args['data-token-separators'] = "[',']";
668 668
 			$args['multiple'] = true;
669 669
 		}
670 670
 
671 671
 		// select2 placeholder
672
-		if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){
672
+		if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) {
673 673
 			$args['data-placeholder'] = esc_attr($args['placeholder']);
674 674
 			$args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true;
675 675
 		}
676 676
 
677 677
 		// label
678
-		if(!empty($args['label']) && is_array($args['label'])){
679
-		}elseif(!empty($args['label']) && !$label_after){
678
+		if (!empty($args['label']) && is_array($args['label'])) {
679
+		}elseif (!empty($args['label']) && !$label_after) {
680 680
 			$label_args = array(
681 681
 				'title'=> $args['label'],
682 682
 				'for'=> $args['id'],
683
-				'class' => $args['label_class']." ",
683
+				'class' => $args['label_class'] . " ",
684 684
 				'label_type' => $args['label_type']
685 685
 			);
686 686
 			$output .= self::label($label_args);
687 687
 		}
688 688
 
689 689
 		// maybe horizontal label
690
-		if($args['label_type']=='horizontal'){
690
+		if ($args['label_type'] == 'horizontal') {
691 691
 			$output .= '<div class="col-sm-10">';
692 692
 		}
693 693
 
@@ -695,32 +695,32 @@  discard block
 block discarded – undo
695 695
 		$output .= '<select ';
696 696
 
697 697
 		// style
698
-		if($is_select2){
698
+		if ($is_select2) {
699 699
 			$output .= " style='width:100%;' ";
700 700
 		}
701 701
 
702 702
 		// element require
703
-		if(!empty($args['element_require'])){
703
+		if (!empty($args['element_require'])) {
704 704
 			$output .= AUI_Component_Helper::element_require($args['element_require']);
705 705
 			$args['class'] .= " aui-conditional-field";
706 706
 		}
707 707
 
708 708
 		// class
709 709
 		$class = !empty($args['class']) ? $args['class'] : '';
710
-		$output .= AUI_Component_Helper::class_attr('custom-select '.$class);
710
+		$output .= AUI_Component_Helper::class_attr('custom-select ' . $class);
711 711
 
712 712
 		// name
713
-		if(!empty($args['name'])){
714
-			$output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
713
+		if (!empty($args['name'])) {
714
+			$output .= AUI_Component_Helper::name($args['name'], $args['multiple']);
715 715
 		}
716 716
 
717 717
 		// id
718
-		if(!empty($args['id'])){
718
+		if (!empty($args['id'])) {
719 719
 			$output .= AUI_Component_Helper::id($args['id']);
720 720
 		}
721 721
 
722 722
 		// title
723
-		if(!empty($args['title'])){
723
+		if (!empty($args['title'])) {
724 724
 			$output .= AUI_Component_Helper::title($args['title']);
725 725
 		}
726 726
 
@@ -731,17 +731,17 @@  discard block
 block discarded – undo
731 731
 		$output .= AUI_Component_Helper::aria_attributes($args);
732 732
 
733 733
 		// extra attributes
734
-		if(!empty($args['extra_attributes'])){
734
+		if (!empty($args['extra_attributes'])) {
735 735
 			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
736 736
 		}
737 737
 
738 738
 		// required
739
-		if(!empty($args['required'])){
739
+		if (!empty($args['required'])) {
740 740
 			$output .= ' required ';
741 741
 		}
742 742
 
743 743
 		// multiple
744
-		if(!empty($args['multiple'])){
744
+		if (!empty($args['multiple'])) {
745 745
 			$output .= ' multiple ';
746 746
 		}
747 747
 
@@ -749,21 +749,21 @@  discard block
 block discarded – undo
749 749
 		$output .= ' >';
750 750
 
751 751
 		// placeholder
752
-		if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){
753
-			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
754
-		}elseif($is_select2 && !empty($args['placeholder'])){
752
+		if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) {
753
+			$output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>';
754
+		}elseif ($is_select2 && !empty($args['placeholder'])) {
755 755
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
756 756
 		}
757 757
 
758 758
 		// Options
759
-		if(!empty($args['options'])){
759
+		if (!empty($args['options'])) {
760 760
 
761
-			if(!is_array($args['options'])){
761
+			if (!is_array($args['options'])) {
762 762
 				$output .= $args['options']; // not the preferred way but an option
763
-			}else{
764
-				foreach($args['options'] as $val => $name){
763
+			} else {
764
+				foreach ($args['options'] as $val => $name) {
765 765
 					$selected = '';
766
-					if(is_array($name)){
766
+					if (is_array($name)) {
767 767
 						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
768 768
 							$option_label = isset($name['label']) ? $name['label'] : '';
769 769
 
@@ -771,23 +771,23 @@  discard block
 block discarded – undo
771 771
 						} else {
772 772
 							$option_label = isset($name['label']) ? $name['label'] : '';
773 773
 							$option_value = isset($name['value']) ? $name['value'] : '';
774
-							if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){
774
+							if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) {
775 775
 								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
776
-							} elseif(!empty($args['value'])) {
777
-								$selected = selected($option_value,stripslashes_deep($args['value']), false);
776
+							} elseif (!empty($args['value'])) {
777
+								$selected = selected($option_value, stripslashes_deep($args['value']), false);
778 778
 							}
779 779
 
780 780
 							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
781 781
 						}
782
-					}else{
783
-						if(!empty($args['value'])){
784
-							if(is_array($args['value'])){
785
-								$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
786
-							} elseif(!empty($args['value'])) {
787
-								$selected = selected( $args['value'], $val, false);
782
+					} else {
783
+						if (!empty($args['value'])) {
784
+							if (is_array($args['value'])) {
785
+								$selected = in_array($val, $args['value']) ? 'selected="selected"' : '';
786
+							} elseif (!empty($args['value'])) {
787
+								$selected = selected($args['value'], $val, false);
788 788
 							}
789 789
 						}
790
-						$output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
790
+						$output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>';
791 791
 					}
792 792
 				}
793 793
 			}
@@ -797,31 +797,31 @@  discard block
 block discarded – undo
797 797
 		// closing tag
798 798
 		$output .= '</select>';
799 799
 
800
-		if(!empty($args['label']) && $label_after){
800
+		if (!empty($args['label']) && $label_after) {
801 801
 			$label_args = array(
802 802
 				'title'=> $args['label'],
803 803
 				'for'=> $args['id'],
804
-				'class' => $args['label_class']." ",
804
+				'class' => $args['label_class'] . " ",
805 805
 				'label_type' => $args['label_type']
806 806
 			);
807 807
 			$output .= self::label($label_args);
808 808
 		}
809 809
 
810 810
 		// help text
811
-		if(!empty($args['help_text'])){
811
+		if (!empty($args['help_text'])) {
812 812
 			$output .= AUI_Component_Helper::help_text($args['help_text']);
813 813
 		}
814 814
 
815 815
 		// maybe horizontal label
816
-		if($args['label_type']=='horizontal'){
816
+		if ($args['label_type'] == 'horizontal') {
817 817
 			$output .= '</div>';
818 818
 		}
819 819
 
820 820
 
821 821
 		// wrap
822
-		if(!$args['no_wrap']){
823
-			$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
824
-			$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
822
+		if (!$args['no_wrap']) {
823
+			$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
824
+			$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
825 825
 			$output = self::wrap(array(
826 826
 				'content' => $output,
827 827
 				'class'   => $wrap_class,
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 	 *
842 842
 	 * @return string The rendered component.
843 843
 	 */
844
-	public static function radio($args = array()){
844
+	public static function radio($args = array()) {
845 845
 		$defaults = array(
846 846
 			'class'      => '',
847 847
 			'wrap_class' => '',
@@ -864,14 +864,14 @@  discard block
 block discarded – undo
864 864
 		/**
865 865
 		 * Parse incoming $args into an array and merge it with $defaults
866 866
 		 */
867
-		$args   = wp_parse_args( $args, $defaults );
867
+		$args = wp_parse_args($args, $defaults);
868 868
 
869 869
 		// for now lets use horizontal for floating
870
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';}
870
+		if ($args['label_type'] == 'floating') {$args['label_type'] = 'horizontal'; }
871 871
 
872 872
 		$label_args = array(
873 873
 			'title'=> $args['label'],
874
-			'class' => $args['label_class']." pt-0 ",
874
+			'class' => $args['label_class'] . " pt-0 ",
875 875
 			'label_type' => $args['label_type']
876 876
 		);
877 877
 
@@ -880,36 +880,36 @@  discard block
 block discarded – undo
880 880
 
881 881
 
882 882
 		// label before
883
-		if(!empty($args['label'])){
884
-			$output .= self::label( $label_args, 'radio' );
883
+		if (!empty($args['label'])) {
884
+			$output .= self::label($label_args, 'radio');
885 885
 		}
886 886
 
887 887
 		// maybe horizontal label
888
-		if($args['label_type']=='horizontal'){
888
+		if ($args['label_type'] == 'horizontal') {
889 889
 			$output .= '<div class="col-sm-10">';
890 890
 		}
891 891
 
892
-		if(!empty($args['options'])){
892
+		if (!empty($args['options'])) {
893 893
 			$count = 0;
894
-			foreach($args['options'] as $value => $label){
894
+			foreach ($args['options'] as $value => $label) {
895 895
 				$option_args = $args;
896 896
 				$option_args['value'] = $value;
897 897
 				$option_args['label'] = $label;
898 898
 				$option_args['checked'] = $value == $args['value'] ? true : false;
899
-				$output .= self::radio_option($option_args,$count);
899
+				$output .= self::radio_option($option_args, $count);
900 900
 				$count++;
901 901
 			}
902 902
 		}
903 903
 
904 904
 		// maybe horizontal label
905
-		if($args['label_type']=='horizontal'){
905
+		if ($args['label_type'] == 'horizontal') {
906 906
 			$output .= '</div>';
907 907
 		}
908 908
 
909 909
 
910 910
 		// wrap
911
-		$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
912
-		$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
911
+		$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
912
+		$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
913 913
 		$output = self::wrap(array(
914 914
 			'content' => $output,
915 915
 			'class'   => $wrap_class,
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	 *
929 929
 	 * @return string The rendered component.
930 930
 	 */
931
-	public static function radio_option($args = array(),$count = ''){
931
+	public static function radio_option($args = array(), $count = '') {
932 932
 		$defaults = array(
933 933
 			'class'      => '',
934 934
 			'id'         => '',
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 		/**
947 947
 		 * Parse incoming $args into an array and merge it with $defaults
948 948
 		 */
949
-		$args   = wp_parse_args( $args, $defaults );
949
+		$args   = wp_parse_args($args, $defaults);
950 950
 
951 951
 		$output = '';
952 952
 
@@ -957,27 +957,27 @@  discard block
 block discarded – undo
957 957
 		$output .= ' class="form-check-input" ';
958 958
 
959 959
 		// name
960
-		if(!empty($args['name'])){
960
+		if (!empty($args['name'])) {
961 961
 			$output .= AUI_Component_Helper::name($args['name']);
962 962
 		}
963 963
 
964 964
 		// id
965
-		if(!empty($args['id'])){
966
-			$output .= AUI_Component_Helper::id($args['id'].$count);
965
+		if (!empty($args['id'])) {
966
+			$output .= AUI_Component_Helper::id($args['id'] . $count);
967 967
 		}
968 968
 
969 969
 		// title
970
-		if(!empty($args['title'])){
970
+		if (!empty($args['title'])) {
971 971
 			$output .= AUI_Component_Helper::title($args['title']);
972 972
 		}
973 973
 
974 974
 		// value
975
-		if(isset($args['value'])){
976
-			$output .= ' value="'.sanitize_text_field($args['value']).'" ';
975
+		if (isset($args['value'])) {
976
+			$output .= ' value="' . sanitize_text_field($args['value']) . '" ';
977 977
 		}
978 978
 
979 979
 		// checked, for radio and checkboxes
980
-		if( $args['checked'] ){
980
+		if ($args['checked']) {
981 981
 			$output .= ' checked ';
982 982
 		}
983 983
 
@@ -988,12 +988,12 @@  discard block
 block discarded – undo
988 988
 		$output .= AUI_Component_Helper::aria_attributes($args);
989 989
 
990 990
 		// extra attributes
991
-		if(!empty($args['extra_attributes'])){
991
+		if (!empty($args['extra_attributes'])) {
992 992
 			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
993 993
 		}
994 994
 
995 995
 		// required
996
-		if(!empty($args['required'])){
996
+		if (!empty($args['required'])) {
997 997
 			$output .= ' required ';
998 998
 		}
999 999
 
@@ -1001,13 +1001,13 @@  discard block
 block discarded – undo
1001 1001
 		$output .= ' >';
1002 1002
 
1003 1003
 		// label
1004
-		if(!empty($args['label']) && is_array($args['label'])){
1005
-		}elseif(!empty($args['label'])){
1006
-			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
1004
+		if (!empty($args['label']) && is_array($args['label'])) {
1005
+		}elseif (!empty($args['label'])) {
1006
+			$output .= self::label(array('title'=>$args['label'], 'for'=>$args['id'] . $count, 'class'=>'form-check-label'), 'radio');
1007 1007
 		}
1008 1008
 
1009 1009
 		// wrap
1010
-		if(!$args['no_wrap']){
1010
+		if (!$args['no_wrap']) {
1011 1011
 			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1012 1012
 			$output = self::wrap(array(
1013 1013
 				'content' => $output,
Please login to merge, or discard this patch.
Braces   +15 added lines, -16 removed lines patch added patch discarded remove patch
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 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 ';
@@ -167,8 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
 			// label
169 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';}
170
+				if($type == 'file'){$label_args['class'] .= 'custom-file-label';} elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
172 171
 				$label = self::label( $label_args, $type );
173 172
 			}
174 173
 
@@ -189,7 +188,7 @@  discard block
 block discarded – undo
189 188
 					'content' => $output,
190 189
 					'class'   => 'form-group custom-file'
191 190
 				) );
192
-			}elseif($type == 'checkbox'){
191
+			} elseif($type == 'checkbox'){
193 192
 				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
194 193
 				$output = self::wrap( array(
195 194
 					'content' => $output,
@@ -199,7 +198,7 @@  discard block
 block discarded – undo
199 198
 				if($args['label_type']=='horizontal'){
200 199
 					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
201 200
 				}
202
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
201
+			} elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
203 202
 
204 203
 
205 204
 				// allow password field to toggle view
@@ -325,7 +324,7 @@  discard block
 block discarded – undo
325 324
 
326 325
 		// label
327 326
 		if(!empty($args['label']) && is_array($args['label'])){
328
-		}elseif(!empty($args['label']) && !$label_after){
327
+		} elseif(!empty($args['label']) && !$label_after){
329 328
 			$label_args = array(
330 329
 				'title'=> $args['label'],
331 330
 				'for'=> $args['id'],
@@ -360,7 +359,7 @@  discard block
 block discarded – undo
360 359
 
361 360
 			wp_editor( $content, $editor_id, $settings );
362 361
 			$output .= ob_get_clean();
363
-		}else{
362
+		} else{
364 363
 
365 364
 			// open
366 365
 			$output .= '<textarea ';
@@ -483,7 +482,7 @@  discard block
 block discarded – undo
483 482
 			// maybe hide labels //@todo set a global option for visibility class
484 483
 			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
485 484
 				$class = $args['class'];
486
-			}else{
485
+			} else{
487 486
 				$class = 'sr-only '.$args['class'];
488 487
 			}
489 488
 
@@ -594,7 +593,7 @@  discard block
 block discarded – undo
594 593
 			$output .= '</'.sanitize_html_class($args['type']).'>';
595 594
 
596 595
 
597
-		}else{
596
+		} else{
598 597
 			$output = $args['content'];
599 598
 		}
600 599
 
@@ -657,7 +656,7 @@  discard block
 block discarded – undo
657 656
 		if(!empty($args['select2'])){
658 657
 			$args['class'] .= ' aui-select2';
659 658
 			$is_select2 = true;
660
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
659
+		} elseif( strpos($args['class'], 'aui-select2') !== false){
661 660
 			$is_select2 = true;
662 661
 		}
663 662
 
@@ -676,7 +675,7 @@  discard block
 block discarded – undo
676 675
 
677 676
 		// label
678 677
 		if(!empty($args['label']) && is_array($args['label'])){
679
-		}elseif(!empty($args['label']) && !$label_after){
678
+		} elseif(!empty($args['label']) && !$label_after){
680 679
 			$label_args = array(
681 680
 				'title'=> $args['label'],
682 681
 				'for'=> $args['id'],
@@ -751,7 +750,7 @@  discard block
 block discarded – undo
751 750
 		// placeholder
752 751
 		if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){
753 752
 			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
754
-		}elseif($is_select2 && !empty($args['placeholder'])){
753
+		} elseif($is_select2 && !empty($args['placeholder'])){
755 754
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
756 755
 		}
757 756
 
@@ -760,7 +759,7 @@  discard block
 block discarded – undo
760 759
 
761 760
 			if(!is_array($args['options'])){
762 761
 				$output .= $args['options']; // not the preferred way but an option
763
-			}else{
762
+			} else{
764 763
 				foreach($args['options'] as $val => $name){
765 764
 					$selected = '';
766 765
 					if(is_array($name)){
@@ -779,7 +778,7 @@  discard block
 block discarded – undo
779 778
 
780 779
 							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
781 780
 						}
782
-					}else{
781
+					} else{
783 782
 						if(!empty($args['value'])){
784 783
 							if(is_array($args['value'])){
785 784
 								$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
@@ -1002,7 +1001,7 @@  discard block
 block discarded – undo
1002 1001
 
1003 1002
 		// label
1004 1003
 		if(!empty($args['label']) && is_array($args['label'])){
1005
-		}elseif(!empty($args['label'])){
1004
+		} elseif(!empty($args['label'])){
1006 1005
 			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
1007 1006
 		}
1008 1007
 
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
  * Bail if we are not in WP.
8 8
  */
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit;
10
+    exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16 16
 add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
18
-	$this_version = "0.1.35";
19
-	if(version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
22
-	}
17
+    global $ayecode_ui_version,$ayecode_ui_file_key;
18
+    $this_version = "0.1.35";
19
+    if(version_compare($this_version , $ayecode_ui_version, '>')){
20
+        $ayecode_ui_version = $this_version ;
21
+        $ayecode_ui_file_key = wp_hash( __FILE__ );
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 28
 add_action('after_setup_theme', function () {
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' );
33
-	}
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' );
33
+    }
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39 39
 if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
42
-			return false;
43
-		}
44
-		return AUI::instance();
45
-	}
40
+    function aui(){
41
+        if(!class_exists("AUI",false)){
42
+            return false;
43
+        }
44
+        return AUI::instance();
45
+    }
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,39 +6,39 @@
 block discarded – undo
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.35";
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();
Please login to merge, or discard this patch.
templates/payment-forms-admin/edit/address.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
@@ -31,44 +31,44 @@  discard block
 block discarded – undo
31 31
 
32 32
                 <div class='form-group'>
33 33
                     <label class="d-block">
34
-                        <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span>
34
+                        <span><?php esc_html_e('Field Label', 'invoicing'); ?></span>
35 35
                         <input v-model='field.label' class='form-control' type="text"/>
36 36
                     </label>
37 37
                 </div>
38 38
 
39 39
                 <div class='form-group'>
40 40
                     <label class="d-block">
41
-                        <span><?php esc_html_e( 'Placeholder text', 'invoicing' ); ?></span>
41
+                        <span><?php esc_html_e('Placeholder text', 'invoicing'); ?></span>
42 42
                         <input v-model='field.placeholder' class='form-control' type="text"/>
43 43
                     </label>
44 44
                 </div>
45 45
 
46 46
                 <div class='form-group'>
47 47
                     <label class="d-block">
48
-                        <span><?php esc_html_e( 'Width', 'invoicing' ) ?></span>
48
+                        <span><?php esc_html_e('Width', 'invoicing') ?></span>
49 49
                         <select class='form-control custom-select' v-model='field.grid_width'>
50
-                            <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option>
51
-                            <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option>
52
-                            <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option>
50
+                            <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option>
51
+                            <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option>
52
+                            <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option>
53 53
                         </select>
54 54
                     </label>
55 55
                 </div>
56 56
 
57 57
                 <div class='form-group'>
58 58
                     <label class="d-block">
59
-                        <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span>
60
-                        <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='field.description' class='form-control' rows='3'></textarea>
59
+                        <span><?php esc_html_e('Help Text', 'invoicing'); ?></span>
60
+                        <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='field.description' class='form-control' rows='3'></textarea>
61 61
                     </label>
62 62
                 </div>
63 63
 
64 64
                 <div class='form-group form-check'>
65 65
                     <input :id="active_form_element.id + '_edit_required' + index" v-model='field.required' type='checkbox' class='form-check-input' />
66
-                    <label class='form-check-label' :for="active_form_element.id + '_edit_required' + index"><?php esc_html_e( 'Is required', 'invoicing' ); ?></label>
66
+                    <label class='form-check-label' :for="active_form_element.id + '_edit_required' + index"><?php esc_html_e('Is required', 'invoicing'); ?></label>
67 67
                 </div>
68 68
 
69 69
                 <div class='form-group form-check'>
70 70
                     <input :id="active_form_element.id + '_edit_visible' + index" v-model='field.visible' type='checkbox' class='form-check-input' />
71
-                    <label class='form-check-label' :for="active_form_element.id + '_edit_visible' + index"><?php esc_html_e( 'Is visible', 'invoicing' ); ?></label>
71
+                    <label class='form-check-label' :for="active_form_element.id + '_edit_visible' + index"><?php esc_html_e('Is visible', 'invoicing'); ?></label>
72 72
                 </div>
73 73
 
74 74
             </div>
Please login to merge, or discard this patch.
templates/payment-forms/form.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -7,44 +7,44 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Make sure that the form is active.
13
-if ( ! $form->is_active() ) {
13
+if (!$form->is_active()) {
14 14
     echo aui()->alert(
15 15
         array(
16 16
             'type'    => 'warning',
17
-            'content' => __( 'This payment form is no longer active', 'invoicing' ),
17
+            'content' => __('This payment form is no longer active', 'invoicing'),
18 18
         )
19 19
     );
20 20
     return;
21 21
 }
22 22
 
23 23
 // Fires before displaying a payment form.
24
-do_action( 'getpaid_before_payment_form', $form );
24
+do_action('getpaid_before_payment_form', $form);
25 25
 ?>
26 26
 
27
-<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint( $form->get_id() ); ?> bsui' method='POST' data-key='<?php echo uniqid('gpf'); ?>'>
27
+<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint($form->get_id()); ?> bsui' method='POST' data-key='<?php echo uniqid('gpf'); ?>'>
28 28
 
29 29
 
30 30
     <?php 
31 31
     
32 32
         // Fires when printing the top of a payment form.
33
-        do_action( 'getpaid_payment_form_top', $form );
33
+        do_action('getpaid_payment_form_top', $form);
34 34
 
35 35
         // And the optional invoice id.
36
-        if ( ! empty( $form->invoice ) ) {
37
-            echo getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() );
36
+        if (!empty($form->invoice)) {
37
+            echo getpaid_hidden_field('invoice_id', $form->invoice->get_id());
38 38
         }
39 39
 
40 40
         // We also want to include the form id.
41
-        echo getpaid_hidden_field( 'form_id', $form->get_id() );
41
+        echo getpaid_hidden_field('form_id', $form->get_id());
42 42
 
43 43
         // And an indication that this is a payment form submission.
44
-        echo getpaid_hidden_field( 'getpaid_payment_form_submission', '1' );
44
+        echo getpaid_hidden_field('getpaid_payment_form_submission', '1');
45 45
 
46 46
         // Fires before displaying payment form elements.
47
-        do_action( 'getpaid_payment_form_before_elements', $form );
47
+        do_action('getpaid_payment_form_before_elements', $form);
48 48
 
49 49
         // Display the elements.
50 50
         ?>
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
             <div class="row">
53 53
                 <?php
54 54
 
55
-                    foreach ( $form->get_elements() as $element ) {
55
+                    foreach ($form->get_elements() as $element) {
56 56
 
57
-                        if ( isset( $element['type'] ) ) {
58
-                            $grid_class = esc_attr( getpaid_get_form_element_grid_class( $element ) );
57
+                        if (isset($element['type'])) {
58
+                            $grid_class = esc_attr(getpaid_get_form_element_grid_class($element));
59 59
                             echo "<div class='$grid_class'>";
60
-                            do_action( 'getpaid_payment_form_element', $element, $form );
61
-                            do_action( "getpaid_payment_form_element_{$element['type']}_template", $element, $form );
60
+                            do_action('getpaid_payment_form_element', $element, $form);
61
+                            do_action("getpaid_payment_form_element_{$element['type']}_template", $element, $form);
62 62
                             echo "</div>";
63 63
                         }
64 64
 
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
 
71 71
         <?php
72 72
         // Fires after displaying payment form elements.
73
-        do_action( 'getpaid_payment_form_after_elements', $form );
73
+        do_action('getpaid_payment_form_after_elements', $form);
74 74
 
75 75
         echo "<div class='getpaid-payment-form-errors alert alert-danger d-none'></div>";
76 76
 
77
-        if ( wpinv_current_user_can_manage_invoicing() ) {
77
+        if (wpinv_current_user_can_manage_invoicing()) {
78 78
 
79 79
             edit_post_link(
80
-                __( 'Edit this form.', 'invoicing' ),
80
+                __('Edit this form.', 'invoicing'),
81 81
                 '<small class="form-text text-muted">',
82
-                '&nbsp;' . __( 'This is only visible to website administators.', 'invoicing' ) . '</small>',
82
+                '&nbsp;' . __('This is only visible to website administators.', 'invoicing') . '</small>',
83 83
                 $form->get_id(),
84 84
                 'text-danger'
85 85
             );
@@ -94,4 +94,4 @@  discard block
 block discarded – undo
94 94
 <?php
95 95
 
96 96
 // Fires after displaying a payment form.
97
-do_action( 'getpaid_after_payment_form', $form );
97
+do_action('getpaid_after_payment_form', $form);
Please login to merge, or discard this patch.
templates/payment-forms/elements/address.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -7,50 +7,50 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-if ( empty( $fields ) ) {
12
+if (empty($fields)) {
13 13
     return;
14 14
 }
15 15
 
16 16
 // Prepare the user's country.
17
-$country = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_country', true ) : '';
18
-$country = empty( $country ) ? wpinv_get_default_country() : $country;
17
+$country = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_country', true) : '';
18
+$country = empty($country) ? wpinv_get_default_country() : $country;
19 19
 
20 20
 // A prefix for all ids (so that a form can be included in the same page multiple times).
21
-$uniqid = uniqid( '_' );
21
+$uniqid = uniqid('_');
22 22
 
23 23
 echo "<div class='row'>";
24
-foreach ( $fields as $address_field ) {
24
+foreach ($fields as $address_field) {
25 25
 
26 26
     // Skip if it is hidden.
27
-    if ( empty( $address_field['visible'] ) ) {
27
+    if (empty($address_field['visible'])) {
28 28
         continue;
29 29
     }
30 30
 
31
-    $wrap_class  = getpaid_get_form_element_grid_class( $address_field );
32
-    $wrap_class  = esc_attr( "$wrap_class getpaid-address-field-wrapper" );
33
-    $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
34
-    $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
35
-    $value       = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_' . $address_field['name'], true ) : '';
36
-    $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
31
+    $wrap_class  = getpaid_get_form_element_grid_class($address_field);
32
+    $wrap_class  = esc_attr("$wrap_class getpaid-address-field-wrapper");
33
+    $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
34
+    $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
35
+    $value       = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_' . $address_field['name'], true) : '';
36
+    $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
37 37
 
38
-    if ( ! empty( $address_field['required'] ) ) {
38
+    if (!empty($address_field['required'])) {
39 39
         $label .= "<span class='text-danger'> *</span>";
40 40
     }
41 41
 
42 42
     // Display the country.
43
-    if ( 'wpinv_country' == $address_field['name'] ) {
43
+    if ('wpinv_country' == $address_field['name']) {
44 44
 
45 45
         echo aui()->select(
46 46
             array(
47 47
                 'options'     => wpinv_get_country_list(),
48 48
                 'name'        => 'wpinv_country',
49 49
                 'id'          => 'wpinv_country' . $uniqid,
50
-                'value'       => sanitize_text_field( $country ),
50
+                'value'       => sanitize_text_field($country),
51 51
                 'placeholder' => $placeholder,
52
-                'required'    => ! empty( $address_field['required'] ),
53
-                'label'       => wp_kses_post( $label ),
52
+                'required'    => !empty($address_field['required']),
53
+                'label'       => wp_kses_post($label),
54 54
                 'label_type'  => 'vertical',
55 55
                 'help_text'   => $description,
56 56
                 'class'       => 'getpaid-address-field wpinv_country',
@@ -63,39 +63,39 @@  discard block
 block discarded – undo
63 63
     }
64 64
 
65 65
     // Display the state.
66
-    if ( 'wpinv_state' == $address_field['name'] ) {
66
+    if ('wpinv_state' == $address_field['name']) {
67 67
 
68
-        if ( empty( $value ) ) {
68
+        if (empty($value)) {
69 69
             $value = wpinv_get_default_state();
70 70
         }
71 71
 
72
-        echo getpaid_get_states_select_markup (
72
+        echo getpaid_get_states_select_markup(
73 73
             $country,
74 74
             $value,
75 75
             $placeholder,
76 76
             $label,
77 77
             $description,
78
-            ! empty( $address_field['required'] ),
78
+            !empty($address_field['required']),
79 79
             $wrap_class
80 80
         );
81 81
 
82 82
         continue;
83 83
     }
84 84
 
85
-    $key = str_replace( 'wpinv_', '', $address_field['name'] );
86
-    $key = esc_attr( str_replace( '_', '-', $key ) );
85
+    $key = str_replace('wpinv_', '', $address_field['name']);
86
+    $key = esc_attr(str_replace('_', '-', $key));
87 87
     echo aui()->input(
88 88
         array(
89
-            'name'        => esc_attr( $address_field['name'] ),
90
-            'id'          => esc_attr( $address_field['name'] ) . $uniqid,
91
-            'required'    => ! empty( $address_field['required'] ),
89
+            'name'        => esc_attr($address_field['name']),
90
+            'id'          => esc_attr($address_field['name']) . $uniqid,
91
+            'required'    => !empty($address_field['required']),
92 92
             'placeholder' => $placeholder,
93
-            'label'       => wp_kses_post( $label ),
93
+            'label'       => wp_kses_post($label),
94 94
             'label_type'  => 'vertical',
95 95
             'help_text'   => $description,
96 96
             'type'        => 'text',
97 97
             'value'       => $value,
98
-            'class'       => 'getpaid-address-field ' . esc_attr( $address_field['name'] ),
98
+            'class'       => 'getpaid-address-field ' . esc_attr($address_field['name']),
99 99
             'wrap_class'  => "$wrap_class getpaid-address-field-wrapper__$key",
100 100
             'label_class' => 'getpaid-address-field-label getpaid-address-field-label__' . $key,
101 101
         )
Please login to merge, or discard this patch.
includes/data/payment-form-elements.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -9,41 +9,41 @@  discard block
 block discarded – undo
9 9
  * @version 1.0.19
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 return array(
15 15
 
16 16
     array(
17 17
         'type'     => 'heading',
18
-        'name'     => __( 'Heading', 'invoicing' ),
18
+        'name'     => __('Heading', 'invoicing'),
19 19
         'defaults' => array(
20 20
             'level' => 'h2',
21
-            'text'  => __( 'Heading', 'invoicing' ),
21
+            'text'  => __('Heading', 'invoicing'),
22 22
         )
23 23
     ),
24 24
 
25 25
     array(
26 26
         'type' => 'paragraph',
27
-        'name' => __( 'Paragraph', 'invoicing' ),
27
+        'name' => __('Paragraph', 'invoicing'),
28 28
         'defaults'  => array(
29
-            'text'  => __( 'Paragraph text', 'invoicing' ),
29
+            'text'  => __('Paragraph text', 'invoicing'),
30 30
         )
31 31
     ),
32 32
 
33 33
     array( 
34 34
         'type' => 'alert',
35
-        'name' => __( 'Alert', 'invoicing' ),
35
+        'name' => __('Alert', 'invoicing'),
36 36
         'defaults'  => array(
37 37
             'value'        => '',
38 38
             'class'        => 'alert-warning',
39
-            'text'         => __( 'Alert', 'invoicing' ),
39
+            'text'         => __('Alert', 'invoicing'),
40 40
             'dismissible'  => false,
41 41
         )
42 42
     ),
43 43
 
44 44
     array( 
45 45
         'type' => 'separator',
46
-        'name' => __( 'Separator', 'invoicing' ),
46
+        'name' => __('Separator', 'invoicing'),
47 47
         'defaults'  => array(
48 48
             'value'        => '',
49 49
         ),
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 
52 52
     array(
53 53
         'type' => 'text',
54
-        'name' => __( 'Text Input', 'invoicing' ),
54
+        'name' => __('Text Input', 'invoicing'),
55 55
         'defaults'  => array(
56
-            'placeholder'  => __( 'Enter some text', 'invoicing' ),
56
+            'placeholder'  => __('Enter some text', 'invoicing'),
57 57
             'value'        => '',
58
-            'label'        => __( 'Field Label', 'invoicing' ),
58
+            'label'        => __('Field Label', 'invoicing'),
59 59
             'description'  => '',
60 60
             'required'     => false,
61 61
         )
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 
64 64
     array(
65 65
         'type' => 'textarea',
66
-        'name' => __( 'Textarea', 'invoicing' ),
66
+        'name' => __('Textarea', 'invoicing'),
67 67
         'defaults'         => array(
68
-            'placeholder'  => __( 'Enter your text hear', 'invoicing' ),
68
+            'placeholder'  => __('Enter your text hear', 'invoicing'),
69 69
             'value'        => '',
70
-            'label'        => __( 'Textarea Label', 'invoicing' ),
70
+            'label'        => __('Textarea Label', 'invoicing'),
71 71
             'description'  => '',
72 72
             'required'     => false,
73 73
         )
@@ -75,27 +75,27 @@  discard block
 block discarded – undo
75 75
 
76 76
     array(
77 77
         'type' => 'select',
78
-        'name' => __( 'Dropdown', 'invoicing' ),
78
+        'name' => __('Dropdown', 'invoicing'),
79 79
         'defaults'         => array(
80
-            'placeholder'  => __( 'Select a value', 'invoicing' ),
80
+            'placeholder'  => __('Select a value', 'invoicing'),
81 81
             'value'        => '',
82
-            'label'        => __( 'Dropdown Label', 'invoicing' ),
82
+            'label'        => __('Dropdown Label', 'invoicing'),
83 83
             'description'  => '',
84 84
             'required'     => false,
85 85
             'options'      => array(
86
-                esc_attr__( 'Option One', 'invoicing' ),
87
-                esc_attr__( 'Option Two', 'invoicing' ),
88
-                esc_attr__( 'Option Three', 'invoicing' )
86
+                esc_attr__('Option One', 'invoicing'),
87
+                esc_attr__('Option Two', 'invoicing'),
88
+                esc_attr__('Option Three', 'invoicing')
89 89
             ),
90 90
         )
91 91
     ),
92 92
 
93 93
     array(
94 94
         'type' => 'checkbox',
95
-        'name' => __( 'Checkbox', 'invoicing' ),
95
+        'name' => __('Checkbox', 'invoicing'),
96 96
         'defaults'         => array(
97 97
             'value'        => '',
98
-            'label'        => __( 'Checkbox Label', 'invoicing' ),
98
+            'label'        => __('Checkbox Label', 'invoicing'),
99 99
             'description'  => '',
100 100
             'required'     => false,
101 101
         )
@@ -103,23 +103,23 @@  discard block
 block discarded – undo
103 103
 
104 104
     array( 
105 105
         'type' => 'radio',
106
-        'name' => __( 'Radio', 'invoicing' ),
106
+        'name' => __('Radio', 'invoicing'),
107 107
         'defaults'     => array(
108
-            'label'    => __( 'Select one choice', 'invoicing' ),
108
+            'label'    => __('Select one choice', 'invoicing'),
109 109
             'options'  => array(
110
-                esc_attr__( 'Choice One', 'invoicing' ),
111
-                esc_attr__( 'Choice Two', 'invoicing' ),
112
-                esc_attr__( 'Choice Three', 'invoicing' )
110
+                esc_attr__('Choice One', 'invoicing'),
111
+                esc_attr__('Choice Two', 'invoicing'),
112
+                esc_attr__('Choice Three', 'invoicing')
113 113
             ),
114 114
         )
115 115
     ),
116 116
 
117 117
     array( 
118 118
         'type' => 'date',
119
-        'name' => __( 'Date', 'invoicing' ),
119
+        'name' => __('Date', 'invoicing'),
120 120
         'defaults' => array(
121 121
             'value'        => '',
122
-            'label'        => __( 'Date', 'invoicing' ),
122
+            'label'        => __('Date', 'invoicing'),
123 123
             'description'  => '',
124 124
             'required'     => false,
125 125
         )
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 
128 128
     array( 
129 129
         'type' => 'time',
130
-        'name' => __( 'Time', 'invoicing' ),
130
+        'name' => __('Time', 'invoicing'),
131 131
         'defaults' => array(
132 132
             'value'        => '',
133
-            'label'        => __( 'Time', 'invoicing' ),
133
+            'label'        => __('Time', 'invoicing'),
134 134
             'description'  => '',
135 135
             'required'     => false,
136 136
         )
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 
139 139
     array( 
140 140
         'type' => 'number',
141
-        'name' => __( 'Number', 'invoicing' ),
141
+        'name' => __('Number', 'invoicing'),
142 142
         'defaults' => array(
143 143
             'placeholder'  => '',
144 144
             'value'        => '',
145
-            'label'        => __( 'Number', 'invoicing' ),
145
+            'label'        => __('Number', 'invoicing'),
146 146
             'description'  => '',
147 147
             'required'     => false,
148 148
         )
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 
151 151
     array( 
152 152
         'type' => 'website',
153
-        'name' => __( 'Website', 'invoicing' ),
153
+        'name' => __('Website', 'invoicing'),
154 154
         'defaults' => array(
155 155
             'placeholder'  => 'http://example.com',
156 156
             'value'        => '',
157
-            'label'        => __( 'Website', 'invoicing' ),
157
+            'label'        => __('Website', 'invoicing'),
158 158
             'description'  => '',
159 159
             'required'     => false,
160 160
         )
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
 
163 163
     array( 
164 164
         'type' => 'email',
165
-        'name' => __( 'Email', 'invoicing' ),
165
+        'name' => __('Email', 'invoicing'),
166 166
         'defaults'  => array(
167 167
             'placeholder'  => '[email protected]',
168 168
             'value'        => '',
169
-            'label'        => __( 'Email Address', 'invoicing' ),
169
+            'label'        => __('Email Address', 'invoicing'),
170 170
             'description'  => '',
171 171
             'required'     => false,
172 172
         )
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 
175 175
     array( 
176 176
         'type' => 'address',
177
-        'name' => __( 'Address', 'invoicing' ),
177
+        'name' => __('Address', 'invoicing'),
178 178
         'defaults'  => array(
179 179
 
180 180
             'fields' => array(
181 181
                 array(
182 182
                     'placeholder'  => 'Jon',
183 183
                     'value'        => '',
184
-                    'label'        => __( 'First Name', 'invoicing' ),
184
+                    'label'        => __('First Name', 'invoicing'),
185 185
                     'description'  => '',
186 186
                     'required'     => false,
187 187
                     'visible'      => true,
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
                 array(
192 192
                     'placeholder'  => 'Snow',
193 193
                     'value'        => '',
194
-                    'label'        => __( 'Last Name', 'invoicing' ),
194
+                    'label'        => __('Last Name', 'invoicing'),
195 195
                     'description'  => '',
196 196
                     'required'     => false,
197 197
                     'visible'      => true,
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
                 array(
202 202
                     'placeholder'  => '',
203 203
                     'value'        => '',
204
-                    'label'        => __( 'Address', 'invoicing' ),
204
+                    'label'        => __('Address', 'invoicing'),
205 205
                     'description'  => '',
206 206
                     'required'     => false,
207 207
                     'visible'      => true,
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                 array(
212 212
                     'placeholder'  => '',
213 213
                     'value'        => '',
214
-                    'label'        => __( 'City', 'invoicing' ),
214
+                    'label'        => __('City', 'invoicing'),
215 215
                     'description'  => '',
216 216
                     'required'     => false,
217 217
                     'visible'      => true,
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
                 ),
220 220
 
221 221
                 array(
222
-                    'placeholder'  => __( 'Select your country' ),
222
+                    'placeholder'  => __('Select your country'),
223 223
                     'value'        => '',
224
-                    'label'        => __( 'Country', 'invoicing' ),
224
+                    'label'        => __('Country', 'invoicing'),
225 225
                     'description'  => '',
226 226
                     'required'     => false,
227 227
                     'visible'      => true,
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
                 ),
230 230
 
231 231
                 array(
232
-                    'placeholder'  => __( 'Choose a state', 'invoicing' ),
232
+                    'placeholder'  => __('Choose a state', 'invoicing'),
233 233
                     'value'        => '',
234
-                    'label'        => __( 'State / Province', 'invoicing' ),
234
+                    'label'        => __('State / Province', 'invoicing'),
235 235
                     'description'  => '',
236 236
                     'required'     => false,
237 237
                     'visible'      => true,
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
                 array(
242 242
                     'placeholder'  => '',
243 243
                     'value'        => '',
244
-                    'label'        => __( 'ZIP / Postcode', 'invoicing' ),
244
+                    'label'        => __('ZIP / Postcode', 'invoicing'),
245 245
                     'description'  => '',
246 246
                     'required'     => false,
247 247
                     'visible'      => true,
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
                 array(
252 252
                     'placeholder'  => '',
253 253
                     'value'        => '',
254
-                    'label'        => __( 'Phone', 'invoicing' ),
254
+                    'label'        => __('Phone', 'invoicing'),
255 255
                     'description'  => '',
256 256
                     'required'     => false,
257 257
                     'visible'      => true,
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
                 array(
262 262
                     'placeholder'  => '',
263 263
                     'value'        => '',
264
-                    'label'        => __( 'Company', 'invoicing' ),
264
+                    'label'        => __('Company', 'invoicing'),
265 265
                     'description'  => '',
266 266
                     'required'     => false,
267 267
                     'visible'      => false,
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
                 array(
272 272
                     'placeholder'  => '',
273 273
                     'value'        => '',
274
-                    'label'        => __( 'VAT Number', 'invoicing' ),
274
+                    'label'        => __('VAT Number', 'invoicing'),
275 275
                     'description'  => '',
276 276
                     'required'     => false,
277 277
                     'visible'      => false,
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 
284 284
     array( 
285 285
         'type' => 'billing_email',
286
-        'name' => __( 'Billing Email', 'invoicing' ),
286
+        'name' => __('Billing Email', 'invoicing'),
287 287
         'defaults'  => array(
288 288
             'placeholder'  => '[email protected]',
289 289
             'value'        => '',
290
-            'label'        => __( 'Billing Email', 'invoicing' ),
290
+            'label'        => __('Billing Email', 'invoicing'),
291 291
             'description'  => '',
292 292
             'premade'      => true,
293 293
         )
@@ -295,18 +295,18 @@  discard block
 block discarded – undo
295 295
 
296 296
     array( 
297 297
         'type' => 'discount',
298
-        'name' => __( 'Discount Input', 'invoicing' ),
298
+        'name' => __('Discount Input', 'invoicing'),
299 299
         'defaults'  => array(
300 300
             'value'        => '',
301
-            'input_label'  => __( 'Coupon Code', 'invoicing' ),
302
-            'button_label' => __( 'Apply Coupon', 'invoicing' ),
303
-            'description'  => __( 'Have a discount code? Enter it above.', 'invoicing' ),
301
+            'input_label'  => __('Coupon Code', 'invoicing'),
302
+            'button_label' => __('Apply Coupon', 'invoicing'),
303
+            'description'  => __('Have a discount code? Enter it above.', 'invoicing'),
304 304
         )
305 305
     ),
306 306
 
307 307
     array( 
308 308
         'type' => 'items',
309
-        'name' => __( 'Items', 'invoicing' ),
309
+        'name' => __('Items', 'invoicing'),
310 310
         'defaults'  => array(
311 311
             'value'        => '',
312 312
             'items_type'   => 'total',
@@ -318,22 +318,22 @@  discard block
 block discarded – undo
318 318
 
319 319
     array( 
320 320
         'type' => 'price_input',
321
-        'name' => __( 'Price Input', 'invoicing' ),
321
+        'name' => __('Price Input', 'invoicing'),
322 322
         'defaults'  => array(
323 323
             'placeholder'  => wpinv_format_amount(0),
324 324
             'value'        => wpinv_format_amount(0),
325 325
             'minimum'      => wpinv_format_amount(0),
326
-            'label'        => __( 'Enter Amount', 'invoicing' ),
326
+            'label'        => __('Enter Amount', 'invoicing'),
327 327
             'description'  => '',
328 328
         )
329 329
     ),
330 330
 
331 331
     array( 
332 332
         'type' => 'price_select',
333
-        'name' => __( 'Price Select', 'invoicing' ),
333
+        'name' => __('Price Select', 'invoicing'),
334 334
         'defaults'  => array(
335 335
             'description'  => '',
336
-            'label'        => __( 'Select Amount', 'invoicing' ),
336
+            'label'        => __('Select Amount', 'invoicing'),
337 337
             'options'      => 'Option 1|10, Option 2|20',
338 338
             'placeholder'  => '',
339 339
             'select_type'  => 'select',
@@ -342,39 +342,39 @@  discard block
 block discarded – undo
342 342
 
343 343
     array( 
344 344
         'type'       => 'pay_button',
345
-        'name'       => __( 'Payment Button', 'invoicing' ),
345
+        'name'       => __('Payment Button', 'invoicing'),
346 346
         'defaults'   => array(
347 347
             'value'          => '',
348 348
             'class'          => 'btn-primary',
349
-            'label'          => __( 'Pay %price% »', 'invoicing' ),
350
-            'free'           => __( 'Continue »', 'invoicing' ),
351
-            'description'    => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ),
349
+            'label'          => __('Pay %price% »', 'invoicing'),
350
+            'free'           => __('Continue »', 'invoicing'),
351
+            'description'    => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'),
352 352
             'premade'        => true,
353 353
         )
354 354
     ),
355 355
 
356 356
     array(
357 357
         'type'       => 'gateway_select',
358
-        'name'       => __( 'Gateway Select', 'invoicing' ),
358
+        'name'       => __('Gateway Select', 'invoicing'),
359 359
         'defaults'   => array(
360
-            'text'    => __( 'Select Payment Method', 'invoicing' ),
360
+            'text'    => __('Select Payment Method', 'invoicing'),
361 361
             'premade' => true,
362 362
         )
363 363
     ),
364 364
 
365 365
     array( 
366 366
         'type'       => 'total_payable',
367
-        'name'       => __( 'Total Payable', 'invoicing' ),
367
+        'name'       => __('Total Payable', 'invoicing'),
368 368
         'defaults'   => array(
369
-            'text' => __( 'Total to pay:', 'invoicing' ),
369
+            'text' => __('Total to pay:', 'invoicing'),
370 370
         )
371 371
     ),
372 372
 
373 373
     array( 
374 374
         'type'       => 'ip_address',
375
-        'name'       => __( 'IP Address', 'invoicing' ),
375
+        'name'       => __('IP Address', 'invoicing'),
376 376
         'defaults'   => array(
377
-            'text' => __( 'Your IP address is:', 'invoicing' ),
377
+            'text' => __('Your IP address is:', 'invoicing'),
378 378
         )
379 379
     )
380 380
 );
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-refresh-prices.php 2 patches
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -12,217 +12,217 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Refresh_Prices {
14 14
 
15
-	/**
16
-	 * Contains the response for refreshing prices.
17
-	 * @var array
18
-	 */
19
-	public $response = array();
15
+    /**
16
+     * Contains the response for refreshing prices.
17
+     * @var array
18
+     */
19
+    public $response = array();
20 20
 
21 21
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 */
26
-	public function __construct( $submission ) {
27
-
28
-		$this->response = array(
29
-			'submission_id' => $submission->id,
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     */
26
+    public function __construct( $submission ) {
27
+
28
+        $this->response = array(
29
+            'submission_id' => $submission->id,
30 30
             'has_recurring' => $submission->has_recurring,
31 31
             'is_free'       => ! $submission->should_collect_payment_details(),
32
-		);
33
-
34
-		$this->add_totals( $submission );
35
-		$this->add_texts( $submission );
36
-		$this->add_items( $submission );
37
-		$this->add_fees( $submission );
38
-		$this->add_discounts( $submission );
39
-		$this->add_taxes( $submission );
40
-		$this->add_gateways( $submission );
41
-
42
-	}
43
-
44
-	/**
45
-	 * Adds totals to a response for submission refresh prices.
46
-	 *
47
-	 * @param GetPaid_Payment_Form_Submission $submission
48
-	 */
49
-	public function add_totals( $submission ) {
50
-
51
-		$this->response = array_merge(
52
-			$this->response,
53
-			array(
54
-
55
-				'totals'        => array(
56
-					'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
57
-					'discount'  => $submission->format_amount( $submission->get_discount() ),
58
-					'fees'      => $submission->format_amount( $submission->get_fee() ),
59
-					'tax'       => $submission->format_amount( $submission->get_tax() ),
60
-					'total'     => $submission->format_amount( $submission->get_total() ),
61
-					'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
62
-				),
63
-
64
-				'recurring'     => array(
65
-					'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
66
-					'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
67
-					'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
68
-					'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
69
-					'total'     => $submission->format_amount( $submission->get_recurring_total() ),
70
-				),
71
-
72
-			)
73
-		);
74
-
75
-	}
76
-
77
-	/**
78
-	 * Adds texts to a response for submission refresh prices.
79
-	 *
80
-	 * @param GetPaid_Payment_Form_Submission $submission
81
-	 */
82
-	public function add_texts( $submission ) {
83
-
84
-		$payable = $submission->format_amount( $submission->get_total() );
85
-
86
-		if ( $submission->has_recurring != 0 ) {
87
-
88
-			$recurring = new WPInv_Item( $submission->has_recurring );
89
-			$period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
90
-
91
-			if ( $submission->get_total() == $submission->get_recurring_total() ) {
92
-				$payable = "$payable / $period";
93
-			} else {
94
-				$payable = sprintf(
95
-					__( '%1$s (renews at %2$s / %3$s)'),
96
-					$submission->format_amount( $submission->get_total() ),
97
-					$submission->format_amount( $submission->get_recurring_total() ),
98
-					$period
99
-				);
100
-			}
101
-
102
-		}
103
-
104
-		$texts = array(
105
-			'.getpaid-checkout-total-payable' => $payable,
106
-		);
107
-
108
-		foreach ( $submission->get_items() as $item_id => $item ) {
109
-			$texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount( $item->get_sub_total() );
110
-			$texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() );
111
-		}
112
-
113
-		$this->response = array_merge( $this->response, array( 'texts' => $texts ) );
114
-
115
-	}
116
-
117
-	/**
118
-	 * Adds items to a response for submission refresh prices.
119
-	 *
120
-	 * @param GetPaid_Payment_Form_Submission $submission
121
-	 */
122
-	public function add_items( $submission ) {
123
-
124
-		// Add items.
125
-		$items = array();
32
+        );
33
+
34
+        $this->add_totals( $submission );
35
+        $this->add_texts( $submission );
36
+        $this->add_items( $submission );
37
+        $this->add_fees( $submission );
38
+        $this->add_discounts( $submission );
39
+        $this->add_taxes( $submission );
40
+        $this->add_gateways( $submission );
41
+
42
+    }
43
+
44
+    /**
45
+     * Adds totals to a response for submission refresh prices.
46
+     *
47
+     * @param GetPaid_Payment_Form_Submission $submission
48
+     */
49
+    public function add_totals( $submission ) {
50
+
51
+        $this->response = array_merge(
52
+            $this->response,
53
+            array(
54
+
55
+                'totals'        => array(
56
+                    'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
57
+                    'discount'  => $submission->format_amount( $submission->get_discount() ),
58
+                    'fees'      => $submission->format_amount( $submission->get_fee() ),
59
+                    'tax'       => $submission->format_amount( $submission->get_tax() ),
60
+                    'total'     => $submission->format_amount( $submission->get_total() ),
61
+                    'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
62
+                ),
63
+
64
+                'recurring'     => array(
65
+                    'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
66
+                    'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
67
+                    'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
68
+                    'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
69
+                    'total'     => $submission->format_amount( $submission->get_recurring_total() ),
70
+                ),
71
+
72
+            )
73
+        );
74
+
75
+    }
76
+
77
+    /**
78
+     * Adds texts to a response for submission refresh prices.
79
+     *
80
+     * @param GetPaid_Payment_Form_Submission $submission
81
+     */
82
+    public function add_texts( $submission ) {
83
+
84
+        $payable = $submission->format_amount( $submission->get_total() );
85
+
86
+        if ( $submission->has_recurring != 0 ) {
87
+
88
+            $recurring = new WPInv_Item( $submission->has_recurring );
89
+            $period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
90
+
91
+            if ( $submission->get_total() == $submission->get_recurring_total() ) {
92
+                $payable = "$payable / $period";
93
+            } else {
94
+                $payable = sprintf(
95
+                    __( '%1$s (renews at %2$s / %3$s)'),
96
+                    $submission->format_amount( $submission->get_total() ),
97
+                    $submission->format_amount( $submission->get_recurring_total() ),
98
+                    $period
99
+                );
100
+            }
101
+
102
+        }
103
+
104
+        $texts = array(
105
+            '.getpaid-checkout-total-payable' => $payable,
106
+        );
107
+
108
+        foreach ( $submission->get_items() as $item_id => $item ) {
109
+            $texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount( $item->get_sub_total() );
110
+            $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() );
111
+        }
112
+
113
+        $this->response = array_merge( $this->response, array( 'texts' => $texts ) );
114
+
115
+    }
116
+
117
+    /**
118
+     * Adds items to a response for submission refresh prices.
119
+     *
120
+     * @param GetPaid_Payment_Form_Submission $submission
121
+     */
122
+    public function add_items( $submission ) {
123
+
124
+        // Add items.
125
+        $items = array();
126 126
 
127 127
         foreach ( $submission->get_items() as $item_id => $item ) {
128
-			$items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
129
-		}
128
+            $items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
129
+        }
130 130
 
131
-		$this->response = array_merge(
132
-			$this->response,
133
-			array( 'items' => $items )
134
-		);
131
+        $this->response = array_merge(
132
+            $this->response,
133
+            array( 'items' => $items )
134
+        );
135 135
 
136
-	}
136
+    }
137 137
 
138
-	/**
139
-	 * Adds fees to a response for submission refresh prices.
140
-	 *
141
-	 * @param GetPaid_Payment_Form_Submission $submission
142
-	 */
143
-	public function add_fees( $submission ) {
138
+    /**
139
+     * Adds fees to a response for submission refresh prices.
140
+     *
141
+     * @param GetPaid_Payment_Form_Submission $submission
142
+     */
143
+    public function add_fees( $submission ) {
144 144
 
145
-		$fees = array();
145
+        $fees = array();
146 146
 
147 147
         foreach ( $submission->get_fees() as $name => $data ) {
148
-			$fees[$name] = $submission->format_amount( $data['initial_fee'] );
149
-		}
148
+            $fees[$name] = $submission->format_amount( $data['initial_fee'] );
149
+        }
150 150
 
151
-		$this->response = array_merge(
152
-			$this->response,
153
-			array( 'fees' => $fees )
154
-		);
151
+        $this->response = array_merge(
152
+            $this->response,
153
+            array( 'fees' => $fees )
154
+        );
155 155
 
156
-	}
156
+    }
157 157
 
158
-	/**
159
-	 * Adds discounts to a response for submission refresh prices.
160
-	 *
161
-	 * @param GetPaid_Payment_Form_Submission $submission
162
-	 */
163
-	public function add_discounts( $submission ) {
158
+    /**
159
+     * Adds discounts to a response for submission refresh prices.
160
+     *
161
+     * @param GetPaid_Payment_Form_Submission $submission
162
+     */
163
+    public function add_discounts( $submission ) {
164 164
 
165
-		$discounts = array();
165
+        $discounts = array();
166 166
 
167 167
         foreach ( $submission->get_discounts() as $name => $data ) {
168
-			$discounts[$name] = $submission->format_amount( $data['initial_discount'] );
169
-		}
168
+            $discounts[$name] = $submission->format_amount( $data['initial_discount'] );
169
+        }
170 170
 
171
-		$this->response = array_merge(
172
-			$this->response,
173
-			array( 'discounts' => $discounts )
174
-		);
171
+        $this->response = array_merge(
172
+            $this->response,
173
+            array( 'discounts' => $discounts )
174
+        );
175 175
 
176
-	}
176
+    }
177 177
 
178
-	/**
179
-	 * Adds taxes to a response for submission refresh prices.
180
-	 *
181
-	 * @param GetPaid_Payment_Form_Submission $submission
182
-	 */
183
-	public function add_taxes( $submission ) {
178
+    /**
179
+     * Adds taxes to a response for submission refresh prices.
180
+     *
181
+     * @param GetPaid_Payment_Form_Submission $submission
182
+     */
183
+    public function add_taxes( $submission ) {
184 184
 
185
-		$taxes = array();
185
+        $taxes = array();
186 186
 
187 187
         foreach ( $submission->get_taxes() as $name => $data ) {
188
-			$taxes[$name] = $submission->format_amount( $data['initial_tax'] );
189
-		}
188
+            $taxes[$name] = $submission->format_amount( $data['initial_tax'] );
189
+        }
190 190
 
191
-		$this->response = array_merge(
192
-			$this->response,
193
-			array( 'taxes' => $taxes )
194
-		);
191
+        $this->response = array_merge(
192
+            $this->response,
193
+            array( 'taxes' => $taxes )
194
+        );
195 195
 
196
-	}
196
+    }
197 197
 
198
-	/**
199
-	 * Adds gateways to a response for submission refresh prices.
200
-	 *
201
-	 * @param GetPaid_Payment_Form_Submission $submission
202
-	 */
203
-	public function add_gateways( $submission ) {
198
+    /**
199
+     * Adds gateways to a response for submission refresh prices.
200
+     *
201
+     * @param GetPaid_Payment_Form_Submission $submission
202
+     */
203
+    public function add_gateways( $submission ) {
204 204
 
205
-		$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
205
+        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
206 206
 
207
-		if ( $this->response['has_recurring'] ) {
207
+        if ( $this->response['has_recurring'] ) {
208 208
 
209
-			foreach ( $gateways as $i => $gateway ) {
209
+            foreach ( $gateways as $i => $gateway ) {
210 210
 
211
-				if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
212
-					unset( $gateways[ $i ] );
213
-				}
211
+                if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
212
+                    unset( $gateways[ $i ] );
213
+                }
214 214
 
215
-			}
215
+            }
216 216
 
217
-		}
217
+        }
218 218
 
219 219
 
220
-		$gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
221
-		$this->response = array_merge(
222
-			$this->response,
223
-			array( 'gateways' => $gateways )
224
-		);
220
+        $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
221
+        $this->response = array_merge(
222
+            $this->response,
223
+            array( 'gateways' => $gateways )
224
+        );
225 225
 
226
-	}
226
+    }
227 227
 
228 228
 }
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission refresh prices class
@@ -23,21 +23,21 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param GetPaid_Payment_Form_Submission $submission
25 25
 	 */
26
-	public function __construct( $submission ) {
26
+	public function __construct($submission) {
27 27
 
28 28
 		$this->response = array(
29 29
 			'submission_id' => $submission->id,
30 30
             'has_recurring' => $submission->has_recurring,
31
-            'is_free'       => ! $submission->should_collect_payment_details(),
31
+            'is_free'       => !$submission->should_collect_payment_details(),
32 32
 		);
33 33
 
34
-		$this->add_totals( $submission );
35
-		$this->add_texts( $submission );
36
-		$this->add_items( $submission );
37
-		$this->add_fees( $submission );
38
-		$this->add_discounts( $submission );
39
-		$this->add_taxes( $submission );
40
-		$this->add_gateways( $submission );
34
+		$this->add_totals($submission);
35
+		$this->add_texts($submission);
36
+		$this->add_items($submission);
37
+		$this->add_fees($submission);
38
+		$this->add_discounts($submission);
39
+		$this->add_taxes($submission);
40
+		$this->add_gateways($submission);
41 41
 
42 42
 	}
43 43
 
@@ -46,27 +46,27 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @param GetPaid_Payment_Form_Submission $submission
48 48
 	 */
49
-	public function add_totals( $submission ) {
49
+	public function add_totals($submission) {
50 50
 
51 51
 		$this->response = array_merge(
52 52
 			$this->response,
53 53
 			array(
54 54
 
55 55
 				'totals'        => array(
56
-					'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
57
-					'discount'  => $submission->format_amount( $submission->get_discount() ),
58
-					'fees'      => $submission->format_amount( $submission->get_fee() ),
59
-					'tax'       => $submission->format_amount( $submission->get_tax() ),
60
-					'total'     => $submission->format_amount( $submission->get_total() ),
61
-					'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
56
+					'subtotal'  => $submission->format_amount($submission->get_subtotal()),
57
+					'discount'  => $submission->format_amount($submission->get_discount()),
58
+					'fees'      => $submission->format_amount($submission->get_fee()),
59
+					'tax'       => $submission->format_amount($submission->get_tax()),
60
+					'total'     => $submission->format_amount($submission->get_total()),
61
+					'raw_total' => html_entity_decode(sanitize_text_field($submission->format_amount($submission->get_total())), ENT_QUOTES),
62 62
 				),
63 63
 
64 64
 				'recurring'     => array(
65
-					'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
66
-					'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
67
-					'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
68
-					'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
69
-					'total'     => $submission->format_amount( $submission->get_recurring_total() ),
65
+					'subtotal'  => $submission->format_amount($submission->get_recurring_subtotal()),
66
+					'discount'  => $submission->format_amount($submission->get_recurring_discount()),
67
+					'fees'      => $submission->format_amount($submission->get_recurring_fee()),
68
+					'tax'       => $submission->format_amount($submission->get_recurring_tax()),
69
+					'total'     => $submission->format_amount($submission->get_recurring_total()),
70 70
 				),
71 71
 
72 72
 			)
@@ -79,22 +79,22 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param GetPaid_Payment_Form_Submission $submission
81 81
 	 */
82
-	public function add_texts( $submission ) {
82
+	public function add_texts($submission) {
83 83
 
84
-		$payable = $submission->format_amount( $submission->get_total() );
84
+		$payable = $submission->format_amount($submission->get_total());
85 85
 
86
-		if ( $submission->has_recurring != 0 ) {
86
+		if ($submission->has_recurring != 0) {
87 87
 
88
-			$recurring = new WPInv_Item( $submission->has_recurring );
89
-			$period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
88
+			$recurring = new WPInv_Item($submission->has_recurring);
89
+			$period    = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), '');
90 90
 
91
-			if ( $submission->get_total() == $submission->get_recurring_total() ) {
91
+			if ($submission->get_total() == $submission->get_recurring_total()) {
92 92
 				$payable = "$payable / $period";
93 93
 			} else {
94 94
 				$payable = sprintf(
95
-					__( '%1$s (renews at %2$s / %3$s)'),
96
-					$submission->format_amount( $submission->get_total() ),
97
-					$submission->format_amount( $submission->get_recurring_total() ),
95
+					__('%1$s (renews at %2$s / %3$s)'),
96
+					$submission->format_amount($submission->get_total()),
97
+					$submission->format_amount($submission->get_recurring_total()),
98 98
 					$period
99 99
 				);
100 100
 			}
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
 			'.getpaid-checkout-total-payable' => $payable,
106 106
 		);
107 107
 
108
-		foreach ( $submission->get_items() as $item_id => $item ) {
109
-			$texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount( $item->get_sub_total() );
110
-			$texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() );
108
+		foreach ($submission->get_items() as $item_id => $item) {
109
+			$texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount($item->get_sub_total());
110
+			$texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount($item->get_recurring_sub_total());
111 111
 		}
112 112
 
113
-		$this->response = array_merge( $this->response, array( 'texts' => $texts ) );
113
+		$this->response = array_merge($this->response, array('texts' => $texts));
114 114
 
115 115
 	}
116 116
 
@@ -119,18 +119,18 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @param GetPaid_Payment_Form_Submission $submission
121 121
 	 */
122
-	public function add_items( $submission ) {
122
+	public function add_items($submission) {
123 123
 
124 124
 		// Add items.
125 125
 		$items = array();
126 126
 
127
-        foreach ( $submission->get_items() as $item_id => $item ) {
128
-			$items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
127
+        foreach ($submission->get_items() as $item_id => $item) {
128
+			$items["$item_id"] = $submission->format_amount($item->get_sub_total());
129 129
 		}
130 130
 
131 131
 		$this->response = array_merge(
132 132
 			$this->response,
133
-			array( 'items' => $items )
133
+			array('items' => $items)
134 134
 		);
135 135
 
136 136
 	}
@@ -140,17 +140,17 @@  discard block
 block discarded – undo
140 140
 	 *
141 141
 	 * @param GetPaid_Payment_Form_Submission $submission
142 142
 	 */
143
-	public function add_fees( $submission ) {
143
+	public function add_fees($submission) {
144 144
 
145 145
 		$fees = array();
146 146
 
147
-        foreach ( $submission->get_fees() as $name => $data ) {
148
-			$fees[$name] = $submission->format_amount( $data['initial_fee'] );
147
+        foreach ($submission->get_fees() as $name => $data) {
148
+			$fees[$name] = $submission->format_amount($data['initial_fee']);
149 149
 		}
150 150
 
151 151
 		$this->response = array_merge(
152 152
 			$this->response,
153
-			array( 'fees' => $fees )
153
+			array('fees' => $fees)
154 154
 		);
155 155
 
156 156
 	}
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @param GetPaid_Payment_Form_Submission $submission
162 162
 	 */
163
-	public function add_discounts( $submission ) {
163
+	public function add_discounts($submission) {
164 164
 
165 165
 		$discounts = array();
166 166
 
167
-        foreach ( $submission->get_discounts() as $name => $data ) {
168
-			$discounts[$name] = $submission->format_amount( $data['initial_discount'] );
167
+        foreach ($submission->get_discounts() as $name => $data) {
168
+			$discounts[$name] = $submission->format_amount($data['initial_discount']);
169 169
 		}
170 170
 
171 171
 		$this->response = array_merge(
172 172
 			$this->response,
173
-			array( 'discounts' => $discounts )
173
+			array('discounts' => $discounts)
174 174
 		);
175 175
 
176 176
 	}
@@ -180,17 +180,17 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @param GetPaid_Payment_Form_Submission $submission
182 182
 	 */
183
-	public function add_taxes( $submission ) {
183
+	public function add_taxes($submission) {
184 184
 
185 185
 		$taxes = array();
186 186
 
187
-        foreach ( $submission->get_taxes() as $name => $data ) {
188
-			$taxes[$name] = $submission->format_amount( $data['initial_tax'] );
187
+        foreach ($submission->get_taxes() as $name => $data) {
188
+			$taxes[$name] = $submission->format_amount($data['initial_tax']);
189 189
 		}
190 190
 
191 191
 		$this->response = array_merge(
192 192
 			$this->response,
193
-			array( 'taxes' => $taxes )
193
+			array('taxes' => $taxes)
194 194
 		);
195 195
 
196 196
 	}
@@ -200,16 +200,16 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @param GetPaid_Payment_Form_Submission $submission
202 202
 	 */
203
-	public function add_gateways( $submission ) {
203
+	public function add_gateways($submission) {
204 204
 
205
-		$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
205
+		$gateways = array_keys(wpinv_get_enabled_payment_gateways());
206 206
 
207
-		if ( $this->response['has_recurring'] ) {
207
+		if ($this->response['has_recurring']) {
208 208
 
209
-			foreach ( $gateways as $i => $gateway ) {
209
+			foreach ($gateways as $i => $gateway) {
210 210
 
211
-				if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
212
-					unset( $gateways[ $i ] );
211
+				if (!wpinv_gateway_support_subscription($gateway)) {
212
+					unset($gateways[$i]);
213 213
 				}
214 214
 
215 215
 			}
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
 		}
218 218
 
219 219
 
220
-		$gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
220
+		$gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission);
221 221
 		$this->response = array_merge(
222 222
 			$this->response,
223
-			array( 'gateways' => $gateways )
223
+			array('gateways' => $gateways)
224 224
 		);
225 225
 
226 226
 	}
Please login to merge, or discard this patch.
templates/payment-forms-admin/edit/pay_button.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,44 +7,44 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
14 14
 <div class='form-group'>
15 15
     <label class="d-block">
16
-        <span><?php esc_html_e( 'Button Text', 'invoicing' ); ?></span>
16
+        <span><?php esc_html_e('Button Text', 'invoicing'); ?></span>
17 17
         <input v-model='active_form_element.label' class='form-control' type="text"/>
18
-        <small class="form-text text-muted"><?php _e( '%price% will be replaced by the total payable amount', 'invoicing' ); ?></small>
18
+        <small class="form-text text-muted"><?php _e('%price% will be replaced by the total payable amount', 'invoicing'); ?></small>
19 19
     </label>
20 20
 </div>
21 21
 
22 22
 <div class='form-group'>
23 23
     <label class="d-block">
24
-        <span><?php esc_html_e( 'Free Checkout Text', 'invoicing' ); ?></span>
24
+        <span><?php esc_html_e('Free Checkout Text', 'invoicing'); ?></span>
25 25
         <input v-model='active_form_element.free' class='form-control' type="text"/>
26
-        <small class="form-text text-muted"><?php _e( 'The text to display if the total payable amount is zero', 'invoicing' ); ?></small>
26
+        <small class="form-text text-muted"><?php _e('The text to display if the total payable amount is zero', 'invoicing'); ?></small>
27 27
     </label>
28 28
 </div>
29 29
 
30 30
 <div class='form-group'>
31 31
     <label class="d-block">
32
-        <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span>
33
-        <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea>
32
+        <span><?php esc_html_e('Help Text', 'invoicing'); ?></span>
33
+        <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea>
34 34
     </label>
35 35
 </div>
36 36
 
37 37
 <div class='form-group'>
38
-    <label :for="active_form_element.id + '_edit_type'"><?php esc_html_e( 'Button Type', 'invoicing' ) ?></label>
38
+    <label :for="active_form_element.id + '_edit_type'"><?php esc_html_e('Button Type', 'invoicing') ?></label>
39 39
     <select class='form-control custom-select' :id="active_form_element.id + '_edit_type'" v-model='active_form_element.class'>
40
-        <option value='btn-primary'><?php esc_html_e( 'Primary', 'invoicing' ); ?></option>
41
-        <option value='btn-secondary'><?php esc_html_e( 'Secondary', 'invoicing' ); ?></option>
42
-        <option value='btn-success'><?php esc_html_e( 'Success', 'invoicing' ); ?></option>
43
-        <option value='btn-danger'><?php esc_html_e( 'Danger', 'invoicing' ); ?></option>
44
-        <option value='btn-warning'><?php esc_html_e( 'Warning', 'invoicing' ); ?></option>
45
-        <option value='btn-info'><?php esc_html_e( 'Info', 'invoicing' ); ?></option>
46
-        <option value='btn-light'><?php esc_html_e( 'Light', 'invoicing' ); ?></option>
47
-        <option value='btn-dark'><?php esc_html_e( 'Dark', 'invoicing' ); ?></option>
48
-        <option value='btn-link'><?php esc_html_e( 'Link', 'invoicing' ); ?></option>
40
+        <option value='btn-primary'><?php esc_html_e('Primary', 'invoicing'); ?></option>
41
+        <option value='btn-secondary'><?php esc_html_e('Secondary', 'invoicing'); ?></option>
42
+        <option value='btn-success'><?php esc_html_e('Success', 'invoicing'); ?></option>
43
+        <option value='btn-danger'><?php esc_html_e('Danger', 'invoicing'); ?></option>
44
+        <option value='btn-warning'><?php esc_html_e('Warning', 'invoicing'); ?></option>
45
+        <option value='btn-info'><?php esc_html_e('Info', 'invoicing'); ?></option>
46
+        <option value='btn-light'><?php esc_html_e('Light', 'invoicing'); ?></option>
47
+        <option value='btn-dark'><?php esc_html_e('Dark', 'invoicing'); ?></option>
48
+        <option value='btn-link'><?php esc_html_e('Link', 'invoicing'); ?></option>
49 49
     </select>
50 50
 </div>
Please login to merge, or discard this patch.
templates/payment-forms/elements/pay_button.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,18 +7,18 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$class = empty( $class ) ? 'btn-primary' : sanitize_html_class( $class );
13
-$label = empty( $label ) ? esc_attr__( 'Pay %price% »', 'invoicing' ) : esc_attr( $label );
14
-$free  = empty( $free ) ? esc_attr__( 'Continue »', 'invoicing' ) : esc_attr( $free );
12
+$class = empty($class) ? 'btn-primary' : sanitize_html_class($class);
13
+$label = empty($label) ? esc_attr__('Pay %price% »', 'invoicing') : esc_attr($label);
14
+$free  = empty($free) ? esc_attr__('Continue »', 'invoicing') : esc_attr($free);
15 15
 
16 16
 echo aui()->input(
17 17
     array(
18
-        'name'             => esc_attr( $id ),
19
-        'id'               => esc_attr( $id ) . uniqid( '_' ),
18
+        'name'             => esc_attr($id),
19
+        'id'               => esc_attr($id) . uniqid('_'),
20 20
         'value'            => $label,
21
-        'help_text'        => empty( $description ) ? '' : wp_kses_post( $description ),
21
+        'help_text'        => empty($description) ? '' : wp_kses_post($description),
22 22
         'type'             => 'submit',
23 23
         'class'            => 'getpaid-payment-form-submit btn btn-block submit-button ' . $class,
24 24
         'extra_attributes' => array(
Please login to merge, or discard this patch.