Passed
Push — develop ( d44a36...35a5e4 )
by Aristeides
03:17
created
field/class-kirki-field-spacing.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@
 block discarded – undo
23 23
 	protected function set_choices() {
24 24
 		$default_args = array(
25 25
 			'controls' => array(
26
-				'top'    => ( isset( $this->default['top'] ) ),
27
-				'bottom' => ( isset( $this->default['top'] ) ),
28
-				'left'   => ( isset( $this->default['top'] ) ),
29
-				'right'  => ( isset( $this->default['top'] ) ),
26
+				'top'    => ( isset( $this->default[ 'top' ] ) ),
27
+				'bottom' => ( isset( $this->default[ 'top' ] ) ),
28
+				'left'   => ( isset( $this->default[ 'top' ] ) ),
29
+				'right'  => ( isset( $this->default[ 'top' ] ) ),
30 30
 			),
31 31
 			'labels'   => array(
32 32
 				'top'    => esc_html__( 'Top', 'kirki' ),
Please login to merge, or discard this patch.
field/class-kirki-field-image.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 		if ( ! is_array( $this->choices ) ) {
66 66
 			$this->choices = (array) $this->choices;
67 67
 		}
68
-		if ( ! isset( $this->choices['save_as'] ) ) {
69
-			$this->choices['save_as'] = 'url';
68
+		if ( ! isset( $this->choices[ 'save_as' ] ) ) {
69
+			$this->choices[ 'save_as' ] = 'url';
70 70
 		}
71
-		if ( ! isset( $this->choices['labels'] ) ) {
72
-			$this->choices['labels'] = array();
71
+		if ( ! isset( $this->choices[ 'labels' ] ) ) {
72
+			$this->choices[ 'labels' ] = array();
73 73
 		}
74 74
 		$this->set_button_labels();
75
-		$this->choices['labels'] = wp_parse_args( $this->choices['labels'], $this->button_labels );
75
+		$this->choices[ 'labels' ] = wp_parse_args( $this->choices[ 'labels' ], $this->button_labels );
76 76
 	}
77 77
 
78 78
 	/**
@@ -96,15 +96,15 @@  discard block
 block discarded – undo
96 96
 	 * @param string|array $value The control's value.
97 97
 	 */
98 98
 	public function sanitize( $value ) {
99
-		if ( isset( $this->choices['save_as'] ) && 'array' === $this->choices['save_as'] ) {
99
+		if ( isset( $this->choices[ 'save_as' ] ) && 'array' === $this->choices[ 'save_as' ] ) {
100 100
 			return array(
101
-				'id'     => ( isset( $value['id'] ) && '' !== $value['id'] ) ? (int) $value['id'] : '',
102
-				'url'    => ( isset( $value['url'] ) && '' !== $value['url'] ) ? esc_url_raw( $value['url'] ) : '',
103
-				'width'  => ( isset( $value['width'] ) && '' !== $value['width'] ) ? (int) $value['width'] : '',
104
-				'height' => ( isset( $value['height'] ) && '' !== $value['height'] ) ? (int) $value['height'] : '',
101
+				'id'     => ( isset( $value[ 'id' ] ) && '' !== $value[ 'id' ] ) ? (int) $value[ 'id' ] : '',
102
+				'url'    => ( isset( $value[ 'url' ] ) && '' !== $value[ 'url' ] ) ? esc_url_raw( $value[ 'url' ] ) : '',
103
+				'width'  => ( isset( $value[ 'width' ] ) && '' !== $value[ 'width' ] ) ? (int) $value[ 'width' ] : '',
104
+				'height' => ( isset( $value[ 'height' ] ) && '' !== $value[ 'height' ] ) ? (int) $value[ 'height' ] : '',
105 105
 			);
106 106
 		}
107
-		if ( isset( $this->choices['save_as'] ) && 'id' === $this->choices['save_as'] ) {
107
+		if ( isset( $this->choices[ 'save_as' ] ) && 'id' === $this->choices[ 'save_as' ] ) {
108 108
 			return absint( $value );
109 109
 		}
110 110
 		if ( is_string( $value ) ) {
Please login to merge, or discard this patch.
field/class-kirki-field-editor.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@
 block discarded – undo
32 32
 		if ( ! is_array( $this->choices ) ) {
33 33
 			$this->choices = array();
34 34
 		}
35
-		$this->choices['element'] = 'textarea';
36
-		$this->choices['rows']    = '5';
35
+		$this->choices[ 'element' ] = 'textarea';
36
+		$this->choices[ 'rows' ]    = '5';
37 37
 	}
38 38
 
39 39
 	/**
Please login to merge, or discard this patch.
field/class-kirki-field-sortable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 		$sanitized_value = array();
49 49
 		foreach ( $value as $sub_value ) {
50 50
 			if ( isset( $this->choices[ $sub_value ] ) ) {
51
-				$sanitized_value[] = sanitize_text_field( $sub_value );
51
+				$sanitized_value[ ] = sanitize_text_field( $sub_value );
52 52
 			}
53 53
 		}
54 54
 		return $sanitized_value;
Please login to merge, or discard this patch.
field/class-kirki-field-typography.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
 	protected function set_default() {
48 48
 
49 49
 		// Accomodate the use of font-weight and convert to variant.
50
-		if ( isset( $this->default['font-weight'] ) ) {
51
-			$this->default['variant'] = ( 'regular' === $this->default['font-weight'] ) ? 400 : (string) intval( $this->default['font-weight'] );
50
+		if ( isset( $this->default[ 'font-weight' ] ) ) {
51
+			$this->default[ 'variant' ] = ( 'regular' === $this->default[ 'font-weight' ] ) ? 400 : (string) intval( $this->default[ 'font-weight' ] );
52 52
 		}
53 53
 
54 54
 		// Make sure letter-spacing has units.
55
-		if ( isset( $this->default['letter-spacing'] ) && is_numeric( $this->default['letter-spacing'] ) && $this->default['letter-spacing'] ) {
56
-			$this->default['letter-spacing'] .= 'px';
55
+		if ( isset( $this->default[ 'letter-spacing' ] ) && is_numeric( $this->default[ 'letter-spacing' ] ) && $this->default[ 'letter-spacing' ] ) {
56
+			$this->default[ 'letter-spacing' ] .= 'px';
57 57
 		}
58 58
 	}
59 59
 
@@ -102,15 +102,15 @@  discard block
 block discarded – undo
102 102
 			foreach ( $this->output as $output ) {
103 103
 
104 104
 				// If 'element' or 'property' are not defined, skip this.
105
-				if ( ! isset( $output['element'] ) ) {
105
+				if ( ! isset( $output[ 'element' ] ) ) {
106 106
 					continue;
107 107
 				}
108
-				if ( is_array( $output['element'] ) ) {
109
-					$output['element'] = implode( ',', $output['element'] );
108
+				if ( is_array( $output[ 'element' ] ) ) {
109
+					$output[ 'element' ] = implode( ',', $output[ 'element' ] );
110 110
 				}
111 111
 
112 112
 				// If we got this far, it's safe to add this.
113
-				$js_vars[] = $output;
113
+				$js_vars[ ] = $output;
114 114
 			}
115 115
 
116 116
 			// Did we manage to get all the items from 'output'?
@@ -139,29 +139,29 @@  discard block
 block discarded – undo
139 139
 		foreach ( $value as $key => $val ) {
140 140
 			switch ( $key ) {
141 141
 				case 'font-family':
142
-					$value['font-family'] = sanitize_text_field( $val );
142
+					$value[ 'font-family' ] = sanitize_text_field( $val );
143 143
 					break;
144 144
 				case 'font-weight':
145
-					if ( isset( $value['variant'] ) ) {
145
+					if ( isset( $value[ 'variant' ] ) ) {
146 146
 						break;
147 147
 					}
148
-					$value['variant'] = $val;
149
-					if ( isset( $value['font-style'] ) && 'italic' === $value['font-style'] ) {
150
-						$value['variant'] = ( '400' !== $val || 400 !== $val ) ? $value['variant'] . 'italic' : 'italic';
148
+					$value[ 'variant' ] = $val;
149
+					if ( isset( $value[ 'font-style' ] ) && 'italic' === $value[ 'font-style' ] ) {
150
+						$value[ 'variant' ] = ( '400' !== $val || 400 !== $val ) ? $value[ 'variant' ] . 'italic' : 'italic';
151 151
 					}
152 152
 					break;
153 153
 				case 'variant':
154 154
 
155 155
 					// Use 'regular' instead of 400 for font-variant.
156
-					$value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val;
156
+					$value[ 'variant' ] = ( 400 === $val || '400' === $val ) ? 'regular' : $val;
157 157
 
158 158
 					// Get font-weight from variant.
159
-					$value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
160
-					$value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? 400 : absint( $value['font-weight'] );
159
+					$value[ 'font-weight' ] = filter_var( $value[ 'variant' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
160
+					$value[ 'font-weight' ] = ( 'regular' === $value[ 'variant' ] || 'italic' === $value[ 'variant' ] ) ? 400 : absint( $value[ 'font-weight' ] );
161 161
 
162 162
 					// Get font-style from variant.
163
-					if ( ! isset( $value['font-style'] ) ) {
164
-						$value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic';
163
+					if ( ! isset( $value[ 'font-style' ] ) ) {
164
+						$value[ 'font-style' ] = ( false === strpos( $value[ 'variant' ], 'italic' ) ) ? 'normal' : 'italic';
165 165
 					}
166 166
 					break;
167 167
 				case 'font-size':
@@ -172,21 +172,21 @@  discard block
 block discarded – undo
172 172
 					break;
173 173
 				case 'text-align':
174 174
 					if ( ! in_array( $val, array( '', 'inherit', 'left', 'center', 'right', 'justify' ), true ) ) {
175
-						$value['text-align'] = '';
175
+						$value[ 'text-align' ] = '';
176 176
 					}
177 177
 					break;
178 178
 				case 'text-transform':
179 179
 					if ( ! in_array( $val, array( '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ), true ) ) {
180
-						$value['text-transform'] = '';
180
+						$value[ 'text-transform' ] = '';
181 181
 					}
182 182
 					break;
183 183
 				case 'text-decoration':
184 184
 					if ( ! in_array( $val, array( '', 'none', 'underline', 'overline', 'line-through', 'initial', 'inherit' ), true ) ) {
185
-						$value['text-transform'] = '';
185
+						$value[ 'text-transform' ] = '';
186 186
 					}
187 187
 					break;
188 188
 				case 'color':
189
-					$value['color'] = '' === $value['color'] ? '' : ariColor::newColor( $val )->toCSS( 'hex' );
189
+					$value[ 'color' ] = '' === $value[ 'color' ] ? '' : ariColor::newColor( $val )->toCSS( 'hex' );
190 190
 					break;
191 191
 			}
192 192
 		}
Please login to merge, or discard this patch.
core/class-kirki-panel.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@
 block discarded – undo
44 44
 	public function add_panel( $args ) {
45 45
 		global $wp_customize;
46 46
 
47
-		if ( ! isset( $args['type'] ) || ! array_key_exists( $args['type'], $this->panel_types ) ) {
48
-			$args['type'] = 'default';
47
+		if ( ! isset( $args[ 'type' ] ) || ! array_key_exists( $args[ 'type' ], $this->panel_types ) ) {
48
+			$args[ 'type' ] = 'default';
49 49
 		}
50
-		$panel_classname = $this->panel_types[ $args['type'] ];
50
+		$panel_classname = $this->panel_types[ $args[ 'type' ] ];
51 51
 
52
-		$wp_customize->add_panel( new $panel_classname( $wp_customize, $args['id'], $args ) );
52
+		$wp_customize->add_panel( new $panel_classname( $wp_customize, $args[ 'id' ], $args ) );
53 53
 	}
54 54
 }
Please login to merge, or discard this patch.
core/class-kirki-sections.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@
 block discarded – undo
37 37
 		$css = '';
38 38
 		if ( ! empty( Kirki::$sections ) ) {
39 39
 			foreach ( Kirki::$sections as $section_args ) {
40
-				if ( isset( $section_args['id'] ) && isset( $section_args['type'] ) && 'outer' === $section_args['type'] || 'kirki-outer' === $section_args['type'] ) {
41
-					echo '#customize-theme-controls li#accordion-section-' . esc_html( $section_args['id'] ) . '{display:list-item!important;}';
40
+				if ( isset( $section_args[ 'id' ] ) && isset( $section_args[ 'type' ] ) && 'outer' === $section_args[ 'type' ] || 'kirki-outer' === $section_args[ 'type' ] ) {
41
+					echo '#customize-theme-controls li#accordion-section-' . esc_html( $section_args[ 'id' ] ) . '{display:list-item!important;}';
42 42
 				}
43 43
 			}
44 44
 		}
Please login to merge, or discard this patch.
core/class-kirki-section.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,15 +46,15 @@
 block discarded – undo
46 46
 		// The default class to be used when creating a section.
47 47
 		$section_classname = 'WP_Customize_Section';
48 48
 
49
-		if ( isset( $args['type'] ) && array_key_exists( $args['type'], $this->section_types ) ) {
50
-			$section_classname = $this->section_types[ $args['type'] ];
49
+		if ( isset( $args[ 'type' ] ) && array_key_exists( $args[ 'type' ], $this->section_types ) ) {
50
+			$section_classname = $this->section_types[ $args[ 'type' ] ];
51 51
 		}
52
-		if ( isset( $args['type'] ) && 'kirki-outer' === $args['type'] ) {
53
-			$args['type']      = 'outer';
52
+		if ( isset( $args[ 'type' ] ) && 'kirki-outer' === $args[ 'type' ] ) {
53
+			$args[ 'type' ]      = 'outer';
54 54
 			$section_classname = 'WP_Customize_Section';
55 55
 		}
56 56
 
57 57
 		// Add the section.
58
-		$wp_customize->add_section( new $section_classname( $wp_customize, $args['id'], $args ) );
58
+		$wp_customize->add_section( new $section_classname( $wp_customize, $args[ 'id' ], $args ) );
59 59
 	}
60 60
 }
Please login to merge, or discard this patch.
core/class-kirki-values.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
 	 * @return array
39 39
 	 */
40 40
 	public function typography_field_tweaks( $value, $field_id ) {
41
-		if ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['type'] ) ) {
42
-			if ( 'kirki-typography' === Kirki::$fields[ $field_id ]['type'] ) {
41
+		if ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ][ 'type' ] ) ) {
42
+			if ( 'kirki-typography' === Kirki::$fields[ $field_id ][ 'type' ] ) {
43 43
 
44 44
 				// Sanitize the value.
45 45
 				// This also adds font-weight if it doesn't already exist.
46 46
 				$value = Kirki_Field_Typography::sanitize( $value );
47 47
 
48 48
 				// Combine font-family and font-backup.
49
-				if ( isset( $value['font-family'] ) && isset( $value['font-backup'] ) ) {
50
-					$value['font-family'] .= ', ' . $value['font-backup'];
51
-					unset( $value['font-backup'] );
49
+				if ( isset( $value[ 'font-family' ] ) && isset( $value[ 'font-backup' ] ) ) {
50
+					$value[ 'font-family' ] .= ', ' . $value[ 'font-backup' ];
51
+					unset( $value[ 'font-backup' ] );
52 52
 				}
53 53
 			}
54 54
 		}
@@ -85,39 +85,39 @@  discard block
 block discarded – undo
85 85
 			$config_id = 'global';
86 86
 		}
87 87
 
88
-		if ( 'theme_mod' === Kirki::$config[ $config_id ]['option_type'] ) {
88
+		if ( 'theme_mod' === Kirki::$config[ $config_id ][ 'option_type' ] ) {
89 89
 
90 90
 			// We're using theme_mods so just get the value using get_theme_mod.
91 91
 			$default_value = null;
92
-			if ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['default'] ) ) {
93
-				$default_value = Kirki::$fields[ $field_id ]['default'];
92
+			if ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ][ 'default' ] ) ) {
93
+				$default_value = Kirki::$fields[ $field_id ][ 'default' ];
94 94
 			}
95 95
 			$value = get_theme_mod( $field_id, $default_value );
96 96
 			return apply_filters( 'kirki_values_get_value', $value, $field_id );
97 97
 		}
98 98
 
99
-		if ( 'option' === Kirki::$config[ $config_id ]['option_type'] ) {
99
+		if ( 'option' === Kirki::$config[ $config_id ][ 'option_type' ] ) {
100 100
 
101 101
 			// We're using options.
102
-			if ( '' !== Kirki::$config[ $config_id ]['option_name'] ) {
102
+			if ( '' !== Kirki::$config[ $config_id ][ 'option_name' ] ) {
103 103
 
104 104
 				// Options are serialized as a single option in the db.
105 105
 				// We'll have to get the option and then get the item from the array.
106
-				$options = get_option( Kirki::$config[ $config_id ]['option_name'] );
106
+				$options = get_option( Kirki::$config[ $config_id ][ 'option_name' ] );
107 107
 
108
-				if ( ! isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']' ] ) ) {
109
-					$field_id = Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']';
108
+				if ( ! isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ Kirki::$config[ $config_id ][ 'option_name' ] . '[' . $field_id . ']' ] ) ) {
109
+					$field_id = Kirki::$config[ $config_id ][ 'option_name' ] . '[' . $field_id . ']';
110 110
 				}
111
-				$setting_modified = str_replace( ']', '', str_replace( Kirki::$config[ $config_id ]['option_name'] . '[', '', $field_id ) );
111
+				$setting_modified = str_replace( ']', '', str_replace( Kirki::$config[ $config_id ][ 'option_name' ] . '[', '', $field_id ) );
112 112
 
113
-				$default_value = ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['default'] ) ) ? Kirki::$fields[ $field_id ]['default'] : '';
113
+				$default_value = ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ][ 'default' ] ) ) ? Kirki::$fields[ $field_id ][ 'default' ] : '';
114 114
 				$value         = ( isset( $options[ $setting_modified ] ) ) ? $options[ $setting_modified ] : $default_value;
115 115
 				$value         = maybe_unserialize( $value );
116 116
 				return apply_filters( 'kirki_values_get_value', $value, $field_id );
117 117
 			}
118 118
 
119 119
 			// Each option separately saved in the db.
120
-			$value = get_option( $field_id, Kirki::$fields[ $field_id ]['default'] );
120
+			$value = get_option( $field_id, Kirki::$fields[ $field_id ][ 'default' ] );
121 121
 			return apply_filters( 'kirki_values_get_value', $value, $field_id );
122 122
 
123 123
 		}
@@ -133,18 +133,18 @@  discard block
 block discarded – undo
133 133
 	 * @return string|array
134 134
 	 */
135 135
 	public static function get_sanitized_field_value( $field ) {
136
-		$value = $field['default'];
137
-		if ( isset( $field['option_type'] ) && 'theme_mod' === $field['option_type'] ) {
138
-			$value = get_theme_mod( $field['settings'], $field['default'] );
139
-		} elseif ( isset( $field['option_type'] ) && 'option' === $field['option_type'] ) {
140
-			if ( isset( $field['option_name'] ) && '' !== $field['option_name'] ) {
141
-				$all_values     = get_option( $field['option_name'], array() );
142
-				$sub_setting_id = str_replace( array( ']', $field['option_name'] . '[' ), '', $field['settings'] );
136
+		$value = $field[ 'default' ];
137
+		if ( isset( $field[ 'option_type' ] ) && 'theme_mod' === $field[ 'option_type' ] ) {
138
+			$value = get_theme_mod( $field[ 'settings' ], $field[ 'default' ] );
139
+		} elseif ( isset( $field[ 'option_type' ] ) && 'option' === $field[ 'option_type' ] ) {
140
+			if ( isset( $field[ 'option_name' ] ) && '' !== $field[ 'option_name' ] ) {
141
+				$all_values     = get_option( $field[ 'option_name' ], array() );
142
+				$sub_setting_id = str_replace( array( ']', $field[ 'option_name' ] . '[' ), '', $field[ 'settings' ] );
143 143
 				if ( isset( $all_values[ $sub_setting_id ] ) ) {
144 144
 					$value = $all_values[ $sub_setting_id ];
145 145
 				}
146 146
 			} else {
147
-				$value = get_option( $field['settings'], $field['default'] );
147
+				$value = get_option( $field[ 'settings' ], $field[ 'default' ] );
148 148
 			}
149 149
 		}
150 150
 		return $value;
Please login to merge, or discard this patch.