@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | $config = Kirki_Config::get_instance( $config_id, $args ); |
146 | 146 | $config_args = $config->get_config(); |
147 | - self::$config[ $config_args['id'] ] = $config_args; |
|
147 | + self::$config[ $config_args[ 'id' ] ] = $config_args; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public static function add_panel( $id = '', $args = array() ) { |
159 | 159 | |
160 | - $args['id'] = esc_attr( $id ); |
|
161 | - $args['description'] = ( isset( $args['description'] ) ) ? $args['description'] : ''; |
|
162 | - $args['priority'] = ( isset( $args['priority'] ) ) ? absint( $args['priority'] ) : 10; |
|
163 | - $args['type'] = ( isset( $args['type'] ) ) ? $args['type'] : 'default'; |
|
164 | - $args['type'] = 'kirki-' . $args['type']; |
|
160 | + $args[ 'id' ] = esc_attr( $id ); |
|
161 | + $args[ 'description' ] = ( isset( $args[ 'description' ] ) ) ? $args[ 'description' ] : ''; |
|
162 | + $args[ 'priority' ] = ( isset( $args[ 'priority' ] ) ) ? absint( $args[ 'priority' ] ) : 10; |
|
163 | + $args[ 'type' ] = ( isset( $args[ 'type' ] ) ) ? $args[ 'type' ] : 'default'; |
|
164 | + $args[ 'type' ] = 'kirki-' . $args[ 'type' ]; |
|
165 | 165 | |
166 | - self::$panels[ $args['id'] ] = $args; |
|
166 | + self::$panels[ $args[ 'id' ] ] = $args; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public static function remove_panel( $id = '' ) { |
178 | 178 | if ( ! in_array( $id, self::$panels_to_remove, true ) ) { |
179 | - self::$panels_to_remove[] = $id; |
|
179 | + self::$panels_to_remove[ ] = $id; |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public static function add_section( $id, $args ) { |
192 | 192 | |
193 | - $args['id'] = esc_attr( $id ); |
|
194 | - $args['panel'] = ( isset( $args['panel'] ) ) ? esc_attr( $args['panel'] ) : ''; |
|
195 | - $args['description'] = ( isset( $args['description'] ) ) ? $args['description'] : ''; |
|
196 | - $args['priority'] = ( isset( $args['priority'] ) ) ? absint( $args['priority'] ) : 10; |
|
197 | - $args['type'] = ( isset( $args['type'] ) ) ? $args['type'] : 'default'; |
|
198 | - $args['type'] = 'kirki-' . $args['type']; |
|
193 | + $args[ 'id' ] = esc_attr( $id ); |
|
194 | + $args[ 'panel' ] = ( isset( $args[ 'panel' ] ) ) ? esc_attr( $args[ 'panel' ] ) : ''; |
|
195 | + $args[ 'description' ] = ( isset( $args[ 'description' ] ) ) ? $args[ 'description' ] : ''; |
|
196 | + $args[ 'priority' ] = ( isset( $args[ 'priority' ] ) ) ? absint( $args[ 'priority' ] ) : 10; |
|
197 | + $args[ 'type' ] = ( isset( $args[ 'type' ] ) ) ? $args[ 'type' ] : 'default'; |
|
198 | + $args[ 'type' ] = 'kirki-' . $args[ 'type' ]; |
|
199 | 199 | |
200 | - self::$sections[ $args['id'] ] = $args; |
|
200 | + self::$sections[ $args[ 'id' ] ] = $args; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public static function remove_section( $id = '' ) { |
212 | 212 | if ( ! in_array( $id, self::$sections_to_remove, true ) ) { |
213 | - self::$sections_to_remove[] = $id; |
|
213 | + self::$sections_to_remove[ ] = $id; |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
@@ -229,16 +229,16 @@ discard block |
||
229 | 229 | } |
230 | 230 | |
231 | 231 | // Early exit if 'type' is not defined. |
232 | - if ( ! isset( $args['type'] ) ) { |
|
232 | + if ( ! isset( $args[ 'type' ] ) ) { |
|
233 | 233 | return; |
234 | 234 | } |
235 | 235 | |
236 | 236 | // If the field is font-awesome, enqueue the icons on the frontend. |
237 | - if ( class_exists( 'Kirki_Modules_CSS' ) && ( 'fontawesome' === $args['type'] || 'kirki-fontawesome' === $args['type'] ) ) { |
|
237 | + if ( class_exists( 'Kirki_Modules_CSS' ) && ( 'fontawesome' === $args[ 'type' ] || 'kirki-fontawesome' === $args[ 'type' ] ) ) { |
|
238 | 238 | Kirki_Modules_CSS::add_fontawesome_script(); |
239 | 239 | } |
240 | 240 | |
241 | - $str = str_replace( array( '-', '_' ), ' ', $args['type'] ); |
|
241 | + $str = str_replace( array( '-', '_' ), ' ', $args[ 'type' ] ); |
|
242 | 242 | $classname = 'Kirki_Field_' . str_replace( ' ', '_', ucwords( $str ) ); |
243 | 243 | if ( class_exists( $classname ) ) { |
244 | 244 | new $classname( $config_id, $args ); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public static function remove_control( $id ) { |
268 | 268 | if ( ! in_array( $id, self::$controls_to_remove, true ) ) { |
269 | - self::$controls_to_remove[] = $id; |
|
269 | + self::$controls_to_remove[ ] = $id; |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $fonts_to_load = $this->googlefonts->fonts; |
88 | 88 | |
89 | 89 | if ( ! empty( $fonts_to_load ) && 'preconnect' === $relation_type ) { |
90 | - $urls[] = array( |
|
90 | + $urls[ ] = array( |
|
91 | 91 | 'href' => 'https://fonts.gstatic.com', |
92 | 92 | 'crossorigin', |
93 | 93 | ); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $weights[ $key ] = str_replace( array( 'regular', 'bold', 'italic' ), array( '400', '', 'i' ), $value ); |
121 | 121 | } |
122 | 122 | } |
123 | - $this->fonts_to_load[] = $font . ':' . join( ',', $weights ) . ':cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai'; |
|
123 | + $this->fonts_to_load[ ] = $font . ':' . join( ',', $weights ) . ':cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai'; |
|
124 | 124 | } |
125 | 125 | if ( ! empty( $this->fonts_to_load ) ) { |
126 | 126 | Kirki_Modules_Webfont_Loader::$load = true; |
@@ -39,18 +39,18 @@ |
||
39 | 39 | |
40 | 40 | foreach ( array_keys( $value ) as $key ) { |
41 | 41 | |
42 | - $property = ( empty( $output['property'] ) ) ? $key : $output['property'] . '-' . $key; |
|
43 | - if ( isset( $output['choice'] ) && $output['property'] ) { |
|
44 | - if ( $key === $output['choice'] ) { |
|
45 | - $property = $output['property']; |
|
42 | + $property = ( empty( $output[ 'property' ] ) ) ? $key : $output[ 'property' ] . '-' . $key; |
|
43 | + if ( isset( $output[ 'choice' ] ) && $output[ 'property' ] ) { |
|
44 | + if ( $key === $output[ 'choice' ] ) { |
|
45 | + $property = $output[ 'property' ]; |
|
46 | 46 | } else { |
47 | 47 | continue; |
48 | 48 | } |
49 | 49 | } |
50 | - if ( false !== strpos( $output['property'], '%%' ) ) { |
|
51 | - $property = str_replace( '%%', $key, $output['property'] ); |
|
50 | + if ( false !== strpos( $output[ 'property' ], '%%' ) ) { |
|
51 | + $property = str_replace( '%%', $key, $output[ 'property' ] ); |
|
52 | 52 | } |
53 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $this->process_property_value( $property, $value[ $key ] ) . $output['suffix']; |
|
53 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $property ] = $output[ 'prefix' ] . $this->process_property_value( $property, $value[ $key ] ) . $output[ 'suffix' ]; |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | } |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | |
63 | 63 | // Apply the kirki_config filter. |
64 | 64 | $config = apply_filters( 'kirki_config', array() ); |
65 | - if ( isset( $config['url_path'] ) ) { |
|
66 | - Kirki::$url = $config['url_path']; |
|
65 | + if ( isset( $config[ 'url_path' ] ) ) { |
|
66 | + Kirki::$url = $config[ 'url_path' ]; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Make sure the right protocol is used. |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | $this->control_types = $this->default_control_types(); |
145 | 145 | if ( ! class_exists( 'WP_Customize_Code_Editor_Control' ) ) { |
146 | - unset( $this->control_types['code_editor'] ); |
|
146 | + unset( $this->control_types[ 'code_editor' ] ); |
|
147 | 147 | } |
148 | 148 | foreach ( $this->control_types as $key => $classname ) { |
149 | 149 | if ( ! class_exists( $classname ) ) { |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | if ( ! empty( Kirki::$panels ) ) { |
175 | 175 | foreach ( Kirki::$panels as $panel_args ) { |
176 | 176 | // Extra checks for nested panels. |
177 | - if ( isset( $panel_args['panel'] ) ) { |
|
178 | - if ( isset( Kirki::$panels[ $panel_args['panel'] ] ) ) { |
|
177 | + if ( isset( $panel_args[ 'panel' ] ) ) { |
|
178 | + if ( isset( Kirki::$panels[ $panel_args[ 'panel' ] ] ) ) { |
|
179 | 179 | // Set the type to nested. |
180 | - $panel_args['type'] = 'kirki-nested'; |
|
180 | + $panel_args[ 'type' ] = 'kirki-nested'; |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | if ( ! empty( Kirki::$sections ) ) { |
196 | 196 | foreach ( Kirki::$sections as $section_args ) { |
197 | 197 | // Extra checks for nested sections. |
198 | - if ( isset( $section_args['section'] ) ) { |
|
199 | - if ( isset( Kirki::$sections[ $section_args['section'] ] ) ) { |
|
198 | + if ( isset( $section_args[ 'section' ] ) ) { |
|
199 | + if ( isset( Kirki::$sections[ $section_args[ 'section' ] ] ) ) { |
|
200 | 200 | // Set the type to nested. |
201 | - $section_args['type'] = 'kirki-nested'; |
|
201 | + $section_args[ 'type' ] = 'kirki-nested'; |
|
202 | 202 | // We need to check if the parent section is nested inside a panel. |
203 | - $parent_section = Kirki::$sections[ $section_args['section'] ]; |
|
204 | - if ( isset( $parent_section['panel'] ) ) { |
|
205 | - $section_args['panel'] = $parent_section['panel']; |
|
203 | + $parent_section = Kirki::$sections[ $section_args[ 'section' ] ]; |
|
204 | + if ( isset( $parent_section[ 'panel' ] ) ) { |
|
205 | + $section_args[ 'panel' ] = $parent_section[ 'panel' ]; |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | |
39 | 39 | // We're using a flat select. |
40 | 40 | foreach ( $this->choices as $key => $args ) { |
41 | - $this->choices[ $key ] = $args['label']; |
|
41 | + $this->choices[ $key ] = $args[ 'label' ]; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | } |
204 | 204 | |
205 | 205 | // Return regular if the one we want could not be found. |
206 | - if ( isset( $local_urls['regular'] ) ) { |
|
207 | - return $local_urls['regular']; |
|
206 | + if ( isset( $local_urls[ 'regular' ] ) ) { |
|
207 | + return $local_urls[ 'regular' ]; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | // Return the first available if all else failed. |
211 | 211 | $vals = array_values( $local_urls ); |
212 | - return $vals[0]; |
|
212 | + return $vals[ 0 ]; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | public function get_root_path() { |
402 | 402 | // Get the upload directory for this site. |
403 | 403 | $upload_dir = wp_upload_dir(); |
404 | - $path = untrailingslashit( wp_normalize_path( $upload_dir['basedir'] ) ) . '/webfonts'; |
|
404 | + $path = untrailingslashit( wp_normalize_path( $upload_dir[ 'basedir' ] ) ) . '/webfonts'; |
|
405 | 405 | |
406 | 406 | // If the folder doesn't exist, create it. |
407 | 407 | if ( ! file_exists( $path ) ) { |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | $upload_dir = wp_upload_dir(); |
427 | 427 | |
428 | 428 | // The URL. |
429 | - $url = trailingslashit( $upload_dir['baseurl'] ); |
|
429 | + $url = trailingslashit( $upload_dir[ 'baseurl' ] ); |
|
430 | 430 | // Take care of domain mapping. |
431 | 431 | // When using domain mapping we have to make sure that the URL to the file |
432 | 432 | // does not include the original domain but instead the mapped domain. |
@@ -453,7 +453,8 @@ |
||
453 | 453 | $variants = array_keys( $this->files ); |
454 | 454 | } |
455 | 455 | foreach ( $this->files as $variant => $file ) { |
456 | - if ( in_array( $variant, $variants ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict |
|
456 | + if ( in_array( $variant, $variants ) ) { |
|
457 | +// phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict |
|
457 | 458 | $this->download_font_file( $file ); |
458 | 459 | } |
459 | 460 | } |
@@ -36,12 +36,12 @@ |
||
36 | 36 | foreach ( array( 'background-image', 'background-color', 'background-repeat', 'background-position', 'background-size', 'background-attachment' ) as $property ) { |
37 | 37 | |
38 | 38 | // See https://github.com/aristath/kirki/issues/1808. |
39 | - if ( 'background-color' === $property && isset( $value['background-color'] ) && $value['background-color'] && ( ! isset( $value['background-image'] ) || empty( $value['background-image'] ) ) ) { |
|
40 | - $this->styles[ $output['media_query'] ][ $output['element'] ]['background'] = $output['prefix'] . $this->process_property_value( $property, $value[ $property ] ) . $output['suffix']; |
|
39 | + if ( 'background-color' === $property && isset( $value[ 'background-color' ] ) && $value[ 'background-color' ] && ( ! isset( $value[ 'background-image' ] ) || empty( $value[ 'background-image' ] ) ) ) { |
|
40 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ 'background' ] = $output[ 'prefix' ] . $this->process_property_value( $property, $value[ $property ] ) . $output[ 'suffix' ]; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | if ( isset( $value[ $property ] ) && ! empty( $value[ $property ] ) ) { |
44 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $this->process_property_value( $property, $value[ $property ] ) . $output['suffix']; |
|
44 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $property ] = $output[ 'prefix' ] . $this->process_property_value( $property, $value[ $property ] ) . $output[ 'suffix' ]; |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | } |
@@ -243,28 +243,28 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $plugins = get_plugins(); |
46 | 46 | $_plugin = ''; |
47 | 47 | foreach ( $plugins as $plugin => $args ) { |
48 | - if ( ! $is_plugin && isset( $args['Name'] ) && ( 'Kirki' === $args['Name'] || 'Kirki Toolkit' === $args['Name'] ) ) { |
|
48 | + if ( ! $is_plugin && isset( $args[ 'Name' ] ) && ( 'Kirki' === $args[ 'Name' ] || 'Kirki Toolkit' === $args[ 'Name' ] ) ) { |
|
49 | 49 | $is_plugin = true; |
50 | 50 | $_plugin = $plugin; |
51 | 51 | } |
@@ -82,26 +82,26 @@ discard block |
||
82 | 82 | foreach ( Kirki::$fields as $field ) { |
83 | 83 | |
84 | 84 | // Check if we have variables for this field. |
85 | - if ( isset( $field['variables'] ) && $field['variables'] && ! empty( $field['variables'] ) ) { |
|
85 | + if ( isset( $field[ 'variables' ] ) && $field[ 'variables' ] && ! empty( $field[ 'variables' ] ) ) { |
|
86 | 86 | |
87 | 87 | // Loop through the array of variables. |
88 | - foreach ( $field['variables'] as $field_variable ) { |
|
88 | + foreach ( $field[ 'variables' ] as $field_variable ) { |
|
89 | 89 | |
90 | 90 | // Is the variable ['name'] defined? If yes, then we can proceed. |
91 | - if ( isset( $field_variable['name'] ) ) { |
|
91 | + if ( isset( $field_variable[ 'name' ] ) ) { |
|
92 | 92 | |
93 | 93 | // Sanitize the variable name. |
94 | - $variable_name = esc_attr( $field_variable['name'] ); |
|
94 | + $variable_name = esc_attr( $field_variable[ 'name' ] ); |
|
95 | 95 | |
96 | 96 | // Do we have a callback function defined? If not then set $variable_callback to false. |
97 | - $variable_callback = ( isset( $field_variable['callback'] ) && is_callable( $field_variable['callback'] ) ) ? $field_variable['callback'] : false; |
|
97 | + $variable_callback = ( isset( $field_variable[ 'callback' ] ) && is_callable( $field_variable[ 'callback' ] ) ) ? $field_variable[ 'callback' ] : false; |
|
98 | 98 | |
99 | 99 | // If we have a variable_callback defined then get the value of the option |
100 | 100 | // and run it through the callback function. |
101 | 101 | // If no callback is defined (false) then just get the value. |
102 | - $variables[ $variable_name ] = Kirki_Values::get_value( $field['settings'] ); |
|
102 | + $variables[ $variable_name ] = Kirki_Values::get_value( $field[ 'settings' ] ); |
|
103 | 103 | if ( $variable_callback ) { |
104 | - $variables[ $variable_name ] = call_user_func( $field_variable['callback'], Kirki_Values::get_value( $field['settings'] ) ); |
|
104 | + $variables[ $variable_name ] = call_user_func( $field_variable[ 'callback' ], Kirki_Values::get_value( $field[ 'settings' ] ) ); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
@@ -128,31 +128,31 @@ discard block |
||
128 | 128 | if ( |
129 | 129 | self::is_plugin() || |
130 | 130 | false === strpos( $url, 'wordpress.org' ) || ( |
131 | - ! isset( $request['body'] ) || |
|
132 | - ! isset( $request['body']['plugins'] ) || |
|
133 | - ! isset( $request['body']['translations'] ) || |
|
134 | - ! isset( $request['body']['locale'] ) || |
|
135 | - ! isset( $request['body']['all'] ) |
|
131 | + ! isset( $request[ 'body' ] ) || |
|
132 | + ! isset( $request[ 'body' ][ 'plugins' ] ) || |
|
133 | + ! isset( $request[ 'body' ][ 'translations' ] ) || |
|
134 | + ! isset( $request[ 'body' ][ 'locale' ] ) || |
|
135 | + ! isset( $request[ 'body' ][ 'all' ] ) |
|
136 | 136 | ) |
137 | 137 | ) { |
138 | 138 | return $request; |
139 | 139 | } |
140 | 140 | |
141 | - $plugins = json_decode( $request['body']['plugins'], true ); |
|
142 | - if ( ! isset( $plugins['plugins'] ) ) { |
|
141 | + $plugins = json_decode( $request[ 'body' ][ 'plugins' ], true ); |
|
142 | + if ( ! isset( $plugins[ 'plugins' ] ) ) { |
|
143 | 143 | return $request; |
144 | 144 | } |
145 | 145 | $exists = false; |
146 | - foreach ( $plugins['plugins'] as $plugin ) { |
|
147 | - if ( isset( $plugin['Name'] ) && 'Kirki Toolkit' === $plugin['Name'] ) { |
|
146 | + foreach ( $plugins[ 'plugins' ] as $plugin ) { |
|
147 | + if ( isset( $plugin[ 'Name' ] ) && 'Kirki Toolkit' === $plugin[ 'Name' ] ) { |
|
148 | 148 | $exists = true; |
149 | 149 | } |
150 | 150 | } |
151 | 151 | // Inject data. |
152 | 152 | if ( ! $exists && defined( 'KIRKI_PLUGIN_FILE' ) ) { |
153 | - $plugins['plugins']['kirki/kirki.php'] = get_plugin_data( KIRKI_PLUGIN_FILE ); |
|
153 | + $plugins[ 'plugins' ][ 'kirki/kirki.php' ] = get_plugin_data( KIRKI_PLUGIN_FILE ); |
|
154 | 154 | } |
155 | - $request['body']['plugins'] = wp_json_encode( $plugins ); |
|
155 | + $request[ 'body' ][ 'plugins' ] = wp_json_encode( $plugins ); |
|
156 | 156 | return $request; |
157 | 157 | } |
158 | 158 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | // We only need the major version. |
173 | 173 | if ( 'major' === $context ) { |
174 | 174 | $version_parts = explode( '.', $wp_version ); |
175 | - return $version_parts[0]; |
|
175 | + return $version_parts[ 0 ]; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | return $wp_version; |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | // We only need the major version. |
195 | 195 | if ( 'major' === $context ) { |
196 | 196 | $version_parts = explode( '.', $wp_version ); |
197 | - return absint( $version_parts[0] ); |
|
197 | + return absint( $version_parts[ 0 ] ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | // If we got this far, we want the full monty. |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | if ( false !== strpos( $wp_version, '-' ) ) { |
203 | 203 | // We're on a dev version. |
204 | 204 | $version_parts = explode( '-', $wp_version ); |
205 | - return floatval( $version_parts[0] ); |
|
205 | + return floatval( $version_parts[ 0 ] ); |
|
206 | 206 | } |
207 | 207 | return floatval( $wp_version ); |
208 | 208 | } |