@@ -6,7 +6,7 @@ |
||
6 | 6 | if (!headers_sent()) { |
7 | 7 | header('HTTP/1.1 500 Internal Server Error'); |
8 | 8 | } |
9 | - $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; |
|
9 | + $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running ' . PHP_VERSION . ', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.' . PHP_EOL; |
|
10 | 10 | if (!ini_get('display_errors')) { |
11 | 11 | if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
12 | 12 | fwrite(STDERR, $err); |
@@ -327,11 +327,11 @@ |
||
327 | 327 | foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { |
328 | 328 | if (isset(self::$installedByVendor[$vendorDir])) { |
329 | 329 | $installed[] = self::$installedByVendor[$vendorDir]; |
330 | - } elseif (is_file($vendorDir.'/composer/installed.php')) { |
|
330 | + } elseif (is_file($vendorDir . '/composer/installed.php')) { |
|
331 | 331 | /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ |
332 | - $required = require $vendorDir.'/composer/installed.php'; |
|
332 | + $required = require $vendorDir . '/composer/installed.php'; |
|
333 | 333 | $installed[] = self::$installedByVendor[$vendorDir] = $required; |
334 | - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { |
|
334 | + if (null === self::$installed && strtr($vendorDir . '/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { |
|
335 | 335 | self::$installed = $installed[count($installed) - 1]; |
336 | 336 | } |
337 | 337 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | $loader->register(true); |
35 | 35 | |
36 | 36 | $filesToLoad = \Composer\Autoload\ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$files; |
37 | - $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { |
|
37 | + $requireFile = \Closure::bind(static function($fileIdentifier, $file) { |
|
38 | 38 | if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { |
39 | 39 | $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; |
40 | 40 |
@@ -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 | global $aui_bs5; |
23 | 23 | |
24 | 24 | $defaults = array( |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | /** |
70 | 70 | * Parse incoming $args into an array and merge it with $defaults |
71 | 71 | */ |
72 | - $args = wp_parse_args( $args, $defaults ); |
|
72 | + $args = wp_parse_args($args, $defaults); |
|
73 | 73 | $output = ''; |
74 | - if ( ! empty( $args['type'] ) ) { |
|
74 | + if (!empty($args['type'])) { |
|
75 | 75 | // hidden label option needs to be empty |
76 | 76 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
77 | 77 | |
78 | - $type = sanitize_html_class( $args['type'] ); |
|
78 | + $type = sanitize_html_class($args['type']); |
|
79 | 79 | |
80 | 80 | $help_text = ''; |
81 | 81 | $label = ''; |
@@ -89,17 +89,17 @@ discard block |
||
89 | 89 | ); |
90 | 90 | |
91 | 91 | // floating labels need label after |
92 | - if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) { |
|
92 | + if ($args['label_type'] == 'floating' && $type != 'checkbox') { |
|
93 | 93 | $label_after = true; |
94 | 94 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
95 | 95 | } |
96 | 96 | |
97 | 97 | // size |
98 | 98 | $size = ''; |
99 | - if ( $args['size'] == 'lg' || $args['size'] == 'large' ) { |
|
99 | + if ($args['size'] == 'lg' || $args['size'] == 'large') { |
|
100 | 100 | $size = 'lg'; |
101 | 101 | $args['class'] .= ' form-control-lg'; |
102 | - }elseif ( $args['size'] == 'sm' || $args['size'] == 'small' ) { |
|
102 | + }elseif ($args['size'] == 'sm' || $args['size'] == 'small') { |
|
103 | 103 | $size = 'sm'; |
104 | 104 | $args['class'] .= ' form-control-sm'; |
105 | 105 | } |
@@ -108,28 +108,28 @@ discard block |
||
108 | 108 | $clear_function = 'jQuery(this).parent().parent().find(\'input\').val(\'\');'; |
109 | 109 | |
110 | 110 | // Some special sauce for files |
111 | - if ( $type == 'file' ) { |
|
111 | + if ($type == 'file') { |
|
112 | 112 | $label_after = true; // if type file we need the label after |
113 | 113 | $args['class'] .= ' custom-file-input '; |
114 | - } elseif ( $type == 'checkbox' ) { |
|
114 | + } elseif ($type == 'checkbox') { |
|
115 | 115 | $label_after = true; // if type file we need the label after |
116 | 116 | $args['class'] .= $aui_bs5 ? ' form-check-input c-pointer ' : ' custom-control-input c-pointer '; |
117 | - } elseif ( $type == 'datepicker' || $type == 'timepicker' ) { |
|
117 | + } elseif ($type == 'datepicker' || $type == 'timepicker') { |
|
118 | 118 | $orig_type = $type; |
119 | 119 | $type = 'text'; |
120 | 120 | $args['class'] .= ' bg-initial '; // @todo not sure why we have this? |
121 | - $clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr( $args['name'] ) . "\']').trigger('change');"; |
|
121 | + $clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr($args['name']) . "\']').trigger('change');"; |
|
122 | 122 | |
123 | 123 | $args['extra_attributes']['data-aui-init'] = 'flatpickr'; |
124 | 124 | |
125 | 125 | // Disable native datetime inputs. |
126 | - $disable_mobile_attr = isset( $args['extra_attributes']['data-disable-mobile'] ) ? $args['extra_attributes']['data-disable-mobile'] : 'true'; |
|
127 | - $disable_mobile_attr = apply_filters( 'aui_flatpickr_disable_disable_mobile_attr', $disable_mobile_attr, $args ); |
|
126 | + $disable_mobile_attr = isset($args['extra_attributes']['data-disable-mobile']) ? $args['extra_attributes']['data-disable-mobile'] : 'true'; |
|
127 | + $disable_mobile_attr = apply_filters('aui_flatpickr_disable_disable_mobile_attr', $disable_mobile_attr, $args); |
|
128 | 128 | |
129 | 129 | $args['extra_attributes']['data-disable-mobile'] = $disable_mobile_attr; |
130 | 130 | |
131 | 131 | // set a way to clear field if empty |
132 | - if ( $args['input_group_right'] === '' && $args['clear_icon'] !== false ) { |
|
132 | + if ($args['input_group_right'] === '' && $args['clear_icon'] !== false) { |
|
133 | 133 | $args['input_group_right_inside'] = true; |
134 | 134 | $args['clear_icon'] = true; |
135 | 135 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | // enqueue the script |
138 | 138 | $aui_settings = AyeCode_UI_Settings::instance(); |
139 | 139 | $aui_settings->enqueue_flatpickr(); |
140 | - } elseif ( $type == 'iconpicker' ) { |
|
140 | + } elseif ($type == 'iconpicker') { |
|
141 | 141 | $type = 'text'; |
142 | 142 | //$args['class'] .= ' aui-flatpickr bg-initial '; |
143 | 143 | // $args['class'] .= ' bg-initial '; |
@@ -152,104 +152,104 @@ discard block |
||
152 | 152 | $aui_settings->enqueue_iconpicker(); |
153 | 153 | } |
154 | 154 | |
155 | - if ( $type == 'checkbox' && ( ( ! empty( $args['name'] ) && strpos( $args['name'], '[' ) === false ) || ! empty( $args['with_hidden'] ) ) ) { |
|
156 | - $output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />'; |
|
155 | + if ($type == 'checkbox' && ((!empty($args['name']) && strpos($args['name'], '[') === false) || !empty($args['with_hidden']))) { |
|
156 | + $output .= '<input type="hidden" name="' . esc_attr($args['name']) . '" value="0" />'; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | // allow clear icon |
160 | - if ( $args['input_group_right'] === '' && $args['clear_icon'] ) { |
|
161 | - $font_size = $size == 'sm' ? '1.3' : ( $size == 'lg' ? '1.65' : '1.5' ); |
|
160 | + if ($args['input_group_right'] === '' && $args['clear_icon']) { |
|
161 | + $font_size = $size == 'sm' ? '1.3' : ($size == 'lg' ? '1.65' : '1.5'); |
|
162 | 162 | $args['input_group_right_inside'] = true; |
163 | 163 | $align_class = $aui_bs5 ? ' h-100 py-0' : ''; |
164 | - $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none ' . $align_class . '" onclick="' . $clear_function . '"><span style="font-size: ' . $font_size . 'rem" aria-hidden="true" class="' . ( $aui_bs5 ? 'btn-close' : 'close' ) . '">' . ( $aui_bs5 ? '' : '×' ) . '</span></span>'; |
|
164 | + $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none ' . $align_class . '" onclick="' . $clear_function . '"><span style="font-size: ' . $font_size . 'rem" aria-hidden="true" class="' . ($aui_bs5 ? 'btn-close' : 'close') . '">' . ($aui_bs5 ? '' : '×') . '</span></span>'; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // open/type |
168 | 168 | $output .= '<input type="' . $type . '" '; |
169 | 169 | |
170 | 170 | // name |
171 | - if ( ! empty( $args['name'] ) ) { |
|
172 | - $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
171 | + if (!empty($args['name'])) { |
|
172 | + $output .= ' name="' . esc_attr($args['name']) . '" '; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | // id |
176 | - if ( ! empty( $args['id'] ) ) { |
|
177 | - $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
176 | + if (!empty($args['id'])) { |
|
177 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | // placeholder |
181 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
182 | - $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
181 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
182 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | // title |
186 | - if ( ! empty( $args['title'] ) ) { |
|
187 | - $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
186 | + if (!empty($args['title'])) { |
|
187 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | // value |
191 | - if ( ! empty( $args['value'] ) ) { |
|
192 | - $output .= AUI_Component_Helper::value( $args['value'] ); |
|
191 | + if (!empty($args['value'])) { |
|
192 | + $output .= AUI_Component_Helper::value($args['value']); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | // checked, for radio and checkboxes |
196 | - if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) { |
|
196 | + if (($type == 'checkbox' || $type == 'radio') && $args['checked']) { |
|
197 | 197 | $output .= ' checked '; |
198 | 198 | } |
199 | 199 | |
200 | 200 | // validation text |
201 | - if ( ! empty( $args['validation_text'] ) ) { |
|
202 | - $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" '; |
|
201 | + if (!empty($args['validation_text'])) { |
|
202 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr(addslashes($args['validation_text'])) . '\')" '; |
|
203 | 203 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
204 | 204 | } |
205 | 205 | |
206 | 206 | // validation_pattern |
207 | - if ( ! empty( $args['validation_pattern'] ) ) { |
|
208 | - $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
207 | + if (!empty($args['validation_pattern'])) { |
|
208 | + $output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" '; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | // step (for numbers) |
212 | - if ( ! empty( $args['step'] ) ) { |
|
212 | + if (!empty($args['step'])) { |
|
213 | 213 | $output .= ' step="' . $args['step'] . '" '; |
214 | 214 | } |
215 | 215 | |
216 | 216 | // required |
217 | - if ( ! empty( $args['required'] ) ) { |
|
217 | + if (!empty($args['required'])) { |
|
218 | 218 | $output .= ' required '; |
219 | 219 | } |
220 | 220 | |
221 | 221 | // class |
222 | - $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
223 | - $output .= $aui_bs5 && $type == 'checkbox' ? ' class="' . $class . '" ' : ' class="form-control ' . $class . '" '; |
|
222 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
223 | + $output .= $aui_bs5 && $type == 'checkbox' ? ' class="' . $class . '" ' : ' class="form-control ' . $class . '" '; |
|
224 | 224 | |
225 | 225 | // data-attributes |
226 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
226 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
227 | 227 | |
228 | 228 | // extra attributes |
229 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
230 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
229 | + if (!empty($args['extra_attributes'])) { |
|
230 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | // close |
234 | 234 | $output .= ' >'; |
235 | 235 | |
236 | 236 | // help text |
237 | - if ( ! empty( $args['help_text'] ) ) { |
|
238 | - $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
237 | + if (!empty($args['help_text'])) { |
|
238 | + $help_text = AUI_Component_Helper::help_text($args['help_text']); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | // label |
242 | - if ( ! empty( $args['label'] ) ) { |
|
242 | + if (!empty($args['label'])) { |
|
243 | 243 | $label_base_class = ''; |
244 | - if ( $type == 'file' ) { |
|
244 | + if ($type == 'file') { |
|
245 | 245 | $label_base_class = ' custom-file-label'; |
246 | - } elseif ( $type == 'checkbox' ) { |
|
247 | - if ( ! empty( $args['label_force_left'] ) ) { |
|
248 | - $label_args['title'] = wp_kses_post( $args['help_text'] ); |
|
246 | + } elseif ($type == 'checkbox') { |
|
247 | + if (!empty($args['label_force_left'])) { |
|
248 | + $label_args['title'] = wp_kses_post($args['help_text']); |
|
249 | 249 | $help_text = ''; |
250 | 250 | //$label_args['class'] .= ' d-inline '; |
251 | 251 | $args['wrap_class'] .= ' align-items-center '; |
252 | - }else{ |
|
252 | + } else { |
|
253 | 253 | |
254 | 254 | } |
255 | 255 | |
@@ -257,49 +257,49 @@ discard block |
||
257 | 257 | } |
258 | 258 | $label_args['class'] .= $label_base_class; |
259 | 259 | $temp_label_args = $label_args; |
260 | - if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";} |
|
261 | - $label = self::label( $temp_label_args, $type ); |
|
260 | + if (!empty($args['label_force_left'])) {$temp_label_args['class'] = $label_base_class . " text-muted"; } |
|
261 | + $label = self::label($temp_label_args, $type); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
265 | 265 | |
266 | 266 | |
267 | 267 | // set help text in the correct position |
268 | - if ( $label_after ) { |
|
268 | + if ($label_after) { |
|
269 | 269 | $output .= $label . $help_text; |
270 | 270 | } |
271 | 271 | |
272 | 272 | // some input types need a separate wrap |
273 | - if ( $type == 'file' ) { |
|
274 | - $output = self::wrap( array( |
|
273 | + if ($type == 'file') { |
|
274 | + $output = self::wrap(array( |
|
275 | 275 | 'content' => $output, |
276 | 276 | 'class' => $aui_bs5 ? 'mb-3 custom-file' : 'form-group custom-file' |
277 | - ) ); |
|
278 | - } elseif ( $type == 'checkbox' ) { |
|
277 | + )); |
|
278 | + } elseif ($type == 'checkbox') { |
|
279 | 279 | |
280 | 280 | $label_args['title'] = $args['label']; |
281 | - $label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ); |
|
282 | - $label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>'; |
|
283 | - $switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : ''; |
|
284 | - if ( $aui_bs5 ) { |
|
281 | + $label_col = AUI_Component_Helper::get_column_class($args['label_col'], 'label'); |
|
282 | + $label = !empty($args['label_force_left']) ? self::label($label_args, 'cb') : '<div class="' . $label_col . ' col-form-label"></div>'; |
|
283 | + $switch_size_class = $args['switch'] && !is_bool($args['switch']) ? ' custom-switch-' . esc_attr($args['switch']) : ''; |
|
284 | + if ($aui_bs5) { |
|
285 | 285 | $wrap_class = $args['switch'] ? 'form-check form-switch' . $switch_size_class : 'form-check'; |
286 | - }else{ |
|
287 | - $wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class : 'custom-checkbox' ; |
|
286 | + } else { |
|
287 | + $wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class : 'custom-checkbox'; |
|
288 | 288 | } |
289 | - if ( ! empty( $args['label_force_left'] ) ) { |
|
289 | + if (!empty($args['label_force_left'])) { |
|
290 | 290 | $wrap_class .= $aui_bs5 ? '' : ' d-flex align-content-center'; |
291 | - $label = str_replace(array("form-check-label","custom-control-label"),"", self::label( $label_args, 'cb' ) ); |
|
291 | + $label = str_replace(array("form-check-label", "custom-control-label"), "", self::label($label_args, 'cb')); |
|
292 | 292 | } |
293 | - $output = self::wrap( array( |
|
293 | + $output = self::wrap(array( |
|
294 | 294 | 'content' => $output, |
295 | 295 | 'class' => $aui_bs5 ? $wrap_class : 'custom-control ' . $wrap_class |
296 | - ) ); |
|
296 | + )); |
|
297 | 297 | |
298 | - if ( $args['label_type'] == 'horizontal' ) { |
|
299 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
298 | + if ($args['label_type'] == 'horizontal') { |
|
299 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
300 | 300 | $output = $label . '<div class="' . $input_col . '">' . $output . '</div>'; |
301 | 301 | } |
302 | - } elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) { |
|
302 | + } elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) { |
|
303 | 303 | |
304 | 304 | |
305 | 305 | // allow password field to toggle view |
@@ -313,70 +313,70 @@ discard block |
||
313 | 313 | } |
314 | 314 | |
315 | 315 | // input group wraps |
316 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
317 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
316 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
317 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
318 | 318 | $group_size = $size == 'lg' ? ' input-group-lg' : ''; |
319 | 319 | $group_size = !$group_size && $size == 'sm' ? ' input-group-sm' : $group_size; |
320 | 320 | |
321 | - if ( $args['input_group_left'] ) { |
|
322 | - $output = self::wrap( array( |
|
321 | + if ($args['input_group_left']) { |
|
322 | + $output = self::wrap(array( |
|
323 | 323 | 'content' => $output, |
324 | 324 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
325 | 325 | 'input_group_left' => $args['input_group_left'], |
326 | 326 | 'input_group_left_inside' => $args['input_group_left_inside'] |
327 | - ) ); |
|
327 | + )); |
|
328 | 328 | } |
329 | - if ( $args['input_group_right'] ) { |
|
330 | - $output = self::wrap( array( |
|
329 | + if ($args['input_group_right']) { |
|
330 | + $output = self::wrap(array( |
|
331 | 331 | 'content' => $output, |
332 | 332 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
333 | 333 | 'input_group_right' => $args['input_group_right'], |
334 | 334 | 'input_group_right_inside' => $args['input_group_right_inside'] |
335 | - ) ); |
|
335 | + )); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | } |
339 | 339 | |
340 | - if ( ! $label_after ) { |
|
340 | + if (!$label_after) { |
|
341 | 341 | $output .= $help_text; |
342 | 342 | } |
343 | 343 | |
344 | 344 | |
345 | - if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
346 | - $output = self::wrap( array( |
|
345 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
346 | + $output = self::wrap(array( |
|
347 | 347 | 'content' => $output, |
348 | - 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
349 | - ) ); |
|
348 | + 'class' => AUI_Component_Helper::get_column_class($args['label_col'], 'input') |
|
349 | + )); |
|
350 | 350 | } |
351 | 351 | |
352 | - if ( ! $label_after ) { |
|
352 | + if (!$label_after) { |
|
353 | 353 | $output = $label . $output; |
354 | 354 | } |
355 | 355 | |
356 | 356 | // wrap |
357 | - if ( ! $args['no_wrap'] ) { |
|
358 | - if ( ! empty( $args['form_group_class'] ) ) { |
|
359 | - $fg_class = esc_attr( $args['form_group_class'] ); |
|
360 | - }else{ |
|
357 | + if (!$args['no_wrap']) { |
|
358 | + if (!empty($args['form_group_class'])) { |
|
359 | + $fg_class = esc_attr($args['form_group_class']); |
|
360 | + } else { |
|
361 | 361 | $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
362 | 362 | } |
363 | 363 | $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : $fg_class; |
364 | 364 | $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
365 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
366 | - $output = self::wrap( array( |
|
365 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
366 | + $output = self::wrap(array( |
|
367 | 367 | 'content' => $output, |
368 | 368 | 'class' => $wrap_class, |
369 | 369 | 'element_require' => $args['element_require'], |
370 | 370 | 'argument_id' => $args['id'], |
371 | 371 | 'wrap_attributes' => $args['wrap_attributes'], |
372 | - ) ); |
|
372 | + )); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
376 | 376 | return $output; |
377 | 377 | } |
378 | 378 | |
379 | - public static function label( $args = array(), $type = '' ) { |
|
379 | + public static function label($args = array(), $type = '') { |
|
380 | 380 | global $aui_bs5; |
381 | 381 | //<label for="exampleInputEmail1">Email address</label> |
382 | 382 | $defaults = array( |
@@ -390,35 +390,35 @@ discard block |
||
390 | 390 | /** |
391 | 391 | * Parse incoming $args into an array and merge it with $defaults |
392 | 392 | */ |
393 | - $args = wp_parse_args( $args, $defaults ); |
|
393 | + $args = wp_parse_args($args, $defaults); |
|
394 | 394 | $output = ''; |
395 | 395 | |
396 | - if ( $args['title'] ) { |
|
396 | + if ($args['title']) { |
|
397 | 397 | |
398 | 398 | // maybe hide labels //@todo set a global option for visibility class |
399 | - if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) { |
|
399 | + if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) { |
|
400 | 400 | $class = $args['class']; |
401 | 401 | } else { |
402 | 402 | $class = 'sr-only ' . $args['class']; |
403 | 403 | } |
404 | 404 | |
405 | 405 | // maybe horizontal |
406 | - if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
407 | - $class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label '.$type; |
|
406 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
407 | + $class .= ' ' . AUI_Component_Helper::get_column_class($args['label_col'], 'label') . ' col-form-label ' . $type; |
|
408 | 408 | } |
409 | 409 | |
410 | - if( $aui_bs5 ){ $class .= ' form-label'; } |
|
410 | + if ($aui_bs5) { $class .= ' form-label'; } |
|
411 | 411 | |
412 | 412 | // open |
413 | 413 | $output .= '<label '; |
414 | 414 | |
415 | 415 | // for |
416 | - if ( ! empty( $args['for'] ) ) { |
|
417 | - $output .= ' for="' . esc_attr( $args['for'] ) . '" '; |
|
416 | + if (!empty($args['for'])) { |
|
417 | + $output .= ' for="' . esc_attr($args['for']) . '" '; |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | // class |
421 | - $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
421 | + $class = $class ? AUI_Component_Helper::esc_classes($class) : ''; |
|
422 | 422 | $output .= ' class="' . $class . '" '; |
423 | 423 | |
424 | 424 | // close |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | |
427 | 427 | |
428 | 428 | // title, don't escape fully as can contain html |
429 | - if ( ! empty( $args['title'] ) ) { |
|
430 | - $output .= wp_kses_post( $args['title'] ); |
|
429 | + if (!empty($args['title'])) { |
|
430 | + $output .= wp_kses_post($args['title']); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | // close wrap |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * |
448 | 448 | * @return string |
449 | 449 | */ |
450 | - public static function wrap( $args = array() ) { |
|
450 | + public static function wrap($args = array()) { |
|
451 | 451 | global $aui_bs5; |
452 | 452 | $defaults = array( |
453 | 453 | 'type' => 'div', |
@@ -465,31 +465,31 @@ discard block |
||
465 | 465 | /** |
466 | 466 | * Parse incoming $args into an array and merge it with $defaults |
467 | 467 | */ |
468 | - $args = wp_parse_args( $args, $defaults ); |
|
468 | + $args = wp_parse_args($args, $defaults); |
|
469 | 469 | $output = ''; |
470 | - if ( $args['type'] ) { |
|
470 | + if ($args['type']) { |
|
471 | 471 | |
472 | 472 | // open |
473 | - $output .= '<' . sanitize_html_class( $args['type'] ); |
|
473 | + $output .= '<' . sanitize_html_class($args['type']); |
|
474 | 474 | |
475 | 475 | // element require |
476 | - if ( ! empty( $args['element_require'] ) ) { |
|
477 | - $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
476 | + if (!empty($args['element_require'])) { |
|
477 | + $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
478 | 478 | $args['class'] .= " aui-conditional-field"; |
479 | 479 | } |
480 | 480 | |
481 | 481 | // argument_id |
482 | - if ( ! empty( $args['argument_id'] ) ) { |
|
483 | - $output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"'; |
|
482 | + if (!empty($args['argument_id'])) { |
|
483 | + $output .= ' data-argument="' . esc_attr($args['argument_id']) . '"'; |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | // class |
487 | - $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
487 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
488 | 488 | $output .= ' class="' . $class . '" '; |
489 | 489 | |
490 | 490 | // Attributes |
491 | - if ( ! empty( $args['wrap_attributes'] ) ) { |
|
492 | - $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] ); |
|
491 | + if (!empty($args['wrap_attributes'])) { |
|
492 | + $output .= AUI_Component_Helper::extra_attributes($args['wrap_attributes']); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | // close wrap |
@@ -497,9 +497,9 @@ discard block |
||
497 | 497 | |
498 | 498 | |
499 | 499 | // Input group left |
500 | - if ( ! empty( $args['input_group_left'] ) ) { |
|
501 | - $position_class = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : ''; |
|
502 | - $input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
500 | + if (!empty($args['input_group_left'])) { |
|
501 | + $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
|
502 | + $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
503 | 503 | $output .= $aui_bs5 ? $input_group_left : '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
504 | 504 | // $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
505 | 505 | } |
@@ -508,16 +508,16 @@ discard block |
||
508 | 508 | $output .= $args['content']; |
509 | 509 | |
510 | 510 | // Input group right |
511 | - if ( ! empty( $args['input_group_right'] ) ) { |
|
512 | - $position_class = ! empty( $args['input_group_right_inside'] ) ? 'position-absolute h-100' : ''; |
|
513 | - $input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
514 | - $output .= $aui_bs5 ? str_replace( 'input-group-text','input-group-text top-0 end-0', $input_group_right ) : '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>'; |
|
511 | + if (!empty($args['input_group_right'])) { |
|
512 | + $position_class = !empty($args['input_group_right_inside']) ? 'position-absolute h-100' : ''; |
|
513 | + $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
514 | + $output .= $aui_bs5 ? str_replace('input-group-text', 'input-group-text top-0 end-0', $input_group_right) : '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>'; |
|
515 | 515 | // $output .= '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>'; |
516 | 516 | } |
517 | 517 | |
518 | 518 | |
519 | 519 | // close wrap |
520 | - $output .= '</' . sanitize_html_class( $args['type'] ) . '>'; |
|
520 | + $output .= '</' . sanitize_html_class($args['type']) . '>'; |
|
521 | 521 | |
522 | 522 | |
523 | 523 | } else { |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * |
535 | 535 | * @return string The rendered component. |
536 | 536 | */ |
537 | - public static function textarea( $args = array() ) { |
|
537 | + public static function textarea($args = array()) { |
|
538 | 538 | global $aui_bs5; |
539 | 539 | |
540 | 540 | $defaults = array( |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | /** |
575 | 575 | * Parse incoming $args into an array and merge it with $defaults |
576 | 576 | */ |
577 | - $args = wp_parse_args( $args, $defaults ); |
|
577 | + $args = wp_parse_args($args, $defaults); |
|
578 | 578 | $output = ''; |
579 | 579 | $label = ''; |
580 | 580 | |
@@ -582,21 +582,21 @@ discard block |
||
582 | 582 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
583 | 583 | |
584 | 584 | // floating labels don't work with wysiwyg so set it as top |
585 | - if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) { |
|
585 | + if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) { |
|
586 | 586 | $args['label_type'] = 'top'; |
587 | 587 | } |
588 | 588 | |
589 | 589 | $label_after = $args['label_after']; |
590 | 590 | |
591 | 591 | // floating labels need label after |
592 | - if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) { |
|
592 | + if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) { |
|
593 | 593 | $label_after = true; |
594 | 594 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
595 | 595 | } |
596 | 596 | |
597 | 597 | // label |
598 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
599 | - } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
598 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
599 | + } elseif (!empty($args['label']) && !$label_after) { |
|
600 | 600 | $label_args = array( |
601 | 601 | 'title' => $args['label'], |
602 | 602 | 'for' => $args['id'], |
@@ -604,34 +604,34 @@ discard block |
||
604 | 604 | 'label_type' => $args['label_type'], |
605 | 605 | 'label_col' => $args['label_col'] |
606 | 606 | ); |
607 | - $label .= self::label( $label_args ); |
|
607 | + $label .= self::label($label_args); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | // maybe horizontal label |
611 | - if ( $args['label_type'] == 'horizontal' ) { |
|
612 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
611 | + if ($args['label_type'] == 'horizontal') { |
|
612 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
613 | 613 | $label .= '<div class="' . $input_col . '">'; |
614 | 614 | } |
615 | 615 | |
616 | - if ( ! empty( $args['wysiwyg'] ) ) { |
|
616 | + if (!empty($args['wysiwyg'])) { |
|
617 | 617 | ob_start(); |
618 | 618 | $content = $args['value']; |
619 | - $editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor'; |
|
619 | + $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor'; |
|
620 | 620 | $settings = array( |
621 | - 'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4, |
|
621 | + 'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4, |
|
622 | 622 | 'quicktags' => false, |
623 | 623 | 'media_buttons' => false, |
624 | 624 | 'editor_class' => 'form-control', |
625 | - 'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ), |
|
625 | + 'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']), |
|
626 | 626 | 'teeny' => true, |
627 | 627 | ); |
628 | 628 | |
629 | 629 | // maybe set settings if array |
630 | - if ( is_array( $args['wysiwyg'] ) ) { |
|
631 | - $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
630 | + if (is_array($args['wysiwyg'])) { |
|
631 | + $settings = wp_parse_args($args['wysiwyg'], $settings); |
|
632 | 632 | } |
633 | 633 | |
634 | - wp_editor( $content, $editor_id, $settings ); |
|
634 | + wp_editor($content, $editor_id, $settings); |
|
635 | 635 | $output .= ob_get_clean(); |
636 | 636 | } else { |
637 | 637 | |
@@ -639,65 +639,65 @@ discard block |
||
639 | 639 | $output .= '<textarea '; |
640 | 640 | |
641 | 641 | // name |
642 | - if ( ! empty( $args['name'] ) ) { |
|
643 | - $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
642 | + if (!empty($args['name'])) { |
|
643 | + $output .= ' name="' . esc_attr($args['name']) . '" '; |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | // id |
647 | - if ( ! empty( $args['id'] ) ) { |
|
648 | - $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
647 | + if (!empty($args['id'])) { |
|
648 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | // placeholder |
652 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
653 | - $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
652 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
653 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | // title |
657 | - if ( ! empty( $args['title'] ) ) { |
|
658 | - $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
657 | + if (!empty($args['title'])) { |
|
658 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | // validation text |
662 | - if ( ! empty( $args['validation_text'] ) ) { |
|
663 | - $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" '; |
|
662 | + if (!empty($args['validation_text'])) { |
|
663 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr(addslashes($args['validation_text'])) . '\')" '; |
|
664 | 664 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
665 | 665 | } |
666 | 666 | |
667 | 667 | // validation_pattern |
668 | - if ( ! empty( $args['validation_pattern'] ) ) { |
|
669 | - $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
668 | + if (!empty($args['validation_pattern'])) { |
|
669 | + $output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" '; |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | // required |
673 | - if ( ! empty( $args['required'] ) ) { |
|
673 | + if (!empty($args['required'])) { |
|
674 | 674 | $output .= ' required '; |
675 | 675 | } |
676 | 676 | |
677 | 677 | // rows |
678 | - if ( ! empty( $args['rows'] ) ) { |
|
679 | - $output .= ' rows="' . absint( $args['rows'] ) . '" '; |
|
678 | + if (!empty($args['rows'])) { |
|
679 | + $output .= ' rows="' . absint($args['rows']) . '" '; |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | |
683 | 683 | // class |
684 | - $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
684 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
685 | 685 | $output .= ' class="form-control ' . $class . '" '; |
686 | 686 | |
687 | 687 | // extra attributes |
688 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
689 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
688 | + if (!empty($args['extra_attributes'])) { |
|
689 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | // close tag |
693 | 693 | $output .= ' >'; |
694 | 694 | |
695 | 695 | // value |
696 | - if ( ! empty( $args['value'] ) ) { |
|
697 | - if ( ! empty( $args['allow_tags'] ) ) { |
|
698 | - $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
696 | + if (!empty($args['value'])) { |
|
697 | + if (!empty($args['allow_tags'])) { |
|
698 | + $output .= AUI_Component_Helper::sanitize_html_field($args['value'], $args); // Sanitize HTML. |
|
699 | 699 | } else { |
700 | - $output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] ); |
|
700 | + $output .= AUI_Component_Helper::sanitize_textarea_field($args['value']); |
|
701 | 701 | } |
702 | 702 | } |
703 | 703 | |
@@ -706,23 +706,23 @@ discard block |
||
706 | 706 | |
707 | 707 | |
708 | 708 | // input group wraps |
709 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
710 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
711 | - if ( $args['input_group_left'] ) { |
|
712 | - $output = self::wrap( array( |
|
709 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
710 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
711 | + if ($args['input_group_left']) { |
|
712 | + $output = self::wrap(array( |
|
713 | 713 | 'content' => $output, |
714 | 714 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
715 | 715 | 'input_group_left' => $args['input_group_left'], |
716 | 716 | 'input_group_left_inside' => $args['input_group_left_inside'] |
717 | - ) ); |
|
717 | + )); |
|
718 | 718 | } |
719 | - if ( $args['input_group_right'] ) { |
|
720 | - $output = self::wrap( array( |
|
719 | + if ($args['input_group_right']) { |
|
720 | + $output = self::wrap(array( |
|
721 | 721 | 'content' => $output, |
722 | 722 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
723 | 723 | 'input_group_right' => $args['input_group_right'], |
724 | 724 | 'input_group_right_inside' => $args['input_group_right_inside'] |
725 | - ) ); |
|
725 | + )); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | } |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | |
731 | 731 | } |
732 | 732 | |
733 | - if ( ! empty( $args['label'] ) && $label_after ) { |
|
733 | + if (!empty($args['label']) && $label_after) { |
|
734 | 734 | $label_args = array( |
735 | 735 | 'title' => $args['label'], |
736 | 736 | 'for' => $args['id'], |
@@ -738,41 +738,41 @@ discard block |
||
738 | 738 | 'label_type' => $args['label_type'], |
739 | 739 | 'label_col' => $args['label_col'] |
740 | 740 | ); |
741 | - $output .= self::label( $label_args ); |
|
741 | + $output .= self::label($label_args); |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | // help text |
745 | - if ( ! empty( $args['help_text'] ) ) { |
|
746 | - $output .= AUI_Component_Helper::help_text( $args['help_text'] ); |
|
745 | + if (!empty($args['help_text'])) { |
|
746 | + $output .= AUI_Component_Helper::help_text($args['help_text']); |
|
747 | 747 | } |
748 | 748 | |
749 | - if ( ! $label_after ) { |
|
749 | + if (!$label_after) { |
|
750 | 750 | $output = $label . $output; |
751 | 751 | } |
752 | 752 | |
753 | 753 | // maybe horizontal label |
754 | - if ( $args['label_type'] == 'horizontal' ) { |
|
754 | + if ($args['label_type'] == 'horizontal') { |
|
755 | 755 | $output .= '</div>'; |
756 | 756 | } |
757 | 757 | |
758 | 758 | |
759 | 759 | // wrap |
760 | - if ( ! $args['no_wrap'] ) { |
|
761 | - if ( ! empty( $args['form_group_class'] ) ) { |
|
762 | - $fg_class = esc_attr( $args['form_group_class'] ); |
|
763 | - }else{ |
|
760 | + if (!$args['no_wrap']) { |
|
761 | + if (!empty($args['form_group_class'])) { |
|
762 | + $fg_class = esc_attr($args['form_group_class']); |
|
763 | + } else { |
|
764 | 764 | $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
765 | 765 | } |
766 | 766 | $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : $fg_class; |
767 | 767 | $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
768 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
769 | - $output = self::wrap( array( |
|
768 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
769 | + $output = self::wrap(array( |
|
770 | 770 | 'content' => $output, |
771 | 771 | 'class' => $wrap_class, |
772 | 772 | 'element_require' => $args['element_require'], |
773 | 773 | 'argument_id' => $args['id'], |
774 | 774 | 'wrap_attributes' => $args['wrap_attributes'], |
775 | - ) ); |
|
775 | + )); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | * |
787 | 787 | * @return string The rendered component. |
788 | 788 | */ |
789 | - public static function select( $args = array() ) { |
|
789 | + public static function select($args = array()) { |
|
790 | 790 | global $aui_bs5; |
791 | 791 | $defaults = array( |
792 | 792 | 'class' => '', |
@@ -825,11 +825,11 @@ discard block |
||
825 | 825 | /** |
826 | 826 | * Parse incoming $args into an array and merge it with $defaults |
827 | 827 | */ |
828 | - $args = wp_parse_args( $args, $defaults ); |
|
828 | + $args = wp_parse_args($args, $defaults); |
|
829 | 829 | $output = ''; |
830 | 830 | |
831 | 831 | // for now lets hide floating labels |
832 | - if ( $args['label_type'] == 'floating' ) { |
|
832 | + if ($args['label_type'] == 'floating') { |
|
833 | 833 | $args['label_type'] = 'hidden'; |
834 | 834 | } |
835 | 835 | |
@@ -840,90 +840,90 @@ discard block |
||
840 | 840 | $label_after = $args['label_after']; |
841 | 841 | |
842 | 842 | // floating labels need label after |
843 | - if ( $args['label_type'] == 'floating' ) { |
|
843 | + if ($args['label_type'] == 'floating') { |
|
844 | 844 | $label_after = true; |
845 | 845 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
846 | 846 | } |
847 | 847 | |
848 | 848 | // Maybe setup select2 |
849 | 849 | $is_select2 = false; |
850 | - if ( ! empty( $args['select2'] ) ) { |
|
850 | + if (!empty($args['select2'])) { |
|
851 | 851 | $args['class'] .= ' aui-select2'; |
852 | 852 | $is_select2 = true; |
853 | - } elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) { |
|
853 | + } elseif (strpos($args['class'], 'aui-select2') !== false) { |
|
854 | 854 | $is_select2 = true; |
855 | 855 | } |
856 | 856 | |
857 | 857 | // select2 tags |
858 | - if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason |
|
858 | + if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason |
|
859 | 859 | $args['data-tags'] = 'true'; |
860 | 860 | $args['data-token-separators'] = "[',']"; |
861 | 861 | $args['multiple'] = true; |
862 | 862 | } |
863 | 863 | |
864 | 864 | // select2 placeholder |
865 | - if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) { |
|
866 | - $args['data-placeholder'] = esc_attr( $args['placeholder'] ); |
|
867 | - $args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true; |
|
865 | + if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) { |
|
866 | + $args['data-placeholder'] = esc_attr($args['placeholder']); |
|
867 | + $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true; |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | // Set hidden input to save empty value for multiselect. |
871 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) { |
|
872 | - $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value="" data-ignore-rule/>'; |
|
871 | + if (!empty($args['multiple']) && !empty($args['name'])) { |
|
872 | + $output .= '<input type="hidden" ' . AUI_Component_Helper::name($args['name']) . ' value="" data-ignore-rule/>'; |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | // open/type |
876 | 876 | $output .= '<select '; |
877 | 877 | |
878 | 878 | // style |
879 | - if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) { |
|
879 | + if ($is_select2 && !($args['input_group_left'] || $args['input_group_right'])) { |
|
880 | 880 | $output .= " style='width:100%;' "; |
881 | 881 | } |
882 | 882 | |
883 | 883 | // element require |
884 | - if ( ! empty( $args['element_require'] ) ) { |
|
885 | - $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
884 | + if (!empty($args['element_require'])) { |
|
885 | + $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
886 | 886 | $args['class'] .= " aui-conditional-field"; |
887 | 887 | } |
888 | 888 | |
889 | 889 | // class |
890 | - $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
890 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
891 | 891 | $select_class = $aui_bs5 ? 'form-select ' : 'custom-select '; |
892 | - $output .= AUI_Component_Helper::class_attr( $select_class . $class ); |
|
892 | + $output .= AUI_Component_Helper::class_attr($select_class . $class); |
|
893 | 893 | |
894 | 894 | // name |
895 | - if ( ! empty( $args['name'] ) ) { |
|
896 | - $output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] ); |
|
895 | + if (!empty($args['name'])) { |
|
896 | + $output .= AUI_Component_Helper::name($args['name'], $args['multiple']); |
|
897 | 897 | } |
898 | 898 | |
899 | 899 | // id |
900 | - if ( ! empty( $args['id'] ) ) { |
|
901 | - $output .= AUI_Component_Helper::id( $args['id'] ); |
|
900 | + if (!empty($args['id'])) { |
|
901 | + $output .= AUI_Component_Helper::id($args['id']); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | // title |
905 | - if ( ! empty( $args['title'] ) ) { |
|
906 | - $output .= AUI_Component_Helper::title( $args['title'] ); |
|
905 | + if (!empty($args['title'])) { |
|
906 | + $output .= AUI_Component_Helper::title($args['title']); |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | // data-attributes |
910 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
910 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
911 | 911 | |
912 | 912 | // aria-attributes |
913 | - $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
913 | + $output .= AUI_Component_Helper::aria_attributes($args); |
|
914 | 914 | |
915 | 915 | // extra attributes |
916 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
917 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
916 | + if (!empty($args['extra_attributes'])) { |
|
917 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
918 | 918 | } |
919 | 919 | |
920 | 920 | // required |
921 | - if ( ! empty( $args['required'] ) ) { |
|
921 | + if (!empty($args['required'])) { |
|
922 | 922 | $output .= ' required '; |
923 | 923 | } |
924 | 924 | |
925 | 925 | // multiple |
926 | - if ( ! empty( $args['multiple'] ) ) { |
|
926 | + if (!empty($args['multiple'])) { |
|
927 | 927 | $output .= ' multiple '; |
928 | 928 | } |
929 | 929 | |
@@ -931,50 +931,50 @@ discard block |
||
931 | 931 | $output .= ' >'; |
932 | 932 | |
933 | 933 | // placeholder |
934 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) { |
|
935 | - $output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>'; |
|
936 | - } elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) { |
|
934 | + if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) { |
|
935 | + $output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>'; |
|
936 | + } elseif ($is_select2 && !empty($args['placeholder'])) { |
|
937 | 937 | $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
938 | 938 | } |
939 | 939 | |
940 | 940 | // Options |
941 | - if ( ! empty( $args['options'] ) ) { |
|
941 | + if (!empty($args['options'])) { |
|
942 | 942 | |
943 | - if ( ! is_array( $args['options'] ) ) { |
|
943 | + if (!is_array($args['options'])) { |
|
944 | 944 | $output .= $args['options']; // not the preferred way but an option |
945 | 945 | } else { |
946 | - foreach ( $args['options'] as $val => $name ) { |
|
946 | + foreach ($args['options'] as $val => $name) { |
|
947 | 947 | $selected = ''; |
948 | - if ( is_array( $name ) ) { |
|
949 | - if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) { |
|
950 | - $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
948 | + if (is_array($name)) { |
|
949 | + if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) { |
|
950 | + $option_label = isset($name['label']) ? $name['label'] : ''; |
|
951 | 951 | |
952 | - $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>'; |
|
952 | + $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; |
|
953 | 953 | } else { |
954 | - $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
955 | - $option_value = isset( $name['value'] ) ? $name['value'] : ''; |
|
956 | - $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : ''; |
|
957 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) { |
|
958 | - $selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : ""; |
|
959 | - } elseif ( ! empty( $args['value'] ) ) { |
|
960 | - $selected = selected( $option_value, stripslashes_deep( $args['value'] ), false ); |
|
961 | - } elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) { |
|
962 | - $selected = selected( $option_value, $args['value'], false ); |
|
954 | + $option_label = isset($name['label']) ? $name['label'] : ''; |
|
955 | + $option_value = isset($name['value']) ? $name['value'] : ''; |
|
956 | + $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes($name['extra_attributes']) : ''; |
|
957 | + if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) { |
|
958 | + $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : ""; |
|
959 | + } elseif (!empty($args['value'])) { |
|
960 | + $selected = selected($option_value, stripslashes_deep($args['value']), false); |
|
961 | + } elseif (empty($args['value']) && $args['value'] === $option_value) { |
|
962 | + $selected = selected($option_value, $args['value'], false); |
|
963 | 963 | } |
964 | 964 | |
965 | - $output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>'; |
|
965 | + $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . ' ' . $extra_attributes . '>' . $option_label . '</option>'; |
|
966 | 966 | } |
967 | 967 | } else { |
968 | - if ( ! empty( $args['value'] ) ) { |
|
969 | - if ( is_array( $args['value'] ) ) { |
|
970 | - $selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : ''; |
|
971 | - } elseif ( ! empty( $args['value'] ) ) { |
|
972 | - $selected = selected( $args['value'], $val, false ); |
|
968 | + if (!empty($args['value'])) { |
|
969 | + if (is_array($args['value'])) { |
|
970 | + $selected = in_array($val, $args['value']) ? 'selected="selected"' : ''; |
|
971 | + } elseif (!empty($args['value'])) { |
|
972 | + $selected = selected($args['value'], $val, false); |
|
973 | 973 | } |
974 | - } elseif ( $args['value'] === $val ) { |
|
975 | - $selected = selected( $args['value'], $val, false ); |
|
974 | + } elseif ($args['value'] === $val) { |
|
975 | + $selected = selected($args['value'], $val, false); |
|
976 | 976 | } |
977 | - $output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>'; |
|
977 | + $output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>'; |
|
978 | 978 | } |
979 | 979 | } |
980 | 980 | } |
@@ -987,8 +987,8 @@ discard block |
||
987 | 987 | $label = ''; |
988 | 988 | $help_text = ''; |
989 | 989 | // label |
990 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
991 | - } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
990 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
991 | + } elseif (!empty($args['label']) && !$label_after) { |
|
992 | 992 | $label_args = array( |
993 | 993 | 'title' => $args['label'], |
994 | 994 | 'for' => $args['id'], |
@@ -996,49 +996,49 @@ discard block |
||
996 | 996 | 'label_type' => $args['label_type'], |
997 | 997 | 'label_col' => $args['label_col'] |
998 | 998 | ); |
999 | - $label = self::label( $label_args ); |
|
999 | + $label = self::label($label_args); |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | // help text |
1003 | - if ( ! empty( $args['help_text'] ) ) { |
|
1004 | - $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
1003 | + if (!empty($args['help_text'])) { |
|
1004 | + $help_text = AUI_Component_Helper::help_text($args['help_text']); |
|
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | // input group wraps |
1008 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
1009 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
1010 | - if ( $args['input_group_left'] ) { |
|
1011 | - $output = self::wrap( array( |
|
1008 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
1009 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
1010 | + if ($args['input_group_left']) { |
|
1011 | + $output = self::wrap(array( |
|
1012 | 1012 | 'content' => $output, |
1013 | 1013 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
1014 | 1014 | 'input_group_left' => $args['input_group_left'], |
1015 | 1015 | 'input_group_left_inside' => $args['input_group_left_inside'] |
1016 | - ) ); |
|
1016 | + )); |
|
1017 | 1017 | } |
1018 | - if ( $args['input_group_right'] ) { |
|
1019 | - $output = self::wrap( array( |
|
1018 | + if ($args['input_group_right']) { |
|
1019 | + $output = self::wrap(array( |
|
1020 | 1020 | 'content' => $output, |
1021 | 1021 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
1022 | 1022 | 'input_group_right' => $args['input_group_right'], |
1023 | 1023 | 'input_group_right_inside' => $args['input_group_right_inside'] |
1024 | - ) ); |
|
1024 | + )); |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | } |
1028 | 1028 | |
1029 | - if ( ! $label_after ) { |
|
1029 | + if (!$label_after) { |
|
1030 | 1030 | $output .= $help_text; |
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | |
1034 | - if ( $args['label_type'] == 'horizontal' ) { |
|
1035 | - $output = self::wrap( array( |
|
1034 | + if ($args['label_type'] == 'horizontal') { |
|
1035 | + $output = self::wrap(array( |
|
1036 | 1036 | 'content' => $output, |
1037 | - 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
1038 | - ) ); |
|
1037 | + 'class' => AUI_Component_Helper::get_column_class($args['label_col'], 'input') |
|
1038 | + )); |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | - if ( ! $label_after ) { |
|
1041 | + if (!$label_after) { |
|
1042 | 1042 | $output = $label . $output; |
1043 | 1043 | } |
1044 | 1044 | |
@@ -1049,21 +1049,21 @@ discard block |
||
1049 | 1049 | |
1050 | 1050 | |
1051 | 1051 | // wrap |
1052 | - if ( ! $args['no_wrap'] ) { |
|
1053 | - if ( ! empty( $args['form_group_class'] ) ) { |
|
1054 | - $fg_class = esc_attr( $args['form_group_class'] ); |
|
1055 | - }else{ |
|
1052 | + if (!$args['no_wrap']) { |
|
1053 | + if (!empty($args['form_group_class'])) { |
|
1054 | + $fg_class = esc_attr($args['form_group_class']); |
|
1055 | + } else { |
|
1056 | 1056 | $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
1057 | 1057 | } |
1058 | 1058 | $wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class; |
1059 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
1060 | - $output = self::wrap( array( |
|
1059 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
1060 | + $output = self::wrap(array( |
|
1061 | 1061 | 'content' => $output, |
1062 | 1062 | 'class' => $wrap_class, |
1063 | 1063 | 'element_require' => $args['element_require'], |
1064 | 1064 | 'argument_id' => $args['id'], |
1065 | 1065 | 'wrap_attributes' => $args['wrap_attributes'], |
1066 | - ) ); |
|
1066 | + )); |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | |
@@ -1077,7 +1077,7 @@ discard block |
||
1077 | 1077 | * |
1078 | 1078 | * @return string The rendered component. |
1079 | 1079 | */ |
1080 | - public static function radio( $args = array() ) { |
|
1080 | + public static function radio($args = array()) { |
|
1081 | 1081 | global $aui_bs5; |
1082 | 1082 | |
1083 | 1083 | $defaults = array( |
@@ -1109,10 +1109,10 @@ discard block |
||
1109 | 1109 | /** |
1110 | 1110 | * Parse incoming $args into an array and merge it with $defaults |
1111 | 1111 | */ |
1112 | - $args = wp_parse_args( $args, $defaults ); |
|
1112 | + $args = wp_parse_args($args, $defaults); |
|
1113 | 1113 | |
1114 | 1114 | // for now lets use horizontal for floating |
1115 | - if ( $args['label_type'] == 'floating' ) { |
|
1115 | + if ($args['label_type'] == 'floating') { |
|
1116 | 1116 | $args['label_type'] = 'horizontal'; |
1117 | 1117 | } |
1118 | 1118 | |
@@ -1123,10 +1123,10 @@ discard block |
||
1123 | 1123 | 'label_col' => $args['label_col'] |
1124 | 1124 | ); |
1125 | 1125 | |
1126 | - if ( $args['label_type'] == 'top' || $args['label_type'] == 'hidden' ) { |
|
1126 | + if ($args['label_type'] == 'top' || $args['label_type'] == 'hidden') { |
|
1127 | 1127 | $label_args['class'] .= 'd-block '; |
1128 | 1128 | |
1129 | - if ( $args['label_type'] == 'hidden' ) { |
|
1129 | + if ($args['label_type'] == 'hidden') { |
|
1130 | 1130 | $label_args['class'] .= 'sr-only '; |
1131 | 1131 | } |
1132 | 1132 | } |
@@ -1134,48 +1134,48 @@ discard block |
||
1134 | 1134 | $output = ''; |
1135 | 1135 | |
1136 | 1136 | // label before |
1137 | - if ( ! empty( $args['label'] ) ) { |
|
1138 | - $output .= self::label( $label_args, 'radio' ); |
|
1137 | + if (!empty($args['label'])) { |
|
1138 | + $output .= self::label($label_args, 'radio'); |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | // maybe horizontal label |
1142 | - if ( $args['label_type'] == 'horizontal' ) { |
|
1143 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
1142 | + if ($args['label_type'] == 'horizontal') { |
|
1143 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
1144 | 1144 | $output .= '<div class="' . $input_col . '">'; |
1145 | 1145 | } |
1146 | 1146 | |
1147 | - if ( ! empty( $args['options'] ) ) { |
|
1147 | + if (!empty($args['options'])) { |
|
1148 | 1148 | $count = 0; |
1149 | - foreach ( $args['options'] as $value => $label ) { |
|
1149 | + foreach ($args['options'] as $value => $label) { |
|
1150 | 1150 | $option_args = $args; |
1151 | 1151 | $option_args['value'] = $value; |
1152 | 1152 | $option_args['label'] = $label; |
1153 | 1153 | $option_args['checked'] = $value == $args['value'] ? true : false; |
1154 | - $output .= self::radio_option( $option_args, $count ); |
|
1155 | - $count ++; |
|
1154 | + $output .= self::radio_option($option_args, $count); |
|
1155 | + $count++; |
|
1156 | 1156 | } |
1157 | 1157 | } |
1158 | 1158 | |
1159 | 1159 | // help text |
1160 | - $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
1160 | + $help_text = !empty($args['help_text']) ? AUI_Component_Helper::help_text($args['help_text']) : ''; |
|
1161 | 1161 | $output .= $help_text; |
1162 | 1162 | |
1163 | 1163 | // maybe horizontal label |
1164 | - if ( $args['label_type'] == 'horizontal' ) { |
|
1164 | + if ($args['label_type'] == 'horizontal') { |
|
1165 | 1165 | $output .= '</div>'; |
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | // wrap |
1169 | 1169 | $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
1170 | 1170 | $wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class; |
1171 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
1172 | - $output = self::wrap( array( |
|
1171 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
1172 | + $output = self::wrap(array( |
|
1173 | 1173 | 'content' => $output, |
1174 | 1174 | 'class' => $wrap_class, |
1175 | 1175 | 'element_require' => $args['element_require'], |
1176 | 1176 | 'argument_id' => $args['id'], |
1177 | 1177 | 'wrap_attributes' => $args['wrap_attributes'], |
1178 | - ) ); |
|
1178 | + )); |
|
1179 | 1179 | |
1180 | 1180 | |
1181 | 1181 | return $output; |
@@ -1188,7 +1188,7 @@ discard block |
||
1188 | 1188 | * |
1189 | 1189 | * @return string The rendered component. |
1190 | 1190 | */ |
1191 | - public static function radio_option( $args = array(), $count = '' ) { |
|
1191 | + public static function radio_option($args = array(), $count = '') { |
|
1192 | 1192 | $defaults = array( |
1193 | 1193 | 'class' => '', |
1194 | 1194 | 'id' => '', |
@@ -1206,7 +1206,7 @@ discard block |
||
1206 | 1206 | /** |
1207 | 1207 | * Parse incoming $args into an array and merge it with $defaults |
1208 | 1208 | */ |
1209 | - $args = wp_parse_args( $args, $defaults ); |
|
1209 | + $args = wp_parse_args($args, $defaults); |
|
1210 | 1210 | |
1211 | 1211 | $output = ''; |
1212 | 1212 | |
@@ -1217,43 +1217,43 @@ discard block |
||
1217 | 1217 | $output .= ' class="form-check-input" '; |
1218 | 1218 | |
1219 | 1219 | // name |
1220 | - if ( ! empty( $args['name'] ) ) { |
|
1221 | - $output .= AUI_Component_Helper::name( $args['name'] ); |
|
1220 | + if (!empty($args['name'])) { |
|
1221 | + $output .= AUI_Component_Helper::name($args['name']); |
|
1222 | 1222 | } |
1223 | 1223 | |
1224 | 1224 | // id |
1225 | - if ( ! empty( $args['id'] ) ) { |
|
1226 | - $output .= AUI_Component_Helper::id( $args['id'] . $count ); |
|
1225 | + if (!empty($args['id'])) { |
|
1226 | + $output .= AUI_Component_Helper::id($args['id'] . $count); |
|
1227 | 1227 | } |
1228 | 1228 | |
1229 | 1229 | // title |
1230 | - if ( ! empty( $args['title'] ) ) { |
|
1231 | - $output .= AUI_Component_Helper::title( $args['title'] ); |
|
1230 | + if (!empty($args['title'])) { |
|
1231 | + $output .= AUI_Component_Helper::title($args['title']); |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | // value |
1235 | - if ( isset( $args['value'] ) ) { |
|
1236 | - $output .= AUI_Component_Helper::value( $args['value'] ); |
|
1235 | + if (isset($args['value'])) { |
|
1236 | + $output .= AUI_Component_Helper::value($args['value']); |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | // checked, for radio and checkboxes |
1240 | - if ( $args['checked'] ) { |
|
1240 | + if ($args['checked']) { |
|
1241 | 1241 | $output .= ' checked '; |
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | // data-attributes |
1245 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
1245 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
1246 | 1246 | |
1247 | 1247 | // aria-attributes |
1248 | - $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
1248 | + $output .= AUI_Component_Helper::aria_attributes($args); |
|
1249 | 1249 | |
1250 | 1250 | // extra attributes |
1251 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
1252 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
1251 | + if (!empty($args['extra_attributes'])) { |
|
1252 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
1253 | 1253 | } |
1254 | 1254 | |
1255 | 1255 | // required |
1256 | - if ( ! empty( $args['required'] ) ) { |
|
1256 | + if (!empty($args['required'])) { |
|
1257 | 1257 | $output .= ' required '; |
1258 | 1258 | } |
1259 | 1259 | |
@@ -1261,38 +1261,38 @@ discard block |
||
1261 | 1261 | $output .= ' >'; |
1262 | 1262 | |
1263 | 1263 | // label |
1264 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
1265 | - } elseif ( ! empty( $args['label'] ) ) { |
|
1266 | - $output .= self::label( array( |
|
1264 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
1265 | + } elseif (!empty($args['label'])) { |
|
1266 | + $output .= self::label(array( |
|
1267 | 1267 | 'title' => $args['label'], |
1268 | 1268 | 'for' => $args['id'] . $count, |
1269 | 1269 | 'class' => 'form-check-label' |
1270 | - ), 'radio' ); |
|
1270 | + ), 'radio'); |
|
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | // wrap |
1274 | - if ( ! $args['no_wrap'] ) { |
|
1274 | + if (!$args['no_wrap']) { |
|
1275 | 1275 | $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
1276 | 1276 | |
1277 | 1277 | // Unique wrap class |
1278 | 1278 | $uniq_class = 'fwrap'; |
1279 | - if ( ! empty( $args['name'] ) ) { |
|
1279 | + if (!empty($args['name'])) { |
|
1280 | 1280 | $uniq_class .= '-' . $args['name']; |
1281 | - } else if ( ! empty( $args['id'] ) ) { |
|
1281 | + } else if (!empty($args['id'])) { |
|
1282 | 1282 | $uniq_class .= '-' . $args['id']; |
1283 | 1283 | } |
1284 | 1284 | |
1285 | - if ( isset( $args['value'] ) || $args['value'] !== "" ) { |
|
1285 | + if (isset($args['value']) || $args['value'] !== "") { |
|
1286 | 1286 | $uniq_class .= '-' . $args['value']; |
1287 | 1287 | } else { |
1288 | 1288 | $uniq_class .= '-' . $count; |
1289 | 1289 | } |
1290 | - $wrap_class .= ' ' . sanitize_html_class( $uniq_class ); |
|
1290 | + $wrap_class .= ' ' . sanitize_html_class($uniq_class); |
|
1291 | 1291 | |
1292 | - $output = self::wrap( array( |
|
1292 | + $output = self::wrap(array( |
|
1293 | 1293 | 'content' => $output, |
1294 | 1294 | 'class' => $wrap_class |
1295 | - ) ); |
|
1295 | + )); |
|
1296 | 1296 | } |
1297 | 1297 | |
1298 | 1298 | return $output; |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @return array|mixed|string|string[] |
15 | 15 | */ |
16 | -function aui_bs_convert_sd_output( $output, $instance = '', $args = '', $sd = '' ) { |
|
16 | +function aui_bs_convert_sd_output($output, $instance = '', $args = '', $sd = '') { |
|
17 | 17 | global $aui_bs5; |
18 | 18 | |
19 | - if ( $aui_bs5 ) { |
|
19 | + if ($aui_bs5) { |
|
20 | 20 | $convert = array( |
21 | 21 | '"ml-' => '"ms-', |
22 | 22 | '"mr-' => '"me-', |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | 'class="close"' => 'class="btn-close"', |
76 | 76 | '<span aria-hidden="true">×</span>' => '', |
77 | 77 | ); |
78 | - $output = str_replace( |
|
79 | - array_keys( $convert ), |
|
80 | - array_values( $convert ), |
|
78 | + $output = str_replace( |
|
79 | + array_keys($convert), |
|
80 | + array_values($convert), |
|
81 | 81 | $output |
82 | 82 | ); |
83 | 83 | } |
@@ -85,4 +85,4 @@ discard block |
||
85 | 85 | return $output; |
86 | 86 | } |
87 | 87 | |
88 | -add_filter( 'wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4 ); //$output, $instance, $args, $this |
|
88 | +add_filter('wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4); //$output, $instance, $args, $this |
@@ -4,11 +4,11 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
7 | +if (!defined('ABSPATH')) { |
|
8 | 8 | exit; // Exit if accessed directly |
9 | 9 | } |
10 | 10 | |
11 | -if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) : |
|
11 | +if (!class_exists('GetPaid_Admin_Profile', false)) : |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * GetPaid_Admin_Profile Class. |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | * Hook in tabs. |
20 | 20 | */ |
21 | 21 | public function __construct() { |
22 | - add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
23 | - add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
22 | + add_action('show_user_profile', array($this, 'add_customer_meta_fields'), 100); |
|
23 | + add_action('edit_user_profile', array($this, 'add_customer_meta_fields'), 100); |
|
24 | 24 | |
25 | - add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
26 | - add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
25 | + add_action('personal_options_update', array($this, 'save_customer_meta_fields')); |
|
26 | + add_action('edit_user_profile_update', array($this, 'save_customer_meta_fields')); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -37,54 +37,54 @@ discard block |
||
37 | 37 | 'getpaid_customer_meta_fields', |
38 | 38 | array( |
39 | 39 | 'billing' => array( |
40 | - 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
40 | + 'title' => __('Billing Details (GetPaid)', 'invoicing'), |
|
41 | 41 | 'fields' => array( |
42 | 42 | '_wpinv_first_name' => array( |
43 | - 'label' => __( 'First name', 'invoicing' ), |
|
43 | + 'label' => __('First name', 'invoicing'), |
|
44 | 44 | 'description' => '', |
45 | 45 | ), |
46 | 46 | '_wpinv_last_name' => array( |
47 | - 'label' => __( 'Last name', 'invoicing' ), |
|
47 | + 'label' => __('Last name', 'invoicing'), |
|
48 | 48 | 'description' => '', |
49 | 49 | ), |
50 | 50 | '_wpinv_company' => array( |
51 | - 'label' => __( 'Company', 'invoicing' ), |
|
51 | + 'label' => __('Company', 'invoicing'), |
|
52 | 52 | 'description' => '', |
53 | 53 | ), |
54 | 54 | '_wpinv_company_id' => array( |
55 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
55 | + 'label' => __('Company ID', 'invoicing'), |
|
56 | 56 | 'description' => '', |
57 | 57 | ), |
58 | 58 | '_wpinv_address' => array( |
59 | - 'label' => __( 'Address', 'invoicing' ), |
|
59 | + 'label' => __('Address', 'invoicing'), |
|
60 | 60 | 'description' => '', |
61 | 61 | ), |
62 | 62 | '_wpinv_city' => array( |
63 | - 'label' => __( 'City', 'invoicing' ), |
|
63 | + 'label' => __('City', 'invoicing'), |
|
64 | 64 | 'description' => '', |
65 | 65 | ), |
66 | 66 | '_wpinv_zip' => array( |
67 | - 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
67 | + 'label' => __('Postcode / ZIP', 'invoicing'), |
|
68 | 68 | 'description' => '', |
69 | 69 | ), |
70 | 70 | '_wpinv_country' => array( |
71 | - 'label' => __( 'Country / Region', 'invoicing' ), |
|
71 | + 'label' => __('Country / Region', 'invoicing'), |
|
72 | 72 | 'description' => '', |
73 | 73 | 'class' => 'getpaid_js_field-country', |
74 | 74 | 'type' => 'select', |
75 | - 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
75 | + 'options' => array('' => __('Select a country / region…', 'invoicing')) + wpinv_get_country_list(), |
|
76 | 76 | ), |
77 | 77 | '_wpinv_state' => array( |
78 | - 'label' => __( 'State / County', 'invoicing' ), |
|
79 | - 'description' => __( 'State / County or state code', 'invoicing' ), |
|
78 | + 'label' => __('State / County', 'invoicing'), |
|
79 | + 'description' => __('State / County or state code', 'invoicing'), |
|
80 | 80 | 'class' => 'getpaid_js_field-state regular-text', |
81 | 81 | ), |
82 | 82 | '_wpinv_phone' => array( |
83 | - 'label' => __( 'Phone', 'invoicing' ), |
|
83 | + 'label' => __('Phone', 'invoicing'), |
|
84 | 84 | 'description' => '', |
85 | 85 | ), |
86 | 86 | '_wpinv_vat_number' => array( |
87 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
87 | + 'label' => __('VAT Number', 'invoicing'), |
|
88 | 88 | 'description' => '', |
89 | 89 | ), |
90 | 90 | ), |
@@ -99,52 +99,52 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @param WP_User $user |
101 | 101 | */ |
102 | - public function add_customer_meta_fields( $user ) { |
|
103 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
102 | + public function add_customer_meta_fields($user) { |
|
103 | + if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user->ID)) { |
|
104 | 104 | return; |
105 | 105 | } |
106 | 106 | |
107 | 107 | $show_fields = $this->get_customer_meta_fields(); |
108 | 108 | |
109 | - $customer = getpaid_get_customer_by_user_id( (int) $user->ID ); |
|
109 | + $customer = getpaid_get_customer_by_user_id((int) $user->ID); |
|
110 | 110 | |
111 | - foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
112 | - if ( ! wpinv_use_taxes() && isset( $fieldset['fields']['_wpinv_vat_number'] ) ) { |
|
113 | - unset( $fieldset['fields']['_wpinv_vat_number'] ); |
|
111 | + foreach ($show_fields as $fieldset_key => $fieldset) : |
|
112 | + if (!wpinv_use_taxes() && isset($fieldset['fields']['_wpinv_vat_number'])) { |
|
113 | + unset($fieldset['fields']['_wpinv_vat_number']); |
|
114 | 114 | } |
115 | 115 | ?> |
116 | - <h2><?php echo esc_html( $fieldset['title'] ); ?></h2> |
|
117 | - <table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>"> |
|
118 | - <?php foreach ( $fieldset['fields'] as $key => $field ) : |
|
119 | - if ( ! empty( $customer ) ) { |
|
120 | - if ( strpos( $key, '_wpinv_' ) === 0 ) { |
|
121 | - $save_key = substr( $key , 7 ); |
|
116 | + <h2><?php echo esc_html($fieldset['title']); ?></h2> |
|
117 | + <table class="form-table" id="<?php echo esc_attr('getpaid-fieldset-' . $fieldset_key); ?>"> |
|
118 | + <?php foreach ($fieldset['fields'] as $key => $field) : |
|
119 | + if (!empty($customer)) { |
|
120 | + if (strpos($key, '_wpinv_') === 0) { |
|
121 | + $save_key = substr($key, 7); |
|
122 | 122 | } else { |
123 | 123 | $save_key = $key; |
124 | 124 | } |
125 | 125 | |
126 | - $value = $customer->get( $save_key ); |
|
126 | + $value = $customer->get($save_key); |
|
127 | 127 | } else { |
128 | - $value = $this->get_user_meta( $user->ID, $key ); |
|
128 | + $value = $this->get_user_meta($user->ID, $key); |
|
129 | 129 | } |
130 | 130 | ?> |
131 | 131 | <tr> |
132 | 132 | <th> |
133 | - <label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label> |
|
133 | + <label for="<?php echo esc_attr($key); ?>"><?php echo esc_html($field['label']); ?></label> |
|
134 | 134 | </th> |
135 | 135 | <td> |
136 | - <?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?> |
|
137 | - <select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;"> |
|
138 | - <?php foreach ( $field['options'] as $option_key => $option_value ) : ?> |
|
139 | - <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $value, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option> |
|
136 | + <?php if (!empty($field['type']) && 'select' === $field['type']) : ?> |
|
137 | + <select name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" class="<?php echo esc_attr($field['class']); ?> wpi_select2" style="width: 25em;"> |
|
138 | + <?php foreach ($field['options'] as $option_key => $option_value) : ?> |
|
139 | + <option value="<?php echo esc_attr($option_key); ?>" <?php selected($value, $option_key, true); ?>><?php echo esc_html($option_value); ?></option> |
|
140 | 140 | <?php endforeach; ?> |
141 | 141 | </select> |
142 | - <?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?> |
|
143 | - <input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) $value, 1, true ); ?> /> |
|
142 | + <?php elseif (!empty($field['type']) && 'checkbox' === $field['type']) : ?> |
|
143 | + <input type="checkbox" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="1" class="<?php echo esc_attr($field['class']); ?>" <?php checked((int) $value, 1, true); ?> /> |
|
144 | 144 | <?php else : ?> |
145 | - <input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $value ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" /> |
|
145 | + <input type="text" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="<?php echo esc_attr($value); ?>" class="<?php echo (!empty($field['class']) ? esc_attr($field['class']) : 'regular-text'); ?>" /> |
|
146 | 146 | <?php endif; ?> |
147 | - <p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p> |
|
147 | + <p class="description"><?php echo wp_kses_post($field['description']); ?></p> |
|
148 | 148 | </td> |
149 | 149 | </tr> |
150 | 150 | <?php endforeach; ?> |
@@ -158,43 +158,43 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @param int $user_id User ID of the user being saved |
160 | 160 | */ |
161 | - public function save_customer_meta_fields( $user_id ) { |
|
162 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
161 | + public function save_customer_meta_fields($user_id) { |
|
162 | + if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user_id)) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | 166 | $save_fields = $this->get_customer_meta_fields(); |
167 | 167 | $save_data = array(); |
168 | 168 | |
169 | - foreach ( $save_fields as $fieldset ) { |
|
170 | - foreach ( $fieldset['fields'] as $key => $field ) { |
|
171 | - if ( strpos( $key, '_wpinv_' ) === 0 ) { |
|
172 | - $save_key = substr( $key , 7 ); |
|
169 | + foreach ($save_fields as $fieldset) { |
|
170 | + foreach ($fieldset['fields'] as $key => $field) { |
|
171 | + if (strpos($key, '_wpinv_') === 0) { |
|
172 | + $save_key = substr($key, 7); |
|
173 | 173 | } else { |
174 | 174 | $save_key = $key; |
175 | 175 | } |
176 | 176 | |
177 | - if ( $save_key && isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
178 | - $save_data[ $save_key ] = ! empty( $_POST[ $key ] ) ? true : false; |
|
179 | - } else if ( $save_key && isset( $_POST[ $key ] ) ) { |
|
180 | - $save_data[ $save_key ] = wpinv_clean( $_POST[ $key ] ); |
|
177 | + if ($save_key && isset($field['type']) && 'checkbox' === $field['type']) { |
|
178 | + $save_data[$save_key] = !empty($_POST[$key]) ? true : false; |
|
179 | + } else if ($save_key && isset($_POST[$key])) { |
|
180 | + $save_data[$save_key] = wpinv_clean($_POST[$key]); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | - if ( empty( $save_data ) ) { |
|
185 | + if (empty($save_data)) { |
|
186 | 186 | return; |
187 | 187 | } |
188 | 188 | |
189 | - $customer = getpaid_get_customer_by_user_id( (int) $user_id ); |
|
189 | + $customer = getpaid_get_customer_by_user_id((int) $user_id); |
|
190 | 190 | |
191 | - if ( empty( $customer ) ) { |
|
192 | - $customer = new GetPaid_Customer( 0 ); |
|
193 | - $customer->clone_user( (int) $user_id ); |
|
191 | + if (empty($customer)) { |
|
192 | + $customer = new GetPaid_Customer(0); |
|
193 | + $customer->clone_user((int) $user_id); |
|
194 | 194 | } |
195 | 195 | |
196 | - foreach ( $save_data as $key => $value ) { |
|
197 | - $customer->set( $key, $value ); |
|
196 | + foreach ($save_data as $key => $value) { |
|
197 | + $customer->set($key, $value); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | $customer->save(); |
@@ -208,12 +208,12 @@ discard block |
||
208 | 208 | * @param string $key Key for user meta field |
209 | 209 | * @return string |
210 | 210 | */ |
211 | - protected function get_user_meta( $user_id, $key ) { |
|
212 | - $value = get_user_meta( $user_id, $key, true ); |
|
213 | - $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
211 | + protected function get_user_meta($user_id, $key) { |
|
212 | + $value = get_user_meta($user_id, $key, true); |
|
213 | + $existing_fields = array('_wpinv_first_name', '_wpinv_last_name'); |
|
214 | 214 | |
215 | - if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
216 | - $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
215 | + if (!$value && in_array($key, $existing_fields)) { |
|
216 | + $value = get_user_meta($user_id, str_replace('_wpinv_', '', $key), true); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | return $value; |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$invoice = new WPInv_Invoice( $invoice ); |
|
13 | -$address_row = wpinv_get_invoice_address_markup( $invoice->get_user_info() ); |
|
12 | +$invoice = new WPInv_Invoice($invoice); |
|
13 | +$address_row = wpinv_get_invoice_address_markup($invoice->get_user_info()); |
|
14 | 14 | $phone = $invoice->get_phone(); |
15 | 15 | $email = $invoice->get_email(); |
16 | 16 | $vat_number = $invoice->get_vat_number(); |
@@ -22,47 +22,47 @@ discard block |
||
22 | 22 | |
23 | 23 | |
24 | 24 | <div class="invoice-billing-address-label col-2"> |
25 | - <strong><?php esc_html_e( 'To:', 'invoicing' ); ?></strong> |
|
25 | + <strong><?php esc_html_e('To:', 'invoicing'); ?></strong> |
|
26 | 26 | </div> |
27 | 27 | |
28 | 28 | |
29 | 29 | <div class="invoice-billing-address-value col-10"> |
30 | 30 | |
31 | - <?php do_action( 'getpaid_billing_address_top' ); ?> |
|
31 | + <?php do_action('getpaid_billing_address_top'); ?> |
|
32 | 32 | |
33 | - <?php if ( ! empty( $address_row ) ) : ?> |
|
33 | + <?php if (!empty($address_row)) : ?> |
|
34 | 34 | <div class="billing-address"> |
35 | - <?php echo wp_kses_post( $address_row ); ?> |
|
35 | + <?php echo wp_kses_post($address_row); ?> |
|
36 | 36 | </div> |
37 | 37 | <?php endif; ?> |
38 | 38 | |
39 | 39 | |
40 | - <?php if ( ! empty( $phone ) ) : ?> |
|
40 | + <?php if (!empty($phone)) : ?> |
|
41 | 41 | <div class="billing-phone"> |
42 | - <?php echo wp_sprintf( esc_html__( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ); ?> |
|
42 | + <?php echo wp_sprintf(esc_html__('Phone: %s', 'invoicing'), esc_html($phone)); ?> |
|
43 | 43 | </div> |
44 | 44 | <?php endif; ?> |
45 | 45 | |
46 | 46 | |
47 | - <?php if ( ! empty( $email ) ) : ?> |
|
47 | + <?php if (!empty($email)) : ?> |
|
48 | 48 | <div class="billing-email"> |
49 | - <?php echo wp_sprintf( esc_html__( 'Email: %s', 'invoicing' ), esc_html( $email ) ); ?> |
|
49 | + <?php echo wp_sprintf(esc_html__('Email: %s', 'invoicing'), esc_html($email)); ?> |
|
50 | 50 | </div> |
51 | 51 | <?php endif; ?> |
52 | 52 | |
53 | - <?php if ( ! empty( $vat_number ) && wpinv_use_taxes() ) : ?> |
|
53 | + <?php if (!empty($vat_number) && wpinv_use_taxes()) : ?> |
|
54 | 54 | <div class="vat-number"> |
55 | - <?php echo wp_sprintf( esc_html__( 'Vat Number: %s', 'invoicing' ), esc_html( $vat_number ) ); ?> |
|
55 | + <?php echo wp_sprintf(esc_html__('Vat Number: %s', 'invoicing'), esc_html($vat_number)); ?> |
|
56 | 56 | </div> |
57 | 57 | <?php endif; ?> |
58 | 58 | |
59 | - <?php if ( ! empty( $company_id ) ) : ?> |
|
59 | + <?php if (!empty($company_id)) : ?> |
|
60 | 60 | <div class="company-id"> |
61 | - <?php echo wp_sprintf( esc_html__( 'Company ID: %s', 'invoicing' ), esc_html( $company_id ) ); ?> |
|
61 | + <?php echo wp_sprintf(esc_html__('Company ID: %s', 'invoicing'), esc_html($company_id)); ?> |
|
62 | 62 | </div> |
63 | 63 | <?php endif; ?> |
64 | 64 | |
65 | - <?php do_action( 'getpaid_billing_address_bottom' ); ?> |
|
65 | + <?php do_action('getpaid_billing_address_bottom'); ?> |
|
66 | 66 | |
67 | 67 | </div> |
68 | 68 |
@@ -45,20 +45,20 @@ discard block |
||
45 | 45 | // The calling class name |
46 | 46 | 'base_id' => 'hello_world', |
47 | 47 | // this is used as the widget id and the shortcode id. |
48 | - 'name' => __( 'Hello World', 'ayecode-connect' ), |
|
48 | + 'name' => __('Hello World', 'ayecode-connect'), |
|
49 | 49 | // the name of the widget/block |
50 | 50 | 'widget_ops' => array( |
51 | 51 | 'classname' => 'hello-world-class', |
52 | 52 | // widget class |
53 | - 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ), |
|
53 | + 'description' => esc_html__('This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect'), |
|
54 | 54 | // widget description |
55 | 55 | ), |
56 | 56 | 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div. |
57 | 57 | 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
58 | 58 | 'after_text' => array( // this is the input name='' |
59 | - 'title' => __( 'Text after hello:', 'ayecode-connect' ), |
|
59 | + 'title' => __('Text after hello:', 'ayecode-connect'), |
|
60 | 60 | // input title |
61 | - 'desc' => __( 'This is the text that will appear after `Hello:`.', 'ayecode-connect' ), |
|
61 | + 'desc' => __('This is the text that will appear after `Hello:`.', 'ayecode-connect'), |
|
62 | 62 | // input description |
63 | 63 | 'type' => 'text', |
64 | 64 | // the type of input, test, select, checkbox etc. |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | ) |
75 | 75 | ); |
76 | 76 | |
77 | - parent::__construct( $options ); |
|
77 | + parent::__construct($options); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
@@ -87,18 +87,18 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return string |
89 | 89 | */ |
90 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
90 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @var string $after_text |
94 | 94 | * @var string $another_input This is added by filter below. |
95 | 95 | */ |
96 | - extract( $args, EXTR_SKIP ); |
|
96 | + extract($args, EXTR_SKIP); |
|
97 | 97 | |
98 | 98 | /* |
99 | 99 | * This value is added by filter so might not exist if filter is removed so we check. |
100 | 100 | */ |
101 | - if ( ! isset( $another_input ) ) { |
|
101 | + if (!isset($another_input)) { |
|
102 | 102 | $another_input = ''; |
103 | 103 | } |
104 | 104 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | // register it. |
112 | -add_action( 'widgets_init', function () { |
|
113 | - register_widget( 'SD_Hello_World' ); |
|
112 | +add_action('widgets_init', function() { |
|
113 | + register_widget('SD_Hello_World'); |
|
114 | 114 | } ); |
115 | 115 | |
116 | 116 | |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return mixed |
123 | 123 | */ |
124 | -function _my_extra_arguments( $options ) { |
|
124 | +function _my_extra_arguments($options) { |
|
125 | 125 | |
126 | 126 | /* |
127 | 127 | * Add a new input option. |
128 | 128 | */ |
129 | 129 | $options['arguments']['another_input'] = array( |
130 | 130 | 'name' => 'another_input', // this is the input name='' |
131 | - 'title' => __( 'Another input:', 'ayecode-connect' ), // input title |
|
132 | - 'desc' => __( 'This is an input added via filter.', 'ayecode-connect' ), // input description |
|
131 | + 'title' => __('Another input:', 'ayecode-connect'), // input title |
|
132 | + 'desc' => __('This is an input added via filter.', 'ayecode-connect'), // input description |
|
133 | 133 | 'type' => 'text', // the type of input, test, select, checkbox etc. |
134 | 134 | 'placeholder' => 'Placeholder text', // the input placeholder text. |
135 | 135 | 'desc_tip' => true, // if the input should show the widget description text as a tooltip. |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | /* |
141 | 141 | * Output the new option in the block output also. |
142 | 142 | */ |
143 | - $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";; |
|
143 | + $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]"; ; |
|
144 | 144 | |
145 | 145 | return $options; |
146 | 146 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Main Invoicing class. |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param string $prop The prop to set. |
57 | 57 | * @param mixed $value The value to retrieve. |
58 | 58 | */ |
59 | - public function set( $prop, $value ) { |
|
60 | - $this->data[ $prop ] = $value; |
|
59 | + public function set($prop, $value) { |
|
60 | + $this->data[$prop] = $value; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @param string $prop The prop to set. |
67 | 67 | * @return mixed The value. |
68 | 68 | */ |
69 | - public function get( $prop ) { |
|
70 | - if ( isset( $this->data[ $prop ] ) ) { |
|
71 | - return $this->data[ $prop ]; |
|
69 | + public function get($prop) { |
|
70 | + if (isset($this->data[$prop])) { |
|
71 | + return $this->data[$prop]; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | return null; |
@@ -79,30 +79,30 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function set_properties() { |
81 | 81 | // Sessions. |
82 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
83 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
82 | + $this->set('session', new WPInv_Session_Handler()); |
|
83 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
84 | 84 | $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
85 | 85 | |
86 | 86 | // Init other objects. |
87 | - $this->set( 'notes', new WPInv_Notes() ); |
|
88 | - $this->set( 'api', new WPInv_API() ); |
|
89 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
90 | - $this->set( 'template', new GetPaid_Template() ); |
|
91 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
92 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
93 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
94 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
95 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
96 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
97 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
87 | + $this->set('notes', new WPInv_Notes()); |
|
88 | + $this->set('api', new WPInv_API()); |
|
89 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
90 | + $this->set('template', new GetPaid_Template()); |
|
91 | + $this->set('admin', new GetPaid_Admin()); |
|
92 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
93 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
94 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
95 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
96 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
97 | + $this->set('maxmind', new GetPaid_MaxMind_Geolocation()); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Define plugin constants. |
102 | 102 | */ |
103 | 103 | public function define_constants() { |
104 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
105 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
104 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
105 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
106 | 106 | $this->version = WPINV_VERSION; |
107 | 107 | } |
108 | 108 | |
@@ -113,38 +113,38 @@ discard block |
||
113 | 113 | */ |
114 | 114 | protected function init_hooks() { |
115 | 115 | /* Internationalize the text strings used. */ |
116 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
116 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
117 | 117 | |
118 | 118 | // Init the plugin after WordPress inits. |
119 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
120 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
121 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
122 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
123 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
124 | - add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
125 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
126 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
127 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
128 | - add_filter( 'the_seo_framework_sitemap_supported_post_types', array( $this, 'exclude_invoicing_post_types' ) ); |
|
129 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
130 | - |
|
131 | - add_filter( 'query_vars', array( $this, 'custom_query_vars' ) ); |
|
132 | - add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 ); |
|
133 | - add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 ); |
|
119 | + add_action('init', array($this, 'init'), 1); |
|
120 | + add_action('init', array($this, 'maybe_process_ipn'), 10); |
|
121 | + add_action('init', array($this, 'wpinv_actions')); |
|
122 | + add_action('init', array($this, 'maybe_do_authenticated_action'), 100); |
|
123 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11); |
|
124 | + add_action('wp_footer', array($this, 'wp_footer')); |
|
125 | + add_action('wp_head', array($this, 'wp_head')); |
|
126 | + add_action('widgets_init', array($this, 'register_widgets')); |
|
127 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
128 | + add_filter('the_seo_framework_sitemap_supported_post_types', array($this, 'exclude_invoicing_post_types')); |
|
129 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
130 | + |
|
131 | + add_filter('query_vars', array($this, 'custom_query_vars')); |
|
132 | + add_action('init', array($this, 'add_rewrite_rule'), 10, 0); |
|
133 | + add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1); |
|
134 | 134 | |
135 | 135 | // Fires after registering actions. |
136 | - do_action( 'wpinv_actions', $this ); |
|
137 | - do_action( 'getpaid_actions', $this ); |
|
136 | + do_action('wpinv_actions', $this); |
|
137 | + do_action('getpaid_actions', $this); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | public function plugins_loaded() { |
141 | 141 | /* Internationalize the text strings used. */ |
142 | 142 | $this->load_textdomain(); |
143 | 143 | |
144 | - do_action( 'wpinv_loaded' ); |
|
144 | + do_action('wpinv_loaded'); |
|
145 | 145 | |
146 | 146 | // Fix oxygen page builder conflict |
147 | - if ( function_exists( 'ct_css_output' ) ) { |
|
147 | + if (function_exists('ct_css_output')) { |
|
148 | 148 | wpinv_oxygen_fix_conflict(); |
149 | 149 | } |
150 | 150 | } |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function load_textdomain() { |
164 | 164 | // Determines the current locale. |
165 | - if ( function_exists( 'determine_locale' ) ) { |
|
165 | + if (function_exists('determine_locale')) { |
|
166 | 166 | $locale = determine_locale(); |
167 | - } else if ( function_exists( 'get_user_locale' ) ) { |
|
167 | + } else if (function_exists('get_user_locale')) { |
|
168 | 168 | $locale = get_user_locale(); |
169 | 169 | } else { |
170 | 170 | $locale = get_locale(); |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | /** |
174 | 174 | * Filter the locale to use for translations. |
175 | 175 | */ |
176 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
176 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
177 | 177 | |
178 | - unload_textdomain( 'invoicing' ); |
|
179 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
180 | - load_plugin_textdomain( 'invoicing', false, plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' ); |
|
178 | + unload_textdomain('invoicing'); |
|
179 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
180 | + load_plugin_textdomain('invoicing', false, plugin_basename(dirname(WPINV_PLUGIN_FILE)) . '/languages/'); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | |
211 | 211 | // Register autoloader. |
212 | 212 | try { |
213 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
214 | - } catch ( Exception $e ) { |
|
215 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
213 | + spl_autoload_register(array($this, 'autoload'), true); |
|
214 | + } catch (Exception $e) { |
|
215 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php'; |
239 | 239 | require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
240 | 240 | |
241 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
241 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
242 | 242 | GetPaid_Post_Types_Admin::init(); |
243 | 243 | |
244 | 244 | require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'; |
@@ -249,15 +249,15 @@ discard block |
||
249 | 249 | require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'; |
250 | 250 | // load the user class only on the users.php page |
251 | 251 | global $pagenow; |
252 | - if ( $pagenow == 'users.php' ) { |
|
252 | + if ($pagenow == 'users.php') { |
|
253 | 253 | new WPInv_Admin_Users(); |
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
257 | 257 | // Register cli commands |
258 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
258 | + if (defined('WP_CLI') && WP_CLI) { |
|
259 | 259 | require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'; |
260 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
260 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
@@ -269,20 +269,20 @@ discard block |
||
269 | 269 | * @since 1.0.19 |
270 | 270 | * @return void |
271 | 271 | */ |
272 | - public function autoload( $class_name ) { |
|
272 | + public function autoload($class_name) { |
|
273 | 273 | // Normalize the class name... |
274 | - $class_name = strtolower( $class_name ); |
|
274 | + $class_name = strtolower($class_name); |
|
275 | 275 | |
276 | 276 | // ... and make sure it is our class. |
277 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
277 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
278 | 278 | return; |
279 | 279 | } |
280 | 280 | |
281 | 281 | // Next, prepare the file name from the class. |
282 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
282 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
283 | 283 | |
284 | 284 | // Base path of the classes. |
285 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
285 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
286 | 286 | |
287 | 287 | // And an array of possible locations in order of importance. |
288 | 288 | $locations = array( |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | "$plugin_path/includes/admin/meta-boxes", |
298 | 298 | ); |
299 | 299 | |
300 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
301 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
302 | - include trailingslashit( $location ) . $file_name; |
|
300 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
301 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
302 | + include trailingslashit($location) . $file_name; |
|
303 | 303 | break; |
304 | 304 | } |
305 | 305 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function init() { |
312 | 312 | // Fires before getpaid inits. |
313 | - do_action( 'before_getpaid_init', $this ); |
|
313 | + do_action('before_getpaid_init', $this); |
|
314 | 314 | |
315 | 315 | // Maybe upgrade. |
316 | 316 | $this->maybe_upgrade_database(); |
@@ -327,17 +327,17 @@ discard block |
||
327 | 327 | ) |
328 | 328 | ); |
329 | 329 | |
330 | - foreach ( $gateways as $id => $class ) { |
|
331 | - $this->gateways[ $id ] = new $class(); |
|
330 | + foreach ($gateways as $id => $class) { |
|
331 | + $this->gateways[$id] = new $class(); |
|
332 | 332 | } |
333 | 333 | |
334 | - if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) { |
|
334 | + if ('yes' != get_option('wpinv_renamed_gateways')) { |
|
335 | 335 | GetPaid_Installer::rename_gateways_label(); |
336 | - update_option( 'wpinv_renamed_gateways', 'yes' ); |
|
336 | + update_option('wpinv_renamed_gateways', 'yes'); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | // Fires after getpaid inits. |
340 | - do_action( 'getpaid_init', $this ); |
|
340 | + do_action('getpaid_init', $this); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -345,52 +345,52 @@ discard block |
||
345 | 345 | */ |
346 | 346 | public function maybe_process_ipn() { |
347 | 347 | // Ensure that this is an IPN request. |
348 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
348 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
349 | 349 | return; |
350 | 350 | } |
351 | 351 | |
352 | - $gateway = sanitize_text_field( $_GET['wpi-gateway'] ); |
|
352 | + $gateway = sanitize_text_field($_GET['wpi-gateway']); |
|
353 | 353 | |
354 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
355 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
354 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
355 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
356 | 356 | exit; |
357 | 357 | } |
358 | 358 | |
359 | 359 | public function enqueue_scripts() { |
360 | 360 | // Fires before adding scripts. |
361 | - do_action( 'getpaid_enqueue_scripts' ); |
|
361 | + do_action('getpaid_enqueue_scripts'); |
|
362 | 362 | |
363 | 363 | $localize = array(); |
364 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
364 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
365 | 365 | $localize['thousands'] = wpinv_thousands_separator(); |
366 | 366 | $localize['decimals'] = wpinv_decimal_separator(); |
367 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
368 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
367 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
368 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
369 | 369 | $localize['UseTaxes'] = wpinv_use_taxes(); |
370 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
371 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
372 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
370 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
371 | + $localize['loading'] = __('Loading...', 'invoicing'); |
|
372 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
373 | 373 | $localize['recaptchaSettings'] = getpaid_get_recaptcha_settings(); |
374 | 374 | |
375 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
375 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
376 | 376 | |
377 | 377 | // reCaptcha. |
378 | - if ( getpaid_is_recaptcha_enabled() && ( $recaptcha_js = getpaid_recaptcha_api_url() ) ) { |
|
379 | - wp_enqueue_script( 'recaptcha', $recaptcha_js, array(), null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion |
|
378 | + if (getpaid_is_recaptcha_enabled() && ($recaptcha_js = getpaid_recaptcha_api_url())) { |
|
379 | + wp_enqueue_script('recaptcha', $recaptcha_js, array(), null, true); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion |
|
380 | 380 | } |
381 | 381 | |
382 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
383 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
384 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
382 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
383 | + wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true); |
|
384 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | public function wpinv_actions() { |
388 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
389 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
388 | + if (isset($_REQUEST['wpi_action'])) { |
|
389 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
390 | 390 | } |
391 | 391 | |
392 | - if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) { |
|
393 | - include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php'; |
|
392 | + if (defined('WP_ALL_IMPORT_ROOT_DIR')) { |
|
393 | + include plugin_dir_path(__FILE__) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php'; |
|
394 | 394 | } |
395 | 395 | } |
396 | 396 | |
@@ -401,21 +401,21 @@ discard block |
||
401 | 401 | * current user owns the invoice/subscription. |
402 | 402 | */ |
403 | 403 | public function maybe_do_authenticated_action() { |
404 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
405 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
406 | - $data = wp_unslash( $_REQUEST ); |
|
404 | + if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
405 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
406 | + $data = wp_unslash($_REQUEST); |
|
407 | 407 | |
408 | - if ( is_user_logged_in() ) { |
|
409 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
408 | + if (is_user_logged_in()) { |
|
409 | + do_action("getpaid_authenticated_action_$key", $data); |
|
410 | 410 | } |
411 | 411 | |
412 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
412 | + do_action("getpaid_unauthenticated_action_$key", $data); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
416 | - public function pre_get_posts( $wp_query ) { |
|
417 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
418 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
416 | + public function pre_get_posts($wp_query) { |
|
417 | + if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
418 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type'])); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | return $wp_query; |
@@ -430,17 +430,17 @@ discard block |
||
430 | 430 | |
431 | 431 | // Currently, UX Builder does not work particulaly well with SuperDuper. |
432 | 432 | // So we disable our widgets when editing a page with UX Builder. |
433 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
433 | + if (function_exists('ux_builder_is_active') && ux_builder_is_active()) { |
|
434 | 434 | return; |
435 | 435 | } |
436 | 436 | |
437 | - $block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array(); |
|
437 | + $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array(); |
|
438 | 438 | |
439 | - if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) { |
|
439 | + if (is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
440 | 440 | // don't initiate in these conditions. |
441 | 441 | } else { |
442 | 442 | // Only load allowed widgets. |
443 | - $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array(); |
|
443 | + $exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array(); |
|
444 | 444 | $widgets = apply_filters( |
445 | 445 | 'getpaid_widget_classes', |
446 | 446 | array( |
@@ -456,15 +456,15 @@ discard block |
||
456 | 456 | ); |
457 | 457 | |
458 | 458 | // For each widget... |
459 | - foreach ( $widgets as $widget ) { |
|
459 | + foreach ($widgets as $widget) { |
|
460 | 460 | // Abort early if it is excluded for this page. |
461 | - if ( in_array( $widget, $exclude ) ) { |
|
461 | + if (in_array($widget, $exclude)) { |
|
462 | 462 | continue; |
463 | 463 | } |
464 | 464 | |
465 | 465 | // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it. |
466 | - if ( is_subclass_of( $widget, 'WP_Widget' ) ) { |
|
467 | - register_widget( $widget ); |
|
466 | + if (is_subclass_of($widget, 'WP_Widget')) { |
|
467 | + register_widget($widget); |
|
468 | 468 | } else { |
469 | 469 | new $widget(); |
470 | 470 | } |
@@ -481,28 +481,28 @@ discard block |
||
481 | 481 | // Ensure the database tables are up to date. |
482 | 482 | GetPaid_Installer::maybe_create_db_tables(); |
483 | 483 | |
484 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
484 | + $wpi_version = get_option('wpinv_version', 0); |
|
485 | 485 | |
486 | - if ( $wpi_version == WPINV_VERSION ) { |
|
486 | + if ($wpi_version == WPINV_VERSION) { |
|
487 | 487 | return; |
488 | 488 | } |
489 | 489 | |
490 | 490 | $installer = new GetPaid_Installer(); |
491 | 491 | |
492 | - if ( empty( $wpi_version ) ) { |
|
493 | - return $installer->upgrade_db( 0 ); |
|
492 | + if (empty($wpi_version)) { |
|
493 | + return $installer->upgrade_db(0); |
|
494 | 494 | } |
495 | 495 | |
496 | - $upgrades = array( |
|
496 | + $upgrades = array( |
|
497 | 497 | '0.0.5' => '004', |
498 | 498 | '1.0.3' => '102', |
499 | 499 | '2.0.0' => '118', |
500 | 500 | '2.8.0' => '279', |
501 | 501 | ); |
502 | 502 | |
503 | - foreach ( $upgrades as $key => $method ) { |
|
504 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
505 | - return $installer->upgrade_db( $method ); |
|
503 | + foreach ($upgrades as $key => $method) { |
|
504 | + if (version_compare($wpi_version, $key, '<')) { |
|
505 | + return $installer->upgrade_db($method); |
|
506 | 506 | } |
507 | 507 | } |
508 | 508 | } |
@@ -513,11 +513,11 @@ discard block |
||
513 | 513 | * @since 2.0.8 |
514 | 514 | */ |
515 | 515 | public function maybe_flush_permalinks() { |
516 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
516 | + $flush = get_option('wpinv_flush_permalinks', 0); |
|
517 | 517 | |
518 | - if ( ! empty( $flush ) ) { |
|
518 | + if (!empty($flush)) { |
|
519 | 519 | flush_rewrite_rules(); |
520 | - delete_option( 'wpinv_flush_permalinks' ); |
|
520 | + delete_option('wpinv_flush_permalinks'); |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
@@ -527,9 +527,9 @@ discard block |
||
527 | 527 | * @since 1.0.19 |
528 | 528 | * @param int[] $excluded_posts_ids |
529 | 529 | */ |
530 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) { |
|
530 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
531 | 531 | // Ensure that we have an array. |
532 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
532 | + if (!is_array($excluded_posts_ids)) { |
|
533 | 533 | $excluded_posts_ids = array(); |
534 | 534 | } |
535 | 535 | |
@@ -537,25 +537,25 @@ discard block |
||
537 | 537 | $our_pages = array(); |
538 | 538 | |
539 | 539 | // Checkout page. |
540 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
540 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
541 | 541 | |
542 | 542 | // Success page. |
543 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
543 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
544 | 544 | |
545 | 545 | // Failure page. |
546 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
546 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
547 | 547 | |
548 | 548 | // History page. |
549 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
549 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
550 | 550 | |
551 | 551 | // Subscriptions page. |
552 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
552 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
553 | 553 | |
554 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
554 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
555 | 555 | |
556 | 556 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
557 | 557 | |
558 | - return array_unique( $excluded_posts_ids ); |
|
558 | + return array_unique($excluded_posts_ids); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | /** |
@@ -564,14 +564,14 @@ discard block |
||
564 | 564 | * @since 1.0.19 |
565 | 565 | * @param string[] $post_types |
566 | 566 | */ |
567 | - public function exclude_invoicing_post_types( $post_types ) { |
|
567 | + public function exclude_invoicing_post_types($post_types) { |
|
568 | 568 | // Ensure that we have an array. |
569 | - if ( ! is_array( $post_types ) ) { |
|
569 | + if (!is_array($post_types)) { |
|
570 | 570 | $post_types = array(); |
571 | 571 | } |
572 | 572 | |
573 | 573 | // Remove our post types. |
574 | - return array_diff( $post_types, array_keys( getpaid_get_invoice_post_types() ) ); |
|
574 | + return array_diff($post_types, array_keys(getpaid_get_invoice_post_types())); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | * @since 2.0.0 |
581 | 581 | */ |
582 | 582 | public function wp_footer() { |
583 | - wpinv_get_template( 'frontend-footer.php' ); |
|
583 | + wpinv_get_template('frontend-footer.php'); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | /** |
@@ -589,14 +589,14 @@ discard block |
||
589 | 589 | * @since 2.0.0 |
590 | 590 | */ |
591 | 591 | public function wp_head() { |
592 | - wpinv_get_template( 'frontend-head.php' ); |
|
592 | + wpinv_get_template('frontend-head.php'); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
596 | 596 | * Custom query vars. |
597 | 597 | * |
598 | 598 | */ |
599 | - public function custom_query_vars( $vars ) { |
|
599 | + public function custom_query_vars($vars) { |
|
600 | 600 | $vars[] = 'getpaid-ipn'; |
601 | 601 | return $vars; |
602 | 602 | } |
@@ -607,26 +607,26 @@ discard block |
||
607 | 607 | */ |
608 | 608 | public function add_rewrite_rule() { |
609 | 609 | $tag = 'getpaid-ipn'; |
610 | - add_rewrite_tag( "%$tag%", '([^&]+)' ); |
|
611 | - add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top' ); |
|
610 | + add_rewrite_tag("%$tag%", '([^&]+)'); |
|
611 | + add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top'); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
615 | 615 | * Processes non-query string ipns. |
616 | 616 | * |
617 | 617 | */ |
618 | - public function maybe_process_new_ipn( $query ) { |
|
619 | - if ( is_admin() || ! $query->is_main_query() ) { |
|
618 | + public function maybe_process_new_ipn($query) { |
|
619 | + if (is_admin() || !$query->is_main_query()) { |
|
620 | 620 | return; |
621 | 621 | } |
622 | 622 | |
623 | - $gateway = get_query_var( 'getpaid-ipn' ); |
|
623 | + $gateway = get_query_var('getpaid-ipn'); |
|
624 | 624 | |
625 | - if ( ! empty( $gateway ) ) { |
|
626 | - $gateway = sanitize_text_field( $gateway ); |
|
625 | + if (!empty($gateway)) { |
|
626 | + $gateway = sanitize_text_field($gateway); |
|
627 | 627 | nocache_headers(); |
628 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
629 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
628 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
629 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
630 | 630 | exit; |
631 | 631 | } |
632 | 632 | } |