@@ -1,7 +1,7 @@ discard block |
||
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,1031 +11,1031 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class AUI_Component_Input { |
13 | 13 | |
14 | - /** |
|
15 | - * Build the component. |
|
16 | - * |
|
17 | - * @param array $args |
|
18 | - * |
|
19 | - * @return string The rendered component. |
|
20 | - */ |
|
21 | - public static function input($args = array()){ |
|
22 | - $defaults = array( |
|
23 | - 'type' => 'text', |
|
24 | - 'name' => '', |
|
25 | - 'class' => '', |
|
26 | - 'wrap_class' => '', |
|
27 | - 'id' => '', |
|
28 | - 'placeholder'=> '', |
|
29 | - 'title' => '', |
|
30 | - 'value' => '', |
|
31 | - 'required' => false, |
|
32 | - 'label' => '', |
|
33 | - 'label_after'=> false, |
|
34 | - 'label_class'=> '', |
|
35 | - 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
36 | - 'help_text' => '', |
|
37 | - 'validation_text' => '', |
|
38 | - 'validation_pattern' => '', |
|
39 | - 'no_wrap' => false, |
|
40 | - 'input_group_right' => '', |
|
41 | - 'input_group_left' => '', |
|
42 | - 'input_group_right_inside' => false, // forces the input group inside the input |
|
43 | - 'input_group_left_inside' => false, // forces the input group inside the input |
|
44 | - 'step' => '', |
|
45 | - 'switch' => false, // to show checkbox as a switch |
|
46 | - 'checked' => false, // set a checkbox or radio as selected |
|
47 | - 'password_toggle' => true, // toggle view/hide password |
|
48 | - 'element_require' => '', // [%element_id%] == "1" |
|
49 | - 'extra_attributes' => array() // an array of extra attributes |
|
50 | - ); |
|
51 | - |
|
52 | - /** |
|
53 | - * Parse incoming $args into an array and merge it with $defaults |
|
54 | - */ |
|
55 | - $args = wp_parse_args( $args, $defaults ); |
|
56 | - $output = ''; |
|
57 | - if ( ! empty( $args['type'] ) ) { |
|
58 | - // hidden label option needs to be empty |
|
59 | - $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
60 | - |
|
61 | - $type = sanitize_html_class( $args['type'] ); |
|
62 | - |
|
63 | - $help_text = ''; |
|
64 | - $label = ''; |
|
65 | - $label_after = $args['label_after']; |
|
66 | - $label_args = array( |
|
67 | - 'title'=> $args['label'], |
|
68 | - 'for'=> $args['id'], |
|
69 | - 'class' => $args['label_class']." ", |
|
70 | - 'label_type' => $args['label_type'] |
|
71 | - ); |
|
72 | - |
|
73 | - // floating labels need label after |
|
74 | - if( $args['label_type'] == 'floating' && $type != 'checkbox' ){ |
|
75 | - $label_after = true; |
|
76 | - $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
77 | - } |
|
78 | - |
|
79 | - // Some special sauce for files |
|
80 | - if($type=='file' ){ |
|
81 | - $label_after = true; // if type file we need the label after |
|
82 | - $args['class'] .= ' custom-file-input '; |
|
83 | - }elseif($type=='checkbox'){ |
|
84 | - $label_after = true; // if type file we need the label after |
|
85 | - $args['class'] .= ' custom-control-input '; |
|
86 | - }elseif($type=='datepicker' || $type=='timepicker'){ |
|
87 | - $type = 'text'; |
|
88 | - //$args['class'] .= ' aui-flatpickr bg-initial '; |
|
89 | - $args['class'] .= ' bg-initial '; |
|
90 | - |
|
91 | - $args['extra_attributes']['data-aui-init'] = 'flatpickr'; |
|
92 | - // enqueue the script |
|
93 | - $aui_settings = AyeCode_UI_Settings::instance(); |
|
94 | - $aui_settings->enqueue_flatpickr(); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - // open/type |
|
99 | - $output .= '<input type="' . $type . '" '; |
|
100 | - |
|
101 | - // name |
|
102 | - if(!empty($args['name'])){ |
|
103 | - $output .= ' name="'.esc_attr($args['name']).'" '; |
|
104 | - } |
|
105 | - |
|
106 | - // id |
|
107 | - if(!empty($args['id'])){ |
|
108 | - $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
109 | - } |
|
110 | - |
|
111 | - // placeholder |
|
112 | - if(isset($args['placeholder']) && '' != $args['placeholder'] ){ |
|
113 | - $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
114 | - } |
|
115 | - |
|
116 | - // title |
|
117 | - if(!empty($args['title'])){ |
|
118 | - $output .= ' title="'.esc_attr($args['title']).'" '; |
|
119 | - } |
|
120 | - |
|
121 | - // value |
|
122 | - if(!empty($args['value'])){ |
|
123 | - $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
124 | - } |
|
125 | - |
|
126 | - // checked, for radio and checkboxes |
|
127 | - if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){ |
|
128 | - $output .= ' checked '; |
|
129 | - } |
|
130 | - |
|
131 | - // validation text |
|
132 | - if(!empty($args['validation_text'])){ |
|
133 | - $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
134 | - $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
135 | - } |
|
136 | - |
|
137 | - // validation_pattern |
|
138 | - if(!empty($args['validation_pattern'])){ |
|
139 | - $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
140 | - } |
|
141 | - |
|
142 | - // step (for numbers) |
|
143 | - if(!empty($args['step'])){ |
|
144 | - $output .= ' step="'.$args['step'].'" '; |
|
145 | - } |
|
146 | - |
|
147 | - // required |
|
148 | - if(!empty($args['required'])){ |
|
149 | - $output .= ' required '; |
|
150 | - } |
|
151 | - |
|
152 | - // class |
|
153 | - $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
154 | - $output .= ' class="form-control '.$class.'" '; |
|
155 | - |
|
156 | - // data-attributes |
|
157 | - $output .= AUI_Component_Helper::data_attributes($args); |
|
158 | - |
|
159 | - // extra attributes |
|
160 | - if(!empty($args['extra_attributes'])){ |
|
161 | - $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
162 | - } |
|
163 | - |
|
164 | - // close |
|
165 | - $output .= ' >'; |
|
166 | - |
|
167 | - |
|
168 | - // label |
|
169 | - if(!empty($args['label'])){ |
|
170 | - if($type == 'file'){$label_args['class'] .= 'custom-file-label';} |
|
171 | - elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';} |
|
172 | - $label = self::label( $label_args, $type ); |
|
173 | - } |
|
174 | - |
|
175 | - // help text |
|
176 | - if(!empty($args['help_text'])){ |
|
177 | - $help_text = AUI_Component_Helper::help_text($args['help_text']); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - // set help text in the correct possition |
|
182 | - if($label_after){ |
|
183 | - $output .= $label . $help_text; |
|
184 | - } |
|
185 | - |
|
186 | - // some input types need a separate wrap |
|
187 | - if($type == 'file') { |
|
188 | - $output = self::wrap( array( |
|
189 | - 'content' => $output, |
|
190 | - 'class' => 'form-group custom-file' |
|
191 | - ) ); |
|
192 | - }elseif($type == 'checkbox'){ |
|
193 | - $wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox'; |
|
194 | - $output = self::wrap( array( |
|
195 | - 'content' => $output, |
|
196 | - 'class' => 'custom-control '.$wrap_class |
|
197 | - ) ); |
|
198 | - |
|
199 | - if($args['label_type']=='horizontal'){ |
|
200 | - $output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>'; |
|
201 | - } |
|
202 | - }elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){ |
|
203 | - |
|
204 | - |
|
205 | - // allow password field to toggle view |
|
206 | - $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" |
|
14 | + /** |
|
15 | + * Build the component. |
|
16 | + * |
|
17 | + * @param array $args |
|
18 | + * |
|
19 | + * @return string The rendered component. |
|
20 | + */ |
|
21 | + public static function input($args = array()){ |
|
22 | + $defaults = array( |
|
23 | + 'type' => 'text', |
|
24 | + 'name' => '', |
|
25 | + 'class' => '', |
|
26 | + 'wrap_class' => '', |
|
27 | + 'id' => '', |
|
28 | + 'placeholder'=> '', |
|
29 | + 'title' => '', |
|
30 | + 'value' => '', |
|
31 | + 'required' => false, |
|
32 | + 'label' => '', |
|
33 | + 'label_after'=> false, |
|
34 | + 'label_class'=> '', |
|
35 | + 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
36 | + 'help_text' => '', |
|
37 | + 'validation_text' => '', |
|
38 | + 'validation_pattern' => '', |
|
39 | + 'no_wrap' => false, |
|
40 | + 'input_group_right' => '', |
|
41 | + 'input_group_left' => '', |
|
42 | + 'input_group_right_inside' => false, // forces the input group inside the input |
|
43 | + 'input_group_left_inside' => false, // forces the input group inside the input |
|
44 | + 'step' => '', |
|
45 | + 'switch' => false, // to show checkbox as a switch |
|
46 | + 'checked' => false, // set a checkbox or radio as selected |
|
47 | + 'password_toggle' => true, // toggle view/hide password |
|
48 | + 'element_require' => '', // [%element_id%] == "1" |
|
49 | + 'extra_attributes' => array() // an array of extra attributes |
|
50 | + ); |
|
51 | + |
|
52 | + /** |
|
53 | + * Parse incoming $args into an array and merge it with $defaults |
|
54 | + */ |
|
55 | + $args = wp_parse_args( $args, $defaults ); |
|
56 | + $output = ''; |
|
57 | + if ( ! empty( $args['type'] ) ) { |
|
58 | + // hidden label option needs to be empty |
|
59 | + $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
60 | + |
|
61 | + $type = sanitize_html_class( $args['type'] ); |
|
62 | + |
|
63 | + $help_text = ''; |
|
64 | + $label = ''; |
|
65 | + $label_after = $args['label_after']; |
|
66 | + $label_args = array( |
|
67 | + 'title'=> $args['label'], |
|
68 | + 'for'=> $args['id'], |
|
69 | + 'class' => $args['label_class']." ", |
|
70 | + 'label_type' => $args['label_type'] |
|
71 | + ); |
|
72 | + |
|
73 | + // floating labels need label after |
|
74 | + if( $args['label_type'] == 'floating' && $type != 'checkbox' ){ |
|
75 | + $label_after = true; |
|
76 | + $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
77 | + } |
|
78 | + |
|
79 | + // Some special sauce for files |
|
80 | + if($type=='file' ){ |
|
81 | + $label_after = true; // if type file we need the label after |
|
82 | + $args['class'] .= ' custom-file-input '; |
|
83 | + }elseif($type=='checkbox'){ |
|
84 | + $label_after = true; // if type file we need the label after |
|
85 | + $args['class'] .= ' custom-control-input '; |
|
86 | + }elseif($type=='datepicker' || $type=='timepicker'){ |
|
87 | + $type = 'text'; |
|
88 | + //$args['class'] .= ' aui-flatpickr bg-initial '; |
|
89 | + $args['class'] .= ' bg-initial '; |
|
90 | + |
|
91 | + $args['extra_attributes']['data-aui-init'] = 'flatpickr'; |
|
92 | + // enqueue the script |
|
93 | + $aui_settings = AyeCode_UI_Settings::instance(); |
|
94 | + $aui_settings->enqueue_flatpickr(); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + // open/type |
|
99 | + $output .= '<input type="' . $type . '" '; |
|
100 | + |
|
101 | + // name |
|
102 | + if(!empty($args['name'])){ |
|
103 | + $output .= ' name="'.esc_attr($args['name']).'" '; |
|
104 | + } |
|
105 | + |
|
106 | + // id |
|
107 | + if(!empty($args['id'])){ |
|
108 | + $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
109 | + } |
|
110 | + |
|
111 | + // placeholder |
|
112 | + if(isset($args['placeholder']) && '' != $args['placeholder'] ){ |
|
113 | + $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
114 | + } |
|
115 | + |
|
116 | + // title |
|
117 | + if(!empty($args['title'])){ |
|
118 | + $output .= ' title="'.esc_attr($args['title']).'" '; |
|
119 | + } |
|
120 | + |
|
121 | + // value |
|
122 | + if(!empty($args['value'])){ |
|
123 | + $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
124 | + } |
|
125 | + |
|
126 | + // checked, for radio and checkboxes |
|
127 | + if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){ |
|
128 | + $output .= ' checked '; |
|
129 | + } |
|
130 | + |
|
131 | + // validation text |
|
132 | + if(!empty($args['validation_text'])){ |
|
133 | + $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
134 | + $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
135 | + } |
|
136 | + |
|
137 | + // validation_pattern |
|
138 | + if(!empty($args['validation_pattern'])){ |
|
139 | + $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
140 | + } |
|
141 | + |
|
142 | + // step (for numbers) |
|
143 | + if(!empty($args['step'])){ |
|
144 | + $output .= ' step="'.$args['step'].'" '; |
|
145 | + } |
|
146 | + |
|
147 | + // required |
|
148 | + if(!empty($args['required'])){ |
|
149 | + $output .= ' required '; |
|
150 | + } |
|
151 | + |
|
152 | + // class |
|
153 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
154 | + $output .= ' class="form-control '.$class.'" '; |
|
155 | + |
|
156 | + // data-attributes |
|
157 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
158 | + |
|
159 | + // extra attributes |
|
160 | + if(!empty($args['extra_attributes'])){ |
|
161 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
162 | + } |
|
163 | + |
|
164 | + // close |
|
165 | + $output .= ' >'; |
|
166 | + |
|
167 | + |
|
168 | + // label |
|
169 | + if(!empty($args['label'])){ |
|
170 | + if($type == 'file'){$label_args['class'] .= 'custom-file-label';} |
|
171 | + elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';} |
|
172 | + $label = self::label( $label_args, $type ); |
|
173 | + } |
|
174 | + |
|
175 | + // help text |
|
176 | + if(!empty($args['help_text'])){ |
|
177 | + $help_text = AUI_Component_Helper::help_text($args['help_text']); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + // set help text in the correct possition |
|
182 | + if($label_after){ |
|
183 | + $output .= $label . $help_text; |
|
184 | + } |
|
185 | + |
|
186 | + // some input types need a separate wrap |
|
187 | + if($type == 'file') { |
|
188 | + $output = self::wrap( array( |
|
189 | + 'content' => $output, |
|
190 | + 'class' => 'form-group custom-file' |
|
191 | + ) ); |
|
192 | + }elseif($type == 'checkbox'){ |
|
193 | + $wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox'; |
|
194 | + $output = self::wrap( array( |
|
195 | + 'content' => $output, |
|
196 | + 'class' => 'custom-control '.$wrap_class |
|
197 | + ) ); |
|
198 | + |
|
199 | + if($args['label_type']=='horizontal'){ |
|
200 | + $output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>'; |
|
201 | + } |
|
202 | + }elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){ |
|
203 | + |
|
204 | + |
|
205 | + // allow password field to toggle view |
|
206 | + $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" |
|
207 | 207 | onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\'); |
208 | 208 | var $eli = jQuery(this).parent().parent().find(\'input\'); |
209 | 209 | if($el.hasClass(\'fa-eye\')) |
210 | 210 | {$eli.attr(\'type\',\'text\');} |
211 | 211 | else{$eli.attr(\'type\',\'password\');}" |
212 | 212 | ><i class="far fa-fw fa-eye-slash"></i></span>'; |
213 | - } |
|
214 | - |
|
215 | - // input group wraps |
|
216 | - if($args['input_group_left'] || $args['input_group_right']){ |
|
217 | - $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
218 | - if($args['input_group_left']){ |
|
219 | - $output = self::wrap( array( |
|
220 | - 'content' => $output, |
|
221 | - 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
222 | - 'input_group_left' => $args['input_group_left'], |
|
223 | - 'input_group_left_inside' => $args['input_group_left_inside'] |
|
224 | - ) ); |
|
225 | - } |
|
226 | - if($args['input_group_right']){ |
|
227 | - $output = self::wrap( array( |
|
228 | - 'content' => $output, |
|
229 | - 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
230 | - 'input_group_right' => $args['input_group_right'], |
|
231 | - 'input_group_right_inside' => $args['input_group_right_inside'] |
|
232 | - ) ); |
|
233 | - } |
|
234 | - |
|
235 | - } |
|
236 | - |
|
237 | - if(!$label_after){ |
|
238 | - $output .= $help_text; |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
243 | - $output = self::wrap( array( |
|
244 | - 'content' => $output, |
|
245 | - 'class' => 'col-sm-10', |
|
246 | - ) ); |
|
247 | - } |
|
248 | - |
|
249 | - if(!$label_after){ |
|
250 | - $output = $label . $output; |
|
251 | - } |
|
252 | - |
|
253 | - // wrap |
|
254 | - if(!$args['no_wrap']){ |
|
255 | - |
|
256 | - $form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
|
257 | - $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
258 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
259 | - $output = self::wrap(array( |
|
260 | - 'content' => $output, |
|
261 | - 'class' => $wrap_class, |
|
262 | - 'element_require' => $args['element_require'], |
|
263 | - 'argument_id' => $args['id'] |
|
264 | - )); |
|
265 | - } |
|
266 | - |
|
267 | - |
|
268 | - |
|
269 | - } |
|
270 | - |
|
271 | - return $output; |
|
272 | - } |
|
273 | - |
|
274 | - /** |
|
275 | - * Build the component. |
|
276 | - * |
|
277 | - * @param array $args |
|
278 | - * |
|
279 | - * @return string The rendered component. |
|
280 | - */ |
|
281 | - public static function textarea($args = array()){ |
|
282 | - $defaults = array( |
|
283 | - 'name' => '', |
|
284 | - 'class' => '', |
|
285 | - 'wrap_class' => '', |
|
286 | - 'id' => '', |
|
287 | - 'placeholder'=> '', |
|
288 | - 'title' => '', |
|
289 | - 'value' => '', |
|
290 | - 'required' => false, |
|
291 | - 'label' => '', |
|
292 | - 'label_after'=> false, |
|
293 | - 'label_class' => '', |
|
294 | - 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
295 | - 'help_text' => '', |
|
296 | - 'validation_text' => '', |
|
297 | - 'validation_pattern' => '', |
|
298 | - 'no_wrap' => false, |
|
299 | - 'rows' => '', |
|
300 | - 'wysiwyg' => false, |
|
301 | - 'allow_tags' => false, // Allow HTML tags |
|
302 | - 'element_require' => '', // [%element_id%] == "1" |
|
303 | - 'extra_attributes' => array(), // an array of extra attributes |
|
304 | - ); |
|
305 | - |
|
306 | - /** |
|
307 | - * Parse incoming $args into an array and merge it with $defaults |
|
308 | - */ |
|
309 | - $args = wp_parse_args( $args, $defaults ); |
|
310 | - $output = ''; |
|
311 | - |
|
312 | - // hidden label option needs to be empty |
|
313 | - $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
314 | - |
|
315 | - // floating labels don't work with wysiwyg so set it as top |
|
316 | - if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){ |
|
317 | - $args['label_type'] = 'top'; |
|
318 | - } |
|
319 | - |
|
320 | - $label_after = $args['label_after']; |
|
321 | - |
|
322 | - // floating labels need label after |
|
323 | - if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){ |
|
324 | - $label_after = true; |
|
325 | - $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
326 | - } |
|
327 | - |
|
328 | - // label |
|
329 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
330 | - }elseif(!empty($args['label']) && !$label_after){ |
|
331 | - $label_args = array( |
|
332 | - 'title'=> $args['label'], |
|
333 | - 'for'=> $args['id'], |
|
334 | - 'class' => $args['label_class']." ", |
|
335 | - 'label_type' => $args['label_type'] |
|
336 | - ); |
|
337 | - $output .= self::label( $label_args ); |
|
338 | - } |
|
339 | - |
|
340 | - // maybe horizontal label |
|
341 | - if($args['label_type']=='horizontal'){ |
|
342 | - $output .= '<div class="col-sm-10">'; |
|
343 | - } |
|
344 | - |
|
345 | - if(!empty($args['wysiwyg'])){ |
|
346 | - ob_start(); |
|
347 | - $content = $args['value']; |
|
348 | - $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor'; |
|
349 | - $settings = array( |
|
350 | - 'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4, |
|
351 | - 'quicktags' => false, |
|
352 | - 'media_buttons' => false, |
|
353 | - 'editor_class' => 'form-control', |
|
354 | - 'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']), |
|
355 | - 'teeny' => true, |
|
356 | - ); |
|
357 | - |
|
358 | - // maybe set settings if array |
|
359 | - if(is_array($args['wysiwyg'])){ |
|
360 | - $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
361 | - } |
|
362 | - |
|
363 | - wp_editor( $content, $editor_id, $settings ); |
|
364 | - $output .= ob_get_clean(); |
|
365 | - }else{ |
|
366 | - |
|
367 | - // open |
|
368 | - $output .= '<textarea '; |
|
369 | - |
|
370 | - // name |
|
371 | - if(!empty($args['name'])){ |
|
372 | - $output .= ' name="'.sanitize_html_class($args['name']).'" '; |
|
373 | - } |
|
374 | - |
|
375 | - // id |
|
376 | - if(!empty($args['id'])){ |
|
377 | - $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
378 | - } |
|
379 | - |
|
380 | - // placeholder |
|
381 | - if(isset($args['placeholder']) && '' != $args['placeholder']){ |
|
382 | - $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
383 | - } |
|
384 | - |
|
385 | - // title |
|
386 | - if(!empty($args['title'])){ |
|
387 | - $output .= ' title="'.esc_attr($args['title']).'" '; |
|
388 | - } |
|
389 | - |
|
390 | - // validation text |
|
391 | - if(!empty($args['validation_text'])){ |
|
392 | - $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
393 | - $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
394 | - } |
|
395 | - |
|
396 | - // validation_pattern |
|
397 | - if(!empty($args['validation_pattern'])){ |
|
398 | - $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
399 | - } |
|
400 | - |
|
401 | - // required |
|
402 | - if(!empty($args['required'])){ |
|
403 | - $output .= ' required '; |
|
404 | - } |
|
405 | - |
|
406 | - // rows |
|
407 | - if(!empty($args['rows'])){ |
|
408 | - $output .= ' rows="'.absint($args['rows']).'" '; |
|
409 | - } |
|
410 | - |
|
411 | - |
|
412 | - // class |
|
413 | - $class = !empty($args['class']) ? $args['class'] : ''; |
|
414 | - $output .= ' class="form-control '.$class.'" '; |
|
415 | - |
|
416 | - // extra attributes |
|
417 | - if(!empty($args['extra_attributes'])){ |
|
418 | - $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
419 | - } |
|
420 | - |
|
421 | - // close tag |
|
422 | - $output .= ' >'; |
|
423 | - |
|
424 | - // value |
|
425 | - if ( ! empty( $args['value'] ) ) { |
|
426 | - if ( ! empty( $args['allow_tags'] ) ) { |
|
427 | - $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
428 | - } else { |
|
429 | - $output .= sanitize_textarea_field( $args['value'] ); |
|
430 | - } |
|
431 | - } |
|
432 | - |
|
433 | - // closing tag |
|
434 | - $output .= '</textarea>'; |
|
435 | - |
|
436 | - } |
|
437 | - |
|
438 | - if(!empty($args['label']) && $label_after){ |
|
439 | - $label_args = array( |
|
440 | - 'title'=> $args['label'], |
|
441 | - 'for'=> $args['id'], |
|
442 | - 'class' => $args['label_class']." ", |
|
443 | - 'label_type' => $args['label_type'] |
|
444 | - ); |
|
445 | - $output .= self::label( $label_args ); |
|
446 | - } |
|
447 | - |
|
448 | - // help text |
|
449 | - if(!empty($args['help_text'])){ |
|
450 | - $output .= AUI_Component_Helper::help_text($args['help_text']); |
|
451 | - } |
|
452 | - |
|
453 | - // maybe horizontal label |
|
454 | - if($args['label_type']=='horizontal'){ |
|
455 | - $output .= '</div>'; |
|
456 | - } |
|
457 | - |
|
458 | - |
|
459 | - // wrap |
|
460 | - if(!$args['no_wrap']){ |
|
461 | - $form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group'; |
|
462 | - $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
463 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
464 | - $output = self::wrap(array( |
|
465 | - 'content' => $output, |
|
466 | - 'class' => $wrap_class, |
|
467 | - 'element_require' => $args['element_require'], |
|
468 | - 'argument_id' => $args['id'] |
|
469 | - )); |
|
470 | - } |
|
471 | - |
|
472 | - |
|
473 | - return $output; |
|
474 | - } |
|
475 | - |
|
476 | - public static function label($args = array(), $type = ''){ |
|
477 | - //<label for="exampleInputEmail1">Email address</label> |
|
478 | - $defaults = array( |
|
479 | - 'title' => 'div', |
|
480 | - 'for' => '', |
|
481 | - 'class' => '', |
|
482 | - 'label_type' => '', // empty = hidden, top, horizontal |
|
483 | - ); |
|
484 | - |
|
485 | - /** |
|
486 | - * Parse incoming $args into an array and merge it with $defaults |
|
487 | - */ |
|
488 | - $args = wp_parse_args( $args, $defaults ); |
|
489 | - $output = ''; |
|
490 | - |
|
491 | - if($args['title']){ |
|
492 | - |
|
493 | - // maybe hide labels //@todo set a global option for visibility class |
|
494 | - if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){ |
|
495 | - $class = $args['class']; |
|
496 | - }else{ |
|
497 | - $class = 'sr-only '.$args['class']; |
|
498 | - } |
|
499 | - |
|
500 | - // maybe horizontal |
|
501 | - if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
502 | - $class .= ' col-sm-2 col-form-label'; |
|
503 | - } |
|
504 | - |
|
505 | - // open |
|
506 | - $output .= '<label '; |
|
507 | - |
|
508 | - // for |
|
509 | - if(!empty($args['for'])){ |
|
510 | - $output .= ' for="'.sanitize_text_field($args['for']).'" '; |
|
511 | - } |
|
512 | - |
|
513 | - // class |
|
514 | - $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
515 | - $output .= ' class="'.$class.'" '; |
|
516 | - |
|
517 | - // close |
|
518 | - $output .= '>'; |
|
519 | - |
|
520 | - |
|
521 | - // title, don't escape fully as can contain html |
|
522 | - if(!empty($args['title'])){ |
|
523 | - $output .= wp_kses_post($args['title']); |
|
524 | - } |
|
525 | - |
|
526 | - // close wrap |
|
527 | - $output .= '</label>'; |
|
528 | - |
|
529 | - |
|
530 | - } |
|
531 | - |
|
532 | - |
|
533 | - return $output; |
|
534 | - } |
|
535 | - |
|
536 | - /** |
|
537 | - * Wrap some content in a HTML wrapper. |
|
538 | - * |
|
539 | - * @param array $args |
|
540 | - * |
|
541 | - * @return string |
|
542 | - */ |
|
543 | - public static function wrap($args = array()){ |
|
544 | - $defaults = array( |
|
545 | - 'type' => 'div', |
|
546 | - 'class' => 'form-group', |
|
547 | - 'content' => '', |
|
548 | - 'input_group_left' => '', |
|
549 | - 'input_group_right' => '', |
|
550 | - 'input_group_left_inside' => false, |
|
551 | - 'input_group_right_inside' => false, |
|
552 | - 'element_require' => '', |
|
553 | - 'argument_id' => '', |
|
554 | - ); |
|
555 | - |
|
556 | - /** |
|
557 | - * Parse incoming $args into an array and merge it with $defaults |
|
558 | - */ |
|
559 | - $args = wp_parse_args( $args, $defaults ); |
|
560 | - $output = ''; |
|
561 | - if($args['type']){ |
|
562 | - |
|
563 | - // open |
|
564 | - $output .= '<'.sanitize_html_class($args['type']); |
|
565 | - |
|
566 | - // element require |
|
567 | - if(!empty($args['element_require'])){ |
|
568 | - $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
569 | - $args['class'] .= " aui-conditional-field"; |
|
570 | - } |
|
571 | - |
|
572 | - // argument_id |
|
573 | - if( !empty($args['argument_id']) ){ |
|
574 | - $output .= ' data-argument="'.esc_attr($args['argument_id']).'"'; |
|
575 | - } |
|
576 | - |
|
577 | - // class |
|
578 | - $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
579 | - $output .= ' class="'.$class.'" '; |
|
580 | - |
|
581 | - // close wrap |
|
582 | - $output .= ' >'; |
|
583 | - |
|
584 | - |
|
585 | - // Input group left |
|
586 | - if(!empty($args['input_group_left'])){ |
|
587 | - $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
|
588 | - $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>'; |
|
589 | - $output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>'; |
|
590 | - } |
|
591 | - |
|
592 | - // content |
|
593 | - $output .= $args['content']; |
|
594 | - |
|
595 | - // Input group right |
|
596 | - if(!empty($args['input_group_right'])){ |
|
597 | - $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
|
598 | - $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>'; |
|
599 | - $output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>'; |
|
600 | - } |
|
601 | - |
|
602 | - |
|
603 | - // close wrap |
|
604 | - $output .= '</'.sanitize_html_class($args['type']).'>'; |
|
605 | - |
|
606 | - |
|
607 | - }else{ |
|
608 | - $output = $args['content']; |
|
609 | - } |
|
610 | - |
|
611 | - return $output; |
|
612 | - } |
|
613 | - |
|
614 | - /** |
|
615 | - * Build the component. |
|
616 | - * |
|
617 | - * @param array $args |
|
618 | - * |
|
619 | - * @return string The rendered component. |
|
620 | - */ |
|
621 | - public static function select($args = array()){ |
|
622 | - $defaults = array( |
|
623 | - 'class' => '', |
|
624 | - 'wrap_class' => '', |
|
625 | - 'id' => '', |
|
626 | - 'title' => '', |
|
627 | - 'value' => '', // can be an array or a string |
|
628 | - 'required' => false, |
|
629 | - 'label' => '', |
|
630 | - 'label_after'=> false, |
|
631 | - 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
632 | - 'label_class' => '', |
|
633 | - 'help_text' => '', |
|
634 | - 'placeholder'=> '', |
|
635 | - 'options' => array(), // array or string |
|
636 | - 'icon' => '', |
|
637 | - 'multiple' => false, |
|
638 | - 'select2' => false, |
|
639 | - 'no_wrap' => false, |
|
640 | - 'element_require' => '', // [%element_id%] == "1" |
|
641 | - 'extra_attributes' => array(), // an array of extra attributes |
|
642 | - ); |
|
643 | - |
|
644 | - /** |
|
645 | - * Parse incoming $args into an array and merge it with $defaults |
|
646 | - */ |
|
647 | - $args = wp_parse_args( $args, $defaults ); |
|
648 | - $output = ''; |
|
649 | - |
|
650 | - // for now lets hide floating labels |
|
651 | - if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';} |
|
652 | - |
|
653 | - // hidden label option needs to be empty |
|
654 | - $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
655 | - |
|
656 | - |
|
657 | - $label_after = $args['label_after']; |
|
658 | - |
|
659 | - // floating labels need label after |
|
660 | - if( $args['label_type'] == 'floating' ){ |
|
661 | - $label_after = true; |
|
662 | - $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
663 | - } |
|
664 | - |
|
665 | - // Maybe setup select2 |
|
666 | - $is_select2 = false; |
|
667 | - if(!empty($args['select2'])){ |
|
668 | - $args['class'] .= ' aui-select2'; |
|
669 | - $is_select2 = true; |
|
670 | - }elseif( strpos($args['class'], 'aui-select2') !== false){ |
|
671 | - $is_select2 = true; |
|
672 | - } |
|
673 | - |
|
674 | - // select2 tags |
|
675 | - if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason |
|
676 | - $args['data-tags'] = 'true'; |
|
677 | - $args['data-token-separators'] = "[',']"; |
|
678 | - $args['multiple'] = true; |
|
679 | - } |
|
680 | - |
|
681 | - // select2 placeholder |
|
682 | - if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){ |
|
683 | - $args['data-placeholder'] = esc_attr($args['placeholder']); |
|
684 | - $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true; |
|
685 | - } |
|
686 | - |
|
687 | - // label |
|
688 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
689 | - }elseif(!empty($args['label']) && !$label_after){ |
|
690 | - $label_args = array( |
|
691 | - 'title'=> $args['label'], |
|
692 | - 'for'=> $args['id'], |
|
693 | - 'class' => $args['label_class']." ", |
|
694 | - 'label_type' => $args['label_type'] |
|
695 | - ); |
|
696 | - $output .= self::label($label_args); |
|
697 | - } |
|
698 | - |
|
699 | - // maybe horizontal label |
|
700 | - if($args['label_type']=='horizontal'){ |
|
701 | - $output .= '<div class="col-sm-10">'; |
|
702 | - } |
|
703 | - |
|
704 | - // Set hidden input to save empty value for multiselect. |
|
705 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) { |
|
706 | - $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>'; |
|
707 | - } |
|
708 | - |
|
709 | - // open/type |
|
710 | - $output .= '<select '; |
|
711 | - |
|
712 | - // style |
|
713 | - if($is_select2){ |
|
714 | - $output .= " style='width:100%;' "; |
|
715 | - } |
|
716 | - |
|
717 | - // element require |
|
718 | - if(!empty($args['element_require'])){ |
|
719 | - $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
720 | - $args['class'] .= " aui-conditional-field"; |
|
721 | - } |
|
722 | - |
|
723 | - // class |
|
724 | - $class = !empty($args['class']) ? $args['class'] : ''; |
|
725 | - $output .= AUI_Component_Helper::class_attr('custom-select '.$class); |
|
726 | - |
|
727 | - // name |
|
728 | - if(!empty($args['name'])){ |
|
729 | - $output .= AUI_Component_Helper::name($args['name'],$args['multiple']); |
|
730 | - } |
|
731 | - |
|
732 | - // id |
|
733 | - if(!empty($args['id'])){ |
|
734 | - $output .= AUI_Component_Helper::id($args['id']); |
|
735 | - } |
|
736 | - |
|
737 | - // title |
|
738 | - if(!empty($args['title'])){ |
|
739 | - $output .= AUI_Component_Helper::title($args['title']); |
|
740 | - } |
|
741 | - |
|
742 | - // data-attributes |
|
743 | - $output .= AUI_Component_Helper::data_attributes($args); |
|
744 | - |
|
745 | - // aria-attributes |
|
746 | - $output .= AUI_Component_Helper::aria_attributes($args); |
|
747 | - |
|
748 | - // extra attributes |
|
749 | - if(!empty($args['extra_attributes'])){ |
|
750 | - $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
751 | - } |
|
752 | - |
|
753 | - // required |
|
754 | - if(!empty($args['required'])){ |
|
755 | - $output .= ' required '; |
|
756 | - } |
|
757 | - |
|
758 | - // multiple |
|
759 | - if(!empty($args['multiple'])){ |
|
760 | - $output .= ' multiple '; |
|
761 | - } |
|
762 | - |
|
763 | - // close opening tag |
|
764 | - $output .= ' >'; |
|
765 | - |
|
766 | - // placeholder |
|
767 | - if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){ |
|
768 | - $output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>'; |
|
769 | - }elseif($is_select2 && !empty($args['placeholder'])){ |
|
770 | - $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
|
771 | - } |
|
772 | - |
|
773 | - // Options |
|
774 | - if(!empty($args['options'])){ |
|
775 | - |
|
776 | - if(!is_array($args['options'])){ |
|
777 | - $output .= $args['options']; // not the preferred way but an option |
|
778 | - }else{ |
|
779 | - foreach($args['options'] as $val => $name){ |
|
780 | - $selected = ''; |
|
781 | - if(is_array($name)){ |
|
782 | - if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) { |
|
783 | - $option_label = isset($name['label']) ? $name['label'] : ''; |
|
784 | - |
|
785 | - $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; |
|
786 | - } else { |
|
787 | - $option_label = isset($name['label']) ? $name['label'] : ''; |
|
788 | - $option_value = isset($name['value']) ? $name['value'] : ''; |
|
789 | - if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){ |
|
790 | - $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : ""; |
|
791 | - } elseif(!empty($args['value'])) { |
|
792 | - $selected = selected($option_value,stripslashes_deep($args['value']), false); |
|
793 | - } |
|
794 | - |
|
795 | - $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; |
|
796 | - } |
|
797 | - }else{ |
|
798 | - if(!empty($args['value'])){ |
|
799 | - if(is_array($args['value'])){ |
|
800 | - $selected = in_array($val,$args['value']) ? 'selected="selected"' : ''; |
|
801 | - } elseif(!empty($args['value'])) { |
|
802 | - $selected = selected( $args['value'], $val, false); |
|
803 | - } |
|
804 | - } |
|
805 | - $output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>'; |
|
806 | - } |
|
807 | - } |
|
808 | - } |
|
809 | - |
|
810 | - } |
|
811 | - |
|
812 | - // closing tag |
|
813 | - $output .= '</select>'; |
|
814 | - |
|
815 | - if(!empty($args['label']) && $label_after){ |
|
816 | - $label_args = array( |
|
817 | - 'title'=> $args['label'], |
|
818 | - 'for'=> $args['id'], |
|
819 | - 'class' => $args['label_class']." ", |
|
820 | - 'label_type' => $args['label_type'] |
|
821 | - ); |
|
822 | - $output .= self::label($label_args); |
|
823 | - } |
|
824 | - |
|
825 | - // help text |
|
826 | - if(!empty($args['help_text'])){ |
|
827 | - $output .= AUI_Component_Helper::help_text($args['help_text']); |
|
828 | - } |
|
829 | - |
|
830 | - // maybe horizontal label |
|
831 | - if($args['label_type']=='horizontal'){ |
|
832 | - $output .= '</div>'; |
|
833 | - } |
|
834 | - |
|
835 | - |
|
836 | - // wrap |
|
837 | - if(!$args['no_wrap']){ |
|
838 | - $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
839 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
840 | - $output = self::wrap(array( |
|
841 | - 'content' => $output, |
|
842 | - 'class' => $wrap_class, |
|
843 | - 'element_require' => $args['element_require'], |
|
844 | - 'argument_id' => $args['id'] |
|
845 | - )); |
|
846 | - } |
|
847 | - |
|
848 | - |
|
849 | - return $output; |
|
850 | - } |
|
851 | - |
|
852 | - /** |
|
853 | - * Build the component. |
|
854 | - * |
|
855 | - * @param array $args |
|
856 | - * |
|
857 | - * @return string The rendered component. |
|
858 | - */ |
|
859 | - public static function radio($args = array()){ |
|
860 | - $defaults = array( |
|
861 | - 'class' => '', |
|
862 | - 'wrap_class' => '', |
|
863 | - 'id' => '', |
|
864 | - 'title' => '', |
|
865 | - 'horizontal' => false, // sets the lable horizontal |
|
866 | - 'value' => '', |
|
867 | - 'label' => '', |
|
868 | - 'label_class'=> '', |
|
869 | - 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
870 | - 'help_text' => '', |
|
871 | - 'inline' => true, |
|
872 | - 'required' => false, |
|
873 | - 'options' => array(), |
|
874 | - 'icon' => '', |
|
875 | - 'no_wrap' => false, |
|
876 | - 'element_require' => '', // [%element_id%] == "1" |
|
877 | - 'extra_attributes' => array() // an array of extra attributes |
|
878 | - ); |
|
879 | - |
|
880 | - /** |
|
881 | - * Parse incoming $args into an array and merge it with $defaults |
|
882 | - */ |
|
883 | - $args = wp_parse_args( $args, $defaults ); |
|
884 | - |
|
885 | - // for now lets use horizontal for floating |
|
886 | - if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';} |
|
887 | - |
|
888 | - $label_args = array( |
|
889 | - 'title'=> $args['label'], |
|
890 | - 'class' => $args['label_class']." pt-0 ", |
|
891 | - 'label_type' => $args['label_type'] |
|
892 | - ); |
|
893 | - |
|
894 | - $output = ''; |
|
895 | - |
|
896 | - |
|
897 | - |
|
898 | - // label before |
|
899 | - if(!empty($args['label'])){ |
|
900 | - $output .= self::label( $label_args, 'radio' ); |
|
901 | - } |
|
902 | - |
|
903 | - // maybe horizontal label |
|
904 | - if($args['label_type']=='horizontal'){ |
|
905 | - $output .= '<div class="col-sm-10">'; |
|
906 | - } |
|
907 | - |
|
908 | - if(!empty($args['options'])){ |
|
909 | - $count = 0; |
|
910 | - foreach($args['options'] as $value => $label){ |
|
911 | - $option_args = $args; |
|
912 | - $option_args['value'] = $value; |
|
913 | - $option_args['label'] = $label; |
|
914 | - $option_args['checked'] = $value == $args['value'] ? true : false; |
|
915 | - $output .= self::radio_option($option_args,$count); |
|
916 | - $count++; |
|
917 | - } |
|
918 | - } |
|
919 | - |
|
920 | - // help text |
|
921 | - $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
922 | - $output .= $help_text; |
|
923 | - |
|
924 | - // maybe horizontal label |
|
925 | - if($args['label_type']=='horizontal'){ |
|
926 | - $output .= '</div>'; |
|
927 | - } |
|
928 | - |
|
929 | - // wrap |
|
930 | - $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
931 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
932 | - $output = self::wrap(array( |
|
933 | - 'content' => $output, |
|
934 | - 'class' => $wrap_class, |
|
935 | - 'element_require' => $args['element_require'], |
|
936 | - 'argument_id' => $args['id'] |
|
937 | - )); |
|
938 | - |
|
939 | - |
|
940 | - return $output; |
|
941 | - } |
|
942 | - |
|
943 | - /** |
|
944 | - * Build the component. |
|
945 | - * |
|
946 | - * @param array $args |
|
947 | - * |
|
948 | - * @return string The rendered component. |
|
949 | - */ |
|
950 | - public static function radio_option($args = array(),$count = ''){ |
|
951 | - $defaults = array( |
|
952 | - 'class' => '', |
|
953 | - 'id' => '', |
|
954 | - 'title' => '', |
|
955 | - 'value' => '', |
|
956 | - 'required' => false, |
|
957 | - 'inline' => true, |
|
958 | - 'label' => '', |
|
959 | - 'options' => array(), |
|
960 | - 'icon' => '', |
|
961 | - 'no_wrap' => false, |
|
962 | - 'extra_attributes' => array() // an array of extra attributes |
|
963 | - ); |
|
964 | - |
|
965 | - /** |
|
966 | - * Parse incoming $args into an array and merge it with $defaults |
|
967 | - */ |
|
968 | - $args = wp_parse_args( $args, $defaults ); |
|
969 | - |
|
970 | - $output = ''; |
|
971 | - |
|
972 | - // open/type |
|
973 | - $output .= '<input type="radio"'; |
|
974 | - |
|
975 | - // class |
|
976 | - $output .= ' class="form-check-input" '; |
|
977 | - |
|
978 | - // name |
|
979 | - if(!empty($args['name'])){ |
|
980 | - $output .= AUI_Component_Helper::name($args['name']); |
|
981 | - } |
|
982 | - |
|
983 | - // id |
|
984 | - if(!empty($args['id'])){ |
|
985 | - $output .= AUI_Component_Helper::id($args['id'].$count); |
|
986 | - } |
|
987 | - |
|
988 | - // title |
|
989 | - if(!empty($args['title'])){ |
|
990 | - $output .= AUI_Component_Helper::title($args['title']); |
|
991 | - } |
|
992 | - |
|
993 | - // value |
|
994 | - if(isset($args['value'])){ |
|
995 | - $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
996 | - } |
|
997 | - |
|
998 | - // checked, for radio and checkboxes |
|
999 | - if( $args['checked'] ){ |
|
1000 | - $output .= ' checked '; |
|
1001 | - } |
|
1002 | - |
|
1003 | - // data-attributes |
|
1004 | - $output .= AUI_Component_Helper::data_attributes($args); |
|
1005 | - |
|
1006 | - // aria-attributes |
|
1007 | - $output .= AUI_Component_Helper::aria_attributes($args); |
|
1008 | - |
|
1009 | - // extra attributes |
|
1010 | - if(!empty($args['extra_attributes'])){ |
|
1011 | - $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
1012 | - } |
|
1013 | - |
|
1014 | - // required |
|
1015 | - if(!empty($args['required'])){ |
|
1016 | - $output .= ' required '; |
|
1017 | - } |
|
1018 | - |
|
1019 | - // close opening tag |
|
1020 | - $output .= ' >'; |
|
1021 | - |
|
1022 | - // label |
|
1023 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
1024 | - }elseif(!empty($args['label'])){ |
|
1025 | - $output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio'); |
|
1026 | - } |
|
1027 | - |
|
1028 | - // wrap |
|
1029 | - if(!$args['no_wrap']){ |
|
1030 | - $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
|
1031 | - $output = self::wrap(array( |
|
1032 | - 'content' => $output, |
|
1033 | - 'class' => $wrap_class |
|
1034 | - )); |
|
1035 | - } |
|
1036 | - |
|
1037 | - |
|
1038 | - return $output; |
|
1039 | - } |
|
213 | + } |
|
214 | + |
|
215 | + // input group wraps |
|
216 | + if($args['input_group_left'] || $args['input_group_right']){ |
|
217 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
218 | + if($args['input_group_left']){ |
|
219 | + $output = self::wrap( array( |
|
220 | + 'content' => $output, |
|
221 | + 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
222 | + 'input_group_left' => $args['input_group_left'], |
|
223 | + 'input_group_left_inside' => $args['input_group_left_inside'] |
|
224 | + ) ); |
|
225 | + } |
|
226 | + if($args['input_group_right']){ |
|
227 | + $output = self::wrap( array( |
|
228 | + 'content' => $output, |
|
229 | + 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
230 | + 'input_group_right' => $args['input_group_right'], |
|
231 | + 'input_group_right_inside' => $args['input_group_right_inside'] |
|
232 | + ) ); |
|
233 | + } |
|
234 | + |
|
235 | + } |
|
236 | + |
|
237 | + if(!$label_after){ |
|
238 | + $output .= $help_text; |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
243 | + $output = self::wrap( array( |
|
244 | + 'content' => $output, |
|
245 | + 'class' => 'col-sm-10', |
|
246 | + ) ); |
|
247 | + } |
|
248 | + |
|
249 | + if(!$label_after){ |
|
250 | + $output = $label . $output; |
|
251 | + } |
|
252 | + |
|
253 | + // wrap |
|
254 | + if(!$args['no_wrap']){ |
|
255 | + |
|
256 | + $form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
|
257 | + $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
258 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
259 | + $output = self::wrap(array( |
|
260 | + 'content' => $output, |
|
261 | + 'class' => $wrap_class, |
|
262 | + 'element_require' => $args['element_require'], |
|
263 | + 'argument_id' => $args['id'] |
|
264 | + )); |
|
265 | + } |
|
266 | + |
|
267 | + |
|
268 | + |
|
269 | + } |
|
270 | + |
|
271 | + return $output; |
|
272 | + } |
|
273 | + |
|
274 | + /** |
|
275 | + * Build the component. |
|
276 | + * |
|
277 | + * @param array $args |
|
278 | + * |
|
279 | + * @return string The rendered component. |
|
280 | + */ |
|
281 | + public static function textarea($args = array()){ |
|
282 | + $defaults = array( |
|
283 | + 'name' => '', |
|
284 | + 'class' => '', |
|
285 | + 'wrap_class' => '', |
|
286 | + 'id' => '', |
|
287 | + 'placeholder'=> '', |
|
288 | + 'title' => '', |
|
289 | + 'value' => '', |
|
290 | + 'required' => false, |
|
291 | + 'label' => '', |
|
292 | + 'label_after'=> false, |
|
293 | + 'label_class' => '', |
|
294 | + 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
295 | + 'help_text' => '', |
|
296 | + 'validation_text' => '', |
|
297 | + 'validation_pattern' => '', |
|
298 | + 'no_wrap' => false, |
|
299 | + 'rows' => '', |
|
300 | + 'wysiwyg' => false, |
|
301 | + 'allow_tags' => false, // Allow HTML tags |
|
302 | + 'element_require' => '', // [%element_id%] == "1" |
|
303 | + 'extra_attributes' => array(), // an array of extra attributes |
|
304 | + ); |
|
305 | + |
|
306 | + /** |
|
307 | + * Parse incoming $args into an array and merge it with $defaults |
|
308 | + */ |
|
309 | + $args = wp_parse_args( $args, $defaults ); |
|
310 | + $output = ''; |
|
311 | + |
|
312 | + // hidden label option needs to be empty |
|
313 | + $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
314 | + |
|
315 | + // floating labels don't work with wysiwyg so set it as top |
|
316 | + if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){ |
|
317 | + $args['label_type'] = 'top'; |
|
318 | + } |
|
319 | + |
|
320 | + $label_after = $args['label_after']; |
|
321 | + |
|
322 | + // floating labels need label after |
|
323 | + if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){ |
|
324 | + $label_after = true; |
|
325 | + $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
326 | + } |
|
327 | + |
|
328 | + // label |
|
329 | + if(!empty($args['label']) && is_array($args['label'])){ |
|
330 | + }elseif(!empty($args['label']) && !$label_after){ |
|
331 | + $label_args = array( |
|
332 | + 'title'=> $args['label'], |
|
333 | + 'for'=> $args['id'], |
|
334 | + 'class' => $args['label_class']." ", |
|
335 | + 'label_type' => $args['label_type'] |
|
336 | + ); |
|
337 | + $output .= self::label( $label_args ); |
|
338 | + } |
|
339 | + |
|
340 | + // maybe horizontal label |
|
341 | + if($args['label_type']=='horizontal'){ |
|
342 | + $output .= '<div class="col-sm-10">'; |
|
343 | + } |
|
344 | + |
|
345 | + if(!empty($args['wysiwyg'])){ |
|
346 | + ob_start(); |
|
347 | + $content = $args['value']; |
|
348 | + $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor'; |
|
349 | + $settings = array( |
|
350 | + 'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4, |
|
351 | + 'quicktags' => false, |
|
352 | + 'media_buttons' => false, |
|
353 | + 'editor_class' => 'form-control', |
|
354 | + 'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']), |
|
355 | + 'teeny' => true, |
|
356 | + ); |
|
357 | + |
|
358 | + // maybe set settings if array |
|
359 | + if(is_array($args['wysiwyg'])){ |
|
360 | + $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
361 | + } |
|
362 | + |
|
363 | + wp_editor( $content, $editor_id, $settings ); |
|
364 | + $output .= ob_get_clean(); |
|
365 | + }else{ |
|
366 | + |
|
367 | + // open |
|
368 | + $output .= '<textarea '; |
|
369 | + |
|
370 | + // name |
|
371 | + if(!empty($args['name'])){ |
|
372 | + $output .= ' name="'.sanitize_html_class($args['name']).'" '; |
|
373 | + } |
|
374 | + |
|
375 | + // id |
|
376 | + if(!empty($args['id'])){ |
|
377 | + $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
378 | + } |
|
379 | + |
|
380 | + // placeholder |
|
381 | + if(isset($args['placeholder']) && '' != $args['placeholder']){ |
|
382 | + $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
383 | + } |
|
384 | + |
|
385 | + // title |
|
386 | + if(!empty($args['title'])){ |
|
387 | + $output .= ' title="'.esc_attr($args['title']).'" '; |
|
388 | + } |
|
389 | + |
|
390 | + // validation text |
|
391 | + if(!empty($args['validation_text'])){ |
|
392 | + $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
393 | + $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
394 | + } |
|
395 | + |
|
396 | + // validation_pattern |
|
397 | + if(!empty($args['validation_pattern'])){ |
|
398 | + $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
399 | + } |
|
400 | + |
|
401 | + // required |
|
402 | + if(!empty($args['required'])){ |
|
403 | + $output .= ' required '; |
|
404 | + } |
|
405 | + |
|
406 | + // rows |
|
407 | + if(!empty($args['rows'])){ |
|
408 | + $output .= ' rows="'.absint($args['rows']).'" '; |
|
409 | + } |
|
410 | + |
|
411 | + |
|
412 | + // class |
|
413 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
414 | + $output .= ' class="form-control '.$class.'" '; |
|
415 | + |
|
416 | + // extra attributes |
|
417 | + if(!empty($args['extra_attributes'])){ |
|
418 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
419 | + } |
|
420 | + |
|
421 | + // close tag |
|
422 | + $output .= ' >'; |
|
423 | + |
|
424 | + // value |
|
425 | + if ( ! empty( $args['value'] ) ) { |
|
426 | + if ( ! empty( $args['allow_tags'] ) ) { |
|
427 | + $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
428 | + } else { |
|
429 | + $output .= sanitize_textarea_field( $args['value'] ); |
|
430 | + } |
|
431 | + } |
|
432 | + |
|
433 | + // closing tag |
|
434 | + $output .= '</textarea>'; |
|
435 | + |
|
436 | + } |
|
437 | + |
|
438 | + if(!empty($args['label']) && $label_after){ |
|
439 | + $label_args = array( |
|
440 | + 'title'=> $args['label'], |
|
441 | + 'for'=> $args['id'], |
|
442 | + 'class' => $args['label_class']." ", |
|
443 | + 'label_type' => $args['label_type'] |
|
444 | + ); |
|
445 | + $output .= self::label( $label_args ); |
|
446 | + } |
|
447 | + |
|
448 | + // help text |
|
449 | + if(!empty($args['help_text'])){ |
|
450 | + $output .= AUI_Component_Helper::help_text($args['help_text']); |
|
451 | + } |
|
452 | + |
|
453 | + // maybe horizontal label |
|
454 | + if($args['label_type']=='horizontal'){ |
|
455 | + $output .= '</div>'; |
|
456 | + } |
|
457 | + |
|
458 | + |
|
459 | + // wrap |
|
460 | + if(!$args['no_wrap']){ |
|
461 | + $form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group'; |
|
462 | + $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
463 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
464 | + $output = self::wrap(array( |
|
465 | + 'content' => $output, |
|
466 | + 'class' => $wrap_class, |
|
467 | + 'element_require' => $args['element_require'], |
|
468 | + 'argument_id' => $args['id'] |
|
469 | + )); |
|
470 | + } |
|
471 | + |
|
472 | + |
|
473 | + return $output; |
|
474 | + } |
|
475 | + |
|
476 | + public static function label($args = array(), $type = ''){ |
|
477 | + //<label for="exampleInputEmail1">Email address</label> |
|
478 | + $defaults = array( |
|
479 | + 'title' => 'div', |
|
480 | + 'for' => '', |
|
481 | + 'class' => '', |
|
482 | + 'label_type' => '', // empty = hidden, top, horizontal |
|
483 | + ); |
|
484 | + |
|
485 | + /** |
|
486 | + * Parse incoming $args into an array and merge it with $defaults |
|
487 | + */ |
|
488 | + $args = wp_parse_args( $args, $defaults ); |
|
489 | + $output = ''; |
|
490 | + |
|
491 | + if($args['title']){ |
|
492 | + |
|
493 | + // maybe hide labels //@todo set a global option for visibility class |
|
494 | + if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){ |
|
495 | + $class = $args['class']; |
|
496 | + }else{ |
|
497 | + $class = 'sr-only '.$args['class']; |
|
498 | + } |
|
499 | + |
|
500 | + // maybe horizontal |
|
501 | + if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
502 | + $class .= ' col-sm-2 col-form-label'; |
|
503 | + } |
|
504 | + |
|
505 | + // open |
|
506 | + $output .= '<label '; |
|
507 | + |
|
508 | + // for |
|
509 | + if(!empty($args['for'])){ |
|
510 | + $output .= ' for="'.sanitize_text_field($args['for']).'" '; |
|
511 | + } |
|
512 | + |
|
513 | + // class |
|
514 | + $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
515 | + $output .= ' class="'.$class.'" '; |
|
516 | + |
|
517 | + // close |
|
518 | + $output .= '>'; |
|
519 | + |
|
520 | + |
|
521 | + // title, don't escape fully as can contain html |
|
522 | + if(!empty($args['title'])){ |
|
523 | + $output .= wp_kses_post($args['title']); |
|
524 | + } |
|
525 | + |
|
526 | + // close wrap |
|
527 | + $output .= '</label>'; |
|
528 | + |
|
529 | + |
|
530 | + } |
|
531 | + |
|
532 | + |
|
533 | + return $output; |
|
534 | + } |
|
535 | + |
|
536 | + /** |
|
537 | + * Wrap some content in a HTML wrapper. |
|
538 | + * |
|
539 | + * @param array $args |
|
540 | + * |
|
541 | + * @return string |
|
542 | + */ |
|
543 | + public static function wrap($args = array()){ |
|
544 | + $defaults = array( |
|
545 | + 'type' => 'div', |
|
546 | + 'class' => 'form-group', |
|
547 | + 'content' => '', |
|
548 | + 'input_group_left' => '', |
|
549 | + 'input_group_right' => '', |
|
550 | + 'input_group_left_inside' => false, |
|
551 | + 'input_group_right_inside' => false, |
|
552 | + 'element_require' => '', |
|
553 | + 'argument_id' => '', |
|
554 | + ); |
|
555 | + |
|
556 | + /** |
|
557 | + * Parse incoming $args into an array and merge it with $defaults |
|
558 | + */ |
|
559 | + $args = wp_parse_args( $args, $defaults ); |
|
560 | + $output = ''; |
|
561 | + if($args['type']){ |
|
562 | + |
|
563 | + // open |
|
564 | + $output .= '<'.sanitize_html_class($args['type']); |
|
565 | + |
|
566 | + // element require |
|
567 | + if(!empty($args['element_require'])){ |
|
568 | + $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
569 | + $args['class'] .= " aui-conditional-field"; |
|
570 | + } |
|
571 | + |
|
572 | + // argument_id |
|
573 | + if( !empty($args['argument_id']) ){ |
|
574 | + $output .= ' data-argument="'.esc_attr($args['argument_id']).'"'; |
|
575 | + } |
|
576 | + |
|
577 | + // class |
|
578 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
579 | + $output .= ' class="'.$class.'" '; |
|
580 | + |
|
581 | + // close wrap |
|
582 | + $output .= ' >'; |
|
583 | + |
|
584 | + |
|
585 | + // Input group left |
|
586 | + if(!empty($args['input_group_left'])){ |
|
587 | + $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
|
588 | + $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>'; |
|
589 | + $output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>'; |
|
590 | + } |
|
591 | + |
|
592 | + // content |
|
593 | + $output .= $args['content']; |
|
594 | + |
|
595 | + // Input group right |
|
596 | + if(!empty($args['input_group_right'])){ |
|
597 | + $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
|
598 | + $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>'; |
|
599 | + $output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>'; |
|
600 | + } |
|
601 | + |
|
602 | + |
|
603 | + // close wrap |
|
604 | + $output .= '</'.sanitize_html_class($args['type']).'>'; |
|
605 | + |
|
606 | + |
|
607 | + }else{ |
|
608 | + $output = $args['content']; |
|
609 | + } |
|
610 | + |
|
611 | + return $output; |
|
612 | + } |
|
613 | + |
|
614 | + /** |
|
615 | + * Build the component. |
|
616 | + * |
|
617 | + * @param array $args |
|
618 | + * |
|
619 | + * @return string The rendered component. |
|
620 | + */ |
|
621 | + public static function select($args = array()){ |
|
622 | + $defaults = array( |
|
623 | + 'class' => '', |
|
624 | + 'wrap_class' => '', |
|
625 | + 'id' => '', |
|
626 | + 'title' => '', |
|
627 | + 'value' => '', // can be an array or a string |
|
628 | + 'required' => false, |
|
629 | + 'label' => '', |
|
630 | + 'label_after'=> false, |
|
631 | + 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
632 | + 'label_class' => '', |
|
633 | + 'help_text' => '', |
|
634 | + 'placeholder'=> '', |
|
635 | + 'options' => array(), // array or string |
|
636 | + 'icon' => '', |
|
637 | + 'multiple' => false, |
|
638 | + 'select2' => false, |
|
639 | + 'no_wrap' => false, |
|
640 | + 'element_require' => '', // [%element_id%] == "1" |
|
641 | + 'extra_attributes' => array(), // an array of extra attributes |
|
642 | + ); |
|
643 | + |
|
644 | + /** |
|
645 | + * Parse incoming $args into an array and merge it with $defaults |
|
646 | + */ |
|
647 | + $args = wp_parse_args( $args, $defaults ); |
|
648 | + $output = ''; |
|
649 | + |
|
650 | + // for now lets hide floating labels |
|
651 | + if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';} |
|
652 | + |
|
653 | + // hidden label option needs to be empty |
|
654 | + $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
655 | + |
|
656 | + |
|
657 | + $label_after = $args['label_after']; |
|
658 | + |
|
659 | + // floating labels need label after |
|
660 | + if( $args['label_type'] == 'floating' ){ |
|
661 | + $label_after = true; |
|
662 | + $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
663 | + } |
|
664 | + |
|
665 | + // Maybe setup select2 |
|
666 | + $is_select2 = false; |
|
667 | + if(!empty($args['select2'])){ |
|
668 | + $args['class'] .= ' aui-select2'; |
|
669 | + $is_select2 = true; |
|
670 | + }elseif( strpos($args['class'], 'aui-select2') !== false){ |
|
671 | + $is_select2 = true; |
|
672 | + } |
|
673 | + |
|
674 | + // select2 tags |
|
675 | + if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason |
|
676 | + $args['data-tags'] = 'true'; |
|
677 | + $args['data-token-separators'] = "[',']"; |
|
678 | + $args['multiple'] = true; |
|
679 | + } |
|
680 | + |
|
681 | + // select2 placeholder |
|
682 | + if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){ |
|
683 | + $args['data-placeholder'] = esc_attr($args['placeholder']); |
|
684 | + $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true; |
|
685 | + } |
|
686 | + |
|
687 | + // label |
|
688 | + if(!empty($args['label']) && is_array($args['label'])){ |
|
689 | + }elseif(!empty($args['label']) && !$label_after){ |
|
690 | + $label_args = array( |
|
691 | + 'title'=> $args['label'], |
|
692 | + 'for'=> $args['id'], |
|
693 | + 'class' => $args['label_class']." ", |
|
694 | + 'label_type' => $args['label_type'] |
|
695 | + ); |
|
696 | + $output .= self::label($label_args); |
|
697 | + } |
|
698 | + |
|
699 | + // maybe horizontal label |
|
700 | + if($args['label_type']=='horizontal'){ |
|
701 | + $output .= '<div class="col-sm-10">'; |
|
702 | + } |
|
703 | + |
|
704 | + // Set hidden input to save empty value for multiselect. |
|
705 | + if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) { |
|
706 | + $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>'; |
|
707 | + } |
|
708 | + |
|
709 | + // open/type |
|
710 | + $output .= '<select '; |
|
711 | + |
|
712 | + // style |
|
713 | + if($is_select2){ |
|
714 | + $output .= " style='width:100%;' "; |
|
715 | + } |
|
716 | + |
|
717 | + // element require |
|
718 | + if(!empty($args['element_require'])){ |
|
719 | + $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
720 | + $args['class'] .= " aui-conditional-field"; |
|
721 | + } |
|
722 | + |
|
723 | + // class |
|
724 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
725 | + $output .= AUI_Component_Helper::class_attr('custom-select '.$class); |
|
726 | + |
|
727 | + // name |
|
728 | + if(!empty($args['name'])){ |
|
729 | + $output .= AUI_Component_Helper::name($args['name'],$args['multiple']); |
|
730 | + } |
|
731 | + |
|
732 | + // id |
|
733 | + if(!empty($args['id'])){ |
|
734 | + $output .= AUI_Component_Helper::id($args['id']); |
|
735 | + } |
|
736 | + |
|
737 | + // title |
|
738 | + if(!empty($args['title'])){ |
|
739 | + $output .= AUI_Component_Helper::title($args['title']); |
|
740 | + } |
|
741 | + |
|
742 | + // data-attributes |
|
743 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
744 | + |
|
745 | + // aria-attributes |
|
746 | + $output .= AUI_Component_Helper::aria_attributes($args); |
|
747 | + |
|
748 | + // extra attributes |
|
749 | + if(!empty($args['extra_attributes'])){ |
|
750 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
751 | + } |
|
752 | + |
|
753 | + // required |
|
754 | + if(!empty($args['required'])){ |
|
755 | + $output .= ' required '; |
|
756 | + } |
|
757 | + |
|
758 | + // multiple |
|
759 | + if(!empty($args['multiple'])){ |
|
760 | + $output .= ' multiple '; |
|
761 | + } |
|
762 | + |
|
763 | + // close opening tag |
|
764 | + $output .= ' >'; |
|
765 | + |
|
766 | + // placeholder |
|
767 | + if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){ |
|
768 | + $output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>'; |
|
769 | + }elseif($is_select2 && !empty($args['placeholder'])){ |
|
770 | + $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
|
771 | + } |
|
772 | + |
|
773 | + // Options |
|
774 | + if(!empty($args['options'])){ |
|
775 | + |
|
776 | + if(!is_array($args['options'])){ |
|
777 | + $output .= $args['options']; // not the preferred way but an option |
|
778 | + }else{ |
|
779 | + foreach($args['options'] as $val => $name){ |
|
780 | + $selected = ''; |
|
781 | + if(is_array($name)){ |
|
782 | + if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) { |
|
783 | + $option_label = isset($name['label']) ? $name['label'] : ''; |
|
784 | + |
|
785 | + $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; |
|
786 | + } else { |
|
787 | + $option_label = isset($name['label']) ? $name['label'] : ''; |
|
788 | + $option_value = isset($name['value']) ? $name['value'] : ''; |
|
789 | + if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){ |
|
790 | + $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : ""; |
|
791 | + } elseif(!empty($args['value'])) { |
|
792 | + $selected = selected($option_value,stripslashes_deep($args['value']), false); |
|
793 | + } |
|
794 | + |
|
795 | + $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; |
|
796 | + } |
|
797 | + }else{ |
|
798 | + if(!empty($args['value'])){ |
|
799 | + if(is_array($args['value'])){ |
|
800 | + $selected = in_array($val,$args['value']) ? 'selected="selected"' : ''; |
|
801 | + } elseif(!empty($args['value'])) { |
|
802 | + $selected = selected( $args['value'], $val, false); |
|
803 | + } |
|
804 | + } |
|
805 | + $output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>'; |
|
806 | + } |
|
807 | + } |
|
808 | + } |
|
809 | + |
|
810 | + } |
|
811 | + |
|
812 | + // closing tag |
|
813 | + $output .= '</select>'; |
|
814 | + |
|
815 | + if(!empty($args['label']) && $label_after){ |
|
816 | + $label_args = array( |
|
817 | + 'title'=> $args['label'], |
|
818 | + 'for'=> $args['id'], |
|
819 | + 'class' => $args['label_class']." ", |
|
820 | + 'label_type' => $args['label_type'] |
|
821 | + ); |
|
822 | + $output .= self::label($label_args); |
|
823 | + } |
|
824 | + |
|
825 | + // help text |
|
826 | + if(!empty($args['help_text'])){ |
|
827 | + $output .= AUI_Component_Helper::help_text($args['help_text']); |
|
828 | + } |
|
829 | + |
|
830 | + // maybe horizontal label |
|
831 | + if($args['label_type']=='horizontal'){ |
|
832 | + $output .= '</div>'; |
|
833 | + } |
|
834 | + |
|
835 | + |
|
836 | + // wrap |
|
837 | + if(!$args['no_wrap']){ |
|
838 | + $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
839 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
840 | + $output = self::wrap(array( |
|
841 | + 'content' => $output, |
|
842 | + 'class' => $wrap_class, |
|
843 | + 'element_require' => $args['element_require'], |
|
844 | + 'argument_id' => $args['id'] |
|
845 | + )); |
|
846 | + } |
|
847 | + |
|
848 | + |
|
849 | + return $output; |
|
850 | + } |
|
851 | + |
|
852 | + /** |
|
853 | + * Build the component. |
|
854 | + * |
|
855 | + * @param array $args |
|
856 | + * |
|
857 | + * @return string The rendered component. |
|
858 | + */ |
|
859 | + public static function radio($args = array()){ |
|
860 | + $defaults = array( |
|
861 | + 'class' => '', |
|
862 | + 'wrap_class' => '', |
|
863 | + 'id' => '', |
|
864 | + 'title' => '', |
|
865 | + 'horizontal' => false, // sets the lable horizontal |
|
866 | + 'value' => '', |
|
867 | + 'label' => '', |
|
868 | + 'label_class'=> '', |
|
869 | + 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
870 | + 'help_text' => '', |
|
871 | + 'inline' => true, |
|
872 | + 'required' => false, |
|
873 | + 'options' => array(), |
|
874 | + 'icon' => '', |
|
875 | + 'no_wrap' => false, |
|
876 | + 'element_require' => '', // [%element_id%] == "1" |
|
877 | + 'extra_attributes' => array() // an array of extra attributes |
|
878 | + ); |
|
879 | + |
|
880 | + /** |
|
881 | + * Parse incoming $args into an array and merge it with $defaults |
|
882 | + */ |
|
883 | + $args = wp_parse_args( $args, $defaults ); |
|
884 | + |
|
885 | + // for now lets use horizontal for floating |
|
886 | + if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';} |
|
887 | + |
|
888 | + $label_args = array( |
|
889 | + 'title'=> $args['label'], |
|
890 | + 'class' => $args['label_class']." pt-0 ", |
|
891 | + 'label_type' => $args['label_type'] |
|
892 | + ); |
|
893 | + |
|
894 | + $output = ''; |
|
895 | + |
|
896 | + |
|
897 | + |
|
898 | + // label before |
|
899 | + if(!empty($args['label'])){ |
|
900 | + $output .= self::label( $label_args, 'radio' ); |
|
901 | + } |
|
902 | + |
|
903 | + // maybe horizontal label |
|
904 | + if($args['label_type']=='horizontal'){ |
|
905 | + $output .= '<div class="col-sm-10">'; |
|
906 | + } |
|
907 | + |
|
908 | + if(!empty($args['options'])){ |
|
909 | + $count = 0; |
|
910 | + foreach($args['options'] as $value => $label){ |
|
911 | + $option_args = $args; |
|
912 | + $option_args['value'] = $value; |
|
913 | + $option_args['label'] = $label; |
|
914 | + $option_args['checked'] = $value == $args['value'] ? true : false; |
|
915 | + $output .= self::radio_option($option_args,$count); |
|
916 | + $count++; |
|
917 | + } |
|
918 | + } |
|
919 | + |
|
920 | + // help text |
|
921 | + $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
922 | + $output .= $help_text; |
|
923 | + |
|
924 | + // maybe horizontal label |
|
925 | + if($args['label_type']=='horizontal'){ |
|
926 | + $output .= '</div>'; |
|
927 | + } |
|
928 | + |
|
929 | + // wrap |
|
930 | + $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
931 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
932 | + $output = self::wrap(array( |
|
933 | + 'content' => $output, |
|
934 | + 'class' => $wrap_class, |
|
935 | + 'element_require' => $args['element_require'], |
|
936 | + 'argument_id' => $args['id'] |
|
937 | + )); |
|
938 | + |
|
939 | + |
|
940 | + return $output; |
|
941 | + } |
|
942 | + |
|
943 | + /** |
|
944 | + * Build the component. |
|
945 | + * |
|
946 | + * @param array $args |
|
947 | + * |
|
948 | + * @return string The rendered component. |
|
949 | + */ |
|
950 | + public static function radio_option($args = array(),$count = ''){ |
|
951 | + $defaults = array( |
|
952 | + 'class' => '', |
|
953 | + 'id' => '', |
|
954 | + 'title' => '', |
|
955 | + 'value' => '', |
|
956 | + 'required' => false, |
|
957 | + 'inline' => true, |
|
958 | + 'label' => '', |
|
959 | + 'options' => array(), |
|
960 | + 'icon' => '', |
|
961 | + 'no_wrap' => false, |
|
962 | + 'extra_attributes' => array() // an array of extra attributes |
|
963 | + ); |
|
964 | + |
|
965 | + /** |
|
966 | + * Parse incoming $args into an array and merge it with $defaults |
|
967 | + */ |
|
968 | + $args = wp_parse_args( $args, $defaults ); |
|
969 | + |
|
970 | + $output = ''; |
|
971 | + |
|
972 | + // open/type |
|
973 | + $output .= '<input type="radio"'; |
|
974 | + |
|
975 | + // class |
|
976 | + $output .= ' class="form-check-input" '; |
|
977 | + |
|
978 | + // name |
|
979 | + if(!empty($args['name'])){ |
|
980 | + $output .= AUI_Component_Helper::name($args['name']); |
|
981 | + } |
|
982 | + |
|
983 | + // id |
|
984 | + if(!empty($args['id'])){ |
|
985 | + $output .= AUI_Component_Helper::id($args['id'].$count); |
|
986 | + } |
|
987 | + |
|
988 | + // title |
|
989 | + if(!empty($args['title'])){ |
|
990 | + $output .= AUI_Component_Helper::title($args['title']); |
|
991 | + } |
|
992 | + |
|
993 | + // value |
|
994 | + if(isset($args['value'])){ |
|
995 | + $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
996 | + } |
|
997 | + |
|
998 | + // checked, for radio and checkboxes |
|
999 | + if( $args['checked'] ){ |
|
1000 | + $output .= ' checked '; |
|
1001 | + } |
|
1002 | + |
|
1003 | + // data-attributes |
|
1004 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
1005 | + |
|
1006 | + // aria-attributes |
|
1007 | + $output .= AUI_Component_Helper::aria_attributes($args); |
|
1008 | + |
|
1009 | + // extra attributes |
|
1010 | + if(!empty($args['extra_attributes'])){ |
|
1011 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
1012 | + } |
|
1013 | + |
|
1014 | + // required |
|
1015 | + if(!empty($args['required'])){ |
|
1016 | + $output .= ' required '; |
|
1017 | + } |
|
1018 | + |
|
1019 | + // close opening tag |
|
1020 | + $output .= ' >'; |
|
1021 | + |
|
1022 | + // label |
|
1023 | + if(!empty($args['label']) && is_array($args['label'])){ |
|
1024 | + }elseif(!empty($args['label'])){ |
|
1025 | + $output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio'); |
|
1026 | + } |
|
1027 | + |
|
1028 | + // wrap |
|
1029 | + if(!$args['no_wrap']){ |
|
1030 | + $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
|
1031 | + $output = self::wrap(array( |
|
1032 | + 'content' => $output, |
|
1033 | + 'class' => $wrap_class |
|
1034 | + )); |
|
1035 | + } |
|
1036 | + |
|
1037 | + |
|
1038 | + return $output; |
|
1039 | + } |
|
1040 | 1040 | |
1041 | 1041 | } |
1042 | 1042 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; // Exit if accessed directly |
5 | 5 | } |
6 | 6 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return string The rendered component. |
20 | 20 | */ |
21 | - public static function input($args = array()){ |
|
21 | + public static function input($args = array()) { |
|
22 | 22 | $defaults = array( |
23 | 23 | 'type' => 'text', |
24 | 24 | 'name' => '', |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * Parse incoming $args into an array and merge it with $defaults |
54 | 54 | */ |
55 | - $args = wp_parse_args( $args, $defaults ); |
|
55 | + $args = wp_parse_args($args, $defaults); |
|
56 | 56 | $output = ''; |
57 | - if ( ! empty( $args['type'] ) ) { |
|
57 | + if (!empty($args['type'])) { |
|
58 | 58 | // hidden label option needs to be empty |
59 | 59 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
60 | 60 | |
61 | - $type = sanitize_html_class( $args['type'] ); |
|
61 | + $type = sanitize_html_class($args['type']); |
|
62 | 62 | |
63 | 63 | $help_text = ''; |
64 | 64 | $label = ''; |
@@ -66,24 +66,24 @@ discard block |
||
66 | 66 | $label_args = array( |
67 | 67 | 'title'=> $args['label'], |
68 | 68 | 'for'=> $args['id'], |
69 | - 'class' => $args['label_class']." ", |
|
69 | + 'class' => $args['label_class'] . " ", |
|
70 | 70 | 'label_type' => $args['label_type'] |
71 | 71 | ); |
72 | 72 | |
73 | 73 | // floating labels need label after |
74 | - if( $args['label_type'] == 'floating' && $type != 'checkbox' ){ |
|
74 | + if ($args['label_type'] == 'floating' && $type != 'checkbox') { |
|
75 | 75 | $label_after = true; |
76 | 76 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
77 | 77 | } |
78 | 78 | |
79 | 79 | // Some special sauce for files |
80 | - if($type=='file' ){ |
|
80 | + if ($type == 'file') { |
|
81 | 81 | $label_after = true; // if type file we need the label after |
82 | 82 | $args['class'] .= ' custom-file-input '; |
83 | - }elseif($type=='checkbox'){ |
|
83 | + }elseif ($type == 'checkbox') { |
|
84 | 84 | $label_after = true; // if type file we need the label after |
85 | 85 | $args['class'] .= ' custom-control-input '; |
86 | - }elseif($type=='datepicker' || $type=='timepicker'){ |
|
86 | + }elseif ($type == 'datepicker' || $type == 'timepicker') { |
|
87 | 87 | $type = 'text'; |
88 | 88 | //$args['class'] .= ' aui-flatpickr bg-initial '; |
89 | 89 | $args['class'] .= ' bg-initial '; |
@@ -99,65 +99,65 @@ discard block |
||
99 | 99 | $output .= '<input type="' . $type . '" '; |
100 | 100 | |
101 | 101 | // name |
102 | - if(!empty($args['name'])){ |
|
103 | - $output .= ' name="'.esc_attr($args['name']).'" '; |
|
102 | + if (!empty($args['name'])) { |
|
103 | + $output .= ' name="' . esc_attr($args['name']) . '" '; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // id |
107 | - if(!empty($args['id'])){ |
|
108 | - $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
107 | + if (!empty($args['id'])) { |
|
108 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // placeholder |
112 | - if(isset($args['placeholder']) && '' != $args['placeholder'] ){ |
|
113 | - $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
112 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
113 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // title |
117 | - if(!empty($args['title'])){ |
|
118 | - $output .= ' title="'.esc_attr($args['title']).'" '; |
|
117 | + if (!empty($args['title'])) { |
|
118 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | // value |
122 | - if(!empty($args['value'])){ |
|
123 | - $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
122 | + if (!empty($args['value'])) { |
|
123 | + $output .= ' value="' . sanitize_text_field($args['value']) . '" '; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // checked, for radio and checkboxes |
127 | - if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){ |
|
127 | + if (($type == 'checkbox' || $type == 'radio') && $args['checked']) { |
|
128 | 128 | $output .= ' checked '; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // validation text |
132 | - if(!empty($args['validation_text'])){ |
|
133 | - $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
132 | + if (!empty($args['validation_text'])) { |
|
133 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" '; |
|
134 | 134 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
135 | 135 | } |
136 | 136 | |
137 | 137 | // validation_pattern |
138 | - if(!empty($args['validation_pattern'])){ |
|
139 | - $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
138 | + if (!empty($args['validation_pattern'])) { |
|
139 | + $output .= ' pattern="' . $args['validation_pattern'] . '" '; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | // step (for numbers) |
143 | - if(!empty($args['step'])){ |
|
144 | - $output .= ' step="'.$args['step'].'" '; |
|
143 | + if (!empty($args['step'])) { |
|
144 | + $output .= ' step="' . $args['step'] . '" '; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | // required |
148 | - if(!empty($args['required'])){ |
|
148 | + if (!empty($args['required'])) { |
|
149 | 149 | $output .= ' required '; |
150 | 150 | } |
151 | 151 | |
152 | 152 | // class |
153 | - $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
154 | - $output .= ' class="form-control '.$class.'" '; |
|
153 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
154 | + $output .= ' class="form-control ' . $class . '" '; |
|
155 | 155 | |
156 | 156 | // data-attributes |
157 | 157 | $output .= AUI_Component_Helper::data_attributes($args); |
158 | 158 | |
159 | 159 | // extra attributes |
160 | - if(!empty($args['extra_attributes'])){ |
|
160 | + if (!empty($args['extra_attributes'])) { |
|
161 | 161 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
162 | 162 | } |
163 | 163 | |
@@ -166,40 +166,40 @@ discard block |
||
166 | 166 | |
167 | 167 | |
168 | 168 | // label |
169 | - if(!empty($args['label'])){ |
|
170 | - if($type == 'file'){$label_args['class'] .= 'custom-file-label';} |
|
171 | - elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';} |
|
172 | - $label = self::label( $label_args, $type ); |
|
169 | + if (!empty($args['label'])) { |
|
170 | + if ($type == 'file') {$label_args['class'] .= 'custom-file-label'; } |
|
171 | + elseif ($type == 'checkbox') {$label_args['class'] .= 'custom-control-label'; } |
|
172 | + $label = self::label($label_args, $type); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | // help text |
176 | - if(!empty($args['help_text'])){ |
|
176 | + if (!empty($args['help_text'])) { |
|
177 | 177 | $help_text = AUI_Component_Helper::help_text($args['help_text']); |
178 | 178 | } |
179 | 179 | |
180 | 180 | |
181 | 181 | // set help text in the correct possition |
182 | - if($label_after){ |
|
182 | + if ($label_after) { |
|
183 | 183 | $output .= $label . $help_text; |
184 | 184 | } |
185 | 185 | |
186 | 186 | // some input types need a separate wrap |
187 | - if($type == 'file') { |
|
188 | - $output = self::wrap( array( |
|
187 | + if ($type == 'file') { |
|
188 | + $output = self::wrap(array( |
|
189 | 189 | 'content' => $output, |
190 | 190 | 'class' => 'form-group custom-file' |
191 | - ) ); |
|
192 | - }elseif($type == 'checkbox'){ |
|
191 | + )); |
|
192 | + }elseif ($type == 'checkbox') { |
|
193 | 193 | $wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox'; |
194 | - $output = self::wrap( array( |
|
194 | + $output = self::wrap(array( |
|
195 | 195 | 'content' => $output, |
196 | - 'class' => 'custom-control '.$wrap_class |
|
197 | - ) ); |
|
196 | + 'class' => 'custom-control ' . $wrap_class |
|
197 | + )); |
|
198 | 198 | |
199 | - if($args['label_type']=='horizontal'){ |
|
199 | + if ($args['label_type'] == 'horizontal') { |
|
200 | 200 | $output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>'; |
201 | 201 | } |
202 | - }elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){ |
|
202 | + }elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) { |
|
203 | 203 | |
204 | 204 | |
205 | 205 | // allow password field to toggle view |
@@ -213,49 +213,49 @@ discard block |
||
213 | 213 | } |
214 | 214 | |
215 | 215 | // input group wraps |
216 | - if($args['input_group_left'] || $args['input_group_right']){ |
|
216 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
217 | 217 | $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
218 | - if($args['input_group_left']){ |
|
219 | - $output = self::wrap( array( |
|
218 | + if ($args['input_group_left']) { |
|
219 | + $output = self::wrap(array( |
|
220 | 220 | 'content' => $output, |
221 | - 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
221 | + 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
222 | 222 | 'input_group_left' => $args['input_group_left'], |
223 | 223 | 'input_group_left_inside' => $args['input_group_left_inside'] |
224 | - ) ); |
|
224 | + )); |
|
225 | 225 | } |
226 | - if($args['input_group_right']){ |
|
227 | - $output = self::wrap( array( |
|
226 | + if ($args['input_group_right']) { |
|
227 | + $output = self::wrap(array( |
|
228 | 228 | 'content' => $output, |
229 | - 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
229 | + 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
230 | 230 | 'input_group_right' => $args['input_group_right'], |
231 | 231 | 'input_group_right_inside' => $args['input_group_right_inside'] |
232 | - ) ); |
|
232 | + )); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | } |
236 | 236 | |
237 | - if(!$label_after){ |
|
237 | + if (!$label_after) { |
|
238 | 238 | $output .= $help_text; |
239 | 239 | } |
240 | 240 | |
241 | 241 | |
242 | - if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
243 | - $output = self::wrap( array( |
|
242 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
243 | + $output = self::wrap(array( |
|
244 | 244 | 'content' => $output, |
245 | 245 | 'class' => 'col-sm-10', |
246 | - ) ); |
|
246 | + )); |
|
247 | 247 | } |
248 | 248 | |
249 | - if(!$label_after){ |
|
249 | + if (!$label_after) { |
|
250 | 250 | $output = $label . $output; |
251 | 251 | } |
252 | 252 | |
253 | 253 | // wrap |
254 | - if(!$args['no_wrap']){ |
|
254 | + if (!$args['no_wrap']) { |
|
255 | 255 | |
256 | - $form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
|
257 | - $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
258 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
256 | + $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
|
257 | + $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
258 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
259 | 259 | $output = self::wrap(array( |
260 | 260 | 'content' => $output, |
261 | 261 | 'class' => $wrap_class, |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return string The rendered component. |
280 | 280 | */ |
281 | - public static function textarea($args = array()){ |
|
281 | + public static function textarea($args = array()) { |
|
282 | 282 | $defaults = array( |
283 | 283 | 'name' => '', |
284 | 284 | 'class' => '', |
@@ -306,43 +306,43 @@ discard block |
||
306 | 306 | /** |
307 | 307 | * Parse incoming $args into an array and merge it with $defaults |
308 | 308 | */ |
309 | - $args = wp_parse_args( $args, $defaults ); |
|
309 | + $args = wp_parse_args($args, $defaults); |
|
310 | 310 | $output = ''; |
311 | 311 | |
312 | 312 | // hidden label option needs to be empty |
313 | 313 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
314 | 314 | |
315 | 315 | // floating labels don't work with wysiwyg so set it as top |
316 | - if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){ |
|
316 | + if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) { |
|
317 | 317 | $args['label_type'] = 'top'; |
318 | 318 | } |
319 | 319 | |
320 | 320 | $label_after = $args['label_after']; |
321 | 321 | |
322 | 322 | // floating labels need label after |
323 | - if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){ |
|
323 | + if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) { |
|
324 | 324 | $label_after = true; |
325 | 325 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
326 | 326 | } |
327 | 327 | |
328 | 328 | // label |
329 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
330 | - }elseif(!empty($args['label']) && !$label_after){ |
|
329 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
330 | + }elseif (!empty($args['label']) && !$label_after) { |
|
331 | 331 | $label_args = array( |
332 | 332 | 'title'=> $args['label'], |
333 | 333 | 'for'=> $args['id'], |
334 | - 'class' => $args['label_class']." ", |
|
334 | + 'class' => $args['label_class'] . " ", |
|
335 | 335 | 'label_type' => $args['label_type'] |
336 | 336 | ); |
337 | - $output .= self::label( $label_args ); |
|
337 | + $output .= self::label($label_args); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | // maybe horizontal label |
341 | - if($args['label_type']=='horizontal'){ |
|
341 | + if ($args['label_type'] == 'horizontal') { |
|
342 | 342 | $output .= '<div class="col-sm-10">'; |
343 | 343 | } |
344 | 344 | |
345 | - if(!empty($args['wysiwyg'])){ |
|
345 | + if (!empty($args['wysiwyg'])) { |
|
346 | 346 | ob_start(); |
347 | 347 | $content = $args['value']; |
348 | 348 | $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor'; |
@@ -356,65 +356,65 @@ discard block |
||
356 | 356 | ); |
357 | 357 | |
358 | 358 | // maybe set settings if array |
359 | - if(is_array($args['wysiwyg'])){ |
|
360 | - $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
359 | + if (is_array($args['wysiwyg'])) { |
|
360 | + $settings = wp_parse_args($args['wysiwyg'], $settings); |
|
361 | 361 | } |
362 | 362 | |
363 | - wp_editor( $content, $editor_id, $settings ); |
|
363 | + wp_editor($content, $editor_id, $settings); |
|
364 | 364 | $output .= ob_get_clean(); |
365 | - }else{ |
|
365 | + } else { |
|
366 | 366 | |
367 | 367 | // open |
368 | 368 | $output .= '<textarea '; |
369 | 369 | |
370 | 370 | // name |
371 | - if(!empty($args['name'])){ |
|
372 | - $output .= ' name="'.sanitize_html_class($args['name']).'" '; |
|
371 | + if (!empty($args['name'])) { |
|
372 | + $output .= ' name="' . sanitize_html_class($args['name']) . '" '; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | // id |
376 | - if(!empty($args['id'])){ |
|
377 | - $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
376 | + if (!empty($args['id'])) { |
|
377 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | // placeholder |
381 | - if(isset($args['placeholder']) && '' != $args['placeholder']){ |
|
382 | - $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
381 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
382 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | // title |
386 | - if(!empty($args['title'])){ |
|
387 | - $output .= ' title="'.esc_attr($args['title']).'" '; |
|
386 | + if (!empty($args['title'])) { |
|
387 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | // validation text |
391 | - if(!empty($args['validation_text'])){ |
|
392 | - $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
391 | + if (!empty($args['validation_text'])) { |
|
392 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" '; |
|
393 | 393 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
394 | 394 | } |
395 | 395 | |
396 | 396 | // validation_pattern |
397 | - if(!empty($args['validation_pattern'])){ |
|
398 | - $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
397 | + if (!empty($args['validation_pattern'])) { |
|
398 | + $output .= ' pattern="' . $args['validation_pattern'] . '" '; |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | // required |
402 | - if(!empty($args['required'])){ |
|
402 | + if (!empty($args['required'])) { |
|
403 | 403 | $output .= ' required '; |
404 | 404 | } |
405 | 405 | |
406 | 406 | // rows |
407 | - if(!empty($args['rows'])){ |
|
408 | - $output .= ' rows="'.absint($args['rows']).'" '; |
|
407 | + if (!empty($args['rows'])) { |
|
408 | + $output .= ' rows="' . absint($args['rows']) . '" '; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | |
412 | 412 | // class |
413 | 413 | $class = !empty($args['class']) ? $args['class'] : ''; |
414 | - $output .= ' class="form-control '.$class.'" '; |
|
414 | + $output .= ' class="form-control ' . $class . '" '; |
|
415 | 415 | |
416 | 416 | // extra attributes |
417 | - if(!empty($args['extra_attributes'])){ |
|
417 | + if (!empty($args['extra_attributes'])) { |
|
418 | 418 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
419 | 419 | } |
420 | 420 | |
@@ -422,11 +422,11 @@ discard block |
||
422 | 422 | $output .= ' >'; |
423 | 423 | |
424 | 424 | // value |
425 | - if ( ! empty( $args['value'] ) ) { |
|
426 | - if ( ! empty( $args['allow_tags'] ) ) { |
|
427 | - $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
425 | + if (!empty($args['value'])) { |
|
426 | + if (!empty($args['allow_tags'])) { |
|
427 | + $output .= AUI_Component_Helper::sanitize_html_field($args['value'], $args); // Sanitize HTML. |
|
428 | 428 | } else { |
429 | - $output .= sanitize_textarea_field( $args['value'] ); |
|
429 | + $output .= sanitize_textarea_field($args['value']); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
@@ -435,32 +435,32 @@ discard block |
||
435 | 435 | |
436 | 436 | } |
437 | 437 | |
438 | - if(!empty($args['label']) && $label_after){ |
|
438 | + if (!empty($args['label']) && $label_after) { |
|
439 | 439 | $label_args = array( |
440 | 440 | 'title'=> $args['label'], |
441 | 441 | 'for'=> $args['id'], |
442 | - 'class' => $args['label_class']." ", |
|
442 | + 'class' => $args['label_class'] . " ", |
|
443 | 443 | 'label_type' => $args['label_type'] |
444 | 444 | ); |
445 | - $output .= self::label( $label_args ); |
|
445 | + $output .= self::label($label_args); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | // help text |
449 | - if(!empty($args['help_text'])){ |
|
449 | + if (!empty($args['help_text'])) { |
|
450 | 450 | $output .= AUI_Component_Helper::help_text($args['help_text']); |
451 | 451 | } |
452 | 452 | |
453 | 453 | // maybe horizontal label |
454 | - if($args['label_type']=='horizontal'){ |
|
454 | + if ($args['label_type'] == 'horizontal') { |
|
455 | 455 | $output .= '</div>'; |
456 | 456 | } |
457 | 457 | |
458 | 458 | |
459 | 459 | // wrap |
460 | - if(!$args['no_wrap']){ |
|
461 | - $form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group'; |
|
462 | - $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
463 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
460 | + if (!$args['no_wrap']) { |
|
461 | + $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group'; |
|
462 | + $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
463 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
464 | 464 | $output = self::wrap(array( |
465 | 465 | 'content' => $output, |
466 | 466 | 'class' => $wrap_class, |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | return $output; |
474 | 474 | } |
475 | 475 | |
476 | - public static function label($args = array(), $type = ''){ |
|
476 | + public static function label($args = array(), $type = '') { |
|
477 | 477 | //<label for="exampleInputEmail1">Email address</label> |
478 | 478 | $defaults = array( |
479 | 479 | 'title' => 'div', |
@@ -485,20 +485,20 @@ discard block |
||
485 | 485 | /** |
486 | 486 | * Parse incoming $args into an array and merge it with $defaults |
487 | 487 | */ |
488 | - $args = wp_parse_args( $args, $defaults ); |
|
488 | + $args = wp_parse_args($args, $defaults); |
|
489 | 489 | $output = ''; |
490 | 490 | |
491 | - if($args['title']){ |
|
491 | + if ($args['title']) { |
|
492 | 492 | |
493 | 493 | // maybe hide labels //@todo set a global option for visibility class |
494 | - if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){ |
|
494 | + if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) { |
|
495 | 495 | $class = $args['class']; |
496 | - }else{ |
|
497 | - $class = 'sr-only '.$args['class']; |
|
496 | + } else { |
|
497 | + $class = 'sr-only ' . $args['class']; |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | // maybe horizontal |
501 | - if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
501 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
502 | 502 | $class .= ' col-sm-2 col-form-label'; |
503 | 503 | } |
504 | 504 | |
@@ -506,20 +506,20 @@ discard block |
||
506 | 506 | $output .= '<label '; |
507 | 507 | |
508 | 508 | // for |
509 | - if(!empty($args['for'])){ |
|
510 | - $output .= ' for="'.sanitize_text_field($args['for']).'" '; |
|
509 | + if (!empty($args['for'])) { |
|
510 | + $output .= ' for="' . sanitize_text_field($args['for']) . '" '; |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | // class |
514 | - $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
515 | - $output .= ' class="'.$class.'" '; |
|
514 | + $class = $class ? AUI_Component_Helper::esc_classes($class) : ''; |
|
515 | + $output .= ' class="' . $class . '" '; |
|
516 | 516 | |
517 | 517 | // close |
518 | 518 | $output .= '>'; |
519 | 519 | |
520 | 520 | |
521 | 521 | // title, don't escape fully as can contain html |
522 | - if(!empty($args['title'])){ |
|
522 | + if (!empty($args['title'])) { |
|
523 | 523 | $output .= wp_kses_post($args['title']); |
524 | 524 | } |
525 | 525 | |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return string |
542 | 542 | */ |
543 | - public static function wrap($args = array()){ |
|
543 | + public static function wrap($args = array()) { |
|
544 | 544 | $defaults = array( |
545 | 545 | 'type' => 'div', |
546 | 546 | 'class' => 'form-group', |
@@ -556,55 +556,55 @@ discard block |
||
556 | 556 | /** |
557 | 557 | * Parse incoming $args into an array and merge it with $defaults |
558 | 558 | */ |
559 | - $args = wp_parse_args( $args, $defaults ); |
|
559 | + $args = wp_parse_args($args, $defaults); |
|
560 | 560 | $output = ''; |
561 | - if($args['type']){ |
|
561 | + if ($args['type']) { |
|
562 | 562 | |
563 | 563 | // open |
564 | - $output .= '<'.sanitize_html_class($args['type']); |
|
564 | + $output .= '<' . sanitize_html_class($args['type']); |
|
565 | 565 | |
566 | 566 | // element require |
567 | - if(!empty($args['element_require'])){ |
|
567 | + if (!empty($args['element_require'])) { |
|
568 | 568 | $output .= AUI_Component_Helper::element_require($args['element_require']); |
569 | 569 | $args['class'] .= " aui-conditional-field"; |
570 | 570 | } |
571 | 571 | |
572 | 572 | // argument_id |
573 | - if( !empty($args['argument_id']) ){ |
|
574 | - $output .= ' data-argument="'.esc_attr($args['argument_id']).'"'; |
|
573 | + if (!empty($args['argument_id'])) { |
|
574 | + $output .= ' data-argument="' . esc_attr($args['argument_id']) . '"'; |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | // class |
578 | - $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
579 | - $output .= ' class="'.$class.'" '; |
|
578 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
579 | + $output .= ' class="' . $class . '" '; |
|
580 | 580 | |
581 | 581 | // close wrap |
582 | 582 | $output .= ' >'; |
583 | 583 | |
584 | 584 | |
585 | 585 | // Input group left |
586 | - if(!empty($args['input_group_left'])){ |
|
586 | + if (!empty($args['input_group_left'])) { |
|
587 | 587 | $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
588 | - $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>'; |
|
589 | - $output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>'; |
|
588 | + $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
589 | + $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | // content |
593 | 593 | $output .= $args['content']; |
594 | 594 | |
595 | 595 | // Input group right |
596 | - if(!empty($args['input_group_right'])){ |
|
596 | + if (!empty($args['input_group_right'])) { |
|
597 | 597 | $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
598 | - $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>'; |
|
599 | - $output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>'; |
|
598 | + $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
599 | + $output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>'; |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | |
603 | 603 | // close wrap |
604 | - $output .= '</'.sanitize_html_class($args['type']).'>'; |
|
604 | + $output .= '</' . sanitize_html_class($args['type']) . '>'; |
|
605 | 605 | |
606 | 606 | |
607 | - }else{ |
|
607 | + } else { |
|
608 | 608 | $output = $args['content']; |
609 | 609 | } |
610 | 610 | |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | * |
619 | 619 | * @return string The rendered component. |
620 | 620 | */ |
621 | - public static function select($args = array()){ |
|
621 | + public static function select($args = array()) { |
|
622 | 622 | $defaults = array( |
623 | 623 | 'class' => '', |
624 | 624 | 'wrap_class' => '', |
@@ -644,11 +644,11 @@ discard block |
||
644 | 644 | /** |
645 | 645 | * Parse incoming $args into an array and merge it with $defaults |
646 | 646 | */ |
647 | - $args = wp_parse_args( $args, $defaults ); |
|
647 | + $args = wp_parse_args($args, $defaults); |
|
648 | 648 | $output = ''; |
649 | 649 | |
650 | 650 | // for now lets hide floating labels |
651 | - if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';} |
|
651 | + if ($args['label_type'] == 'floating') {$args['label_type'] = 'hidden'; } |
|
652 | 652 | |
653 | 653 | // hidden label option needs to be empty |
654 | 654 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
@@ -657,85 +657,85 @@ discard block |
||
657 | 657 | $label_after = $args['label_after']; |
658 | 658 | |
659 | 659 | // floating labels need label after |
660 | - if( $args['label_type'] == 'floating' ){ |
|
660 | + if ($args['label_type'] == 'floating') { |
|
661 | 661 | $label_after = true; |
662 | 662 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
663 | 663 | } |
664 | 664 | |
665 | 665 | // Maybe setup select2 |
666 | 666 | $is_select2 = false; |
667 | - if(!empty($args['select2'])){ |
|
667 | + if (!empty($args['select2'])) { |
|
668 | 668 | $args['class'] .= ' aui-select2'; |
669 | 669 | $is_select2 = true; |
670 | - }elseif( strpos($args['class'], 'aui-select2') !== false){ |
|
670 | + }elseif (strpos($args['class'], 'aui-select2') !== false) { |
|
671 | 671 | $is_select2 = true; |
672 | 672 | } |
673 | 673 | |
674 | 674 | // select2 tags |
675 | - if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason |
|
675 | + if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason |
|
676 | 676 | $args['data-tags'] = 'true'; |
677 | 677 | $args['data-token-separators'] = "[',']"; |
678 | 678 | $args['multiple'] = true; |
679 | 679 | } |
680 | 680 | |
681 | 681 | // select2 placeholder |
682 | - if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){ |
|
682 | + if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) { |
|
683 | 683 | $args['data-placeholder'] = esc_attr($args['placeholder']); |
684 | 684 | $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true; |
685 | 685 | } |
686 | 686 | |
687 | 687 | // label |
688 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
689 | - }elseif(!empty($args['label']) && !$label_after){ |
|
688 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
689 | + }elseif (!empty($args['label']) && !$label_after) { |
|
690 | 690 | $label_args = array( |
691 | 691 | 'title'=> $args['label'], |
692 | 692 | 'for'=> $args['id'], |
693 | - 'class' => $args['label_class']." ", |
|
693 | + 'class' => $args['label_class'] . " ", |
|
694 | 694 | 'label_type' => $args['label_type'] |
695 | 695 | ); |
696 | 696 | $output .= self::label($label_args); |
697 | 697 | } |
698 | 698 | |
699 | 699 | // maybe horizontal label |
700 | - if($args['label_type']=='horizontal'){ |
|
700 | + if ($args['label_type'] == 'horizontal') { |
|
701 | 701 | $output .= '<div class="col-sm-10">'; |
702 | 702 | } |
703 | 703 | |
704 | 704 | // Set hidden input to save empty value for multiselect. |
705 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) { |
|
706 | - $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>'; |
|
705 | + if (!empty($args['multiple']) && !empty($args['name'])) { |
|
706 | + $output .= '<input type="hidden" ' . AUI_Component_Helper::name($args['name']) . ' value=""/>'; |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | // open/type |
710 | 710 | $output .= '<select '; |
711 | 711 | |
712 | 712 | // style |
713 | - if($is_select2){ |
|
713 | + if ($is_select2) { |
|
714 | 714 | $output .= " style='width:100%;' "; |
715 | 715 | } |
716 | 716 | |
717 | 717 | // element require |
718 | - if(!empty($args['element_require'])){ |
|
718 | + if (!empty($args['element_require'])) { |
|
719 | 719 | $output .= AUI_Component_Helper::element_require($args['element_require']); |
720 | 720 | $args['class'] .= " aui-conditional-field"; |
721 | 721 | } |
722 | 722 | |
723 | 723 | // class |
724 | 724 | $class = !empty($args['class']) ? $args['class'] : ''; |
725 | - $output .= AUI_Component_Helper::class_attr('custom-select '.$class); |
|
725 | + $output .= AUI_Component_Helper::class_attr('custom-select ' . $class); |
|
726 | 726 | |
727 | 727 | // name |
728 | - if(!empty($args['name'])){ |
|
729 | - $output .= AUI_Component_Helper::name($args['name'],$args['multiple']); |
|
728 | + if (!empty($args['name'])) { |
|
729 | + $output .= AUI_Component_Helper::name($args['name'], $args['multiple']); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | // id |
733 | - if(!empty($args['id'])){ |
|
733 | + if (!empty($args['id'])) { |
|
734 | 734 | $output .= AUI_Component_Helper::id($args['id']); |
735 | 735 | } |
736 | 736 | |
737 | 737 | // title |
738 | - if(!empty($args['title'])){ |
|
738 | + if (!empty($args['title'])) { |
|
739 | 739 | $output .= AUI_Component_Helper::title($args['title']); |
740 | 740 | } |
741 | 741 | |
@@ -746,17 +746,17 @@ discard block |
||
746 | 746 | $output .= AUI_Component_Helper::aria_attributes($args); |
747 | 747 | |
748 | 748 | // extra attributes |
749 | - if(!empty($args['extra_attributes'])){ |
|
749 | + if (!empty($args['extra_attributes'])) { |
|
750 | 750 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
751 | 751 | } |
752 | 752 | |
753 | 753 | // required |
754 | - if(!empty($args['required'])){ |
|
754 | + if (!empty($args['required'])) { |
|
755 | 755 | $output .= ' required '; |
756 | 756 | } |
757 | 757 | |
758 | 758 | // multiple |
759 | - if(!empty($args['multiple'])){ |
|
759 | + if (!empty($args['multiple'])) { |
|
760 | 760 | $output .= ' multiple '; |
761 | 761 | } |
762 | 762 | |
@@ -764,21 +764,21 @@ discard block |
||
764 | 764 | $output .= ' >'; |
765 | 765 | |
766 | 766 | // placeholder |
767 | - if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){ |
|
768 | - $output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>'; |
|
769 | - }elseif($is_select2 && !empty($args['placeholder'])){ |
|
767 | + if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) { |
|
768 | + $output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>'; |
|
769 | + }elseif ($is_select2 && !empty($args['placeholder'])) { |
|
770 | 770 | $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
771 | 771 | } |
772 | 772 | |
773 | 773 | // Options |
774 | - if(!empty($args['options'])){ |
|
774 | + if (!empty($args['options'])) { |
|
775 | 775 | |
776 | - if(!is_array($args['options'])){ |
|
776 | + if (!is_array($args['options'])) { |
|
777 | 777 | $output .= $args['options']; // not the preferred way but an option |
778 | - }else{ |
|
779 | - foreach($args['options'] as $val => $name){ |
|
778 | + } else { |
|
779 | + foreach ($args['options'] as $val => $name) { |
|
780 | 780 | $selected = ''; |
781 | - if(is_array($name)){ |
|
781 | + if (is_array($name)) { |
|
782 | 782 | if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) { |
783 | 783 | $option_label = isset($name['label']) ? $name['label'] : ''; |
784 | 784 | |
@@ -786,23 +786,23 @@ discard block |
||
786 | 786 | } else { |
787 | 787 | $option_label = isset($name['label']) ? $name['label'] : ''; |
788 | 788 | $option_value = isset($name['value']) ? $name['value'] : ''; |
789 | - if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){ |
|
789 | + if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) { |
|
790 | 790 | $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : ""; |
791 | - } elseif(!empty($args['value'])) { |
|
792 | - $selected = selected($option_value,stripslashes_deep($args['value']), false); |
|
791 | + } elseif (!empty($args['value'])) { |
|
792 | + $selected = selected($option_value, stripslashes_deep($args['value']), false); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; |
796 | 796 | } |
797 | - }else{ |
|
798 | - if(!empty($args['value'])){ |
|
799 | - if(is_array($args['value'])){ |
|
800 | - $selected = in_array($val,$args['value']) ? 'selected="selected"' : ''; |
|
801 | - } elseif(!empty($args['value'])) { |
|
802 | - $selected = selected( $args['value'], $val, false); |
|
797 | + } else { |
|
798 | + if (!empty($args['value'])) { |
|
799 | + if (is_array($args['value'])) { |
|
800 | + $selected = in_array($val, $args['value']) ? 'selected="selected"' : ''; |
|
801 | + } elseif (!empty($args['value'])) { |
|
802 | + $selected = selected($args['value'], $val, false); |
|
803 | 803 | } |
804 | 804 | } |
805 | - $output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>'; |
|
805 | + $output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>'; |
|
806 | 806 | } |
807 | 807 | } |
808 | 808 | } |
@@ -812,31 +812,31 @@ discard block |
||
812 | 812 | // closing tag |
813 | 813 | $output .= '</select>'; |
814 | 814 | |
815 | - if(!empty($args['label']) && $label_after){ |
|
815 | + if (!empty($args['label']) && $label_after) { |
|
816 | 816 | $label_args = array( |
817 | 817 | 'title'=> $args['label'], |
818 | 818 | 'for'=> $args['id'], |
819 | - 'class' => $args['label_class']." ", |
|
819 | + 'class' => $args['label_class'] . " ", |
|
820 | 820 | 'label_type' => $args['label_type'] |
821 | 821 | ); |
822 | 822 | $output .= self::label($label_args); |
823 | 823 | } |
824 | 824 | |
825 | 825 | // help text |
826 | - if(!empty($args['help_text'])){ |
|
826 | + if (!empty($args['help_text'])) { |
|
827 | 827 | $output .= AUI_Component_Helper::help_text($args['help_text']); |
828 | 828 | } |
829 | 829 | |
830 | 830 | // maybe horizontal label |
831 | - if($args['label_type']=='horizontal'){ |
|
831 | + if ($args['label_type'] == 'horizontal') { |
|
832 | 832 | $output .= '</div>'; |
833 | 833 | } |
834 | 834 | |
835 | 835 | |
836 | 836 | // wrap |
837 | - if(!$args['no_wrap']){ |
|
838 | - $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
839 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
837 | + if (!$args['no_wrap']) { |
|
838 | + $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
|
839 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
840 | 840 | $output = self::wrap(array( |
841 | 841 | 'content' => $output, |
842 | 842 | 'class' => $wrap_class, |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | * |
857 | 857 | * @return string The rendered component. |
858 | 858 | */ |
859 | - public static function radio($args = array()){ |
|
859 | + public static function radio($args = array()) { |
|
860 | 860 | $defaults = array( |
861 | 861 | 'class' => '', |
862 | 862 | 'wrap_class' => '', |
@@ -880,14 +880,14 @@ discard block |
||
880 | 880 | /** |
881 | 881 | * Parse incoming $args into an array and merge it with $defaults |
882 | 882 | */ |
883 | - $args = wp_parse_args( $args, $defaults ); |
|
883 | + $args = wp_parse_args($args, $defaults); |
|
884 | 884 | |
885 | 885 | // for now lets use horizontal for floating |
886 | - if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';} |
|
886 | + if ($args['label_type'] == 'floating') {$args['label_type'] = 'horizontal'; } |
|
887 | 887 | |
888 | 888 | $label_args = array( |
889 | 889 | 'title'=> $args['label'], |
890 | - 'class' => $args['label_class']." pt-0 ", |
|
890 | + 'class' => $args['label_class'] . " pt-0 ", |
|
891 | 891 | 'label_type' => $args['label_type'] |
892 | 892 | ); |
893 | 893 | |
@@ -896,39 +896,39 @@ discard block |
||
896 | 896 | |
897 | 897 | |
898 | 898 | // label before |
899 | - if(!empty($args['label'])){ |
|
900 | - $output .= self::label( $label_args, 'radio' ); |
|
899 | + if (!empty($args['label'])) { |
|
900 | + $output .= self::label($label_args, 'radio'); |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | // maybe horizontal label |
904 | - if($args['label_type']=='horizontal'){ |
|
904 | + if ($args['label_type'] == 'horizontal') { |
|
905 | 905 | $output .= '<div class="col-sm-10">'; |
906 | 906 | } |
907 | 907 | |
908 | - if(!empty($args['options'])){ |
|
908 | + if (!empty($args['options'])) { |
|
909 | 909 | $count = 0; |
910 | - foreach($args['options'] as $value => $label){ |
|
910 | + foreach ($args['options'] as $value => $label) { |
|
911 | 911 | $option_args = $args; |
912 | 912 | $option_args['value'] = $value; |
913 | 913 | $option_args['label'] = $label; |
914 | 914 | $option_args['checked'] = $value == $args['value'] ? true : false; |
915 | - $output .= self::radio_option($option_args,$count); |
|
915 | + $output .= self::radio_option($option_args, $count); |
|
916 | 916 | $count++; |
917 | 917 | } |
918 | 918 | } |
919 | 919 | |
920 | 920 | // help text |
921 | - $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
921 | + $help_text = !empty($args['help_text']) ? AUI_Component_Helper::help_text($args['help_text']) : ''; |
|
922 | 922 | $output .= $help_text; |
923 | 923 | |
924 | 924 | // maybe horizontal label |
925 | - if($args['label_type']=='horizontal'){ |
|
925 | + if ($args['label_type'] == 'horizontal') { |
|
926 | 926 | $output .= '</div>'; |
927 | 927 | } |
928 | 928 | |
929 | 929 | // wrap |
930 | - $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
931 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
930 | + $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
|
931 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
932 | 932 | $output = self::wrap(array( |
933 | 933 | 'content' => $output, |
934 | 934 | 'class' => $wrap_class, |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | * |
948 | 948 | * @return string The rendered component. |
949 | 949 | */ |
950 | - public static function radio_option($args = array(),$count = ''){ |
|
950 | + public static function radio_option($args = array(), $count = '') { |
|
951 | 951 | $defaults = array( |
952 | 952 | 'class' => '', |
953 | 953 | 'id' => '', |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | /** |
966 | 966 | * Parse incoming $args into an array and merge it with $defaults |
967 | 967 | */ |
968 | - $args = wp_parse_args( $args, $defaults ); |
|
968 | + $args = wp_parse_args($args, $defaults); |
|
969 | 969 | |
970 | 970 | $output = ''; |
971 | 971 | |
@@ -976,27 +976,27 @@ discard block |
||
976 | 976 | $output .= ' class="form-check-input" '; |
977 | 977 | |
978 | 978 | // name |
979 | - if(!empty($args['name'])){ |
|
979 | + if (!empty($args['name'])) { |
|
980 | 980 | $output .= AUI_Component_Helper::name($args['name']); |
981 | 981 | } |
982 | 982 | |
983 | 983 | // id |
984 | - if(!empty($args['id'])){ |
|
985 | - $output .= AUI_Component_Helper::id($args['id'].$count); |
|
984 | + if (!empty($args['id'])) { |
|
985 | + $output .= AUI_Component_Helper::id($args['id'] . $count); |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | // title |
989 | - if(!empty($args['title'])){ |
|
989 | + if (!empty($args['title'])) { |
|
990 | 990 | $output .= AUI_Component_Helper::title($args['title']); |
991 | 991 | } |
992 | 992 | |
993 | 993 | // value |
994 | - if(isset($args['value'])){ |
|
995 | - $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
994 | + if (isset($args['value'])) { |
|
995 | + $output .= ' value="' . sanitize_text_field($args['value']) . '" '; |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | // checked, for radio and checkboxes |
999 | - if( $args['checked'] ){ |
|
999 | + if ($args['checked']) { |
|
1000 | 1000 | $output .= ' checked '; |
1001 | 1001 | } |
1002 | 1002 | |
@@ -1007,12 +1007,12 @@ discard block |
||
1007 | 1007 | $output .= AUI_Component_Helper::aria_attributes($args); |
1008 | 1008 | |
1009 | 1009 | // extra attributes |
1010 | - if(!empty($args['extra_attributes'])){ |
|
1010 | + if (!empty($args['extra_attributes'])) { |
|
1011 | 1011 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | // required |
1015 | - if(!empty($args['required'])){ |
|
1015 | + if (!empty($args['required'])) { |
|
1016 | 1016 | $output .= ' required '; |
1017 | 1017 | } |
1018 | 1018 | |
@@ -1020,13 +1020,13 @@ discard block |
||
1020 | 1020 | $output .= ' >'; |
1021 | 1021 | |
1022 | 1022 | // label |
1023 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
1024 | - }elseif(!empty($args['label'])){ |
|
1025 | - $output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio'); |
|
1023 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
1024 | + }elseif (!empty($args['label'])) { |
|
1025 | + $output .= self::label(array('title'=>$args['label'], 'for'=>$args['id'] . $count, 'class'=>'form-check-label'), 'radio'); |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | // wrap |
1029 | - if(!$args['no_wrap']){ |
|
1029 | + if (!$args['no_wrap']) { |
|
1030 | 1030 | $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
1031 | 1031 | $output = self::wrap(array( |
1032 | 1032 | 'content' => $output, |
@@ -1,7 +1,7 @@ discard block |
||
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,231 +11,231 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class AUI { |
13 | 13 | |
14 | - /** |
|
15 | - * Holds the class instance. |
|
16 | - * |
|
17 | - * @since 1.0.0 |
|
18 | - * @var null |
|
19 | - */ |
|
20 | - private static $instance = null; |
|
21 | - |
|
22 | - /** |
|
23 | - * Holds the current AUI version number. |
|
24 | - * |
|
25 | - * @var string $ver The current version number. |
|
26 | - */ |
|
27 | - public static $ver = '0.1.49'; |
|
28 | - |
|
29 | - public static $options = null; |
|
30 | - |
|
31 | - /** |
|
32 | - * There can be only one. |
|
33 | - * |
|
34 | - * @since 1.0.0 |
|
35 | - * @return AUI|null |
|
36 | - */ |
|
37 | - public static function instance() { |
|
38 | - if ( self::$instance == null ) { |
|
39 | - self::$instance = new AUI(); |
|
40 | - } |
|
41 | - |
|
42 | - return self::$instance; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * AUI constructor. |
|
47 | - * |
|
48 | - * @since 1.0.0 |
|
49 | - */ |
|
50 | - private function __construct() { |
|
51 | - if ( function_exists( "__autoload" ) ) { |
|
52 | - spl_autoload_register( "__autoload" ); |
|
53 | - } |
|
54 | - spl_autoload_register( array( $this, 'autoload' ) ); |
|
55 | - |
|
56 | - // load options |
|
57 | - self::$options = get_option('aui_options'); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Autoload any components on the fly. |
|
62 | - * |
|
63 | - * @since 1.0.0 |
|
64 | - * |
|
65 | - * @param $classname |
|
66 | - */ |
|
67 | - private function autoload( $classname ) { |
|
68 | - $class = str_replace( '_', '-', strtolower( $classname ) ); |
|
69 | - $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php'; |
|
70 | - if ( $file_path && is_readable( $file_path ) ) { |
|
71 | - include_once( $file_path ); |
|
72 | - } |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Get the AUI options. |
|
77 | - * |
|
78 | - * @param $option |
|
79 | - * |
|
80 | - * @return string|void |
|
81 | - */ |
|
82 | - public function get_option( $option ){ |
|
83 | - $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : ''; |
|
84 | - |
|
85 | - if ( ! $result && $option) { |
|
86 | - if( $option == 'color_primary' ){ |
|
87 | - $result = AUI_PRIMARY_COLOR; |
|
88 | - }elseif( $option == 'color_secondary' ){ |
|
89 | - $result = AUI_SECONDARY_COLOR; |
|
90 | - } |
|
91 | - } |
|
92 | - return $result; |
|
93 | - } |
|
94 | - |
|
95 | - public function render( $items = array() ) { |
|
96 | - $output = ''; |
|
97 | - |
|
98 | - if ( ! empty( $items ) ) { |
|
99 | - foreach ( $items as $args ) { |
|
100 | - $render = isset( $args['render'] ) ? $args['render'] : ''; |
|
101 | - if ( $render && method_exists( __CLASS__, $render ) ) { |
|
102 | - $output .= $this->$render( $args ); |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - return $output; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Render and return a bootstrap alert component. |
|
112 | - * |
|
113 | - * @since 1.0.0 |
|
114 | - * |
|
115 | - * @param array $args |
|
116 | - * |
|
117 | - * @return string The rendered component. |
|
118 | - */ |
|
119 | - public function alert( $args = array() ) { |
|
120 | - return AUI_Component_Alert::get( $args ); |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Render and return a bootstrap input component. |
|
125 | - * |
|
126 | - * @since 1.0.0 |
|
127 | - * |
|
128 | - * @param array $args |
|
129 | - * |
|
130 | - * @return string The rendered component. |
|
131 | - */ |
|
132 | - public function input( $args = array() ) { |
|
133 | - return AUI_Component_Input::input( $args ); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Render and return a bootstrap textarea component. |
|
138 | - * |
|
139 | - * @since 1.0.0 |
|
140 | - * |
|
141 | - * @param array $args |
|
142 | - * |
|
143 | - * @return string The rendered component. |
|
144 | - */ |
|
145 | - public function textarea( $args = array() ) { |
|
146 | - return AUI_Component_Input::textarea( $args ); |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * Render and return a bootstrap button component. |
|
151 | - * |
|
152 | - * @since 1.0.0 |
|
153 | - * |
|
154 | - * @param array $args |
|
155 | - * |
|
156 | - * @return string The rendered component. |
|
157 | - */ |
|
158 | - public function button( $args = array() ) { |
|
159 | - return AUI_Component_Button::get( $args ); |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * Render and return a bootstrap button component. |
|
164 | - * |
|
165 | - * @since 1.0.0 |
|
166 | - * |
|
167 | - * @param array $args |
|
168 | - * |
|
169 | - * @return string The rendered component. |
|
170 | - */ |
|
171 | - public function badge( $args = array() ) { |
|
172 | - $defaults = array( |
|
173 | - 'class' => 'badge badge-primary align-middle', |
|
174 | - ); |
|
175 | - |
|
176 | - // maybe set type |
|
177 | - if ( empty( $args['href'] ) ) { |
|
178 | - $defaults['type'] = 'badge'; |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * Parse incoming $args into an array and merge it with $defaults |
|
183 | - */ |
|
184 | - $args = wp_parse_args( $args, $defaults ); |
|
185 | - |
|
186 | - return AUI_Component_Button::get( $args ); |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Render and return a bootstrap dropdown component. |
|
191 | - * |
|
192 | - * @since 1.0.0 |
|
193 | - * |
|
194 | - * @param array $args |
|
195 | - * |
|
196 | - * @return string The rendered component. |
|
197 | - */ |
|
198 | - public function dropdown( $args = array() ) { |
|
199 | - return AUI_Component_Dropdown::get( $args ); |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * Render and return a bootstrap select component. |
|
204 | - * |
|
205 | - * @since 1.0.0 |
|
206 | - * |
|
207 | - * @param array $args |
|
208 | - * |
|
209 | - * @return string The rendered component. |
|
210 | - */ |
|
211 | - public function select( $args = array() ) { |
|
212 | - return AUI_Component_Input::select( $args ); |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Render and return a bootstrap radio component. |
|
217 | - * |
|
218 | - * @since 1.0.0 |
|
219 | - * |
|
220 | - * @param array $args |
|
221 | - * |
|
222 | - * @return string The rendered component. |
|
223 | - */ |
|
224 | - public function radio( $args = array() ) { |
|
225 | - return AUI_Component_Input::radio( $args ); |
|
226 | - } |
|
227 | - |
|
228 | - /** |
|
229 | - * Render and return a bootstrap pagination component. |
|
230 | - * |
|
231 | - * @since 1.0.0 |
|
232 | - * |
|
233 | - * @param array $args |
|
234 | - * |
|
235 | - * @return string The rendered component. |
|
236 | - */ |
|
237 | - public function pagination( $args = array() ) { |
|
238 | - return AUI_Component_Pagination::get( $args ); |
|
239 | - } |
|
14 | + /** |
|
15 | + * Holds the class instance. |
|
16 | + * |
|
17 | + * @since 1.0.0 |
|
18 | + * @var null |
|
19 | + */ |
|
20 | + private static $instance = null; |
|
21 | + |
|
22 | + /** |
|
23 | + * Holds the current AUI version number. |
|
24 | + * |
|
25 | + * @var string $ver The current version number. |
|
26 | + */ |
|
27 | + public static $ver = '0.1.49'; |
|
28 | + |
|
29 | + public static $options = null; |
|
30 | + |
|
31 | + /** |
|
32 | + * There can be only one. |
|
33 | + * |
|
34 | + * @since 1.0.0 |
|
35 | + * @return AUI|null |
|
36 | + */ |
|
37 | + public static function instance() { |
|
38 | + if ( self::$instance == null ) { |
|
39 | + self::$instance = new AUI(); |
|
40 | + } |
|
41 | + |
|
42 | + return self::$instance; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * AUI constructor. |
|
47 | + * |
|
48 | + * @since 1.0.0 |
|
49 | + */ |
|
50 | + private function __construct() { |
|
51 | + if ( function_exists( "__autoload" ) ) { |
|
52 | + spl_autoload_register( "__autoload" ); |
|
53 | + } |
|
54 | + spl_autoload_register( array( $this, 'autoload' ) ); |
|
55 | + |
|
56 | + // load options |
|
57 | + self::$options = get_option('aui_options'); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Autoload any components on the fly. |
|
62 | + * |
|
63 | + * @since 1.0.0 |
|
64 | + * |
|
65 | + * @param $classname |
|
66 | + */ |
|
67 | + private function autoload( $classname ) { |
|
68 | + $class = str_replace( '_', '-', strtolower( $classname ) ); |
|
69 | + $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php'; |
|
70 | + if ( $file_path && is_readable( $file_path ) ) { |
|
71 | + include_once( $file_path ); |
|
72 | + } |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Get the AUI options. |
|
77 | + * |
|
78 | + * @param $option |
|
79 | + * |
|
80 | + * @return string|void |
|
81 | + */ |
|
82 | + public function get_option( $option ){ |
|
83 | + $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : ''; |
|
84 | + |
|
85 | + if ( ! $result && $option) { |
|
86 | + if( $option == 'color_primary' ){ |
|
87 | + $result = AUI_PRIMARY_COLOR; |
|
88 | + }elseif( $option == 'color_secondary' ){ |
|
89 | + $result = AUI_SECONDARY_COLOR; |
|
90 | + } |
|
91 | + } |
|
92 | + return $result; |
|
93 | + } |
|
94 | + |
|
95 | + public function render( $items = array() ) { |
|
96 | + $output = ''; |
|
97 | + |
|
98 | + if ( ! empty( $items ) ) { |
|
99 | + foreach ( $items as $args ) { |
|
100 | + $render = isset( $args['render'] ) ? $args['render'] : ''; |
|
101 | + if ( $render && method_exists( __CLASS__, $render ) ) { |
|
102 | + $output .= $this->$render( $args ); |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + return $output; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Render and return a bootstrap alert component. |
|
112 | + * |
|
113 | + * @since 1.0.0 |
|
114 | + * |
|
115 | + * @param array $args |
|
116 | + * |
|
117 | + * @return string The rendered component. |
|
118 | + */ |
|
119 | + public function alert( $args = array() ) { |
|
120 | + return AUI_Component_Alert::get( $args ); |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Render and return a bootstrap input component. |
|
125 | + * |
|
126 | + * @since 1.0.0 |
|
127 | + * |
|
128 | + * @param array $args |
|
129 | + * |
|
130 | + * @return string The rendered component. |
|
131 | + */ |
|
132 | + public function input( $args = array() ) { |
|
133 | + return AUI_Component_Input::input( $args ); |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Render and return a bootstrap textarea component. |
|
138 | + * |
|
139 | + * @since 1.0.0 |
|
140 | + * |
|
141 | + * @param array $args |
|
142 | + * |
|
143 | + * @return string The rendered component. |
|
144 | + */ |
|
145 | + public function textarea( $args = array() ) { |
|
146 | + return AUI_Component_Input::textarea( $args ); |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * Render and return a bootstrap button component. |
|
151 | + * |
|
152 | + * @since 1.0.0 |
|
153 | + * |
|
154 | + * @param array $args |
|
155 | + * |
|
156 | + * @return string The rendered component. |
|
157 | + */ |
|
158 | + public function button( $args = array() ) { |
|
159 | + return AUI_Component_Button::get( $args ); |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * Render and return a bootstrap button component. |
|
164 | + * |
|
165 | + * @since 1.0.0 |
|
166 | + * |
|
167 | + * @param array $args |
|
168 | + * |
|
169 | + * @return string The rendered component. |
|
170 | + */ |
|
171 | + public function badge( $args = array() ) { |
|
172 | + $defaults = array( |
|
173 | + 'class' => 'badge badge-primary align-middle', |
|
174 | + ); |
|
175 | + |
|
176 | + // maybe set type |
|
177 | + if ( empty( $args['href'] ) ) { |
|
178 | + $defaults['type'] = 'badge'; |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * Parse incoming $args into an array and merge it with $defaults |
|
183 | + */ |
|
184 | + $args = wp_parse_args( $args, $defaults ); |
|
185 | + |
|
186 | + return AUI_Component_Button::get( $args ); |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Render and return a bootstrap dropdown component. |
|
191 | + * |
|
192 | + * @since 1.0.0 |
|
193 | + * |
|
194 | + * @param array $args |
|
195 | + * |
|
196 | + * @return string The rendered component. |
|
197 | + */ |
|
198 | + public function dropdown( $args = array() ) { |
|
199 | + return AUI_Component_Dropdown::get( $args ); |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * Render and return a bootstrap select component. |
|
204 | + * |
|
205 | + * @since 1.0.0 |
|
206 | + * |
|
207 | + * @param array $args |
|
208 | + * |
|
209 | + * @return string The rendered component. |
|
210 | + */ |
|
211 | + public function select( $args = array() ) { |
|
212 | + return AUI_Component_Input::select( $args ); |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Render and return a bootstrap radio component. |
|
217 | + * |
|
218 | + * @since 1.0.0 |
|
219 | + * |
|
220 | + * @param array $args |
|
221 | + * |
|
222 | + * @return string The rendered component. |
|
223 | + */ |
|
224 | + public function radio( $args = array() ) { |
|
225 | + return AUI_Component_Input::radio( $args ); |
|
226 | + } |
|
227 | + |
|
228 | + /** |
|
229 | + * Render and return a bootstrap pagination component. |
|
230 | + * |
|
231 | + * @since 1.0.0 |
|
232 | + * |
|
233 | + * @param array $args |
|
234 | + * |
|
235 | + * @return string The rendered component. |
|
236 | + */ |
|
237 | + public function pagination( $args = array() ) { |
|
238 | + return AUI_Component_Pagination::get( $args ); |
|
239 | + } |
|
240 | 240 | |
241 | 241 | } |
242 | 242 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
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,236 +21,236 @@ discard block |
||
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.1.49'; |
|
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 = "4.5.3"; |
|
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 | - * Main AyeCode_UI_Settings Instance. |
|
93 | - * |
|
94 | - * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
95 | - * |
|
96 | - * @since 1.0.0 |
|
97 | - * @static |
|
98 | - * @return AyeCode_UI_Settings - Main instance. |
|
99 | - */ |
|
100 | - public static function instance() { |
|
101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
102 | - |
|
103 | - self::$instance = new AyeCode_UI_Settings; |
|
104 | - |
|
105 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
106 | - |
|
107 | - if ( is_admin() ) { |
|
108 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
109 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
110 | - |
|
111 | - // Maybe show example page |
|
112 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
113 | - } |
|
114 | - |
|
115 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
116 | - |
|
117 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
118 | - } |
|
119 | - |
|
120 | - return self::$instance; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Setup some constants. |
|
125 | - */ |
|
126 | - public function constants(){ |
|
127 | - define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
|
128 | - define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
|
129 | - if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
130 | - if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Initiate the settings and add the required action hooks. |
|
135 | - */ |
|
136 | - public function init() { |
|
137 | - $this->constants(); |
|
138 | - $this->settings = $this->get_settings(); |
|
139 | - $this->url = $this->get_url(); |
|
140 | - |
|
141 | - /** |
|
142 | - * Maybe load CSS |
|
143 | - * |
|
144 | - * We load super early in case there is a theme version that might change the colors |
|
145 | - */ |
|
146 | - if ( $this->settings['css'] ) { |
|
147 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
148 | - } |
|
149 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
150 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
151 | - } |
|
152 | - |
|
153 | - // maybe load JS |
|
154 | - if ( $this->settings['js'] ) { |
|
155 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
156 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
157 | - } |
|
158 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
159 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
160 | - } |
|
161 | - |
|
162 | - // Maybe set the HTML font size |
|
163 | - if ( $this->settings['html_font_size'] ) { |
|
164 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Check if we should load the admin scripts or not. |
|
172 | - * |
|
173 | - * @return bool |
|
174 | - */ |
|
175 | - public function load_admin_scripts(){ |
|
176 | - $result = true; |
|
177 | - |
|
178 | - // check if specifically disabled |
|
179 | - if(!empty($this->settings['disable_admin'])){ |
|
180 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
181 | - foreach($url_parts as $part){ |
|
182 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
183 | - return false; // return early, no point checking further |
|
184 | - } |
|
185 | - } |
|
186 | - } |
|
187 | - |
|
188 | - return $result; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Add a html font size to the footer. |
|
193 | - */ |
|
194 | - public function html_font_size(){ |
|
195 | - $this->settings = $this->get_settings(); |
|
196 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
197 | - } |
|
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.1.49'; |
|
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 = "4.5.3"; |
|
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 | + * Main AyeCode_UI_Settings Instance. |
|
93 | + * |
|
94 | + * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
95 | + * |
|
96 | + * @since 1.0.0 |
|
97 | + * @static |
|
98 | + * @return AyeCode_UI_Settings - Main instance. |
|
99 | + */ |
|
100 | + public static function instance() { |
|
101 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
102 | + |
|
103 | + self::$instance = new AyeCode_UI_Settings; |
|
104 | + |
|
105 | + add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
106 | + |
|
107 | + if ( is_admin() ) { |
|
108 | + add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
109 | + add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
110 | + |
|
111 | + // Maybe show example page |
|
112 | + add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
113 | + } |
|
198 | 114 | |
199 | - /** |
|
200 | - * Check if the current admin screen should load scripts. |
|
201 | - * |
|
202 | - * @return bool |
|
203 | - */ |
|
204 | - public function is_aui_screen(){ |
|
205 | - $load = false; |
|
206 | - // check if we should load or not |
|
207 | - if ( is_admin() ) { |
|
208 | - // Only enable on set pages |
|
209 | - $aui_screens = array( |
|
210 | - 'page', |
|
211 | - 'post', |
|
212 | - 'settings_page_ayecode-ui-settings', |
|
213 | - 'appearance_page_gutenberg-widgets' |
|
214 | - ); |
|
215 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
216 | - |
|
217 | - $screen = get_current_screen(); |
|
115 | + add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
116 | + |
|
117 | + do_action( 'ayecode_ui_settings_loaded' ); |
|
118 | + } |
|
119 | + |
|
120 | + return self::$instance; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Setup some constants. |
|
125 | + */ |
|
126 | + public function constants(){ |
|
127 | + define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
|
128 | + define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
|
129 | + if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
130 | + if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Initiate the settings and add the required action hooks. |
|
135 | + */ |
|
136 | + public function init() { |
|
137 | + $this->constants(); |
|
138 | + $this->settings = $this->get_settings(); |
|
139 | + $this->url = $this->get_url(); |
|
140 | + |
|
141 | + /** |
|
142 | + * Maybe load CSS |
|
143 | + * |
|
144 | + * We load super early in case there is a theme version that might change the colors |
|
145 | + */ |
|
146 | + if ( $this->settings['css'] ) { |
|
147 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
148 | + } |
|
149 | + if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
150 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
151 | + } |
|
152 | + |
|
153 | + // maybe load JS |
|
154 | + if ( $this->settings['js'] ) { |
|
155 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
156 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
157 | + } |
|
158 | + if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
159 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
160 | + } |
|
161 | + |
|
162 | + // Maybe set the HTML font size |
|
163 | + if ( $this->settings['html_font_size'] ) { |
|
164 | + add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Check if we should load the admin scripts or not. |
|
172 | + * |
|
173 | + * @return bool |
|
174 | + */ |
|
175 | + public function load_admin_scripts(){ |
|
176 | + $result = true; |
|
177 | + |
|
178 | + // check if specifically disabled |
|
179 | + if(!empty($this->settings['disable_admin'])){ |
|
180 | + $url_parts = explode("\n",$this->settings['disable_admin']); |
|
181 | + foreach($url_parts as $part){ |
|
182 | + if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
183 | + return false; // return early, no point checking further |
|
184 | + } |
|
185 | + } |
|
186 | + } |
|
187 | + |
|
188 | + return $result; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Add a html font size to the footer. |
|
193 | + */ |
|
194 | + public function html_font_size(){ |
|
195 | + $this->settings = $this->get_settings(); |
|
196 | + echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Check if the current admin screen should load scripts. |
|
201 | + * |
|
202 | + * @return bool |
|
203 | + */ |
|
204 | + public function is_aui_screen(){ |
|
205 | + $load = false; |
|
206 | + // check if we should load or not |
|
207 | + if ( is_admin() ) { |
|
208 | + // Only enable on set pages |
|
209 | + $aui_screens = array( |
|
210 | + 'page', |
|
211 | + 'post', |
|
212 | + 'settings_page_ayecode-ui-settings', |
|
213 | + 'appearance_page_gutenberg-widgets' |
|
214 | + ); |
|
215 | + $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
216 | + |
|
217 | + $screen = get_current_screen(); |
|
218 | 218 | |
219 | 219 | // echo '###'.$screen->id; |
220 | 220 | |
221 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
222 | - $load = true; |
|
223 | - } |
|
224 | - } |
|
221 | + if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
222 | + $load = true; |
|
223 | + } |
|
224 | + } |
|
225 | 225 | |
226 | - return $load; |
|
227 | - } |
|
226 | + return $load; |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * Adds the styles. |
|
231 | - */ |
|
232 | - public function enqueue_style() { |
|
229 | + /** |
|
230 | + * Adds the styles. |
|
231 | + */ |
|
232 | + public function enqueue_style() { |
|
233 | 233 | |
234 | - if( is_admin() && !$this->is_aui_screen()){ |
|
235 | - // don't add wp-admin scripts if not requested to |
|
236 | - }else{ |
|
237 | - $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
234 | + if( is_admin() && !$this->is_aui_screen()){ |
|
235 | + // don't add wp-admin scripts if not requested to |
|
236 | + }else{ |
|
237 | + $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
238 | 238 | |
239 | - $rtl = is_rtl() ? '-rtl' : ''; |
|
239 | + $rtl = is_rtl() ? '-rtl' : ''; |
|
240 | 240 | |
241 | - if($this->settings[$css_setting]){ |
|
242 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
243 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
244 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
245 | - wp_enqueue_style( 'ayecode-ui' ); |
|
241 | + if($this->settings[$css_setting]){ |
|
242 | + $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
243 | + $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
244 | + wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
245 | + wp_enqueue_style( 'ayecode-ui' ); |
|
246 | 246 | |
247 | - // flatpickr |
|
248 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
247 | + // flatpickr |
|
248 | + wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
249 | 249 | |
250 | 250 | |
251 | - // fix some wp-admin issues |
|
252 | - if(is_admin()){ |
|
253 | - $custom_css = " |
|
251 | + // fix some wp-admin issues |
|
252 | + if(is_admin()){ |
|
253 | + $custom_css = " |
|
254 | 254 | body{ |
255 | 255 | background-color: #f1f1f1; |
256 | 256 | font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; |
@@ -292,35 +292,35 @@ discard block |
||
292 | 292 | } |
293 | 293 | "; |
294 | 294 | |
295 | - // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
296 | - $custom_css .= " |
|
295 | + // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
296 | + $custom_css .= " |
|
297 | 297 | .edit-post-sidebar input[type=color].components-text-control__input{ |
298 | 298 | padding: 0; |
299 | 299 | } |
300 | 300 | "; |
301 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
302 | - } |
|
301 | + wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
302 | + } |
|
303 | 303 | |
304 | - // custom changes |
|
305 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
304 | + // custom changes |
|
305 | + wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
306 | 306 | |
307 | - } |
|
308 | - } |
|
307 | + } |
|
308 | + } |
|
309 | 309 | |
310 | 310 | |
311 | - } |
|
311 | + } |
|
312 | + |
|
313 | + /** |
|
314 | + * Get inline script used if bootstrap enqueued |
|
315 | + * |
|
316 | + * If this remains small then its best to use this than to add another JS file. |
|
317 | + */ |
|
318 | + public function inline_script() { |
|
319 | + // Flatpickr calendar locale |
|
320 | + $flatpickr_locale = self::flatpickr_locale(); |
|
312 | 321 | |
313 | - /** |
|
314 | - * Get inline script used if bootstrap enqueued |
|
315 | - * |
|
316 | - * If this remains small then its best to use this than to add another JS file. |
|
317 | - */ |
|
318 | - public function inline_script() { |
|
319 | - // Flatpickr calendar locale |
|
320 | - $flatpickr_locale = self::flatpickr_locale(); |
|
321 | - |
|
322 | - ob_start(); |
|
323 | - ?> |
|
322 | + ob_start(); |
|
323 | + ?> |
|
324 | 324 | <script> |
325 | 325 | /** |
326 | 326 | * An AUI bootstrap adaptation of GreedyNav.js ( by Luke Jackson ). |
@@ -985,29 +985,29 @@ discard block |
||
985 | 985 | |
986 | 986 | </script> |
987 | 987 | <?php |
988 | - $output = ob_get_clean(); |
|
988 | + $output = ob_get_clean(); |
|
989 | 989 | |
990 | 990 | |
991 | 991 | |
992 | - /* |
|
992 | + /* |
|
993 | 993 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
994 | 994 | */ |
995 | - return str_replace( array( |
|
996 | - '<script>', |
|
997 | - '</script>' |
|
998 | - ), '', self::minify_js($output) ); |
|
999 | - } |
|
1000 | - |
|
1001 | - |
|
1002 | - /** |
|
1003 | - * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1004 | - * |
|
1005 | - * @TODO we may need this when other conflicts arrise. |
|
1006 | - * @return mixed |
|
1007 | - */ |
|
1008 | - public static function bs3_compat_js() { |
|
1009 | - ob_start(); |
|
1010 | - ?> |
|
995 | + return str_replace( array( |
|
996 | + '<script>', |
|
997 | + '</script>' |
|
998 | + ), '', self::minify_js($output) ); |
|
999 | + } |
|
1000 | + |
|
1001 | + |
|
1002 | + /** |
|
1003 | + * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1004 | + * |
|
1005 | + * @TODO we may need this when other conflicts arrise. |
|
1006 | + * @return mixed |
|
1007 | + */ |
|
1008 | + public static function bs3_compat_js() { |
|
1009 | + ob_start(); |
|
1010 | + ?> |
|
1011 | 1011 | <script> |
1012 | 1012 | <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
1013 | 1013 | /* With Avada builder */ |
@@ -1015,20 +1015,20 @@ discard block |
||
1015 | 1015 | <?php } ?> |
1016 | 1016 | </script> |
1017 | 1017 | <?php |
1018 | - return str_replace( array( |
|
1019 | - '<script>', |
|
1020 | - '</script>' |
|
1021 | - ), '', ob_get_clean()); |
|
1022 | - } |
|
1023 | - |
|
1024 | - /** |
|
1025 | - * Get inline script used if bootstrap file browser enqueued. |
|
1026 | - * |
|
1027 | - * If this remains small then its best to use this than to add another JS file. |
|
1028 | - */ |
|
1029 | - public function inline_script_file_browser(){ |
|
1030 | - ob_start(); |
|
1031 | - ?> |
|
1018 | + return str_replace( array( |
|
1019 | + '<script>', |
|
1020 | + '</script>' |
|
1021 | + ), '', ob_get_clean()); |
|
1022 | + } |
|
1023 | + |
|
1024 | + /** |
|
1025 | + * Get inline script used if bootstrap file browser enqueued. |
|
1026 | + * |
|
1027 | + * If this remains small then its best to use this than to add another JS file. |
|
1028 | + */ |
|
1029 | + public function inline_script_file_browser(){ |
|
1030 | + ob_start(); |
|
1031 | + ?> |
|
1032 | 1032 | <script> |
1033 | 1033 | // run on doc ready |
1034 | 1034 | jQuery(document).ready(function () { |
@@ -1036,192 +1036,192 @@ discard block |
||
1036 | 1036 | }); |
1037 | 1037 | </script> |
1038 | 1038 | <?php |
1039 | - $output = ob_get_clean(); |
|
1039 | + $output = ob_get_clean(); |
|
1040 | 1040 | |
1041 | - /* |
|
1041 | + /* |
|
1042 | 1042 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1043 | 1043 | */ |
1044 | - return str_replace( array( |
|
1045 | - '<script>', |
|
1046 | - '</script>' |
|
1047 | - ), '', $output ); |
|
1048 | - } |
|
1049 | - |
|
1050 | - /** |
|
1051 | - * Adds the Font Awesome JS. |
|
1052 | - */ |
|
1053 | - public function enqueue_scripts() { |
|
1054 | - |
|
1055 | - if( is_admin() && !$this->is_aui_screen()){ |
|
1056 | - // don't add wp-admin scripts if not requested to |
|
1057 | - }else { |
|
1058 | - |
|
1059 | - $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
1060 | - |
|
1061 | - // select2 |
|
1062 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
1063 | - |
|
1064 | - // flatpickr |
|
1065 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
1066 | - |
|
1067 | - // Bootstrap file browser |
|
1068 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
1069 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
1070 | - |
|
1071 | - $load_inline = false; |
|
1072 | - |
|
1073 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
1074 | - // Bootstrap bundle |
|
1075 | - $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
1076 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
1077 | - 'select2', |
|
1078 | - 'jquery' |
|
1079 | - ), $this->latest, $this->is_bs3_compat() ); |
|
1080 | - // if in admin then add to footer for compatibility. |
|
1081 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
1082 | - $script = $this->inline_script(); |
|
1083 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
1084 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
1085 | - $url = $this->url . 'assets/js/popper.min.js'; |
|
1086 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
|
1087 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
1088 | - $load_inline = true; |
|
1089 | - } else { |
|
1090 | - $load_inline = true; |
|
1091 | - } |
|
1092 | - |
|
1093 | - // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
1094 | - if ( $load_inline ) { |
|
1095 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
1096 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
1097 | - $script = $this->inline_script(); |
|
1098 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
1099 | - } |
|
1100 | - } |
|
1101 | - |
|
1102 | - } |
|
1103 | - |
|
1104 | - /** |
|
1105 | - * Enqueue flatpickr if called. |
|
1106 | - */ |
|
1107 | - public function enqueue_flatpickr(){ |
|
1108 | - wp_enqueue_style( 'flatpickr' ); |
|
1109 | - wp_enqueue_script( 'flatpickr' ); |
|
1110 | - } |
|
1111 | - |
|
1112 | - /** |
|
1113 | - * Get the url path to the current folder. |
|
1114 | - * |
|
1115 | - * @return string |
|
1116 | - */ |
|
1117 | - public function get_url() { |
|
1118 | - |
|
1119 | - $url = ''; |
|
1120 | - // check if we are inside a plugin |
|
1121 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
1122 | - |
|
1123 | - // add check in-case user has changed wp-content dir name. |
|
1124 | - $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
1125 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
1126 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
1127 | - |
|
1128 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
1129 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
1130 | - } |
|
1131 | - |
|
1132 | - return $url; |
|
1133 | - } |
|
1134 | - |
|
1135 | - /** |
|
1136 | - * Register the database settings with WordPress. |
|
1137 | - */ |
|
1138 | - public function register_settings() { |
|
1139 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
1140 | - } |
|
1141 | - |
|
1142 | - /** |
|
1143 | - * Add the WordPress settings menu item. |
|
1144 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
1145 | - */ |
|
1146 | - public function menu_item() { |
|
1147 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
1148 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
1149 | - $this, |
|
1150 | - 'settings_page' |
|
1151 | - ) ); |
|
1152 | - } |
|
1153 | - |
|
1154 | - /** |
|
1155 | - * Get a list of themes and their default JS settings. |
|
1156 | - * |
|
1157 | - * @return array |
|
1158 | - */ |
|
1159 | - public function theme_js_settings(){ |
|
1160 | - return array( |
|
1161 | - 'ayetheme' => 'popper', |
|
1162 | - 'listimia' => 'required', |
|
1163 | - 'listimia_backend' => 'core-popper', |
|
1164 | - //'avada' => 'required', // removed as we now add compatibility |
|
1165 | - ); |
|
1166 | - } |
|
1167 | - |
|
1168 | - /** |
|
1169 | - * Get the current Font Awesome output settings. |
|
1170 | - * |
|
1171 | - * @return array The array of settings. |
|
1172 | - */ |
|
1173 | - public function get_settings() { |
|
1174 | - |
|
1175 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
1176 | - $js_default = 'core-popper'; |
|
1177 | - $js_default_backend = $js_default; |
|
1178 | - |
|
1179 | - // maybe set defaults (if no settings set) |
|
1180 | - if(empty($db_settings)){ |
|
1181 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
1182 | - $theme_js_settings = self::theme_js_settings(); |
|
1183 | - if(isset($theme_js_settings[$active_theme])){ |
|
1184 | - $js_default = $theme_js_settings[$active_theme]; |
|
1185 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
1186 | - } |
|
1187 | - } |
|
1188 | - |
|
1189 | - $defaults = array( |
|
1190 | - 'css' => 'compatibility', // core, compatibility |
|
1191 | - 'js' => $js_default, // js to load, core-popper, popper |
|
1192 | - 'html_font_size' => '16', // js to load, core-popper, popper |
|
1193 | - 'css_backend' => 'compatibility', // core, compatibility |
|
1194 | - 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
1195 | - 'disable_admin' => '', // URL snippets to disable loading on admin |
|
1196 | - ); |
|
1197 | - |
|
1198 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
1199 | - |
|
1200 | - /** |
|
1201 | - * Filter the Bootstrap settings. |
|
1202 | - * |
|
1203 | - * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
1204 | - */ |
|
1205 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
1206 | - } |
|
1207 | - |
|
1044 | + return str_replace( array( |
|
1045 | + '<script>', |
|
1046 | + '</script>' |
|
1047 | + ), '', $output ); |
|
1048 | + } |
|
1049 | + |
|
1050 | + /** |
|
1051 | + * Adds the Font Awesome JS. |
|
1052 | + */ |
|
1053 | + public function enqueue_scripts() { |
|
1054 | + |
|
1055 | + if( is_admin() && !$this->is_aui_screen()){ |
|
1056 | + // don't add wp-admin scripts if not requested to |
|
1057 | + }else { |
|
1058 | + |
|
1059 | + $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
1060 | + |
|
1061 | + // select2 |
|
1062 | + wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
1063 | + |
|
1064 | + // flatpickr |
|
1065 | + wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
1066 | + |
|
1067 | + // Bootstrap file browser |
|
1068 | + wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
1069 | + wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
1070 | + |
|
1071 | + $load_inline = false; |
|
1072 | + |
|
1073 | + if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
1074 | + // Bootstrap bundle |
|
1075 | + $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
1076 | + wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
1077 | + 'select2', |
|
1078 | + 'jquery' |
|
1079 | + ), $this->latest, $this->is_bs3_compat() ); |
|
1080 | + // if in admin then add to footer for compatibility. |
|
1081 | + is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
1082 | + $script = $this->inline_script(); |
|
1083 | + wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
1084 | + } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
1085 | + $url = $this->url . 'assets/js/popper.min.js'; |
|
1086 | + wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
|
1087 | + wp_enqueue_script( 'bootstrap-js-popper' ); |
|
1088 | + $load_inline = true; |
|
1089 | + } else { |
|
1090 | + $load_inline = true; |
|
1091 | + } |
|
1208 | 1092 | |
1209 | - /** |
|
1210 | - * The settings page html output. |
|
1211 | - */ |
|
1212 | - public function settings_page() { |
|
1213 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
1214 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
1215 | - } |
|
1216 | - ?> |
|
1093 | + // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
1094 | + if ( $load_inline ) { |
|
1095 | + wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
1096 | + wp_enqueue_script( 'bootstrap-dummy' ); |
|
1097 | + $script = $this->inline_script(); |
|
1098 | + wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
1099 | + } |
|
1100 | + } |
|
1101 | + |
|
1102 | + } |
|
1103 | + |
|
1104 | + /** |
|
1105 | + * Enqueue flatpickr if called. |
|
1106 | + */ |
|
1107 | + public function enqueue_flatpickr(){ |
|
1108 | + wp_enqueue_style( 'flatpickr' ); |
|
1109 | + wp_enqueue_script( 'flatpickr' ); |
|
1110 | + } |
|
1111 | + |
|
1112 | + /** |
|
1113 | + * Get the url path to the current folder. |
|
1114 | + * |
|
1115 | + * @return string |
|
1116 | + */ |
|
1117 | + public function get_url() { |
|
1118 | + |
|
1119 | + $url = ''; |
|
1120 | + // check if we are inside a plugin |
|
1121 | + $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
1122 | + |
|
1123 | + // add check in-case user has changed wp-content dir name. |
|
1124 | + $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
1125 | + $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
1126 | + $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
1127 | + |
|
1128 | + if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
1129 | + $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
1130 | + } |
|
1131 | + |
|
1132 | + return $url; |
|
1133 | + } |
|
1134 | + |
|
1135 | + /** |
|
1136 | + * Register the database settings with WordPress. |
|
1137 | + */ |
|
1138 | + public function register_settings() { |
|
1139 | + register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
1140 | + } |
|
1141 | + |
|
1142 | + /** |
|
1143 | + * Add the WordPress settings menu item. |
|
1144 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
1145 | + */ |
|
1146 | + public function menu_item() { |
|
1147 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
1148 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
1149 | + $this, |
|
1150 | + 'settings_page' |
|
1151 | + ) ); |
|
1152 | + } |
|
1153 | + |
|
1154 | + /** |
|
1155 | + * Get a list of themes and their default JS settings. |
|
1156 | + * |
|
1157 | + * @return array |
|
1158 | + */ |
|
1159 | + public function theme_js_settings(){ |
|
1160 | + return array( |
|
1161 | + 'ayetheme' => 'popper', |
|
1162 | + 'listimia' => 'required', |
|
1163 | + 'listimia_backend' => 'core-popper', |
|
1164 | + //'avada' => 'required', // removed as we now add compatibility |
|
1165 | + ); |
|
1166 | + } |
|
1167 | + |
|
1168 | + /** |
|
1169 | + * Get the current Font Awesome output settings. |
|
1170 | + * |
|
1171 | + * @return array The array of settings. |
|
1172 | + */ |
|
1173 | + public function get_settings() { |
|
1174 | + |
|
1175 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
1176 | + $js_default = 'core-popper'; |
|
1177 | + $js_default_backend = $js_default; |
|
1178 | + |
|
1179 | + // maybe set defaults (if no settings set) |
|
1180 | + if(empty($db_settings)){ |
|
1181 | + $active_theme = strtolower( get_template() ); // active parent theme. |
|
1182 | + $theme_js_settings = self::theme_js_settings(); |
|
1183 | + if(isset($theme_js_settings[$active_theme])){ |
|
1184 | + $js_default = $theme_js_settings[$active_theme]; |
|
1185 | + $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
1186 | + } |
|
1187 | + } |
|
1188 | + |
|
1189 | + $defaults = array( |
|
1190 | + 'css' => 'compatibility', // core, compatibility |
|
1191 | + 'js' => $js_default, // js to load, core-popper, popper |
|
1192 | + 'html_font_size' => '16', // js to load, core-popper, popper |
|
1193 | + 'css_backend' => 'compatibility', // core, compatibility |
|
1194 | + 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
1195 | + 'disable_admin' => '', // URL snippets to disable loading on admin |
|
1196 | + ); |
|
1197 | + |
|
1198 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
1199 | + |
|
1200 | + /** |
|
1201 | + * Filter the Bootstrap settings. |
|
1202 | + * |
|
1203 | + * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
1204 | + */ |
|
1205 | + return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
1206 | + } |
|
1207 | + |
|
1208 | + |
|
1209 | + /** |
|
1210 | + * The settings page html output. |
|
1211 | + */ |
|
1212 | + public function settings_page() { |
|
1213 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
1214 | + wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
1215 | + } |
|
1216 | + ?> |
|
1217 | 1217 | <div class="wrap"> |
1218 | 1218 | <h1><?php echo $this->name; ?></h1> |
1219 | 1219 | <p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p> |
1220 | 1220 | <form method="post" action="options.php"> |
1221 | 1221 | <?php |
1222 | - settings_fields( 'ayecode-ui-settings' ); |
|
1223 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
1224 | - ?> |
|
1222 | + settings_fields( 'ayecode-ui-settings' ); |
|
1223 | + do_settings_sections( 'ayecode-ui-settings' ); |
|
1224 | + ?> |
|
1225 | 1225 | |
1226 | 1226 | <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
1227 | 1227 | <table class="form-table wpbs-table-settings"> |
@@ -1301,60 +1301,60 @@ discard block |
||
1301 | 1301 | </table> |
1302 | 1302 | |
1303 | 1303 | <?php |
1304 | - submit_button(); |
|
1305 | - ?> |
|
1304 | + submit_button(); |
|
1305 | + ?> |
|
1306 | 1306 | </form> |
1307 | 1307 | |
1308 | 1308 | <div id="wpbs-version"><?php echo $this->version; ?></div> |
1309 | 1309 | </div> |
1310 | 1310 | |
1311 | 1311 | <?php |
1312 | - } |
|
1313 | - |
|
1314 | - public function customizer_settings($wp_customize){ |
|
1315 | - $wp_customize->add_section('aui_settings', array( |
|
1316 | - 'title' => __('AyeCode UI','aui'), |
|
1317 | - 'priority' => 120, |
|
1318 | - )); |
|
1319 | - |
|
1320 | - // ============================= |
|
1321 | - // = Color Picker = |
|
1322 | - // ============================= |
|
1323 | - $wp_customize->add_setting('aui_options[color_primary]', array( |
|
1324 | - 'default' => AUI_PRIMARY_COLOR, |
|
1325 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
1326 | - 'capability' => 'edit_theme_options', |
|
1327 | - 'type' => 'option', |
|
1328 | - 'transport' => 'refresh', |
|
1329 | - )); |
|
1330 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1331 | - 'label' => __('Primary Color','aui'), |
|
1332 | - 'section' => 'aui_settings', |
|
1333 | - 'settings' => 'aui_options[color_primary]', |
|
1334 | - ))); |
|
1335 | - |
|
1336 | - $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
1337 | - 'default' => '#6c757d', |
|
1338 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
1339 | - 'capability' => 'edit_theme_options', |
|
1340 | - 'type' => 'option', |
|
1341 | - 'transport' => 'refresh', |
|
1342 | - )); |
|
1343 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1344 | - 'label' => __('Secondary Color','aui'), |
|
1345 | - 'section' => 'aui_settings', |
|
1346 | - 'settings' => 'aui_options[color_secondary]', |
|
1347 | - ))); |
|
1348 | - } |
|
1349 | - |
|
1350 | - /** |
|
1351 | - * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1352 | - * |
|
1353 | - * @return mixed |
|
1354 | - */ |
|
1355 | - public static function bs3_compat_css() { |
|
1356 | - ob_start(); |
|
1357 | - ?> |
|
1312 | + } |
|
1313 | + |
|
1314 | + public function customizer_settings($wp_customize){ |
|
1315 | + $wp_customize->add_section('aui_settings', array( |
|
1316 | + 'title' => __('AyeCode UI','aui'), |
|
1317 | + 'priority' => 120, |
|
1318 | + )); |
|
1319 | + |
|
1320 | + // ============================= |
|
1321 | + // = Color Picker = |
|
1322 | + // ============================= |
|
1323 | + $wp_customize->add_setting('aui_options[color_primary]', array( |
|
1324 | + 'default' => AUI_PRIMARY_COLOR, |
|
1325 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
1326 | + 'capability' => 'edit_theme_options', |
|
1327 | + 'type' => 'option', |
|
1328 | + 'transport' => 'refresh', |
|
1329 | + )); |
|
1330 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1331 | + 'label' => __('Primary Color','aui'), |
|
1332 | + 'section' => 'aui_settings', |
|
1333 | + 'settings' => 'aui_options[color_primary]', |
|
1334 | + ))); |
|
1335 | + |
|
1336 | + $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
1337 | + 'default' => '#6c757d', |
|
1338 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
1339 | + 'capability' => 'edit_theme_options', |
|
1340 | + 'type' => 'option', |
|
1341 | + 'transport' => 'refresh', |
|
1342 | + )); |
|
1343 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1344 | + 'label' => __('Secondary Color','aui'), |
|
1345 | + 'section' => 'aui_settings', |
|
1346 | + 'settings' => 'aui_options[color_secondary]', |
|
1347 | + ))); |
|
1348 | + } |
|
1349 | + |
|
1350 | + /** |
|
1351 | + * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1352 | + * |
|
1353 | + * @return mixed |
|
1354 | + */ |
|
1355 | + public static function bs3_compat_css() { |
|
1356 | + ob_start(); |
|
1357 | + ?> |
|
1358 | 1358 | <style> |
1359 | 1359 | /* Bootstrap 3 compatibility */ |
1360 | 1360 | body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;} |
@@ -1380,579 +1380,579 @@ discard block |
||
1380 | 1380 | <?php } ?> |
1381 | 1381 | </style> |
1382 | 1382 | <?php |
1383 | - return str_replace( array( |
|
1384 | - '<style>', |
|
1385 | - '</style>' |
|
1386 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1387 | - } |
|
1383 | + return str_replace( array( |
|
1384 | + '<style>', |
|
1385 | + '</style>' |
|
1386 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
1387 | + } |
|
1388 | 1388 | |
1389 | 1389 | |
1390 | - public static function custom_css($compatibility = true) { |
|
1391 | - $settings = get_option('aui_options'); |
|
1390 | + public static function custom_css($compatibility = true) { |
|
1391 | + $settings = get_option('aui_options'); |
|
1392 | 1392 | |
1393 | - ob_start(); |
|
1393 | + ob_start(); |
|
1394 | 1394 | |
1395 | - $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
1396 | - $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
1397 | - //AUI_PRIMARY_COLOR_ORIGINAL |
|
1398 | - ?> |
|
1395 | + $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
1396 | + $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
1397 | + //AUI_PRIMARY_COLOR_ORIGINAL |
|
1398 | + ?> |
|
1399 | 1399 | <style> |
1400 | 1400 | <?php |
1401 | 1401 | |
1402 | - // BS v3 compat |
|
1403 | - if( self::is_bs3_compat() ){ |
|
1404 | - echo self::bs3_compat_css(); |
|
1405 | - } |
|
1402 | + // BS v3 compat |
|
1403 | + if( self::is_bs3_compat() ){ |
|
1404 | + echo self::bs3_compat_css(); |
|
1405 | + } |
|
1406 | 1406 | |
1407 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1408 | - echo self::css_primary($primary_color,$compatibility); |
|
1409 | - } |
|
1407 | + if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1408 | + echo self::css_primary($primary_color,$compatibility); |
|
1409 | + } |
|
1410 | 1410 | |
1411 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1412 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1413 | - } |
|
1411 | + if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1412 | + echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1413 | + } |
|
1414 | 1414 | |
1415 | - // Set admin bar z-index lower when modal is open. |
|
1416 | - echo ' body.modal-open #wpadminbar{z-index:999}'; |
|
1415 | + // Set admin bar z-index lower when modal is open. |
|
1416 | + echo ' body.modal-open #wpadminbar{z-index:999}'; |
|
1417 | 1417 | ?> |
1418 | 1418 | </style> |
1419 | 1419 | <?php |
1420 | 1420 | |
1421 | 1421 | |
1422 | - /* |
|
1422 | + /* |
|
1423 | 1423 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1424 | 1424 | */ |
1425 | - return str_replace( array( |
|
1426 | - '<style>', |
|
1427 | - '</style>' |
|
1428 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1429 | - } |
|
1430 | - |
|
1431 | - /** |
|
1432 | - * Check if we should add booststrap 3 compatibility changes. |
|
1433 | - * |
|
1434 | - * @return bool |
|
1435 | - */ |
|
1436 | - public static function is_bs3_compat(){ |
|
1437 | - return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
1438 | - } |
|
1439 | - |
|
1440 | - public static function css_primary($color_code,$compatibility){; |
|
1441 | - $color_code = sanitize_hex_color($color_code); |
|
1442 | - if(!$color_code){return '';} |
|
1443 | - /** |
|
1444 | - * c = color, b = background color, o = border-color, f = fill |
|
1445 | - */ |
|
1446 | - $selectors = array( |
|
1447 | - 'a' => array('c'), |
|
1448 | - '.btn-primary' => array('b','o'), |
|
1449 | - '.btn-primary.disabled' => array('b','o'), |
|
1450 | - '.btn-primary:disabled' => array('b','o'), |
|
1451 | - '.btn-outline-primary' => array('c','o'), |
|
1452 | - '.btn-outline-primary:hover' => array('b','o'), |
|
1453 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1454 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1455 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1456 | - '.btn-link' => array('c'), |
|
1457 | - '.dropdown-item.active' => array('b'), |
|
1458 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1459 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1425 | + return str_replace( array( |
|
1426 | + '<style>', |
|
1427 | + '</style>' |
|
1428 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
1429 | + } |
|
1430 | + |
|
1431 | + /** |
|
1432 | + * Check if we should add booststrap 3 compatibility changes. |
|
1433 | + * |
|
1434 | + * @return bool |
|
1435 | + */ |
|
1436 | + public static function is_bs3_compat(){ |
|
1437 | + return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
1438 | + } |
|
1439 | + |
|
1440 | + public static function css_primary($color_code,$compatibility){; |
|
1441 | + $color_code = sanitize_hex_color($color_code); |
|
1442 | + if(!$color_code){return '';} |
|
1443 | + /** |
|
1444 | + * c = color, b = background color, o = border-color, f = fill |
|
1445 | + */ |
|
1446 | + $selectors = array( |
|
1447 | + 'a' => array('c'), |
|
1448 | + '.btn-primary' => array('b','o'), |
|
1449 | + '.btn-primary.disabled' => array('b','o'), |
|
1450 | + '.btn-primary:disabled' => array('b','o'), |
|
1451 | + '.btn-outline-primary' => array('c','o'), |
|
1452 | + '.btn-outline-primary:hover' => array('b','o'), |
|
1453 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1454 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1455 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1456 | + '.btn-link' => array('c'), |
|
1457 | + '.dropdown-item.active' => array('b'), |
|
1458 | + '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1459 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1460 | 1460 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
1461 | 1461 | // '.custom-range::-moz-range-thumb' => array('b'), |
1462 | 1462 | // '.custom-range::-ms-thumb' => array('b'), |
1463 | - '.nav-pills .nav-link.active' => array('b'), |
|
1464 | - '.nav-pills .show>.nav-link' => array('b'), |
|
1465 | - '.page-link' => array('c'), |
|
1466 | - '.page-item.active .page-link' => array('b','o'), |
|
1467 | - '.badge-primary' => array('b'), |
|
1468 | - '.alert-primary' => array('b','o'), |
|
1469 | - '.progress-bar' => array('b'), |
|
1470 | - '.list-group-item.active' => array('b','o'), |
|
1471 | - '.bg-primary' => array('b','f'), |
|
1472 | - '.btn-link.btn-primary' => array('c'), |
|
1473 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1474 | - ); |
|
1475 | - |
|
1476 | - $important_selectors = array( |
|
1477 | - '.bg-primary' => array('b','f'), |
|
1478 | - '.border-primary' => array('o'), |
|
1479 | - '.text-primary' => array('c'), |
|
1480 | - ); |
|
1481 | - |
|
1482 | - $color = array(); |
|
1483 | - $color_i = array(); |
|
1484 | - $background = array(); |
|
1485 | - $background_i = array(); |
|
1486 | - $border = array(); |
|
1487 | - $border_i = array(); |
|
1488 | - $fill = array(); |
|
1489 | - $fill_i = array(); |
|
1490 | - |
|
1491 | - $output = ''; |
|
1492 | - |
|
1493 | - // build rules into each type |
|
1494 | - foreach($selectors as $selector => $types){ |
|
1495 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1496 | - $types = array_combine($types,$types); |
|
1497 | - if(isset($types['c'])){$color[] = $selector;} |
|
1498 | - if(isset($types['b'])){$background[] = $selector;} |
|
1499 | - if(isset($types['o'])){$border[] = $selector;} |
|
1500 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1501 | - } |
|
1502 | - |
|
1503 | - // build rules into each type |
|
1504 | - foreach($important_selectors as $selector => $types){ |
|
1505 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1506 | - $types = array_combine($types,$types); |
|
1507 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1508 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1509 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1510 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1511 | - } |
|
1512 | - |
|
1513 | - // add any color rules |
|
1514 | - if(!empty($color)){ |
|
1515 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1516 | - } |
|
1517 | - if(!empty($color_i)){ |
|
1518 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1519 | - } |
|
1520 | - |
|
1521 | - // add any background color rules |
|
1522 | - if(!empty($background)){ |
|
1523 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1524 | - } |
|
1525 | - if(!empty($background_i)){ |
|
1526 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1527 | - } |
|
1528 | - |
|
1529 | - // add any border color rules |
|
1530 | - if(!empty($border)){ |
|
1531 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1532 | - } |
|
1533 | - if(!empty($border_i)){ |
|
1534 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1535 | - } |
|
1536 | - |
|
1537 | - // add any fill color rules |
|
1538 | - if(!empty($fill)){ |
|
1539 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1540 | - } |
|
1541 | - if(!empty($fill_i)){ |
|
1542 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1543 | - } |
|
1544 | - |
|
1545 | - |
|
1546 | - $prefix = $compatibility ? ".bsui " : ""; |
|
1547 | - |
|
1548 | - // darken |
|
1549 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1550 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1551 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1552 | - |
|
1553 | - // lighten |
|
1554 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1555 | - |
|
1556 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1557 | - $op_25 = $color_code."40"; // 25% opacity |
|
1558 | - |
|
1559 | - |
|
1560 | - // button states |
|
1561 | - $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1562 | - $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;} "; |
|
1563 | - $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.";} "; |
|
1564 | - $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;} "; |
|
1565 | - |
|
1566 | - |
|
1567 | - // dropdown's |
|
1568 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1569 | - |
|
1570 | - |
|
1571 | - // input states |
|
1572 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1573 | - |
|
1574 | - // page link |
|
1575 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1576 | - |
|
1577 | - return $output; |
|
1578 | - } |
|
1579 | - |
|
1580 | - public static function css_secondary($color_code,$compatibility){; |
|
1581 | - $color_code = sanitize_hex_color($color_code); |
|
1582 | - if(!$color_code){return '';} |
|
1583 | - /** |
|
1584 | - * c = color, b = background color, o = border-color, f = fill |
|
1585 | - */ |
|
1586 | - $selectors = array( |
|
1587 | - '.btn-secondary' => array('b','o'), |
|
1588 | - '.btn-secondary.disabled' => array('b','o'), |
|
1589 | - '.btn-secondary:disabled' => array('b','o'), |
|
1590 | - '.btn-outline-secondary' => array('c','o'), |
|
1591 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
1592 | - '.btn-outline-secondary.disabled' => array('c'), |
|
1593 | - '.btn-outline-secondary:disabled' => array('c'), |
|
1594 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1595 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1596 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1597 | - '.badge-secondary' => array('b'), |
|
1598 | - '.alert-secondary' => array('b','o'), |
|
1599 | - '.btn-link.btn-secondary' => array('c'), |
|
1600 | - ); |
|
1601 | - |
|
1602 | - $important_selectors = array( |
|
1603 | - '.bg-secondary' => array('b','f'), |
|
1604 | - '.border-secondary' => array('o'), |
|
1605 | - '.text-secondary' => array('c'), |
|
1606 | - ); |
|
1607 | - |
|
1608 | - $color = array(); |
|
1609 | - $color_i = array(); |
|
1610 | - $background = array(); |
|
1611 | - $background_i = array(); |
|
1612 | - $border = array(); |
|
1613 | - $border_i = array(); |
|
1614 | - $fill = array(); |
|
1615 | - $fill_i = array(); |
|
1616 | - |
|
1617 | - $output = ''; |
|
1618 | - |
|
1619 | - // build rules into each type |
|
1620 | - foreach($selectors as $selector => $types){ |
|
1621 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1622 | - $types = array_combine($types,$types); |
|
1623 | - if(isset($types['c'])){$color[] = $selector;} |
|
1624 | - if(isset($types['b'])){$background[] = $selector;} |
|
1625 | - if(isset($types['o'])){$border[] = $selector;} |
|
1626 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1627 | - } |
|
1628 | - |
|
1629 | - // build rules into each type |
|
1630 | - foreach($important_selectors as $selector => $types){ |
|
1631 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1632 | - $types = array_combine($types,$types); |
|
1633 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1634 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1635 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1636 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1637 | - } |
|
1638 | - |
|
1639 | - // add any color rules |
|
1640 | - if(!empty($color)){ |
|
1641 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1642 | - } |
|
1643 | - if(!empty($color_i)){ |
|
1644 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1645 | - } |
|
1646 | - |
|
1647 | - // add any background color rules |
|
1648 | - if(!empty($background)){ |
|
1649 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1650 | - } |
|
1651 | - if(!empty($background_i)){ |
|
1652 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1653 | - } |
|
1654 | - |
|
1655 | - // add any border color rules |
|
1656 | - if(!empty($border)){ |
|
1657 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1658 | - } |
|
1659 | - if(!empty($border_i)){ |
|
1660 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1661 | - } |
|
1662 | - |
|
1663 | - // add any fill color rules |
|
1664 | - if(!empty($fill)){ |
|
1665 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1666 | - } |
|
1667 | - if(!empty($fill_i)){ |
|
1668 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1669 | - } |
|
1670 | - |
|
1671 | - |
|
1672 | - $prefix = $compatibility ? ".bsui " : ""; |
|
1673 | - |
|
1674 | - // darken |
|
1675 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1676 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1677 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1678 | - |
|
1679 | - // lighten |
|
1680 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1681 | - |
|
1682 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1683 | - $op_25 = $color_code."40"; // 25% opacity |
|
1684 | - |
|
1685 | - |
|
1686 | - // button states |
|
1687 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1688 | - $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;} "; |
|
1689 | - $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.";} "; |
|
1690 | - $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;} "; |
|
1691 | - |
|
1692 | - |
|
1693 | - return $output; |
|
1694 | - } |
|
1695 | - |
|
1696 | - /** |
|
1697 | - * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
1698 | - * |
|
1699 | - * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
1700 | - * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
1701 | - * |
|
1702 | - * @return string |
|
1703 | - */ |
|
1704 | - public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
1705 | - $hexCode = ltrim($hexCode, '#'); |
|
1706 | - |
|
1707 | - if (strlen($hexCode) == 3) { |
|
1708 | - $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
1709 | - } |
|
1710 | - |
|
1711 | - $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
1712 | - |
|
1713 | - foreach ($hexCode as & $color) { |
|
1714 | - $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
1715 | - $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
1716 | - |
|
1717 | - $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
1718 | - } |
|
1719 | - |
|
1720 | - return '#' . implode($hexCode); |
|
1721 | - } |
|
1722 | - |
|
1723 | - /** |
|
1724 | - * Check if we should display examples. |
|
1725 | - */ |
|
1726 | - public function maybe_show_examples(){ |
|
1727 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1728 | - echo "<head>"; |
|
1729 | - wp_head(); |
|
1730 | - echo "</head>"; |
|
1731 | - echo "<body>"; |
|
1732 | - echo $this->get_examples(); |
|
1733 | - echo "</body>"; |
|
1734 | - exit; |
|
1735 | - } |
|
1736 | - } |
|
1737 | - |
|
1738 | - /** |
|
1739 | - * Get developer examples. |
|
1740 | - * |
|
1741 | - * @return string |
|
1742 | - */ |
|
1743 | - public function get_examples(){ |
|
1744 | - $output = ''; |
|
1745 | - |
|
1746 | - |
|
1747 | - // open form |
|
1748 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
1749 | - |
|
1750 | - // input example |
|
1751 | - $output .= aui()->input(array( |
|
1752 | - 'type' => 'text', |
|
1753 | - 'id' => 'text-example', |
|
1754 | - 'name' => 'text-example', |
|
1755 | - 'placeholder' => 'text placeholder', |
|
1756 | - 'title' => 'Text input example', |
|
1757 | - 'value' => '', |
|
1758 | - 'required' => false, |
|
1759 | - 'help_text' => 'help text', |
|
1760 | - 'label' => 'Text input example label' |
|
1761 | - )); |
|
1762 | - |
|
1763 | - // input example |
|
1764 | - $output .= aui()->input(array( |
|
1765 | - 'type' => 'url', |
|
1766 | - 'id' => 'text-example2', |
|
1767 | - 'name' => 'text-example', |
|
1768 | - 'placeholder' => 'url placeholder', |
|
1769 | - 'title' => 'Text input example', |
|
1770 | - 'value' => '', |
|
1771 | - 'required' => false, |
|
1772 | - 'help_text' => 'help text', |
|
1773 | - 'label' => 'Text input example label' |
|
1774 | - )); |
|
1775 | - |
|
1776 | - // checkbox example |
|
1777 | - $output .= aui()->input(array( |
|
1778 | - 'type' => 'checkbox', |
|
1779 | - 'id' => 'checkbox-example', |
|
1780 | - 'name' => 'checkbox-example', |
|
1781 | - 'placeholder' => 'checkbox-example', |
|
1782 | - 'title' => 'Checkbox example', |
|
1783 | - 'value' => '1', |
|
1784 | - 'checked' => true, |
|
1785 | - 'required' => false, |
|
1786 | - 'help_text' => 'help text', |
|
1787 | - 'label' => 'Checkbox checked' |
|
1788 | - )); |
|
1789 | - |
|
1790 | - // checkbox example |
|
1791 | - $output .= aui()->input(array( |
|
1792 | - 'type' => 'checkbox', |
|
1793 | - 'id' => 'checkbox-example2', |
|
1794 | - 'name' => 'checkbox-example2', |
|
1795 | - 'placeholder' => 'checkbox-example', |
|
1796 | - 'title' => 'Checkbox example', |
|
1797 | - 'value' => '1', |
|
1798 | - 'checked' => false, |
|
1799 | - 'required' => false, |
|
1800 | - 'help_text' => 'help text', |
|
1801 | - 'label' => 'Checkbox un-checked' |
|
1802 | - )); |
|
1803 | - |
|
1804 | - // switch example |
|
1805 | - $output .= aui()->input(array( |
|
1806 | - 'type' => 'checkbox', |
|
1807 | - 'id' => 'switch-example', |
|
1808 | - 'name' => 'switch-example', |
|
1809 | - 'placeholder' => 'checkbox-example', |
|
1810 | - 'title' => 'Switch example', |
|
1811 | - 'value' => '1', |
|
1812 | - 'checked' => true, |
|
1813 | - 'switch' => true, |
|
1814 | - 'required' => false, |
|
1815 | - 'help_text' => 'help text', |
|
1816 | - 'label' => 'Switch on' |
|
1817 | - )); |
|
1818 | - |
|
1819 | - // switch example |
|
1820 | - $output .= aui()->input(array( |
|
1821 | - 'type' => 'checkbox', |
|
1822 | - 'id' => 'switch-example2', |
|
1823 | - 'name' => 'switch-example2', |
|
1824 | - 'placeholder' => 'checkbox-example', |
|
1825 | - 'title' => 'Switch example', |
|
1826 | - 'value' => '1', |
|
1827 | - 'checked' => false, |
|
1828 | - 'switch' => true, |
|
1829 | - 'required' => false, |
|
1830 | - 'help_text' => 'help text', |
|
1831 | - 'label' => 'Switch off' |
|
1832 | - )); |
|
1833 | - |
|
1834 | - // close form |
|
1835 | - $output .= "</form>"; |
|
1836 | - |
|
1837 | - return $output; |
|
1838 | - } |
|
1839 | - |
|
1840 | - /** |
|
1841 | - * Calendar params. |
|
1842 | - * |
|
1843 | - * @since 0.1.44 |
|
1844 | - * |
|
1845 | - * @return array Calendar params. |
|
1846 | - */ |
|
1847 | - public static function calendar_params() { |
|
1848 | - $params = array( |
|
1849 | - 'month_long_1' => __( 'January', 'aui' ), |
|
1850 | - 'month_long_2' => __( 'February', 'aui' ), |
|
1851 | - 'month_long_3' => __( 'March', 'aui' ), |
|
1852 | - 'month_long_4' => __( 'April', 'aui' ), |
|
1853 | - 'month_long_5' => __( 'May', 'aui' ), |
|
1854 | - 'month_long_6' => __( 'June', 'aui' ), |
|
1855 | - 'month_long_7' => __( 'July', 'aui' ), |
|
1856 | - 'month_long_8' => __( 'August', 'aui' ), |
|
1857 | - 'month_long_9' => __( 'September', 'aui' ), |
|
1858 | - 'month_long_10' => __( 'October', 'aui' ), |
|
1859 | - 'month_long_11' => __( 'November', 'aui' ), |
|
1860 | - 'month_long_12' => __( 'December', 'aui' ), |
|
1861 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
1862 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
1863 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
1864 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
1865 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
1866 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
1867 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
1868 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
1869 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
1870 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
1871 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
1872 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
1873 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
1874 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
1875 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
1876 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
1877 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
1878 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
1879 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
1880 | - 'day_s2_1' => __( 'Su', 'aui' ), |
|
1881 | - 'day_s2_2' => __( 'Mo', 'aui' ), |
|
1882 | - 'day_s2_3' => __( 'Tu', 'aui' ), |
|
1883 | - 'day_s2_4' => __( 'We', 'aui' ), |
|
1884 | - 'day_s2_5' => __( 'Th', 'aui' ), |
|
1885 | - 'day_s2_6' => __( 'Fr', 'aui' ), |
|
1886 | - 'day_s2_7' => __( 'Sa', 'aui' ), |
|
1887 | - 'day_s3_1' => __( 'Sun', 'aui' ), |
|
1888 | - 'day_s3_2' => __( 'Mon', 'aui' ), |
|
1889 | - 'day_s3_3' => __( 'Tue', 'aui' ), |
|
1890 | - 'day_s3_4' => __( 'Wed', 'aui' ), |
|
1891 | - 'day_s3_5' => __( 'Thu', 'aui' ), |
|
1892 | - 'day_s3_6' => __( 'Fri', 'aui' ), |
|
1893 | - 'day_s3_7' => __( 'Sat', 'aui' ), |
|
1894 | - 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
1895 | - 'day_s5_2' => __( 'Monday', 'aui' ), |
|
1896 | - 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
1897 | - 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
1898 | - 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
1899 | - 'day_s5_6' => __( 'Friday', 'aui' ), |
|
1900 | - 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
1901 | - 'am_lower' => __( 'am', 'aui' ), |
|
1902 | - 'pm_lower' => __( 'pm', 'aui' ), |
|
1903 | - 'am_upper' => __( 'AM', 'aui' ), |
|
1904 | - 'pm_upper' => __( 'PM', 'aui' ), |
|
1905 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
1906 | - 'time_24hr' => false, |
|
1907 | - 'year' => __( 'Year', 'aui' ), |
|
1908 | - 'hour' => __( 'Hour', 'aui' ), |
|
1909 | - 'minute' => __( 'Minute', 'aui' ), |
|
1910 | - 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
1911 | - 'rangeSeparator' => __( ' to ', 'aui' ), |
|
1912 | - 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
1913 | - 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
1914 | - ); |
|
1915 | - |
|
1916 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
1917 | - } |
|
1918 | - |
|
1919 | - /** |
|
1920 | - * Flatpickr calendar localize. |
|
1921 | - * |
|
1922 | - * @since 0.1.44 |
|
1923 | - * |
|
1924 | - * @return string Calendar locale. |
|
1925 | - */ |
|
1926 | - public static function flatpickr_locale() { |
|
1927 | - $params = self::calendar_params(); |
|
1928 | - |
|
1929 | - if ( is_string( $params ) ) { |
|
1930 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
1931 | - } else { |
|
1932 | - foreach ( (array) $params as $key => $value ) { |
|
1933 | - if ( ! is_scalar( $value ) ) { |
|
1934 | - continue; |
|
1935 | - } |
|
1936 | - |
|
1937 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
1938 | - } |
|
1939 | - } |
|
1463 | + '.nav-pills .nav-link.active' => array('b'), |
|
1464 | + '.nav-pills .show>.nav-link' => array('b'), |
|
1465 | + '.page-link' => array('c'), |
|
1466 | + '.page-item.active .page-link' => array('b','o'), |
|
1467 | + '.badge-primary' => array('b'), |
|
1468 | + '.alert-primary' => array('b','o'), |
|
1469 | + '.progress-bar' => array('b'), |
|
1470 | + '.list-group-item.active' => array('b','o'), |
|
1471 | + '.bg-primary' => array('b','f'), |
|
1472 | + '.btn-link.btn-primary' => array('c'), |
|
1473 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1474 | + ); |
|
1475 | + |
|
1476 | + $important_selectors = array( |
|
1477 | + '.bg-primary' => array('b','f'), |
|
1478 | + '.border-primary' => array('o'), |
|
1479 | + '.text-primary' => array('c'), |
|
1480 | + ); |
|
1481 | + |
|
1482 | + $color = array(); |
|
1483 | + $color_i = array(); |
|
1484 | + $background = array(); |
|
1485 | + $background_i = array(); |
|
1486 | + $border = array(); |
|
1487 | + $border_i = array(); |
|
1488 | + $fill = array(); |
|
1489 | + $fill_i = array(); |
|
1490 | + |
|
1491 | + $output = ''; |
|
1492 | + |
|
1493 | + // build rules into each type |
|
1494 | + foreach($selectors as $selector => $types){ |
|
1495 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1496 | + $types = array_combine($types,$types); |
|
1497 | + if(isset($types['c'])){$color[] = $selector;} |
|
1498 | + if(isset($types['b'])){$background[] = $selector;} |
|
1499 | + if(isset($types['o'])){$border[] = $selector;} |
|
1500 | + if(isset($types['f'])){$fill[] = $selector;} |
|
1501 | + } |
|
1502 | + |
|
1503 | + // build rules into each type |
|
1504 | + foreach($important_selectors as $selector => $types){ |
|
1505 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1506 | + $types = array_combine($types,$types); |
|
1507 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
1508 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
1509 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
1510 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
1511 | + } |
|
1512 | + |
|
1513 | + // add any color rules |
|
1514 | + if(!empty($color)){ |
|
1515 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1516 | + } |
|
1517 | + if(!empty($color_i)){ |
|
1518 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1519 | + } |
|
1520 | + |
|
1521 | + // add any background color rules |
|
1522 | + if(!empty($background)){ |
|
1523 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1524 | + } |
|
1525 | + if(!empty($background_i)){ |
|
1526 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1527 | + } |
|
1528 | + |
|
1529 | + // add any border color rules |
|
1530 | + if(!empty($border)){ |
|
1531 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1532 | + } |
|
1533 | + if(!empty($border_i)){ |
|
1534 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1535 | + } |
|
1536 | + |
|
1537 | + // add any fill color rules |
|
1538 | + if(!empty($fill)){ |
|
1539 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1540 | + } |
|
1541 | + if(!empty($fill_i)){ |
|
1542 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1543 | + } |
|
1544 | + |
|
1545 | + |
|
1546 | + $prefix = $compatibility ? ".bsui " : ""; |
|
1547 | + |
|
1548 | + // darken |
|
1549 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1550 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1551 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1552 | + |
|
1553 | + // lighten |
|
1554 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1555 | + |
|
1556 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1557 | + $op_25 = $color_code."40"; // 25% opacity |
|
1558 | + |
|
1559 | + |
|
1560 | + // button states |
|
1561 | + $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1562 | + $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;} "; |
|
1563 | + $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.";} "; |
|
1564 | + $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;} "; |
|
1565 | + |
|
1566 | + |
|
1567 | + // dropdown's |
|
1568 | + $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1569 | + |
|
1570 | + |
|
1571 | + // input states |
|
1572 | + $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1573 | + |
|
1574 | + // page link |
|
1575 | + $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1576 | + |
|
1577 | + return $output; |
|
1578 | + } |
|
1579 | + |
|
1580 | + public static function css_secondary($color_code,$compatibility){; |
|
1581 | + $color_code = sanitize_hex_color($color_code); |
|
1582 | + if(!$color_code){return '';} |
|
1583 | + /** |
|
1584 | + * c = color, b = background color, o = border-color, f = fill |
|
1585 | + */ |
|
1586 | + $selectors = array( |
|
1587 | + '.btn-secondary' => array('b','o'), |
|
1588 | + '.btn-secondary.disabled' => array('b','o'), |
|
1589 | + '.btn-secondary:disabled' => array('b','o'), |
|
1590 | + '.btn-outline-secondary' => array('c','o'), |
|
1591 | + '.btn-outline-secondary:hover' => array('b','o'), |
|
1592 | + '.btn-outline-secondary.disabled' => array('c'), |
|
1593 | + '.btn-outline-secondary:disabled' => array('c'), |
|
1594 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1595 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1596 | + '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1597 | + '.badge-secondary' => array('b'), |
|
1598 | + '.alert-secondary' => array('b','o'), |
|
1599 | + '.btn-link.btn-secondary' => array('c'), |
|
1600 | + ); |
|
1601 | + |
|
1602 | + $important_selectors = array( |
|
1603 | + '.bg-secondary' => array('b','f'), |
|
1604 | + '.border-secondary' => array('o'), |
|
1605 | + '.text-secondary' => array('c'), |
|
1606 | + ); |
|
1607 | + |
|
1608 | + $color = array(); |
|
1609 | + $color_i = array(); |
|
1610 | + $background = array(); |
|
1611 | + $background_i = array(); |
|
1612 | + $border = array(); |
|
1613 | + $border_i = array(); |
|
1614 | + $fill = array(); |
|
1615 | + $fill_i = array(); |
|
1616 | + |
|
1617 | + $output = ''; |
|
1618 | + |
|
1619 | + // build rules into each type |
|
1620 | + foreach($selectors as $selector => $types){ |
|
1621 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1622 | + $types = array_combine($types,$types); |
|
1623 | + if(isset($types['c'])){$color[] = $selector;} |
|
1624 | + if(isset($types['b'])){$background[] = $selector;} |
|
1625 | + if(isset($types['o'])){$border[] = $selector;} |
|
1626 | + if(isset($types['f'])){$fill[] = $selector;} |
|
1627 | + } |
|
1628 | + |
|
1629 | + // build rules into each type |
|
1630 | + foreach($important_selectors as $selector => $types){ |
|
1631 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1632 | + $types = array_combine($types,$types); |
|
1633 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
1634 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
1635 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
1636 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
1637 | + } |
|
1638 | + |
|
1639 | + // add any color rules |
|
1640 | + if(!empty($color)){ |
|
1641 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1642 | + } |
|
1643 | + if(!empty($color_i)){ |
|
1644 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1645 | + } |
|
1646 | + |
|
1647 | + // add any background color rules |
|
1648 | + if(!empty($background)){ |
|
1649 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1650 | + } |
|
1651 | + if(!empty($background_i)){ |
|
1652 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1653 | + } |
|
1654 | + |
|
1655 | + // add any border color rules |
|
1656 | + if(!empty($border)){ |
|
1657 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1658 | + } |
|
1659 | + if(!empty($border_i)){ |
|
1660 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1661 | + } |
|
1662 | + |
|
1663 | + // add any fill color rules |
|
1664 | + if(!empty($fill)){ |
|
1665 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1666 | + } |
|
1667 | + if(!empty($fill_i)){ |
|
1668 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1669 | + } |
|
1670 | + |
|
1671 | + |
|
1672 | + $prefix = $compatibility ? ".bsui " : ""; |
|
1673 | + |
|
1674 | + // darken |
|
1675 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1676 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1677 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1678 | + |
|
1679 | + // lighten |
|
1680 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1681 | + |
|
1682 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1683 | + $op_25 = $color_code."40"; // 25% opacity |
|
1684 | + |
|
1685 | + |
|
1686 | + // button states |
|
1687 | + $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1688 | + $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;} "; |
|
1689 | + $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.";} "; |
|
1690 | + $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;} "; |
|
1691 | + |
|
1692 | + |
|
1693 | + return $output; |
|
1694 | + } |
|
1695 | + |
|
1696 | + /** |
|
1697 | + * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
1698 | + * |
|
1699 | + * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
1700 | + * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
1701 | + * |
|
1702 | + * @return string |
|
1703 | + */ |
|
1704 | + public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
1705 | + $hexCode = ltrim($hexCode, '#'); |
|
1706 | + |
|
1707 | + if (strlen($hexCode) == 3) { |
|
1708 | + $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
1709 | + } |
|
1710 | + |
|
1711 | + $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
1712 | + |
|
1713 | + foreach ($hexCode as & $color) { |
|
1714 | + $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
1715 | + $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
1716 | + |
|
1717 | + $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
1718 | + } |
|
1719 | + |
|
1720 | + return '#' . implode($hexCode); |
|
1721 | + } |
|
1722 | + |
|
1723 | + /** |
|
1724 | + * Check if we should display examples. |
|
1725 | + */ |
|
1726 | + public function maybe_show_examples(){ |
|
1727 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1728 | + echo "<head>"; |
|
1729 | + wp_head(); |
|
1730 | + echo "</head>"; |
|
1731 | + echo "<body>"; |
|
1732 | + echo $this->get_examples(); |
|
1733 | + echo "</body>"; |
|
1734 | + exit; |
|
1735 | + } |
|
1736 | + } |
|
1737 | + |
|
1738 | + /** |
|
1739 | + * Get developer examples. |
|
1740 | + * |
|
1741 | + * @return string |
|
1742 | + */ |
|
1743 | + public function get_examples(){ |
|
1744 | + $output = ''; |
|
1745 | + |
|
1746 | + |
|
1747 | + // open form |
|
1748 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
1749 | + |
|
1750 | + // input example |
|
1751 | + $output .= aui()->input(array( |
|
1752 | + 'type' => 'text', |
|
1753 | + 'id' => 'text-example', |
|
1754 | + 'name' => 'text-example', |
|
1755 | + 'placeholder' => 'text placeholder', |
|
1756 | + 'title' => 'Text input example', |
|
1757 | + 'value' => '', |
|
1758 | + 'required' => false, |
|
1759 | + 'help_text' => 'help text', |
|
1760 | + 'label' => 'Text input example label' |
|
1761 | + )); |
|
1762 | + |
|
1763 | + // input example |
|
1764 | + $output .= aui()->input(array( |
|
1765 | + 'type' => 'url', |
|
1766 | + 'id' => 'text-example2', |
|
1767 | + 'name' => 'text-example', |
|
1768 | + 'placeholder' => 'url placeholder', |
|
1769 | + 'title' => 'Text input example', |
|
1770 | + 'value' => '', |
|
1771 | + 'required' => false, |
|
1772 | + 'help_text' => 'help text', |
|
1773 | + 'label' => 'Text input example label' |
|
1774 | + )); |
|
1775 | + |
|
1776 | + // checkbox example |
|
1777 | + $output .= aui()->input(array( |
|
1778 | + 'type' => 'checkbox', |
|
1779 | + 'id' => 'checkbox-example', |
|
1780 | + 'name' => 'checkbox-example', |
|
1781 | + 'placeholder' => 'checkbox-example', |
|
1782 | + 'title' => 'Checkbox example', |
|
1783 | + 'value' => '1', |
|
1784 | + 'checked' => true, |
|
1785 | + 'required' => false, |
|
1786 | + 'help_text' => 'help text', |
|
1787 | + 'label' => 'Checkbox checked' |
|
1788 | + )); |
|
1789 | + |
|
1790 | + // checkbox example |
|
1791 | + $output .= aui()->input(array( |
|
1792 | + 'type' => 'checkbox', |
|
1793 | + 'id' => 'checkbox-example2', |
|
1794 | + 'name' => 'checkbox-example2', |
|
1795 | + 'placeholder' => 'checkbox-example', |
|
1796 | + 'title' => 'Checkbox example', |
|
1797 | + 'value' => '1', |
|
1798 | + 'checked' => false, |
|
1799 | + 'required' => false, |
|
1800 | + 'help_text' => 'help text', |
|
1801 | + 'label' => 'Checkbox un-checked' |
|
1802 | + )); |
|
1803 | + |
|
1804 | + // switch example |
|
1805 | + $output .= aui()->input(array( |
|
1806 | + 'type' => 'checkbox', |
|
1807 | + 'id' => 'switch-example', |
|
1808 | + 'name' => 'switch-example', |
|
1809 | + 'placeholder' => 'checkbox-example', |
|
1810 | + 'title' => 'Switch example', |
|
1811 | + 'value' => '1', |
|
1812 | + 'checked' => true, |
|
1813 | + 'switch' => true, |
|
1814 | + 'required' => false, |
|
1815 | + 'help_text' => 'help text', |
|
1816 | + 'label' => 'Switch on' |
|
1817 | + )); |
|
1818 | + |
|
1819 | + // switch example |
|
1820 | + $output .= aui()->input(array( |
|
1821 | + 'type' => 'checkbox', |
|
1822 | + 'id' => 'switch-example2', |
|
1823 | + 'name' => 'switch-example2', |
|
1824 | + 'placeholder' => 'checkbox-example', |
|
1825 | + 'title' => 'Switch example', |
|
1826 | + 'value' => '1', |
|
1827 | + 'checked' => false, |
|
1828 | + 'switch' => true, |
|
1829 | + 'required' => false, |
|
1830 | + 'help_text' => 'help text', |
|
1831 | + 'label' => 'Switch off' |
|
1832 | + )); |
|
1833 | + |
|
1834 | + // close form |
|
1835 | + $output .= "</form>"; |
|
1836 | + |
|
1837 | + return $output; |
|
1838 | + } |
|
1839 | + |
|
1840 | + /** |
|
1841 | + * Calendar params. |
|
1842 | + * |
|
1843 | + * @since 0.1.44 |
|
1844 | + * |
|
1845 | + * @return array Calendar params. |
|
1846 | + */ |
|
1847 | + public static function calendar_params() { |
|
1848 | + $params = array( |
|
1849 | + 'month_long_1' => __( 'January', 'aui' ), |
|
1850 | + 'month_long_2' => __( 'February', 'aui' ), |
|
1851 | + 'month_long_3' => __( 'March', 'aui' ), |
|
1852 | + 'month_long_4' => __( 'April', 'aui' ), |
|
1853 | + 'month_long_5' => __( 'May', 'aui' ), |
|
1854 | + 'month_long_6' => __( 'June', 'aui' ), |
|
1855 | + 'month_long_7' => __( 'July', 'aui' ), |
|
1856 | + 'month_long_8' => __( 'August', 'aui' ), |
|
1857 | + 'month_long_9' => __( 'September', 'aui' ), |
|
1858 | + 'month_long_10' => __( 'October', 'aui' ), |
|
1859 | + 'month_long_11' => __( 'November', 'aui' ), |
|
1860 | + 'month_long_12' => __( 'December', 'aui' ), |
|
1861 | + 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
1862 | + 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
1863 | + 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
1864 | + 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
1865 | + 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
1866 | + 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
1867 | + 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
1868 | + 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
1869 | + 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
1870 | + 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
1871 | + 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
1872 | + 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
1873 | + 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
1874 | + 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
1875 | + 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
1876 | + 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
1877 | + 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
1878 | + 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
1879 | + 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
1880 | + 'day_s2_1' => __( 'Su', 'aui' ), |
|
1881 | + 'day_s2_2' => __( 'Mo', 'aui' ), |
|
1882 | + 'day_s2_3' => __( 'Tu', 'aui' ), |
|
1883 | + 'day_s2_4' => __( 'We', 'aui' ), |
|
1884 | + 'day_s2_5' => __( 'Th', 'aui' ), |
|
1885 | + 'day_s2_6' => __( 'Fr', 'aui' ), |
|
1886 | + 'day_s2_7' => __( 'Sa', 'aui' ), |
|
1887 | + 'day_s3_1' => __( 'Sun', 'aui' ), |
|
1888 | + 'day_s3_2' => __( 'Mon', 'aui' ), |
|
1889 | + 'day_s3_3' => __( 'Tue', 'aui' ), |
|
1890 | + 'day_s3_4' => __( 'Wed', 'aui' ), |
|
1891 | + 'day_s3_5' => __( 'Thu', 'aui' ), |
|
1892 | + 'day_s3_6' => __( 'Fri', 'aui' ), |
|
1893 | + 'day_s3_7' => __( 'Sat', 'aui' ), |
|
1894 | + 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
1895 | + 'day_s5_2' => __( 'Monday', 'aui' ), |
|
1896 | + 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
1897 | + 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
1898 | + 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
1899 | + 'day_s5_6' => __( 'Friday', 'aui' ), |
|
1900 | + 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
1901 | + 'am_lower' => __( 'am', 'aui' ), |
|
1902 | + 'pm_lower' => __( 'pm', 'aui' ), |
|
1903 | + 'am_upper' => __( 'AM', 'aui' ), |
|
1904 | + 'pm_upper' => __( 'PM', 'aui' ), |
|
1905 | + 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
1906 | + 'time_24hr' => false, |
|
1907 | + 'year' => __( 'Year', 'aui' ), |
|
1908 | + 'hour' => __( 'Hour', 'aui' ), |
|
1909 | + 'minute' => __( 'Minute', 'aui' ), |
|
1910 | + 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
1911 | + 'rangeSeparator' => __( ' to ', 'aui' ), |
|
1912 | + 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
1913 | + 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
1914 | + ); |
|
1915 | + |
|
1916 | + return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
1917 | + } |
|
1918 | + |
|
1919 | + /** |
|
1920 | + * Flatpickr calendar localize. |
|
1921 | + * |
|
1922 | + * @since 0.1.44 |
|
1923 | + * |
|
1924 | + * @return string Calendar locale. |
|
1925 | + */ |
|
1926 | + public static function flatpickr_locale() { |
|
1927 | + $params = self::calendar_params(); |
|
1928 | + |
|
1929 | + if ( is_string( $params ) ) { |
|
1930 | + $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
1931 | + } else { |
|
1932 | + foreach ( (array) $params as $key => $value ) { |
|
1933 | + if ( ! is_scalar( $value ) ) { |
|
1934 | + continue; |
|
1935 | + } |
|
1936 | + |
|
1937 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
1938 | + } |
|
1939 | + } |
|
1940 | 1940 | |
1941 | - $day_s3 = array(); |
|
1942 | - $day_s5 = array(); |
|
1941 | + $day_s3 = array(); |
|
1942 | + $day_s5 = array(); |
|
1943 | 1943 | |
1944 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
1945 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1946 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1947 | - } |
|
1944 | + for ( $i = 1; $i <= 7; $i ++ ) { |
|
1945 | + $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1946 | + $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1947 | + } |
|
1948 | 1948 | |
1949 | - $month_s = array(); |
|
1950 | - $month_long = array(); |
|
1949 | + $month_s = array(); |
|
1950 | + $month_long = array(); |
|
1951 | 1951 | |
1952 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
1953 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
1954 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
1955 | - } |
|
1952 | + for ( $i = 1; $i <= 12; $i ++ ) { |
|
1953 | + $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
1954 | + $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
1955 | + } |
|
1956 | 1956 | |
1957 | 1957 | ob_start(); |
1958 | 1958 | if ( 0 ) { ?><script><?php } ?> |
@@ -1994,184 +1994,184 @@ discard block |
||
1994 | 1994 | } |
1995 | 1995 | <?php if ( 0 ) { ?></script><?php } ?> |
1996 | 1996 | <?php |
1997 | - $locale = ob_get_clean(); |
|
1998 | - |
|
1999 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
2000 | - } |
|
2001 | - |
|
2002 | - /** |
|
2003 | - * Select2 JS params. |
|
2004 | - * |
|
2005 | - * @since 0.1.44 |
|
2006 | - * |
|
2007 | - * @return array Select2 JS params. |
|
2008 | - */ |
|
2009 | - public static function select2_params() { |
|
2010 | - $params = array( |
|
2011 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
2012 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
2013 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
2014 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
2015 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
2016 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
2017 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
2018 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
2019 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
2020 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
2021 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
2022 | - ); |
|
2023 | - |
|
2024 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2025 | - } |
|
2026 | - |
|
2027 | - /** |
|
2028 | - * Select2 JS localize. |
|
2029 | - * |
|
2030 | - * @since 0.1.44 |
|
2031 | - * |
|
2032 | - * @return string Select2 JS locale. |
|
2033 | - */ |
|
2034 | - public static function select2_locale() { |
|
2035 | - $params = self::select2_params(); |
|
2036 | - |
|
2037 | - foreach ( (array) $params as $key => $value ) { |
|
2038 | - if ( ! is_scalar( $value ) ) { |
|
2039 | - continue; |
|
2040 | - } |
|
2041 | - |
|
2042 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2043 | - } |
|
2044 | - |
|
2045 | - $locale = json_encode( $params ); |
|
2046 | - |
|
2047 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2048 | - } |
|
2049 | - |
|
2050 | - /** |
|
2051 | - * Time ago JS localize. |
|
2052 | - * |
|
2053 | - * @since 0.1.47 |
|
2054 | - * |
|
2055 | - * @return string Time ago JS locale. |
|
2056 | - */ |
|
2057 | - public static function timeago_locale() { |
|
2058 | - $params = array( |
|
2059 | - 'prefix_ago' => '', |
|
2060 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
2061 | - 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
2062 | - 'suffix_after' => '', |
|
2063 | - 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
2064 | - 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
2065 | - 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
2066 | - 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
2067 | - 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
2068 | - 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
2069 | - 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
2070 | - 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
2071 | - 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
2072 | - 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
2073 | - 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
2074 | - ); |
|
2075 | - |
|
2076 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2077 | - |
|
2078 | - foreach ( (array) $params as $key => $value ) { |
|
2079 | - if ( ! is_scalar( $value ) ) { |
|
2080 | - continue; |
|
2081 | - } |
|
2082 | - |
|
2083 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2084 | - } |
|
2085 | - |
|
2086 | - $locale = json_encode( $params ); |
|
2087 | - |
|
2088 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2089 | - } |
|
2090 | - |
|
2091 | - /** |
|
2092 | - * JavaScript Minifier |
|
2093 | - * |
|
2094 | - * @param $input |
|
2095 | - * |
|
2096 | - * @return mixed |
|
2097 | - */ |
|
2098 | - public static function minify_js($input) { |
|
2099 | - if(trim($input) === "") return $input; |
|
2100 | - return preg_replace( |
|
2101 | - array( |
|
2102 | - // Remove comment(s) |
|
2103 | - '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
2104 | - // Remove white-space(s) outside the string and regex |
|
2105 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
2106 | - // Remove the last semicolon |
|
2107 | - '#;+\}#', |
|
2108 | - // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
2109 | - '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
2110 | - // --ibid. From `foo['bar']` to `foo.bar` |
|
2111 | - '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
2112 | - ), |
|
2113 | - array( |
|
2114 | - '$1', |
|
2115 | - '$1$2', |
|
2116 | - '}', |
|
2117 | - '$1$3', |
|
2118 | - '$1.$3' |
|
2119 | - ), |
|
2120 | - $input); |
|
2121 | - } |
|
1997 | + $locale = ob_get_clean(); |
|
1998 | + |
|
1999 | + return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
2000 | + } |
|
2001 | + |
|
2002 | + /** |
|
2003 | + * Select2 JS params. |
|
2004 | + * |
|
2005 | + * @since 0.1.44 |
|
2006 | + * |
|
2007 | + * @return array Select2 JS params. |
|
2008 | + */ |
|
2009 | + public static function select2_params() { |
|
2010 | + $params = array( |
|
2011 | + 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
2012 | + 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
2013 | + 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
2014 | + 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
2015 | + 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
2016 | + 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
2017 | + 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
2018 | + 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
2019 | + 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
2020 | + 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
2021 | + 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
2022 | + ); |
|
2023 | + |
|
2024 | + return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2025 | + } |
|
2026 | + |
|
2027 | + /** |
|
2028 | + * Select2 JS localize. |
|
2029 | + * |
|
2030 | + * @since 0.1.44 |
|
2031 | + * |
|
2032 | + * @return string Select2 JS locale. |
|
2033 | + */ |
|
2034 | + public static function select2_locale() { |
|
2035 | + $params = self::select2_params(); |
|
2036 | + |
|
2037 | + foreach ( (array) $params as $key => $value ) { |
|
2038 | + if ( ! is_scalar( $value ) ) { |
|
2039 | + continue; |
|
2040 | + } |
|
2122 | 2041 | |
2123 | - /** |
|
2124 | - * Minify CSS |
|
2125 | - * |
|
2126 | - * @param $input |
|
2127 | - * |
|
2128 | - * @return mixed |
|
2129 | - */ |
|
2130 | - public static function minify_css($input) { |
|
2131 | - if(trim($input) === "") return $input; |
|
2132 | - return preg_replace( |
|
2133 | - array( |
|
2134 | - // Remove comment(s) |
|
2135 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
2136 | - // Remove unused white-space(s) |
|
2137 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
2138 | - // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
2139 | - '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
2140 | - // Replace `:0 0 0 0` with `:0` |
|
2141 | - '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
2142 | - // Replace `background-position:0` with `background-position:0 0` |
|
2143 | - '#(background-position):0(?=[;\}])#si', |
|
2144 | - // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
2145 | - '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
2146 | - // Minify string value |
|
2147 | - '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
2148 | - '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
2149 | - // Minify HEX color code |
|
2150 | - '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
2151 | - // Replace `(border|outline):none` with `(border|outline):0` |
|
2152 | - '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
2153 | - // Remove empty selector(s) |
|
2154 | - '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
2155 | - ), |
|
2156 | - array( |
|
2157 | - '$1', |
|
2158 | - '$1$2$3$4$5$6$7', |
|
2159 | - '$1', |
|
2160 | - ':0', |
|
2161 | - '$1:0 0', |
|
2162 | - '.$1', |
|
2163 | - '$1$3', |
|
2164 | - '$1$2$4$5', |
|
2165 | - '$1$2$3', |
|
2166 | - '$1:0', |
|
2167 | - '$1$2' |
|
2168 | - ), |
|
2169 | - $input); |
|
2170 | - } |
|
2171 | - } |
|
2042 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2043 | + } |
|
2044 | + |
|
2045 | + $locale = json_encode( $params ); |
|
2046 | + |
|
2047 | + return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2048 | + } |
|
2049 | + |
|
2050 | + /** |
|
2051 | + * Time ago JS localize. |
|
2052 | + * |
|
2053 | + * @since 0.1.47 |
|
2054 | + * |
|
2055 | + * @return string Time ago JS locale. |
|
2056 | + */ |
|
2057 | + public static function timeago_locale() { |
|
2058 | + $params = array( |
|
2059 | + 'prefix_ago' => '', |
|
2060 | + 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
2061 | + 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
2062 | + 'suffix_after' => '', |
|
2063 | + 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
2064 | + 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
2065 | + 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
2066 | + 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
2067 | + 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
2068 | + 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
2069 | + 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
2070 | + 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
2071 | + 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
2072 | + 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
2073 | + 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
2074 | + ); |
|
2075 | + |
|
2076 | + $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2077 | + |
|
2078 | + foreach ( (array) $params as $key => $value ) { |
|
2079 | + if ( ! is_scalar( $value ) ) { |
|
2080 | + continue; |
|
2081 | + } |
|
2172 | 2082 | |
2173 | - /** |
|
2174 | - * Run the class if found. |
|
2175 | - */ |
|
2176 | - AyeCode_UI_Settings::instance(); |
|
2083 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2084 | + } |
|
2085 | + |
|
2086 | + $locale = json_encode( $params ); |
|
2087 | + |
|
2088 | + return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2089 | + } |
|
2090 | + |
|
2091 | + /** |
|
2092 | + * JavaScript Minifier |
|
2093 | + * |
|
2094 | + * @param $input |
|
2095 | + * |
|
2096 | + * @return mixed |
|
2097 | + */ |
|
2098 | + public static function minify_js($input) { |
|
2099 | + if(trim($input) === "") return $input; |
|
2100 | + return preg_replace( |
|
2101 | + array( |
|
2102 | + // Remove comment(s) |
|
2103 | + '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
2104 | + // Remove white-space(s) outside the string and regex |
|
2105 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
2106 | + // Remove the last semicolon |
|
2107 | + '#;+\}#', |
|
2108 | + // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
2109 | + '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
2110 | + // --ibid. From `foo['bar']` to `foo.bar` |
|
2111 | + '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
2112 | + ), |
|
2113 | + array( |
|
2114 | + '$1', |
|
2115 | + '$1$2', |
|
2116 | + '}', |
|
2117 | + '$1$3', |
|
2118 | + '$1.$3' |
|
2119 | + ), |
|
2120 | + $input); |
|
2121 | + } |
|
2122 | + |
|
2123 | + /** |
|
2124 | + * Minify CSS |
|
2125 | + * |
|
2126 | + * @param $input |
|
2127 | + * |
|
2128 | + * @return mixed |
|
2129 | + */ |
|
2130 | + public static function minify_css($input) { |
|
2131 | + if(trim($input) === "") return $input; |
|
2132 | + return preg_replace( |
|
2133 | + array( |
|
2134 | + // Remove comment(s) |
|
2135 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
2136 | + // Remove unused white-space(s) |
|
2137 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
2138 | + // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
2139 | + '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
2140 | + // Replace `:0 0 0 0` with `:0` |
|
2141 | + '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
2142 | + // Replace `background-position:0` with `background-position:0 0` |
|
2143 | + '#(background-position):0(?=[;\}])#si', |
|
2144 | + // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
2145 | + '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
2146 | + // Minify string value |
|
2147 | + '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
2148 | + '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
2149 | + // Minify HEX color code |
|
2150 | + '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
2151 | + // Replace `(border|outline):none` with `(border|outline):0` |
|
2152 | + '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
2153 | + // Remove empty selector(s) |
|
2154 | + '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
2155 | + ), |
|
2156 | + array( |
|
2157 | + '$1', |
|
2158 | + '$1$2$3$4$5$6$7', |
|
2159 | + '$1', |
|
2160 | + ':0', |
|
2161 | + '$1:0 0', |
|
2162 | + '.$1', |
|
2163 | + '$1$3', |
|
2164 | + '$1$2$4$5', |
|
2165 | + '$1$2$3', |
|
2166 | + '$1:0', |
|
2167 | + '$1$2' |
|
2168 | + ), |
|
2169 | + $input); |
|
2170 | + } |
|
2171 | + } |
|
2172 | + |
|
2173 | + /** |
|
2174 | + * Run the class if found. |
|
2175 | + */ |
|
2176 | + AyeCode_UI_Settings::instance(); |
|
2177 | 2177 | } |
2178 | 2178 | \ No newline at end of file |
@@ -7,40 +7,40 @@ |
||
7 | 7 | * Bail if we are not in WP. |
8 | 8 | */ |
9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
10 | - exit; |
|
10 | + exit; |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Set the version only if its the current newest while loading. |
15 | 15 | */ |
16 | 16 | add_action('after_setup_theme', function () { |
17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
18 | - $this_version = "0.1.49"; |
|
19 | - if(version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | - $ayecode_ui_version = $this_version ; |
|
21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
22 | - } |
|
17 | + global $ayecode_ui_version,$ayecode_ui_file_key; |
|
18 | + $this_version = "0.1.49"; |
|
19 | + if(version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | + $ayecode_ui_version = $this_version ; |
|
21 | + $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
22 | + } |
|
23 | 23 | },0); |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
27 | 27 | */ |
28 | 28 | add_action('after_setup_theme', function () { |
29 | - global $ayecode_ui_file_key; |
|
30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
33 | - } |
|
29 | + global $ayecode_ui_file_key; |
|
30 | + if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | + include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | + include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
33 | + } |
|
34 | 34 | },1); |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Add the function that calls the class. |
38 | 38 | */ |
39 | 39 | if(!function_exists('aui')){ |
40 | - function aui(){ |
|
41 | - if(!class_exists("AUI",false)){ |
|
42 | - return false; |
|
43 | - } |
|
44 | - return AUI::instance(); |
|
45 | - } |
|
40 | + function aui(){ |
|
41 | + if(!class_exists("AUI",false)){ |
|
42 | + return false; |
|
43 | + } |
|
44 | + return AUI::instance(); |
|
45 | + } |
|
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -6,39 +6,39 @@ |
||
6 | 6 | /** |
7 | 7 | * Bail if we are not in WP. |
8 | 8 | */ |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Set the version only if its the current newest while loading. |
15 | 15 | */ |
16 | -add_action('after_setup_theme', function () { |
|
17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
16 | +add_action('after_setup_theme', function() { |
|
17 | + global $ayecode_ui_version, $ayecode_ui_file_key; |
|
18 | 18 | $this_version = "0.1.49"; |
19 | - if(version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | - $ayecode_ui_version = $this_version ; |
|
21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
19 | + if (version_compare($this_version, $ayecode_ui_version, '>')) { |
|
20 | + $ayecode_ui_version = $this_version; |
|
21 | + $ayecode_ui_file_key = wp_hash(__FILE__); |
|
22 | 22 | } |
23 | 23 | },0); |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
27 | 27 | */ |
28 | -add_action('after_setup_theme', function () { |
|
28 | +add_action('after_setup_theme', function() { |
|
29 | 29 | global $ayecode_ui_file_key; |
30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
30 | + if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) { |
|
31 | + include_once(dirname(__FILE__) . '/includes/class-aui.php'); |
|
32 | + include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php'); |
|
33 | 33 | } |
34 | 34 | },1); |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Add the function that calls the class. |
38 | 38 | */ |
39 | -if(!function_exists('aui')){ |
|
40 | - function aui(){ |
|
41 | - if(!class_exists("AUI",false)){ |
|
39 | +if (!function_exists('aui')) { |
|
40 | + function aui() { |
|
41 | + if (!class_exists("AUI", false)) { |
|
42 | 42 | return false; |
43 | 43 | } |
44 | 44 | return AUI::instance(); |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | class InstalledVersions |
13 | 13 | { |
14 | 14 | private static $installed = array ( |
15 | - 'root' => |
|
16 | - array ( |
|
15 | + 'root' => |
|
16 | + array ( |
|
17 | 17 | 'pretty_version' => 'dev-master', |
18 | 18 | 'version' => 'dev-master', |
19 | 19 | 'aliases' => |
@@ -21,87 +21,87 @@ discard block |
||
21 | 21 | ), |
22 | 22 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
23 | 23 | 'name' => 'ayecode/invoicing', |
24 | - ), |
|
25 | - 'versions' => |
|
26 | - array ( |
|
24 | + ), |
|
25 | + 'versions' => |
|
26 | + array ( |
|
27 | 27 | 'ayecode/ayecode-connect-helper' => |
28 | 28 | array ( |
29 | - 'pretty_version' => '1.0.3', |
|
30 | - 'version' => '1.0.3.0', |
|
31 | - 'aliases' => |
|
32 | - array ( |
|
33 | - ), |
|
34 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
29 | + 'pretty_version' => '1.0.3', |
|
30 | + 'version' => '1.0.3.0', |
|
31 | + 'aliases' => |
|
32 | + array ( |
|
33 | + ), |
|
34 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
35 | 35 | ), |
36 | 36 | 'ayecode/invoicing' => |
37 | 37 | array ( |
38 | - 'pretty_version' => 'dev-master', |
|
39 | - 'version' => 'dev-master', |
|
40 | - 'aliases' => |
|
41 | - array ( |
|
42 | - ), |
|
43 | - 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
|
38 | + 'pretty_version' => 'dev-master', |
|
39 | + 'version' => 'dev-master', |
|
40 | + 'aliases' => |
|
41 | + array ( |
|
42 | + ), |
|
43 | + 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
|
44 | 44 | ), |
45 | 45 | 'ayecode/wp-ayecode-ui' => |
46 | 46 | array ( |
47 | - 'pretty_version' => '0.1.49', |
|
48 | - 'version' => '0.1.49.0', |
|
49 | - 'aliases' => |
|
50 | - array ( |
|
51 | - ), |
|
52 | - 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
|
47 | + 'pretty_version' => '0.1.49', |
|
48 | + 'version' => '0.1.49.0', |
|
49 | + 'aliases' => |
|
50 | + array ( |
|
51 | + ), |
|
52 | + 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
|
53 | 53 | ), |
54 | 54 | 'ayecode/wp-font-awesome-settings' => |
55 | 55 | array ( |
56 | - 'pretty_version' => '1.0.12', |
|
57 | - 'version' => '1.0.12.0', |
|
58 | - 'aliases' => |
|
59 | - array ( |
|
60 | - ), |
|
61 | - 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
56 | + 'pretty_version' => '1.0.12', |
|
57 | + 'version' => '1.0.12.0', |
|
58 | + 'aliases' => |
|
59 | + array ( |
|
60 | + ), |
|
61 | + 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
62 | 62 | ), |
63 | 63 | 'ayecode/wp-super-duper' => |
64 | 64 | array ( |
65 | - 'pretty_version' => '1.0.26', |
|
66 | - 'version' => '1.0.26.0', |
|
67 | - 'aliases' => |
|
68 | - array ( |
|
69 | - ), |
|
70 | - 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
|
65 | + 'pretty_version' => '1.0.26', |
|
66 | + 'version' => '1.0.26.0', |
|
67 | + 'aliases' => |
|
68 | + array ( |
|
69 | + ), |
|
70 | + 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
|
71 | 71 | ), |
72 | 72 | 'composer/installers' => |
73 | 73 | array ( |
74 | - 'pretty_version' => 'v1.11.0', |
|
75 | - 'version' => '1.11.0.0', |
|
76 | - 'aliases' => |
|
77 | - array ( |
|
78 | - ), |
|
79 | - 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
74 | + 'pretty_version' => 'v1.11.0', |
|
75 | + 'version' => '1.11.0.0', |
|
76 | + 'aliases' => |
|
77 | + array ( |
|
78 | + ), |
|
79 | + 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
80 | 80 | ), |
81 | 81 | 'maxmind-db/reader' => |
82 | 82 | array ( |
83 | - 'pretty_version' => 'v1.6.0', |
|
84 | - 'version' => '1.6.0.0', |
|
85 | - 'aliases' => |
|
86 | - array ( |
|
87 | - ), |
|
88 | - 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
83 | + 'pretty_version' => 'v1.6.0', |
|
84 | + 'version' => '1.6.0.0', |
|
85 | + 'aliases' => |
|
86 | + array ( |
|
87 | + ), |
|
88 | + 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
89 | 89 | ), |
90 | 90 | 'roundcube/plugin-installer' => |
91 | 91 | array ( |
92 | - 'replaced' => |
|
93 | - array ( |
|
92 | + 'replaced' => |
|
93 | + array ( |
|
94 | 94 | 0 => '*', |
95 | - ), |
|
95 | + ), |
|
96 | 96 | ), |
97 | 97 | 'shama/baton' => |
98 | 98 | array ( |
99 | - 'replaced' => |
|
100 | - array ( |
|
99 | + 'replaced' => |
|
100 | + array ( |
|
101 | 101 | 0 => '*', |
102 | - ), |
|
102 | + ), |
|
103 | + ), |
|
103 | 104 | ), |
104 | - ), |
|
105 | 105 | ); |
106 | 106 | |
107 | 107 |
@@ -11,93 +11,93 @@ |
||
11 | 11 | |
12 | 12 | class InstalledVersions |
13 | 13 | { |
14 | -private static $installed = array ( |
|
14 | +private static $installed = array( |
|
15 | 15 | 'root' => |
16 | - array ( |
|
16 | + array( |
|
17 | 17 | 'pretty_version' => 'dev-master', |
18 | 18 | 'version' => 'dev-master', |
19 | 19 | 'aliases' => |
20 | - array ( |
|
20 | + array( |
|
21 | 21 | ), |
22 | 22 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
23 | 23 | 'name' => 'ayecode/invoicing', |
24 | 24 | ), |
25 | 25 | 'versions' => |
26 | - array ( |
|
26 | + array( |
|
27 | 27 | 'ayecode/ayecode-connect-helper' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | 'pretty_version' => '1.0.3', |
30 | 30 | 'version' => '1.0.3.0', |
31 | 31 | 'aliases' => |
32 | - array ( |
|
32 | + array( |
|
33 | 33 | ), |
34 | 34 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
35 | 35 | ), |
36 | 36 | 'ayecode/invoicing' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | 'pretty_version' => 'dev-master', |
39 | 39 | 'version' => 'dev-master', |
40 | 40 | 'aliases' => |
41 | - array ( |
|
41 | + array( |
|
42 | 42 | ), |
43 | 43 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
44 | 44 | ), |
45 | 45 | 'ayecode/wp-ayecode-ui' => |
46 | - array ( |
|
46 | + array( |
|
47 | 47 | 'pretty_version' => '0.1.49', |
48 | 48 | 'version' => '0.1.49.0', |
49 | 49 | 'aliases' => |
50 | - array ( |
|
50 | + array( |
|
51 | 51 | ), |
52 | 52 | 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
53 | 53 | ), |
54 | 54 | 'ayecode/wp-font-awesome-settings' => |
55 | - array ( |
|
55 | + array( |
|
56 | 56 | 'pretty_version' => '1.0.12', |
57 | 57 | 'version' => '1.0.12.0', |
58 | 58 | 'aliases' => |
59 | - array ( |
|
59 | + array( |
|
60 | 60 | ), |
61 | 61 | 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
62 | 62 | ), |
63 | 63 | 'ayecode/wp-super-duper' => |
64 | - array ( |
|
64 | + array( |
|
65 | 65 | 'pretty_version' => '1.0.26', |
66 | 66 | 'version' => '1.0.26.0', |
67 | 67 | 'aliases' => |
68 | - array ( |
|
68 | + array( |
|
69 | 69 | ), |
70 | 70 | 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
71 | 71 | ), |
72 | 72 | 'composer/installers' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | 'pretty_version' => 'v1.11.0', |
75 | 75 | 'version' => '1.11.0.0', |
76 | 76 | 'aliases' => |
77 | - array ( |
|
77 | + array( |
|
78 | 78 | ), |
79 | 79 | 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
80 | 80 | ), |
81 | 81 | 'maxmind-db/reader' => |
82 | - array ( |
|
82 | + array( |
|
83 | 83 | 'pretty_version' => 'v1.6.0', |
84 | 84 | 'version' => '1.6.0.0', |
85 | 85 | 'aliases' => |
86 | - array ( |
|
86 | + array( |
|
87 | 87 | ), |
88 | 88 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
89 | 89 | ), |
90 | 90 | 'roundcube/plugin-installer' => |
91 | - array ( |
|
91 | + array( |
|
92 | 92 | 'replaced' => |
93 | - array ( |
|
93 | + array( |
|
94 | 94 | 0 => '*', |
95 | 95 | ), |
96 | 96 | ), |
97 | 97 | 'shama/baton' => |
98 | - array ( |
|
98 | + array( |
|
99 | 99 | 'replaced' => |
100 | - array ( |
|
100 | + array( |
|
101 | 101 | 0 => '*', |
102 | 102 | ), |
103 | 103 | ), |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php return array ( |
2 | - 'root' => |
|
3 | - array ( |
|
2 | + 'root' => |
|
3 | + array ( |
|
4 | 4 | 'pretty_version' => 'dev-master', |
5 | 5 | 'version' => 'dev-master', |
6 | 6 | 'aliases' => |
@@ -8,85 +8,85 @@ discard block |
||
8 | 8 | ), |
9 | 9 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
10 | 10 | 'name' => 'ayecode/invoicing', |
11 | - ), |
|
12 | - 'versions' => |
|
13 | - array ( |
|
11 | + ), |
|
12 | + 'versions' => |
|
13 | + array ( |
|
14 | 14 | 'ayecode/ayecode-connect-helper' => |
15 | 15 | array ( |
16 | - 'pretty_version' => '1.0.3', |
|
17 | - 'version' => '1.0.3.0', |
|
18 | - 'aliases' => |
|
19 | - array ( |
|
20 | - ), |
|
21 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
16 | + 'pretty_version' => '1.0.3', |
|
17 | + 'version' => '1.0.3.0', |
|
18 | + 'aliases' => |
|
19 | + array ( |
|
20 | + ), |
|
21 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
22 | 22 | ), |
23 | 23 | 'ayecode/invoicing' => |
24 | 24 | array ( |
25 | - 'pretty_version' => 'dev-master', |
|
26 | - 'version' => 'dev-master', |
|
27 | - 'aliases' => |
|
28 | - array ( |
|
29 | - ), |
|
30 | - 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
|
25 | + 'pretty_version' => 'dev-master', |
|
26 | + 'version' => 'dev-master', |
|
27 | + 'aliases' => |
|
28 | + array ( |
|
29 | + ), |
|
30 | + 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
|
31 | 31 | ), |
32 | 32 | 'ayecode/wp-ayecode-ui' => |
33 | 33 | array ( |
34 | - 'pretty_version' => '0.1.49', |
|
35 | - 'version' => '0.1.49.0', |
|
36 | - 'aliases' => |
|
37 | - array ( |
|
38 | - ), |
|
39 | - 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
|
34 | + 'pretty_version' => '0.1.49', |
|
35 | + 'version' => '0.1.49.0', |
|
36 | + 'aliases' => |
|
37 | + array ( |
|
38 | + ), |
|
39 | + 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
|
40 | 40 | ), |
41 | 41 | 'ayecode/wp-font-awesome-settings' => |
42 | 42 | array ( |
43 | - 'pretty_version' => '1.0.12', |
|
44 | - 'version' => '1.0.12.0', |
|
45 | - 'aliases' => |
|
46 | - array ( |
|
47 | - ), |
|
48 | - 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
43 | + 'pretty_version' => '1.0.12', |
|
44 | + 'version' => '1.0.12.0', |
|
45 | + 'aliases' => |
|
46 | + array ( |
|
47 | + ), |
|
48 | + 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
49 | 49 | ), |
50 | 50 | 'ayecode/wp-super-duper' => |
51 | 51 | array ( |
52 | - 'pretty_version' => '1.0.26', |
|
53 | - 'version' => '1.0.26.0', |
|
54 | - 'aliases' => |
|
55 | - array ( |
|
56 | - ), |
|
57 | - 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
|
52 | + 'pretty_version' => '1.0.26', |
|
53 | + 'version' => '1.0.26.0', |
|
54 | + 'aliases' => |
|
55 | + array ( |
|
56 | + ), |
|
57 | + 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
|
58 | 58 | ), |
59 | 59 | 'composer/installers' => |
60 | 60 | array ( |
61 | - 'pretty_version' => 'v1.11.0', |
|
62 | - 'version' => '1.11.0.0', |
|
63 | - 'aliases' => |
|
64 | - array ( |
|
65 | - ), |
|
66 | - 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
61 | + 'pretty_version' => 'v1.11.0', |
|
62 | + 'version' => '1.11.0.0', |
|
63 | + 'aliases' => |
|
64 | + array ( |
|
65 | + ), |
|
66 | + 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
67 | 67 | ), |
68 | 68 | 'maxmind-db/reader' => |
69 | 69 | array ( |
70 | - 'pretty_version' => 'v1.6.0', |
|
71 | - 'version' => '1.6.0.0', |
|
72 | - 'aliases' => |
|
73 | - array ( |
|
74 | - ), |
|
75 | - 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
70 | + 'pretty_version' => 'v1.6.0', |
|
71 | + 'version' => '1.6.0.0', |
|
72 | + 'aliases' => |
|
73 | + array ( |
|
74 | + ), |
|
75 | + 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
76 | 76 | ), |
77 | 77 | 'roundcube/plugin-installer' => |
78 | 78 | array ( |
79 | - 'replaced' => |
|
80 | - array ( |
|
79 | + 'replaced' => |
|
80 | + array ( |
|
81 | 81 | 0 => '*', |
82 | - ), |
|
82 | + ), |
|
83 | 83 | ), |
84 | 84 | 'shama/baton' => |
85 | 85 | array ( |
86 | - 'replaced' => |
|
87 | - array ( |
|
86 | + 'replaced' => |
|
87 | + array ( |
|
88 | 88 | 0 => '*', |
89 | - ), |
|
89 | + ), |
|
90 | + ), |
|
90 | 91 | ), |
91 | - ), |
|
92 | 92 | ); |
@@ -1,90 +1,90 @@ |
||
1 | -<?php return array ( |
|
1 | +<?php return array( |
|
2 | 2 | 'root' => |
3 | - array ( |
|
3 | + array( |
|
4 | 4 | 'pretty_version' => 'dev-master', |
5 | 5 | 'version' => 'dev-master', |
6 | 6 | 'aliases' => |
7 | - array ( |
|
7 | + array( |
|
8 | 8 | ), |
9 | 9 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
10 | 10 | 'name' => 'ayecode/invoicing', |
11 | 11 | ), |
12 | 12 | 'versions' => |
13 | - array ( |
|
13 | + array( |
|
14 | 14 | 'ayecode/ayecode-connect-helper' => |
15 | - array ( |
|
15 | + array( |
|
16 | 16 | 'pretty_version' => '1.0.3', |
17 | 17 | 'version' => '1.0.3.0', |
18 | 18 | 'aliases' => |
19 | - array ( |
|
19 | + array( |
|
20 | 20 | ), |
21 | 21 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
22 | 22 | ), |
23 | 23 | 'ayecode/invoicing' => |
24 | - array ( |
|
24 | + array( |
|
25 | 25 | 'pretty_version' => 'dev-master', |
26 | 26 | 'version' => 'dev-master', |
27 | 27 | 'aliases' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | ), |
30 | 30 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
31 | 31 | ), |
32 | 32 | 'ayecode/wp-ayecode-ui' => |
33 | - array ( |
|
33 | + array( |
|
34 | 34 | 'pretty_version' => '0.1.49', |
35 | 35 | 'version' => '0.1.49.0', |
36 | 36 | 'aliases' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | ), |
39 | 39 | 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
40 | 40 | ), |
41 | 41 | 'ayecode/wp-font-awesome-settings' => |
42 | - array ( |
|
42 | + array( |
|
43 | 43 | 'pretty_version' => '1.0.12', |
44 | 44 | 'version' => '1.0.12.0', |
45 | 45 | 'aliases' => |
46 | - array ( |
|
46 | + array( |
|
47 | 47 | ), |
48 | 48 | 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
49 | 49 | ), |
50 | 50 | 'ayecode/wp-super-duper' => |
51 | - array ( |
|
51 | + array( |
|
52 | 52 | 'pretty_version' => '1.0.26', |
53 | 53 | 'version' => '1.0.26.0', |
54 | 54 | 'aliases' => |
55 | - array ( |
|
55 | + array( |
|
56 | 56 | ), |
57 | 57 | 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
58 | 58 | ), |
59 | 59 | 'composer/installers' => |
60 | - array ( |
|
60 | + array( |
|
61 | 61 | 'pretty_version' => 'v1.11.0', |
62 | 62 | 'version' => '1.11.0.0', |
63 | 63 | 'aliases' => |
64 | - array ( |
|
64 | + array( |
|
65 | 65 | ), |
66 | 66 | 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
67 | 67 | ), |
68 | 68 | 'maxmind-db/reader' => |
69 | - array ( |
|
69 | + array( |
|
70 | 70 | 'pretty_version' => 'v1.6.0', |
71 | 71 | 'version' => '1.6.0.0', |
72 | 72 | 'aliases' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | ), |
75 | 75 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
76 | 76 | ), |
77 | 77 | 'roundcube/plugin-installer' => |
78 | - array ( |
|
78 | + array( |
|
79 | 79 | 'replaced' => |
80 | - array ( |
|
80 | + array( |
|
81 | 81 | 0 => '*', |
82 | 82 | ), |
83 | 83 | ), |
84 | 84 | 'shama/baton' => |
85 | - array ( |
|
85 | + array( |
|
86 | 86 | 'replaced' => |
87 | - array ( |
|
87 | + array( |
|
88 | 88 | 0 => '*', |
89 | 89 | ), |
90 | 90 | ), |