@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param array $output The `output` item. |
26 | 26 | * @param array $value The field's value. |
27 | 27 | */ |
28 | - protected function process_output( $output, $value ) { |
|
28 | + protected function process_output($output, $value) { |
|
29 | 29 | $output = wp_parse_args( |
30 | 30 | $output, |
31 | 31 | [ |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | ] |
37 | 37 | ); |
38 | 38 | |
39 | - foreach ( [ 'background-image', 'background-color', 'background-repeat', 'background-position', 'background-size', 'background-attachment' ] as $property ) { |
|
39 | + foreach (['background-image', 'background-color', 'background-repeat', 'background-position', 'background-size', 'background-attachment'] as $property) { |
|
40 | 40 | |
41 | 41 | // See https://github.com/aristath/kirki/issues/1808. |
42 | - if ( 'background-color' === $property && isset( $value['background-color'] ) && $value['background-color'] && ( ! isset( $value['background-image'] ) || empty( $value['background-image'] ) ) ) { |
|
43 | - $this->styles[ $output['media_query'] ][ $output['element'] ]['background'] = $output['prefix'] . $this->process_property_value( $property, $value[ $property ] ) . $output['suffix']; |
|
42 | + if ('background-color' === $property && isset($value['background-color']) && $value['background-color'] && (!isset($value['background-image']) || empty($value['background-image']))) { |
|
43 | + $this->styles[$output['media_query']][$output['element']]['background'] = $output['prefix'] . $this->process_property_value($property, $value[$property]) . $output['suffix']; |
|
44 | 44 | } |
45 | 45 | |
46 | - if ( isset( $value[ $property ] ) && ! empty( $value[ $property ] ) ) { |
|
47 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $this->process_property_value( $property, $value[ $property ] ) . $output['suffix']; |
|
46 | + if (isset($value[$property]) && !empty($value[$property])) { |
|
47 | + $this->styles[$output['media_query']][$output['element']][$property] = $output['prefix'] . $this->process_property_value($property, $value[$property]) . $output['suffix']; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | * @access public |
39 | 39 | * @param array $args The arguments of the field. |
40 | 40 | */ |
41 | - public function init( $args ) { |
|
41 | + public function init($args) { |
|
42 | 42 | |
43 | - $args['required'] = isset( $args['required'] ) ? (array) $args['required'] : []; |
|
44 | - $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global'; |
|
43 | + $args['required'] = isset($args['required']) ? (array) $args['required'] : []; |
|
44 | + $args['kirki_config'] = isset($args['kirki_config']) ? $args['kirki_config'] : 'global'; |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Add a hidden field, the label & description. |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'type' => 'hidden', |
56 | 56 | 'parent_type' => 'kirki-background', |
57 | 57 | ], |
58 | - 'sanitize_callback' => [ '\Kirki\Field\Background', 'sanitize' ], |
|
58 | + 'sanitize_callback' => ['\Kirki\Field\Background', 'sanitize'], |
|
59 | 59 | ], |
60 | 60 | $args |
61 | 61 | ) |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | 'data-kirki-parent-control-type' => 'kirki-background', |
68 | 68 | ]; |
69 | 69 | |
70 | - if ( isset( $args['transport'] ) && 'auto' === $args['transport'] ) { |
|
70 | + if (isset($args['transport']) && 'auto' === $args['transport']) { |
|
71 | 71 | $args['transport'] = 'postMessage'; |
72 | 72 | } |
73 | 73 | |
74 | - $default_bg_color = isset( $args['default']['background-color'] ) ? $args['default']['background-color'] : ''; |
|
74 | + $default_bg_color = isset($args['default']['background-color']) ? $args['default']['background-color'] : ''; |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Background Color. |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | [ |
82 | 82 | 'settings' => $args['settings'] . '[background-color]', |
83 | 83 | 'label' => '', |
84 | - 'description' => esc_html__( 'Background Color', 'kirki' ), |
|
84 | + 'description' => esc_html__('Background Color', 'kirki'), |
|
85 | 85 | 'default' => $default_bg_color, |
86 | 86 | 'section' => $args['section'], |
87 | 87 | 'choices' => [ |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | [ |
101 | 101 | 'settings' => $args['settings'] . '[background-image]', |
102 | 102 | 'label' => '', |
103 | - 'description' => esc_html__( 'Background Image', 'kirki' ), |
|
104 | - 'default' => isset( $args['default']['background-image'] ) ? $args['default']['background-image'] : '', |
|
103 | + 'description' => esc_html__('Background Image', 'kirki'), |
|
104 | + 'default' => isset($args['default']['background-image']) ? $args['default']['background-image'] : '', |
|
105 | 105 | 'section' => $args['section'], |
106 | 106 | ], |
107 | 107 | $args |
@@ -116,14 +116,14 @@ discard block |
||
116 | 116 | [ |
117 | 117 | 'settings' => $args['settings'] . '[background-repeat]', |
118 | 118 | 'label' => '', |
119 | - 'description' => esc_html__( 'Background Repeat', 'kirki' ), |
|
119 | + 'description' => esc_html__('Background Repeat', 'kirki'), |
|
120 | 120 | 'section' => $args['section'], |
121 | - 'default' => isset( $args['default']['background-repeat'] ) ? $args['default']['background-repeat'] : '', |
|
121 | + 'default' => isset($args['default']['background-repeat']) ? $args['default']['background-repeat'] : '', |
|
122 | 122 | 'choices' => [ |
123 | - 'no-repeat' => esc_html__( 'No Repeat', 'kirki' ), |
|
124 | - 'repeat' => esc_html__( 'Repeat All', 'kirki' ), |
|
125 | - 'repeat-x' => esc_html__( 'Repeat Horizontally', 'kirki' ), |
|
126 | - 'repeat-y' => esc_html__( 'Repeat Vertically', 'kirki' ), |
|
123 | + 'no-repeat' => esc_html__('No Repeat', 'kirki'), |
|
124 | + 'repeat' => esc_html__('Repeat All', 'kirki'), |
|
125 | + 'repeat-x' => esc_html__('Repeat Horizontally', 'kirki'), |
|
126 | + 'repeat-y' => esc_html__('Repeat Vertically', 'kirki'), |
|
127 | 127 | ], |
128 | 128 | 'required' => array_merge( |
129 | 129 | $args['required'], |
@@ -149,19 +149,19 @@ discard block |
||
149 | 149 | [ |
150 | 150 | 'settings' => $args['settings'] . '[background-position]', |
151 | 151 | 'label' => '', |
152 | - 'description' => esc_html__( 'Background Position', 'kirki' ), |
|
153 | - 'default' => isset( $args['default']['background-position'] ) ? $args['default']['background-position'] : '', |
|
152 | + 'description' => esc_html__('Background Position', 'kirki'), |
|
153 | + 'default' => isset($args['default']['background-position']) ? $args['default']['background-position'] : '', |
|
154 | 154 | 'section' => $args['section'], |
155 | 155 | 'choices' => [ |
156 | - 'left top' => esc_html__( 'Left Top', 'kirki' ), |
|
157 | - 'left center' => esc_html__( 'Left Center', 'kirki' ), |
|
158 | - 'left bottom' => esc_html__( 'Left Bottom', 'kirki' ), |
|
159 | - 'center top' => esc_html__( 'Center Top', 'kirki' ), |
|
160 | - 'center center' => esc_html__( 'Center Center', 'kirki' ), |
|
161 | - 'center bottom' => esc_html__( 'Center Bottom', 'kirki' ), |
|
162 | - 'right top' => esc_html__( 'Right Top', 'kirki' ), |
|
163 | - 'right center' => esc_html__( 'Right Center', 'kirki' ), |
|
164 | - 'right bottom' => esc_html__( 'Right Bottom', 'kirki' ), |
|
156 | + 'left top' => esc_html__('Left Top', 'kirki'), |
|
157 | + 'left center' => esc_html__('Left Center', 'kirki'), |
|
158 | + 'left bottom' => esc_html__('Left Bottom', 'kirki'), |
|
159 | + 'center top' => esc_html__('Center Top', 'kirki'), |
|
160 | + 'center center' => esc_html__('Center Center', 'kirki'), |
|
161 | + 'center bottom' => esc_html__('Center Bottom', 'kirki'), |
|
162 | + 'right top' => esc_html__('Right Top', 'kirki'), |
|
163 | + 'right center' => esc_html__('Right Center', 'kirki'), |
|
164 | + 'right bottom' => esc_html__('Right Bottom', 'kirki'), |
|
165 | 165 | ], |
166 | 166 | 'required' => array_merge( |
167 | 167 | $args['required'], |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | [ |
188 | 188 | 'settings' => $args['settings'] . '[background-size]', |
189 | 189 | 'label' => '', |
190 | - 'description' => esc_html__( 'Background Size', 'kirki' ), |
|
191 | - 'default' => isset( $args['default']['background-size'] ) ? $args['default']['background-size'] : '', |
|
190 | + 'description' => esc_html__('Background Size', 'kirki'), |
|
191 | + 'default' => isset($args['default']['background-size']) ? $args['default']['background-size'] : '', |
|
192 | 192 | 'section' => $args['section'], |
193 | 193 | 'choices' => [ |
194 | - 'cover' => esc_html__( 'Cover', 'kirki' ), |
|
195 | - 'contain' => esc_html__( 'Contain', 'kirki' ), |
|
196 | - 'auto' => esc_html__( 'Auto', 'kirki' ), |
|
194 | + 'cover' => esc_html__('Cover', 'kirki'), |
|
195 | + 'contain' => esc_html__('Contain', 'kirki'), |
|
196 | + 'auto' => esc_html__('Auto', 'kirki'), |
|
197 | 197 | ], |
198 | 198 | 'required' => array_merge( |
199 | 199 | $args['required'], |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | [ |
220 | 220 | 'type' => 'kirki-radio-buttonset', |
221 | 221 | 'settings' => $args['settings'] . '[background-attachment]', |
222 | - 'description' => esc_html__( 'Background Attachment', 'kirki' ), |
|
222 | + 'description' => esc_html__('Background Attachment', 'kirki'), |
|
223 | 223 | 'label' => '', |
224 | - 'default' => isset( $args['default']['background-attachment'] ) ? $args['default']['background-attachment'] : '', |
|
224 | + 'default' => isset($args['default']['background-attachment']) ? $args['default']['background-attachment'] : '', |
|
225 | 225 | 'section' => $args['section'], |
226 | 226 | 'choices' => [ |
227 | - 'scroll' => esc_html__( 'Scroll', 'kirki' ), |
|
228 | - 'fixed' => esc_html__( 'Fixed', 'kirki' ), |
|
227 | + 'scroll' => esc_html__('Scroll', 'kirki'), |
|
228 | + 'fixed' => esc_html__('Fixed', 'kirki'), |
|
229 | 229 | ], |
230 | 230 | 'required' => array_merge( |
231 | 231 | $args['required'], |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | ) |
244 | 244 | ); |
245 | 245 | |
246 | - add_action( 'customize_preview_init', [ $this, 'enqueue_scripts' ] ); |
|
247 | - add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); |
|
246 | + add_action('customize_preview_init', [$this, 'enqueue_scripts']); |
|
247 | + add_filter('kirki_output_control_classnames', [$this, 'output_control_classnames']); |
|
248 | 248 | |
249 | 249 | } |
250 | 250 | |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | |
260 | 260 | // If a custom sanitize_callback has been defined, |
261 | 261 | // then we don't need to proceed any further. |
262 | - if ( ! empty( $this->sanitize_callback ) ) { |
|
262 | + if (!empty($this->sanitize_callback)) { |
|
263 | 263 | return; |
264 | 264 | } |
265 | 265 | |
266 | - $this->sanitize_callback = [ '\Kirki\Field\Background', 'sanitize' ]; |
|
266 | + $this->sanitize_callback = ['\Kirki\Field\Background', 'sanitize']; |
|
267 | 267 | |
268 | 268 | } |
269 | 269 | |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | * @param array $value The value. |
277 | 277 | * @return array |
278 | 278 | */ |
279 | - public static function sanitize( $value ) { |
|
279 | + public static function sanitize($value) { |
|
280 | 280 | |
281 | - if ( ! is_array( $value ) ) { |
|
281 | + if (!is_array($value)) { |
|
282 | 282 | return []; |
283 | 283 | } |
284 | 284 | |
@@ -291,15 +291,15 @@ discard block |
||
291 | 291 | 'background-attachment' => '', |
292 | 292 | ]; |
293 | 293 | |
294 | - if ( isset( $value['background-color'] ) ) { |
|
295 | - $sanitized_value['background-color'] = \Kirki\Field\Color::sanitize( $value['background-color'] ); |
|
294 | + if (isset($value['background-color'])) { |
|
295 | + $sanitized_value['background-color'] = \Kirki\Field\Color::sanitize($value['background-color']); |
|
296 | 296 | } |
297 | 297 | |
298 | - if ( isset( $value['background-image'] ) ) { |
|
299 | - $sanitized_value['background-image'] = esc_url_raw( $value['background-image'] ); |
|
298 | + if (isset($value['background-image'])) { |
|
299 | + $sanitized_value['background-image'] = esc_url_raw($value['background-image']); |
|
300 | 300 | } |
301 | 301 | |
302 | - if ( isset( $value['background-repeat'] ) ) { |
|
302 | + if (isset($value['background-repeat'])) { |
|
303 | 303 | $sanitized_value['background-repeat'] = in_array( |
304 | 304 | $value['background-repeat'], |
305 | 305 | [ |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | ) ? $value['background-repeat'] : ''; |
313 | 313 | } |
314 | 314 | |
315 | - if ( isset( $value['background-position'] ) ) { |
|
315 | + if (isset($value['background-position'])) { |
|
316 | 316 | $sanitized_value['background-position'] = in_array( |
317 | 317 | $value['background-position'], |
318 | 318 | [ |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | ) ? $value['background-position'] : ''; |
331 | 331 | } |
332 | 332 | |
333 | - if ( isset( $value['background-size'] ) ) { |
|
333 | + if (isset($value['background-size'])) { |
|
334 | 334 | $sanitized_value['background-size'] = in_array( |
335 | 335 | $value['background-size'], |
336 | 336 | [ |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | ) ? $value['background-size'] : ''; |
343 | 343 | } |
344 | 344 | |
345 | - if ( isset( $value['background-attachment'] ) ) { |
|
345 | + if (isset($value['background-attachment'])) { |
|
346 | 346 | $sanitized_value['background-attachment'] = in_array( |
347 | 347 | $value['background-attachment'], |
348 | 348 | [ |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | |
372 | 372 | // Check if transport is set to auto. |
373 | 373 | // If not, then skip the auto-calculations and exit early. |
374 | - if ( 'auto' !== $this->transport ) { |
|
374 | + if ('auto' !== $this->transport) { |
|
375 | 375 | return; |
376 | 376 | } |
377 | 377 | |
@@ -383,21 +383,21 @@ discard block |
||
383 | 383 | |
384 | 384 | // Try to auto-generate js_vars. |
385 | 385 | // First we need to check if js_vars are empty, and that output is not empty. |
386 | - if ( empty( $this->js_vars ) && ! empty( $this->output ) ) { |
|
386 | + if (empty($this->js_vars) && !empty($this->output)) { |
|
387 | 387 | |
388 | 388 | // Start going through each item in the $output array. |
389 | - foreach ( $this->output as $output ) { |
|
389 | + foreach ($this->output as $output) { |
|
390 | 390 | |
391 | 391 | // If 'element' is not defined, skip this. |
392 | - if ( ! isset( $output['element'] ) ) { |
|
392 | + if (!isset($output['element'])) { |
|
393 | 393 | continue; |
394 | 394 | } |
395 | - if ( is_array( $output['element'] ) ) { |
|
396 | - $output['element'] = implode( ',', $output['element'] ); |
|
395 | + if (is_array($output['element'])) { |
|
396 | + $output['element'] = implode(',', $output['element']); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | // If there's a sanitize_callback defined, skip this. |
400 | - if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) ) { |
|
400 | + if (isset($output['sanitize_callback']) && !empty($output['sanitize_callback'])) { |
|
401 | 401 | continue; |
402 | 402 | } |
403 | 403 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | |
408 | 408 | // Did we manage to get all the items from 'output'? |
409 | 409 | // If not, then we're missing something so don't add this. |
410 | - if ( count( $js_vars ) !== count( $this->output ) ) { |
|
410 | + if (count($js_vars) !== count($this->output)) { |
|
411 | 411 | return; |
412 | 412 | } |
413 | 413 | $this->js_vars = $js_vars; |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
425 | 425 | * @return void |
426 | 426 | */ |
427 | - public function add_setting( $wp_customize ) {} |
|
427 | + public function add_setting($wp_customize) {} |
|
428 | 428 | |
429 | 429 | /** |
430 | 430 | * Override the parent method. No need for a control. |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
435 | 435 | * @return void |
436 | 436 | */ |
437 | - public function add_control( $wp_customize ) {} |
|
437 | + public function add_control($wp_customize) {} |
|
438 | 438 | |
439 | 439 | /** |
440 | 440 | * Enqueue scripts & styles. |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | */ |
446 | 446 | public function enqueue_scripts() { |
447 | 447 | |
448 | - wp_enqueue_script( 'kirki-typography', URL::get_from_path( __DIR__ ) . '/script.js', [ 'wp-hooks' ], '1.0', true ); |
|
448 | + wp_enqueue_script('kirki-typography', URL::get_from_path(__DIR__) . '/script.js', ['wp-hooks'], '1.0', true); |
|
449 | 449 | |
450 | 450 | } |
451 | 451 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * @param array $classnames The array of classnames. |
458 | 458 | * @return array |
459 | 459 | */ |
460 | - public function output_control_classnames( $classnames ) { |
|
460 | + public function output_control_classnames($classnames) { |
|
461 | 461 | |
462 | 462 | $classnames['kirki-background'] = '\Kirki\Field\CSS\Background'; |
463 | 463 | return $classnames; |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | public function enqueue() { |
166 | 166 | |
167 | 167 | // Enqueue the styles. |
168 | - wp_enqueue_style( 'kirki-control-base', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
168 | + wp_enqueue_style('kirki-control-base', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.css'), [], self::$control_ver); |
|
169 | 169 | |
170 | 170 | // Enqueue the scripts. |
171 | - wp_enqueue_script( 'kirki-control-base', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'customize-controls' ], self::$control_ver, false ); |
|
171 | + wp_enqueue_script('kirki-control-base', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.js'), ['customize-controls'], self::$control_ver, false); |
|
172 | 172 | |
173 | 173 | } |
174 | 174 | |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | */ |
180 | 180 | protected function render() { |
181 | 181 | |
182 | - $id = 'customize-control-' . str_replace( [ '[', ']' ], [ '-', '' ], $this->id ); |
|
182 | + $id = 'customize-control-' . str_replace(['[', ']'], ['-', ''], $this->id); |
|
183 | 183 | $class = 'customize-control customize-control-kirki customize-control-' . $this->type; |
184 | - $gap = isset( $this->wrapper_opts['gap'] ) ? $this->wrapper_opts['gap'] : 'default'; |
|
185 | - $tag = isset( $this->wrapper_opts['tag'] ) ? $this->wrapper_opts['tag'] : 'li'; |
|
184 | + $gap = isset($this->wrapper_opts['gap']) ? $this->wrapper_opts['gap'] : 'default'; |
|
185 | + $tag = isset($this->wrapper_opts['tag']) ? $this->wrapper_opts['tag'] : 'li'; |
|
186 | 186 | |
187 | - switch ( $gap ) { |
|
187 | + switch ($gap) { |
|
188 | 188 | case 'small': |
189 | 189 | $class .= ' customize-control-has-small-gap'; |
190 | 190 | break; |
@@ -197,41 +197,41 @@ discard block |
||
197 | 197 | break; |
198 | 198 | } |
199 | 199 | |
200 | - if ( empty( $this->wrapper_attrs ) && ! empty( $this->wrapper_atts ) ) { |
|
200 | + if (empty($this->wrapper_attrs) && !empty($this->wrapper_atts)) { |
|
201 | 201 | $this->wrapper_attrs = $this->wrapper_atts; |
202 | 202 | } |
203 | 203 | |
204 | - if ( isset( $this->wrapper_attrs['id'] ) ) { |
|
204 | + if (isset($this->wrapper_attrs['id'])) { |
|
205 | 205 | $id = $this->wrapper_attrs['id']; |
206 | 206 | } |
207 | 207 | |
208 | - if ( ! isset( $this->wrapper_attrs['data-kirki-setting'] ) ) { |
|
208 | + if (!isset($this->wrapper_attrs['data-kirki-setting'])) { |
|
209 | 209 | $this->wrapper_attrs['data-kirki-setting'] = $this->id; |
210 | 210 | } |
211 | 211 | |
212 | - if ( ! isset( $this->wrapper_attrs['data-kirki-setting-link'] ) ) { |
|
213 | - if ( isset( $this->settings['default'] ) ) { |
|
212 | + if (!isset($this->wrapper_attrs['data-kirki-setting-link'])) { |
|
213 | + if (isset($this->settings['default'])) { |
|
214 | 214 | $this->wrapper_attrs['data-kirki-setting-link'] = $this->settings['default']->id; |
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | 218 | $data_attrs = ''; |
219 | 219 | |
220 | - foreach ( $this->wrapper_attrs as $attr_key => $attr_value ) { |
|
221 | - if ( 0 === strpos( $attr_key, 'data-' ) ) { |
|
222 | - $data_attrs .= ' ' . esc_attr( $attr_key ) . '="' . esc_attr( $attr_value ) . '"'; |
|
220 | + foreach ($this->wrapper_attrs as $attr_key => $attr_value) { |
|
221 | + if (0 === strpos($attr_key, 'data-')) { |
|
222 | + $data_attrs .= ' ' . esc_attr($attr_key) . '="' . esc_attr($attr_value) . '"'; |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
226 | - if ( isset( $this->wrapper_attrs['class'] ) ) { |
|
227 | - $class = str_ireplace( '{default_class}', $class, $this->wrapper_attrs['class'] ); |
|
226 | + if (isset($this->wrapper_attrs['class'])) { |
|
227 | + $class = str_ireplace('{default_class}', $class, $this->wrapper_attrs['class']); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | // ! Consider to esc $data_attrs. |
231 | 231 | // ? What function we can use to escape string like data-xx="yy"? |
232 | - printf( '<' . esc_attr( $tag ) . ' id="%s" class="%s"%s>', esc_attr( $id ), esc_attr( $class ), $data_attrs ); |
|
232 | + printf('<' . esc_attr($tag) . ' id="%s" class="%s"%s>', esc_attr($id), esc_attr($class), $data_attrs); |
|
233 | 233 | $this->render_content(); |
234 | - echo '</' . esc_attr( $tag ) . '>'; |
|
234 | + echo '</' . esc_attr($tag) . '>'; |
|
235 | 235 | |
236 | 236 | } |
237 | 237 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | // Default value. |
252 | 252 | $this->json['default'] = $this->setting->default; |
253 | 253 | |
254 | - if ( isset( $this->default ) ) { |
|
254 | + if (isset($this->default)) { |
|
255 | 255 | $this->json['default'] = $this->default; |
256 | 256 | } |
257 | 257 | |
@@ -274,14 +274,14 @@ discard block |
||
274 | 274 | $this->json['l10n'] = $this->l10n(); |
275 | 275 | |
276 | 276 | // The ajaxurl in case we need it. |
277 | - $this->json['ajaxurl'] = admin_url( 'admin-ajax.php' ); |
|
277 | + $this->json['ajaxurl'] = admin_url('admin-ajax.php'); |
|
278 | 278 | |
279 | 279 | // Input attributes. |
280 | 280 | $this->json['inputAttrs'] = ''; |
281 | 281 | |
282 | - if ( is_array( $this->input_attrs ) ) { |
|
283 | - foreach ( $this->input_attrs as $attr => $value ) { |
|
284 | - $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
282 | + if (is_array($this->input_attrs)) { |
|
283 | + foreach ($this->input_attrs as $attr => $value) { |
|
284 | + $this->json['inputAttrs'] .= $attr . '="' . esc_attr($value) . '" '; |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
56 | 56 | * @return array |
57 | 57 | */ |
58 | - public function filter_setting_args( $args, $wp_customize ) { |
|
59 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
60 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
58 | + public function filter_setting_args($args, $wp_customize) { |
|
59 | + if ($args['settings'] === $this->args['settings']) { |
|
60 | + $args = parent::filter_setting_args($args, $wp_customize); |
|
61 | 61 | |
62 | 62 | // Set the sanitize-callback if none is defined. |
63 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
64 | - $args['sanitize_callback'] = [ __CLASS__, 'sanitize' ]; |
|
63 | + if (!isset($args['sanitize_callback']) || !$args['sanitize_callback']) { |
|
64 | + $args['sanitize_callback'] = [__CLASS__, 'sanitize']; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | return $args; |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
77 | 77 | * @return array |
78 | 78 | */ |
79 | - public function filter_control_args( $args, $wp_customize ) { |
|
80 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
81 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
79 | + public function filter_control_args($args, $wp_customize) { |
|
80 | + if ($args['settings'] === $this->args['settings']) { |
|
81 | + $args = parent::filter_control_args($args, $wp_customize); |
|
82 | 82 | $args['type'] = 'kirki-multicheck'; |
83 | 83 | } |
84 | 84 | return $args; |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * @param string|array $value The control's value. |
94 | 94 | * @return array |
95 | 95 | */ |
96 | - public static function sanitize( $value ) { |
|
97 | - $value = ( ! is_array( $value ) ) ? explode( ',', $value ) : $value; |
|
98 | - return ( ! empty( $value ) ) ? array_map( 'sanitize_text_field', $value ) : []; |
|
96 | + public static function sanitize($value) { |
|
97 | + $value = (!is_array($value)) ? explode(',', $value) : $value; |
|
98 | + return (!empty($value)) ? array_map('sanitize_text_field', $value) : []; |
|
99 | 99 | } |
100 | 100 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | use Kirki\URL; |
18 | 18 | |
19 | 19 | // Exit if accessed directly. |
20 | -if ( ! defined( 'ABSPATH' ) ) { |
|
20 | +if (!defined('ABSPATH')) { |
|
21 | 21 | exit; |
22 | 22 | } |
23 | 23 | |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | parent::enqueue(); |
59 | 59 | |
60 | 60 | // Enqueue the script. |
61 | - wp_enqueue_script( 'kirki-control-multicheck', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base' ], self::$control_ver, false ); |
|
61 | + wp_enqueue_script('kirki-control-multicheck', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.js'), ['jquery', 'customize-base', 'kirki-control-base'], self::$control_ver, false); |
|
62 | 62 | |
63 | 63 | // Enqueue the style. |
64 | - wp_enqueue_style( 'kirki-control-multicheck-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
64 | + wp_enqueue_style('kirki-control-multicheck-style', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.css'), [], self::$control_ver); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
56 | 56 | * @return array |
57 | 57 | */ |
58 | - public function filter_setting_args( $args, $wp_customize ) { |
|
59 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
60 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
58 | + public function filter_setting_args($args, $wp_customize) { |
|
59 | + if ($args['settings'] === $this->args['settings']) { |
|
60 | + $args = parent::filter_setting_args($args, $wp_customize); |
|
61 | 61 | |
62 | 62 | // Set the sanitize-callback if none is defined. |
63 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
64 | - $args['sanitize_callback'] = [ $this, 'sanitize' ]; |
|
63 | + if (!isset($args['sanitize_callback']) || !$args['sanitize_callback']) { |
|
64 | + $args['sanitize_callback'] = [$this, 'sanitize']; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | return $args; |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
77 | 77 | * @return array |
78 | 78 | */ |
79 | - public function filter_control_args( $args, $wp_customize ) { |
|
80 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
81 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
79 | + public function filter_control_args($args, $wp_customize) { |
|
80 | + if ($args['settings'] === $this->args['settings']) { |
|
81 | + $args = parent::filter_control_args($args, $wp_customize); |
|
82 | 82 | $args['type'] = 'kirki-sortable'; |
83 | 83 | } |
84 | 84 | return $args; |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | * @param array $value The checkbox value. |
94 | 94 | * @return array |
95 | 95 | */ |
96 | - public function sanitize( $value = [] ) { |
|
96 | + public function sanitize($value = []) { |
|
97 | 97 | $value = (array) $value; |
98 | 98 | |
99 | - foreach ( $value as $key => $sub_value ) { |
|
100 | - $value[ $key ] = sanitize_text_field( $sub_value ); |
|
99 | + foreach ($value as $key => $sub_value) { |
|
100 | + $value[$key] = sanitize_text_field($sub_value); |
|
101 | 101 | } |
102 | 102 | return $value; |
103 | 103 | } |
@@ -48,10 +48,10 @@ |
||
48 | 48 | parent::enqueue(); |
49 | 49 | |
50 | 50 | // Enqueue the script. |
51 | - wp_enqueue_script( 'kirki-control-sortable', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base' ], self::$control_ver, false ); |
|
51 | + wp_enqueue_script('kirki-control-sortable', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.js'), ['jquery', 'customize-base'], self::$control_ver, false); |
|
52 | 52 | |
53 | 53 | // Enqueue the style. |
54 | - wp_enqueue_style( 'kirki-control-sortable-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
54 | + wp_enqueue_style('kirki-control-sortable-style', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.css'), [], self::$control_ver); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
56 | 56 | * @return array |
57 | 57 | */ |
58 | - public function filter_setting_args( $args, $wp_customize ) { |
|
59 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
60 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
61 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
58 | + public function filter_setting_args($args, $wp_customize) { |
|
59 | + if ($args['settings'] === $this->args['settings']) { |
|
60 | + $args = parent::filter_setting_args($args, $wp_customize); |
|
61 | + if (!isset($args['sanitize_callback']) || !$args['sanitize_callback']) { |
|
62 | 62 | $args['sanitize_callback'] = '__return_null'; |
63 | 63 | } |
64 | 64 | } |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
75 | 75 | * @return array |
76 | 76 | */ |
77 | - public function filter_control_args( $args, $wp_customize ) { |
|
78 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
79 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
77 | + public function filter_control_args($args, $wp_customize) { |
|
78 | + if ($args['settings'] === $this->args['settings']) { |
|
79 | + $args = parent::filter_control_args($args, $wp_customize); |
|
80 | 80 | $args['type'] = 'kirki-custom'; |
81 | 81 | } |
82 | 82 | return $args; |
@@ -30,69 +30,69 @@ discard block |
||
30 | 30 | * @param string $field_id The field ID. |
31 | 31 | * @return string|array |
32 | 32 | */ |
33 | - public static function get_value( $config_id = '', $field_id = '' ) { |
|
33 | + public static function get_value($config_id = '', $field_id = '') { |
|
34 | 34 | |
35 | 35 | // Make sure value is defined. |
36 | 36 | $value = ''; |
37 | 37 | |
38 | 38 | // This allows us to skip the $config_id argument. |
39 | 39 | // If we skip adding a $config_id, use the 'global' configuration. |
40 | - if ( ( '' === $field_id ) && '' !== $config_id ) { |
|
40 | + if (('' === $field_id) && '' !== $config_id) { |
|
41 | 41 | $field_id = $config_id; |
42 | 42 | $config_id = 'global'; |
43 | 43 | } |
44 | 44 | |
45 | 45 | // If $config_id is empty, set it to 'global'. |
46 | - $config_id = ( '' === $config_id ) ? 'global' : $config_id; |
|
46 | + $config_id = ('' === $config_id) ? 'global' : $config_id; |
|
47 | 47 | |
48 | 48 | // Fallback to 'global' if $config_id is not found. |
49 | - if ( ! isset( Kirki::$config[ $config_id ] ) ) { |
|
49 | + if (!isset(Kirki::$config[$config_id])) { |
|
50 | 50 | $config_id = 'global'; |
51 | 51 | } |
52 | 52 | |
53 | - if ( 'theme_mod' === Kirki::$config[ $config_id ]['option_type'] ) { |
|
53 | + if ('theme_mod' === Kirki::$config[$config_id]['option_type']) { |
|
54 | 54 | |
55 | 55 | // We're using theme_mods so just get the value using get_theme_mod. |
56 | 56 | $default_value = null; |
57 | 57 | |
58 | - if ( isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ $field_id ]['default'] ) ) { |
|
59 | - $default_value = Kirki::$all_fields[ $field_id ]['default']; |
|
58 | + if (isset(Kirki::$all_fields[$field_id]) && isset(Kirki::$all_fields[$field_id]['default'])) { |
|
59 | + $default_value = Kirki::$all_fields[$field_id]['default']; |
|
60 | 60 | } |
61 | 61 | |
62 | - $value = get_theme_mod( $field_id, $default_value ); |
|
62 | + $value = get_theme_mod($field_id, $default_value); |
|
63 | 63 | |
64 | - return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
64 | + return apply_filters('kirki_values_get_value', $value, $field_id); |
|
65 | 65 | } |
66 | 66 | |
67 | - if ( 'option' === Kirki::$config[ $config_id ]['option_type'] ) { |
|
67 | + if ('option' === Kirki::$config[$config_id]['option_type']) { |
|
68 | 68 | |
69 | 69 | // We're using options. |
70 | - if ( '' !== Kirki::$config[ $config_id ]['option_name'] ) { |
|
70 | + if ('' !== Kirki::$config[$config_id]['option_name']) { |
|
71 | 71 | // Options are serialized as a single option in the db. |
72 | 72 | // We'll have to get the option and then get the item from the array. |
73 | - $options = get_option( Kirki::$config[ $config_id ]['option_name'] ); |
|
73 | + $options = get_option(Kirki::$config[$config_id]['option_name']); |
|
74 | 74 | |
75 | - if ( ! isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']' ] ) ) { |
|
76 | - $field_id = Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']'; |
|
75 | + if (!isset(Kirki::$all_fields[$field_id]) && isset(Kirki::$all_fields[Kirki::$config[$config_id]['option_name'] . '[' . $field_id . ']'])) { |
|
76 | + $field_id = Kirki::$config[$config_id]['option_name'] . '[' . $field_id . ']'; |
|
77 | 77 | } |
78 | 78 | |
79 | - $setting_modified = str_replace( ']', '', str_replace( Kirki::$config[ $config_id ]['option_name'] . '[', '', $field_id ) ); |
|
79 | + $setting_modified = str_replace(']', '', str_replace(Kirki::$config[$config_id]['option_name'] . '[', '', $field_id)); |
|
80 | 80 | |
81 | - $default_value = ( isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ $field_id ]['default'] ) ) ? Kirki::$all_fields[ $field_id ]['default'] : ''; |
|
82 | - $value = ( isset( $options[ $setting_modified ] ) ) ? $options[ $setting_modified ] : $default_value; |
|
83 | - $value = maybe_unserialize( $value ); |
|
81 | + $default_value = (isset(Kirki::$all_fields[$field_id]) && isset(Kirki::$all_fields[$field_id]['default'])) ? Kirki::$all_fields[$field_id]['default'] : ''; |
|
82 | + $value = (isset($options[$setting_modified])) ? $options[$setting_modified] : $default_value; |
|
83 | + $value = maybe_unserialize($value); |
|
84 | 84 | |
85 | - return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
85 | + return apply_filters('kirki_values_get_value', $value, $field_id); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | // Each option separately saved in the db. |
89 | - $value = get_option( $field_id, Kirki::$all_fields[ $field_id ]['default'] ); |
|
89 | + $value = get_option($field_id, Kirki::$all_fields[$field_id]['default']); |
|
90 | 90 | |
91 | - return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
91 | + return apply_filters('kirki_values_get_value', $value, $field_id); |
|
92 | 92 | |
93 | 93 | } |
94 | 94 | |
95 | - return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
95 | + return apply_filters('kirki_values_get_value', $value, $field_id); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | * @param array $field The field aruments. |
105 | 105 | * @return string|array |
106 | 106 | */ |
107 | - public static function get_sanitized_field_value( $field ) { |
|
107 | + public static function get_sanitized_field_value($field) { |
|
108 | 108 | $value = $field['default']; |
109 | - if ( ! isset( $field['option_type'] ) || 'theme_mod' === $field['option_type'] ) { |
|
110 | - $value = get_theme_mod( $field['settings'], $field['default'] ); |
|
111 | - } elseif ( isset( $field['option_type'] ) && 'option' === $field['option_type'] ) { |
|
112 | - if ( isset( $field['option_name'] ) && '' !== $field['option_name'] ) { |
|
113 | - $all_values = get_option( $field['option_name'], [] ); |
|
114 | - $sub_setting_id = str_replace( [ ']', $field['option_name'] . '[' ], '', $field['settings'] ); |
|
115 | - if ( isset( $all_values[ $sub_setting_id ] ) ) { |
|
116 | - $value = $all_values[ $sub_setting_id ]; |
|
109 | + if (!isset($field['option_type']) || 'theme_mod' === $field['option_type']) { |
|
110 | + $value = get_theme_mod($field['settings'], $field['default']); |
|
111 | + } elseif (isset($field['option_type']) && 'option' === $field['option_type']) { |
|
112 | + if (isset($field['option_name']) && '' !== $field['option_name']) { |
|
113 | + $all_values = get_option($field['option_name'], []); |
|
114 | + $sub_setting_id = str_replace([']', $field['option_name'] . '['], '', $field['settings']); |
|
115 | + if (isset($all_values[$sub_setting_id])) { |
|
116 | + $value = $all_values[$sub_setting_id]; |
|
117 | 117 | } |
118 | 118 | } else { |
119 | - $value = get_option( $field['settings'], $field['default'] ); |
|
119 | + $value = get_option($field['settings'], $field['default']); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | return $value; |