Passed
Push — develop ( c72d19...28820c )
by Aristeides
03:14
created
core/class-kirki-field.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -243,28 +243,28 @@  discard block
 block discarded – undo
243 243
 	 */
244 244
 	public function __construct( $config_id = 'global', $args = array() ) {
245 245
 
246
-		if ( isset( $args['setting'] ) && ! empty( $args['setting'] ) && ( ! isset( $args['settings'] ) || empty( $args['settings'] ) ) ) {
246
+		if ( isset( $args[ 'setting' ] ) && ! empty( $args[ 'setting' ] ) && ( ! isset( $args[ 'settings' ] ) || empty( $args[ 'settings' ] ) ) ) {
247 247
 			/* translators: %s represents the field ID where the error occurs. */
248
-			_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Typo found in field %s - setting instead of settings.', 'kirki' ), esc_attr( $args['settings'] ) ), '3.0.10' );
249
-			$args['settings'] = $args['setting'];
250
-			unset( $args['setting'] );
248
+			_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Typo found in field %s - setting instead of settings.', 'kirki' ), esc_attr( $args[ 'settings' ] ) ), '3.0.10' );
249
+			$args[ 'settings' ] = $args[ 'setting' ];
250
+			unset( $args[ 'setting' ] );
251 251
 		}
252 252
 
253 253
 		// In case the user only provides 1 argument,
254 254
 		// assume that the provided argument is $args and set $config_id = 'global'.
255 255
 		if ( is_array( $config_id ) && empty( $args ) ) {
256 256
 			/* translators: %1$s represents the field ID where the error occurs. %2$s is the URL in the documentation site. */
257
-			_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' );
257
+			_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args[ 'settings' ] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' );
258 258
 			$args      = $config_id;
259 259
 			$config_id = 'global';
260 260
 		}
261 261
 
262
-		$args['kirki_config'] = $config_id;
262
+		$args[ 'kirki_config' ] = $config_id;
263 263
 
264 264
 		$this->kirki_config = trim( esc_attr( $config_id ) );
265 265
 		if ( '' === $config_id ) {
266 266
 			/* translators: %1$s represents the field ID where the error occurs. %2$s is the URL in the documentation site. */
267
-			_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' );
267
+			_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args[ 'settings' ] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' );
268 268
 			$this->kirki_config = 'global';
269 269
 		}
270 270
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 		$defaults = get_class_vars( __CLASS__ );
273 273
 
274 274
 		// Get the config arguments, and merge them with the defaults.
275
-		$config_defaults = ( isset( Kirki::$config['global'] ) ) ? Kirki::$config['global'] : array();
275
+		$config_defaults = ( isset( Kirki::$config[ 'global' ] ) ) ? Kirki::$config[ 'global' ] : array();
276 276
 		if ( 'global' !== $this->kirki_config && isset( Kirki::$config[ $this->kirki_config ] ) ) {
277 277
 			$config_defaults = Kirki::$config[ $this->kirki_config ];
278 278
 		}
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 			$this->partial_refresh = array();
421 421
 		}
422 422
 		foreach ( $this->partial_refresh as $id => $args ) {
423
-			if ( ! is_array( $args ) || ! isset( $args['selector'] ) || ! isset( $args['render_callback'] ) || ! is_callable( $args['render_callback'] ) ) {
423
+			if ( ! is_array( $args ) || ! isset( $args[ 'selector' ] ) || ! isset( $args[ 'render_callback' ] ) || ! is_callable( $args[ 'render_callback' ] ) ) {
424 424
 				/* translators: %1$s represents the field ID where the error occurs. */
425 425
 				_doing_it_wrong( __METHOD__, sprintf( esc_attr__( '"partial_refresh" invalid entry in field %s', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' );
426 426
 				unset( $this->partial_refresh[ $id ] );
@@ -458,8 +458,8 @@  discard block
 block discarded – undo
458 458
 			}
459 459
 		}
460 460
 		$this->settings = $settings;
461
-		if ( isset( $this->settings['kirki_placeholder_setting'] ) ) {
462
-			$this->settings = $this->settings['kirki_placeholder_setting'];
461
+		if ( isset( $this->settings[ 'kirki_placeholder_setting' ] ) ) {
462
+			$this->settings = $this->settings[ 'kirki_placeholder_setting' ];
463 463
 		}
464 464
 	}
465 465
 
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 						unset( $this->active_callback[ $key ] );
482 482
 					}
483 483
 				}
484
-				if ( isset( $this->active_callback[0] ) ) {
484
+				if ( isset( $this->active_callback[ 0 ] ) ) {
485 485
 					$this->required = $this->active_callback;
486 486
 				}
487 487
 			}
@@ -568,34 +568,34 @@  discard block
 block discarded – undo
568 568
 			);
569 569
 		}
570 570
 		// Convert to array of arrays if needed.
571
-		if ( isset( $this->output['element'] ) ) {
571
+		if ( isset( $this->output[ 'element' ] ) ) {
572 572
 			/* translators: The field ID where the error occurs. */
573 573
 			_doing_it_wrong( __METHOD__, sprintf( esc_attr__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' );
574 574
 			$this->output = array( $this->output );
575 575
 		}
576 576
 		foreach ( $this->output as $key => $output ) {
577
-			if ( empty( $output ) || ! isset( $output['element'] ) ) {
577
+			if ( empty( $output ) || ! isset( $output[ 'element' ] ) ) {
578 578
 				unset( $this->output[ $key ] );
579 579
 				continue;
580 580
 			}
581
-			if ( ! isset( $output['sanitize_callback'] ) && isset( $output['callback'] ) ) {
582
-				$this->output[ $key ]['sanitize_callback'] = $output['callback'];
581
+			if ( ! isset( $output[ 'sanitize_callback' ] ) && isset( $output[ 'callback' ] ) ) {
582
+				$this->output[ $key ][ 'sanitize_callback' ] = $output[ 'callback' ];
583 583
 			}
584 584
 			// Convert element arrays to strings.
585
-			if ( isset( $output['element'] ) && is_array( $output['element'] ) ) {
586
-				$this->output[ $key ]['element'] = array_unique( $this->output[ $key ]['element'] );
587
-				sort( $this->output[ $key ]['element'] );
585
+			if ( isset( $output[ 'element' ] ) && is_array( $output[ 'element' ] ) ) {
586
+				$this->output[ $key ][ 'element' ] = array_unique( $this->output[ $key ][ 'element' ] );
587
+				sort( $this->output[ $key ][ 'element' ] );
588 588
 
589 589
 				// Trim each element in the array.
590
-				foreach ( $this->output[ $key ]['element'] as $index => $element ) {
591
-					$this->output[ $key ]['element'][ $index ] = trim( $element );
590
+				foreach ( $this->output[ $key ][ 'element' ] as $index => $element ) {
591
+					$this->output[ $key ][ 'element' ][ $index ] = trim( $element );
592 592
 				}
593
-				$this->output[ $key ]['element'] = implode( ',', $this->output[ $key ]['element'] );
593
+				$this->output[ $key ][ 'element' ] = implode( ',', $this->output[ $key ][ 'element' ] );
594 594
 			}
595 595
 
596 596
 			// Fix for https://github.com/aristath/kirki/issues/1659#issuecomment-346229751.
597
-			$this->output[ $key ]['element'] = str_replace( array( "\t", "\n", "\r", "\0", "\x0B" ), ' ', $this->output[ $key ]['element'] );
598
-			$this->output[ $key ]['element'] = trim( preg_replace( '/\s+/', ' ', $this->output[ $key ]['element'] ) );
597
+			$this->output[ $key ][ 'element' ] = str_replace( array( "\t", "\n", "\r", "\0", "\x0B" ), ' ', $this->output[ $key ][ 'element' ] );
598
+			$this->output[ $key ][ 'element' ] = trim( preg_replace( '/\s+/', ' ', $this->output[ $key ][ 'element' ] ) );
599 599
 		}
600 600
 	}
601 601
 
@@ -628,23 +628,23 @@  discard block
 block discarded – undo
628 628
 
629 629
 			// Start going through each item in the $output array.
630 630
 			foreach ( $this->output as $output ) {
631
-				$output['function'] = ( isset( $output['function'] ) ) ? $output['function'] : 'style';
631
+				$output[ 'function' ] = ( isset( $output[ 'function' ] ) ) ? $output[ 'function' ] : 'style';
632 632
 
633 633
 				// If 'element' or 'property' are not defined, skip this.
634
-				if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) {
634
+				if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) {
635 635
 					continue;
636 636
 				}
637
-				if ( is_array( $output['element'] ) ) {
638
-					$output['element'] = implode( ',', $output['element'] );
637
+				if ( is_array( $output[ 'element' ] ) ) {
638
+					$output[ 'element' ] = implode( ',', $output[ 'element' ] );
639 639
 				}
640 640
 
641 641
 				// If there's a sanitize_callback defined skip this, unless we also have a js_callback defined.
642
-				if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) && ! isset( $output['js_callback'] ) ) {
642
+				if ( isset( $output[ 'sanitize_callback' ] ) && ! empty( $output[ 'sanitize_callback' ] ) && ! isset( $output[ 'js_callback' ] ) ) {
643 643
 					continue;
644 644
 				}
645 645
 
646 646
 				// If we got this far, it's safe to add this.
647
-				$js_vars[] = $output;
647
+				$js_vars[ ] = $output;
648 648
 			}
649 649
 
650 650
 			// Did we manage to get all the items from 'output'?
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 			$variable        = ( is_string( $this->variables ) && ! empty( $this->variables ) ) ? $this->variables : false;
670 670
 			$this->variables = array();
671 671
 			if ( $variable && empty( $this->variables ) ) {
672
-				$this->variables[0]['name'] = $variable;
672
+				$this->variables[ 0 ][ 'name' ] = $variable;
673 673
 			}
674 674
 		}
675 675
 	}
@@ -717,12 +717,12 @@  discard block
 block discarded – undo
717 717
 		if ( is_string( $this->css_vars ) ) {
718 718
 			$this->css_vars = array( $this->css_vars );
719 719
 		}
720
-		if ( isset( $this->css_vars[0] ) && is_string( $this->css_vars[0] ) ) {
720
+		if ( isset( $this->css_vars[ 0 ] ) && is_string( $this->css_vars[ 0 ] ) ) {
721 721
 			$this->css_vars = array( $this->css_vars );
722 722
 		}
723 723
 		foreach ( $this->css_vars as $key => $val ) {
724
-			if ( ! isset( $val[1] ) ) {
725
-				$this->css_vars[ $key ][1] = '$';
724
+			if ( ! isset( $val[ 1 ] ) ) {
725
+				$this->css_vars[ $key ][ 1 ] = '$';
726 726
 			}
727 727
 		}
728 728
 	}
Please login to merge, or discard this patch.