Passed
Push — master ( b5d6c7...020c1f )
by Stiofan
06:03
created
ayecode/wp-ayecode-ui/includes/components/class-aui-component-input.php 1 patch
Indentation   +1261 added lines, -1261 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,1284 +11,1284 @@  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
-		global $aui_bs5;
23
-
24
-		$defaults = array(
25
-			'type'                     => 'text',
26
-			'name'                     => '',
27
-			'class'                    => '',
28
-			'wrap_class'               => '',
29
-			'id'                       => '',
30
-			'placeholder'              => '',
31
-			'title'                    => '',
32
-			'value'                    => '',
33
-			'required'                 => false,
34
-			'size'                     => '', // sm, lg, small, large
35
-			'clear_icon'               => '', // true will show a clear icon, can't be used with input_group_right
36
-			'with_hidden'              => false, // Append hidden field for single checkbox.
37
-			'label'                    => '',
38
-			'label_after'              => false,
39
-			'label_class'              => '',
40
-			'label_col'                => '2',
41
-			'label_type'               => '', // top, horizontal, empty = hidden
42
-			'label_force_left'         => false, // used to force checkbox label left when using horizontal
43
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
44
-			'help_text'                => '',
45
-			'validation_text'          => '',
46
-			'validation_pattern'       => '',
47
-			'no_wrap'                  => false,
48
-			'input_group_right'        => '',
49
-			'input_group_left'         => '',
50
-			'input_group_right_inside' => false,
51
-			// forces the input group inside the input
52
-			'input_group_left_inside'  => false,
53
-			// forces the input group inside the input
54
-			'form_group_class'         => '',
55
-			'step'                     => '',
56
-			'switch'                   => false,
57
-			// to show checkbox as a switch
58
-			'checked'                  => false,
59
-			// set a checkbox or radio as selected
60
-			'password_toggle'          => true,
61
-			// toggle view/hide password
62
-			'element_require'          => '',
63
-			// [%element_id%] == "1"
64
-			'extra_attributes'         => array(),
65
-			// an array of extra attributes
66
-			'wrap_attributes'          => array()
67
-		);
68
-
69
-		/**
70
-		 * Parse incoming $args into an array and merge it with $defaults
71
-		 */
72
-		$args   = wp_parse_args( $args, $defaults );
73
-		$output = '';
74
-		if ( ! empty( $args['type'] ) ) {
75
-			// hidden label option needs to be empty
76
-			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
77
-
78
-			$type = sanitize_html_class( $args['type'] );
79
-
80
-			$help_text   = '';
81
-			$label       = '';
82
-			$label_after = $args['label_after'];
83
-			$label_args  = array(
84
-				'title'      => $args['label'],
85
-				'for'        => $args['id'],
86
-				'class'      => $args['label_class'] . " ",
87
-				'label_type' => $args['label_type'],
88
-				'label_col'  => $args['label_col']
89
-			);
90
-
91
-			// floating labels need label after
92
-			if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
93
-				$label_after         = true;
94
-				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
95
-			}
96
-
97
-			// size
98
-			$size = '';
99
-			if ( $args['size'] == 'lg' || $args['size'] == 'large' ) {
100
-				$size = 'lg';
101
-				$args['class'] .= ' form-control-lg';
102
-			}elseif ( $args['size'] == 'sm' || $args['size'] == 'small' ) {
103
-				$size = 'sm';
104
-				$args['class'] .= ' form-control-sm';
105
-			}
106
-
107
-			// clear function
108
-			$clear_function = 'jQuery(this).parent().parent().find(\'input\').val(\'\');';
109
-
110
-			// Some special sauce for files
111
-			if ( $type == 'file' ) {
112
-				$label_after = true; // if type file we need the label after
113
-				$args['class'] .= ' custom-file-input ';
114
-			} elseif ( $type == 'checkbox' ) {
115
-				$label_after = true; // if type file we need the label after
116
-				$args['class'] .= $aui_bs5 ? ' form-check-input' : ' custom-control-input ';
117
-			} elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
118
-				$orig_type = $type;
119
-				$type = 'text';
120
-				$args['class'] .= ' bg-initial '; // @todo not sure why we have this?
121
-				$clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr( $args['name'] ) . "\']').trigger('change');";
122
-
123
-				$args['extra_attributes']['data-aui-init'] = 'flatpickr';
124
-
125
-				// Disable native datetime inputs.
126
-				$disable_mobile_attr = isset( $args['extra_attributes']['data-disable-mobile'] ) ? $args['extra_attributes']['data-disable-mobile'] : 'true';
127
-				$disable_mobile_attr = apply_filters( 'aui_flatpickr_disable_disable_mobile_attr', $disable_mobile_attr, $args );
128
-
129
-				$args['extra_attributes']['data-disable-mobile'] = $disable_mobile_attr;
130
-
131
-				// set a way to clear field if empty
132
-				if ( $args['input_group_right'] === '' && $args['clear_icon'] !== false ) {
133
-					$args['input_group_right_inside'] = true;
134
-					$args['clear_icon'] = true;
135
-				}
136
-
137
-				// enqueue the script
138
-				$aui_settings = AyeCode_UI_Settings::instance();
139
-				$aui_settings->enqueue_flatpickr();
140
-			} elseif ( $type == 'iconpicker' ) {
141
-				$type = 'text';
142
-				//$args['class'] .= ' aui-flatpickr bg-initial ';
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
+        global $aui_bs5;
23
+
24
+        $defaults = array(
25
+            'type'                     => 'text',
26
+            'name'                     => '',
27
+            'class'                    => '',
28
+            'wrap_class'               => '',
29
+            'id'                       => '',
30
+            'placeholder'              => '',
31
+            'title'                    => '',
32
+            'value'                    => '',
33
+            'required'                 => false,
34
+            'size'                     => '', // sm, lg, small, large
35
+            'clear_icon'               => '', // true will show a clear icon, can't be used with input_group_right
36
+            'with_hidden'              => false, // Append hidden field for single checkbox.
37
+            'label'                    => '',
38
+            'label_after'              => false,
39
+            'label_class'              => '',
40
+            'label_col'                => '2',
41
+            'label_type'               => '', // top, horizontal, empty = hidden
42
+            'label_force_left'         => false, // used to force checkbox label left when using horizontal
43
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
44
+            'help_text'                => '',
45
+            'validation_text'          => '',
46
+            'validation_pattern'       => '',
47
+            'no_wrap'                  => false,
48
+            'input_group_right'        => '',
49
+            'input_group_left'         => '',
50
+            'input_group_right_inside' => false,
51
+            // forces the input group inside the input
52
+            'input_group_left_inside'  => false,
53
+            // forces the input group inside the input
54
+            'form_group_class'         => '',
55
+            'step'                     => '',
56
+            'switch'                   => false,
57
+            // to show checkbox as a switch
58
+            'checked'                  => false,
59
+            // set a checkbox or radio as selected
60
+            'password_toggle'          => true,
61
+            // toggle view/hide password
62
+            'element_require'          => '',
63
+            // [%element_id%] == "1"
64
+            'extra_attributes'         => array(),
65
+            // an array of extra attributes
66
+            'wrap_attributes'          => array()
67
+        );
68
+
69
+        /**
70
+         * Parse incoming $args into an array and merge it with $defaults
71
+         */
72
+        $args   = wp_parse_args( $args, $defaults );
73
+        $output = '';
74
+        if ( ! empty( $args['type'] ) ) {
75
+            // hidden label option needs to be empty
76
+            $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
77
+
78
+            $type = sanitize_html_class( $args['type'] );
79
+
80
+            $help_text   = '';
81
+            $label       = '';
82
+            $label_after = $args['label_after'];
83
+            $label_args  = array(
84
+                'title'      => $args['label'],
85
+                'for'        => $args['id'],
86
+                'class'      => $args['label_class'] . " ",
87
+                'label_type' => $args['label_type'],
88
+                'label_col'  => $args['label_col']
89
+            );
90
+
91
+            // floating labels need label after
92
+            if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
93
+                $label_after         = true;
94
+                $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
95
+            }
96
+
97
+            // size
98
+            $size = '';
99
+            if ( $args['size'] == 'lg' || $args['size'] == 'large' ) {
100
+                $size = 'lg';
101
+                $args['class'] .= ' form-control-lg';
102
+            }elseif ( $args['size'] == 'sm' || $args['size'] == 'small' ) {
103
+                $size = 'sm';
104
+                $args['class'] .= ' form-control-sm';
105
+            }
106
+
107
+            // clear function
108
+            $clear_function = 'jQuery(this).parent().parent().find(\'input\').val(\'\');';
109
+
110
+            // Some special sauce for files
111
+            if ( $type == 'file' ) {
112
+                $label_after = true; // if type file we need the label after
113
+                $args['class'] .= ' custom-file-input ';
114
+            } elseif ( $type == 'checkbox' ) {
115
+                $label_after = true; // if type file we need the label after
116
+                $args['class'] .= $aui_bs5 ? ' form-check-input' : ' custom-control-input ';
117
+            } elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
118
+                $orig_type = $type;
119
+                $type = 'text';
120
+                $args['class'] .= ' bg-initial '; // @todo not sure why we have this?
121
+                $clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr( $args['name'] ) . "\']').trigger('change');";
122
+
123
+                $args['extra_attributes']['data-aui-init'] = 'flatpickr';
124
+
125
+                // Disable native datetime inputs.
126
+                $disable_mobile_attr = isset( $args['extra_attributes']['data-disable-mobile'] ) ? $args['extra_attributes']['data-disable-mobile'] : 'true';
127
+                $disable_mobile_attr = apply_filters( 'aui_flatpickr_disable_disable_mobile_attr', $disable_mobile_attr, $args );
128
+
129
+                $args['extra_attributes']['data-disable-mobile'] = $disable_mobile_attr;
130
+
131
+                // set a way to clear field if empty
132
+                if ( $args['input_group_right'] === '' && $args['clear_icon'] !== false ) {
133
+                    $args['input_group_right_inside'] = true;
134
+                    $args['clear_icon'] = true;
135
+                }
136
+
137
+                // enqueue the script
138
+                $aui_settings = AyeCode_UI_Settings::instance();
139
+                $aui_settings->enqueue_flatpickr();
140
+            } elseif ( $type == 'iconpicker' ) {
141
+                $type = 'text';
142
+                //$args['class'] .= ' aui-flatpickr bg-initial ';
143 143
 //				$args['class'] .= ' bg-initial ';
144 144
 
145
-				$args['extra_attributes']['data-aui-init'] = 'iconpicker';
146
-				$args['extra_attributes']['data-placement'] = 'bottomRight';
145
+                $args['extra_attributes']['data-aui-init'] = 'iconpicker';
146
+                $args['extra_attributes']['data-placement'] = 'bottomRight';
147 147
 
148
-				$args['input_group_right'] = '<span class="input-group-addon input-group-text c-pointer"></span>';
148
+                $args['input_group_right'] = '<span class="input-group-addon input-group-text c-pointer"></span>';
149 149
 //				$args['input_group_right_inside'] = true;
150
-				// enqueue the script
151
-				$aui_settings = AyeCode_UI_Settings::instance();
152
-				$aui_settings->enqueue_iconpicker();
153
-			}
154
-
155
-			if ( $type == 'checkbox' && ( ( ! empty( $args['name'] ) && strpos( $args['name'], '[' ) === false ) || ! empty( $args['with_hidden'] ) ) ) {
156
-				$output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
157
-			}
158
-
159
-			// allow clear icon
160
-			if ( $args['input_group_right'] === '' && $args['clear_icon'] ) {
161
-				$font_size = $size == 'sm' ? '1.3' : ( $size == 'lg' ? '1.65' : '1.5' );
162
-				$args['input_group_right_inside'] = true;
163
-				$align_class = $aui_bs5 ? ' h-100 py-0' : '';
164
-				$args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none ' . $align_class . '" onclick="' . $clear_function . '"><span style="font-size: ' . $font_size . 'rem" aria-hidden="true" class="' . ( $aui_bs5 ? 'btn-close' : 'close' ) . '">' . ( $aui_bs5 ? '' : '&times;' ) . '</span></span>';
165
-			}
166
-
167
-			// open/type
168
-			$output .= '<input type="' . $type . '" ';
169
-
170
-			// name
171
-			if ( ! empty( $args['name'] ) ) {
172
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
173
-			}
174
-
175
-			// id
176
-			if ( ! empty( $args['id'] ) ) {
177
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
178
-			}
179
-
180
-			// placeholder
181
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
182
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
183
-			}
184
-
185
-			// title
186
-			if ( ! empty( $args['title'] ) ) {
187
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
188
-			}
189
-
190
-			// value
191
-			if ( ! empty( $args['value'] ) ) {
192
-				$output .= AUI_Component_Helper::value( $args['value'] );
193
-			}
194
-
195
-			// checked, for radio and checkboxes
196
-			if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
197
-				$output .= ' checked ';
198
-			}
199
-
200
-			// validation text
201
-			if ( ! empty( $args['validation_text'] ) ) {
202
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" ';
203
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
204
-			}
205
-
206
-			// validation_pattern
207
-			if ( ! empty( $args['validation_pattern'] ) ) {
208
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
209
-			}
210
-
211
-			// step (for numbers)
212
-			if ( ! empty( $args['step'] ) ) {
213
-				$output .= ' step="' . $args['step'] . '" ';
214
-			}
215
-
216
-			// required
217
-			if ( ! empty( $args['required'] ) ) {
218
-				$output .= ' required ';
219
-			}
220
-
221
-			// class
222
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
223
-			$output .= $aui_bs5 &&  $type == 'checkbox' ? ' class="' . $class . '" ' : ' class="form-control ' . $class . '" ';
224
-
225
-			// data-attributes
226
-			$output .= AUI_Component_Helper::data_attributes( $args );
227
-
228
-			// extra attributes
229
-			if ( ! empty( $args['extra_attributes'] ) ) {
230
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
231
-			}
232
-
233
-			// close
234
-			$output .= ' >';
235
-
236
-			// help text
237
-			if ( ! empty( $args['help_text'] ) ) {
238
-				$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
239
-			}
240
-
241
-			// label
242
-			if ( ! empty( $args['label'] ) ) {
243
-				$label_base_class = '';
244
-				if ( $type == 'file' ) {
245
-					$label_base_class = ' custom-file-label';
246
-				} elseif ( $type == 'checkbox' ) {
247
-					if ( ! empty( $args['label_force_left'] ) ) {
248
-						$label_args['title'] = wp_kses_post( $args['help_text'] );
249
-						$help_text = '';
250
-						//$label_args['class'] .= ' d-inline ';
251
-						$args['wrap_class'] .= ' align-items-center ';
252
-					}else{
253
-
254
-					}
255
-
256
-					$label_base_class = $aui_bs5 ? ' form-check-label' : ' custom-control-label';
257
-				}
258
-				$label_args['class'] .= $label_base_class;
259
-				$temp_label_args = $label_args;
260
-				if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
261
-				$label = self::label( $temp_label_args, $type );
262
-			}
263
-
264
-
265
-
266
-
267
-			// set help text in the correct position
268
-			if ( $label_after ) {
269
-				$output .= $label . $help_text;
270
-			}
271
-
272
-			// some input types need a separate wrap
273
-			if ( $type == 'file' ) {
274
-				$output = self::wrap( array(
275
-					'content' => $output,
276
-					'class'   => $aui_bs5 ? 'mb-3 custom-file' : 'form-group custom-file'
277
-				) );
278
-			} elseif ( $type == 'checkbox' ) {
279
-
280
-				$label_args['title'] = $args['label'];
281
-				$label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
282
-				$label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
283
-				$switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
284
-				if ( $aui_bs5 ) {
285
-					$wrap_class = $args['switch'] ? 'form-check form-switch' . $switch_size_class : 'form-check';
286
-				}else{
287
-					$wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class :  'custom-checkbox' ;
288
-				}
289
-				if ( ! empty( $args['label_force_left'] ) ) {
290
-					$wrap_class .= $aui_bs5 ? '' : ' d-flex align-content-center';
291
-					$label = str_replace(array("form-check-label","custom-control-label"),"", self::label( $label_args, 'cb' ) );
292
-				}
293
-				$output     = self::wrap( array(
294
-					'content' => $output,
295
-					'class'   => $aui_bs5 ? $wrap_class : 'custom-control ' . $wrap_class
296
-				) );
297
-
298
-				if ( $args['label_type'] == 'horizontal' ) {
299
-					$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
300
-					$output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
301
-				}
302
-			} elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
303
-
304
-
305
-				// allow password field to toggle view
306
-				$args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
150
+                // enqueue the script
151
+                $aui_settings = AyeCode_UI_Settings::instance();
152
+                $aui_settings->enqueue_iconpicker();
153
+            }
154
+
155
+            if ( $type == 'checkbox' && ( ( ! empty( $args['name'] ) && strpos( $args['name'], '[' ) === false ) || ! empty( $args['with_hidden'] ) ) ) {
156
+                $output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
157
+            }
158
+
159
+            // allow clear icon
160
+            if ( $args['input_group_right'] === '' && $args['clear_icon'] ) {
161
+                $font_size = $size == 'sm' ? '1.3' : ( $size == 'lg' ? '1.65' : '1.5' );
162
+                $args['input_group_right_inside'] = true;
163
+                $align_class = $aui_bs5 ? ' h-100 py-0' : '';
164
+                $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none ' . $align_class . '" onclick="' . $clear_function . '"><span style="font-size: ' . $font_size . 'rem" aria-hidden="true" class="' . ( $aui_bs5 ? 'btn-close' : 'close' ) . '">' . ( $aui_bs5 ? '' : '&times;' ) . '</span></span>';
165
+            }
166
+
167
+            // open/type
168
+            $output .= '<input type="' . $type . '" ';
169
+
170
+            // name
171
+            if ( ! empty( $args['name'] ) ) {
172
+                $output .= ' name="' . esc_attr( $args['name'] ) . '" ';
173
+            }
174
+
175
+            // id
176
+            if ( ! empty( $args['id'] ) ) {
177
+                $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
178
+            }
179
+
180
+            // placeholder
181
+            if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
182
+                $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
183
+            }
184
+
185
+            // title
186
+            if ( ! empty( $args['title'] ) ) {
187
+                $output .= ' title="' . esc_attr( $args['title'] ) . '" ';
188
+            }
189
+
190
+            // value
191
+            if ( ! empty( $args['value'] ) ) {
192
+                $output .= AUI_Component_Helper::value( $args['value'] );
193
+            }
194
+
195
+            // checked, for radio and checkboxes
196
+            if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
197
+                $output .= ' checked ';
198
+            }
199
+
200
+            // validation text
201
+            if ( ! empty( $args['validation_text'] ) ) {
202
+                $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" ';
203
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
204
+            }
205
+
206
+            // validation_pattern
207
+            if ( ! empty( $args['validation_pattern'] ) ) {
208
+                $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
209
+            }
210
+
211
+            // step (for numbers)
212
+            if ( ! empty( $args['step'] ) ) {
213
+                $output .= ' step="' . $args['step'] . '" ';
214
+            }
215
+
216
+            // required
217
+            if ( ! empty( $args['required'] ) ) {
218
+                $output .= ' required ';
219
+            }
220
+
221
+            // class
222
+            $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
223
+            $output .= $aui_bs5 &&  $type == 'checkbox' ? ' class="' . $class . '" ' : ' class="form-control ' . $class . '" ';
224
+
225
+            // data-attributes
226
+            $output .= AUI_Component_Helper::data_attributes( $args );
227
+
228
+            // extra attributes
229
+            if ( ! empty( $args['extra_attributes'] ) ) {
230
+                $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
231
+            }
232
+
233
+            // close
234
+            $output .= ' >';
235
+
236
+            // help text
237
+            if ( ! empty( $args['help_text'] ) ) {
238
+                $help_text = AUI_Component_Helper::help_text( $args['help_text'] );
239
+            }
240
+
241
+            // label
242
+            if ( ! empty( $args['label'] ) ) {
243
+                $label_base_class = '';
244
+                if ( $type == 'file' ) {
245
+                    $label_base_class = ' custom-file-label';
246
+                } elseif ( $type == 'checkbox' ) {
247
+                    if ( ! empty( $args['label_force_left'] ) ) {
248
+                        $label_args['title'] = wp_kses_post( $args['help_text'] );
249
+                        $help_text = '';
250
+                        //$label_args['class'] .= ' d-inline ';
251
+                        $args['wrap_class'] .= ' align-items-center ';
252
+                    }else{
253
+
254
+                    }
255
+
256
+                    $label_base_class = $aui_bs5 ? ' form-check-label' : ' custom-control-label';
257
+                }
258
+                $label_args['class'] .= $label_base_class;
259
+                $temp_label_args = $label_args;
260
+                if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
261
+                $label = self::label( $temp_label_args, $type );
262
+            }
263
+
264
+
265
+
266
+
267
+            // set help text in the correct position
268
+            if ( $label_after ) {
269
+                $output .= $label . $help_text;
270
+            }
271
+
272
+            // some input types need a separate wrap
273
+            if ( $type == 'file' ) {
274
+                $output = self::wrap( array(
275
+                    'content' => $output,
276
+                    'class'   => $aui_bs5 ? 'mb-3 custom-file' : 'form-group custom-file'
277
+                ) );
278
+            } elseif ( $type == 'checkbox' ) {
279
+
280
+                $label_args['title'] = $args['label'];
281
+                $label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
282
+                $label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
283
+                $switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
284
+                if ( $aui_bs5 ) {
285
+                    $wrap_class = $args['switch'] ? 'form-check form-switch' . $switch_size_class : 'form-check';
286
+                }else{
287
+                    $wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class :  'custom-checkbox' ;
288
+                }
289
+                if ( ! empty( $args['label_force_left'] ) ) {
290
+                    $wrap_class .= $aui_bs5 ? '' : ' d-flex align-content-center';
291
+                    $label = str_replace(array("form-check-label","custom-control-label"),"", self::label( $label_args, 'cb' ) );
292
+                }
293
+                $output     = self::wrap( array(
294
+                    'content' => $output,
295
+                    'class'   => $aui_bs5 ? $wrap_class : 'custom-control ' . $wrap_class
296
+                ) );
297
+
298
+                if ( $args['label_type'] == 'horizontal' ) {
299
+                    $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
300
+                    $output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
301
+                }
302
+            } elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
303
+
304
+
305
+                // allow password field to toggle view
306
+                $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
307 307
 onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\');
308 308
 var $eli = jQuery(this).parent().parent().find(\'input\');
309 309
 if($el.hasClass(\'fa-eye\'))
310 310
 {$eli.attr(\'type\',\'text\');}
311 311
 else{$eli.attr(\'type\',\'password\');}"
312 312
 ><i class="far fa-fw fa-eye-slash"></i></span>';
313
-			}
314
-
315
-			// input group wraps
316
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
317
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
318
-				$group_size = $size == 'lg' ? ' input-group-lg' : '';
319
-				$group_size = !$group_size && $size == 'sm' ? ' input-group-sm' : $group_size;
320
-
321
-				if ( $args['input_group_left'] ) {
322
-					$output = self::wrap( array(
323
-						'content'                 => $output,
324
-						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size,
325
-						'input_group_left'        => $args['input_group_left'],
326
-						'input_group_left_inside' => $args['input_group_left_inside']
327
-					) );
328
-				}
329
-				if ( $args['input_group_right'] ) {
330
-					$output = self::wrap( array(
331
-						'content'                  => $output,
332
-						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size,
333
-						'input_group_right'        => $args['input_group_right'],
334
-						'input_group_right_inside' => $args['input_group_right_inside']
335
-					) );
336
-				}
337
-
338
-			}
339
-
340
-			if ( ! $label_after ) {
341
-				$output .= $help_text;
342
-			}
343
-
344
-
345
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
346
-				$output = self::wrap( array(
347
-					'content' => $output,
348
-					'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
349
-				) );
350
-			}
351
-
352
-			if ( ! $label_after ) {
353
-				$output = $label . $output;
354
-			}
355
-
356
-			// wrap
357
-			if ( ! $args['no_wrap'] ) {
358
-				if ( ! empty( $args['form_group_class'] ) ) {
359
-					$fg_class = esc_attr( $args['form_group_class'] );
360
-				}else{
361
-					$fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
362
-				}
363
-				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : $fg_class;
364
-				$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
365
-				$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
366
-				$output           = self::wrap( array(
367
-					'content'         => $output,
368
-					'class'           => $wrap_class,
369
-					'element_require' => $args['element_require'],
370
-					'argument_id'     => $args['id'],
371
-					'wrap_attributes' => $args['wrap_attributes'],
372
-				) );
373
-			}
374
-		}
375
-
376
-		return $output;
377
-	}
378
-
379
-	public static function label( $args = array(), $type = '' ) {
380
-		global $aui_bs5;
381
-		//<label for="exampleInputEmail1">Email address</label>
382
-		$defaults = array(
383
-			'title'      => 'div',
384
-			'for'        => '',
385
-			'class'      => '',
386
-			'label_type' => '', // empty = hidden, top, horizontal
387
-			'label_col'  => '',
388
-		);
389
-
390
-		/**
391
-		 * Parse incoming $args into an array and merge it with $defaults
392
-		 */
393
-		$args   = wp_parse_args( $args, $defaults );
394
-		$output = '';
395
-
396
-		if ( $args['title'] ) {
397
-
398
-			// maybe hide labels //@todo set a global option for visibility class
399
-			if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
400
-				$class = $args['class'];
401
-			} else {
402
-				$class = 'sr-only ' . $args['class'];
403
-			}
404
-
405
-			// maybe horizontal
406
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
407
-				$class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label '.$type;
408
-			}
409
-
410
-			if( $aui_bs5 ){ $class .= ' form-label'; }
411
-
412
-			// open
413
-			$output .= '<label ';
414
-
415
-			// for
416
-			if ( ! empty( $args['for'] ) ) {
417
-				$output .= ' for="' . esc_attr( $args['for'] ) . '" ';
418
-			}
419
-
420
-			// class
421
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
422
-			$output .= ' class="' . $class . '" ';
423
-
424
-			// close
425
-			$output .= '>';
426
-
427
-
428
-			// title, don't escape fully as can contain html
429
-			if ( ! empty( $args['title'] ) ) {
430
-				$output .= wp_kses_post( $args['title'] );
431
-			}
432
-
433
-			// close wrap
434
-			$output .= '</label>';
435
-
436
-
437
-		}
438
-
439
-
440
-		return $output;
441
-	}
442
-
443
-	/**
444
-	 * Wrap some content in a HTML wrapper.
445
-	 *
446
-	 * @param array $args
447
-	 *
448
-	 * @return string
449
-	 */
450
-	public static function wrap( $args = array() ) {
451
-		global $aui_bs5;
452
-		$defaults = array(
453
-			'type'                     => 'div',
454
-			'class'                    => $aui_bs5 ? 'mb-3' : 'form-group',
455
-			'content'                  => '',
456
-			'input_group_left'         => '',
457
-			'input_group_right'        => '',
458
-			'input_group_left_inside'  => false,
459
-			'input_group_right_inside' => false,
460
-			'element_require'          => '',
461
-			'argument_id'              => '',
462
-			'wrap_attributes'          => array()
463
-		);
464
-
465
-		/**
466
-		 * Parse incoming $args into an array and merge it with $defaults
467
-		 */
468
-		$args   = wp_parse_args( $args, $defaults );
469
-		$output = '';
470
-		if ( $args['type'] ) {
471
-
472
-			// open
473
-			$output .= '<' . sanitize_html_class( $args['type'] );
474
-
475
-			// element require
476
-			if ( ! empty( $args['element_require'] ) ) {
477
-				$output .= AUI_Component_Helper::element_require( $args['element_require'] );
478
-				$args['class'] .= " aui-conditional-field";
479
-			}
480
-
481
-			// argument_id
482
-			if ( ! empty( $args['argument_id'] ) ) {
483
-				$output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
484
-			}
485
-
486
-			// class
487
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
488
-			$output .= ' class="' . $class . '" ';
489
-
490
-			// Attributes
491
-			if ( ! empty( $args['wrap_attributes'] ) ) {
492
-				$output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
493
-			}
494
-
495
-			// close wrap
496
-			$output .= ' >';
497
-
498
-
499
-			// Input group left
500
-			if ( ! empty( $args['input_group_left'] ) ) {
501
-				$position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
502
-				$input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
503
-				$output .= $aui_bs5 ? $input_group_left : '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
313
+            }
314
+
315
+            // input group wraps
316
+            if ( $args['input_group_left'] || $args['input_group_right'] ) {
317
+                $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
318
+                $group_size = $size == 'lg' ? ' input-group-lg' : '';
319
+                $group_size = !$group_size && $size == 'sm' ? ' input-group-sm' : $group_size;
320
+
321
+                if ( $args['input_group_left'] ) {
322
+                    $output = self::wrap( array(
323
+                        'content'                 => $output,
324
+                        'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size,
325
+                        'input_group_left'        => $args['input_group_left'],
326
+                        'input_group_left_inside' => $args['input_group_left_inside']
327
+                    ) );
328
+                }
329
+                if ( $args['input_group_right'] ) {
330
+                    $output = self::wrap( array(
331
+                        'content'                  => $output,
332
+                        'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size,
333
+                        'input_group_right'        => $args['input_group_right'],
334
+                        'input_group_right_inside' => $args['input_group_right_inside']
335
+                    ) );
336
+                }
337
+
338
+            }
339
+
340
+            if ( ! $label_after ) {
341
+                $output .= $help_text;
342
+            }
343
+
344
+
345
+            if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
346
+                $output = self::wrap( array(
347
+                    'content' => $output,
348
+                    'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
349
+                ) );
350
+            }
351
+
352
+            if ( ! $label_after ) {
353
+                $output = $label . $output;
354
+            }
355
+
356
+            // wrap
357
+            if ( ! $args['no_wrap'] ) {
358
+                if ( ! empty( $args['form_group_class'] ) ) {
359
+                    $fg_class = esc_attr( $args['form_group_class'] );
360
+                }else{
361
+                    $fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
362
+                }
363
+                $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : $fg_class;
364
+                $wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
365
+                $wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
366
+                $output           = self::wrap( array(
367
+                    'content'         => $output,
368
+                    'class'           => $wrap_class,
369
+                    'element_require' => $args['element_require'],
370
+                    'argument_id'     => $args['id'],
371
+                    'wrap_attributes' => $args['wrap_attributes'],
372
+                ) );
373
+            }
374
+        }
375
+
376
+        return $output;
377
+    }
378
+
379
+    public static function label( $args = array(), $type = '' ) {
380
+        global $aui_bs5;
381
+        //<label for="exampleInputEmail1">Email address</label>
382
+        $defaults = array(
383
+            'title'      => 'div',
384
+            'for'        => '',
385
+            'class'      => '',
386
+            'label_type' => '', // empty = hidden, top, horizontal
387
+            'label_col'  => '',
388
+        );
389
+
390
+        /**
391
+         * Parse incoming $args into an array and merge it with $defaults
392
+         */
393
+        $args   = wp_parse_args( $args, $defaults );
394
+        $output = '';
395
+
396
+        if ( $args['title'] ) {
397
+
398
+            // maybe hide labels //@todo set a global option for visibility class
399
+            if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
400
+                $class = $args['class'];
401
+            } else {
402
+                $class = 'sr-only ' . $args['class'];
403
+            }
404
+
405
+            // maybe horizontal
406
+            if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
407
+                $class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label '.$type;
408
+            }
409
+
410
+            if( $aui_bs5 ){ $class .= ' form-label'; }
411
+
412
+            // open
413
+            $output .= '<label ';
414
+
415
+            // for
416
+            if ( ! empty( $args['for'] ) ) {
417
+                $output .= ' for="' . esc_attr( $args['for'] ) . '" ';
418
+            }
419
+
420
+            // class
421
+            $class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
422
+            $output .= ' class="' . $class . '" ';
423
+
424
+            // close
425
+            $output .= '>';
426
+
427
+
428
+            // title, don't escape fully as can contain html
429
+            if ( ! empty( $args['title'] ) ) {
430
+                $output .= wp_kses_post( $args['title'] );
431
+            }
432
+
433
+            // close wrap
434
+            $output .= '</label>';
435
+
436
+
437
+        }
438
+
439
+
440
+        return $output;
441
+    }
442
+
443
+    /**
444
+     * Wrap some content in a HTML wrapper.
445
+     *
446
+     * @param array $args
447
+     *
448
+     * @return string
449
+     */
450
+    public static function wrap( $args = array() ) {
451
+        global $aui_bs5;
452
+        $defaults = array(
453
+            'type'                     => 'div',
454
+            'class'                    => $aui_bs5 ? 'mb-3' : 'form-group',
455
+            'content'                  => '',
456
+            'input_group_left'         => '',
457
+            'input_group_right'        => '',
458
+            'input_group_left_inside'  => false,
459
+            'input_group_right_inside' => false,
460
+            'element_require'          => '',
461
+            'argument_id'              => '',
462
+            'wrap_attributes'          => array()
463
+        );
464
+
465
+        /**
466
+         * Parse incoming $args into an array and merge it with $defaults
467
+         */
468
+        $args   = wp_parse_args( $args, $defaults );
469
+        $output = '';
470
+        if ( $args['type'] ) {
471
+
472
+            // open
473
+            $output .= '<' . sanitize_html_class( $args['type'] );
474
+
475
+            // element require
476
+            if ( ! empty( $args['element_require'] ) ) {
477
+                $output .= AUI_Component_Helper::element_require( $args['element_require'] );
478
+                $args['class'] .= " aui-conditional-field";
479
+            }
480
+
481
+            // argument_id
482
+            if ( ! empty( $args['argument_id'] ) ) {
483
+                $output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
484
+            }
485
+
486
+            // class
487
+            $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
488
+            $output .= ' class="' . $class . '" ';
489
+
490
+            // Attributes
491
+            if ( ! empty( $args['wrap_attributes'] ) ) {
492
+                $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
493
+            }
494
+
495
+            // close wrap
496
+            $output .= ' >';
497
+
498
+
499
+            // Input group left
500
+            if ( ! empty( $args['input_group_left'] ) ) {
501
+                $position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
502
+                $input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
503
+                $output .= $aui_bs5 ? $input_group_left : '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
504 504
 //				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
505
-			}
505
+            }
506 506
 
507
-			// content
508
-			$output .= $args['content'];
507
+            // content
508
+            $output .= $args['content'];
509 509
 
510
-			// Input group right
511
-			if ( ! empty( $args['input_group_right'] ) ) {
512
-				$position_class    = ! empty( $args['input_group_right_inside'] ) ? 'position-absolute h-100' : '';
513
-				$input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
514
-				$output .= $aui_bs5 ? str_replace( 'input-group-text','input-group-text top-0 end-0', $input_group_right ) : '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>';
510
+            // Input group right
511
+            if ( ! empty( $args['input_group_right'] ) ) {
512
+                $position_class    = ! empty( $args['input_group_right_inside'] ) ? 'position-absolute h-100' : '';
513
+                $input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
514
+                $output .= $aui_bs5 ? str_replace( 'input-group-text','input-group-text top-0 end-0', $input_group_right ) : '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>';
515 515
 //				$output .= '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>';
516
-			}
517
-
518
-
519
-			// close wrap
520
-			$output .= '</' . sanitize_html_class( $args['type'] ) . '>';
521
-
522
-
523
-		} else {
524
-			$output = $args['content'];
525
-		}
526
-
527
-		return $output;
528
-	}
529
-
530
-	/**
531
-	 * Build the component.
532
-	 *
533
-	 * @param array $args
534
-	 *
535
-	 * @return string The rendered component.
536
-	 */
537
-	public static function textarea( $args = array() ) {
538
-		global $aui_bs5;
539
-
540
-		$defaults = array(
541
-			'name'               => '',
542
-			'class'              => '',
543
-			'wrap_class'         => '',
544
-			'id'                 => '',
545
-			'placeholder'        => '',
546
-			'title'              => '',
547
-			'value'              => '',
548
-			'required'           => false,
549
-			'label'              => '',
550
-			'label_after'        => false,
551
-			'label_class'        => '',
552
-			'label_type'         => '',
553
-			'label_col'          => '',
554
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
555
-			'input_group_right'        => '',
556
-			'input_group_left'         => '',
557
-			'input_group_right_inside' => false,
558
-			'form_group_class'      => '',
559
-			'help_text'          => '',
560
-			'validation_text'    => '',
561
-			'validation_pattern' => '',
562
-			'no_wrap'            => false,
563
-			'rows'               => '',
564
-			'wysiwyg'            => false,
565
-			'allow_tags'         => false,
566
-			// Allow HTML tags
567
-			'element_require'    => '',
568
-			// [%element_id%] == "1"
569
-			'extra_attributes'   => array(),
570
-			// an array of extra attributes
571
-			'wrap_attributes'    => array(),
572
-		);
573
-
574
-		/**
575
-		 * Parse incoming $args into an array and merge it with $defaults
576
-		 */
577
-		$args   = wp_parse_args( $args, $defaults );
578
-		$output = '';
579
-		$label = '';
580
-
581
-		// hidden label option needs to be empty
582
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
583
-
584
-		// floating labels don't work with wysiwyg so set it as top
585
-		if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
586
-			$args['label_type'] = 'top';
587
-		}
588
-
589
-		$label_after = $args['label_after'];
590
-
591
-		// floating labels need label after
592
-		if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
593
-			$label_after         = true;
594
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
595
-		}
596
-
597
-		// label
598
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
599
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
600
-			$label_args = array(
601
-				'title'      => $args['label'],
602
-				'for'        => $args['id'],
603
-				'class'      => $args['label_class'] . " ",
604
-				'label_type' => $args['label_type'],
605
-				'label_col'  => $args['label_col']
606
-			);
607
-			$label .= self::label( $label_args );
608
-		}
609
-
610
-		// maybe horizontal label
611
-		if ( $args['label_type'] == 'horizontal' ) {
612
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
613
-			$label .= '<div class="' . $input_col . '">';
614
-		}
615
-
616
-		if ( ! empty( $args['wysiwyg'] ) ) {
617
-			ob_start();
618
-			$content   = $args['value'];
619
-			$editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
620
-			$settings  = array(
621
-				'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
622
-				'quicktags'     => false,
623
-				'media_buttons' => false,
624
-				'editor_class'  => 'form-control',
625
-				'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
626
-				'teeny'         => true,
627
-			);
628
-
629
-			// maybe set settings if array
630
-			if ( is_array( $args['wysiwyg'] ) ) {
631
-				$settings = wp_parse_args( $args['wysiwyg'], $settings );
632
-			}
633
-
634
-			wp_editor( $content, $editor_id, $settings );
635
-			$output .= ob_get_clean();
636
-		} else {
637
-
638
-			// open
639
-			$output .= '<textarea ';
640
-
641
-			// name
642
-			if ( ! empty( $args['name'] ) ) {
643
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
644
-			}
645
-
646
-			// id
647
-			if ( ! empty( $args['id'] ) ) {
648
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
649
-			}
650
-
651
-			// placeholder
652
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
653
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
654
-			}
655
-
656
-			// title
657
-			if ( ! empty( $args['title'] ) ) {
658
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
659
-			}
660
-
661
-			// validation text
662
-			if ( ! empty( $args['validation_text'] ) ) {
663
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" ';
664
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
665
-			}
666
-
667
-			// validation_pattern
668
-			if ( ! empty( $args['validation_pattern'] ) ) {
669
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
670
-			}
671
-
672
-			// required
673
-			if ( ! empty( $args['required'] ) ) {
674
-				$output .= ' required ';
675
-			}
676
-
677
-			// rows
678
-			if ( ! empty( $args['rows'] ) ) {
679
-				$output .= ' rows="' . absint( $args['rows'] ) . '" ';
680
-			}
681
-
682
-
683
-			// class
684
-			$class = ! empty( $args['class'] ) ? $args['class'] : '';
685
-			$output .= ' class="form-control ' . $class . '" ';
686
-
687
-			// extra attributes
688
-			if ( ! empty( $args['extra_attributes'] ) ) {
689
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
690
-			}
691
-
692
-			// close tag
693
-			$output .= ' >';
694
-
695
-			// value
696
-			if ( ! empty( $args['value'] ) ) {
697
-				if ( ! empty( $args['allow_tags'] ) ) {
698
-					$output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
699
-				} else {
700
-					$output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] );
701
-				}
702
-			}
703
-
704
-			// closing tag
705
-			$output .= '</textarea>';
706
-
707
-
708
-			// input group wraps
709
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
710
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
711
-				if ( $args['input_group_left'] ) {
712
-					$output = self::wrap( array(
713
-						'content'                 => $output,
714
-						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
715
-						'input_group_left'        => $args['input_group_left'],
716
-						'input_group_left_inside' => $args['input_group_left_inside']
717
-					) );
718
-				}
719
-				if ( $args['input_group_right'] ) {
720
-					$output = self::wrap( array(
721
-						'content'                  => $output,
722
-						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
723
-						'input_group_right'        => $args['input_group_right'],
724
-						'input_group_right_inside' => $args['input_group_right_inside']
725
-					) );
726
-				}
727
-
728
-			}
729
-
730
-
731
-		}
732
-
733
-		if ( ! empty( $args['label'] ) && $label_after ) {
734
-			$label_args = array(
735
-				'title'      => $args['label'],
736
-				'for'        => $args['id'],
737
-				'class'      => $args['label_class'] . " ",
738
-				'label_type' => $args['label_type'],
739
-				'label_col'  => $args['label_col']
740
-			);
741
-			$output .= self::label( $label_args );
742
-		}
743
-
744
-		// help text
745
-		if ( ! empty( $args['help_text'] ) ) {
746
-			$output .= AUI_Component_Helper::help_text( $args['help_text'] );
747
-		}
748
-
749
-		if ( ! $label_after ) {
750
-			$output = $label . $output;
751
-		}
752
-
753
-		// maybe horizontal label
754
-		if ( $args['label_type'] == 'horizontal' ) {
755
-			$output .= '</div>';
756
-		}
757
-
758
-
759
-		// wrap
760
-		if ( ! $args['no_wrap'] ) {
761
-			if ( ! empty( $args['form_group_class'] ) ) {
762
-				$fg_class = esc_attr( $args['form_group_class'] );
763
-			}else{
764
-				$fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
765
-			}
766
-			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : $fg_class;
767
-			$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
768
-			$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
769
-			$output           = self::wrap( array(
770
-				'content'         => $output,
771
-				'class'           => $wrap_class,
772
-				'element_require' => $args['element_require'],
773
-				'argument_id'     => $args['id'],
774
-				'wrap_attributes' => $args['wrap_attributes'],
775
-			) );
776
-		}
777
-
778
-
779
-		return $output;
780
-	}
781
-
782
-	/**
783
-	 * Build the component.
784
-	 *
785
-	 * @param array $args
786
-	 *
787
-	 * @return string The rendered component.
788
-	 */
789
-	public static function select( $args = array() ) {
790
-		global $aui_bs5;
791
-		$defaults = array(
792
-			'class'            => '',
793
-			'wrap_class'       => '',
794
-			'id'               => '',
795
-			'title'            => '',
796
-			'value'            => '',
797
-			// can be an array or a string
798
-			'required'         => false,
799
-			'label'            => '',
800
-			'label_after'      => false,
801
-			'label_type'       => '',
802
-			'label_col'        => '',
803
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
804
-			'label_class'      => '',
805
-			'help_text'        => '',
806
-			'placeholder'      => '',
807
-			'options'          => array(),
808
-			// array or string
809
-			'icon'             => '',
810
-			'multiple'         => false,
811
-			'select2'          => false,
812
-			'no_wrap'          => false,
813
-			'input_group_right' => '',
814
-			'input_group_left' => '',
815
-			'input_group_right_inside' => false, // forces the input group inside the input
816
-			'input_group_left_inside' => false, // forces the input group inside the input
817
-			'form_group_class'  => '',
818
-			'element_require'  => '',
819
-			// [%element_id%] == "1"
820
-			'extra_attributes' => array(),
821
-			// an array of extra attributes
822
-			'wrap_attributes'  => array(),
823
-		);
824
-
825
-		/**
826
-		 * Parse incoming $args into an array and merge it with $defaults
827
-		 */
828
-		$args   = wp_parse_args( $args, $defaults );
829
-		$output = '';
830
-
831
-		// for now lets hide floating labels
832
-		if ( $args['label_type'] == 'floating' ) {
833
-			$args['label_type'] = 'hidden';
834
-		}
835
-
836
-		// hidden label option needs to be empty
837
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
838
-
839
-
840
-		$label_after = $args['label_after'];
841
-
842
-		// floating labels need label after
843
-		if ( $args['label_type'] == 'floating' ) {
844
-			$label_after         = true;
845
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
846
-		}
847
-
848
-		// Maybe setup select2
849
-		$is_select2 = false;
850
-		if ( ! empty( $args['select2'] ) ) {
851
-			$args['class'] .= ' aui-select2';
852
-			$is_select2 = true;
853
-		} elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
854
-			$is_select2 = true;
855
-		}
856
-
857
-		// select2 tags
858
-		if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
859
-			$args['data-tags']             = 'true';
860
-			$args['data-token-separators'] = "[',']";
861
-			$args['multiple']              = true;
862
-		}
863
-
864
-		// select2 placeholder
865
-		if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
866
-			$args['data-placeholder'] = esc_attr( $args['placeholder'] );
867
-			$args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
868
-		}
869
-
870
-		// Set hidden input to save empty value for multiselect.
871
-		if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
872
-			$output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value="" data-ignore-rule/>';
873
-		}
874
-
875
-		// open/type
876
-		$output .= '<select ';
877
-
878
-		// style
879
-		if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
880
-			$output .= " style='width:100%;' ";
881
-		}
882
-
883
-		// element require
884
-		if ( ! empty( $args['element_require'] ) ) {
885
-			$output .= AUI_Component_Helper::element_require( $args['element_require'] );
886
-			$args['class'] .= " aui-conditional-field";
887
-		}
888
-
889
-		// class
890
-		$class = ! empty( $args['class'] ) ? $args['class'] : '';
891
-		$select_class = $aui_bs5 ? 'form-select ' : 'custom-select ';
892
-		$output .= AUI_Component_Helper::class_attr( $select_class . $class );
893
-
894
-		// name
895
-		if ( ! empty( $args['name'] ) ) {
896
-			$output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
897
-		}
898
-
899
-		// id
900
-		if ( ! empty( $args['id'] ) ) {
901
-			$output .= AUI_Component_Helper::id( $args['id'] );
902
-		}
903
-
904
-		// title
905
-		if ( ! empty( $args['title'] ) ) {
906
-			$output .= AUI_Component_Helper::title( $args['title'] );
907
-		}
908
-
909
-		// data-attributes
910
-		$output .= AUI_Component_Helper::data_attributes( $args );
911
-
912
-		// aria-attributes
913
-		$output .= AUI_Component_Helper::aria_attributes( $args );
914
-
915
-		// extra attributes
916
-		if ( ! empty( $args['extra_attributes'] ) ) {
917
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
918
-		}
919
-
920
-		// required
921
-		if ( ! empty( $args['required'] ) ) {
922
-			$output .= ' required ';
923
-		}
924
-
925
-		// multiple
926
-		if ( ! empty( $args['multiple'] ) ) {
927
-			$output .= ' multiple ';
928
-		}
929
-
930
-		// close opening tag
931
-		$output .= ' >';
932
-
933
-		// placeholder
934
-		if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
935
-			$output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
936
-		} elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
937
-			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
938
-		}
939
-
940
-		// Options
941
-		if ( ! empty( $args['options'] ) ) {
942
-
943
-			if ( ! is_array( $args['options'] ) ) {
944
-				$output .= $args['options']; // not the preferred way but an option
945
-			} else {
946
-				foreach ( $args['options'] as $val => $name ) {
947
-					$selected = '';
948
-					if ( is_array( $name ) ) {
949
-						if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
950
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
951
-
952
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
953
-						} else {
954
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
955
-							$option_value = isset( $name['value'] ) ? $name['value'] : '';
956
-							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
957
-							if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
958
-								$selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
959
-							} elseif ( ! empty( $args['value'] ) ) {
960
-								$selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
961
-							} elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) {
962
-								$selected = selected( $option_value, $args['value'], false );
963
-							}
964
-
965
-							$output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
966
-						}
967
-					} else {
968
-						if ( ! empty( $args['value'] ) ) {
969
-							if ( is_array( $args['value'] ) ) {
970
-								$selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
971
-							} elseif ( ! empty( $args['value'] ) ) {
972
-								$selected = selected( $args['value'], $val, false );
973
-							}
974
-						} elseif ( $args['value'] === $val ) {
975
-							$selected = selected( $args['value'], $val, false );
976
-						}
977
-						$output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
978
-					}
979
-				}
980
-			}
981
-
982
-		}
983
-
984
-		// closing tag
985
-		$output .= '</select>';
986
-
987
-		$label = '';
988
-		$help_text = '';
989
-		// label
990
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
991
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
992
-			$label_args = array(
993
-				'title'      => $args['label'],
994
-				'for'        => $args['id'],
995
-				'class'      => $args['label_class'] . " ",
996
-				'label_type' => $args['label_type'],
997
-				'label_col'  => $args['label_col']
998
-			);
999
-			$label = self::label( $label_args );
1000
-		}
1001
-
1002
-		// help text
1003
-		if ( ! empty( $args['help_text'] ) ) {
1004
-			$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
1005
-		}
1006
-
1007
-		// input group wraps
1008
-		if ( $args['input_group_left'] || $args['input_group_right'] ) {
1009
-			$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
1010
-			if ( $args['input_group_left'] ) {
1011
-				$output = self::wrap( array(
1012
-					'content'                 => $output,
1013
-					'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
1014
-					'input_group_left'        => $args['input_group_left'],
1015
-					'input_group_left_inside' => $args['input_group_left_inside']
1016
-				) );
1017
-			}
1018
-			if ( $args['input_group_right'] ) {
1019
-				$output = self::wrap( array(
1020
-					'content'                  => $output,
1021
-					'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
1022
-					'input_group_right'        => $args['input_group_right'],
1023
-					'input_group_right_inside' => $args['input_group_right_inside']
1024
-				) );
1025
-			}
1026
-
1027
-		}
1028
-
1029
-		if ( ! $label_after ) {
1030
-			$output .= $help_text;
1031
-		}
1032
-
1033
-
1034
-		if ( $args['label_type'] == 'horizontal' ) {
1035
-			$output = self::wrap( array(
1036
-				'content' => $output,
1037
-				'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
1038
-			) );
1039
-		}
1040
-
1041
-		if ( ! $label_after ) {
1042
-			$output = $label . $output;
1043
-		}
1044
-
1045
-		// maybe horizontal label
516
+            }
517
+
518
+
519
+            // close wrap
520
+            $output .= '</' . sanitize_html_class( $args['type'] ) . '>';
521
+
522
+
523
+        } else {
524
+            $output = $args['content'];
525
+        }
526
+
527
+        return $output;
528
+    }
529
+
530
+    /**
531
+     * Build the component.
532
+     *
533
+     * @param array $args
534
+     *
535
+     * @return string The rendered component.
536
+     */
537
+    public static function textarea( $args = array() ) {
538
+        global $aui_bs5;
539
+
540
+        $defaults = array(
541
+            'name'               => '',
542
+            'class'              => '',
543
+            'wrap_class'         => '',
544
+            'id'                 => '',
545
+            'placeholder'        => '',
546
+            'title'              => '',
547
+            'value'              => '',
548
+            'required'           => false,
549
+            'label'              => '',
550
+            'label_after'        => false,
551
+            'label_class'        => '',
552
+            'label_type'         => '',
553
+            'label_col'          => '',
554
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
555
+            'input_group_right'        => '',
556
+            'input_group_left'         => '',
557
+            'input_group_right_inside' => false,
558
+            'form_group_class'      => '',
559
+            'help_text'          => '',
560
+            'validation_text'    => '',
561
+            'validation_pattern' => '',
562
+            'no_wrap'            => false,
563
+            'rows'               => '',
564
+            'wysiwyg'            => false,
565
+            'allow_tags'         => false,
566
+            // Allow HTML tags
567
+            'element_require'    => '',
568
+            // [%element_id%] == "1"
569
+            'extra_attributes'   => array(),
570
+            // an array of extra attributes
571
+            'wrap_attributes'    => array(),
572
+        );
573
+
574
+        /**
575
+         * Parse incoming $args into an array and merge it with $defaults
576
+         */
577
+        $args   = wp_parse_args( $args, $defaults );
578
+        $output = '';
579
+        $label = '';
580
+
581
+        // hidden label option needs to be empty
582
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
583
+
584
+        // floating labels don't work with wysiwyg so set it as top
585
+        if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
586
+            $args['label_type'] = 'top';
587
+        }
588
+
589
+        $label_after = $args['label_after'];
590
+
591
+        // floating labels need label after
592
+        if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
593
+            $label_after         = true;
594
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
595
+        }
596
+
597
+        // label
598
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
599
+        } elseif ( ! empty( $args['label'] ) && ! $label_after ) {
600
+            $label_args = array(
601
+                'title'      => $args['label'],
602
+                'for'        => $args['id'],
603
+                'class'      => $args['label_class'] . " ",
604
+                'label_type' => $args['label_type'],
605
+                'label_col'  => $args['label_col']
606
+            );
607
+            $label .= self::label( $label_args );
608
+        }
609
+
610
+        // maybe horizontal label
611
+        if ( $args['label_type'] == 'horizontal' ) {
612
+            $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
613
+            $label .= '<div class="' . $input_col . '">';
614
+        }
615
+
616
+        if ( ! empty( $args['wysiwyg'] ) ) {
617
+            ob_start();
618
+            $content   = $args['value'];
619
+            $editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
620
+            $settings  = array(
621
+                'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
622
+                'quicktags'     => false,
623
+                'media_buttons' => false,
624
+                'editor_class'  => 'form-control',
625
+                'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
626
+                'teeny'         => true,
627
+            );
628
+
629
+            // maybe set settings if array
630
+            if ( is_array( $args['wysiwyg'] ) ) {
631
+                $settings = wp_parse_args( $args['wysiwyg'], $settings );
632
+            }
633
+
634
+            wp_editor( $content, $editor_id, $settings );
635
+            $output .= ob_get_clean();
636
+        } else {
637
+
638
+            // open
639
+            $output .= '<textarea ';
640
+
641
+            // name
642
+            if ( ! empty( $args['name'] ) ) {
643
+                $output .= ' name="' . esc_attr( $args['name'] ) . '" ';
644
+            }
645
+
646
+            // id
647
+            if ( ! empty( $args['id'] ) ) {
648
+                $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
649
+            }
650
+
651
+            // placeholder
652
+            if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
653
+                $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
654
+            }
655
+
656
+            // title
657
+            if ( ! empty( $args['title'] ) ) {
658
+                $output .= ' title="' . esc_attr( $args['title'] ) . '" ';
659
+            }
660
+
661
+            // validation text
662
+            if ( ! empty( $args['validation_text'] ) ) {
663
+                $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" ';
664
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
665
+            }
666
+
667
+            // validation_pattern
668
+            if ( ! empty( $args['validation_pattern'] ) ) {
669
+                $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
670
+            }
671
+
672
+            // required
673
+            if ( ! empty( $args['required'] ) ) {
674
+                $output .= ' required ';
675
+            }
676
+
677
+            // rows
678
+            if ( ! empty( $args['rows'] ) ) {
679
+                $output .= ' rows="' . absint( $args['rows'] ) . '" ';
680
+            }
681
+
682
+
683
+            // class
684
+            $class = ! empty( $args['class'] ) ? $args['class'] : '';
685
+            $output .= ' class="form-control ' . $class . '" ';
686
+
687
+            // extra attributes
688
+            if ( ! empty( $args['extra_attributes'] ) ) {
689
+                $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
690
+            }
691
+
692
+            // close tag
693
+            $output .= ' >';
694
+
695
+            // value
696
+            if ( ! empty( $args['value'] ) ) {
697
+                if ( ! empty( $args['allow_tags'] ) ) {
698
+                    $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
699
+                } else {
700
+                    $output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] );
701
+                }
702
+            }
703
+
704
+            // closing tag
705
+            $output .= '</textarea>';
706
+
707
+
708
+            // input group wraps
709
+            if ( $args['input_group_left'] || $args['input_group_right'] ) {
710
+                $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
711
+                if ( $args['input_group_left'] ) {
712
+                    $output = self::wrap( array(
713
+                        'content'                 => $output,
714
+                        'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
715
+                        'input_group_left'        => $args['input_group_left'],
716
+                        'input_group_left_inside' => $args['input_group_left_inside']
717
+                    ) );
718
+                }
719
+                if ( $args['input_group_right'] ) {
720
+                    $output = self::wrap( array(
721
+                        'content'                  => $output,
722
+                        'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
723
+                        'input_group_right'        => $args['input_group_right'],
724
+                        'input_group_right_inside' => $args['input_group_right_inside']
725
+                    ) );
726
+                }
727
+
728
+            }
729
+
730
+
731
+        }
732
+
733
+        if ( ! empty( $args['label'] ) && $label_after ) {
734
+            $label_args = array(
735
+                'title'      => $args['label'],
736
+                'for'        => $args['id'],
737
+                'class'      => $args['label_class'] . " ",
738
+                'label_type' => $args['label_type'],
739
+                'label_col'  => $args['label_col']
740
+            );
741
+            $output .= self::label( $label_args );
742
+        }
743
+
744
+        // help text
745
+        if ( ! empty( $args['help_text'] ) ) {
746
+            $output .= AUI_Component_Helper::help_text( $args['help_text'] );
747
+        }
748
+
749
+        if ( ! $label_after ) {
750
+            $output = $label . $output;
751
+        }
752
+
753
+        // maybe horizontal label
754
+        if ( $args['label_type'] == 'horizontal' ) {
755
+            $output .= '</div>';
756
+        }
757
+
758
+
759
+        // wrap
760
+        if ( ! $args['no_wrap'] ) {
761
+            if ( ! empty( $args['form_group_class'] ) ) {
762
+                $fg_class = esc_attr( $args['form_group_class'] );
763
+            }else{
764
+                $fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
765
+            }
766
+            $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : $fg_class;
767
+            $wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
768
+            $wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
769
+            $output           = self::wrap( array(
770
+                'content'         => $output,
771
+                'class'           => $wrap_class,
772
+                'element_require' => $args['element_require'],
773
+                'argument_id'     => $args['id'],
774
+                'wrap_attributes' => $args['wrap_attributes'],
775
+            ) );
776
+        }
777
+
778
+
779
+        return $output;
780
+    }
781
+
782
+    /**
783
+     * Build the component.
784
+     *
785
+     * @param array $args
786
+     *
787
+     * @return string The rendered component.
788
+     */
789
+    public static function select( $args = array() ) {
790
+        global $aui_bs5;
791
+        $defaults = array(
792
+            'class'            => '',
793
+            'wrap_class'       => '',
794
+            'id'               => '',
795
+            'title'            => '',
796
+            'value'            => '',
797
+            // can be an array or a string
798
+            'required'         => false,
799
+            'label'            => '',
800
+            'label_after'      => false,
801
+            'label_type'       => '',
802
+            'label_col'        => '',
803
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
804
+            'label_class'      => '',
805
+            'help_text'        => '',
806
+            'placeholder'      => '',
807
+            'options'          => array(),
808
+            // array or string
809
+            'icon'             => '',
810
+            'multiple'         => false,
811
+            'select2'          => false,
812
+            'no_wrap'          => false,
813
+            'input_group_right' => '',
814
+            'input_group_left' => '',
815
+            'input_group_right_inside' => false, // forces the input group inside the input
816
+            'input_group_left_inside' => false, // forces the input group inside the input
817
+            'form_group_class'  => '',
818
+            'element_require'  => '',
819
+            // [%element_id%] == "1"
820
+            'extra_attributes' => array(),
821
+            // an array of extra attributes
822
+            'wrap_attributes'  => array(),
823
+        );
824
+
825
+        /**
826
+         * Parse incoming $args into an array and merge it with $defaults
827
+         */
828
+        $args   = wp_parse_args( $args, $defaults );
829
+        $output = '';
830
+
831
+        // for now lets hide floating labels
832
+        if ( $args['label_type'] == 'floating' ) {
833
+            $args['label_type'] = 'hidden';
834
+        }
835
+
836
+        // hidden label option needs to be empty
837
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
838
+
839
+
840
+        $label_after = $args['label_after'];
841
+
842
+        // floating labels need label after
843
+        if ( $args['label_type'] == 'floating' ) {
844
+            $label_after         = true;
845
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
846
+        }
847
+
848
+        // Maybe setup select2
849
+        $is_select2 = false;
850
+        if ( ! empty( $args['select2'] ) ) {
851
+            $args['class'] .= ' aui-select2';
852
+            $is_select2 = true;
853
+        } elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
854
+            $is_select2 = true;
855
+        }
856
+
857
+        // select2 tags
858
+        if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
859
+            $args['data-tags']             = 'true';
860
+            $args['data-token-separators'] = "[',']";
861
+            $args['multiple']              = true;
862
+        }
863
+
864
+        // select2 placeholder
865
+        if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
866
+            $args['data-placeholder'] = esc_attr( $args['placeholder'] );
867
+            $args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
868
+        }
869
+
870
+        // Set hidden input to save empty value for multiselect.
871
+        if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
872
+            $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value="" data-ignore-rule/>';
873
+        }
874
+
875
+        // open/type
876
+        $output .= '<select ';
877
+
878
+        // style
879
+        if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
880
+            $output .= " style='width:100%;' ";
881
+        }
882
+
883
+        // element require
884
+        if ( ! empty( $args['element_require'] ) ) {
885
+            $output .= AUI_Component_Helper::element_require( $args['element_require'] );
886
+            $args['class'] .= " aui-conditional-field";
887
+        }
888
+
889
+        // class
890
+        $class = ! empty( $args['class'] ) ? $args['class'] : '';
891
+        $select_class = $aui_bs5 ? 'form-select ' : 'custom-select ';
892
+        $output .= AUI_Component_Helper::class_attr( $select_class . $class );
893
+
894
+        // name
895
+        if ( ! empty( $args['name'] ) ) {
896
+            $output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
897
+        }
898
+
899
+        // id
900
+        if ( ! empty( $args['id'] ) ) {
901
+            $output .= AUI_Component_Helper::id( $args['id'] );
902
+        }
903
+
904
+        // title
905
+        if ( ! empty( $args['title'] ) ) {
906
+            $output .= AUI_Component_Helper::title( $args['title'] );
907
+        }
908
+
909
+        // data-attributes
910
+        $output .= AUI_Component_Helper::data_attributes( $args );
911
+
912
+        // aria-attributes
913
+        $output .= AUI_Component_Helper::aria_attributes( $args );
914
+
915
+        // extra attributes
916
+        if ( ! empty( $args['extra_attributes'] ) ) {
917
+            $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
918
+        }
919
+
920
+        // required
921
+        if ( ! empty( $args['required'] ) ) {
922
+            $output .= ' required ';
923
+        }
924
+
925
+        // multiple
926
+        if ( ! empty( $args['multiple'] ) ) {
927
+            $output .= ' multiple ';
928
+        }
929
+
930
+        // close opening tag
931
+        $output .= ' >';
932
+
933
+        // placeholder
934
+        if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
935
+            $output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
936
+        } elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
937
+            $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
938
+        }
939
+
940
+        // Options
941
+        if ( ! empty( $args['options'] ) ) {
942
+
943
+            if ( ! is_array( $args['options'] ) ) {
944
+                $output .= $args['options']; // not the preferred way but an option
945
+            } else {
946
+                foreach ( $args['options'] as $val => $name ) {
947
+                    $selected = '';
948
+                    if ( is_array( $name ) ) {
949
+                        if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
950
+                            $option_label = isset( $name['label'] ) ? $name['label'] : '';
951
+
952
+                            $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
953
+                        } else {
954
+                            $option_label = isset( $name['label'] ) ? $name['label'] : '';
955
+                            $option_value = isset( $name['value'] ) ? $name['value'] : '';
956
+                            $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
957
+                            if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
958
+                                $selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
959
+                            } elseif ( ! empty( $args['value'] ) ) {
960
+                                $selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
961
+                            } elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) {
962
+                                $selected = selected( $option_value, $args['value'], false );
963
+                            }
964
+
965
+                            $output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
966
+                        }
967
+                    } else {
968
+                        if ( ! empty( $args['value'] ) ) {
969
+                            if ( is_array( $args['value'] ) ) {
970
+                                $selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
971
+                            } elseif ( ! empty( $args['value'] ) ) {
972
+                                $selected = selected( $args['value'], $val, false );
973
+                            }
974
+                        } elseif ( $args['value'] === $val ) {
975
+                            $selected = selected( $args['value'], $val, false );
976
+                        }
977
+                        $output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
978
+                    }
979
+                }
980
+            }
981
+
982
+        }
983
+
984
+        // closing tag
985
+        $output .= '</select>';
986
+
987
+        $label = '';
988
+        $help_text = '';
989
+        // label
990
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
991
+        } elseif ( ! empty( $args['label'] ) && ! $label_after ) {
992
+            $label_args = array(
993
+                'title'      => $args['label'],
994
+                'for'        => $args['id'],
995
+                'class'      => $args['label_class'] . " ",
996
+                'label_type' => $args['label_type'],
997
+                'label_col'  => $args['label_col']
998
+            );
999
+            $label = self::label( $label_args );
1000
+        }
1001
+
1002
+        // help text
1003
+        if ( ! empty( $args['help_text'] ) ) {
1004
+            $help_text = AUI_Component_Helper::help_text( $args['help_text'] );
1005
+        }
1006
+
1007
+        // input group wraps
1008
+        if ( $args['input_group_left'] || $args['input_group_right'] ) {
1009
+            $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
1010
+            if ( $args['input_group_left'] ) {
1011
+                $output = self::wrap( array(
1012
+                    'content'                 => $output,
1013
+                    'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
1014
+                    'input_group_left'        => $args['input_group_left'],
1015
+                    'input_group_left_inside' => $args['input_group_left_inside']
1016
+                ) );
1017
+            }
1018
+            if ( $args['input_group_right'] ) {
1019
+                $output = self::wrap( array(
1020
+                    'content'                  => $output,
1021
+                    'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
1022
+                    'input_group_right'        => $args['input_group_right'],
1023
+                    'input_group_right_inside' => $args['input_group_right_inside']
1024
+                ) );
1025
+            }
1026
+
1027
+        }
1028
+
1029
+        if ( ! $label_after ) {
1030
+            $output .= $help_text;
1031
+        }
1032
+
1033
+
1034
+        if ( $args['label_type'] == 'horizontal' ) {
1035
+            $output = self::wrap( array(
1036
+                'content' => $output,
1037
+                'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
1038
+            ) );
1039
+        }
1040
+
1041
+        if ( ! $label_after ) {
1042
+            $output = $label . $output;
1043
+        }
1044
+
1045
+        // maybe horizontal label
1046 1046
 //		if ( $args['label_type'] == 'horizontal' ) {
1047 1047
 //			$output .= '</div>';
1048 1048
 //		}
1049 1049
 
1050 1050
 
1051
-		// wrap
1052
-		if ( ! $args['no_wrap'] ) {
1053
-			if ( ! empty( $args['form_group_class'] ) ) {
1054
-				$fg_class = esc_attr( $args['form_group_class'] );
1055
-			}else{
1056
-				$fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
1057
-			}
1058
-			$wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class;
1059
-			$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1060
-			$output     = self::wrap( array(
1061
-				'content'         => $output,
1062
-				'class'           => $wrap_class,
1063
-				'element_require' => $args['element_require'],
1064
-				'argument_id'     => $args['id'],
1065
-				'wrap_attributes' => $args['wrap_attributes'],
1066
-			) );
1067
-		}
1068
-
1069
-
1070
-		return $output;
1071
-	}
1072
-
1073
-	/**
1074
-	 * Build the component.
1075
-	 *
1076
-	 * @param array $args
1077
-	 *
1078
-	 * @return string The rendered component.
1079
-	 */
1080
-	public static function radio( $args = array() ) {
1081
-		global $aui_bs5;
1082
-
1083
-		$defaults = array(
1084
-			'class'            => '',
1085
-			'wrap_class'       => '',
1086
-			'id'               => '',
1087
-			'title'            => '',
1088
-			'horizontal'       => false,
1089
-			// sets the lable horizontal
1090
-			'value'            => '',
1091
-			'label'            => '',
1092
-			'label_class'      => '',
1093
-			'label_type'       => '',
1094
-			'label_col'        => '',
1095
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
1096
-			'help_text'        => '',
1097
-			'inline'           => true,
1098
-			'required'         => false,
1099
-			'options'          => array(),
1100
-			'icon'             => '',
1101
-			'no_wrap'          => false,
1102
-			'element_require'  => '',
1103
-			// [%element_id%] == "1"
1104
-			'extra_attributes' => array(),
1105
-			// an array of extra attributes
1106
-			'wrap_attributes'  => array()
1107
-		);
1108
-
1109
-		/**
1110
-		 * Parse incoming $args into an array and merge it with $defaults
1111
-		 */
1112
-		$args = wp_parse_args( $args, $defaults );
1113
-
1114
-		// for now lets use horizontal for floating
1115
-		if ( $args['label_type'] == 'floating' ) {
1116
-			$args['label_type'] = 'horizontal';
1117
-		}
1118
-
1119
-		$label_args = array(
1120
-			'title'      => $args['label'],
1121
-			'class'      => $args['label_class'] . " pt-0 ",
1122
-			'label_type' => $args['label_type'],
1123
-			'label_col'  => $args['label_col']
1124
-		);
1125
-
1126
-		$output = '';
1127
-
1128
-
1129
-		// label before
1130
-		if ( ! empty( $args['label'] ) ) {
1131
-			$output .= self::label( $label_args, 'radio' );
1132
-		}
1133
-
1134
-		// maybe horizontal label
1135
-		if ( $args['label_type'] == 'horizontal' ) {
1136
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1137
-			$output .= '<div class="' . $input_col . '">';
1138
-		}
1139
-
1140
-		if ( ! empty( $args['options'] ) ) {
1141
-			$count = 0;
1142
-			foreach ( $args['options'] as $value => $label ) {
1143
-				$option_args            = $args;
1144
-				$option_args['value']   = $value;
1145
-				$option_args['label']   = $label;
1146
-				$option_args['checked'] = $value == $args['value'] ? true : false;
1147
-				$output .= self::radio_option( $option_args, $count );
1148
-				$count ++;
1149
-			}
1150
-		}
1151
-
1152
-		// help text
1153
-		$help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1154
-		$output .= $help_text;
1155
-
1156
-		// maybe horizontal label
1157
-		if ( $args['label_type'] == 'horizontal' ) {
1158
-			$output .= '</div>';
1159
-		}
1160
-
1161
-		// wrap
1162
-		$fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
1163
-		$wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class;
1164
-		$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1165
-		$output     = self::wrap( array(
1166
-			'content'         => $output,
1167
-			'class'           => $wrap_class,
1168
-			'element_require' => $args['element_require'],
1169
-			'argument_id'     => $args['id'],
1170
-			'wrap_attributes' => $args['wrap_attributes'],
1171
-		) );
1172
-
1173
-
1174
-		return $output;
1175
-	}
1176
-
1177
-	/**
1178
-	 * Build the component.
1179
-	 *
1180
-	 * @param array $args
1181
-	 *
1182
-	 * @return string The rendered component.
1183
-	 */
1184
-	public static function radio_option( $args = array(), $count = '' ) {
1185
-		$defaults = array(
1186
-			'class'            => '',
1187
-			'id'               => '',
1188
-			'title'            => '',
1189
-			'value'            => '',
1190
-			'required'         => false,
1191
-			'inline'           => true,
1192
-			'label'            => '',
1193
-			'options'          => array(),
1194
-			'icon'             => '',
1195
-			'no_wrap'          => false,
1196
-			'extra_attributes' => array() // an array of extra attributes
1197
-		);
1198
-
1199
-		/**
1200
-		 * Parse incoming $args into an array and merge it with $defaults
1201
-		 */
1202
-		$args = wp_parse_args( $args, $defaults );
1203
-
1204
-		$output = '';
1205
-
1206
-		// open/type
1207
-		$output .= '<input type="radio"';
1208
-
1209
-		// class
1210
-		$output .= ' class="form-check-input" ';
1211
-
1212
-		// name
1213
-		if ( ! empty( $args['name'] ) ) {
1214
-			$output .= AUI_Component_Helper::name( $args['name'] );
1215
-		}
1216
-
1217
-		// id
1218
-		if ( ! empty( $args['id'] ) ) {
1219
-			$output .= AUI_Component_Helper::id( $args['id'] . $count );
1220
-		}
1221
-
1222
-		// title
1223
-		if ( ! empty( $args['title'] ) ) {
1224
-			$output .= AUI_Component_Helper::title( $args['title'] );
1225
-		}
1226
-
1227
-		// value
1228
-		if ( isset( $args['value'] ) ) {
1229
-			$output .= AUI_Component_Helper::value( $args['value'] );
1230
-		}
1231
-
1232
-		// checked, for radio and checkboxes
1233
-		if ( $args['checked'] ) {
1234
-			$output .= ' checked ';
1235
-		}
1236
-
1237
-		// data-attributes
1238
-		$output .= AUI_Component_Helper::data_attributes( $args );
1239
-
1240
-		// aria-attributes
1241
-		$output .= AUI_Component_Helper::aria_attributes( $args );
1242
-
1243
-		// extra attributes
1244
-		if ( ! empty( $args['extra_attributes'] ) ) {
1245
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1246
-		}
1247
-
1248
-		// required
1249
-		if ( ! empty( $args['required'] ) ) {
1250
-			$output .= ' required ';
1251
-		}
1252
-
1253
-		// close opening tag
1254
-		$output .= ' >';
1255
-
1256
-		// label
1257
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1258
-		} elseif ( ! empty( $args['label'] ) ) {
1259
-			$output .= self::label( array(
1260
-				'title' => $args['label'],
1261
-				'for'   => $args['id'] . $count,
1262
-				'class' => 'form-check-label'
1263
-			), 'radio' );
1264
-		}
1265
-
1266
-		// wrap
1267
-		if ( ! $args['no_wrap'] ) {
1268
-			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1269
-
1270
-			// Unique wrap class
1271
-			$uniq_class = 'fwrap';
1272
-			if ( ! empty( $args['name'] ) ) {
1273
-				$uniq_class .= '-' . $args['name'];
1274
-			} else if ( ! empty( $args['id'] ) ) {
1275
-				$uniq_class .= '-' . $args['id'];
1276
-			}
1277
-
1278
-			if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1279
-				$uniq_class .= '-' . $args['value'];
1280
-			} else {
1281
-				$uniq_class .= '-' . $count;
1282
-			}
1283
-			$wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1284
-
1285
-			$output = self::wrap( array(
1286
-				'content' => $output,
1287
-				'class'   => $wrap_class
1288
-			) );
1289
-		}
1290
-
1291
-		return $output;
1292
-	}
1051
+        // wrap
1052
+        if ( ! $args['no_wrap'] ) {
1053
+            if ( ! empty( $args['form_group_class'] ) ) {
1054
+                $fg_class = esc_attr( $args['form_group_class'] );
1055
+            }else{
1056
+                $fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
1057
+            }
1058
+            $wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class;
1059
+            $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1060
+            $output     = self::wrap( array(
1061
+                'content'         => $output,
1062
+                'class'           => $wrap_class,
1063
+                'element_require' => $args['element_require'],
1064
+                'argument_id'     => $args['id'],
1065
+                'wrap_attributes' => $args['wrap_attributes'],
1066
+            ) );
1067
+        }
1068
+
1069
+
1070
+        return $output;
1071
+    }
1072
+
1073
+    /**
1074
+     * Build the component.
1075
+     *
1076
+     * @param array $args
1077
+     *
1078
+     * @return string The rendered component.
1079
+     */
1080
+    public static function radio( $args = array() ) {
1081
+        global $aui_bs5;
1082
+
1083
+        $defaults = array(
1084
+            'class'            => '',
1085
+            'wrap_class'       => '',
1086
+            'id'               => '',
1087
+            'title'            => '',
1088
+            'horizontal'       => false,
1089
+            // sets the lable horizontal
1090
+            'value'            => '',
1091
+            'label'            => '',
1092
+            'label_class'      => '',
1093
+            'label_type'       => '',
1094
+            'label_col'        => '',
1095
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
1096
+            'help_text'        => '',
1097
+            'inline'           => true,
1098
+            'required'         => false,
1099
+            'options'          => array(),
1100
+            'icon'             => '',
1101
+            'no_wrap'          => false,
1102
+            'element_require'  => '',
1103
+            // [%element_id%] == "1"
1104
+            'extra_attributes' => array(),
1105
+            // an array of extra attributes
1106
+            'wrap_attributes'  => array()
1107
+        );
1108
+
1109
+        /**
1110
+         * Parse incoming $args into an array and merge it with $defaults
1111
+         */
1112
+        $args = wp_parse_args( $args, $defaults );
1113
+
1114
+        // for now lets use horizontal for floating
1115
+        if ( $args['label_type'] == 'floating' ) {
1116
+            $args['label_type'] = 'horizontal';
1117
+        }
1118
+
1119
+        $label_args = array(
1120
+            'title'      => $args['label'],
1121
+            'class'      => $args['label_class'] . " pt-0 ",
1122
+            'label_type' => $args['label_type'],
1123
+            'label_col'  => $args['label_col']
1124
+        );
1125
+
1126
+        $output = '';
1127
+
1128
+
1129
+        // label before
1130
+        if ( ! empty( $args['label'] ) ) {
1131
+            $output .= self::label( $label_args, 'radio' );
1132
+        }
1133
+
1134
+        // maybe horizontal label
1135
+        if ( $args['label_type'] == 'horizontal' ) {
1136
+            $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1137
+            $output .= '<div class="' . $input_col . '">';
1138
+        }
1139
+
1140
+        if ( ! empty( $args['options'] ) ) {
1141
+            $count = 0;
1142
+            foreach ( $args['options'] as $value => $label ) {
1143
+                $option_args            = $args;
1144
+                $option_args['value']   = $value;
1145
+                $option_args['label']   = $label;
1146
+                $option_args['checked'] = $value == $args['value'] ? true : false;
1147
+                $output .= self::radio_option( $option_args, $count );
1148
+                $count ++;
1149
+            }
1150
+        }
1151
+
1152
+        // help text
1153
+        $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1154
+        $output .= $help_text;
1155
+
1156
+        // maybe horizontal label
1157
+        if ( $args['label_type'] == 'horizontal' ) {
1158
+            $output .= '</div>';
1159
+        }
1160
+
1161
+        // wrap
1162
+        $fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
1163
+        $wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class;
1164
+        $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1165
+        $output     = self::wrap( array(
1166
+            'content'         => $output,
1167
+            'class'           => $wrap_class,
1168
+            'element_require' => $args['element_require'],
1169
+            'argument_id'     => $args['id'],
1170
+            'wrap_attributes' => $args['wrap_attributes'],
1171
+        ) );
1172
+
1173
+
1174
+        return $output;
1175
+    }
1176
+
1177
+    /**
1178
+     * Build the component.
1179
+     *
1180
+     * @param array $args
1181
+     *
1182
+     * @return string The rendered component.
1183
+     */
1184
+    public static function radio_option( $args = array(), $count = '' ) {
1185
+        $defaults = array(
1186
+            'class'            => '',
1187
+            'id'               => '',
1188
+            'title'            => '',
1189
+            'value'            => '',
1190
+            'required'         => false,
1191
+            'inline'           => true,
1192
+            'label'            => '',
1193
+            'options'          => array(),
1194
+            'icon'             => '',
1195
+            'no_wrap'          => false,
1196
+            'extra_attributes' => array() // an array of extra attributes
1197
+        );
1198
+
1199
+        /**
1200
+         * Parse incoming $args into an array and merge it with $defaults
1201
+         */
1202
+        $args = wp_parse_args( $args, $defaults );
1203
+
1204
+        $output = '';
1205
+
1206
+        // open/type
1207
+        $output .= '<input type="radio"';
1208
+
1209
+        // class
1210
+        $output .= ' class="form-check-input" ';
1211
+
1212
+        // name
1213
+        if ( ! empty( $args['name'] ) ) {
1214
+            $output .= AUI_Component_Helper::name( $args['name'] );
1215
+        }
1216
+
1217
+        // id
1218
+        if ( ! empty( $args['id'] ) ) {
1219
+            $output .= AUI_Component_Helper::id( $args['id'] . $count );
1220
+        }
1221
+
1222
+        // title
1223
+        if ( ! empty( $args['title'] ) ) {
1224
+            $output .= AUI_Component_Helper::title( $args['title'] );
1225
+        }
1226
+
1227
+        // value
1228
+        if ( isset( $args['value'] ) ) {
1229
+            $output .= AUI_Component_Helper::value( $args['value'] );
1230
+        }
1231
+
1232
+        // checked, for radio and checkboxes
1233
+        if ( $args['checked'] ) {
1234
+            $output .= ' checked ';
1235
+        }
1236
+
1237
+        // data-attributes
1238
+        $output .= AUI_Component_Helper::data_attributes( $args );
1239
+
1240
+        // aria-attributes
1241
+        $output .= AUI_Component_Helper::aria_attributes( $args );
1242
+
1243
+        // extra attributes
1244
+        if ( ! empty( $args['extra_attributes'] ) ) {
1245
+            $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1246
+        }
1247
+
1248
+        // required
1249
+        if ( ! empty( $args['required'] ) ) {
1250
+            $output .= ' required ';
1251
+        }
1252
+
1253
+        // close opening tag
1254
+        $output .= ' >';
1255
+
1256
+        // label
1257
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1258
+        } elseif ( ! empty( $args['label'] ) ) {
1259
+            $output .= self::label( array(
1260
+                'title' => $args['label'],
1261
+                'for'   => $args['id'] . $count,
1262
+                'class' => 'form-check-label'
1263
+            ), 'radio' );
1264
+        }
1265
+
1266
+        // wrap
1267
+        if ( ! $args['no_wrap'] ) {
1268
+            $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1269
+
1270
+            // Unique wrap class
1271
+            $uniq_class = 'fwrap';
1272
+            if ( ! empty( $args['name'] ) ) {
1273
+                $uniq_class .= '-' . $args['name'];
1274
+            } else if ( ! empty( $args['id'] ) ) {
1275
+                $uniq_class .= '-' . $args['id'];
1276
+            }
1277
+
1278
+            if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1279
+                $uniq_class .= '-' . $args['value'];
1280
+            } else {
1281
+                $uniq_class .= '-' . $count;
1282
+            }
1283
+            $wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1284
+
1285
+            $output = self::wrap( array(
1286
+                'content' => $output,
1287
+                'class'   => $wrap_class
1288
+            ) );
1289
+        }
1290
+
1291
+        return $output;
1292
+    }
1293 1293
 
1294 1294
 }
1295 1295
\ No newline at end of file
Please login to merge, or discard this patch.
wp-ayecode-ui/includes/components/class-aui-component-pagination.php 1 patch
Indentation   +108 added lines, -108 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,112 +11,112 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Pagination {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function get( $args = array() ) {
22
-		global $wp_query, $aui_bs5;
23
-
24
-		$defaults = array(
25
-			'class'              => '',
26
-			'mid_size'           => 2,
27
-			'prev_text'          => '<i class="fas fa-chevron-left"></i>',
28
-			'next_text'          => '<i class="fas fa-chevron-right"></i>',
29
-			'screen_reader_text' => __( 'Posts navigation', 'ayecode-connect' ),
30
-			'before_paging'      => '',
31
-			'after_paging'       => '',
32
-			'type'               => 'array',
33
-			'total'              => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1,
34
-			'links'              => array(), // an array of links if using custom links, this includes the a tag.
35
-			'rounded_style'      => false,
36
-			'custom_next_text'   => '', // Custom next page text
37
-			'custom_prev_text'   => '', // Custom prev page text
38
-		);
39
-
40
-		/**
41
-		 * Parse incoming $args into an array and merge it with $defaults
42
-		 */
43
-		$args = wp_parse_args( $args, $defaults );
44
-
45
-		$output = '';
46
-
47
-		// Don't print empty markup if there's only one page.
48
-		if ( $args['total'] > 1 ) {
49
-			// Set up paginated links.
50
-			$links = !empty(  $args['links'] ) ? $args['links'] :  paginate_links( $args );
51
-
52
-			$class = !empty($args['class']) ? $args['class'] : '';
53
-
54
-			$custom_prev_link = '';
55
-			$custom_next_link = '';
56
-
57
-			// make the output bootstrap ready
58
-			$links_html = "<ul class='pagination m-0 p-0 $class'>";
59
-			if ( ! empty( $links ) ) {
60
-				foreach ( $links as $link ) {
61
-					$_link = $link;
62
-
63
-					if ( $aui_bs5 ) {
64
-						$link_class = $args['rounded_style'] ? 'page-link badge rounded-pill border-0 mx-1 fs-base text-dark link-primary' : 'page-link';
65
-						$link_class_active = $args['rounded_style'] ? ' current active fw-bold badge rounded-pill' : ' current active';
66
-						$links_html .= "<li class='page-item mx-0'>";
67
-						$link = str_replace( array( "page-numbers", " current" ), array( $link_class, $link_class_active ), $link );
68
-						$link = str_replace( 'text-dark link-primary current', 'current', $link );
69
-						$links_html .=  $link;
70
-						$links_html .= "</li>";
71
-					} else {
72
-						$active = strpos( $link, 'current' ) !== false ? 'active' : '';
73
-						$links_html .= "<li class='page-item $active'>";
74
-						$links_html .= str_replace( "page-numbers", "page-link", $link );
75
-						$links_html .= "</li>";
76
-					}
77
-
78
-					if ( strpos( $_link, 'next page-numbers' ) || strpos( $_link, 'prev page-numbers' ) ) {
79
-						$link = str_replace( array( "page-numbers", " current" ), array( 'btn btn-outline-primary rounded' . ( $args['rounded_style'] ? '-pill' : '' ) . ' mx-1 fs-base text-dark link-primary', ' current active fw-bold badge rounded-pill' ), $_link );
80
-						$link = str_replace( 'text-dark link-primary current', 'current', $link );
81
-
82
-						if ( strpos( $_link, 'next page-numbers' ) && ! empty( $args['custom_next_text'] ) ) {
83
-							$custom_next_link = str_replace( $args['next_text'], $args['custom_next_text'], $link );
84
-						} else if ( strpos( $_link, 'prev page-numbers' ) && ! empty( $args['custom_prev_text'] ) ) {
85
-							$custom_prev_link = str_replace( $args['prev_text'], $args['custom_prev_text'], $link );
86
-						}
87
-					}
88
-				}
89
-			}
90
-			$links_html .= "</ul>";
91
-
92
-			if ( $links ) {
93
-				$output .= '<section class="px-0 py-2 w-100">';
94
-				$output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] );
95
-				$output .= '</section>';
96
-			}
97
-
98
-			$output = str_replace( "screen-reader-text", "screen-reader-text sr-only", $output );
99
-			$output = str_replace( "nav-links", "aui-nav-links", $output );
100
-		}
101
-
102
-		if ( $output ) {
103
-			if ( $custom_next_link || $custom_prev_link ) {
104
-				$total   = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
105
-				$current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1;
106
-
107
-				$output = '<div class="row d-flex align-items-center justify-content-between"><div class="col text-start">' . $custom_prev_link . '</div><div class="col text-center d-none d-md-block">' . $output . '</div><div class="col text-center d-md-none">' . $current . '/' . $args['total'] . '</div><div class="col text-end">' . $custom_next_link . '</div></div>';
108
-			}
109
-
110
-			if ( ! empty( $args['before_paging'] ) ) {
111
-				$output = $args['before_paging'] . $output;
112
-			}
113
-
114
-			if ( ! empty( $args['after_paging'] ) ) {
115
-				$output = $output . $args['after_paging'];
116
-			}
117
-		}
118
-
119
-		return $output;
120
-	}
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function get( $args = array() ) {
22
+        global $wp_query, $aui_bs5;
23
+
24
+        $defaults = array(
25
+            'class'              => '',
26
+            'mid_size'           => 2,
27
+            'prev_text'          => '<i class="fas fa-chevron-left"></i>',
28
+            'next_text'          => '<i class="fas fa-chevron-right"></i>',
29
+            'screen_reader_text' => __( 'Posts navigation', 'ayecode-connect' ),
30
+            'before_paging'      => '',
31
+            'after_paging'       => '',
32
+            'type'               => 'array',
33
+            'total'              => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1,
34
+            'links'              => array(), // an array of links if using custom links, this includes the a tag.
35
+            'rounded_style'      => false,
36
+            'custom_next_text'   => '', // Custom next page text
37
+            'custom_prev_text'   => '', // Custom prev page text
38
+        );
39
+
40
+        /**
41
+         * Parse incoming $args into an array and merge it with $defaults
42
+         */
43
+        $args = wp_parse_args( $args, $defaults );
44
+
45
+        $output = '';
46
+
47
+        // Don't print empty markup if there's only one page.
48
+        if ( $args['total'] > 1 ) {
49
+            // Set up paginated links.
50
+            $links = !empty(  $args['links'] ) ? $args['links'] :  paginate_links( $args );
51
+
52
+            $class = !empty($args['class']) ? $args['class'] : '';
53
+
54
+            $custom_prev_link = '';
55
+            $custom_next_link = '';
56
+
57
+            // make the output bootstrap ready
58
+            $links_html = "<ul class='pagination m-0 p-0 $class'>";
59
+            if ( ! empty( $links ) ) {
60
+                foreach ( $links as $link ) {
61
+                    $_link = $link;
62
+
63
+                    if ( $aui_bs5 ) {
64
+                        $link_class = $args['rounded_style'] ? 'page-link badge rounded-pill border-0 mx-1 fs-base text-dark link-primary' : 'page-link';
65
+                        $link_class_active = $args['rounded_style'] ? ' current active fw-bold badge rounded-pill' : ' current active';
66
+                        $links_html .= "<li class='page-item mx-0'>";
67
+                        $link = str_replace( array( "page-numbers", " current" ), array( $link_class, $link_class_active ), $link );
68
+                        $link = str_replace( 'text-dark link-primary current', 'current', $link );
69
+                        $links_html .=  $link;
70
+                        $links_html .= "</li>";
71
+                    } else {
72
+                        $active = strpos( $link, 'current' ) !== false ? 'active' : '';
73
+                        $links_html .= "<li class='page-item $active'>";
74
+                        $links_html .= str_replace( "page-numbers", "page-link", $link );
75
+                        $links_html .= "</li>";
76
+                    }
77
+
78
+                    if ( strpos( $_link, 'next page-numbers' ) || strpos( $_link, 'prev page-numbers' ) ) {
79
+                        $link = str_replace( array( "page-numbers", " current" ), array( 'btn btn-outline-primary rounded' . ( $args['rounded_style'] ? '-pill' : '' ) . ' mx-1 fs-base text-dark link-primary', ' current active fw-bold badge rounded-pill' ), $_link );
80
+                        $link = str_replace( 'text-dark link-primary current', 'current', $link );
81
+
82
+                        if ( strpos( $_link, 'next page-numbers' ) && ! empty( $args['custom_next_text'] ) ) {
83
+                            $custom_next_link = str_replace( $args['next_text'], $args['custom_next_text'], $link );
84
+                        } else if ( strpos( $_link, 'prev page-numbers' ) && ! empty( $args['custom_prev_text'] ) ) {
85
+                            $custom_prev_link = str_replace( $args['prev_text'], $args['custom_prev_text'], $link );
86
+                        }
87
+                    }
88
+                }
89
+            }
90
+            $links_html .= "</ul>";
91
+
92
+            if ( $links ) {
93
+                $output .= '<section class="px-0 py-2 w-100">';
94
+                $output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] );
95
+                $output .= '</section>';
96
+            }
97
+
98
+            $output = str_replace( "screen-reader-text", "screen-reader-text sr-only", $output );
99
+            $output = str_replace( "nav-links", "aui-nav-links", $output );
100
+        }
101
+
102
+        if ( $output ) {
103
+            if ( $custom_next_link || $custom_prev_link ) {
104
+                $total   = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
105
+                $current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1;
106
+
107
+                $output = '<div class="row d-flex align-items-center justify-content-between"><div class="col text-start">' . $custom_prev_link . '</div><div class="col text-center d-none d-md-block">' . $output . '</div><div class="col text-center d-md-none">' . $current . '/' . $args['total'] . '</div><div class="col text-end">' . $custom_next_link . '</div></div>';
108
+            }
109
+
110
+            if ( ! empty( $args['before_paging'] ) ) {
111
+                $output = $args['before_paging'] . $output;
112
+            }
113
+
114
+            if ( ! empty( $args['after_paging'] ) ) {
115
+                $output = $output . $args['after_paging'];
116
+            }
117
+        }
118
+
119
+        return $output;
120
+    }
121 121
 
122 122
 }
123 123
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/includes/inc/bs5-js.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1001,8 +1001,8 @@
 block discarded – undo
1001 1001
     aui_flip_color_scheme_on_scroll();
1002 1002
 
1003 1003
 	<?php
1004
-	// FSE tweaks.
1005
-	if(!empty($_REQUEST['postType'])){ ?>
1004
+    // FSE tweaks.
1005
+    if(!empty($_REQUEST['postType'])){ ?>
1006 1006
     function aui_fse_set_data_scroll() {
1007 1007
         console.log('init scroll');
1008 1008
         let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas");
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/includes/ayecode-ui-settings.php 1 patch
Indentation   +1938 added lines, -1938 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * Bail if we are not in WP.
14 14
  */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -21,480 +21,480 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'AyeCode_UI_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class AyeCode_UI_Settings
28
-	 * @ver 1.0.0
29
-	 * @todo decide how to implement textdomain
30
-	 */
31
-	class AyeCode_UI_Settings {
32
-
33
-		/**
34
-		 * Class version version.
35
-		 *
36
-		 * @var string
37
-		 */
38
-		public $version = '0.2.6';
39
-
40
-		/**
41
-		 * Class textdomain.
42
-		 *
43
-		 * @var string
44
-		 */
45
-		public $textdomain = 'aui';
46
-
47
-		/**
48
-		 * Latest version of Bootstrap at time of publish published.
49
-		 *
50
-		 * @var string
51
-		 */
52
-		public $latest = "5.2.2";
53
-
54
-		/**
55
-		 * Current version of select2 being used.
56
-		 *
57
-		 * @var string
58
-		 */
59
-		public $select2_version = "4.0.11";
60
-
61
-		/**
62
-		 * The title.
63
-		 *
64
-		 * @var string
65
-		 */
66
-		public $name = 'AyeCode UI';
67
-
68
-		/**
69
-		 * The relative url to the assets.
70
-		 *
71
-		 * @var string
72
-		 */
73
-		public $url = '';
74
-
75
-		/**
76
-		 * Holds the settings values.
77
-		 *
78
-		 * @var array
79
-		 */
80
-		private $settings;
81
-
82
-		/**
83
-		 * AyeCode_UI_Settings instance.
84
-		 *
85
-		 * @access private
86
-		 * @since  1.0.0
87
-		 * @var    AyeCode_UI_Settings There can be only one!
88
-		 */
89
-		private static $instance = null;
90
-
91
-
92
-		/**
93
-		 * Main AyeCode_UI_Settings Instance.
94
-		 *
95
-		 * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded.
96
-		 *
97
-		 * @since 1.0.0
98
-		 * @static
99
-		 * @return AyeCode_UI_Settings - Main instance.
100
-		 */
101
-		public static function instance() {
102
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
103
-
104
-				self::$instance = new AyeCode_UI_Settings;
105
-
106
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
107
-
108
-				if ( is_admin() ) {
109
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
110
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
111
-
112
-					// Maybe show example page
113
-					add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
114
-
115
-					if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
116
-						add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 );
117
-					}
118
-				}
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class AyeCode_UI_Settings
28
+     * @ver 1.0.0
29
+     * @todo decide how to implement textdomain
30
+     */
31
+    class AyeCode_UI_Settings {
32
+
33
+        /**
34
+         * Class version version.
35
+         *
36
+         * @var string
37
+         */
38
+        public $version = '0.2.6';
39
+
40
+        /**
41
+         * Class textdomain.
42
+         *
43
+         * @var string
44
+         */
45
+        public $textdomain = 'aui';
46
+
47
+        /**
48
+         * Latest version of Bootstrap at time of publish published.
49
+         *
50
+         * @var string
51
+         */
52
+        public $latest = "5.2.2";
53
+
54
+        /**
55
+         * Current version of select2 being used.
56
+         *
57
+         * @var string
58
+         */
59
+        public $select2_version = "4.0.11";
60
+
61
+        /**
62
+         * The title.
63
+         *
64
+         * @var string
65
+         */
66
+        public $name = 'AyeCode UI';
67
+
68
+        /**
69
+         * The relative url to the assets.
70
+         *
71
+         * @var string
72
+         */
73
+        public $url = '';
74
+
75
+        /**
76
+         * Holds the settings values.
77
+         *
78
+         * @var array
79
+         */
80
+        private $settings;
81
+
82
+        /**
83
+         * AyeCode_UI_Settings instance.
84
+         *
85
+         * @access private
86
+         * @since  1.0.0
87
+         * @var    AyeCode_UI_Settings There can be only one!
88
+         */
89
+        private static $instance = null;
90
+
91
+
92
+        /**
93
+         * Main AyeCode_UI_Settings Instance.
94
+         *
95
+         * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded.
96
+         *
97
+         * @since 1.0.0
98
+         * @static
99
+         * @return AyeCode_UI_Settings - Main instance.
100
+         */
101
+        public static function instance() {
102
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
103
+
104
+                self::$instance = new AyeCode_UI_Settings;
105
+
106
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
107
+
108
+                if ( is_admin() ) {
109
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
110
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
111
+
112
+                    // Maybe show example page
113
+                    add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
114
+
115
+                    if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
116
+                        add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 );
117
+                    }
118
+                }
119 119
 
120
-				add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
120
+                add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
121 121
 
122
-				do_action( 'ayecode_ui_settings_loaded' );
123
-			}
122
+                do_action( 'ayecode_ui_settings_loaded' );
123
+            }
124 124
 
125
-			return self::$instance;
126
-		}
125
+            return self::$instance;
126
+        }
127 127
 
128
-		/**
129
-		 * Add custom colors to the color selector.
130
-		 *
131
-		 * @param $theme_colors
132
-		 * @param $include_outlines
133
-		 * @param $include_branding
134
-		 *
135
-		 * @return mixed
136
-		 */
137
-		public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){
128
+        /**
129
+         * Add custom colors to the color selector.
130
+         *
131
+         * @param $theme_colors
132
+         * @param $include_outlines
133
+         * @param $include_branding
134
+         *
135
+         * @return mixed
136
+         */
137
+        public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){
138 138
 
139 139
 
140
-			$setting = wp_get_global_settings();
140
+            $setting = wp_get_global_settings();
141 141
 
142
-			if(!empty($setting['color']['palette']['custom'])){
143
-				foreach($setting['color']['palette']['custom'] as $color){
144
-					$theme_colors[$color['slug']] = esc_attr($color['name']);
145
-				}
146
-			}
147
-
148
-			return $theme_colors;
149
-		}
150
-
151
-		/**
152
-		 * Setup some constants.
153
-		 */
154
-		public function constants(){
155
-			define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" );
156
-			define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' );
157
-			define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' );
158
-			define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' );
159
-			define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' );
160
-			define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' );
161
-			define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' );
162
-			define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' );
163
-			define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' );
164
-			define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' );
165
-			define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' );
166
-			define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' );
167
-			define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' );
168
-			define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' );
169
-			define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' );
170
-			define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' );
171
-
172
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
173
-				define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL );
174
-			}
175
-			if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) {
176
-				define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL );
177
-			}
178
-			if ( ! defined( 'AUI_INFO_COLOR' ) ) {
179
-				define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL );
180
-			}
181
-			if ( ! defined( 'AUI_WARNING_COLOR' ) ) {
182
-				define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL );
183
-			}
184
-			if ( ! defined( 'AUI_DANGER_COLOR' ) ) {
185
-				define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL );
186
-			}
187
-			if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) {
188
-				define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL );
189
-			}
190
-			if ( ! defined( 'AUI_LIGHT_COLOR' ) ) {
191
-				define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL );
192
-			}
193
-			if ( ! defined( 'AUI_DARK_COLOR' ) ) {
194
-				define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL );
195
-			}
196
-			if ( ! defined( 'AUI_WHITE_COLOR' ) ) {
197
-				define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL );
198
-			}
199
-			if ( ! defined( 'AUI_PURPLE_COLOR' ) ) {
200
-				define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL );
201
-			}
202
-			if ( ! defined( 'AUI_SALMON_COLOR' ) ) {
203
-				define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL );
204
-			}
205
-			if ( ! defined( 'AUI_CYAN_COLOR' ) ) {
206
-				define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL );
207
-			}
208
-			if ( ! defined( 'AUI_GRAY_COLOR' ) ) {
209
-				define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL );
210
-			}
211
-			if ( ! defined( 'AUI_INDIGO_COLOR' ) ) {
212
-				define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL );
213
-			}
214
-			if ( ! defined( 'AUI_ORANGE_COLOR' ) ) {
215
-				define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL );
216
-			}
217
-			if ( ! defined( 'AUI_BLACK_COLOR' ) ) {
218
-				define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL );
219
-			}
220
-
221
-		}
222
-
223
-		public static function get_colors( $original = false){
224
-
225
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
226
-				return array();
227
-			}
228
-			if ( $original ) {
229
-				return array(
230
-					'primary'   => AUI_PRIMARY_COLOR_ORIGINAL,
231
-					'secondary' => AUI_SECONDARY_COLOR_ORIGINAL,
232
-					'info'      => AUI_INFO_COLOR_ORIGINAL,
233
-					'warning'   => AUI_WARNING_COLOR_ORIGINAL,
234
-					'danger'    => AUI_DANGER_COLOR_ORIGINAL,
235
-					'success'   => AUI_SUCCESS_COLOR_ORIGINAL,
236
-					'light'     => AUI_LIGHT_COLOR_ORIGINAL,
237
-					'dark'      => AUI_DARK_COLOR_ORIGINAL,
238
-					'white'     => AUI_WHITE_COLOR_ORIGINAL,
239
-					'purple'    => AUI_PURPLE_COLOR_ORIGINAL,
240
-					'salmon'    => AUI_SALMON_COLOR_ORIGINAL,
241
-					'cyan'      => AUI_CYAN_COLOR_ORIGINAL,
242
-					'gray'      => AUI_GRAY_COLOR_ORIGINAL,
243
-					'indigo'    => AUI_INDIGO_COLOR_ORIGINAL,
244
-					'orange'    => AUI_ORANGE_COLOR_ORIGINAL,
245
-					'black'     => AUI_BLACK_COLOR_ORIGINAL,
246
-				);
247
-			}
248
-
249
-			return array(
250
-				'primary'   => AUI_PRIMARY_COLOR,
251
-				'secondary' => AUI_SECONDARY_COLOR,
252
-				'info'      => AUI_INFO_COLOR,
253
-				'warning'   => AUI_WARNING_COLOR,
254
-				'danger'    => AUI_DANGER_COLOR,
255
-				'success'   => AUI_SUCCESS_COLOR,
256
-				'light'     => AUI_LIGHT_COLOR,
257
-				'dark'      => AUI_DARK_COLOR,
258
-				'white'     => AUI_WHITE_COLOR,
259
-				'purple'    => AUI_PURPLE_COLOR,
260
-				'salmon'    => AUI_SALMON_COLOR,
261
-				'cyan'      => AUI_CYAN_COLOR,
262
-				'gray'      => AUI_GRAY_COLOR,
263
-				'indigo'    => AUI_INDIGO_COLOR,
264
-				'orange'    => AUI_ORANGE_COLOR,
265
-				'black'     => AUI_BLACK_COLOR,
266
-			);
267
-		}
268
-
269
-		/**
270
-		 * Add admin body class to show when BS5 is active.
271
-		 *
272
-		 * @param $classes
273
-		 *
274
-		 * @return mixed
275
-		 */
276
-		public function add_bs5_admin_body_class( $classes = '' ) {
277
-			$classes .= ' aui_bs5';
278
-
279
-			return $classes;
280
-		}
281
-
282
-		/**
283
-		 * Add a body class to show when BS5 is active.
284
-		 *
285
-		 * @param $classes
286
-		 *
287
-		 * @return mixed
288
-		 */
289
-		public function add_bs5_body_class( $classes ) {
290
-			$classes[] = 'aui_bs5';
291
-
292
-			return $classes;
293
-		}
294
-
295
-		/**
296
-		 * Initiate the settings and add the required action hooks.
297
-		 */
298
-		public function init() {
142
+            if(!empty($setting['color']['palette']['custom'])){
143
+                foreach($setting['color']['palette']['custom'] as $color){
144
+                    $theme_colors[$color['slug']] = esc_attr($color['name']);
145
+                }
146
+            }
147
+
148
+            return $theme_colors;
149
+        }
150
+
151
+        /**
152
+         * Setup some constants.
153
+         */
154
+        public function constants(){
155
+            define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" );
156
+            define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' );
157
+            define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' );
158
+            define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' );
159
+            define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' );
160
+            define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' );
161
+            define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' );
162
+            define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' );
163
+            define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' );
164
+            define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' );
165
+            define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' );
166
+            define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' );
167
+            define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' );
168
+            define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' );
169
+            define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' );
170
+            define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' );
171
+
172
+            if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
173
+                define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL );
174
+            }
175
+            if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) {
176
+                define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL );
177
+            }
178
+            if ( ! defined( 'AUI_INFO_COLOR' ) ) {
179
+                define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL );
180
+            }
181
+            if ( ! defined( 'AUI_WARNING_COLOR' ) ) {
182
+                define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL );
183
+            }
184
+            if ( ! defined( 'AUI_DANGER_COLOR' ) ) {
185
+                define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL );
186
+            }
187
+            if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) {
188
+                define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL );
189
+            }
190
+            if ( ! defined( 'AUI_LIGHT_COLOR' ) ) {
191
+                define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL );
192
+            }
193
+            if ( ! defined( 'AUI_DARK_COLOR' ) ) {
194
+                define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL );
195
+            }
196
+            if ( ! defined( 'AUI_WHITE_COLOR' ) ) {
197
+                define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL );
198
+            }
199
+            if ( ! defined( 'AUI_PURPLE_COLOR' ) ) {
200
+                define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL );
201
+            }
202
+            if ( ! defined( 'AUI_SALMON_COLOR' ) ) {
203
+                define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL );
204
+            }
205
+            if ( ! defined( 'AUI_CYAN_COLOR' ) ) {
206
+                define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL );
207
+            }
208
+            if ( ! defined( 'AUI_GRAY_COLOR' ) ) {
209
+                define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL );
210
+            }
211
+            if ( ! defined( 'AUI_INDIGO_COLOR' ) ) {
212
+                define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL );
213
+            }
214
+            if ( ! defined( 'AUI_ORANGE_COLOR' ) ) {
215
+                define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL );
216
+            }
217
+            if ( ! defined( 'AUI_BLACK_COLOR' ) ) {
218
+                define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL );
219
+            }
220
+
221
+        }
222
+
223
+        public static function get_colors( $original = false){
224
+
225
+            if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
226
+                return array();
227
+            }
228
+            if ( $original ) {
229
+                return array(
230
+                    'primary'   => AUI_PRIMARY_COLOR_ORIGINAL,
231
+                    'secondary' => AUI_SECONDARY_COLOR_ORIGINAL,
232
+                    'info'      => AUI_INFO_COLOR_ORIGINAL,
233
+                    'warning'   => AUI_WARNING_COLOR_ORIGINAL,
234
+                    'danger'    => AUI_DANGER_COLOR_ORIGINAL,
235
+                    'success'   => AUI_SUCCESS_COLOR_ORIGINAL,
236
+                    'light'     => AUI_LIGHT_COLOR_ORIGINAL,
237
+                    'dark'      => AUI_DARK_COLOR_ORIGINAL,
238
+                    'white'     => AUI_WHITE_COLOR_ORIGINAL,
239
+                    'purple'    => AUI_PURPLE_COLOR_ORIGINAL,
240
+                    'salmon'    => AUI_SALMON_COLOR_ORIGINAL,
241
+                    'cyan'      => AUI_CYAN_COLOR_ORIGINAL,
242
+                    'gray'      => AUI_GRAY_COLOR_ORIGINAL,
243
+                    'indigo'    => AUI_INDIGO_COLOR_ORIGINAL,
244
+                    'orange'    => AUI_ORANGE_COLOR_ORIGINAL,
245
+                    'black'     => AUI_BLACK_COLOR_ORIGINAL,
246
+                );
247
+            }
248
+
249
+            return array(
250
+                'primary'   => AUI_PRIMARY_COLOR,
251
+                'secondary' => AUI_SECONDARY_COLOR,
252
+                'info'      => AUI_INFO_COLOR,
253
+                'warning'   => AUI_WARNING_COLOR,
254
+                'danger'    => AUI_DANGER_COLOR,
255
+                'success'   => AUI_SUCCESS_COLOR,
256
+                'light'     => AUI_LIGHT_COLOR,
257
+                'dark'      => AUI_DARK_COLOR,
258
+                'white'     => AUI_WHITE_COLOR,
259
+                'purple'    => AUI_PURPLE_COLOR,
260
+                'salmon'    => AUI_SALMON_COLOR,
261
+                'cyan'      => AUI_CYAN_COLOR,
262
+                'gray'      => AUI_GRAY_COLOR,
263
+                'indigo'    => AUI_INDIGO_COLOR,
264
+                'orange'    => AUI_ORANGE_COLOR,
265
+                'black'     => AUI_BLACK_COLOR,
266
+            );
267
+        }
268
+
269
+        /**
270
+         * Add admin body class to show when BS5 is active.
271
+         *
272
+         * @param $classes
273
+         *
274
+         * @return mixed
275
+         */
276
+        public function add_bs5_admin_body_class( $classes = '' ) {
277
+            $classes .= ' aui_bs5';
278
+
279
+            return $classes;
280
+        }
281
+
282
+        /**
283
+         * Add a body class to show when BS5 is active.
284
+         *
285
+         * @param $classes
286
+         *
287
+         * @return mixed
288
+         */
289
+        public function add_bs5_body_class( $classes ) {
290
+            $classes[] = 'aui_bs5';
291
+
292
+            return $classes;
293
+        }
294
+
295
+        /**
296
+         * Initiate the settings and add the required action hooks.
297
+         */
298
+        public function init() {
299 299
             global $aui_bs5;
300 300
 
301
-			// Maybe fix settings
302
-			if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) {
303
-				$db_settings = get_option( 'ayecode-ui-settings' );
304
-				if ( ! empty( $db_settings ) ) {
305
-					$db_settings['css_backend'] = 'compatibility';
306
-					$db_settings['js_backend'] = 'core-popper';
307
-					update_option( 'ayecode-ui-settings', $db_settings );
308
-					wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true"));
309
-				}
310
-			}
301
+            // Maybe fix settings
302
+            if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) {
303
+                $db_settings = get_option( 'ayecode-ui-settings' );
304
+                if ( ! empty( $db_settings ) ) {
305
+                    $db_settings['css_backend'] = 'compatibility';
306
+                    $db_settings['js_backend'] = 'core-popper';
307
+                    update_option( 'ayecode-ui-settings', $db_settings );
308
+                    wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true"));
309
+                }
310
+            }
311 311
 
312
-			$this->constants();
313
-			$this->settings = $this->get_settings();
314
-			$this->url = $this->get_url();
312
+            $this->constants();
313
+            $this->settings = $this->get_settings();
314
+            $this->url = $this->get_url();
315 315
 
316 316
             // define the version
317
-			$aui_bs5 = $this->settings['bs_ver'] === '5';
318
-
319
-			if ( $aui_bs5 ) {
320
-				include_once( dirname( __FILE__ ) . '/inc/bs-conversion.php' );
321
-				add_filter( 'admin_body_class', array( $this, 'add_bs5_admin_body_class' ), 99, 1 );
322
-				add_filter( 'body_class', array( $this, 'add_bs5_body_class' ) );
323
-			}
324
-
325
-			/**
326
-			 * Maybe load CSS
327
-			 *
328
-			 * We load super early in case there is a theme version that might change the colors
329
-			 */
330
-			if ( $this->settings['css'] ) {
331
-				$priority = $this->is_bs3_compat() ? 100 : 1;
317
+            $aui_bs5 = $this->settings['bs_ver'] === '5';
318
+
319
+            if ( $aui_bs5 ) {
320
+                include_once( dirname( __FILE__ ) . '/inc/bs-conversion.php' );
321
+                add_filter( 'admin_body_class', array( $this, 'add_bs5_admin_body_class' ), 99, 1 );
322
+                add_filter( 'body_class', array( $this, 'add_bs5_body_class' ) );
323
+            }
324
+
325
+            /**
326
+             * Maybe load CSS
327
+             *
328
+             * We load super early in case there is a theme version that might change the colors
329
+             */
330
+            if ( $this->settings['css'] ) {
331
+                $priority = $this->is_bs3_compat() ? 100 : 1;
332 332
                 $priority = $aui_bs5 ? 10 : $priority;
333
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority );
334
-			}
335
-			if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
336
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
337
-			}
338
-
339
-			// maybe load JS
340
-			if ( $this->settings['js'] ) {
341
-				$priority = $this->is_bs3_compat() ? 100 : 1;
342
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
343
-			}
344
-			if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
345
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
346
-			}
347
-
348
-			// Maybe set the HTML font size
349
-			if ( $this->settings['html_font_size'] ) {
350
-				add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 );
351
-			}
352
-
353
-			// Maybe show backend style error
354
-			if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){
355
-				add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) );
356
-			}
357
-
358
-		}
359
-
360
-		/**
361
-		 * Show admin notice if backend scripts not loaded.
362
-		 */
363
-		public function show_admin_style_notice(){
364
-			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin'));
365
-			$button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>';
366
-			$message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button;
367
-			echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>';
368
-		}
369
-
370
-		/**
371
-		 * Check if we should load the admin scripts or not.
372
-		 *
373
-		 * @return bool
374
-		 */
375
-		public function load_admin_scripts(){
376
-			$result = true;
377
-
378
-			// check if specifically disabled
379
-			if(!empty($this->settings['disable_admin'])){
380
-				$url_parts = explode("\n",$this->settings['disable_admin']);
381
-				foreach($url_parts as $part){
382
-					if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){
383
-						return false; // return early, no point checking further
384
-					}
385
-				}
386
-			}
387
-
388
-			return $result;
389
-		}
390
-
391
-		/**
392
-		 * Add a html font size to the footer.
393
-		 */
394
-		public function html_font_size(){
395
-			$this->settings = $this->get_settings();
396
-			echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
397
-		}
398
-
399
-		/**
400
-		 * Check if the current admin screen should load scripts.
401
-		 *
402
-		 * @return bool
403
-		 */
404
-		public function is_aui_screen(){
333
+                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority );
334
+            }
335
+            if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
336
+                add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
337
+            }
338
+
339
+            // maybe load JS
340
+            if ( $this->settings['js'] ) {
341
+                $priority = $this->is_bs3_compat() ? 100 : 1;
342
+                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
343
+            }
344
+            if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
345
+                add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
346
+            }
347
+
348
+            // Maybe set the HTML font size
349
+            if ( $this->settings['html_font_size'] ) {
350
+                add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 );
351
+            }
352
+
353
+            // Maybe show backend style error
354
+            if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){
355
+                add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) );
356
+            }
357
+
358
+        }
359
+
360
+        /**
361
+         * Show admin notice if backend scripts not loaded.
362
+         */
363
+        public function show_admin_style_notice(){
364
+            $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin'));
365
+            $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>';
366
+            $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button;
367
+            echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>';
368
+        }
369
+
370
+        /**
371
+         * Check if we should load the admin scripts or not.
372
+         *
373
+         * @return bool
374
+         */
375
+        public function load_admin_scripts(){
376
+            $result = true;
377
+
378
+            // check if specifically disabled
379
+            if(!empty($this->settings['disable_admin'])){
380
+                $url_parts = explode("\n",$this->settings['disable_admin']);
381
+                foreach($url_parts as $part){
382
+                    if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){
383
+                        return false; // return early, no point checking further
384
+                    }
385
+                }
386
+            }
387
+
388
+            return $result;
389
+        }
390
+
391
+        /**
392
+         * Add a html font size to the footer.
393
+         */
394
+        public function html_font_size(){
395
+            $this->settings = $this->get_settings();
396
+            echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
397
+        }
398
+
399
+        /**
400
+         * Check if the current admin screen should load scripts.
401
+         *
402
+         * @return bool
403
+         */
404
+        public function is_aui_screen(){
405 405
 //			echo '###';exit;
406
-			$load = false;
407
-			// check if we should load or not
408
-			if ( is_admin() ) {
409
-				// Only enable on set pages
410
-				$aui_screens = array(
411
-					'page',
406
+            $load = false;
407
+            // check if we should load or not
408
+            if ( is_admin() ) {
409
+                // Only enable on set pages
410
+                $aui_screens = array(
411
+                    'page',
412 412
                     //'docs',
413
-					'post',
414
-					'settings_page_ayecode-ui-settings',
415
-					'appearance_page_gutenberg-widgets',
416
-					'widgets',
417
-					'ayecode-ui-settings',
418
-					'site-editor'
419
-				);
420
-				$screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
413
+                    'post',
414
+                    'settings_page_ayecode-ui-settings',
415
+                    'appearance_page_gutenberg-widgets',
416
+                    'widgets',
417
+                    'ayecode-ui-settings',
418
+                    'site-editor'
419
+                );
420
+                $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
421 421
 
422
-				$screen = get_current_screen();
422
+                $screen = get_current_screen();
423 423
 
424 424
 //				echo '###'.$screen->id;
425 425
 
426
-				// check if we are on a AUI screen
427
-				if ( $screen && in_array( $screen->id, $screen_ids ) ) {
428
-					$load = true;
429
-				}
426
+                // check if we are on a AUI screen
427
+                if ( $screen && in_array( $screen->id, $screen_ids ) ) {
428
+                    $load = true;
429
+                }
430 430
 
431
-				//load for widget previews in WP 5.8
432
-				if( !empty($_REQUEST['legacy-widget-preview'])){
433
-					$load = true;
434
-				}
435
-			}
431
+                //load for widget previews in WP 5.8
432
+                if( !empty($_REQUEST['legacy-widget-preview'])){
433
+                    $load = true;
434
+                }
435
+            }
436 436
 
437 437
 
438 438
 
439
-			return apply_filters( 'aui_load_on_admin' , $load );
440
-		}
439
+            return apply_filters( 'aui_load_on_admin' , $load );
440
+        }
441 441
 
442
-		/**
443
-		 * Check if the current theme is a block theme.
444
-		 *
445
-		 * @return bool
446
-		 */
447
-		public static function is_block_theme() {
448
-			if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) {
449
-				return true;
450
-			}
442
+        /**
443
+         * Check if the current theme is a block theme.
444
+         *
445
+         * @return bool
446
+         */
447
+        public static function is_block_theme() {
448
+            if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) {
449
+                return true;
450
+            }
451 451
 
452
-			return false;
453
-		}
452
+            return false;
453
+        }
454 454
 
455
-		/**
456
-		 * Adds the styles.
457
-		 */
458
-		public function enqueue_style() {
455
+        /**
456
+         * Adds the styles.
457
+         */
458
+        public function enqueue_style() {
459 459
             global $aui_bs5;
460 460
 
461 461
             $load_fse = false;
462 462
 
463
-			if( is_admin() && !$this->is_aui_screen()){
464
-				// don't add wp-admin scripts if not requested to
465
-			}else{
466
-				$css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
463
+            if( is_admin() && !$this->is_aui_screen()){
464
+                // don't add wp-admin scripts if not requested to
465
+            }else{
466
+                $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
467 467
 
468
-				$rtl = is_rtl() && ! $aui_bs5 ? '-rtl' : '';
468
+                $rtl = is_rtl() && ! $aui_bs5 ? '-rtl' : '';
469 469
 
470 470
                 $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
471 471
 
472
-				if($this->settings[$css_setting]){
473
-					$compatibility = $this->settings[$css_setting]=='core' ? false : true;
474
-					$url = $this->settings[$css_setting]=='core' ? $this->url.'assets'.$bs_ver.'/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets'.$bs_ver.'/css/ayecode-ui-compatibility'.$rtl.'.css';
472
+                if($this->settings[$css_setting]){
473
+                    $compatibility = $this->settings[$css_setting]=='core' ? false : true;
474
+                    $url = $this->settings[$css_setting]=='core' ? $this->url.'assets'.$bs_ver.'/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets'.$bs_ver.'/css/ayecode-ui-compatibility'.$rtl.'.css';
475 475
 
476 476
 
477 477
 
478
-					wp_register_style( 'ayecode-ui', $url, array(), $this->version );
479
-					wp_enqueue_style( 'ayecode-ui' );
478
+                    wp_register_style( 'ayecode-ui', $url, array(), $this->version );
479
+                    wp_enqueue_style( 'ayecode-ui' );
480 480
 
481
-					$current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
481
+                    $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
482 482
 
483 483
 //					if ( is_admin() && !empty($_REQUEST['postType']) ) {
484
-					if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) )  ) {
485
-						$url = $this->url.'assets'.$bs_ver.'/css/ayecode-ui-fse.css';
486
-						wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version );
487
-						wp_enqueue_style( 'ayecode-ui-fse' );
488
-						$load_fse = true;
489
-					}
484
+                    if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) )  ) {
485
+                        $url = $this->url.'assets'.$bs_ver.'/css/ayecode-ui-fse.css';
486
+                        wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version );
487
+                        wp_enqueue_style( 'ayecode-ui-fse' );
488
+                        $load_fse = true;
489
+                    }
490 490
 
491 491
 
492
-					// flatpickr
493
-					wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version );
492
+                    // flatpickr
493
+                    wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version );
494 494
 
495
-					// fix some wp-admin issues
496
-					if(is_admin()){
497
-						$custom_css = "
495
+                    // fix some wp-admin issues
496
+                    if(is_admin()){
497
+                        $custom_css = "
498 498
                 body{
499 499
                     background-color: #f1f1f1;
500 500
                     font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif;
@@ -535,67 +535,67 @@  discard block
 block discarded – undo
535 535
 				}
536 536
                 ";
537 537
 
538
-						// @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377
539
-						$custom_css .= "
538
+                        // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377
539
+                        $custom_css .= "
540 540
 						.edit-post-sidebar input[type=color].components-text-control__input{
541 541
 						    padding: 0;
542 542
 						}
543 543
 					";
544
-						wp_add_inline_style( 'ayecode-ui', $custom_css );
545
-					}
544
+                        wp_add_inline_style( 'ayecode-ui', $custom_css );
545
+                    }
546 546
 
547
-					// custom changes
548
-					if ( $load_fse ) {
549
-						wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) );
550
-					}else{
551
-						wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
547
+                    // custom changes
548
+                    if ( $load_fse ) {
549
+                        wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) );
550
+                    }else{
551
+                        wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
552 552
 
553
-					}
553
+                    }
554 554
 
555
-				}
556
-			}
555
+                }
556
+            }
557 557
 
558 558
 
559
-		}
559
+        }
560 560
 
561
-		/**
562
-		 * Get inline script used if bootstrap enqueued
563
-		 *
564
-		 * If this remains small then its best to use this than to add another JS file.
565
-		 */
566
-		public function inline_script() {
561
+        /**
562
+         * Get inline script used if bootstrap enqueued
563
+         *
564
+         * If this remains small then its best to use this than to add another JS file.
565
+         */
566
+        public function inline_script() {
567 567
             global $aui_bs5;
568
-			// Flatpickr calendar locale
569
-			$flatpickr_locale = self::flatpickr_locale();
570
-
571
-			ob_start();
572
-			if ( $aui_bs5 ) {
573
-				include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' );
574
-			}else{
575
-				include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' );
568
+            // Flatpickr calendar locale
569
+            $flatpickr_locale = self::flatpickr_locale();
570
+
571
+            ob_start();
572
+            if ( $aui_bs5 ) {
573
+                include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' );
574
+            }else{
575
+                include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' );
576 576
             }
577 577
 
578
-			$output = ob_get_clean();
578
+            $output = ob_get_clean();
579 579
 
580
-			/*
580
+            /*
581 581
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
582 582
 			 */
583
-			return str_replace( array(
584
-				'<script>',
585
-				'</script>'
586
-			), '', self::minify_js($output) );
587
-		}
588
-
589
-
590
-		/**
591
-		 * JS to help with conflict issues with other plugins and themes using bootstrap v3.
592
-		 *
593
-		 * @TODO we may need this when other conflicts arrise.
594
-		 * @return mixed
595
-		 */
596
-		public static function bs3_compat_js() {
597
-			ob_start();
598
-			?>
583
+            return str_replace( array(
584
+                '<script>',
585
+                '</script>'
586
+            ), '', self::minify_js($output) );
587
+        }
588
+
589
+
590
+        /**
591
+         * JS to help with conflict issues with other plugins and themes using bootstrap v3.
592
+         *
593
+         * @TODO we may need this when other conflicts arrise.
594
+         * @return mixed
595
+         */
596
+        public static function bs3_compat_js() {
597
+            ob_start();
598
+            ?>
599 599
             <script>
600 600
 				<?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
601 601
                 /* With Avada builder */
@@ -603,20 +603,20 @@  discard block
 block discarded – undo
603 603
 				<?php } ?>
604 604
             </script>
605 605
 			<?php
606
-			return str_replace( array(
607
-				'<script>',
608
-				'</script>'
609
-			), '', ob_get_clean());
610
-		}
611
-
612
-		/**
613
-		 * Get inline script used if bootstrap file browser enqueued.
614
-		 *
615
-		 * If this remains small then its best to use this than to add another JS file.
616
-		 */
617
-		public function inline_script_file_browser(){
618
-			ob_start();
619
-			?>
606
+            return str_replace( array(
607
+                '<script>',
608
+                '</script>'
609
+            ), '', ob_get_clean());
610
+        }
611
+
612
+        /**
613
+         * Get inline script used if bootstrap file browser enqueued.
614
+         *
615
+         * If this remains small then its best to use this than to add another JS file.
616
+         */
617
+        public function inline_script_file_browser(){
618
+            ob_start();
619
+            ?>
620 620
             <script>
621 621
                 // run on doc ready
622 622
                 jQuery(document).ready(function () {
@@ -624,247 +624,247 @@  discard block
 block discarded – undo
624 624
                 });
625 625
             </script>
626 626
 			<?php
627
-			$output = ob_get_clean();
627
+            $output = ob_get_clean();
628 628
 
629
-			/*
629
+            /*
630 630
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
631 631
 			 */
632
-			return str_replace( array(
633
-				'<script>',
634
-				'</script>'
635
-			), '', $output );
636
-		}
632
+            return str_replace( array(
633
+                '<script>',
634
+                '</script>'
635
+            ), '', $output );
636
+        }
637 637
 
638
-		/**
639
-		 * Adds the Font Awesome JS.
640
-		 */
641
-		public function enqueue_scripts() {
638
+        /**
639
+         * Adds the Font Awesome JS.
640
+         */
641
+        public function enqueue_scripts() {
642 642
 
643
-			if( is_admin() && !$this->is_aui_screen()){
644
-				// don't add wp-admin scripts if not requested to
645
-			}else {
643
+            if( is_admin() && !$this->is_aui_screen()){
644
+                // don't add wp-admin scripts if not requested to
645
+            }else {
646 646
 
647
-				$js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
647
+                $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
648 648
 
649
-				$bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
649
+                $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
650 650
 
651
-				// select2
652
-				wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
651
+                // select2
652
+                wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
653 653
 
654
-				// flatpickr
655
-				wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version );
654
+                // flatpickr
655
+                wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version );
656 656
 
657
-				// iconpicker
658
-				if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) {
659
-					wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version );
660
-				}else{
661
-					wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
662
-				}
657
+                // iconpicker
658
+                if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) {
659
+                    wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version );
660
+                }else{
661
+                    wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
662
+                }
663 663
 
664
-				// Bootstrap file browser
665
-				wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
666
-				wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
667
-
668
-				$load_inline = false;
669
-
670
-				if ( $this->settings[ $js_setting ] == 'core-popper' ) {
671
-					// Bootstrap bundle
672
-					$url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js';
673
-					wp_register_script( 'bootstrap-js-bundle', $url, array(
674
-						'select2',
675
-						'jquery'
676
-					), $this->version, $this->is_bs3_compat() );
677
-					// if in admin then add to footer for compatibility.
678
-					is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
679
-					$script = $this->inline_script();
680
-					wp_add_inline_script( 'bootstrap-js-bundle', $script );
681
-				} elseif ( $this->settings[ $js_setting ] == 'popper' ) {
682
-					$url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5
683
-					wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version );
684
-					wp_enqueue_script( 'bootstrap-js-popper' );
685
-					$load_inline = true;
686
-				} else {
687
-					$load_inline = true;
688
-				}
664
+                // Bootstrap file browser
665
+                wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
666
+                wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
667
+
668
+                $load_inline = false;
669
+
670
+                if ( $this->settings[ $js_setting ] == 'core-popper' ) {
671
+                    // Bootstrap bundle
672
+                    $url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js';
673
+                    wp_register_script( 'bootstrap-js-bundle', $url, array(
674
+                        'select2',
675
+                        'jquery'
676
+                    ), $this->version, $this->is_bs3_compat() );
677
+                    // if in admin then add to footer for compatibility.
678
+                    is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
679
+                    $script = $this->inline_script();
680
+                    wp_add_inline_script( 'bootstrap-js-bundle', $script );
681
+                } elseif ( $this->settings[ $js_setting ] == 'popper' ) {
682
+                    $url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5
683
+                    wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version );
684
+                    wp_enqueue_script( 'bootstrap-js-popper' );
685
+                    $load_inline = true;
686
+                } else {
687
+                    $load_inline = true;
688
+                }
689 689
 
690
-				// Load needed inline scripts by faking the loading of a script if the main script is not being loaded
691
-				if ( $load_inline ) {
692
-					wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
693
-					wp_enqueue_script( 'bootstrap-dummy' );
694
-					$script = $this->inline_script();
695
-					wp_add_inline_script( 'bootstrap-dummy', $script );
696
-				}
697
-			}
698
-
699
-		}
700
-
701
-		/**
702
-		 * Enqueue flatpickr if called.
703
-		 */
704
-		public function enqueue_flatpickr(){
705
-			wp_enqueue_style( 'flatpickr' );
706
-			wp_enqueue_script( 'flatpickr' );
707
-		}
708
-
709
-		/**
710
-		 * Enqueue iconpicker if called.
711
-		 */
712
-		public function enqueue_iconpicker(){
713
-			wp_enqueue_style( 'iconpicker' );
714
-			wp_enqueue_script( 'iconpicker' );
715
-		}
716
-
717
-		/**
718
-		 * Get the url path to the current folder.
719
-		 *
720
-		 * @return string
721
-		 */
722
-		public function get_url() {
723
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
724
-			$content_url = untrailingslashit( WP_CONTENT_URL );
725
-
726
-			// Replace http:// to https://.
727
-			if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
728
-				$content_url = str_replace( 'http://', 'https://', $content_url );
729
-			}
730
-
731
-			// Check if we are inside a plugin
732
-			$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
733
-			$url = str_replace( $content_dir, $content_url, $file_dir );
734
-
735
-			return trailingslashit( $url );
736
-		}
737
-
738
-		/**
739
-		 * Get the url path to the current folder.
740
-		 *
741
-		 * @return string
742
-		 */
743
-		public function get_url_old() {
744
-
745
-			$url = '';
746
-			// check if we are inside a plugin
747
-			$file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
748
-
749
-			// add check in-case user has changed wp-content dir name.
750
-			$wp_content_folder_name = basename(WP_CONTENT_DIR);
751
-			$dir_parts = explode("/$wp_content_folder_name/",$file_dir);
752
-			$url_parts = explode("/$wp_content_folder_name/",plugins_url());
753
-
754
-			if(!empty($url_parts[0]) && !empty($dir_parts[1])){
755
-				$url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
756
-			}
757
-
758
-			return $url;
759
-		}
760
-
761
-		/**
762
-		 * Register the database settings with WordPress.
763
-		 */
764
-		public function register_settings() {
765
-			register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
766
-		}
767
-
768
-		/**
769
-		 * Add the WordPress settings menu item.
770
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
771
-		 */
772
-		public function menu_item() {
773
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
774
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
775
-				$this,
776
-				'settings_page'
777
-			) );
778
-		}
779
-
780
-		/**
781
-		 * Get a list of themes and their default JS settings.
782
-		 *
783
-		 * @return array
784
-		 */
785
-		public function theme_js_settings(){
786
-			return array(
787
-				'ayetheme' => 'popper',
788
-				'listimia' => 'required',
789
-				'listimia_backend' => 'core-popper',
790
-				//'avada'    => 'required', // removed as we now add compatibility
791
-			);
792
-		}
793
-
794
-		/**
795
-		 * Get the current Font Awesome output settings.
796
-		 *
797
-		 * @return array The array of settings.
798
-		 */
799
-		public function get_settings() {
800
-
801
-			$db_settings = get_option( 'ayecode-ui-settings' );
802
-			$js_default = 'core-popper';
803
-			$js_default_backend = $js_default;
804
-
805
-			// maybe set defaults (if no settings set)
806
-			if(empty($db_settings)){
807
-				$active_theme = strtolower( get_template() ); // active parent theme.
808
-				$theme_js_settings = self::theme_js_settings();
809
-				if(isset($theme_js_settings[$active_theme])){
810
-					$js_default = $theme_js_settings[$active_theme];
811
-					$js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
812
-				}
813
-			}
690
+                // Load needed inline scripts by faking the loading of a script if the main script is not being loaded
691
+                if ( $load_inline ) {
692
+                    wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
693
+                    wp_enqueue_script( 'bootstrap-dummy' );
694
+                    $script = $this->inline_script();
695
+                    wp_add_inline_script( 'bootstrap-dummy', $script );
696
+                }
697
+            }
814 698
 
815
-			/**
816
-			 * Filter the default settings.
817
-			 */
818
-			$defaults = apply_filters( 'ayecode-ui-default-settings', array(
819
-				'css'            => 'compatibility', // core, compatibility
820
-				'js'             => $js_default, // js to load, core-popper, popper
821
-				'html_font_size' => '16', // js to load, core-popper, popper
822
-				'css_backend'    => 'compatibility', // core, compatibility
823
-				'js_backend'     => $js_default_backend, // js to load, core-popper, popper
824
-				'disable_admin'  => '', // URL snippets to disable loading on admin
699
+        }
700
+
701
+        /**
702
+         * Enqueue flatpickr if called.
703
+         */
704
+        public function enqueue_flatpickr(){
705
+            wp_enqueue_style( 'flatpickr' );
706
+            wp_enqueue_script( 'flatpickr' );
707
+        }
708
+
709
+        /**
710
+         * Enqueue iconpicker if called.
711
+         */
712
+        public function enqueue_iconpicker(){
713
+            wp_enqueue_style( 'iconpicker' );
714
+            wp_enqueue_script( 'iconpicker' );
715
+        }
716
+
717
+        /**
718
+         * Get the url path to the current folder.
719
+         *
720
+         * @return string
721
+         */
722
+        public function get_url() {
723
+            $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
724
+            $content_url = untrailingslashit( WP_CONTENT_URL );
725
+
726
+            // Replace http:// to https://.
727
+            if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
728
+                $content_url = str_replace( 'http://', 'https://', $content_url );
729
+            }
730
+
731
+            // Check if we are inside a plugin
732
+            $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
733
+            $url = str_replace( $content_dir, $content_url, $file_dir );
734
+
735
+            return trailingslashit( $url );
736
+        }
737
+
738
+        /**
739
+         * Get the url path to the current folder.
740
+         *
741
+         * @return string
742
+         */
743
+        public function get_url_old() {
744
+
745
+            $url = '';
746
+            // check if we are inside a plugin
747
+            $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
748
+
749
+            // add check in-case user has changed wp-content dir name.
750
+            $wp_content_folder_name = basename(WP_CONTENT_DIR);
751
+            $dir_parts = explode("/$wp_content_folder_name/",$file_dir);
752
+            $url_parts = explode("/$wp_content_folder_name/",plugins_url());
753
+
754
+            if(!empty($url_parts[0]) && !empty($dir_parts[1])){
755
+                $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
756
+            }
757
+
758
+            return $url;
759
+        }
760
+
761
+        /**
762
+         * Register the database settings with WordPress.
763
+         */
764
+        public function register_settings() {
765
+            register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
766
+        }
767
+
768
+        /**
769
+         * Add the WordPress settings menu item.
770
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
771
+         */
772
+        public function menu_item() {
773
+            $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
774
+            call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
775
+                $this,
776
+                'settings_page'
777
+            ) );
778
+        }
779
+
780
+        /**
781
+         * Get a list of themes and their default JS settings.
782
+         *
783
+         * @return array
784
+         */
785
+        public function theme_js_settings(){
786
+            return array(
787
+                'ayetheme' => 'popper',
788
+                'listimia' => 'required',
789
+                'listimia_backend' => 'core-popper',
790
+                //'avada'    => 'required', // removed as we now add compatibility
791
+            );
792
+        }
793
+
794
+        /**
795
+         * Get the current Font Awesome output settings.
796
+         *
797
+         * @return array The array of settings.
798
+         */
799
+        public function get_settings() {
800
+
801
+            $db_settings = get_option( 'ayecode-ui-settings' );
802
+            $js_default = 'core-popper';
803
+            $js_default_backend = $js_default;
804
+
805
+            // maybe set defaults (if no settings set)
806
+            if(empty($db_settings)){
807
+                $active_theme = strtolower( get_template() ); // active parent theme.
808
+                $theme_js_settings = self::theme_js_settings();
809
+                if(isset($theme_js_settings[$active_theme])){
810
+                    $js_default = $theme_js_settings[$active_theme];
811
+                    $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
812
+                }
813
+            }
814
+
815
+            /**
816
+             * Filter the default settings.
817
+             */
818
+            $defaults = apply_filters( 'ayecode-ui-default-settings', array(
819
+                'css'            => 'compatibility', // core, compatibility
820
+                'js'             => $js_default, // js to load, core-popper, popper
821
+                'html_font_size' => '16', // js to load, core-popper, popper
822
+                'css_backend'    => 'compatibility', // core, compatibility
823
+                'js_backend'     => $js_default_backend, // js to load, core-popper, popper
824
+                'disable_admin'  => '', // URL snippets to disable loading on admin
825 825
                 'bs_ver'         => '4', // The default bootstrap version to sue by default
826
-			), $db_settings );
826
+            ), $db_settings );
827 827
 
828
-			$settings = wp_parse_args( $db_settings, $defaults );
828
+            $settings = wp_parse_args( $db_settings, $defaults );
829 829
 
830
-			/**
831
-			 * Filter the Bootstrap settings.
832
-			 *
833
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
834
-			 */
835
-			return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
836
-		}
830
+            /**
831
+             * Filter the Bootstrap settings.
832
+             *
833
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
834
+             */
835
+            return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
836
+        }
837 837
 
838 838
 
839
-		/**
840
-		 * The settings page html output.
841
-		 */
842
-		public function settings_page() {
843
-			if ( ! current_user_can( 'manage_options' ) ) {
844
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
845
-			}
839
+        /**
840
+         * The settings page html output.
841
+         */
842
+        public function settings_page() {
843
+            if ( ! current_user_can( 'manage_options' ) ) {
844
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
845
+            }
846 846
             $overrides = apply_filters( 'ayecode-ui-settings', array(), array(), array() );
847 847
 
848
-			?>
848
+            ?>
849 849
             <div class="wrap">
850 850
                 <h1><?php echo $this->name; ?></h1>
851 851
                 <p><?php echo apply_filters( 'ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.", 'ayecode-connect' ) );?></p>
852 852
                 <form method="post" action="options.php">
853 853
 					<?php
854
-					settings_fields( 'ayecode-ui-settings' );
855
-					do_settings_sections( 'ayecode-ui-settings' );
856
-					?>
854
+                    settings_fields( 'ayecode-ui-settings' );
855
+                    do_settings_sections( 'ayecode-ui-settings' );
856
+                    ?>
857 857
 
858 858
                     <h2><?php _e( 'BootStrap Version', 'ayecode-connect' ); ?></h2>
859 859
                     <p><?php echo apply_filters( 'ayecode-ui-version-settings-message', __("V5 is recommended, however if you have another plugin installed using v4, you may need to use v4 also.", 'ayecode-connect' ) );?></p>
860 860
 	                <div class="bsui"><?php
861
-	                if ( ! empty( $overrides ) ) {
862
-		                echo aui()->alert(array(
863
-			                'type'=> 'info',
864
-			                'content'=> __("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' )
865
-		                ));
866
-	                }
867
-	                ?>
861
+                    if ( ! empty( $overrides ) ) {
862
+                        echo aui()->alert(array(
863
+                            'type'=> 'info',
864
+                            'content'=> __("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' )
865
+                        ));
866
+                    }
867
+                    ?>
868 868
                     </div>
869 869
                     <table class="form-table wpbs-table-version-settings">
870 870
                         <tr valign="top">
@@ -948,77 +948,77 @@  discard block
 block discarded – undo
948 948
                     </table>
949 949
 
950 950
 					<?php
951
-					submit_button();
952
-					?>
951
+                    submit_button();
952
+                    ?>
953 953
                 </form>
954 954
                 <div id="wpbs-version" data-aui-source="<?php echo esc_attr( $this->get_load_source() ); ?>"><?php echo $this->version; ?></div>
955 955
             </div>
956 956
 			<?php
957
-		}
957
+        }
958 958
 
959 959
         public function get_load_source(){
960
-	        $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
961
-	        $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
962
-
963
-	        // Find source plugin/theme of SD
964
-	        $source = array();
965
-	        if ( strpos( $file, $plugins_dir ) !== false ) {
966
-		        $source = explode( "/", plugin_basename( $file ) );
967
-	        } else if ( function_exists( 'get_theme_root' ) ) {
968
-		        $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
969
-
970
-		        if ( strpos( $file, $themes_dir ) !== false ) {
971
-			        $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
972
-		        }
973
-	        }
960
+            $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
961
+            $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
962
+
963
+            // Find source plugin/theme of SD
964
+            $source = array();
965
+            if ( strpos( $file, $plugins_dir ) !== false ) {
966
+                $source = explode( "/", plugin_basename( $file ) );
967
+            } else if ( function_exists( 'get_theme_root' ) ) {
968
+                $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
969
+
970
+                if ( strpos( $file, $themes_dir ) !== false ) {
971
+                    $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
972
+                }
973
+            }
974 974
 
975 975
             return isset($source[0]) ? esc_attr($source[0]) : '';
976 976
         }
977 977
 
978
-		public function customizer_settings($wp_customize){
979
-			$wp_customize->add_section('aui_settings', array(
980
-				'title'    => __('AyeCode UI', 'ayecode-connect' ),
981
-				'priority' => 120,
982
-			));
983
-
984
-			//  =============================
985
-			//  = Color Picker              =
986
-			//  =============================
987
-			$wp_customize->add_setting('aui_options[color_primary]', array(
988
-				'default'           => AUI_PRIMARY_COLOR,
989
-				'sanitize_callback' => 'sanitize_hex_color',
990
-				'capability'        => 'edit_theme_options',
991
-				'type'              => 'option',
992
-				'transport'         => 'refresh',
993
-			));
994
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
995
-				'label'    => __('Primary Color', 'ayecode-connect' ),
996
-				'section'  => 'aui_settings',
997
-				'settings' => 'aui_options[color_primary]',
998
-			)));
999
-
1000
-			$wp_customize->add_setting('aui_options[color_secondary]', array(
1001
-				'default'           => '#6c757d',
1002
-				'sanitize_callback' => 'sanitize_hex_color',
1003
-				'capability'        => 'edit_theme_options',
1004
-				'type'              => 'option',
1005
-				'transport'         => 'refresh',
1006
-			));
1007
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1008
-				'label'    => __('Secondary Color', 'ayecode-connect' ),
1009
-				'section'  => 'aui_settings',
1010
-				'settings' => 'aui_options[color_secondary]',
1011
-			)));
1012
-		}
1013
-
1014
-		/**
1015
-		 * CSS to help with conflict issues with other plugins and themes using bootstrap v3.
1016
-		 *
1017
-		 * @return mixed
1018
-		 */
1019
-		public static function bs3_compat_css() {
1020
-			ob_start();
1021
-			?>
978
+        public function customizer_settings($wp_customize){
979
+            $wp_customize->add_section('aui_settings', array(
980
+                'title'    => __('AyeCode UI', 'ayecode-connect' ),
981
+                'priority' => 120,
982
+            ));
983
+
984
+            //  =============================
985
+            //  = Color Picker              =
986
+            //  =============================
987
+            $wp_customize->add_setting('aui_options[color_primary]', array(
988
+                'default'           => AUI_PRIMARY_COLOR,
989
+                'sanitize_callback' => 'sanitize_hex_color',
990
+                'capability'        => 'edit_theme_options',
991
+                'type'              => 'option',
992
+                'transport'         => 'refresh',
993
+            ));
994
+            $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
995
+                'label'    => __('Primary Color', 'ayecode-connect' ),
996
+                'section'  => 'aui_settings',
997
+                'settings' => 'aui_options[color_primary]',
998
+            )));
999
+
1000
+            $wp_customize->add_setting('aui_options[color_secondary]', array(
1001
+                'default'           => '#6c757d',
1002
+                'sanitize_callback' => 'sanitize_hex_color',
1003
+                'capability'        => 'edit_theme_options',
1004
+                'type'              => 'option',
1005
+                'transport'         => 'refresh',
1006
+            ));
1007
+            $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1008
+                'label'    => __('Secondary Color', 'ayecode-connect' ),
1009
+                'section'  => 'aui_settings',
1010
+                'settings' => 'aui_options[color_secondary]',
1011
+            )));
1012
+        }
1013
+
1014
+        /**
1015
+         * CSS to help with conflict issues with other plugins and themes using bootstrap v3.
1016
+         *
1017
+         * @return mixed
1018
+         */
1019
+        public static function bs3_compat_css() {
1020
+            ob_start();
1021
+            ?>
1022 1022
             <style>
1023 1023
                 /* Bootstrap 3 compatibility */
1024 1024
                 body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;}
@@ -1047,55 +1047,55 @@  discard block
 block discarded – undo
1047 1047
                 <?php } ?>
1048 1048
             </style>
1049 1049
 			<?php
1050
-			return str_replace( array(
1051
-				'<style>',
1052
-				'</style>'
1053
-			), '', self::minify_css( ob_get_clean() ) );
1054
-		}
1050
+            return str_replace( array(
1051
+                '<style>',
1052
+                '</style>'
1053
+            ), '', self::minify_css( ob_get_clean() ) );
1054
+        }
1055 1055
 
1056 1056
 
1057
-		public static function custom_css($compatibility = true) {
1057
+        public static function custom_css($compatibility = true) {
1058 1058
             global $aui_bs5;
1059 1059
 
1060
-			$colors = array();
1061
-			if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
1060
+            $colors = array();
1061
+            if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
1062 1062
 
1063 1063
 
1064
-				$setting = wp_get_global_settings();
1064
+                $setting = wp_get_global_settings();
1065 1065
 
1066 1066
 //                print_r(wp_get_global_styles());//exit;
1067 1067
 //                print_r(get_default_block_editor_settings());exit;
1068 1068
 
1069 1069
 //                print_r($setting);echo  '###';exit;
1070
-				if(!empty($setting['color']['palette']['theme'])){
1071
-					foreach($setting['color']['palette']['theme'] as $color){
1072
-						$colors[$color['slug']] = esc_attr($color['color']);
1073
-					}
1074
-				}
1070
+                if(!empty($setting['color']['palette']['theme'])){
1071
+                    foreach($setting['color']['palette']['theme'] as $color){
1072
+                        $colors[$color['slug']] = esc_attr($color['color']);
1073
+                    }
1074
+                }
1075 1075
 
1076
-				if(!empty($setting['color']['palette']['custom'])){
1077
-					foreach($setting['color']['palette']['custom'] as $color){
1078
-						$colors[$color['slug']] = esc_attr($color['color']);
1079
-					}
1080
-				}
1081
-			}else{
1082
-				$settings = get_option('aui_options');
1083
-				$colors = array(
1084
-					'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1085
-					'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1086
-				);
1087
-			}
1076
+                if(!empty($setting['color']['palette']['custom'])){
1077
+                    foreach($setting['color']['palette']['custom'] as $color){
1078
+                        $colors[$color['slug']] = esc_attr($color['color']);
1079
+                    }
1080
+                }
1081
+            }else{
1082
+                $settings = get_option('aui_options');
1083
+                $colors = array(
1084
+                    'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1085
+                    'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1086
+                );
1087
+            }
1088 1088
 
1089
-			ob_start();
1089
+            ob_start();
1090 1090
 
1091
-			?>
1091
+            ?>
1092 1092
             <style>
1093 1093
                 <?php
1094 1094
 
1095
-					// BS v3 compat
1096
-					if( self::is_bs3_compat() ){
1097
-						echo self::bs3_compat_css();
1098
-					}
1095
+                    // BS v3 compat
1096
+                    if( self::is_bs3_compat() ){
1097
+                        echo self::bs3_compat_css();
1098
+                    }
1099 1099
 
1100 1100
                     $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
1101 1101
                     $is_fse = false;
@@ -1103,26 +1103,26 @@  discard block
 block discarded – undo
1103 1103
                         $is_fse = true;
1104 1104
                     }
1105 1105
 
1106
-					if(!empty($colors)){
1107
-						$d_colors = self::get_colors(true);
1106
+                    if(!empty($colors)){
1107
+                        $d_colors = self::get_colors(true);
1108 1108
 
1109 1109
 //						$is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template';
1110
-						foreach($colors as $key => $color ){
1111
-							if((empty( $d_colors[$key]) ||  $d_colors[$key] != $color) || $is_fse ) {
1112
-								$var = $is_fse ? "var(--wp--preset--color--$key)" : $color;
1113
-								$compat = $is_fse ? '.editor-styles-wrapper' : $compatibility;
1114
-								echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color);
1115
-							}
1116
-						}
1117
-					   // exit;
1118
-					}
1110
+                        foreach($colors as $key => $color ){
1111
+                            if((empty( $d_colors[$key]) ||  $d_colors[$key] != $color) || $is_fse ) {
1112
+                                $var = $is_fse ? "var(--wp--preset--color--$key)" : $color;
1113
+                                $compat = $is_fse ? '.editor-styles-wrapper' : $compatibility;
1114
+                                echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color);
1115
+                            }
1116
+                        }
1117
+                        // exit;
1118
+                    }
1119 1119
 
1120
-					// Set admin bar z-index lower when modal is open.
1121
-					echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1120
+                    // Set admin bar z-index lower when modal is open.
1121
+                    echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1122 1122
 
1123
-					if(is_admin()){
1124
-						echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}';
1125
-					}
1123
+                    if(is_admin()){
1124
+                        echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}';
1125
+                    }
1126 1126
 
1127 1127
                     if( $aui_bs5 && defined( 'BLOCKSTRAP_VERSION' )  ){
1128 1128
                         $css = '';
@@ -1142,28 +1142,28 @@  discard block
 block discarded – undo
1142 1142
                         }
1143 1143
 
1144 1144
                         // line height
1145
-                         if( !empty( $theme_settings['typography']['lineHeight'] ) ){
1145
+                            if( !empty( $theme_settings['typography']['lineHeight'] ) ){
1146 1146
                             $css .= '--bs-body-line-height: ' . esc_attr( $theme_settings['typography']['lineHeight'] ) . ';';
1147 1147
                         }
1148 1148
 
1149 1149
 
1150
-                           // font weight
1151
-                         if( !empty( $theme_settings['typography']['fontWeight'] ) ){
1150
+                            // font weight
1151
+                            if( !empty( $theme_settings['typography']['fontWeight'] ) ){
1152 1152
                             $css .= '--bs-body-font-weight: ' . esc_attr( $theme_settings['typography']['fontWeight'] ) . ';';
1153 1153
                         }
1154 1154
 
1155 1155
                         // Background
1156
-                         if( !empty( $theme_settings['color']['background'] ) ){
1156
+                            if( !empty( $theme_settings['color']['background'] ) ){
1157 1157
                             $css .= '--bs-body-bg: ' . esc_attr( $theme_settings['color']['background'] ) . ';';
1158 1158
                         }
1159 1159
 
1160
-                         // Background Gradient
1161
-                         if( !empty( $theme_settings['color']['gradient'] ) ){
1160
+                            // Background Gradient
1161
+                            if( !empty( $theme_settings['color']['gradient'] ) ){
1162 1162
                             $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';';
1163 1163
                         }
1164 1164
 
1165
-                           // Background Gradient
1166
-                         if( !empty( $theme_settings['color']['gradient'] ) ){
1165
+                            // Background Gradient
1166
+                            if( !empty( $theme_settings['color']['gradient'] ) ){
1167 1167
                             $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';';
1168 1168
                         }
1169 1169
 
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
                             $headings_css .= 'background: ' . esc_attr( $theme_settings['elements']['heading']['color']['background'] ) . ';';
1202 1202
                         }
1203 1203
 
1204
-                         // heading font family
1204
+                            // heading font family
1205 1205
                         if( !empty( $theme_settings['elements']['heading']['typography']['fontFamily'] ) ){
1206 1206
                             $headings_css .= 'font-family: ' . esc_attr( $theme_settings['elements']['heading']['typography']['fontFamily']  ) . ';';
1207 1207
                         }
@@ -1214,21 +1214,21 @@  discard block
 block discarded – undo
1214 1214
 
1215 1215
                         foreach($hs as $hn){
1216 1216
                             $h_css = '';
1217
-                             if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){
1217
+                                if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){
1218 1218
                                 $h_css .= 'color: ' . esc_attr( $theme_settings['elements'][$hn]['color']['text'] ) . ';';
1219
-                             }
1219
+                                }
1220 1220
 
1221
-                              if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){
1221
+                                if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){
1222 1222
                                 $h_css .= 'font-size: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontSize']  ) . ';';
1223
-                             }
1223
+                                }
1224 1224
 
1225
-                              if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){
1225
+                                if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){
1226 1226
                                 $h_css .= 'font-family: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontFamily']  ) . ';';
1227
-                             }
1227
+                                }
1228 1228
 
1229
-                             if($h_css){
1229
+                                if($h_css){
1230 1230
                                 echo $bep . $hn . '{'.$h_css.'}';
1231
-                             }
1231
+                                }
1232 1232
                         }
1233 1233
 
1234 1234
 //                        wp_mail('[email protected]','ss',print_r($_SERVER,true).'@@@');
@@ -1238,171 +1238,171 @@  discard block
 block discarded – undo
1238 1238
 
1239 1239
 
1240 1240
                     }
1241
-				?>
1241
+                ?>
1242 1242
             </style>
1243 1243
 			<?php
1244 1244
 
1245 1245
 
1246
-			/*
1246
+            /*
1247 1247
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1248 1248
 			 */
1249
-			return str_replace( array(
1250
-				'<style>',
1251
-				'</style>'
1252
-			), '', self::minify_css( ob_get_clean() ) );
1253
-		}
1254
-
1255
-
1256
-
1257
-		/**
1258
-		 * Check if we should add booststrap 3 compatibility changes.
1259
-		 *
1260
-		 * @return bool
1261
-		 */
1262
-		public static function is_bs3_compat(){
1263
-			return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
1264
-		}
1265
-
1266
-		public static function hex_to_rgb($hex) {
1267
-			// Remove '#' if present
1268
-			$hex = str_replace('#', '', $hex);
1269
-
1270
-			// Convert 3-digit hex to 6-digit hex
1271
-			if(strlen($hex) == 3) {
1272
-				$hex = str_repeat(substr($hex, 0, 1), 2) . str_repeat(substr($hex, 1, 1), 2) . str_repeat(substr($hex, 2, 1), 2);
1273
-			}
1274
-
1275
-			// Convert hex to RGB
1276
-			$r = hexdec(substr($hex, 0, 2));
1277
-			$g = hexdec(substr($hex, 2, 2));
1278
-			$b = hexdec(substr($hex, 4, 2));
1279
-
1280
-			// Return RGB values as an array
1281
-			return $r . ',' . $g . ',' . $b;
1282
-		}
1283
-
1284
-		/**
1285
-		 * Build the CSS to overwrite a bootstrap color variable.
1286
-		 *
1287
-		 * @param $type
1288
-		 * @param $color_code
1289
-		 * @param $compatibility
1290
-		 *
1291
-		 * @return string
1292
-		 */
1293
-		public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){
1294
-			global $aui_bs5;
1295
-
1296
-			$is_var = false;
1297
-			$is_custom = strpos($type, 'custom-') !== false ? true : false;
1298
-			if(!$color_code){return '';}
1299
-			if(strpos($color_code, 'var') !== false){
1300
-				//if(!sanitize_hex_color($color_code)){
1301
-				$color_code = esc_attr($color_code);
1302
-				$is_var = true;
1249
+            return str_replace( array(
1250
+                '<style>',
1251
+                '</style>'
1252
+            ), '', self::minify_css( ob_get_clean() ) );
1253
+        }
1254
+
1255
+
1256
+
1257
+        /**
1258
+         * Check if we should add booststrap 3 compatibility changes.
1259
+         *
1260
+         * @return bool
1261
+         */
1262
+        public static function is_bs3_compat(){
1263
+            return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
1264
+        }
1265
+
1266
+        public static function hex_to_rgb($hex) {
1267
+            // Remove '#' if present
1268
+            $hex = str_replace('#', '', $hex);
1269
+
1270
+            // Convert 3-digit hex to 6-digit hex
1271
+            if(strlen($hex) == 3) {
1272
+                $hex = str_repeat(substr($hex, 0, 1), 2) . str_repeat(substr($hex, 1, 1), 2) . str_repeat(substr($hex, 2, 1), 2);
1273
+            }
1274
+
1275
+            // Convert hex to RGB
1276
+            $r = hexdec(substr($hex, 0, 2));
1277
+            $g = hexdec(substr($hex, 2, 2));
1278
+            $b = hexdec(substr($hex, 4, 2));
1279
+
1280
+            // Return RGB values as an array
1281
+            return $r . ',' . $g . ',' . $b;
1282
+        }
1283
+
1284
+        /**
1285
+         * Build the CSS to overwrite a bootstrap color variable.
1286
+         *
1287
+         * @param $type
1288
+         * @param $color_code
1289
+         * @param $compatibility
1290
+         *
1291
+         * @return string
1292
+         */
1293
+        public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){
1294
+            global $aui_bs5;
1295
+
1296
+            $is_var = false;
1297
+            $is_custom = strpos($type, 'custom-') !== false ? true : false;
1298
+            if(!$color_code){return '';}
1299
+            if(strpos($color_code, 'var') !== false){
1300
+                //if(!sanitize_hex_color($color_code)){
1301
+                $color_code = esc_attr($color_code);
1302
+                $is_var = true;
1303 1303
 //				$color_code = "rgba($color_code, 0.5)";
1304 1304
 //                echo '###1'.$color_code.'###';//exit;
1305
-			}
1305
+            }
1306 1306
 
1307 1307
 //            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1308 1308
 
1309
-			if(!$color_code){return '';}
1309
+            if(!$color_code){return '';}
1310 1310
 
1311
-			$rgb = self::hex_to_rgb($hex);
1311
+            $rgb = self::hex_to_rgb($hex);
1312 1312
 
1313
-			if($compatibility===true || $compatibility===1){
1314
-				$compatibility = '.bsui';
1315
-			}elseif(!$compatibility){
1316
-				$compatibility = '';
1317
-			}else{
1318
-				$compatibility = esc_attr($compatibility);
1319
-			}
1313
+            if($compatibility===true || $compatibility===1){
1314
+                $compatibility = '.bsui';
1315
+            }elseif(!$compatibility){
1316
+                $compatibility = '';
1317
+            }else{
1318
+                $compatibility = esc_attr($compatibility);
1319
+            }
1320 1320
 
1321
-			$prefix = $compatibility ? $compatibility . " " : "";
1321
+            $prefix = $compatibility ? $compatibility . " " : "";
1322 1322
 
1323 1323
 
1324 1324
             $output = '';
1325 1325
 
1326 1326
 //            echo '####'.$color_code;exit;
1327 1327
 
1328
-			$type = sanitize_html_class($type);
1328
+            $type = sanitize_html_class($type);
1329
+
1330
+            /**
1331
+             * c = color, b = background color, o = border-color, f = fill
1332
+             */
1333
+            $selectors = array(
1334
+                ".btn-{$type}"                                              => array( 'b', 'o' ),
1335
+                ".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1336
+                ".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1337
+                ".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1338
+                ".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1339
+                ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1340
+                ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1341
+                ".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1342
+                ".badge-{$type}"                                            => array( 'b' ),
1343
+                ".alert-{$type}"                                            => array( 'b', 'o' ),
1344
+                ".bg-{$type}"                                               => array( 'b', 'f' ),
1345
+                ".btn-link.btn-{$type}"                                     => array( 'c' ),
1346
+                ".text-{$type}"                                     => array( 'c' ),
1347
+            );
1348
+
1349
+            if ( $aui_bs5 ) {
1350
+                unset($selectors[".alert-{$type}" ]);
1351
+            }
1329 1352
 
1330
-			/**
1331
-			 * c = color, b = background color, o = border-color, f = fill
1332
-			 */
1333
-			$selectors = array(
1334
-				".btn-{$type}"                                              => array( 'b', 'o' ),
1335
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1336
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1337
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1338
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1339
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1340
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1341
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1342
-				".badge-{$type}"                                            => array( 'b' ),
1343
-				".alert-{$type}"                                            => array( 'b', 'o' ),
1344
-				".bg-{$type}"                                               => array( 'b', 'f' ),
1345
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
1346
-				".text-{$type}"                                     => array( 'c' ),
1347
-			);
1348
-
1349
-			if ( $aui_bs5 ) {
1350
-				unset($selectors[".alert-{$type}" ]);
1351
-			}
1352
-
1353
-			if ( $type == 'primary' ) {
1354
-				$selectors = $selectors + array(
1355
-						'a'                                                                                                    => array( 'c' ),
1356
-						'.btn-link'                                                                                            => array( 'c' ),
1357
-						'.dropdown-item.active'                                                                                => array( 'b' ),
1358
-						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
1359
-							'b',
1360
-							'o'
1361
-						),
1362
-						'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1363
-							'b',
1364
-							'o'
1365
-						),
1366
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1367
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1368
-						'.page-link'                                                                                           => array( 'c' ),
1369
-						'.page-item.active .page-link'                                                                         => array(
1370
-							'b',
1371
-							'o'
1372
-						),
1373
-						'.progress-bar'                                                                                        => array( 'b' ),
1374
-						'.list-group-item.active'                                                                              => array(
1375
-							'b',
1376
-							'o'
1377
-						),
1378
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1379
-					);
1380
-			}
1353
+            if ( $type == 'primary' ) {
1354
+                $selectors = $selectors + array(
1355
+                        'a'                                                                                                    => array( 'c' ),
1356
+                        '.btn-link'                                                                                            => array( 'c' ),
1357
+                        '.dropdown-item.active'                                                                                => array( 'b' ),
1358
+                        '.custom-control-input:checked~.custom-control-label::before'                                          => array(
1359
+                            'b',
1360
+                            'o'
1361
+                        ),
1362
+                        '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1363
+                            'b',
1364
+                            'o'
1365
+                        ),
1366
+                        '.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1367
+                        '.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1368
+                        '.page-link'                                                                                           => array( 'c' ),
1369
+                        '.page-item.active .page-link'                                                                         => array(
1370
+                            'b',
1371
+                            'o'
1372
+                        ),
1373
+                        '.progress-bar'                                                                                        => array( 'b' ),
1374
+                        '.list-group-item.active'                                                                              => array(
1375
+                            'b',
1376
+                            'o'
1377
+                        ),
1378
+                        '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1379
+                    );
1380
+            }
1381 1381
 
1382 1382
 
1383 1383
 
1384 1384
             // link
1385
-			if ( $type === 'primary' ) {
1386
-				$output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }';
1387
-				$output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).';  }';
1388
-				$output .= $prefix . ' .navbar { --bs-nav-link-hover-color: '.esc_attr($color_code).'; --bs-navbar-hover-color: '.esc_attr($color_code).'; --bs-navbar-active-color: '.esc_attr($color_code).'; }';
1385
+            if ( $type === 'primary' ) {
1386
+                $output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }';
1387
+                $output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).';  }';
1388
+                $output .= $prefix . ' .navbar { --bs-nav-link-hover-color: '.esc_attr($color_code).'; --bs-navbar-hover-color: '.esc_attr($color_code).'; --bs-navbar-active-color: '.esc_attr($color_code).'; }';
1389 1389
 
1390
-				$output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}';
1391
-				$output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}';
1390
+                $output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}';
1391
+                $output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}';
1392 1392
 
1393 1393
                 // dropdown
1394
-				$output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}';
1394
+                $output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}';
1395 1395
 
1396 1396
                 // pagination
1397
-				$output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}';
1397
+                $output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}';
1398 1398
 
1399
-			}
1399
+            }
1400 1400
 
1401
-			$output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}';
1401
+            $output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}';
1402 1402
 
1403
-			//  buttons
1404
-			$output .= $prefix . ' .btn-'.esc_attr($type).'{';
1405
-			$output .= ' 
1403
+            //  buttons
1404
+            $output .= $prefix . ' .btn-'.esc_attr($type).'{';
1405
+            $output .= ' 
1406 1406
             --bs-btn-bg: '.esc_attr($color_code).';
1407 1407
             --bs-btn-border-color: '.esc_attr($color_code).';
1408 1408
             --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
@@ -1420,11 +1420,11 @@  discard block
 block discarded – undo
1420 1420
 //			--bs-btn-active-color: #fff;
1421 1421
 //			--bs-btn-disabled-color: #fff;
1422 1422
 //            ';
1423
-			$output .= '}';
1423
+            $output .= '}';
1424 1424
 
1425
-			//  buttons outline
1426
-			$output .= $prefix . ' .btn-outline-'.esc_attr($type).'{';
1427
-			$output .= ' 
1425
+            //  buttons outline
1426
+            $output .= $prefix . ' .btn-outline-'.esc_attr($type).'{';
1427
+            $output .= ' 
1428 1428
             --bs-btn-border-color: '.esc_attr($color_code).';
1429 1429
             --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1430 1430
             --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
@@ -1441,37 +1441,37 @@  discard block
 block discarded – undo
1441 1441
 //			--bs-btn-active-color: #fff;
1442 1442
 //			--bs-btn-disabled-color: #fff;
1443 1443
 //            ';
1444
-			$output .= '}';
1444
+            $output .= '}';
1445 1445
 
1446 1446
 
1447 1447
             // button hover
1448
-			$output .= $prefix . ' .btn-'.esc_attr($type).':hover{';
1449
-			$output .= ' 
1448
+            $output .= $prefix . ' .btn-'.esc_attr($type).':hover{';
1449
+            $output .= ' 
1450 1450
             box-shadow: 0 0.25rem 0.25rem 0.125rem rgb(var(--bs-'.esc_attr($type).'-rgb), .1), 0 0.375rem 0.75rem -0.125rem rgb(var(--bs-'.esc_attr($type).'-rgb) , .4);
1451 1451
             }
1452 1452
             ';
1453 1453
 
1454 1454
 
1455
-			if ( $aui_bs5 ) {
1455
+            if ( $aui_bs5 ) {
1456 1456
 //				$output .= $is_var ? 'html body {--bs-'.esc_attr($type).'-rgb: '.$color_code.'; }' : 'html body {--bs-'.esc_attr($type).'-rgb: '.self::hex_to_rgb($color_code).'; }';
1457
-				$output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }';
1458
-				$output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1459
-			}
1457
+                $output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }';
1458
+                $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1459
+            }
1460 1460
 
1461 1461
 
1462
-			if ( $is_custom ) {
1462
+            if ( $is_custom ) {
1463 1463
 
1464 1464
 //				echo '###'.$type;exit;
1465 1465
 
1466
-				// build rules into each type
1467
-				foreach($selectors as $selector => $types){
1468
-					$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1469
-					$types = array_combine($types,$types);
1470
-					if(isset($types['c'])){$color[] = $selector;}
1471
-					if(isset($types['b'])){$background[] = $selector;}
1472
-					if(isset($types['o'])){$border[] = $selector;}
1473
-					if(isset($types['f'])){$fill[] = $selector;}
1474
-				}
1466
+                // build rules into each type
1467
+                foreach($selectors as $selector => $types){
1468
+                    $selector = $compatibility ? $compatibility . " ".$selector : $selector;
1469
+                    $types = array_combine($types,$types);
1470
+                    if(isset($types['c'])){$color[] = $selector;}
1471
+                    if(isset($types['b'])){$background[] = $selector;}
1472
+                    if(isset($types['o'])){$border[] = $selector;}
1473
+                    if(isset($types['f'])){$fill[] = $selector;}
1474
+                }
1475 1475
 
1476 1476
 //				// build rules into each type
1477 1477
 //				foreach($important_selectors as $selector => $types){
@@ -1483,67 +1483,67 @@  discard block
 block discarded – undo
1483 1483
 //					if(isset($types['f'])){$fill_i[] = $selector;}
1484 1484
 //				}
1485 1485
 
1486
-				// add any color rules
1487
-				if(!empty($color)){
1488
-					$output .= implode(",",$color) . "{color: $color_code;} ";
1489
-				}
1490
-				if(!empty($color_i)){
1491
-					$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1492
-				}
1486
+                // add any color rules
1487
+                if(!empty($color)){
1488
+                    $output .= implode(",",$color) . "{color: $color_code;} ";
1489
+                }
1490
+                if(!empty($color_i)){
1491
+                    $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1492
+                }
1493 1493
 
1494
-				// add any background color rules
1495
-				if(!empty($background)){
1496
-					$output .= implode(",",$background) . "{background-color: $color_code;} ";
1497
-				}
1498
-				if(!empty($background_i)){
1499
-					$output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1494
+                // add any background color rules
1495
+                if(!empty($background)){
1496
+                    $output .= implode(",",$background) . "{background-color: $color_code;} ";
1497
+                }
1498
+                if(!empty($background_i)){
1499
+                    $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1500 1500
 //				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1501
-				}
1501
+                }
1502 1502
 
1503
-				// add any border color rules
1504
-				if(!empty($border)){
1505
-					$output .= implode(",",$border) . "{border-color: $color_code;} ";
1506
-				}
1507
-				if(!empty($border_i)){
1508
-					$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1509
-				}
1503
+                // add any border color rules
1504
+                if(!empty($border)){
1505
+                    $output .= implode(",",$border) . "{border-color: $color_code;} ";
1506
+                }
1507
+                if(!empty($border_i)){
1508
+                    $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1509
+                }
1510 1510
 
1511
-				// add any fill color rules
1512
-				if(!empty($fill)){
1513
-					$output .= implode(",",$fill) . "{fill: $color_code;} ";
1514
-				}
1515
-				if(!empty($fill_i)){
1516
-					$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1517
-				}
1511
+                // add any fill color rules
1512
+                if(!empty($fill)){
1513
+                    $output .= implode(",",$fill) . "{fill: $color_code;} ";
1514
+                }
1515
+                if(!empty($fill_i)){
1516
+                    $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1517
+                }
1518 1518
 
1519
-			}
1519
+            }
1520 1520
 
1521 1521
 
1522 1522
 
1523 1523
 
1524
-			$transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
1525
-			// darken
1526
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1527
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1528
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1529
-			$darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1524
+            $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
1525
+            // darken
1526
+            $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1527
+            $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1528
+            $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1529
+            $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1530 1530
 
1531
-			// lighten
1532
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1531
+            // lighten
1532
+            $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1533 1533
 
1534
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1535
-			$op_25 = $color_code."40"; // 25% opacity
1534
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
1535
+            $op_25 = $color_code."40"; // 25% opacity
1536 1536
 
1537 1537
 
1538
-			// button states
1539
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1540
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1538
+            // button states
1539
+            $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1540
+            $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1541 1541
 //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1542
-			$output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1543
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1544
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1542
+            $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1543
+            $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1544
+            $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1545 1545
 
1546
-			// text
1546
+            // text
1547 1547
 //			$output .= $prefix .".xxx, .text-{$type} {color: var(--bs-".esc_attr($type).");} ";
1548 1548
 
1549 1549
 
@@ -1558,773 +1558,773 @@  discard block
 block discarded – undo
1558 1558
 //				$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1559 1559
 //			}
1560 1560
 
1561
-			// alerts
1562
-			if ( $aui_bs5 ) {
1561
+            // alerts
1562
+            if ( $aui_bs5 ) {
1563 1563
 //				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1564
-				$output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1565
-			}
1566
-
1567
-			return $output;
1568
-		}
1569
-
1570
-		/**
1571
-		 * Build the CSS to overwrite a bootstrap color variable.
1572
-		 *
1573
-		 * @param $type
1574
-		 * @param $color_code
1575
-		 * @param $compatibility
1576
-		 *
1577
-		 * @return string
1578
-		 */
1579
-		public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){
1564
+                $output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1565
+            }
1566
+
1567
+            return $output;
1568
+        }
1569
+
1570
+        /**
1571
+         * Build the CSS to overwrite a bootstrap color variable.
1572
+         *
1573
+         * @param $type
1574
+         * @param $color_code
1575
+         * @param $compatibility
1576
+         *
1577
+         * @return string
1578
+         */
1579
+        public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){
1580 1580
             global $aui_bs5;
1581 1581
 
1582
-			$is_var = false;
1583
-			if(!$color_code){return '';}
1584
-			if(strpos($color_code, 'var') !== false){
1585
-				//if(!sanitize_hex_color($color_code)){
1586
-				$color_code = esc_attr($color_code);
1587
-				$is_var = true;
1582
+            $is_var = false;
1583
+            if(!$color_code){return '';}
1584
+            if(strpos($color_code, 'var') !== false){
1585
+                //if(!sanitize_hex_color($color_code)){
1586
+                $color_code = esc_attr($color_code);
1587
+                $is_var = true;
1588 1588
 //				$color_code = "rgba($color_code, 0.5)";
1589 1589
 //                echo '###1'.$color_code.'###';//exit;
1590
-			}
1590
+            }
1591 1591
 
1592 1592
 //            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1593 1593
 
1594
-			if(!$color_code){return '';}
1594
+            if(!$color_code){return '';}
1595 1595
 
1596 1596
             $rgb = self::hex_to_rgb($hex);
1597 1597
 
1598
-			if($compatibility===true || $compatibility===1){
1599
-				$compatibility = '.bsui';
1600
-			}elseif(!$compatibility){
1601
-				$compatibility = '';
1602
-			}else{
1603
-				$compatibility = esc_attr($compatibility);
1604
-			}
1598
+            if($compatibility===true || $compatibility===1){
1599
+                $compatibility = '.bsui';
1600
+            }elseif(!$compatibility){
1601
+                $compatibility = '';
1602
+            }else{
1603
+                $compatibility = esc_attr($compatibility);
1604
+            }
1605 1605
 
1606 1606
 
1607 1607
 
1608 1608
 //            echo '####'.$color_code;exit;
1609 1609
 
1610
-			$type = sanitize_html_class($type);
1611
-
1612
-			/**
1613
-			 * c = color, b = background color, o = border-color, f = fill
1614
-			 */
1615
-			$selectors = array(
1616
-				".btn-{$type}"                                              => array( 'b', 'o' ),
1617
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1618
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1619
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1620
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1621
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1622
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1623
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1624
-				".badge-{$type}"                                            => array( 'b' ),
1625
-				".alert-{$type}"                                            => array( 'b', 'o' ),
1626
-				".bg-{$type}"                                               => array( 'b', 'f' ),
1627
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
1628
-			);
1629
-
1630
-			if ( $aui_bs5 ) {
1610
+            $type = sanitize_html_class($type);
1611
+
1612
+            /**
1613
+             * c = color, b = background color, o = border-color, f = fill
1614
+             */
1615
+            $selectors = array(
1616
+                ".btn-{$type}"                                              => array( 'b', 'o' ),
1617
+                ".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1618
+                ".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1619
+                ".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1620
+                ".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1621
+                ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1622
+                ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1623
+                ".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1624
+                ".badge-{$type}"                                            => array( 'b' ),
1625
+                ".alert-{$type}"                                            => array( 'b', 'o' ),
1626
+                ".bg-{$type}"                                               => array( 'b', 'f' ),
1627
+                ".btn-link.btn-{$type}"                                     => array( 'c' ),
1628
+            );
1629
+
1630
+            if ( $aui_bs5 ) {
1631 1631
                 unset($selectors[".alert-{$type}" ]);
1632
-			}
1633
-
1634
-			if ( $type == 'primary' ) {
1635
-				$selectors = $selectors + array(
1636
-						'a'                                                                                                    => array( 'c' ),
1637
-						'.btn-link'                                                                                            => array( 'c' ),
1638
-						'.dropdown-item.active'                                                                                => array( 'b' ),
1639
-						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
1640
-							'b',
1641
-							'o'
1642
-						),
1643
-						'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1644
-							'b',
1645
-							'o'
1646
-						),
1647
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1648
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1649
-						'.page-link'                                                                                           => array( 'c' ),
1650
-						'.page-item.active .page-link'                                                                         => array(
1651
-							'b',
1652
-							'o'
1653
-						),
1654
-						'.progress-bar'                                                                                        => array( 'b' ),
1655
-						'.list-group-item.active'                                                                              => array(
1656
-							'b',
1657
-							'o'
1658
-						),
1659
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1632
+            }
1633
+
1634
+            if ( $type == 'primary' ) {
1635
+                $selectors = $selectors + array(
1636
+                        'a'                                                                                                    => array( 'c' ),
1637
+                        '.btn-link'                                                                                            => array( 'c' ),
1638
+                        '.dropdown-item.active'                                                                                => array( 'b' ),
1639
+                        '.custom-control-input:checked~.custom-control-label::before'                                          => array(
1640
+                            'b',
1641
+                            'o'
1642
+                        ),
1643
+                        '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1644
+                            'b',
1645
+                            'o'
1646
+                        ),
1647
+                        '.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1648
+                        '.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1649
+                        '.page-link'                                                                                           => array( 'c' ),
1650
+                        '.page-item.active .page-link'                                                                         => array(
1651
+                            'b',
1652
+                            'o'
1653
+                        ),
1654
+                        '.progress-bar'                                                                                        => array( 'b' ),
1655
+                        '.list-group-item.active'                                                                              => array(
1656
+                            'b',
1657
+                            'o'
1658
+                        ),
1659
+                        '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1660 1660
 //				    '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1661 1661
 //				    '.custom-range::-moz-range-thumb' => array('b'),
1662 1662
 //				    '.custom-range::-ms-thumb' => array('b'),
1663
-					);
1664
-			}
1665
-
1666
-			$important_selectors = array(
1667
-				".bg-{$type}" => array('b','f'),
1668
-				".border-{$type}" => array('o'),
1669
-				".text-{$type}" => array('c'),
1670
-			);
1671
-
1672
-			$color = array();
1673
-			$color_i = array();
1674
-			$background = array();
1675
-			$background_i = array();
1676
-			$border = array();
1677
-			$border_i = array();
1678
-			$fill = array();
1679
-			$fill_i = array();
1680
-
1681
-			$output = '';
1682
-
1683
-			if ( $aui_bs5 ) {
1663
+                    );
1664
+            }
1665
+
1666
+            $important_selectors = array(
1667
+                ".bg-{$type}" => array('b','f'),
1668
+                ".border-{$type}" => array('o'),
1669
+                ".text-{$type}" => array('c'),
1670
+            );
1671
+
1672
+            $color = array();
1673
+            $color_i = array();
1674
+            $background = array();
1675
+            $background_i = array();
1676
+            $border = array();
1677
+            $border_i = array();
1678
+            $fill = array();
1679
+            $fill_i = array();
1680
+
1681
+            $output = '';
1682
+
1683
+            if ( $aui_bs5 ) {
1684 1684
 //				$output .= $is_var ? 'html body {--bs-'.esc_attr($type).'-rgb: '.$color_code.'; }' : 'html body {--bs-'.esc_attr($type).'-rgb: '.self::hex_to_rgb($color_code).'; }';
1685
-				$output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1686
-			}
1687
-
1688
-			// build rules into each type
1689
-			foreach($selectors as $selector => $types){
1690
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1691
-				$types = array_combine($types,$types);
1692
-				if(isset($types['c'])){$color[] = $selector;}
1693
-				if(isset($types['b'])){$background[] = $selector;}
1694
-				if(isset($types['o'])){$border[] = $selector;}
1695
-				if(isset($types['f'])){$fill[] = $selector;}
1696
-			}
1697
-
1698
-			// build rules into each type
1699
-			foreach($important_selectors as $selector => $types){
1700
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1701
-				$types = array_combine($types,$types);
1702
-				if(isset($types['c'])){$color_i[] = $selector;}
1703
-				if(isset($types['b'])){$background_i[] = $selector;}
1704
-				if(isset($types['o'])){$border_i[] = $selector;}
1705
-				if(isset($types['f'])){$fill_i[] = $selector;}
1706
-			}
1707
-
1708
-			// add any color rules
1709
-			if(!empty($color)){
1710
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1711
-			}
1712
-			if(!empty($color_i)){
1713
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1714
-			}
1715
-
1716
-			// add any background color rules
1717
-			if(!empty($background)){
1718
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1719
-			}
1720
-			if(!empty($background_i)){
1721
-				$output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1685
+                $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1686
+            }
1687
+
1688
+            // build rules into each type
1689
+            foreach($selectors as $selector => $types){
1690
+                $selector = $compatibility ? $compatibility . " ".$selector : $selector;
1691
+                $types = array_combine($types,$types);
1692
+                if(isset($types['c'])){$color[] = $selector;}
1693
+                if(isset($types['b'])){$background[] = $selector;}
1694
+                if(isset($types['o'])){$border[] = $selector;}
1695
+                if(isset($types['f'])){$fill[] = $selector;}
1696
+            }
1697
+
1698
+            // build rules into each type
1699
+            foreach($important_selectors as $selector => $types){
1700
+                $selector = $compatibility ? $compatibility . " ".$selector : $selector;
1701
+                $types = array_combine($types,$types);
1702
+                if(isset($types['c'])){$color_i[] = $selector;}
1703
+                if(isset($types['b'])){$background_i[] = $selector;}
1704
+                if(isset($types['o'])){$border_i[] = $selector;}
1705
+                if(isset($types['f'])){$fill_i[] = $selector;}
1706
+            }
1707
+
1708
+            // add any color rules
1709
+            if(!empty($color)){
1710
+                $output .= implode(",",$color) . "{color: $color_code;} ";
1711
+            }
1712
+            if(!empty($color_i)){
1713
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1714
+            }
1715
+
1716
+            // add any background color rules
1717
+            if(!empty($background)){
1718
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
1719
+            }
1720
+            if(!empty($background_i)){
1721
+                $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1722 1722
 //				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1723
-			}
1723
+            }
1724 1724
 
1725
-			// add any border color rules
1726
-			if(!empty($border)){
1727
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1728
-			}
1729
-			if(!empty($border_i)){
1730
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1731
-			}
1725
+            // add any border color rules
1726
+            if(!empty($border)){
1727
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
1728
+            }
1729
+            if(!empty($border_i)){
1730
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1731
+            }
1732 1732
 
1733
-			// add any fill color rules
1734
-			if(!empty($fill)){
1735
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1736
-			}
1737
-			if(!empty($fill_i)){
1738
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1739
-			}
1733
+            // add any fill color rules
1734
+            if(!empty($fill)){
1735
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
1736
+            }
1737
+            if(!empty($fill_i)){
1738
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1739
+            }
1740 1740
 
1741 1741
 
1742
-			$prefix = $compatibility ? $compatibility . " " : "";
1742
+            $prefix = $compatibility ? $compatibility . " " : "";
1743 1743
 
1744
-			$transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
1745
-			// darken
1746
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1747
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1748
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1749
-			$darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1744
+            $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
1745
+            // darken
1746
+            $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1747
+            $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1748
+            $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1749
+            $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1750 1750
 
1751
-			// lighten
1752
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1751
+            // lighten
1752
+            $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1753 1753
 
1754
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1755
-			$op_25 = $color_code."40"; // 25% opacity
1754
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
1755
+            $op_25 = $color_code."40"; // 25% opacity
1756 1756
 
1757 1757
 
1758
-			// button states
1759
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1760
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1758
+            // button states
1759
+            $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1760
+            $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1761 1761
 //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1762
-			$output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1763
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1764
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1762
+            $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1763
+            $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1764
+            $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1765 1765
 
1766
-			if ( $type == 'primary' ) {
1767
-				// dropdown's
1768
-				$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1766
+            if ( $type == 'primary' ) {
1767
+                // dropdown's
1768
+                $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1769 1769
 
1770
-				// input states
1771
-				$output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
1770
+                // input states
1771
+                $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
1772 1772
 
1773
-				// page link
1774
-				$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1775
-			}
1773
+                // page link
1774
+                $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1775
+            }
1776 1776
 
1777 1777
             // alerts
1778
-			if ( $aui_bs5 ) {
1778
+            if ( $aui_bs5 ) {
1779 1779
 //				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1780
-				$output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1781
-			}
1782
-
1783
-			return $output;
1784
-		}
1785
-
1786
-		/**
1787
-		 *
1788
-		 * @deprecated 0.1.76 Use css_overwrite()
1789
-		 *
1790
-		 * @param $color_code
1791
-		 * @param $compatibility
1792
-		 * @param $use_variable
1793
-		 *
1794
-		 * @return string
1795
-		 */
1796
-		public static function css_primary($color_code,$compatibility, $use_variable = false){
1797
-
1798
-			if(!$use_variable){
1799
-				$color_code = sanitize_hex_color($color_code);
1800
-				if(!$color_code){return '';}
1801
-			}
1802
-
1803
-			/**
1804
-			 * c = color, b = background color, o = border-color, f = fill
1805
-			 */
1806
-			$selectors = array(
1807
-				'a' => array('c'),
1808
-				'.btn-primary' => array('b','o'),
1809
-				'.btn-primary.disabled' => array('b','o'),
1810
-				'.btn-primary:disabled' => array('b','o'),
1811
-				'.btn-outline-primary' => array('c','o'),
1812
-				'.btn-outline-primary:hover' => array('b','o'),
1813
-				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
1814
-				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
1815
-				'.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
1816
-				'.btn-link' => array('c'),
1817
-				'.dropdown-item.active' => array('b'),
1818
-				'.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
1819
-				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
1780
+                $output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1781
+            }
1782
+
1783
+            return $output;
1784
+        }
1785
+
1786
+        /**
1787
+         *
1788
+         * @deprecated 0.1.76 Use css_overwrite()
1789
+         *
1790
+         * @param $color_code
1791
+         * @param $compatibility
1792
+         * @param $use_variable
1793
+         *
1794
+         * @return string
1795
+         */
1796
+        public static function css_primary($color_code,$compatibility, $use_variable = false){
1797
+
1798
+            if(!$use_variable){
1799
+                $color_code = sanitize_hex_color($color_code);
1800
+                if(!$color_code){return '';}
1801
+            }
1802
+
1803
+            /**
1804
+             * c = color, b = background color, o = border-color, f = fill
1805
+             */
1806
+            $selectors = array(
1807
+                'a' => array('c'),
1808
+                '.btn-primary' => array('b','o'),
1809
+                '.btn-primary.disabled' => array('b','o'),
1810
+                '.btn-primary:disabled' => array('b','o'),
1811
+                '.btn-outline-primary' => array('c','o'),
1812
+                '.btn-outline-primary:hover' => array('b','o'),
1813
+                '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
1814
+                '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
1815
+                '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
1816
+                '.btn-link' => array('c'),
1817
+                '.dropdown-item.active' => array('b'),
1818
+                '.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
1819
+                '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
1820 1820
 //				'.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1821 1821
 //				'.custom-range::-moz-range-thumb' => array('b'),
1822 1822
 //				'.custom-range::-ms-thumb' => array('b'),
1823
-				'.nav-pills .nav-link.active' => array('b'),
1824
-				'.nav-pills .show>.nav-link' => array('b'),
1825
-				'.page-link' => array('c'),
1826
-				'.page-item.active .page-link' => array('b','o'),
1827
-				'.badge-primary' => array('b'),
1828
-				'.alert-primary' => array('b','o'),
1829
-				'.progress-bar' => array('b'),
1830
-				'.list-group-item.active' => array('b','o'),
1831
-				'.bg-primary' => array('b','f'),
1832
-				'.btn-link.btn-primary' => array('c'),
1833
-				'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1834
-			);
1835
-
1836
-			$important_selectors = array(
1837
-				'.bg-primary' => array('b','f'),
1838
-				'.border-primary' => array('o'),
1839
-				'.text-primary' => array('c'),
1840
-			);
1841
-
1842
-			$color = array();
1843
-			$color_i = array();
1844
-			$background = array();
1845
-			$background_i = array();
1846
-			$border = array();
1847
-			$border_i = array();
1848
-			$fill = array();
1849
-			$fill_i = array();
1850
-
1851
-			$output = '';
1852
-
1853
-			// build rules into each type
1854
-			foreach($selectors as $selector => $types){
1855
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1856
-				$types = array_combine($types,$types);
1857
-				if(isset($types['c'])){$color[] = $selector;}
1858
-				if(isset($types['b'])){$background[] = $selector;}
1859
-				if(isset($types['o'])){$border[] = $selector;}
1860
-				if(isset($types['f'])){$fill[] = $selector;}
1861
-			}
1862
-
1863
-			// build rules into each type
1864
-			foreach($important_selectors as $selector => $types){
1865
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1866
-				$types = array_combine($types,$types);
1867
-				if(isset($types['c'])){$color_i[] = $selector;}
1868
-				if(isset($types['b'])){$background_i[] = $selector;}
1869
-				if(isset($types['o'])){$border_i[] = $selector;}
1870
-				if(isset($types['f'])){$fill_i[] = $selector;}
1871
-			}
1872
-
1873
-			// add any color rules
1874
-			if(!empty($color)){
1875
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1876
-			}
1877
-			if(!empty($color_i)){
1878
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1879
-			}
1880
-
1881
-			// add any background color rules
1882
-			if(!empty($background)){
1883
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1884
-			}
1885
-			if(!empty($background_i)){
1886
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1887
-			}
1888
-
1889
-			// add any border color rules
1890
-			if(!empty($border)){
1891
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1892
-			}
1893
-			if(!empty($border_i)){
1894
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1895
-			}
1896
-
1897
-			// add any fill color rules
1898
-			if(!empty($fill)){
1899
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1900
-			}
1901
-			if(!empty($fill_i)){
1902
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1903
-			}
1904
-
1905
-
1906
-			$prefix = $compatibility ? ".bsui " : "";
1907
-
1908
-			// darken
1909
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1910
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1911
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1912
-
1913
-			// lighten
1914
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1915
-
1916
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1917
-			$op_25 = $color_code."40"; // 25% opacity
1918
-
1919
-
1920
-			// button states
1921
-			$output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1922
-			$output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1923
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1924
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1925
-
1926
-
1927
-			// dropdown's
1928
-			$output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1929
-
1930
-
1931
-			// input states
1932
-			$output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
1933
-
1934
-			// page link
1935
-			$output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1936
-
1937
-			return $output;
1938
-		}
1939
-
1940
-		/**
1941
-		 *
1942
-		 * @deprecated 0.1.76 Use css_overwrite()
1943
-		 *
1944
-		 * @param $color_code
1945
-		 * @param $compatibility
1946
-		 *
1947
-		 * @return string
1948
-		 */
1949
-		public static function css_secondary($color_code,$compatibility){;
1950
-			$color_code = sanitize_hex_color($color_code);
1951
-			if(!$color_code){return '';}
1952
-			/**
1953
-			 * c = color, b = background color, o = border-color, f = fill
1954
-			 */
1955
-			$selectors = array(
1956
-				'.btn-secondary' => array('b','o'),
1957
-				'.btn-secondary.disabled' => array('b','o'),
1958
-				'.btn-secondary:disabled' => array('b','o'),
1959
-				'.btn-outline-secondary' => array('c','o'),
1960
-				'.btn-outline-secondary:hover' => array('b','o'),
1961
-				'.btn-outline-secondary.disabled' => array('c'),
1962
-				'.btn-outline-secondary:disabled' => array('c'),
1963
-				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
1964
-				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
1965
-				'.btn-outline-secondary.dropdown-toggle' => array('b','o'),
1966
-				'.badge-secondary' => array('b'),
1967
-				'.alert-secondary' => array('b','o'),
1968
-				'.btn-link.btn-secondary' => array('c'),
1969
-			);
1970
-
1971
-			$important_selectors = array(
1972
-				'.bg-secondary' => array('b','f'),
1973
-				'.border-secondary' => array('o'),
1974
-				'.text-secondary' => array('c'),
1975
-			);
1976
-
1977
-			$color = array();
1978
-			$color_i = array();
1979
-			$background = array();
1980
-			$background_i = array();
1981
-			$border = array();
1982
-			$border_i = array();
1983
-			$fill = array();
1984
-			$fill_i = array();
1985
-
1986
-			$output = '';
1987
-
1988
-			// build rules into each type
1989
-			foreach($selectors as $selector => $types){
1990
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1991
-				$types = array_combine($types,$types);
1992
-				if(isset($types['c'])){$color[] = $selector;}
1993
-				if(isset($types['b'])){$background[] = $selector;}
1994
-				if(isset($types['o'])){$border[] = $selector;}
1995
-				if(isset($types['f'])){$fill[] = $selector;}
1996
-			}
1997
-
1998
-			// build rules into each type
1999
-			foreach($important_selectors as $selector => $types){
2000
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2001
-				$types = array_combine($types,$types);
2002
-				if(isset($types['c'])){$color_i[] = $selector;}
2003
-				if(isset($types['b'])){$background_i[] = $selector;}
2004
-				if(isset($types['o'])){$border_i[] = $selector;}
2005
-				if(isset($types['f'])){$fill_i[] = $selector;}
2006
-			}
2007
-
2008
-			// add any color rules
2009
-			if(!empty($color)){
2010
-				$output .= implode(",",$color) . "{color: $color_code;} ";
2011
-			}
2012
-			if(!empty($color_i)){
2013
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2014
-			}
2015
-
2016
-			// add any background color rules
2017
-			if(!empty($background)){
2018
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
2019
-			}
2020
-			if(!empty($background_i)){
2021
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2022
-			}
2023
-
2024
-			// add any border color rules
2025
-			if(!empty($border)){
2026
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
2027
-			}
2028
-			if(!empty($border_i)){
2029
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2030
-			}
2031
-
2032
-			// add any fill color rules
2033
-			if(!empty($fill)){
2034
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
2035
-			}
2036
-			if(!empty($fill_i)){
2037
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2038
-			}
2039
-
2040
-
2041
-			$prefix = $compatibility ? ".bsui " : "";
2042
-
2043
-			// darken
2044
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2045
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2046
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2047
-
2048
-			// lighten
2049
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2050
-
2051
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
2052
-			$op_25 = $color_code."40"; // 25% opacity
2053
-
2054
-
2055
-			// button states
2056
-			$output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2057
-			$output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2058
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
2059
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2060
-
2061
-
2062
-			return $output;
2063
-		}
2064
-
2065
-		/**
2066
-		 * Increases or decreases the brightness of a color by a percentage of the current brightness.
2067
-		 *
2068
-		 * @param   string  $hexCode        Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
2069
-		 * @param   float   $adjustPercent  A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker.
2070
-		 *
2071
-		 * @return  string
2072
-		 */
2073
-		public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
2074
-			$hexCode = ltrim($hexCode, '#');
2075
-
2076
-			if (strlen($hexCode) == 3) {
2077
-				$hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
2078
-			}
2079
-
2080
-			$hexCode = array_map('hexdec', str_split($hexCode, 2));
2081
-
2082
-			foreach ($hexCode as & $color) {
2083
-				$adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
2084
-				$adjustAmount = ceil($adjustableLimit * $adjustPercent);
2085
-
2086
-				$color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
2087
-			}
2088
-
2089
-			return '#' . implode($hexCode);
2090
-		}
2091
-
2092
-		/**
2093
-		 * Check if we should display examples.
2094
-		 */
2095
-		public function maybe_show_examples(){
2096
-			if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
2097
-				echo "<head>";
2098
-				wp_head();
2099
-				echo "</head>";
2100
-				echo "<body>";
2101
-				echo $this->get_examples();
2102
-				echo "</body>";
2103
-				exit;
2104
-			}
2105
-		}
2106
-
2107
-		/**
2108
-		 * Get developer examples.
2109
-		 *
2110
-		 * @return string
2111
-		 */
2112
-		public function get_examples(){
2113
-			$output = '';
2114
-
2115
-
2116
-			// open form
2117
-			$output .= "<form class='p-5 m-5 border rounded'>";
2118
-
2119
-			// input example
2120
-			$output .= aui()->input(array(
2121
-				'type'  =>  'text',
2122
-				'id'    =>  'text-example',
2123
-				'name'    =>  'text-example',
2124
-				'placeholder'   => 'text placeholder',
2125
-				'title'   => 'Text input example',
2126
-				'value' =>  '',
2127
-				'required'  => false,
2128
-				'help_text' => 'help text',
2129
-				'label' => 'Text input example label'
2130
-			));
2131
-
2132
-			// input example
2133
-			$output .= aui()->input(array(
2134
-				'type'  =>  'url',
2135
-				'id'    =>  'text-example2',
2136
-				'name'    =>  'text-example',
2137
-				'placeholder'   => 'url placeholder',
2138
-				'title'   => 'Text input example',
2139
-				'value' =>  '',
2140
-				'required'  => false,
2141
-				'help_text' => 'help text',
2142
-				'label' => 'Text input example label'
2143
-			));
2144
-
2145
-			// checkbox example
2146
-			$output .= aui()->input(array(
2147
-				'type'  =>  'checkbox',
2148
-				'id'    =>  'checkbox-example',
2149
-				'name'    =>  'checkbox-example',
2150
-				'placeholder'   => 'checkbox-example',
2151
-				'title'   => 'Checkbox example',
2152
-				'value' =>  '1',
2153
-				'checked'   => true,
2154
-				'required'  => false,
2155
-				'help_text' => 'help text',
2156
-				'label' => 'Checkbox checked'
2157
-			));
2158
-
2159
-			// checkbox example
2160
-			$output .= aui()->input(array(
2161
-				'type'  =>  'checkbox',
2162
-				'id'    =>  'checkbox-example2',
2163
-				'name'    =>  'checkbox-example2',
2164
-				'placeholder'   => 'checkbox-example',
2165
-				'title'   => 'Checkbox example',
2166
-				'value' =>  '1',
2167
-				'checked'   => false,
2168
-				'required'  => false,
2169
-				'help_text' => 'help text',
2170
-				'label' => 'Checkbox un-checked'
2171
-			));
2172
-
2173
-			// switch example
2174
-			$output .= aui()->input(array(
2175
-				'type'  =>  'checkbox',
2176
-				'id'    =>  'switch-example',
2177
-				'name'    =>  'switch-example',
2178
-				'placeholder'   => 'checkbox-example',
2179
-				'title'   => 'Switch example',
2180
-				'value' =>  '1',
2181
-				'checked'   => true,
2182
-				'switch'    => true,
2183
-				'required'  => false,
2184
-				'help_text' => 'help text',
2185
-				'label' => 'Switch on'
2186
-			));
2187
-
2188
-			// switch example
2189
-			$output .= aui()->input(array(
2190
-				'type'  =>  'checkbox',
2191
-				'id'    =>  'switch-example2',
2192
-				'name'    =>  'switch-example2',
2193
-				'placeholder'   => 'checkbox-example',
2194
-				'title'   => 'Switch example',
2195
-				'value' =>  '1',
2196
-				'checked'   => false,
2197
-				'switch'    => true,
2198
-				'required'  => false,
2199
-				'help_text' => 'help text',
2200
-				'label' => 'Switch off'
2201
-			));
2202
-
2203
-			// close form
2204
-			$output .= "</form>";
2205
-
2206
-			return $output;
2207
-		}
2208
-
2209
-		/**
2210
-		 * Calendar params.
2211
-		 *
2212
-		 * @since 0.1.44
2213
-		 *
2214
-		 * @return array Calendar params.
2215
-		 */
2216
-		public static function calendar_params() {
2217
-			$params = array(
2218
-				'month_long_1' => __( 'January', 'ayecode-connect' ),
2219
-				'month_long_2' => __( 'February', 'ayecode-connect' ),
2220
-				'month_long_3' => __( 'March', 'ayecode-connect' ),
2221
-				'month_long_4' => __( 'April', 'ayecode-connect' ),
2222
-				'month_long_5' => __( 'May', 'ayecode-connect' ),
2223
-				'month_long_6' => __( 'June', 'ayecode-connect' ),
2224
-				'month_long_7' => __( 'July', 'ayecode-connect' ),
2225
-				'month_long_8' => __( 'August', 'ayecode-connect' ),
2226
-				'month_long_9' => __( 'September', 'ayecode-connect' ),
2227
-				'month_long_10' => __( 'October', 'ayecode-connect' ),
2228
-				'month_long_11' => __( 'November', 'ayecode-connect' ),
2229
-				'month_long_12' => __( 'December', 'ayecode-connect' ),
2230
-				'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ),
2231
-				'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ),
2232
-				'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ),
2233
-				'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ),
2234
-				'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ),
2235
-				'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ),
2236
-				'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ),
2237
-				'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ),
2238
-				'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ),
2239
-				'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ),
2240
-				'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ),
2241
-				'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ),
2242
-				'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ),
2243
-				'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ),
2244
-				'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ),
2245
-				'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ),
2246
-				'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ),
2247
-				'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ),
2248
-				'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ),
2249
-				'day_s2_1' => __( 'Su', 'ayecode-connect' ),
2250
-				'day_s2_2' => __( 'Mo', 'ayecode-connect' ),
2251
-				'day_s2_3' => __( 'Tu', 'ayecode-connect' ),
2252
-				'day_s2_4' => __( 'We', 'ayecode-connect' ),
2253
-				'day_s2_5' => __( 'Th', 'ayecode-connect' ),
2254
-				'day_s2_6' => __( 'Fr', 'ayecode-connect' ),
2255
-				'day_s2_7' => __( 'Sa', 'ayecode-connect' ),
2256
-				'day_s3_1' => __( 'Sun', 'ayecode-connect' ),
2257
-				'day_s3_2' => __( 'Mon', 'ayecode-connect' ),
2258
-				'day_s3_3' => __( 'Tue', 'ayecode-connect' ),
2259
-				'day_s3_4' => __( 'Wed', 'ayecode-connect' ),
2260
-				'day_s3_5' => __( 'Thu', 'ayecode-connect' ),
2261
-				'day_s3_6' => __( 'Fri', 'ayecode-connect' ),
2262
-				'day_s3_7' => __( 'Sat', 'ayecode-connect' ),
2263
-				'day_s5_1' => __( 'Sunday', 'ayecode-connect' ),
2264
-				'day_s5_2' => __( 'Monday', 'ayecode-connect' ),
2265
-				'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ),
2266
-				'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ),
2267
-				'day_s5_5' => __( 'Thursday', 'ayecode-connect' ),
2268
-				'day_s5_6' => __( 'Friday', 'ayecode-connect' ),
2269
-				'day_s5_7' => __( 'Saturday', 'ayecode-connect' ),
2270
-				'am_lower' => __( 'am', 'ayecode-connect' ),
2271
-				'pm_lower' => __( 'pm', 'ayecode-connect' ),
2272
-				'am_upper' => __( 'AM', 'ayecode-connect' ),
2273
-				'pm_upper' => __( 'PM', 'ayecode-connect' ),
2274
-				'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
2275
-				'time_24hr' => false,
2276
-				'year' => __( 'Year', 'ayecode-connect' ),
2277
-				'hour' => __( 'Hour', 'ayecode-connect' ),
2278
-				'minute' => __( 'Minute', 'ayecode-connect' ),
2279
-				'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ),
2280
-				'rangeSeparator' => __( ' to ', 'ayecode-connect' ),
2281
-				'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ),
2282
-				'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' )
2283
-			);
2284
-
2285
-			return apply_filters( 'ayecode_ui_calendar_params', $params );
2286
-		}
2287
-
2288
-		/**
2289
-		 * Flatpickr calendar localize.
2290
-		 *
2291
-		 * @since 0.1.44
2292
-		 *
2293
-		 * @return string Calendar locale.
2294
-		 */
2295
-		public static function flatpickr_locale() {
2296
-			$params = self::calendar_params();
2297
-
2298
-			if ( is_string( $params ) ) {
2299
-				$params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
2300
-			} else {
2301
-				foreach ( (array) $params as $key => $value ) {
2302
-					if ( ! is_scalar( $value ) ) {
2303
-						continue;
2304
-					}
2305
-
2306
-					$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2307
-				}
2308
-			}
1823
+                '.nav-pills .nav-link.active' => array('b'),
1824
+                '.nav-pills .show>.nav-link' => array('b'),
1825
+                '.page-link' => array('c'),
1826
+                '.page-item.active .page-link' => array('b','o'),
1827
+                '.badge-primary' => array('b'),
1828
+                '.alert-primary' => array('b','o'),
1829
+                '.progress-bar' => array('b'),
1830
+                '.list-group-item.active' => array('b','o'),
1831
+                '.bg-primary' => array('b','f'),
1832
+                '.btn-link.btn-primary' => array('c'),
1833
+                '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1834
+            );
1835
+
1836
+            $important_selectors = array(
1837
+                '.bg-primary' => array('b','f'),
1838
+                '.border-primary' => array('o'),
1839
+                '.text-primary' => array('c'),
1840
+            );
1841
+
1842
+            $color = array();
1843
+            $color_i = array();
1844
+            $background = array();
1845
+            $background_i = array();
1846
+            $border = array();
1847
+            $border_i = array();
1848
+            $fill = array();
1849
+            $fill_i = array();
1850
+
1851
+            $output = '';
1852
+
1853
+            // build rules into each type
1854
+            foreach($selectors as $selector => $types){
1855
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
1856
+                $types = array_combine($types,$types);
1857
+                if(isset($types['c'])){$color[] = $selector;}
1858
+                if(isset($types['b'])){$background[] = $selector;}
1859
+                if(isset($types['o'])){$border[] = $selector;}
1860
+                if(isset($types['f'])){$fill[] = $selector;}
1861
+            }
1862
+
1863
+            // build rules into each type
1864
+            foreach($important_selectors as $selector => $types){
1865
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
1866
+                $types = array_combine($types,$types);
1867
+                if(isset($types['c'])){$color_i[] = $selector;}
1868
+                if(isset($types['b'])){$background_i[] = $selector;}
1869
+                if(isset($types['o'])){$border_i[] = $selector;}
1870
+                if(isset($types['f'])){$fill_i[] = $selector;}
1871
+            }
1872
+
1873
+            // add any color rules
1874
+            if(!empty($color)){
1875
+                $output .= implode(",",$color) . "{color: $color_code;} ";
1876
+            }
1877
+            if(!empty($color_i)){
1878
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1879
+            }
1880
+
1881
+            // add any background color rules
1882
+            if(!empty($background)){
1883
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
1884
+            }
1885
+            if(!empty($background_i)){
1886
+                $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1887
+            }
1888
+
1889
+            // add any border color rules
1890
+            if(!empty($border)){
1891
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
1892
+            }
1893
+            if(!empty($border_i)){
1894
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1895
+            }
1896
+
1897
+            // add any fill color rules
1898
+            if(!empty($fill)){
1899
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
1900
+            }
1901
+            if(!empty($fill_i)){
1902
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1903
+            }
1904
+
1905
+
1906
+            $prefix = $compatibility ? ".bsui " : "";
1907
+
1908
+            // darken
1909
+            $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1910
+            $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1911
+            $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1912
+
1913
+            // lighten
1914
+            $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2309 1915
 
2310
-			$day_s3 = array();
2311
-			$day_s5 = array();
1916
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
1917
+            $op_25 = $color_code."40"; // 25% opacity
2312 1918
 
2313
-			for ( $i = 1; $i <= 7; $i ++ ) {
2314
-				$day_s3[] = addslashes( $params[ 'day_s3_' . $i ] );
2315
-				$day_s5[] = addslashes( $params[ 'day_s3_' . $i ] );
2316
-			}
2317 1919
 
2318
-			$month_s = array();
2319
-			$month_long = array();
1920
+            // button states
1921
+            $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1922
+            $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1923
+            $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1924
+            $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2320 1925
 
2321
-			for ( $i = 1; $i <= 12; $i ++ ) {
2322
-				$month_s[] = addslashes( $params[ 'month_s_' . $i ] );
2323
-				$month_long[] = addslashes( $params[ 'month_long_' . $i ] );
2324
-			}
2325 1926
 
2326
-			ob_start();
2327
-		if ( 0 ) { ?><script><?php } ?>
1927
+            // dropdown's
1928
+            $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1929
+
1930
+
1931
+            // input states
1932
+            $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
1933
+
1934
+            // page link
1935
+            $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1936
+
1937
+            return $output;
1938
+        }
1939
+
1940
+        /**
1941
+         *
1942
+         * @deprecated 0.1.76 Use css_overwrite()
1943
+         *
1944
+         * @param $color_code
1945
+         * @param $compatibility
1946
+         *
1947
+         * @return string
1948
+         */
1949
+        public static function css_secondary($color_code,$compatibility){;
1950
+            $color_code = sanitize_hex_color($color_code);
1951
+            if(!$color_code){return '';}
1952
+            /**
1953
+             * c = color, b = background color, o = border-color, f = fill
1954
+             */
1955
+            $selectors = array(
1956
+                '.btn-secondary' => array('b','o'),
1957
+                '.btn-secondary.disabled' => array('b','o'),
1958
+                '.btn-secondary:disabled' => array('b','o'),
1959
+                '.btn-outline-secondary' => array('c','o'),
1960
+                '.btn-outline-secondary:hover' => array('b','o'),
1961
+                '.btn-outline-secondary.disabled' => array('c'),
1962
+                '.btn-outline-secondary:disabled' => array('c'),
1963
+                '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
1964
+                '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
1965
+                '.btn-outline-secondary.dropdown-toggle' => array('b','o'),
1966
+                '.badge-secondary' => array('b'),
1967
+                '.alert-secondary' => array('b','o'),
1968
+                '.btn-link.btn-secondary' => array('c'),
1969
+            );
1970
+
1971
+            $important_selectors = array(
1972
+                '.bg-secondary' => array('b','f'),
1973
+                '.border-secondary' => array('o'),
1974
+                '.text-secondary' => array('c'),
1975
+            );
1976
+
1977
+            $color = array();
1978
+            $color_i = array();
1979
+            $background = array();
1980
+            $background_i = array();
1981
+            $border = array();
1982
+            $border_i = array();
1983
+            $fill = array();
1984
+            $fill_i = array();
1985
+
1986
+            $output = '';
1987
+
1988
+            // build rules into each type
1989
+            foreach($selectors as $selector => $types){
1990
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
1991
+                $types = array_combine($types,$types);
1992
+                if(isset($types['c'])){$color[] = $selector;}
1993
+                if(isset($types['b'])){$background[] = $selector;}
1994
+                if(isset($types['o'])){$border[] = $selector;}
1995
+                if(isset($types['f'])){$fill[] = $selector;}
1996
+            }
1997
+
1998
+            // build rules into each type
1999
+            foreach($important_selectors as $selector => $types){
2000
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
2001
+                $types = array_combine($types,$types);
2002
+                if(isset($types['c'])){$color_i[] = $selector;}
2003
+                if(isset($types['b'])){$background_i[] = $selector;}
2004
+                if(isset($types['o'])){$border_i[] = $selector;}
2005
+                if(isset($types['f'])){$fill_i[] = $selector;}
2006
+            }
2007
+
2008
+            // add any color rules
2009
+            if(!empty($color)){
2010
+                $output .= implode(",",$color) . "{color: $color_code;} ";
2011
+            }
2012
+            if(!empty($color_i)){
2013
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2014
+            }
2015
+
2016
+            // add any background color rules
2017
+            if(!empty($background)){
2018
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
2019
+            }
2020
+            if(!empty($background_i)){
2021
+                $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2022
+            }
2023
+
2024
+            // add any border color rules
2025
+            if(!empty($border)){
2026
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
2027
+            }
2028
+            if(!empty($border_i)){
2029
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2030
+            }
2031
+
2032
+            // add any fill color rules
2033
+            if(!empty($fill)){
2034
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
2035
+            }
2036
+            if(!empty($fill_i)){
2037
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2038
+            }
2039
+
2040
+
2041
+            $prefix = $compatibility ? ".bsui " : "";
2042
+
2043
+            // darken
2044
+            $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2045
+            $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2046
+            $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2047
+
2048
+            // lighten
2049
+            $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2050
+
2051
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
2052
+            $op_25 = $color_code."40"; // 25% opacity
2053
+
2054
+
2055
+            // button states
2056
+            $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2057
+            $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2058
+            $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
2059
+            $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2060
+
2061
+
2062
+            return $output;
2063
+        }
2064
+
2065
+        /**
2066
+         * Increases or decreases the brightness of a color by a percentage of the current brightness.
2067
+         *
2068
+         * @param   string  $hexCode        Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
2069
+         * @param   float   $adjustPercent  A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker.
2070
+         *
2071
+         * @return  string
2072
+         */
2073
+        public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
2074
+            $hexCode = ltrim($hexCode, '#');
2075
+
2076
+            if (strlen($hexCode) == 3) {
2077
+                $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
2078
+            }
2079
+
2080
+            $hexCode = array_map('hexdec', str_split($hexCode, 2));
2081
+
2082
+            foreach ($hexCode as & $color) {
2083
+                $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
2084
+                $adjustAmount = ceil($adjustableLimit * $adjustPercent);
2085
+
2086
+                $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
2087
+            }
2088
+
2089
+            return '#' . implode($hexCode);
2090
+        }
2091
+
2092
+        /**
2093
+         * Check if we should display examples.
2094
+         */
2095
+        public function maybe_show_examples(){
2096
+            if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
2097
+                echo "<head>";
2098
+                wp_head();
2099
+                echo "</head>";
2100
+                echo "<body>";
2101
+                echo $this->get_examples();
2102
+                echo "</body>";
2103
+                exit;
2104
+            }
2105
+        }
2106
+
2107
+        /**
2108
+         * Get developer examples.
2109
+         *
2110
+         * @return string
2111
+         */
2112
+        public function get_examples(){
2113
+            $output = '';
2114
+
2115
+
2116
+            // open form
2117
+            $output .= "<form class='p-5 m-5 border rounded'>";
2118
+
2119
+            // input example
2120
+            $output .= aui()->input(array(
2121
+                'type'  =>  'text',
2122
+                'id'    =>  'text-example',
2123
+                'name'    =>  'text-example',
2124
+                'placeholder'   => 'text placeholder',
2125
+                'title'   => 'Text input example',
2126
+                'value' =>  '',
2127
+                'required'  => false,
2128
+                'help_text' => 'help text',
2129
+                'label' => 'Text input example label'
2130
+            ));
2131
+
2132
+            // input example
2133
+            $output .= aui()->input(array(
2134
+                'type'  =>  'url',
2135
+                'id'    =>  'text-example2',
2136
+                'name'    =>  'text-example',
2137
+                'placeholder'   => 'url placeholder',
2138
+                'title'   => 'Text input example',
2139
+                'value' =>  '',
2140
+                'required'  => false,
2141
+                'help_text' => 'help text',
2142
+                'label' => 'Text input example label'
2143
+            ));
2144
+
2145
+            // checkbox example
2146
+            $output .= aui()->input(array(
2147
+                'type'  =>  'checkbox',
2148
+                'id'    =>  'checkbox-example',
2149
+                'name'    =>  'checkbox-example',
2150
+                'placeholder'   => 'checkbox-example',
2151
+                'title'   => 'Checkbox example',
2152
+                'value' =>  '1',
2153
+                'checked'   => true,
2154
+                'required'  => false,
2155
+                'help_text' => 'help text',
2156
+                'label' => 'Checkbox checked'
2157
+            ));
2158
+
2159
+            // checkbox example
2160
+            $output .= aui()->input(array(
2161
+                'type'  =>  'checkbox',
2162
+                'id'    =>  'checkbox-example2',
2163
+                'name'    =>  'checkbox-example2',
2164
+                'placeholder'   => 'checkbox-example',
2165
+                'title'   => 'Checkbox example',
2166
+                'value' =>  '1',
2167
+                'checked'   => false,
2168
+                'required'  => false,
2169
+                'help_text' => 'help text',
2170
+                'label' => 'Checkbox un-checked'
2171
+            ));
2172
+
2173
+            // switch example
2174
+            $output .= aui()->input(array(
2175
+                'type'  =>  'checkbox',
2176
+                'id'    =>  'switch-example',
2177
+                'name'    =>  'switch-example',
2178
+                'placeholder'   => 'checkbox-example',
2179
+                'title'   => 'Switch example',
2180
+                'value' =>  '1',
2181
+                'checked'   => true,
2182
+                'switch'    => true,
2183
+                'required'  => false,
2184
+                'help_text' => 'help text',
2185
+                'label' => 'Switch on'
2186
+            ));
2187
+
2188
+            // switch example
2189
+            $output .= aui()->input(array(
2190
+                'type'  =>  'checkbox',
2191
+                'id'    =>  'switch-example2',
2192
+                'name'    =>  'switch-example2',
2193
+                'placeholder'   => 'checkbox-example',
2194
+                'title'   => 'Switch example',
2195
+                'value' =>  '1',
2196
+                'checked'   => false,
2197
+                'switch'    => true,
2198
+                'required'  => false,
2199
+                'help_text' => 'help text',
2200
+                'label' => 'Switch off'
2201
+            ));
2202
+
2203
+            // close form
2204
+            $output .= "</form>";
2205
+
2206
+            return $output;
2207
+        }
2208
+
2209
+        /**
2210
+         * Calendar params.
2211
+         *
2212
+         * @since 0.1.44
2213
+         *
2214
+         * @return array Calendar params.
2215
+         */
2216
+        public static function calendar_params() {
2217
+            $params = array(
2218
+                'month_long_1' => __( 'January', 'ayecode-connect' ),
2219
+                'month_long_2' => __( 'February', 'ayecode-connect' ),
2220
+                'month_long_3' => __( 'March', 'ayecode-connect' ),
2221
+                'month_long_4' => __( 'April', 'ayecode-connect' ),
2222
+                'month_long_5' => __( 'May', 'ayecode-connect' ),
2223
+                'month_long_6' => __( 'June', 'ayecode-connect' ),
2224
+                'month_long_7' => __( 'July', 'ayecode-connect' ),
2225
+                'month_long_8' => __( 'August', 'ayecode-connect' ),
2226
+                'month_long_9' => __( 'September', 'ayecode-connect' ),
2227
+                'month_long_10' => __( 'October', 'ayecode-connect' ),
2228
+                'month_long_11' => __( 'November', 'ayecode-connect' ),
2229
+                'month_long_12' => __( 'December', 'ayecode-connect' ),
2230
+                'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ),
2231
+                'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ),
2232
+                'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ),
2233
+                'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ),
2234
+                'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ),
2235
+                'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ),
2236
+                'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ),
2237
+                'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ),
2238
+                'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ),
2239
+                'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ),
2240
+                'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ),
2241
+                'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ),
2242
+                'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ),
2243
+                'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ),
2244
+                'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ),
2245
+                'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ),
2246
+                'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ),
2247
+                'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ),
2248
+                'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ),
2249
+                'day_s2_1' => __( 'Su', 'ayecode-connect' ),
2250
+                'day_s2_2' => __( 'Mo', 'ayecode-connect' ),
2251
+                'day_s2_3' => __( 'Tu', 'ayecode-connect' ),
2252
+                'day_s2_4' => __( 'We', 'ayecode-connect' ),
2253
+                'day_s2_5' => __( 'Th', 'ayecode-connect' ),
2254
+                'day_s2_6' => __( 'Fr', 'ayecode-connect' ),
2255
+                'day_s2_7' => __( 'Sa', 'ayecode-connect' ),
2256
+                'day_s3_1' => __( 'Sun', 'ayecode-connect' ),
2257
+                'day_s3_2' => __( 'Mon', 'ayecode-connect' ),
2258
+                'day_s3_3' => __( 'Tue', 'ayecode-connect' ),
2259
+                'day_s3_4' => __( 'Wed', 'ayecode-connect' ),
2260
+                'day_s3_5' => __( 'Thu', 'ayecode-connect' ),
2261
+                'day_s3_6' => __( 'Fri', 'ayecode-connect' ),
2262
+                'day_s3_7' => __( 'Sat', 'ayecode-connect' ),
2263
+                'day_s5_1' => __( 'Sunday', 'ayecode-connect' ),
2264
+                'day_s5_2' => __( 'Monday', 'ayecode-connect' ),
2265
+                'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ),
2266
+                'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ),
2267
+                'day_s5_5' => __( 'Thursday', 'ayecode-connect' ),
2268
+                'day_s5_6' => __( 'Friday', 'ayecode-connect' ),
2269
+                'day_s5_7' => __( 'Saturday', 'ayecode-connect' ),
2270
+                'am_lower' => __( 'am', 'ayecode-connect' ),
2271
+                'pm_lower' => __( 'pm', 'ayecode-connect' ),
2272
+                'am_upper' => __( 'AM', 'ayecode-connect' ),
2273
+                'pm_upper' => __( 'PM', 'ayecode-connect' ),
2274
+                'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
2275
+                'time_24hr' => false,
2276
+                'year' => __( 'Year', 'ayecode-connect' ),
2277
+                'hour' => __( 'Hour', 'ayecode-connect' ),
2278
+                'minute' => __( 'Minute', 'ayecode-connect' ),
2279
+                'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ),
2280
+                'rangeSeparator' => __( ' to ', 'ayecode-connect' ),
2281
+                'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ),
2282
+                'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' )
2283
+            );
2284
+
2285
+            return apply_filters( 'ayecode_ui_calendar_params', $params );
2286
+        }
2287
+
2288
+        /**
2289
+         * Flatpickr calendar localize.
2290
+         *
2291
+         * @since 0.1.44
2292
+         *
2293
+         * @return string Calendar locale.
2294
+         */
2295
+        public static function flatpickr_locale() {
2296
+            $params = self::calendar_params();
2297
+
2298
+            if ( is_string( $params ) ) {
2299
+                $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
2300
+            } else {
2301
+                foreach ( (array) $params as $key => $value ) {
2302
+                    if ( ! is_scalar( $value ) ) {
2303
+                        continue;
2304
+                    }
2305
+
2306
+                    $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2307
+                }
2308
+            }
2309
+
2310
+            $day_s3 = array();
2311
+            $day_s5 = array();
2312
+
2313
+            for ( $i = 1; $i <= 7; $i ++ ) {
2314
+                $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] );
2315
+                $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] );
2316
+            }
2317
+
2318
+            $month_s = array();
2319
+            $month_long = array();
2320
+
2321
+            for ( $i = 1; $i <= 12; $i ++ ) {
2322
+                $month_s[] = addslashes( $params[ 'month_s_' . $i ] );
2323
+                $month_long[] = addslashes( $params[ 'month_long_' . $i ] );
2324
+            }
2325
+
2326
+            ob_start();
2327
+        if ( 0 ) { ?><script><?php } ?>
2328 2328
                 {
2329 2329
                     weekdays: {
2330 2330
                         shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'],
@@ -2363,189 +2363,189 @@  discard block
 block discarded – undo
2363 2363
                 }
2364 2364
 				<?php if ( 0 ) { ?></script><?php } ?>
2365 2365
 			<?php
2366
-			$locale = ob_get_clean();
2367
-
2368
-			return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2369
-		}
2370
-
2371
-		/**
2372
-		 * Select2 JS params.
2373
-		 *
2374
-		 * @since 0.1.44
2375
-		 *
2376
-		 * @return array Select2 JS params.
2377
-		 */
2378
-		public static function select2_params() {
2379
-			$params = array(
2380
-				'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'ayecode-connect' ),
2381
-				'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ),
2382
-				'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ),
2383
-				'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ),
2384
-				'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ),
2385
-				'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ),
2386
-				'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ),
2387
-				'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ),
2388
-				'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ),
2389
-				'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'ayecode-connect' ),
2390
-				'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'ayecode-connect' )
2391
-			);
2392
-
2393
-			return apply_filters( 'ayecode_ui_select2_params', $params );
2394
-		}
2395
-
2396
-		/**
2397
-		 * Select2 JS localize.
2398
-		 *
2399
-		 * @since 0.1.44
2400
-		 *
2401
-		 * @return string Select2 JS locale.
2402
-		 */
2403
-		public static function select2_locale() {
2404
-			$params = self::select2_params();
2405
-
2406
-			foreach ( (array) $params as $key => $value ) {
2407
-				if ( ! is_scalar( $value ) ) {
2408
-					continue;
2409
-				}
2366
+            $locale = ob_get_clean();
2410 2367
 
2411
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2412
-			}
2413
-
2414
-			$locale = json_encode( $params );
2415
-
2416
-			return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2417
-		}
2418
-
2419
-		/**
2420
-		 * Time ago JS localize.
2421
-		 *
2422
-		 * @since 0.1.47
2423
-		 *
2424
-		 * @return string Time ago JS locale.
2425
-		 */
2426
-		public static function timeago_locale() {
2427
-			$params = array(
2428
-				'prefix_ago' => '',
2429
-				'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ),
2430
-				'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ',
2431
-				'suffix_after' => '',
2432
-				'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ),
2433
-				'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ),
2434
-				'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ),
2435
-				'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ),
2436
-				'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ),
2437
-				'day' => _x( 'a day', 'time ago', 'ayecode-connect' ),
2438
-				'days' => _x( '%d days', 'time ago', 'ayecode-connect' ),
2439
-				'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ),
2440
-				'months' => _x( '%d months', 'time ago', 'ayecode-connect' ),
2441
-				'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ),
2442
-				'years' => _x( '%d years', 'time ago', 'ayecode-connect' ),
2443
-			);
2444
-
2445
-			$params = apply_filters( 'ayecode_ui_timeago_params', $params );
2446
-
2447
-			foreach ( (array) $params as $key => $value ) {
2448
-				if ( ! is_scalar( $value ) ) {
2449
-					continue;
2450
-				}
2368
+            return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2369
+        }
2370
+
2371
+        /**
2372
+         * Select2 JS params.
2373
+         *
2374
+         * @since 0.1.44
2375
+         *
2376
+         * @return array Select2 JS params.
2377
+         */
2378
+        public static function select2_params() {
2379
+            $params = array(
2380
+                'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'ayecode-connect' ),
2381
+                'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ),
2382
+                'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ),
2383
+                'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ),
2384
+                'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ),
2385
+                'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ),
2386
+                'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ),
2387
+                'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ),
2388
+                'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ),
2389
+                'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'ayecode-connect' ),
2390
+                'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'ayecode-connect' )
2391
+            );
2392
+
2393
+            return apply_filters( 'ayecode_ui_select2_params', $params );
2394
+        }
2395
+
2396
+        /**
2397
+         * Select2 JS localize.
2398
+         *
2399
+         * @since 0.1.44
2400
+         *
2401
+         * @return string Select2 JS locale.
2402
+         */
2403
+        public static function select2_locale() {
2404
+            $params = self::select2_params();
2405
+
2406
+            foreach ( (array) $params as $key => $value ) {
2407
+                if ( ! is_scalar( $value ) ) {
2408
+                    continue;
2409
+                }
2410
+
2411
+                $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2412
+            }
2413
+
2414
+            $locale = json_encode( $params );
2415
+
2416
+            return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2417
+        }
2418
+
2419
+        /**
2420
+         * Time ago JS localize.
2421
+         *
2422
+         * @since 0.1.47
2423
+         *
2424
+         * @return string Time ago JS locale.
2425
+         */
2426
+        public static function timeago_locale() {
2427
+            $params = array(
2428
+                'prefix_ago' => '',
2429
+                'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ),
2430
+                'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ',
2431
+                'suffix_after' => '',
2432
+                'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ),
2433
+                'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ),
2434
+                'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ),
2435
+                'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ),
2436
+                'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ),
2437
+                'day' => _x( 'a day', 'time ago', 'ayecode-connect' ),
2438
+                'days' => _x( '%d days', 'time ago', 'ayecode-connect' ),
2439
+                'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ),
2440
+                'months' => _x( '%d months', 'time ago', 'ayecode-connect' ),
2441
+                'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ),
2442
+                'years' => _x( '%d years', 'time ago', 'ayecode-connect' ),
2443
+            );
2444
+
2445
+            $params = apply_filters( 'ayecode_ui_timeago_params', $params );
2446
+
2447
+            foreach ( (array) $params as $key => $value ) {
2448
+                if ( ! is_scalar( $value ) ) {
2449
+                    continue;
2450
+                }
2451
+
2452
+                $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2453
+            }
2454
+
2455
+            $locale = json_encode( $params );
2456
+
2457
+            return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2458
+        }
2451 2459
 
2452
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2453
-			}
2454
-
2455
-			$locale = json_encode( $params );
2456
-
2457
-			return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2458
-		}
2459
-
2460
-		/**
2461
-		 * JavaScript Minifier
2462
-		 *
2463
-		 * @param $input
2464
-		 *
2465
-		 * @return mixed
2466
-		 */
2467
-		public static function minify_js($input) {
2468
-			if(trim($input) === "") return $input;
2469
-			return preg_replace(
2470
-				array(
2471
-					// Remove comment(s)
2472
-					'#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
2473
-					// Remove white-space(s) outside the string and regex
2474
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s',
2475
-					// Remove the last semicolon
2476
-					'#;+\}#',
2477
-					// Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}`
2478
-					'#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i',
2479
-					// --ibid. From `foo['bar']` to `foo.bar`
2480
-					'#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i'
2481
-				),
2482
-				array(
2483
-					'$1',
2484
-					'$1$2',
2485
-					'}',
2486
-					'$1$3',
2487
-					'$1.$3'
2488
-				),
2489
-				$input);
2490
-		}
2491
-
2492
-		/**
2493
-		 * Minify CSS
2494
-		 *
2495
-		 * @param $input
2496
-		 *
2497
-		 * @return mixed
2498
-		 */
2499
-		public static function minify_css($input) {
2500
-			if(trim($input) === "") return $input;
2501
-			return preg_replace(
2502
-				array(
2503
-					// Remove comment(s)
2504
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
2505
-					// Remove unused white-space(s)
2506
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
2507
-					// Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
2508
-					'#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
2509
-					// Replace `:0 0 0 0` with `:0`
2510
-					'#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
2511
-					// Replace `background-position:0` with `background-position:0 0`
2512
-					'#(background-position):0(?=[;\}])#si',
2513
-					// Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
2514
-					'#(?<=[\s:,\-])0+\.(\d+)#s',
2515
-					// Minify string value
2516
-					'#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
2517
-					'#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
2518
-					// Minify HEX color code
2519
-					'#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
2520
-					// Replace `(border|outline):none` with `(border|outline):0`
2521
-					'#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
2522
-					// Remove empty selector(s)
2523
-					'#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
2524
-				),
2525
-				array(
2526
-					'$1',
2527
-					'$1$2$3$4$5$6$7',
2528
-					'$1',
2529
-					':0',
2530
-					'$1:0 0',
2531
-					'.$1',
2532
-					'$1$3',
2533
-					'$1$2$4$5',
2534
-					'$1$2$3',
2535
-					'$1:0',
2536
-					'$1$2'
2537
-				),
2538
-				$input);
2539
-		}
2540
-
2541
-		/**
2542
-		 * Get the conditional fields JavaScript.
2543
-		 *
2544
-		 * @return mixed
2545
-		 */
2546
-		public function conditional_fields_js() {
2547
-			ob_start();
2548
-			?>
2460
+        /**
2461
+         * JavaScript Minifier
2462
+         *
2463
+         * @param $input
2464
+         *
2465
+         * @return mixed
2466
+         */
2467
+        public static function minify_js($input) {
2468
+            if(trim($input) === "") return $input;
2469
+            return preg_replace(
2470
+                array(
2471
+                    // Remove comment(s)
2472
+                    '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
2473
+                    // Remove white-space(s) outside the string and regex
2474
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s',
2475
+                    // Remove the last semicolon
2476
+                    '#;+\}#',
2477
+                    // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}`
2478
+                    '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i',
2479
+                    // --ibid. From `foo['bar']` to `foo.bar`
2480
+                    '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i'
2481
+                ),
2482
+                array(
2483
+                    '$1',
2484
+                    '$1$2',
2485
+                    '}',
2486
+                    '$1$3',
2487
+                    '$1.$3'
2488
+                ),
2489
+                $input);
2490
+        }
2491
+
2492
+        /**
2493
+         * Minify CSS
2494
+         *
2495
+         * @param $input
2496
+         *
2497
+         * @return mixed
2498
+         */
2499
+        public static function minify_css($input) {
2500
+            if(trim($input) === "") return $input;
2501
+            return preg_replace(
2502
+                array(
2503
+                    // Remove comment(s)
2504
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
2505
+                    // Remove unused white-space(s)
2506
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
2507
+                    // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
2508
+                    '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
2509
+                    // Replace `:0 0 0 0` with `:0`
2510
+                    '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
2511
+                    // Replace `background-position:0` with `background-position:0 0`
2512
+                    '#(background-position):0(?=[;\}])#si',
2513
+                    // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
2514
+                    '#(?<=[\s:,\-])0+\.(\d+)#s',
2515
+                    // Minify string value
2516
+                    '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
2517
+                    '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
2518
+                    // Minify HEX color code
2519
+                    '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
2520
+                    // Replace `(border|outline):none` with `(border|outline):0`
2521
+                    '#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
2522
+                    // Remove empty selector(s)
2523
+                    '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
2524
+                ),
2525
+                array(
2526
+                    '$1',
2527
+                    '$1$2$3$4$5$6$7',
2528
+                    '$1',
2529
+                    ':0',
2530
+                    '$1:0 0',
2531
+                    '.$1',
2532
+                    '$1$3',
2533
+                    '$1$2$4$5',
2534
+                    '$1$2$3',
2535
+                    '$1:0',
2536
+                    '$1$2'
2537
+                ),
2538
+                $input);
2539
+        }
2540
+
2541
+        /**
2542
+         * Get the conditional fields JavaScript.
2543
+         *
2544
+         * @return mixed
2545
+         */
2546
+        public function conditional_fields_js() {
2547
+            ob_start();
2548
+            ?>
2549 2549
             <script>
2550 2550
                 /**
2551 2551
                  * Conditional Fields
@@ -3066,14 +3066,14 @@  discard block
 block discarded – undo
3066 3066
 				<?php do_action( 'aui_conditional_fields_js', $this ); ?>
3067 3067
             </script>
3068 3068
 			<?php
3069
-			$output = ob_get_clean();
3069
+            $output = ob_get_clean();
3070 3070
 
3071
-			return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
3072
-		}
3073
-	}
3071
+            return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
3072
+        }
3073
+    }
3074 3074
 
3075
-	/**
3076
-	 * Run the class if found.
3077
-	 */
3078
-	AyeCode_UI_Settings::instance();
3075
+    /**
3076
+     * Run the class if found.
3077
+     */
3078
+    AyeCode_UI_Settings::instance();
3079 3079
 }
3080 3080
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php 1 patch
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.2.6";
19
-	if(empty($ayecode_ui_version) || 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.2.6";
19
+    if(empty($ayecode_ui_version) || 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
 }
Please login to merge, or discard this patch.
vendor/ayecode/ayecode-connect-helper/ayecode-connect-helper.php 1 patch
Indentation   +302 added lines, -302 removed lines patch added patch discarded remove patch
@@ -1,264 +1,264 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 if ( ! class_exists( "AyeCode_Connect_Helper" ) ) {
7
-	/**
8
-	 * Allow the quick setup and connection of our AyeCode Connect plugin.
9
-	 *
10
-	 * Class AyeCode_Connect_Helper
11
-	 */
12
-	class AyeCode_Connect_Helper {
13
-
14
-		// Hold the version number
15
-		var $version = "1.0.4";
16
-
17
-		// Hold the default strings.
18
-		var $strings = array();
19
-
20
-		// Hold the default pages.
21
-		var $pages = array();
22
-
23
-		/**
24
-		 * The constructor.
25
-		 *
26
-		 * AyeCode_Connect_Helper constructor.
27
-		 *
28
-		 * @param array $strings
29
-		 * @param array $pages
30
-		 */
31
-		public function __construct( $strings = array(), $pages = array() ) {
32
-			// Only fire if not localhost and the current user has the right permissions.
33
-			if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) {
34
-				// set default strings
35
-				$default_strings = array(
36
-					'connect_title'     => __( "Thanks for choosing an AyeCode Product!", 'ayecode-connect' ),
37
-					'connect_external'  => __( "Please confirm you wish to connect your site?", 'ayecode-connect' ),
38
-					'connect'           => wp_sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", 'ayecode-connect' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ),
39
-					'connect_button'    => __( "Connect Site", 'ayecode-connect' ),
40
-					'connecting_button' => __( "Connecting...", 'ayecode-connect' ),
41
-					'error_localhost'   => __( "This service will only work with a live domain, not a localhost.", 'ayecode-connect' ),
42
-					'error'             => __( "Something went wrong, please refresh and try again.", 'ayecode-connect' ),
43
-				);
44
-				$this->strings   = array_merge( $default_strings, $strings );
45
-
46
-				// set default pages
47
-				$default_pages = array();
48
-				$this->pages   = array_merge( $default_pages, $pages );
49
-
50
-				// maybe show connect site notice
51
-				add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) );
52
-
53
-				// add ajax action if not already added
54
-				if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) {
55
-					add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) );
56
-				}
57
-			}
58
-
59
-			// add ajax action if not already added
60
-			if ( ! has_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed' ) ) {
61
-				add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) );
62
-			}
63
-		}
64
-
65
-		/**
66
-		 * Give a way to check we can connect via a external redirect.
67
-		 */
68
-		public function ayecode_connect_helper_installed(){
69
-			$active = array(
70
-				'gd'    =>  defined('GEODIRECTORY_VERSION') && version_compare(GEODIRECTORY_VERSION,'2.0.0.79','>') ? 1 : 0,
71
-				'uwp'    =>  defined('USERSWP_VERSION') && version_compare(USERSWP_VERSION,'1.2.1.5','>') ? 1 : 0,
72
-				'wpi'    =>  defined('WPINV_VERSION') && version_compare(WPINV_VERSION,'1.0.14','>') ? 1 : 0,
73
-			);
74
-			wp_send_json_success( $active );
75
-			wp_die();
76
-		}
77
-
78
-		/**
79
-		 * Get slug from path
80
-		 *
81
-		 * @param  string $key
82
-		 *
83
-		 * @return string
84
-		 */
85
-		private function format_plugin_slug( $key ) {
86
-			$slug = explode( '/', $key );
87
-			$slug = explode( '.', end( $slug ) );
88
-
89
-			return $slug[0];
90
-		}
91
-
92
-		/**
93
-		 * Install and activate the AyeCode Connect Plugin
94
-		 */
95
-		public function ayecode_connect_install() {
96
-			// bail if localhost
97
-			if ( $this->is_localhost() ) {
98
-				wp_send_json_error( $this->strings['error_localhost'] );
99
-			}
100
-
101
-			// Explicitly clear the event.
102
-			wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() );
103
-
104
-			$success     = true;
105
-			$plugin_slug = "ayecode-connect";
106
-			if ( ! empty( $plugin_slug ) ) {
107
-				require_once( ABSPATH . 'wp-admin/includes/file.php' );
108
-				require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
109
-				require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
110
-				require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
111
-
112
-				WP_Filesystem();
113
-
114
-				$skin              = new Automatic_Upgrader_Skin;
115
-				$upgrader          = new WP_Upgrader( $skin );
116
-				$installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) );
117
-				$plugin_slug       = $plugin_slug;
118
-				$plugin            = $plugin_slug . '/' . $plugin_slug . '.php';
119
-				$installed         = false;
120
-				$activate          = false;
121
-
122
-				// See if the plugin is installed already
123
-				if ( in_array( $plugin_slug, $installed_plugins ) ) {
124
-					$installed = true;
125
-					$activate  = ! is_plugin_active( $plugin );
126
-				}
127
-
128
-				// Install this thing!
129
-				if ( ! $installed ) {
130
-
131
-					// Suppress feedback
132
-					ob_start();
133
-
134
-					try {
135
-						$plugin_information = plugins_api( 'plugin_information', array(
136
-							'slug'   => $plugin_slug,
137
-							'fields' => array(
138
-								'short_description' => false,
139
-								'sections'          => false,
140
-								'requires'          => false,
141
-								'rating'            => false,
142
-								'ratings'           => false,
143
-								'downloaded'        => false,
144
-								'last_updated'      => false,
145
-								'added'             => false,
146
-								'tags'              => false,
147
-								'homepage'          => false,
148
-								'donate_link'       => false,
149
-								'author_profile'    => false,
150
-								'author'            => false,
151
-							),
152
-						) );
153
-
154
-						if ( is_wp_error( $plugin_information ) ) {
155
-							throw new Exception( $plugin_information->get_error_message() );
156
-						}
157
-
158
-						$package  = $plugin_information->download_link;
159
-						$download = $upgrader->download_package( $package );
160
-
161
-						if ( is_wp_error( $download ) ) {
162
-							throw new Exception( $download->get_error_message() );
163
-						}
164
-
165
-						$working_dir = $upgrader->unpack_package( $download, true );
166
-
167
-						if ( is_wp_error( $working_dir ) ) {
168
-							throw new Exception( $working_dir->get_error_message() );
169
-						}
170
-
171
-						$result = $upgrader->install_package( array(
172
-							'source'                      => $working_dir,
173
-							'destination'                 => WP_PLUGIN_DIR,
174
-							'clear_destination'           => false,
175
-							'abort_if_destination_exists' => false,
176
-							'clear_working'               => true,
177
-							'hook_extra'                  => array(
178
-								'type'   => 'plugin',
179
-								'action' => 'install',
180
-							),
181
-						) );
182
-
183
-						if ( is_wp_error( $result ) ) {
184
-							throw new Exception( $result->get_error_message() );
185
-						}
186
-
187
-						$activate = true;
188
-
189
-					} catch ( Exception $e ) {
190
-						$success = false;
191
-					}
192
-
193
-					// Discard feedback
194
-					ob_end_clean();
195
-				}
196
-
197
-				wp_clean_plugins_cache();
198
-
199
-				// Activate this thing
200
-				if ( $activate ) {
201
-					try {
202
-						$result = activate_plugin( $plugin );
203
-
204
-						if ( is_wp_error( $result ) ) {
205
-							$success = false;
206
-						} else {
207
-							$success = true;
208
-						}
209
-					} catch ( Exception $e ) {
210
-						$success = false;
211
-					}
212
-				}
213
-			}
214
-
215
-			if ( $success && function_exists( 'ayecode_connect_args' ) ) {
216
-				ayecode_connect();// init
217
-				$args        = ayecode_connect_args();
218
-				$client      = new AyeCode_Connect( $args );
219
-				$redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : '';
220
-				$redirect    = $client->build_connect_url( $redirect_to );
221
-				wp_send_json_success( array( 'connect_url' => $redirect ) );
222
-			} else {
223
-				wp_send_json_error( $this->strings['error_localhost'] );
224
-			}
225
-			wp_die();
226
-		}
227
-
228
-		/**
229
-		 * Check if maybe localhost.
230
-		 *
231
-		 * @return bool
232
-		 */
233
-		public function is_localhost() {
234
-			$localhost = false;
235
-
236
-			$host              = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '';
237
-			$localhost_domains = array(
238
-				'localhost',
239
-				'localhost.localdomain',
240
-				'127.0.0.1',
241
-				'::1'
242
-			);
243
-
244
-			if ( in_array( $host, $localhost_domains ) ) {
245
-				$localhost = true;
246
-			}
247
-
248
-			return $localhost;
249
-		}
250
-
251
-		/**
252
-		 * Show notice to connect site.
253
-		 */
254
-		public function ayecode_connect_install_notice() {
255
-			if ( $this->maybe_show() ) {
256
-				$connect_title_string     = $this->strings['connect_title'];
257
-				$connect_external_string  = $this->strings['connect_external'];
258
-				$connect_string           = $this->strings['connect'];
259
-				$connect_button_string    = $this->strings['connect_button'];
260
-				$connecting_button_string = $this->strings['connecting_button'];
261
-				?>
7
+    /**
8
+     * Allow the quick setup and connection of our AyeCode Connect plugin.
9
+     *
10
+     * Class AyeCode_Connect_Helper
11
+     */
12
+    class AyeCode_Connect_Helper {
13
+
14
+        // Hold the version number
15
+        var $version = "1.0.4";
16
+
17
+        // Hold the default strings.
18
+        var $strings = array();
19
+
20
+        // Hold the default pages.
21
+        var $pages = array();
22
+
23
+        /**
24
+         * The constructor.
25
+         *
26
+         * AyeCode_Connect_Helper constructor.
27
+         *
28
+         * @param array $strings
29
+         * @param array $pages
30
+         */
31
+        public function __construct( $strings = array(), $pages = array() ) {
32
+            // Only fire if not localhost and the current user has the right permissions.
33
+            if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) {
34
+                // set default strings
35
+                $default_strings = array(
36
+                    'connect_title'     => __( "Thanks for choosing an AyeCode Product!", 'ayecode-connect' ),
37
+                    'connect_external'  => __( "Please confirm you wish to connect your site?", 'ayecode-connect' ),
38
+                    'connect'           => wp_sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", 'ayecode-connect' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ),
39
+                    'connect_button'    => __( "Connect Site", 'ayecode-connect' ),
40
+                    'connecting_button' => __( "Connecting...", 'ayecode-connect' ),
41
+                    'error_localhost'   => __( "This service will only work with a live domain, not a localhost.", 'ayecode-connect' ),
42
+                    'error'             => __( "Something went wrong, please refresh and try again.", 'ayecode-connect' ),
43
+                );
44
+                $this->strings   = array_merge( $default_strings, $strings );
45
+
46
+                // set default pages
47
+                $default_pages = array();
48
+                $this->pages   = array_merge( $default_pages, $pages );
49
+
50
+                // maybe show connect site notice
51
+                add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) );
52
+
53
+                // add ajax action if not already added
54
+                if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) {
55
+                    add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) );
56
+                }
57
+            }
58
+
59
+            // add ajax action if not already added
60
+            if ( ! has_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed' ) ) {
61
+                add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) );
62
+            }
63
+        }
64
+
65
+        /**
66
+         * Give a way to check we can connect via a external redirect.
67
+         */
68
+        public function ayecode_connect_helper_installed(){
69
+            $active = array(
70
+                'gd'    =>  defined('GEODIRECTORY_VERSION') && version_compare(GEODIRECTORY_VERSION,'2.0.0.79','>') ? 1 : 0,
71
+                'uwp'    =>  defined('USERSWP_VERSION') && version_compare(USERSWP_VERSION,'1.2.1.5','>') ? 1 : 0,
72
+                'wpi'    =>  defined('WPINV_VERSION') && version_compare(WPINV_VERSION,'1.0.14','>') ? 1 : 0,
73
+            );
74
+            wp_send_json_success( $active );
75
+            wp_die();
76
+        }
77
+
78
+        /**
79
+         * Get slug from path
80
+         *
81
+         * @param  string $key
82
+         *
83
+         * @return string
84
+         */
85
+        private function format_plugin_slug( $key ) {
86
+            $slug = explode( '/', $key );
87
+            $slug = explode( '.', end( $slug ) );
88
+
89
+            return $slug[0];
90
+        }
91
+
92
+        /**
93
+         * Install and activate the AyeCode Connect Plugin
94
+         */
95
+        public function ayecode_connect_install() {
96
+            // bail if localhost
97
+            if ( $this->is_localhost() ) {
98
+                wp_send_json_error( $this->strings['error_localhost'] );
99
+            }
100
+
101
+            // Explicitly clear the event.
102
+            wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() );
103
+
104
+            $success     = true;
105
+            $plugin_slug = "ayecode-connect";
106
+            if ( ! empty( $plugin_slug ) ) {
107
+                require_once( ABSPATH . 'wp-admin/includes/file.php' );
108
+                require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
109
+                require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
110
+                require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
111
+
112
+                WP_Filesystem();
113
+
114
+                $skin              = new Automatic_Upgrader_Skin;
115
+                $upgrader          = new WP_Upgrader( $skin );
116
+                $installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) );
117
+                $plugin_slug       = $plugin_slug;
118
+                $plugin            = $plugin_slug . '/' . $plugin_slug . '.php';
119
+                $installed         = false;
120
+                $activate          = false;
121
+
122
+                // See if the plugin is installed already
123
+                if ( in_array( $plugin_slug, $installed_plugins ) ) {
124
+                    $installed = true;
125
+                    $activate  = ! is_plugin_active( $plugin );
126
+                }
127
+
128
+                // Install this thing!
129
+                if ( ! $installed ) {
130
+
131
+                    // Suppress feedback
132
+                    ob_start();
133
+
134
+                    try {
135
+                        $plugin_information = plugins_api( 'plugin_information', array(
136
+                            'slug'   => $plugin_slug,
137
+                            'fields' => array(
138
+                                'short_description' => false,
139
+                                'sections'          => false,
140
+                                'requires'          => false,
141
+                                'rating'            => false,
142
+                                'ratings'           => false,
143
+                                'downloaded'        => false,
144
+                                'last_updated'      => false,
145
+                                'added'             => false,
146
+                                'tags'              => false,
147
+                                'homepage'          => false,
148
+                                'donate_link'       => false,
149
+                                'author_profile'    => false,
150
+                                'author'            => false,
151
+                            ),
152
+                        ) );
153
+
154
+                        if ( is_wp_error( $plugin_information ) ) {
155
+                            throw new Exception( $plugin_information->get_error_message() );
156
+                        }
157
+
158
+                        $package  = $plugin_information->download_link;
159
+                        $download = $upgrader->download_package( $package );
160
+
161
+                        if ( is_wp_error( $download ) ) {
162
+                            throw new Exception( $download->get_error_message() );
163
+                        }
164
+
165
+                        $working_dir = $upgrader->unpack_package( $download, true );
166
+
167
+                        if ( is_wp_error( $working_dir ) ) {
168
+                            throw new Exception( $working_dir->get_error_message() );
169
+                        }
170
+
171
+                        $result = $upgrader->install_package( array(
172
+                            'source'                      => $working_dir,
173
+                            'destination'                 => WP_PLUGIN_DIR,
174
+                            'clear_destination'           => false,
175
+                            'abort_if_destination_exists' => false,
176
+                            'clear_working'               => true,
177
+                            'hook_extra'                  => array(
178
+                                'type'   => 'plugin',
179
+                                'action' => 'install',
180
+                            ),
181
+                        ) );
182
+
183
+                        if ( is_wp_error( $result ) ) {
184
+                            throw new Exception( $result->get_error_message() );
185
+                        }
186
+
187
+                        $activate = true;
188
+
189
+                    } catch ( Exception $e ) {
190
+                        $success = false;
191
+                    }
192
+
193
+                    // Discard feedback
194
+                    ob_end_clean();
195
+                }
196
+
197
+                wp_clean_plugins_cache();
198
+
199
+                // Activate this thing
200
+                if ( $activate ) {
201
+                    try {
202
+                        $result = activate_plugin( $plugin );
203
+
204
+                        if ( is_wp_error( $result ) ) {
205
+                            $success = false;
206
+                        } else {
207
+                            $success = true;
208
+                        }
209
+                    } catch ( Exception $e ) {
210
+                        $success = false;
211
+                    }
212
+                }
213
+            }
214
+
215
+            if ( $success && function_exists( 'ayecode_connect_args' ) ) {
216
+                ayecode_connect();// init
217
+                $args        = ayecode_connect_args();
218
+                $client      = new AyeCode_Connect( $args );
219
+                $redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : '';
220
+                $redirect    = $client->build_connect_url( $redirect_to );
221
+                wp_send_json_success( array( 'connect_url' => $redirect ) );
222
+            } else {
223
+                wp_send_json_error( $this->strings['error_localhost'] );
224
+            }
225
+            wp_die();
226
+        }
227
+
228
+        /**
229
+         * Check if maybe localhost.
230
+         *
231
+         * @return bool
232
+         */
233
+        public function is_localhost() {
234
+            $localhost = false;
235
+
236
+            $host              = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '';
237
+            $localhost_domains = array(
238
+                'localhost',
239
+                'localhost.localdomain',
240
+                '127.0.0.1',
241
+                '::1'
242
+            );
243
+
244
+            if ( in_array( $host, $localhost_domains ) ) {
245
+                $localhost = true;
246
+            }
247
+
248
+            return $localhost;
249
+        }
250
+
251
+        /**
252
+         * Show notice to connect site.
253
+         */
254
+        public function ayecode_connect_install_notice() {
255
+            if ( $this->maybe_show() ) {
256
+                $connect_title_string     = $this->strings['connect_title'];
257
+                $connect_external_string  = $this->strings['connect_external'];
258
+                $connect_string           = $this->strings['connect'];
259
+                $connect_button_string    = $this->strings['connect_button'];
260
+                $connecting_button_string = $this->strings['connecting_button'];
261
+                ?>
262 262
 				<div class="notice notice-info acch-notice">
263 263
 					<span class="acch-float-left">
264 264
 						<svg width="61px" height="61px" viewBox="0 0 61 61" version="1.1"
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
 				</div>
306 306
 
307 307
 				<?php
308
-				// only include the popup HTML if needed.
309
-				if ( ! empty( $_REQUEST['external-connect-request'] ) ) {
310
-					?>
308
+                // only include the popup HTML if needed.
309
+                if ( ! empty( $_REQUEST['external-connect-request'] ) ) {
310
+                    ?>
311 311
 					<div id="ayecode-connect-helper-external-confirm" style="display:none;">
312 312
 						<div class="noticex notice-info acch-notice" style="border: none;">
313 313
 					<span class="acch-float-left">
@@ -353,23 +353,23 @@  discard block
 block discarded – undo
353 353
 						</div>
354 354
 					</div>
355 355
 					<?php
356
-				}
357
-
358
-				// add required scripts
359
-				$this->script();
360
-			}
361
-		}
362
-
363
-		/**
364
-		 * Get the JS Script.
365
-		 */
366
-		public function script() {
367
-
368
-			// add thickbox if external request is requested
369
-			if ( ! empty( $_REQUEST['external-connect-request'] ) ) {
370
-				add_thickbox();
371
-			}
372
-			?>
356
+                }
357
+
358
+                // add required scripts
359
+                $this->script();
360
+            }
361
+        }
362
+
363
+        /**
364
+         * Get the JS Script.
365
+         */
366
+        public function script() {
367
+
368
+            // add thickbox if external request is requested
369
+            if ( ! empty( $_REQUEST['external-connect-request'] ) ) {
370
+                add_thickbox();
371
+            }
372
+            ?>
373 373
 			<style>
374 374
 				.acch-title {
375 375
 					margin: 0;
@@ -435,38 +435,38 @@  discard block
 block discarded – undo
435 435
 					});
436 436
 				} 
437 437
 				<?php
438
-				// add thickbox if external request is requested
439
-				if(! empty( $_REQUEST['external-connect-request'] )) {
440
-				?>
438
+                // add thickbox if external request is requested
439
+                if(! empty( $_REQUEST['external-connect-request'] )) {
440
+                ?>
441 441
 				jQuery(function () {
442 442
 					setTimeout(function () {
443 443
 						tb_show("AyeCode Connect", "?TB_inline?width=300&height=80&inlineId=ayecode-connect-helper-external-confirm");
444 444
 					}, 200);
445 445
 				});
446 446
 				<?php
447
-				}
448
-				?>
447
+                }
448
+                ?>
449 449
 			</script>
450 450
 			<?php
451
-		}
452
-
453
-		/**
454
-		 * Decide what pages to show on.
455
-		 *
456
-		 * @return bool
457
-		 */
458
-		public function maybe_show() {
459
-			$show = false;
460
-
461
-			// check if on a page set to show
462
-			if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) {
463
-				// check if not active and connected
464
-				if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) {
465
-					$show = true;
466
-				}
467
-			}
468
-
469
-			return $show;
470
-		}
471
-	}
451
+        }
452
+
453
+        /**
454
+         * Decide what pages to show on.
455
+         *
456
+         * @return bool
457
+         */
458
+        public function maybe_show() {
459
+            $show = false;
460
+
461
+            // check if on a page set to show
462
+            if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) {
463
+                // check if not active and connected
464
+                if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) {
465
+                    $show = true;
466
+                }
467
+            }
468
+
469
+            return $show;
470
+        }
471
+    }
472 472
 }
Please login to merge, or discard this patch.
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 1 patch
Indentation   +821 added lines, -821 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * Bail if we are not in WP.
14 14
  */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -21,406 +21,406 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class WP_Font_Awesome_Settings
28
-	 */
29
-	class WP_Font_Awesome_Settings {
30
-
31
-		/**
32
-		 * Class version version.
33
-		 *
34
-		 * @var string
35
-		 */
36
-		public $version = '1.1.7';
37
-
38
-		/**
39
-		 * Class textdomain.
40
-		 *
41
-		 * @var string
42
-		 */
43
-		public $textdomain = 'font-awesome-settings';
44
-
45
-		/**
46
-		 * Latest version of Font Awesome at time of publish published.
47
-		 *
48
-		 * @var string
49
-		 */
50
-		public $latest = "6.4.2";
51
-
52
-		/**
53
-		 * The title.
54
-		 *
55
-		 * @var string
56
-		 */
57
-		public $name = 'Font Awesome';
58
-
59
-		/**
60
-		 * Holds the settings values.
61
-		 *
62
-		 * @var array
63
-		 */
64
-		private $settings;
65
-
66
-		/**
67
-		 * WP_Font_Awesome_Settings instance.
68
-		 *
69
-		 * @access private
70
-		 * @since  1.0.0
71
-		 * @var    WP_Font_Awesome_Settings There can be only one!
72
-		 */
73
-		private static $instance = null;
74
-
75
-		/**
76
-		 * Main WP_Font_Awesome_Settings Instance.
77
-		 *
78
-		 * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
79
-		 *
80
-		 * @since 1.0.0
81
-		 * @static
82
-		 * @return WP_Font_Awesome_Settings - Main instance.
83
-		 */
84
-		public static function instance() {
85
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
86
-				self::$instance = new WP_Font_Awesome_Settings;
87
-
88
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
89
-
90
-				if ( is_admin() ) {
91
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
92
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
93
-					add_action( 'admin_init', array( self::$instance, 'constants' ) );
94
-					add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) );
95
-				}
96
-
97
-				do_action( 'wp_font_awesome_settings_loaded' );
98
-			}
99
-
100
-			return self::$instance;
101
-		}
102
-
103
-		/**
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class WP_Font_Awesome_Settings
28
+     */
29
+    class WP_Font_Awesome_Settings {
30
+
31
+        /**
32
+         * Class version version.
33
+         *
34
+         * @var string
35
+         */
36
+        public $version = '1.1.7';
37
+
38
+        /**
39
+         * Class textdomain.
40
+         *
41
+         * @var string
42
+         */
43
+        public $textdomain = 'font-awesome-settings';
44
+
45
+        /**
46
+         * Latest version of Font Awesome at time of publish published.
47
+         *
48
+         * @var string
49
+         */
50
+        public $latest = "6.4.2";
51
+
52
+        /**
53
+         * The title.
54
+         *
55
+         * @var string
56
+         */
57
+        public $name = 'Font Awesome';
58
+
59
+        /**
60
+         * Holds the settings values.
61
+         *
62
+         * @var array
63
+         */
64
+        private $settings;
65
+
66
+        /**
67
+         * WP_Font_Awesome_Settings instance.
68
+         *
69
+         * @access private
70
+         * @since  1.0.0
71
+         * @var    WP_Font_Awesome_Settings There can be only one!
72
+         */
73
+        private static $instance = null;
74
+
75
+        /**
76
+         * Main WP_Font_Awesome_Settings Instance.
77
+         *
78
+         * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
79
+         *
80
+         * @since 1.0.0
81
+         * @static
82
+         * @return WP_Font_Awesome_Settings - Main instance.
83
+         */
84
+        public static function instance() {
85
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
86
+                self::$instance = new WP_Font_Awesome_Settings;
87
+
88
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
89
+
90
+                if ( is_admin() ) {
91
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
92
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
93
+                    add_action( 'admin_init', array( self::$instance, 'constants' ) );
94
+                    add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) );
95
+                }
96
+
97
+                do_action( 'wp_font_awesome_settings_loaded' );
98
+            }
99
+
100
+            return self::$instance;
101
+        }
102
+
103
+        /**
104 104
          * Define any constants that may be needed by other packages.
105 105
          *
106
-		 * @return void
107
-		 */
108
-		public function constants(){
106
+         * @return void
107
+         */
108
+        public function constants(){
109 109
 
110
-			// register iconpicker constant
111
-			if ( ! defined( 'FAS_ICONPICKER_JS_URL' ) ) {
112
-				$url = $this->get_path_url();
113
-				$version = $this->settings['version'];
110
+            // register iconpicker constant
111
+            if ( ! defined( 'FAS_ICONPICKER_JS_URL' ) ) {
112
+                $url = $this->get_path_url();
113
+                $version = $this->settings['version'];
114 114
 
115
-				if( !$version || version_compare($version,'5.999','>')){
116
-					$url .= 'assets/js/fa-iconpicker-v6.min.js';
117
-				}else{
118
-					$url .= 'assets/js/fa-iconpicker-v5.min.js';
119
-				}
115
+                if( !$version || version_compare($version,'5.999','>')){
116
+                    $url .= 'assets/js/fa-iconpicker-v6.min.js';
117
+                }else{
118
+                    $url .= 'assets/js/fa-iconpicker-v5.min.js';
119
+                }
120 120
 
121
-				define( 'FAS_ICONPICKER_JS_URL', $url );
121
+                define( 'FAS_ICONPICKER_JS_URL', $url );
122 122
 
123
-			}
123
+            }
124 124
 
125 125
             // Set a constant if pro enbaled
126
-			if ( ! defined( 'FAS_PRO' ) && $this->settings['pro'] ) {
127
-				define( 'FAS_PRO', true );
128
-			}
129
-		}
130
-
131
-		/**
132
-		 * Get the url path to the current folder.
133
-		 *
134
-		 * @return string
135
-		 */
136
-		public function get_path_url() {
137
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
138
-			$content_url = untrailingslashit( WP_CONTENT_URL );
139
-
140
-			// Replace http:// to https://.
141
-			if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
142
-				$content_url = str_replace( 'http://', 'https://', $content_url );
143
-			}
144
-
145
-			// Check if we are inside a plugin
146
-			$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
147
-			$url = str_replace( $content_dir, $content_url, $file_dir );
148
-
149
-			return trailingslashit( $url );
150
-		}
151
-
152
-		/**
153
-		 * Initiate the settings and add the required action hooks.
154
-		 *
155
-		 * @since 1.0.8 Settings name wrong - FIXED
156
-		 */
157
-		public function init() {
158
-			// Download fontawesome locally.
159
-			add_action( 'add_option_wp-font-awesome-settings', array( $this, 'add_option_wp_font_awesome_settings' ), 10, 2 );
160
-			add_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
161
-
162
-			$this->settings = $this->get_settings();
163
-
164
-			// Check if the official plugin is active and use that instead if so.
165
-			if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
166
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
167
-					add_action( 'admin_head', array( $this, 'add_generator' ), 99 );
168
-				}
169
-
170
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
171
-					add_action( 'wp_head', array( $this, 'add_generator' ), 99 );
172
-				}
173
-
174
-				if ( $this->settings['type'] == 'CSS' ) {
175
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
176
-						add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
177
-						//add_action( 'wp_footer', array( $this, 'enqueue_style' ), 5000 ); // not sure why this was added, seems to break frontend
178
-					}
179
-
180
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
181
-						add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
182
-						add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_styles' ), 10, 2 );
183
-					}
184
-				} else {
185
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
186
-						add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
187
-					}
188
-
189
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
190
-						add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
191
-						add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 );
192
-					}
193
-				}
194
-
195
-				// remove font awesome if set to do so
196
-				if ( $this->settings['dequeue'] == '1' ) {
197
-					add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
198
-				}
199
-			}
200
-
201
-		}
202
-
203
-		/**
204
-		 * Add FA to the FSE.
205
-		 *
206
-		 * @param $editor_settings
207
-		 * @param $block_editor_context
208
-		 *
209
-		 * @return array
210
-		 */
211
-		public function enqueue_editor_styles( $editor_settings, $block_editor_context ){
212
-
213
-			if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) {
214
-				$url = $this->get_url();
215
-				$editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css'  href='$url' media='all' />";
216
-			}
217
-
218
-			return $editor_settings;
219
-		}
220
-
221
-		/**
222
-		 * Add FA to the FSE.
223
-		 *
224
-		 * @param $editor_settings
225
-		 * @param $block_editor_context
226
-		 *
227
-		 * @return array
228
-		 */
229
-		public function enqueue_editor_scripts( $editor_settings, $block_editor_context ){
230
-
231
-			$url = $this->get_url();
232
-			$editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js'></script>";
233
-
234
-			return $editor_settings;
235
-		}
236
-
237
-		/**
238
-		 * Adds the Font Awesome styles.
239
-		 */
240
-		public function enqueue_style() {
241
-			// build url
242
-			$url = $this->get_url();
243
-			$version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null;
244
-
245
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
246
-			wp_register_style( 'font-awesome', $url, array(), $version );
247
-			wp_enqueue_style( 'font-awesome' );
248
-
249
-			// RTL language support CSS.
250
-			if ( is_rtl() ) {
251
-				wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
252
-			}
253
-
254
-			if ( $this->settings['shims'] ) {
255
-				$url = $this->get_url( true );
256
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
257
-				wp_register_style( 'font-awesome-shims', $url, array(), $version );
258
-				wp_enqueue_style( 'font-awesome-shims' );
259
-			}
260
-		}
261
-
262
-		/**
263
-		 * Adds the Font Awesome JS.
264
-		 */
265
-		public function enqueue_scripts() {
266
-			// build url
267
-			$url = $this->get_url();
268
-
269
-			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
270
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
271
-			wp_register_script( 'font-awesome', $url, array(), null );
272
-			wp_enqueue_script( 'font-awesome' );
273
-
274
-			if ( $this->settings['shims'] ) {
275
-				$url = $this->get_url( true );
276
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
277
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
278
-				wp_enqueue_script( 'font-awesome-shims' );
279
-			}
280
-		}
281
-
282
-		/**
283
-		 * Get the url of the Font Awesome files.
284
-		 *
285
-		 * @param bool $shims If this is a shim file or not.
286
-		 * @param bool $local Load locally if allowed.
287
-		 *
288
-		 * @return string The url to the file.
289
-		 */
290
-		public function get_url( $shims = false, $local = true ) {
291
-			$script  = $shims ? 'v4-shims' : 'all';
292
-			$sub     = $this->settings['pro'] ? 'pro' : 'use';
293
-			$type    = $this->settings['type'];
294
-			$version = $this->settings['version'];
295
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
296
-			$url     = '';
297
-
298
-			if ( $type == 'KIT' && $kit_url ) {
299
-				if ( $shims ) {
300
-					// if its a kit then we don't add shims here
301
-					return '';
302
-				}
303
-				$url .= $kit_url; // CDN
304
-				$url .= "?wpfas=true"; // set our var so our version is not removed
305
-			} else {
306
-				$v = '';
307
-				// Check and load locally.
308
-				if ( $local && $this->has_local() ) {
309
-					$script .= ".min";
310
-					$v .= '&ver=' . strip_tags( $this->settings['local_version'] );
311
-					$url .= $this->get_fonts_url(); // Local fonts url.
312
-				} else {
313
-					$url .= "https://$sub.fontawesome.com/releases/"; // CDN
314
-					$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
315
-				}
316
-				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
317
-				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
318
-				$url .= "?wpfas=true" . $v; // set our var so our version is not removed
319
-			}
320
-
321
-			return $url;
322
-		}
323
-
324
-		/**
325
-		 * Try and remove any other versions of Font Awesome added by other plugins/themes.
326
-		 *
327
-		 * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
328
-		 *
329
-		 * @param $url
330
-		 * @param $original_url
331
-		 * @param $_context
332
-		 *
333
-		 * @return string The filtered url.
334
-		 */
335
-		public function remove_font_awesome( $url, $original_url, $_context ) {
336
-
337
-			if ( $_context == 'display'
338
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
339
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
340
-			) {// it's a font-awesome-url (probably)
341
-
342
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
343
-					if ( $this->settings['type'] == 'JS' ) {
344
-						if ( $this->settings['js-pseudo'] ) {
345
-							$url .= "' data-search-pseudo-elements defer='defer";
346
-						} else {
347
-							$url .= "' defer='defer";
348
-						}
349
-					}
350
-				} else {
351
-					$url = ''; // removing the url removes the file
352
-				}
353
-
354
-			}
355
-
356
-			return $url;
357
-		}
358
-
359
-		/**
360
-		 * Register the database settings with WordPress.
361
-		 */
362
-		public function register_settings() {
363
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
364
-		}
365
-
366
-		/**
367
-		 * Add the WordPress settings menu item.
368
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
369
-		 */
370
-		public function menu_item() {
371
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
372
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
373
-				$this,
374
-				'settings_page'
375
-			) );
376
-		}
377
-
378
-		/**
379
-		 * Get the current Font Awesome output settings.
380
-		 *
381
-		 * @return array The array of settings.
382
-		 */
383
-		public function get_settings() {
384
-			$db_settings = get_option( 'wp-font-awesome-settings' );
385
-
386
-			$defaults = array(
387
-				'type'      => 'CSS', // type to use, CSS or JS or KIT
388
-				'version'   => '', // latest
389
-				'enqueue'   => '', // front and backend
390
-				'shims'     => '0', // default OFF now in 2020
391
-				'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
392
-				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
393
-				'pro'       => '0', // if pro CDN url should be used
394
-				'local'     => '0', // Store fonts locally.
395
-				'local_version' => '', // Local fonts version.
396
-				'kit-url'   => '', // the kit url
397
-			);
398
-
399
-			$settings = wp_parse_args( $db_settings, $defaults );
400
-
401
-			/**
402
-			 * Filter the Font Awesome settings.
403
-			 *
404
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
405
-			 */
406
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
407
-		}
408
-
409
-		/**
410
-		 * The settings page html output.
411
-		 */
412
-		public function settings_page() {
413
-			if ( ! current_user_can( 'manage_options' ) ) {
414
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
415
-			}
416
-
417
-			// a hidden way to force the update of the version number via api instead of waiting the 48 hours
418
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
419
-				$this->get_latest_version( $force_api = true );
420
-			}
421
-
422
-			if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
423
-				?>
126
+            if ( ! defined( 'FAS_PRO' ) && $this->settings['pro'] ) {
127
+                define( 'FAS_PRO', true );
128
+            }
129
+        }
130
+
131
+        /**
132
+         * Get the url path to the current folder.
133
+         *
134
+         * @return string
135
+         */
136
+        public function get_path_url() {
137
+            $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
138
+            $content_url = untrailingslashit( WP_CONTENT_URL );
139
+
140
+            // Replace http:// to https://.
141
+            if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
142
+                $content_url = str_replace( 'http://', 'https://', $content_url );
143
+            }
144
+
145
+            // Check if we are inside a plugin
146
+            $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
147
+            $url = str_replace( $content_dir, $content_url, $file_dir );
148
+
149
+            return trailingslashit( $url );
150
+        }
151
+
152
+        /**
153
+         * Initiate the settings and add the required action hooks.
154
+         *
155
+         * @since 1.0.8 Settings name wrong - FIXED
156
+         */
157
+        public function init() {
158
+            // Download fontawesome locally.
159
+            add_action( 'add_option_wp-font-awesome-settings', array( $this, 'add_option_wp_font_awesome_settings' ), 10, 2 );
160
+            add_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
161
+
162
+            $this->settings = $this->get_settings();
163
+
164
+            // Check if the official plugin is active and use that instead if so.
165
+            if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
166
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
167
+                    add_action( 'admin_head', array( $this, 'add_generator' ), 99 );
168
+                }
169
+
170
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
171
+                    add_action( 'wp_head', array( $this, 'add_generator' ), 99 );
172
+                }
173
+
174
+                if ( $this->settings['type'] == 'CSS' ) {
175
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
176
+                        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
177
+                        //add_action( 'wp_footer', array( $this, 'enqueue_style' ), 5000 ); // not sure why this was added, seems to break frontend
178
+                    }
179
+
180
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
181
+                        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
182
+                        add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_styles' ), 10, 2 );
183
+                    }
184
+                } else {
185
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
186
+                        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
187
+                    }
188
+
189
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
190
+                        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
191
+                        add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 );
192
+                    }
193
+                }
194
+
195
+                // remove font awesome if set to do so
196
+                if ( $this->settings['dequeue'] == '1' ) {
197
+                    add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
198
+                }
199
+            }
200
+
201
+        }
202
+
203
+        /**
204
+         * Add FA to the FSE.
205
+         *
206
+         * @param $editor_settings
207
+         * @param $block_editor_context
208
+         *
209
+         * @return array
210
+         */
211
+        public function enqueue_editor_styles( $editor_settings, $block_editor_context ){
212
+
213
+            if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) {
214
+                $url = $this->get_url();
215
+                $editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css'  href='$url' media='all' />";
216
+            }
217
+
218
+            return $editor_settings;
219
+        }
220
+
221
+        /**
222
+         * Add FA to the FSE.
223
+         *
224
+         * @param $editor_settings
225
+         * @param $block_editor_context
226
+         *
227
+         * @return array
228
+         */
229
+        public function enqueue_editor_scripts( $editor_settings, $block_editor_context ){
230
+
231
+            $url = $this->get_url();
232
+            $editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js'></script>";
233
+
234
+            return $editor_settings;
235
+        }
236
+
237
+        /**
238
+         * Adds the Font Awesome styles.
239
+         */
240
+        public function enqueue_style() {
241
+            // build url
242
+            $url = $this->get_url();
243
+            $version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null;
244
+
245
+            wp_deregister_style( 'font-awesome' ); // deregister in case its already there
246
+            wp_register_style( 'font-awesome', $url, array(), $version );
247
+            wp_enqueue_style( 'font-awesome' );
248
+
249
+            // RTL language support CSS.
250
+            if ( is_rtl() ) {
251
+                wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
252
+            }
253
+
254
+            if ( $this->settings['shims'] ) {
255
+                $url = $this->get_url( true );
256
+                wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
257
+                wp_register_style( 'font-awesome-shims', $url, array(), $version );
258
+                wp_enqueue_style( 'font-awesome-shims' );
259
+            }
260
+        }
261
+
262
+        /**
263
+         * Adds the Font Awesome JS.
264
+         */
265
+        public function enqueue_scripts() {
266
+            // build url
267
+            $url = $this->get_url();
268
+
269
+            $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
270
+            call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
271
+            wp_register_script( 'font-awesome', $url, array(), null );
272
+            wp_enqueue_script( 'font-awesome' );
273
+
274
+            if ( $this->settings['shims'] ) {
275
+                $url = $this->get_url( true );
276
+                call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
277
+                wp_register_script( 'font-awesome-shims', $url, array(), null );
278
+                wp_enqueue_script( 'font-awesome-shims' );
279
+            }
280
+        }
281
+
282
+        /**
283
+         * Get the url of the Font Awesome files.
284
+         *
285
+         * @param bool $shims If this is a shim file or not.
286
+         * @param bool $local Load locally if allowed.
287
+         *
288
+         * @return string The url to the file.
289
+         */
290
+        public function get_url( $shims = false, $local = true ) {
291
+            $script  = $shims ? 'v4-shims' : 'all';
292
+            $sub     = $this->settings['pro'] ? 'pro' : 'use';
293
+            $type    = $this->settings['type'];
294
+            $version = $this->settings['version'];
295
+            $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
296
+            $url     = '';
297
+
298
+            if ( $type == 'KIT' && $kit_url ) {
299
+                if ( $shims ) {
300
+                    // if its a kit then we don't add shims here
301
+                    return '';
302
+                }
303
+                $url .= $kit_url; // CDN
304
+                $url .= "?wpfas=true"; // set our var so our version is not removed
305
+            } else {
306
+                $v = '';
307
+                // Check and load locally.
308
+                if ( $local && $this->has_local() ) {
309
+                    $script .= ".min";
310
+                    $v .= '&ver=' . strip_tags( $this->settings['local_version'] );
311
+                    $url .= $this->get_fonts_url(); // Local fonts url.
312
+                } else {
313
+                    $url .= "https://$sub.fontawesome.com/releases/"; // CDN
314
+                    $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
315
+                }
316
+                $url .= $type == 'CSS' ? 'css/' : 'js/'; // type
317
+                $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
318
+                $url .= "?wpfas=true" . $v; // set our var so our version is not removed
319
+            }
320
+
321
+            return $url;
322
+        }
323
+
324
+        /**
325
+         * Try and remove any other versions of Font Awesome added by other plugins/themes.
326
+         *
327
+         * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
328
+         *
329
+         * @param $url
330
+         * @param $original_url
331
+         * @param $_context
332
+         *
333
+         * @return string The filtered url.
334
+         */
335
+        public function remove_font_awesome( $url, $original_url, $_context ) {
336
+
337
+            if ( $_context == 'display'
338
+                 && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
339
+                 && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
340
+            ) {// it's a font-awesome-url (probably)
341
+
342
+                if ( strstr( $url, "wpfas=true" ) !== false ) {
343
+                    if ( $this->settings['type'] == 'JS' ) {
344
+                        if ( $this->settings['js-pseudo'] ) {
345
+                            $url .= "' data-search-pseudo-elements defer='defer";
346
+                        } else {
347
+                            $url .= "' defer='defer";
348
+                        }
349
+                    }
350
+                } else {
351
+                    $url = ''; // removing the url removes the file
352
+                }
353
+
354
+            }
355
+
356
+            return $url;
357
+        }
358
+
359
+        /**
360
+         * Register the database settings with WordPress.
361
+         */
362
+        public function register_settings() {
363
+            register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
364
+        }
365
+
366
+        /**
367
+         * Add the WordPress settings menu item.
368
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
369
+         */
370
+        public function menu_item() {
371
+            $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
372
+            call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
373
+                $this,
374
+                'settings_page'
375
+            ) );
376
+        }
377
+
378
+        /**
379
+         * Get the current Font Awesome output settings.
380
+         *
381
+         * @return array The array of settings.
382
+         */
383
+        public function get_settings() {
384
+            $db_settings = get_option( 'wp-font-awesome-settings' );
385
+
386
+            $defaults = array(
387
+                'type'      => 'CSS', // type to use, CSS or JS or KIT
388
+                'version'   => '', // latest
389
+                'enqueue'   => '', // front and backend
390
+                'shims'     => '0', // default OFF now in 2020
391
+                'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
392
+                'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
393
+                'pro'       => '0', // if pro CDN url should be used
394
+                'local'     => '0', // Store fonts locally.
395
+                'local_version' => '', // Local fonts version.
396
+                'kit-url'   => '', // the kit url
397
+            );
398
+
399
+            $settings = wp_parse_args( $db_settings, $defaults );
400
+
401
+            /**
402
+             * Filter the Font Awesome settings.
403
+             *
404
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
405
+             */
406
+            return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
407
+        }
408
+
409
+        /**
410
+         * The settings page html output.
411
+         */
412
+        public function settings_page() {
413
+            if ( ! current_user_can( 'manage_options' ) ) {
414
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
415
+            }
416
+
417
+            // a hidden way to force the update of the version number via api instead of waiting the 48 hours
418
+            if ( isset( $_REQUEST['force-version-check'] ) ) {
419
+                $this->get_latest_version( $force_api = true );
420
+            }
421
+
422
+            if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
423
+                ?>
424 424
                 <style>
425 425
                     .wpfas-kit-show {
426 426
                         display: none;
@@ -446,16 +446,16 @@  discard block
 block discarded – undo
446 446
                     <h1><?php echo $this->name; ?></h1>
447 447
                     <form method="post" action="options.php" class="fas-settings-form">
448 448
 						<?php
449
-						settings_fields( 'wp-font-awesome-settings' );
450
-						do_settings_sections( 'wp-font-awesome-settings' );
451
-						$table_class = '';
452
-						if ( $this->settings['type'] ) {
453
-							$table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set';
454
-						}
455
-						if ( ! empty( $this->settings['pro'] ) ) {
456
-							$table_class .= ' wpfas-has-pro';
457
-						}
458
-						?>
449
+                        settings_fields( 'wp-font-awesome-settings' );
450
+                        do_settings_sections( 'wp-font-awesome-settings' );
451
+                        $table_class = '';
452
+                        if ( $this->settings['type'] ) {
453
+                            $table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set';
454
+                        }
455
+                        if ( ! empty( $this->settings['pro'] ) ) {
456
+                            $table_class .= ' wpfas-has-pro';
457
+                        }
458
+                        ?>
459 459
 						<?php if ( $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ) { ?>
460 460
 							<?php if ( $this->has_local() ) { ?>
461 461
                                 <div class="notice notice-info"><p><strong><?php _e( 'Font Awesome fonts are loading locally.', 'ayecode-connect' ); ?></strong></p></div>
@@ -480,12 +480,12 @@  discard block
 block discarded – undo
480 480
                                 <td>
481 481
                                     <input class="regular-text" id="wpfas-kit-url" type="url" name="wp-font-awesome-settings[kit-url]" value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>" placeholder="<?php echo 'https://kit.font';echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/>
482 482
                                     <span><?php
483
-										echo wp_sprintf(
484
-											__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect' ),
485
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
486
-											'</a>'
487
-										);
488
-										?></span>
483
+                                        echo wp_sprintf(
484
+                                            __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect' ),
485
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
486
+                                            '</a>'
487
+                                        );
488
+                                        ?></span>
489 489
                                 </td>
490 490
                             </tr>
491 491
 
@@ -526,14 +526,14 @@  discard block
 block discarded – undo
526 526
                                     <input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/>
527 527
                                     <input type="checkbox" name="wp-font-awesome-settings[pro]" value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro" onchange="if(jQuery(this).is(':checked')){jQuery('.wpfas-table-settings').addClass('wpfas-has-pro')}else{jQuery('.wpfas-table-settings').removeClass('wpfas-has-pro')}"/>
528 528
                                     <span><?php
529
-										echo wp_sprintf(
530
-											__( 'Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'ayecode-connect' ),
531
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">',
532
-											' <i class="fas fa-external-link-alt"></i></a>',
533
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">',
534
-											' <i class="fas fa-external-link-alt"></i></a>'
535
-										);
536
-										?></span>
529
+                                        echo wp_sprintf(
530
+                                            __( 'Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'ayecode-connect' ),
531
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">',
532
+                                            ' <i class="fas fa-external-link-alt"></i></a>',
533
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">',
534
+                                            ' <i class="fas fa-external-link-alt"></i></a>'
535
+                                        );
536
+                                        ?></span>
537 537
                                 </td>
538 538
                             </tr>
539 539
 
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
                         </table>
588 588
                         <div class="fas-buttons">
589 589
 							<?php
590
-							submit_button();
591
-							?>
590
+                            submit_button();
591
+                            ?>
592 592
                             <p class="submit"><a href="https://fontawesome.com/referral?a=c9b89e1418" class="button button-secondary"><?php _e('Get 24,000+ more icons with Font Awesome Pro','ayecode-connect'); ?> <i class="fas fa-external-link-alt"></i></a></p>
593 593
 
594 594
                         </div>
@@ -597,414 +597,414 @@  discard block
 block discarded – undo
597 597
                     <div id="wpfas-version"><?php echo wp_sprintf(__( 'Version: %s (affiliate links provided)', 'ayecode-connect' ), $this->version ); ?></div>
598 598
                 </div>
599 599
 				<?php
600
-			}
601
-		}
602
-
603
-		/**
604
-		 * Check a version number is valid and if so return it or else return an empty string.
605
-		 *
606
-		 * @param $version string The version number to check.
607
-		 *
608
-		 * @since 1.0.6
609
-		 *
610
-		 * @return string Either a valid version number or an empty string.
611
-		 */
612
-		public function validate_version_number( $version ) {
613
-
614
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
615
-				// valid
616
-			} else {
617
-				$version = '';// not validated
618
-			}
619
-
620
-			return $version;
621
-		}
622
-
623
-
624
-		/**
625
-		 * Get the latest version of Font Awesome.
626
-		 *
627
-		 * We check for a cached version and if none we will check for a live version via API and then cache it for 48 hours.
628
-		 *
629
-		 * @since 1.0.7
630
-		 * @return mixed|string The latest version number found.
631
-		 */
632
-		public function get_latest_version( $force_api = false ) {
633
-			$latest_version = $this->latest;
634
-
635
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
636
-
637
-			if ( $cache === false || $force_api ) { // its not set
638
-				$api_ver = $this->get_latest_version_from_api();
639
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
640
-					$latest_version = $api_ver;
641
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
642
-				}
643
-			} elseif ( $this->validate_version_number( $cache ) ) {
644
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
645
-					$latest_version = $cache;
646
-				}
647
-			}
648
-
649
-			// Check and auto download fonts locally.
650
-			if ( empty( $this->settings['pro'] ) && empty( $this->settings['version'] ) && $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && ! empty( $this->settings['local_version'] ) && ! empty( $latest_version ) ) {
651
-				if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) {
652
-					$this->download_package( $latest_version );
653
-				}
654
-			}
655
-
656
-			return $latest_version;
657
-		}
658
-
659
-		/**
660
-		 * Get the latest Font Awesome version from the github API.
661
-		 *
662
-		 * @since 1.0.7
663
-		 * @return string The latest version number or `0` on API fail.
664
-		 */
665
-		public function get_latest_version_from_api() {
666
-			$version  = "0";
667
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
668
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
669
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
670
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
671
-					$version = $api_response['tag_name'];
672
-				}
673
-			}
674
-
675
-			return $version;
676
-		}
677
-
678
-		/**
679
-		 * Inline CSS for RTL language support.
680
-		 *
681
-		 * @since 1.0.13
682
-		 * @return string Inline CSS.
683
-		 */
684
-		public function rtl_inline_css() {
685
-			$inline_css = '[dir=rtl] .fa-address,[dir=rtl] .fa-address-card,[dir=rtl] .fa-adjust,[dir=rtl] .fa-alarm-clock,[dir=rtl] .fa-align-left,[dir=rtl] .fa-align-right,[dir=rtl] .fa-analytics,[dir=rtl] .fa-angle-double-left,[dir=rtl] .fa-angle-double-right,[dir=rtl] .fa-angle-left,[dir=rtl] .fa-angle-right,[dir=rtl] .fa-arrow-alt-circle-left,[dir=rtl] .fa-arrow-alt-circle-right,[dir=rtl] .fa-arrow-alt-from-left,[dir=rtl] .fa-arrow-alt-from-right,[dir=rtl] .fa-arrow-alt-left,[dir=rtl] .fa-arrow-alt-right,[dir=rtl] .fa-arrow-alt-square-left,[dir=rtl] .fa-arrow-alt-square-right,[dir=rtl] .fa-arrow-alt-to-left,[dir=rtl] .fa-arrow-alt-to-right,[dir=rtl] .fa-arrow-circle-left,[dir=rtl] .fa-arrow-circle-right,[dir=rtl] .fa-arrow-from-left,[dir=rtl] .fa-arrow-from-right,[dir=rtl] .fa-arrow-left,[dir=rtl] .fa-arrow-right,[dir=rtl] .fa-arrow-square-left,[dir=rtl] .fa-arrow-square-right,[dir=rtl] .fa-arrow-to-left,[dir=rtl] .fa-arrow-to-right,[dir=rtl] .fa-balance-scale-left,[dir=rtl] .fa-balance-scale-right,[dir=rtl] .fa-bed,[dir=rtl] .fa-bed-bunk,[dir=rtl] .fa-bed-empty,[dir=rtl] .fa-border-left,[dir=rtl] .fa-border-right,[dir=rtl] .fa-calendar-check,[dir=rtl] .fa-caret-circle-left,[dir=rtl] .fa-caret-circle-right,[dir=rtl] .fa-caret-left,[dir=rtl] .fa-caret-right,[dir=rtl] .fa-caret-square-left,[dir=rtl] .fa-caret-square-right,[dir=rtl] .fa-cart-arrow-down,[dir=rtl] .fa-cart-plus,[dir=rtl] .fa-chart-area,[dir=rtl] .fa-chart-bar,[dir=rtl] .fa-chart-line,[dir=rtl] .fa-chart-line-down,[dir=rtl] .fa-chart-network,[dir=rtl] .fa-chart-pie,[dir=rtl] .fa-chart-pie-alt,[dir=rtl] .fa-chart-scatter,[dir=rtl] .fa-check-circle,[dir=rtl] .fa-check-square,[dir=rtl] .fa-chevron-circle-left,[dir=rtl] .fa-chevron-circle-right,[dir=rtl] .fa-chevron-double-left,[dir=rtl] .fa-chevron-double-right,[dir=rtl] .fa-chevron-left,[dir=rtl] .fa-chevron-right,[dir=rtl] .fa-chevron-square-left,[dir=rtl] .fa-chevron-square-right,[dir=rtl] .fa-clock,[dir=rtl] .fa-file,[dir=rtl] .fa-file-alt,[dir=rtl] .fa-file-archive,[dir=rtl] .fa-file-audio,[dir=rtl] .fa-file-chart-line,[dir=rtl] .fa-file-chart-pie,[dir=rtl] .fa-file-code,[dir=rtl] .fa-file-excel,[dir=rtl] .fa-file-image,[dir=rtl] .fa-file-pdf,[dir=rtl] .fa-file-powerpoint,[dir=rtl] .fa-file-video,[dir=rtl] .fa-file-word,[dir=rtl] .fa-flag,[dir=rtl] .fa-folder,[dir=rtl] .fa-folder-open,[dir=rtl] .fa-hand-lizard,[dir=rtl] .fa-hand-point-down,[dir=rtl] .fa-hand-point-left,[dir=rtl] .fa-hand-point-right,[dir=rtl] .fa-hand-point-up,[dir=rtl] .fa-hand-scissors,[dir=rtl] .fa-image,[dir=rtl] .fa-long-arrow-alt-left,[dir=rtl] .fa-long-arrow-alt-right,[dir=rtl] .fa-long-arrow-left,[dir=rtl] .fa-long-arrow-right,[dir=rtl] .fa-luggage-cart,[dir=rtl] .fa-moon,[dir=rtl] .fa-pencil,[dir=rtl] .fa-pencil-alt,[dir=rtl] .fa-play-circle,[dir=rtl] .fa-project-diagram,[dir=rtl] .fa-quote-left,[dir=rtl] .fa-quote-right,[dir=rtl] .fa-shopping-cart,[dir=rtl] .fa-thumbs-down,[dir=rtl] .fa-thumbs-up,[dir=rtl] .fa-user-chart{filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);transform:scale(-1,1)}[dir=rtl] .fa-spin{animation-direction:reverse}';
686
-
687
-			return $inline_css;
688
-		}
689
-
690
-		/**
691
-		 * Show any warnings as an admin notice.
692
-		 *
693
-		 * @return void
694
-		 */
695
-		public function admin_notices() {
696
-			$settings = $this->settings;
697
-
698
-			if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
699
-				if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) {
700
-					?>
600
+            }
601
+        }
602
+
603
+        /**
604
+         * Check a version number is valid and if so return it or else return an empty string.
605
+         *
606
+         * @param $version string The version number to check.
607
+         *
608
+         * @since 1.0.6
609
+         *
610
+         * @return string Either a valid version number or an empty string.
611
+         */
612
+        public function validate_version_number( $version ) {
613
+
614
+            if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
615
+                // valid
616
+            } else {
617
+                $version = '';// not validated
618
+            }
619
+
620
+            return $version;
621
+        }
622
+
623
+
624
+        /**
625
+         * Get the latest version of Font Awesome.
626
+         *
627
+         * We check for a cached version and if none we will check for a live version via API and then cache it for 48 hours.
628
+         *
629
+         * @since 1.0.7
630
+         * @return mixed|string The latest version number found.
631
+         */
632
+        public function get_latest_version( $force_api = false ) {
633
+            $latest_version = $this->latest;
634
+
635
+            $cache = get_transient( 'wp-font-awesome-settings-version' );
636
+
637
+            if ( $cache === false || $force_api ) { // its not set
638
+                $api_ver = $this->get_latest_version_from_api();
639
+                if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
640
+                    $latest_version = $api_ver;
641
+                    set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
642
+                }
643
+            } elseif ( $this->validate_version_number( $cache ) ) {
644
+                if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
645
+                    $latest_version = $cache;
646
+                }
647
+            }
648
+
649
+            // Check and auto download fonts locally.
650
+            if ( empty( $this->settings['pro'] ) && empty( $this->settings['version'] ) && $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && ! empty( $this->settings['local_version'] ) && ! empty( $latest_version ) ) {
651
+                if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) {
652
+                    $this->download_package( $latest_version );
653
+                }
654
+            }
655
+
656
+            return $latest_version;
657
+        }
658
+
659
+        /**
660
+         * Get the latest Font Awesome version from the github API.
661
+         *
662
+         * @since 1.0.7
663
+         * @return string The latest version number or `0` on API fail.
664
+         */
665
+        public function get_latest_version_from_api() {
666
+            $version  = "0";
667
+            $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
668
+            if ( ! is_wp_error( $response ) && is_array( $response ) ) {
669
+                $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
670
+                if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
671
+                    $version = $api_response['tag_name'];
672
+                }
673
+            }
674
+
675
+            return $version;
676
+        }
677
+
678
+        /**
679
+         * Inline CSS for RTL language support.
680
+         *
681
+         * @since 1.0.13
682
+         * @return string Inline CSS.
683
+         */
684
+        public function rtl_inline_css() {
685
+            $inline_css = '[dir=rtl] .fa-address,[dir=rtl] .fa-address-card,[dir=rtl] .fa-adjust,[dir=rtl] .fa-alarm-clock,[dir=rtl] .fa-align-left,[dir=rtl] .fa-align-right,[dir=rtl] .fa-analytics,[dir=rtl] .fa-angle-double-left,[dir=rtl] .fa-angle-double-right,[dir=rtl] .fa-angle-left,[dir=rtl] .fa-angle-right,[dir=rtl] .fa-arrow-alt-circle-left,[dir=rtl] .fa-arrow-alt-circle-right,[dir=rtl] .fa-arrow-alt-from-left,[dir=rtl] .fa-arrow-alt-from-right,[dir=rtl] .fa-arrow-alt-left,[dir=rtl] .fa-arrow-alt-right,[dir=rtl] .fa-arrow-alt-square-left,[dir=rtl] .fa-arrow-alt-square-right,[dir=rtl] .fa-arrow-alt-to-left,[dir=rtl] .fa-arrow-alt-to-right,[dir=rtl] .fa-arrow-circle-left,[dir=rtl] .fa-arrow-circle-right,[dir=rtl] .fa-arrow-from-left,[dir=rtl] .fa-arrow-from-right,[dir=rtl] .fa-arrow-left,[dir=rtl] .fa-arrow-right,[dir=rtl] .fa-arrow-square-left,[dir=rtl] .fa-arrow-square-right,[dir=rtl] .fa-arrow-to-left,[dir=rtl] .fa-arrow-to-right,[dir=rtl] .fa-balance-scale-left,[dir=rtl] .fa-balance-scale-right,[dir=rtl] .fa-bed,[dir=rtl] .fa-bed-bunk,[dir=rtl] .fa-bed-empty,[dir=rtl] .fa-border-left,[dir=rtl] .fa-border-right,[dir=rtl] .fa-calendar-check,[dir=rtl] .fa-caret-circle-left,[dir=rtl] .fa-caret-circle-right,[dir=rtl] .fa-caret-left,[dir=rtl] .fa-caret-right,[dir=rtl] .fa-caret-square-left,[dir=rtl] .fa-caret-square-right,[dir=rtl] .fa-cart-arrow-down,[dir=rtl] .fa-cart-plus,[dir=rtl] .fa-chart-area,[dir=rtl] .fa-chart-bar,[dir=rtl] .fa-chart-line,[dir=rtl] .fa-chart-line-down,[dir=rtl] .fa-chart-network,[dir=rtl] .fa-chart-pie,[dir=rtl] .fa-chart-pie-alt,[dir=rtl] .fa-chart-scatter,[dir=rtl] .fa-check-circle,[dir=rtl] .fa-check-square,[dir=rtl] .fa-chevron-circle-left,[dir=rtl] .fa-chevron-circle-right,[dir=rtl] .fa-chevron-double-left,[dir=rtl] .fa-chevron-double-right,[dir=rtl] .fa-chevron-left,[dir=rtl] .fa-chevron-right,[dir=rtl] .fa-chevron-square-left,[dir=rtl] .fa-chevron-square-right,[dir=rtl] .fa-clock,[dir=rtl] .fa-file,[dir=rtl] .fa-file-alt,[dir=rtl] .fa-file-archive,[dir=rtl] .fa-file-audio,[dir=rtl] .fa-file-chart-line,[dir=rtl] .fa-file-chart-pie,[dir=rtl] .fa-file-code,[dir=rtl] .fa-file-excel,[dir=rtl] .fa-file-image,[dir=rtl] .fa-file-pdf,[dir=rtl] .fa-file-powerpoint,[dir=rtl] .fa-file-video,[dir=rtl] .fa-file-word,[dir=rtl] .fa-flag,[dir=rtl] .fa-folder,[dir=rtl] .fa-folder-open,[dir=rtl] .fa-hand-lizard,[dir=rtl] .fa-hand-point-down,[dir=rtl] .fa-hand-point-left,[dir=rtl] .fa-hand-point-right,[dir=rtl] .fa-hand-point-up,[dir=rtl] .fa-hand-scissors,[dir=rtl] .fa-image,[dir=rtl] .fa-long-arrow-alt-left,[dir=rtl] .fa-long-arrow-alt-right,[dir=rtl] .fa-long-arrow-left,[dir=rtl] .fa-long-arrow-right,[dir=rtl] .fa-luggage-cart,[dir=rtl] .fa-moon,[dir=rtl] .fa-pencil,[dir=rtl] .fa-pencil-alt,[dir=rtl] .fa-play-circle,[dir=rtl] .fa-project-diagram,[dir=rtl] .fa-quote-left,[dir=rtl] .fa-quote-right,[dir=rtl] .fa-shopping-cart,[dir=rtl] .fa-thumbs-down,[dir=rtl] .fa-thumbs-up,[dir=rtl] .fa-user-chart{filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);transform:scale(-1,1)}[dir=rtl] .fa-spin{animation-direction:reverse}';
686
+
687
+            return $inline_css;
688
+        }
689
+
690
+        /**
691
+         * Show any warnings as an admin notice.
692
+         *
693
+         * @return void
694
+         */
695
+        public function admin_notices() {
696
+            $settings = $this->settings;
697
+
698
+            if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
699
+                if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) {
700
+                    ?>
701 701
                     <div class="notice  notice-error is-dismissible">
702 702
                         <p><?php _e( 'The Official Font Awesome Plugin is active, please adjust your settings there.', 'ayecode-connect' ); ?></p>
703 703
                     </div>
704 704
 					<?php
705
-				}
706
-			} else {
707
-				if ( ! empty( $settings ) ) {
708
-					if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) {
709
-						$link = admin_url('options-general.php?page=wp-font-awesome-settings');
710
-						?>
705
+                }
706
+            } else {
707
+                if ( ! empty( $settings ) ) {
708
+                    if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) {
709
+                        $link = admin_url('options-general.php?page=wp-font-awesome-settings');
710
+                        ?>
711 711
                         <div class="notice  notice-error is-dismissible">
712 712
                             <p><?php echo wp_sprintf( __( 'Font Awesome Pro v6 requires the use of a kit, please setup your kit in %ssettings.%s', 'ayecode-connect' ),"<a href='". esc_url_raw( $link )."'>","</a>" ); ?></p>
713 713
                         </div>
714 714
 						<?php
715
-					}
716
-				}
717
-			}
718
-		}
719
-
720
-		/**
721
-		 * Handle fontawesome add settings to download fontawesome to store locally.
722
-		 *
723
-		 * @since 1.1.1
724
-		 *
725
-		 * @param string $option The option name.
726
-		 * @param mixed  $value  The option value.
727
-		 */
728
-		public function add_option_wp_font_awesome_settings( $option, $value ) {
729
-			// Do nothing if WordPress is being installed.
730
-			if ( wp_installing() ) {
731
-				return;
732
-			}
733
-
734
-			if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) {
735
-				$version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version();
736
-
737
-				if ( ! empty( $version ) ) {
738
-					$response = $this->download_package( $version, $value );
739
-
740
-					if ( is_wp_error( $response ) ) {
741
-						add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
742
-					}
743
-				}
744
-			}
745
-		}
746
-
747
-		/**
748
-		 * Handle fontawesome update settings to download fontawesome to store locally.
749
-		 *
750
-		 * @since 1.1.0
751
-		 *
752
-		 * @param mixed $old_value The old option value.
753
-		 * @param mixed $value     The new option value.
754
-		 */
755
-		public function update_option_wp_font_awesome_settings( $old_value, $new_value ) {
756
-			// Do nothing if WordPress is being installed.
757
-			if ( wp_installing() ) {
758
-				return;
759
-			}
760
-
761
-			if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) {
762
-				// Old values
763
-				$old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' );
764
-				$old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0;
765
-
766
-				// New values
767
-				$new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
768
-
769
-				if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
770
-					$response = $this->download_package( $new_version, $new_value );
771
-
772
-					if ( is_wp_error( $response ) ) {
773
-						add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
774
-					}
775
-				}
776
-			}
777
-		}
778
-
779
-		/**
780
-		 * Get the fonts directory local path.
781
-		 *
782
-		 * @since 1.1.0
783
-		 *
784
-		 * @param string Fonts directory local path.
785
-		 */
786
-		public function get_fonts_dir() {
787
-			$upload_dir = wp_upload_dir( null, false );
788
-
789
-			return $upload_dir['basedir'] . DIRECTORY_SEPARATOR .  'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
790
-		}
791
-
792
-		/**
793
-		 * Get the fonts directory local url.
794
-		 *
795
-		 * @since 1.1.0
796
-		 *
797
-		 * @param string Fonts directory local url.
798
-		 */
799
-		public function get_fonts_url() {
800
-			$upload_dir = wp_upload_dir( null, false );
801
-
802
-			return $upload_dir['baseurl'] .  '/ayefonts/fa/';
803
-		}
804
-
805
-		/**
806
-		 * Check whether load locally active.
807
-		 *
808
-		 * @since 1.1.0
809
-		 *
810
-		 * @return bool True if active else false.
811
-		 */
812
-		public function has_local() {
813
-			if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
814
-				return true;
815
-			}
816
-
817
-			return false;
818
-		}
819
-
820
-		/**
821
-		 * Get the WP Filesystem access.
822
-		 *
823
-		 * @since 1.1.0
824
-		 *
825
-		 * @return object The WP Filesystem.
826
-		 */
827
-		public function get_wp_filesystem() {
828
-			if ( ! function_exists( 'get_filesystem_method' ) ) {
829
-				require_once( ABSPATH . "/wp-admin/includes/file.php" );
830
-			}
831
-
832
-			$access_type = get_filesystem_method();
833
-
834
-			if ( $access_type === 'direct' ) {
835
-				/* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
836
-				$creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
837
-
838
-				/* Initialize the API */
839
-				if ( ! WP_Filesystem( $creds ) ) {
840
-					/* Any problems and we exit */
841
-					return false;
842
-				}
843
-
844
-				global $wp_filesystem;
845
-
846
-				return $wp_filesystem;
847
-				/* Do our file manipulations below */
848
-			} else if ( defined( 'FTP_USER' ) ) {
849
-				$creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
850
-
851
-				/* Initialize the API */
852
-				if ( ! WP_Filesystem( $creds ) ) {
853
-					/* Any problems and we exit */
854
-					return false;
855
-				}
856
-
857
-				global $wp_filesystem;
858
-
859
-				return $wp_filesystem;
860
-			} else {
861
-				/* Don't have direct write access. Prompt user with our notice */
862
-				return false;
863
-			}
864
-		}
865
-
866
-		/**
867
-		 * Download the fontawesome package file.
868
-		 *
869
-		 * @since 1.1.0
870
-		 *
871
-		 * @param mixed $version The font awesome.
872
-		 * @param array $option Fontawesome settings.
873
-		 * @return WP_ERROR|bool Error on fail and true on success.
874
-		 */
875
-		public function download_package( $version, $option = array() ) {
876
-			$filename = 'fontawesome-free-' . $version . '-web';
877
-			$url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip';
878
-
879
-			if ( ! function_exists( 'wp_handle_upload' ) ) {
880
-				require_once ABSPATH . 'wp-admin/includes/file.php';
881
-			}
882
-
883
-			$download_file = download_url( esc_url_raw( $url ) );
884
-
885
-			if ( is_wp_error( $download_file ) ) {
886
-				return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'ayecode-connect' ) );
887
-			} else if ( empty( $download_file ) ) {
888
-				return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'ayecode-connect' ) );
889
-			}
890
-
891
-			$response = $this->extract_package( $download_file, $filename, true );
892
-
893
-			// Update local version.
894
-			if ( is_wp_error( $response ) ) {
895
-				return $response;
896
-			} else if ( $response ) {
897
-				if ( empty( $option ) ) {
898
-					$option = get_option( 'wp-font-awesome-settings' );
899
-				}
900
-
901
-				$option['local_version'] = $version;
902
-
903
-				// Remove action to prevent looping.
904
-				remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
905
-
906
-				update_option( 'wp-font-awesome-settings', $option );
907
-
908
-				return true;
909
-			}
910
-
911
-			return false;
912
-		}
913
-
914
-		/**
915
-		 * Extract the fontawesome package file.
916
-		 *
917
-		 * @since 1.1.0
918
-		 *
919
-		 * @param string $package The package file path.
920
-		 * @param string $dirname Package file name.
921
-		 * @param bool   $delete_package Delete temp file or not.
922
-		 * @return WP_Error|bool True on success WP_Error on fail.
923
-		 */
924
-		public function extract_package( $package, $dirname = '', $delete_package = false ) {
925
-			global $wp_filesystem;
926
-
927
-			$wp_filesystem = $this->get_wp_filesystem();
928
-
929
-			if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
930
-				return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'ayecode-connect' ) );
931
-			} else if ( empty( $wp_filesystem ) ) {
932
-				return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'ayecode-connect' ) );
933
-			}
934
-
935
-			$fonts_dir = $this->get_fonts_dir();
936
-			$fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
937
-
938
-			if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
939
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
940
-			}
941
-
942
-			// Unzip package to working directory.
943
-			$result = unzip_file( $package, $fonts_tmp_dir );
944
-
945
-			if ( is_wp_error( $result ) ) {
946
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
947
-
948
-				if ( 'incompatible_archive' === $result->get_error_code() ) {
949
-					return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'ayecode-connect' ) );
950
-				}
951
-
952
-				return $result;
953
-			}
954
-
955
-			if ( $wp_filesystem->is_dir( $fonts_dir ) ) {
956
-				$wp_filesystem->delete( $fonts_dir, true );
957
-			}
958
-
959
-			$extract_dir = $fonts_tmp_dir;
960
-
961
-			if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) {
962
-				$extract_dir .= $dirname . DIRECTORY_SEPARATOR;
963
-			}
964
-
965
-			try {
966
-				$return = $wp_filesystem->move( $extract_dir, $fonts_dir, true );
967
-			} catch ( Exception $e ) {
968
-				$return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'ayecode-connect' ) );
969
-			}
970
-
971
-			if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
972
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
973
-			}
974
-
975
-			// Once extracted, delete the package if required.
976
-			if ( $delete_package ) {
977
-				unlink( $package );
978
-			}
979
-
980
-			return $return;
981
-		}
982
-
983
-		/**
984
-		 * Output the version in the header.
985
-		 */
986
-		public function add_generator() {
987
-			$file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
988
-			$plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
989
-
990
-			// Find source plugin/theme.
991
-			$source = array();
992
-			if ( strpos( $file, $plugins_dir ) !== false ) {
993
-				$source = explode( "/", plugin_basename( $file ) );
994
-			} else if ( function_exists( 'get_theme_root' ) ) {
995
-				$themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
996
-
997
-				if ( strpos( $file, $themes_dir ) !== false ) {
998
-					$source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
999
-				}
1000
-			}
1001
-
1002
-			echo '<meta name="generator" content="WP Font Awesome Settings v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-ac-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
1003
-		}
1004
-	}
1005
-
1006
-	/**
1007
-	 * Run the class if found.
1008
-	 */
1009
-	WP_Font_Awesome_Settings::instance();
715
+                    }
716
+                }
717
+            }
718
+        }
719
+
720
+        /**
721
+         * Handle fontawesome add settings to download fontawesome to store locally.
722
+         *
723
+         * @since 1.1.1
724
+         *
725
+         * @param string $option The option name.
726
+         * @param mixed  $value  The option value.
727
+         */
728
+        public function add_option_wp_font_awesome_settings( $option, $value ) {
729
+            // Do nothing if WordPress is being installed.
730
+            if ( wp_installing() ) {
731
+                return;
732
+            }
733
+
734
+            if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) {
735
+                $version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version();
736
+
737
+                if ( ! empty( $version ) ) {
738
+                    $response = $this->download_package( $version, $value );
739
+
740
+                    if ( is_wp_error( $response ) ) {
741
+                        add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
742
+                    }
743
+                }
744
+            }
745
+        }
746
+
747
+        /**
748
+         * Handle fontawesome update settings to download fontawesome to store locally.
749
+         *
750
+         * @since 1.1.0
751
+         *
752
+         * @param mixed $old_value The old option value.
753
+         * @param mixed $value     The new option value.
754
+         */
755
+        public function update_option_wp_font_awesome_settings( $old_value, $new_value ) {
756
+            // Do nothing if WordPress is being installed.
757
+            if ( wp_installing() ) {
758
+                return;
759
+            }
760
+
761
+            if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) {
762
+                // Old values
763
+                $old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' );
764
+                $old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0;
765
+
766
+                // New values
767
+                $new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
768
+
769
+                if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
770
+                    $response = $this->download_package( $new_version, $new_value );
771
+
772
+                    if ( is_wp_error( $response ) ) {
773
+                        add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
774
+                    }
775
+                }
776
+            }
777
+        }
778
+
779
+        /**
780
+         * Get the fonts directory local path.
781
+         *
782
+         * @since 1.1.0
783
+         *
784
+         * @param string Fonts directory local path.
785
+         */
786
+        public function get_fonts_dir() {
787
+            $upload_dir = wp_upload_dir( null, false );
788
+
789
+            return $upload_dir['basedir'] . DIRECTORY_SEPARATOR .  'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
790
+        }
791
+
792
+        /**
793
+         * Get the fonts directory local url.
794
+         *
795
+         * @since 1.1.0
796
+         *
797
+         * @param string Fonts directory local url.
798
+         */
799
+        public function get_fonts_url() {
800
+            $upload_dir = wp_upload_dir( null, false );
801
+
802
+            return $upload_dir['baseurl'] .  '/ayefonts/fa/';
803
+        }
804
+
805
+        /**
806
+         * Check whether load locally active.
807
+         *
808
+         * @since 1.1.0
809
+         *
810
+         * @return bool True if active else false.
811
+         */
812
+        public function has_local() {
813
+            if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
814
+                return true;
815
+            }
816
+
817
+            return false;
818
+        }
819
+
820
+        /**
821
+         * Get the WP Filesystem access.
822
+         *
823
+         * @since 1.1.0
824
+         *
825
+         * @return object The WP Filesystem.
826
+         */
827
+        public function get_wp_filesystem() {
828
+            if ( ! function_exists( 'get_filesystem_method' ) ) {
829
+                require_once( ABSPATH . "/wp-admin/includes/file.php" );
830
+            }
831
+
832
+            $access_type = get_filesystem_method();
833
+
834
+            if ( $access_type === 'direct' ) {
835
+                /* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
836
+                $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
837
+
838
+                /* Initialize the API */
839
+                if ( ! WP_Filesystem( $creds ) ) {
840
+                    /* Any problems and we exit */
841
+                    return false;
842
+                }
843
+
844
+                global $wp_filesystem;
845
+
846
+                return $wp_filesystem;
847
+                /* Do our file manipulations below */
848
+            } else if ( defined( 'FTP_USER' ) ) {
849
+                $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
850
+
851
+                /* Initialize the API */
852
+                if ( ! WP_Filesystem( $creds ) ) {
853
+                    /* Any problems and we exit */
854
+                    return false;
855
+                }
856
+
857
+                global $wp_filesystem;
858
+
859
+                return $wp_filesystem;
860
+            } else {
861
+                /* Don't have direct write access. Prompt user with our notice */
862
+                return false;
863
+            }
864
+        }
865
+
866
+        /**
867
+         * Download the fontawesome package file.
868
+         *
869
+         * @since 1.1.0
870
+         *
871
+         * @param mixed $version The font awesome.
872
+         * @param array $option Fontawesome settings.
873
+         * @return WP_ERROR|bool Error on fail and true on success.
874
+         */
875
+        public function download_package( $version, $option = array() ) {
876
+            $filename = 'fontawesome-free-' . $version . '-web';
877
+            $url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip';
878
+
879
+            if ( ! function_exists( 'wp_handle_upload' ) ) {
880
+                require_once ABSPATH . 'wp-admin/includes/file.php';
881
+            }
882
+
883
+            $download_file = download_url( esc_url_raw( $url ) );
884
+
885
+            if ( is_wp_error( $download_file ) ) {
886
+                return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'ayecode-connect' ) );
887
+            } else if ( empty( $download_file ) ) {
888
+                return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'ayecode-connect' ) );
889
+            }
890
+
891
+            $response = $this->extract_package( $download_file, $filename, true );
892
+
893
+            // Update local version.
894
+            if ( is_wp_error( $response ) ) {
895
+                return $response;
896
+            } else if ( $response ) {
897
+                if ( empty( $option ) ) {
898
+                    $option = get_option( 'wp-font-awesome-settings' );
899
+                }
900
+
901
+                $option['local_version'] = $version;
902
+
903
+                // Remove action to prevent looping.
904
+                remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
905
+
906
+                update_option( 'wp-font-awesome-settings', $option );
907
+
908
+                return true;
909
+            }
910
+
911
+            return false;
912
+        }
913
+
914
+        /**
915
+         * Extract the fontawesome package file.
916
+         *
917
+         * @since 1.1.0
918
+         *
919
+         * @param string $package The package file path.
920
+         * @param string $dirname Package file name.
921
+         * @param bool   $delete_package Delete temp file or not.
922
+         * @return WP_Error|bool True on success WP_Error on fail.
923
+         */
924
+        public function extract_package( $package, $dirname = '', $delete_package = false ) {
925
+            global $wp_filesystem;
926
+
927
+            $wp_filesystem = $this->get_wp_filesystem();
928
+
929
+            if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
930
+                return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'ayecode-connect' ) );
931
+            } else if ( empty( $wp_filesystem ) ) {
932
+                return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'ayecode-connect' ) );
933
+            }
934
+
935
+            $fonts_dir = $this->get_fonts_dir();
936
+            $fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
937
+
938
+            if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
939
+                $wp_filesystem->delete( $fonts_tmp_dir, true );
940
+            }
941
+
942
+            // Unzip package to working directory.
943
+            $result = unzip_file( $package, $fonts_tmp_dir );
944
+
945
+            if ( is_wp_error( $result ) ) {
946
+                $wp_filesystem->delete( $fonts_tmp_dir, true );
947
+
948
+                if ( 'incompatible_archive' === $result->get_error_code() ) {
949
+                    return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'ayecode-connect' ) );
950
+                }
951
+
952
+                return $result;
953
+            }
954
+
955
+            if ( $wp_filesystem->is_dir( $fonts_dir ) ) {
956
+                $wp_filesystem->delete( $fonts_dir, true );
957
+            }
958
+
959
+            $extract_dir = $fonts_tmp_dir;
960
+
961
+            if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) {
962
+                $extract_dir .= $dirname . DIRECTORY_SEPARATOR;
963
+            }
964
+
965
+            try {
966
+                $return = $wp_filesystem->move( $extract_dir, $fonts_dir, true );
967
+            } catch ( Exception $e ) {
968
+                $return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'ayecode-connect' ) );
969
+            }
970
+
971
+            if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
972
+                $wp_filesystem->delete( $fonts_tmp_dir, true );
973
+            }
974
+
975
+            // Once extracted, delete the package if required.
976
+            if ( $delete_package ) {
977
+                unlink( $package );
978
+            }
979
+
980
+            return $return;
981
+        }
982
+
983
+        /**
984
+         * Output the version in the header.
985
+         */
986
+        public function add_generator() {
987
+            $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
988
+            $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
989
+
990
+            // Find source plugin/theme.
991
+            $source = array();
992
+            if ( strpos( $file, $plugins_dir ) !== false ) {
993
+                $source = explode( "/", plugin_basename( $file ) );
994
+            } else if ( function_exists( 'get_theme_root' ) ) {
995
+                $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
996
+
997
+                if ( strpos( $file, $themes_dir ) !== false ) {
998
+                    $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
999
+                }
1000
+            }
1001
+
1002
+            echo '<meta name="generator" content="WP Font Awesome Settings v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-ac-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
1003
+        }
1004
+    }
1005
+
1006
+    /**
1007
+     * Run the class if found.
1008
+     */
1009
+    WP_Font_Awesome_Settings::instance();
1010 1010
 }
Please login to merge, or discard this patch.
vendor/ayecode/wp-deactivation-survey/wp-deactivation-survey.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -1,99 +1,99 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit;
4
+    exit;
5 5
 }
6 6
 
7 7
 if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
8 8
 
9
-	class AyeCode_Deactivation_Survey {
9
+    class AyeCode_Deactivation_Survey {
10 10
 
11
-		/**
12
-		 * AyeCode_Deactivation_Survey instance.
13
-		 *
14
-		 * @access private
15
-		 * @since  1.0.0
16
-		 * @var    AyeCode_Deactivation_Survey There can be only one!
17
-		 */
18
-		private static $instance = null;
11
+        /**
12
+         * AyeCode_Deactivation_Survey instance.
13
+         *
14
+         * @access private
15
+         * @since  1.0.0
16
+         * @var    AyeCode_Deactivation_Survey There can be only one!
17
+         */
18
+        private static $instance = null;
19 19
 
20
-		public static $plugins;
20
+        public static $plugins;
21 21
 
22
-		public $version = "1.0.7";
22
+        public $version = "1.0.7";
23 23
 
24
-		public static function instance( $plugin = array() ) {
25
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
-				self::$instance = new AyeCode_Deactivation_Survey;
27
-				self::$plugins = array();
24
+        public static function instance( $plugin = array() ) {
25
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
+                self::$instance = new AyeCode_Deactivation_Survey;
27
+                self::$plugins = array();
28 28
 
29
-				add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
29
+                add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
30 30
 
31
-				do_action( 'ayecode_deactivation_survey_loaded' );
32
-			}
31
+                do_action( 'ayecode_deactivation_survey_loaded' );
32
+            }
33 33
 
34
-			if(!empty($plugin)){
35
-				self::$plugins[] = (object)$plugin;
36
-			}
34
+            if(!empty($plugin)){
35
+                self::$plugins[] = (object)$plugin;
36
+            }
37 37
 
38
-			return self::$instance;
39
-		}
38
+            return self::$instance;
39
+        }
40 40
 
41
-		public function scripts() {
42
-			global $pagenow;
41
+        public function scripts() {
42
+            global $pagenow;
43 43
 
44
-			// Bail if we are not on the plugins page
45
-			if ( $pagenow != "plugins.php" ) {
46
-				return;
47
-			}
44
+            // Bail if we are not on the plugins page
45
+            if ( $pagenow != "plugins.php" ) {
46
+                return;
47
+            }
48 48
 
49
-			// Enqueue scripts
50
-			add_thickbox();
51
-			wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
49
+            // Enqueue scripts
50
+            add_thickbox();
51
+            wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
52 52
 
53
-			/*
53
+            /*
54 54
 			 * Localized strings. Strings can be localised by plugins using this class.
55 55
 			 * We deliberately don't add textdomains here so that double textdomain warning is not given in theme review.
56 56
 			 */
57
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
-				'quick_feedback'			=> __( 'Quick Feedback', 'ayecode-connect' ),
59
-				'foreword'					=> __( 'If you would be kind enough, please tell us why you\'re deactivating?', 'ayecode-connect' ),
60
-				'better_plugins_name'		=> __( 'Please tell us which plugin?', 'ayecode-connect' ),
61
-				'please_tell_us'			=> __( 'Please tell us the reason so we can improve the plugin', 'ayecode-connect' ),
62
-				'do_not_attach_email'		=> __( 'Do not send my e-mail address with this feedback', 'ayecode-connect' ),
63
-				'brief_description'			=> __( 'Please give us any feedback that could help us improve', 'ayecode-connect' ),
64
-				'cancel'					=> __( 'Cancel', 'ayecode-connect' ),
65
-				'skip_and_deactivate'		=> __( 'Skip &amp; Deactivate', 'ayecode-connect' ),
66
-				'submit_and_deactivate'		=> __( 'Submit &amp; Deactivate', 'ayecode-connect' ),
67
-				'please_wait'				=> __( 'Please wait', 'ayecode-connect' ),
68
-				'get_support'				=> __( 'Get Support', 'ayecode-connect' ),
69
-				'documentation'				=> __( 'Documentation', 'ayecode-connect' ),
70
-				'thank_you'					=> __( 'Thank you!', 'ayecode-connect' ),
71
-			));
72
-
73
-			// Plugins
74
-			$plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
-
76
-			// Reasons
77
-			$defaultReasons = array(
78
-				'suddenly-stopped-working'	=> __( 'The plugin suddenly stopped working', 'ayecode-connect' ),
79
-				'plugin-broke-site'			=> __( 'The plugin broke my site', 'ayecode-connect' ),
80
-				'plugin-setup-difficult'	=> __( 'Too difficult to setup', 'ayecode-connect' ),
81
-				'plugin-design-difficult'	=> __( 'Too difficult to get the design i want', 'ayecode-connect' ),
82
-				'no-longer-needed'			=> __( 'I don\'t need this plugin any more', 'ayecode-connect' ),
83
-				'found-better-plugin'		=> __( 'I found a better plugin', 'ayecode-connect' ),
84
-				'temporary-deactivation'	=> __( 'It\'s a temporary deactivation, I\'m troubleshooting', 'ayecode-connect' ),
85
-				'other'						=> __( 'Other', 'ayecode-connect' ),
86
-			);
87
-
88
-			foreach( $plugins as $plugin ) {
89
-				$plugin->reasons = apply_filters( 'ayecode_deactivation_survey_reasons', $defaultReasons, $plugin );
90
-				$plugin->url = home_url();
91
-				$plugin->activated = 0;
92
-			}
93
-
94
-			// Send plugin data
95
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
96
-		}
97
-	}
57
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
+                'quick_feedback'			=> __( 'Quick Feedback', 'ayecode-connect' ),
59
+                'foreword'					=> __( 'If you would be kind enough, please tell us why you\'re deactivating?', 'ayecode-connect' ),
60
+                'better_plugins_name'		=> __( 'Please tell us which plugin?', 'ayecode-connect' ),
61
+                'please_tell_us'			=> __( 'Please tell us the reason so we can improve the plugin', 'ayecode-connect' ),
62
+                'do_not_attach_email'		=> __( 'Do not send my e-mail address with this feedback', 'ayecode-connect' ),
63
+                'brief_description'			=> __( 'Please give us any feedback that could help us improve', 'ayecode-connect' ),
64
+                'cancel'					=> __( 'Cancel', 'ayecode-connect' ),
65
+                'skip_and_deactivate'		=> __( 'Skip &amp; Deactivate', 'ayecode-connect' ),
66
+                'submit_and_deactivate'		=> __( 'Submit &amp; Deactivate', 'ayecode-connect' ),
67
+                'please_wait'				=> __( 'Please wait', 'ayecode-connect' ),
68
+                'get_support'				=> __( 'Get Support', 'ayecode-connect' ),
69
+                'documentation'				=> __( 'Documentation', 'ayecode-connect' ),
70
+                'thank_you'					=> __( 'Thank you!', 'ayecode-connect' ),
71
+            ));
72
+
73
+            // Plugins
74
+            $plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
+
76
+            // Reasons
77
+            $defaultReasons = array(
78
+                'suddenly-stopped-working'	=> __( 'The plugin suddenly stopped working', 'ayecode-connect' ),
79
+                'plugin-broke-site'			=> __( 'The plugin broke my site', 'ayecode-connect' ),
80
+                'plugin-setup-difficult'	=> __( 'Too difficult to setup', 'ayecode-connect' ),
81
+                'plugin-design-difficult'	=> __( 'Too difficult to get the design i want', 'ayecode-connect' ),
82
+                'no-longer-needed'			=> __( 'I don\'t need this plugin any more', 'ayecode-connect' ),
83
+                'found-better-plugin'		=> __( 'I found a better plugin', 'ayecode-connect' ),
84
+                'temporary-deactivation'	=> __( 'It\'s a temporary deactivation, I\'m troubleshooting', 'ayecode-connect' ),
85
+                'other'						=> __( 'Other', 'ayecode-connect' ),
86
+            );
87
+
88
+            foreach( $plugins as $plugin ) {
89
+                $plugin->reasons = apply_filters( 'ayecode_deactivation_survey_reasons', $defaultReasons, $plugin );
90
+                $plugin->url = home_url();
91
+                $plugin->activated = 0;
92
+            }
93
+
94
+            // Send plugin data
95
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
96
+        }
97
+    }
98 98
 
99 99
 }
100 100
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/hello-world.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -3,102 +3,102 @@  discard block
 block discarded – undo
3 3
 class SD_Hello_World extends WP_Super_Duper {
4 4
 
5 5
 
6
-	public $arguments;
7
-
8
-	/**
9
-	 * Sets up the widgets name etc
10
-	 */
11
-	public function __construct() {
12
-
13
-		$options = array(
14
-			'textdomain'     => 'super-duper',
15
-			// textdomain of the plugin/theme (used to prefix the Gutenberg block)
16
-			'block-icon'     => 'fas fa-globe-americas',
17
-			// Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right
18
-			// OR font-awesome 5 class name: fas fa-globe-americas
19
-			'block-category' => 'widgets',
20
-			// the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'.
21
-			'block-keywords' => "['hello','world']",
22
-			// used in the block search, MAX 3
23
-			'block-output'   => array( // the block visual output elements as an array
24
-				array(
25
-					'element' => 'p',
26
-					'title'   => __( 'Placeholder', 'ayecode-connect' ),
27
-					'class'   => '[%className%]',
28
-					'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
29
-				)
30
-			),
31
-			'block-wrap'    => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all.
32
-			'class_name'     => __CLASS__,
33
-			// The calling class name
34
-			'base_id'        => 'hello_world',
35
-			// this is used as the widget id and the shortcode id.
36
-			'name'           => __( 'Hello World', 'ayecode-connect' ),
37
-			// the name of the widget/block
38
-			'widget_ops'     => array(
39
-				'classname'   => 'hello-world-class',
40
-				// widget class
41
-				'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ),
42
-				// widget description
43
-			),
44
-			'no_wrap'       => true, // This will prevent the widget being wrapped in the containing widget class div.
45
-			'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
46
-				'after_text' => array( // this is the input name=''
47
-					'title'       => __( 'Text after hello:', 'ayecode-connect' ),
48
-					// input title
49
-					'desc'        => __( 'This is the text that will appear after `Hello:`.', 'ayecode-connect' ),
50
-					// input description
51
-					'type'        => 'text',
52
-					// the type of input, test, select, checkbox etc.
53
-					'placeholder' => 'World',
54
-					// the input placeholder text.
55
-					'desc_tip'    => true,
56
-					// if the input should show the widget description text as a tooltip.
57
-					'default'     => 'World',
58
-					// the input default value.
59
-					'advanced'    => false
60
-					// not yet implemented
61
-				),
62
-			)
63
-		);
64
-
65
-		parent::__construct( $options );
66
-	}
67
-
68
-
69
-	/**
70
-	 * This is the output function for the widget, shortcode and block (front end).
71
-	 *
72
-	 * @param array $args The arguments values.
73
-	 * @param array $widget_args The widget arguments when used.
74
-	 * @param string $content The shortcode content argument
75
-	 *
76
-	 * @return string
77
-	 */
78
-	public function output( $args = array(), $widget_args = array(), $content = '' ) {
79
-
80
-		/**
81
-		 * @var string $after_text
82
-		 * @var string $another_input This is added by filter below.
83
-		 */
84
-		extract( $args, EXTR_SKIP );
85
-
86
-		/*
6
+    public $arguments;
7
+
8
+    /**
9
+     * Sets up the widgets name etc
10
+     */
11
+    public function __construct() {
12
+
13
+        $options = array(
14
+            'textdomain'     => 'super-duper',
15
+            // textdomain of the plugin/theme (used to prefix the Gutenberg block)
16
+            'block-icon'     => 'fas fa-globe-americas',
17
+            // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right
18
+            // OR font-awesome 5 class name: fas fa-globe-americas
19
+            'block-category' => 'widgets',
20
+            // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'.
21
+            'block-keywords' => "['hello','world']",
22
+            // used in the block search, MAX 3
23
+            'block-output'   => array( // the block visual output elements as an array
24
+                array(
25
+                    'element' => 'p',
26
+                    'title'   => __( 'Placeholder', 'ayecode-connect' ),
27
+                    'class'   => '[%className%]',
28
+                    'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
29
+                )
30
+            ),
31
+            'block-wrap'    => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all.
32
+            'class_name'     => __CLASS__,
33
+            // The calling class name
34
+            'base_id'        => 'hello_world',
35
+            // this is used as the widget id and the shortcode id.
36
+            'name'           => __( 'Hello World', 'ayecode-connect' ),
37
+            // the name of the widget/block
38
+            'widget_ops'     => array(
39
+                'classname'   => 'hello-world-class',
40
+                // widget class
41
+                'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ),
42
+                // widget description
43
+            ),
44
+            'no_wrap'       => true, // This will prevent the widget being wrapped in the containing widget class div.
45
+            'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
46
+                'after_text' => array( // this is the input name=''
47
+                    'title'       => __( 'Text after hello:', 'ayecode-connect' ),
48
+                    // input title
49
+                    'desc'        => __( 'This is the text that will appear after `Hello:`.', 'ayecode-connect' ),
50
+                    // input description
51
+                    'type'        => 'text',
52
+                    // the type of input, test, select, checkbox etc.
53
+                    'placeholder' => 'World',
54
+                    // the input placeholder text.
55
+                    'desc_tip'    => true,
56
+                    // if the input should show the widget description text as a tooltip.
57
+                    'default'     => 'World',
58
+                    // the input default value.
59
+                    'advanced'    => false
60
+                    // not yet implemented
61
+                ),
62
+            )
63
+        );
64
+
65
+        parent::__construct( $options );
66
+    }
67
+
68
+
69
+    /**
70
+     * This is the output function for the widget, shortcode and block (front end).
71
+     *
72
+     * @param array $args The arguments values.
73
+     * @param array $widget_args The widget arguments when used.
74
+     * @param string $content The shortcode content argument
75
+     *
76
+     * @return string
77
+     */
78
+    public function output( $args = array(), $widget_args = array(), $content = '' ) {
79
+
80
+        /**
81
+         * @var string $after_text
82
+         * @var string $another_input This is added by filter below.
83
+         */
84
+        extract( $args, EXTR_SKIP );
85
+
86
+        /*
87 87
 		 * This value is added by filter so might not exist if filter is removed so we check.
88 88
 		 */
89
-		if ( ! isset( $another_input ) ) {
90
-			$another_input = '';
91
-		}
89
+        if ( ! isset( $another_input ) ) {
90
+            $another_input = '';
91
+        }
92 92
 
93
-		return "Hello: " . $after_text . "" . $another_input;
93
+        return "Hello: " . $after_text . "" . $another_input;
94 94
 
95
-	}
95
+    }
96 96
 
97 97
 }
98 98
 
99 99
 // register it.
100 100
 add_action( 'widgets_init', function () {
101
-	register_widget( 'SD_Hello_World' );
101
+    register_widget( 'SD_Hello_World' );
102 102
 } );
103 103
 
104 104
 
@@ -111,26 +111,26 @@  discard block
 block discarded – undo
111 111
  */
112 112
 function _my_extra_arguments( $options ) {
113 113
 
114
-	/*
114
+    /*
115 115
 	 * Add a new input option.
116 116
 	 */
117
-	$options['arguments']['another_input'] = array(
118
-		'name'        => 'another_input', // this is the input name=''
119
-		'title'       => __( 'Another input:', 'ayecode-connect' ), // input title
120
-		'desc'        => __( 'This is an input added via filter.', 'ayecode-connect' ), // input description
121
-		'type'        => 'text', // the type of input, test, select, checkbox etc.
122
-		'placeholder' => 'Placeholder text', // the input placeholder text.
123
-		'desc_tip'    => true, // if the input should show the widget description text as a tooltip.
124
-		'default'     => '', // the input default value.
125
-		'advanced'    => false // not yet implemented
126
-	);
127
-
128
-	/*
117
+    $options['arguments']['another_input'] = array(
118
+        'name'        => 'another_input', // this is the input name=''
119
+        'title'       => __( 'Another input:', 'ayecode-connect' ), // input title
120
+        'desc'        => __( 'This is an input added via filter.', 'ayecode-connect' ), // input description
121
+        'type'        => 'text', // the type of input, test, select, checkbox etc.
122
+        'placeholder' => 'Placeholder text', // the input placeholder text.
123
+        'desc_tip'    => true, // if the input should show the widget description text as a tooltip.
124
+        'default'     => '', // the input default value.
125
+        'advanced'    => false // not yet implemented
126
+    );
127
+
128
+    /*
129 129
 	 * Output the new option in the block output also.
130 130
 	 */
131
-	$options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";;
131
+    $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";;
132 132
 
133
-	return $options;
133
+    return $options;
134 134
 }
135 135
 
136 136
 //add_filter( 'wp_super_duper_options_hello_world', '_my_extra_arguments' );
137 137
\ No newline at end of file
Please login to merge, or discard this patch.