@@ -217,7 +217,8 @@ |
||
217 | 217 | } |
218 | 218 | // If 'choice' is defined check for sub-values too. |
219 | 219 | // Fixes https://github.com/aristath/kirki/issues/1416. |
220 | - if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
220 | + if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { |
|
221 | +// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
221 | 222 | $skip = true; |
222 | 223 | } |
223 | 224 | } |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | */ |
84 | 84 | protected function apply_sanitize_callback( $output, $value ) { |
85 | 85 | |
86 | - if ( isset( $output['sanitize_callback'] ) && null !== $output['sanitize_callback'] ) { |
|
86 | + if ( isset( $output[ 'sanitize_callback' ] ) && null !== $output[ 'sanitize_callback' ] ) { |
|
87 | 87 | |
88 | 88 | // If the sanitize_callback is invalid, return the value. |
89 | - if ( ! is_callable( $output['sanitize_callback'] ) ) { |
|
89 | + if ( ! is_callable( $output[ 'sanitize_callback' ] ) ) { |
|
90 | 90 | return $value; |
91 | 91 | } |
92 | - return call_user_func( $output['sanitize_callback'], $this->value ); |
|
92 | + return call_user_func( $output[ 'sanitize_callback' ], $this->value ); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | return $value; |
@@ -105,22 +105,22 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function apply_value_pattern( $output, $value ) { |
107 | 107 | |
108 | - if ( isset( $output['value_pattern'] ) && ! empty( $output['value_pattern'] ) && is_string( $output['value_pattern'] ) ) { |
|
108 | + if ( isset( $output[ 'value_pattern' ] ) && ! empty( $output[ 'value_pattern' ] ) && is_string( $output[ 'value_pattern' ] ) ) { |
|
109 | 109 | if ( ! is_array( $value ) ) { |
110 | - $value = str_replace( '$', $value, $output['value_pattern'] ); |
|
110 | + $value = str_replace( '$', $value, $output[ 'value_pattern' ] ); |
|
111 | 111 | } |
112 | 112 | if ( is_array( $value ) ) { |
113 | 113 | foreach ( array_keys( $value ) as $value_k ) { |
114 | 114 | if ( ! is_string( $value[ $value_k ] ) ) { |
115 | 115 | continue; |
116 | 116 | } |
117 | - if ( isset( $output['choice'] ) ) { |
|
118 | - if ( $output['choice'] === $value_k ) { |
|
119 | - $value[ $output['choice'] ] = str_replace( '$', $value[ $output['choice'] ], $output['value_pattern'] ); |
|
117 | + if ( isset( $output[ 'choice' ] ) ) { |
|
118 | + if ( $output[ 'choice' ] === $value_k ) { |
|
119 | + $value[ $output[ 'choice' ] ] = str_replace( '$', $value[ $output[ 'choice' ] ], $output[ 'value_pattern' ] ); |
|
120 | 120 | } |
121 | 121 | continue; |
122 | 122 | } |
123 | - $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output['value_pattern'] ); |
|
123 | + $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output[ 'value_pattern' ] ); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | $value = $this->apply_pattern_replace( $output, $value ); |
@@ -136,14 +136,14 @@ discard block |
||
136 | 136 | * @return string|array |
137 | 137 | */ |
138 | 138 | protected function apply_pattern_replace( $output, $value ) { |
139 | - if ( isset( $output['pattern_replace'] ) && is_array( $output['pattern_replace'] ) ) { |
|
139 | + if ( isset( $output[ 'pattern_replace' ] ) && is_array( $output[ 'pattern_replace' ] ) ) { |
|
140 | 140 | $option_type = ( '' !== Kirki::get_config_param( $this->config_id, 'option_type' ) ) ? Kirki::get_config_param( $this->config_id, 'option_type' ) : 'theme_mod'; |
141 | 141 | $option_name = Kirki::get_config_param( $this->config_id, 'option_name' ); |
142 | 142 | $options = array(); |
143 | 143 | if ( $option_name ) { |
144 | 144 | $options = ( 'site_option' === $option_type ) ? get_site_option( $option_name ) : get_option( $option_name ); |
145 | 145 | } |
146 | - foreach ( $output['pattern_replace'] as $search => $replace ) { |
|
146 | + foreach ( $output[ 'pattern_replace' ] as $search => $replace ) { |
|
147 | 147 | $replacement = ''; |
148 | 148 | switch ( $option_type ) { |
149 | 149 | case 'option': |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | } |
204 | 204 | |
205 | 205 | // No need to proceed this if the current value is the same as in the "exclude" value. |
206 | - if ( isset( $output['exclude'] ) && is_array( $output['exclude'] ) ) { |
|
207 | - foreach ( $output['exclude'] as $exclude ) { |
|
206 | + if ( isset( $output[ 'exclude' ] ) && is_array( $output[ 'exclude' ] ) ) { |
|
207 | + foreach ( $output[ 'exclude' ] as $exclude ) { |
|
208 | 208 | if ( is_array( $value ) ) { |
209 | 209 | if ( is_array( $exclude ) ) { |
210 | 210 | $diff1 = array_diff( $value, $exclude ); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | // If 'choice' is defined check for sub-values too. |
218 | 218 | // Fixes https://github.com/aristath/kirki/issues/1416. |
219 | - if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
219 | + if ( isset( $output[ 'choice' ] ) && isset( $value[ $output[ 'choice' ] ] ) && $exclude == $value[ $output[ 'choice' ] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
220 | 220 | $skip = true; |
221 | 221 | } |
222 | 222 | } |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | // Apply any value patterns defined. |
238 | 238 | $value = $this->apply_value_pattern( $output, $value ); |
239 | 239 | |
240 | - if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
|
241 | - $output['element'] = array_unique( $output['element'] ); |
|
242 | - sort( $output['element'] ); |
|
243 | - $output['element'] = implode( ',', $output['element'] ); |
|
240 | + if ( isset( $output[ 'element' ] ) && is_array( $output[ 'element' ] ) ) { |
|
241 | + $output[ 'element' ] = array_unique( $output[ 'element' ] ); |
|
242 | + sort( $output[ 'element' ] ); |
|
243 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | $value = $this->process_value( $value, $output ); |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | * @return null |
259 | 259 | */ |
260 | 260 | protected function process_output( $output, $value ) { |
261 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
261 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
262 | 262 | return; |
263 | 263 | } |
264 | - $output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global'; |
|
265 | - $output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : ''; |
|
266 | - $output['units'] = ( isset( $output['units'] ) ) ? $output['units'] : ''; |
|
267 | - $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; |
|
264 | + $output[ 'media_query' ] = ( isset( $output[ 'media_query' ] ) ) ? $output[ 'media_query' ] : 'global'; |
|
265 | + $output[ 'prefix' ] = ( isset( $output[ 'prefix' ] ) ) ? $output[ 'prefix' ] : ''; |
|
266 | + $output[ 'units' ] = ( isset( $output[ 'units' ] ) ) ? $output[ 'units' ] : ''; |
|
267 | + $output[ 'suffix' ] = ( isset( $output[ 'suffix' ] ) ) ? $output[ 'suffix' ] : ''; |
|
268 | 268 | |
269 | 269 | // Properties that can accept multiple values. |
270 | 270 | // Useful for example for gradients where all browsers use the "background-image" property |
@@ -273,15 +273,15 @@ discard block |
||
273 | 273 | 'background-image', |
274 | 274 | 'background', |
275 | 275 | ); |
276 | - if ( in_array( $output['property'], $accepts_multiple, true ) ) { |
|
277 | - if ( isset( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) && ! is_array( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) ) { |
|
278 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = (array) $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ]; |
|
276 | + if ( in_array( $output[ 'property' ], $accepts_multiple, true ) ) { |
|
277 | + if ( isset( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) && ! is_array( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) ) { |
|
278 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = (array) $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ]; |
|
279 | 279 | } |
280 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ][] = $output['prefix'] . $value . $output['units'] . $output['suffix']; |
|
280 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ][ ] = $output[ 'prefix' ] . $value . $output[ 'units' ] . $output[ 'suffix' ]; |
|
281 | 281 | return; |
282 | 282 | } |
283 | 283 | if ( is_string( $value ) || is_numeric( $value ) ) { |
284 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; |
|
284 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
@@ -320,8 +320,8 @@ discard block |
||
320 | 320 | * @return string|array |
321 | 321 | */ |
322 | 322 | protected function process_value( $value, $output ) { |
323 | - if ( isset( $output['property'] ) ) { |
|
324 | - return $this->process_property_value( $output['property'], $value ); |
|
323 | + if ( isset( $output[ 'property' ] ) ) { |
|
324 | + return $this->process_property_value( $output[ 'property' ], $value ); |
|
325 | 325 | } |
326 | 326 | return $value; |
327 | 327 | } |
@@ -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 | } |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | echo '<style id="kirki-css-vars">'; |
77 | 77 | echo ':root{'; |
78 | 78 | foreach ( $fields as $id => $args ) { |
79 | - if ( ! isset( $args['css_vars'] ) || empty( $args['css_vars'] ) ) { |
|
79 | + if ( ! isset( $args[ 'css_vars' ] ) || empty( $args[ 'css_vars' ] ) ) { |
|
80 | 80 | continue; |
81 | 81 | } |
82 | - $val = Kirki_Values::get_value( $args['kirki_config'], $id ); |
|
83 | - foreach ( $args['css_vars'] as $css_var ) { |
|
84 | - if ( isset( $css_var[2] ) && is_array( $val ) && isset( $val[ $css_var[2] ] ) ) { |
|
85 | - echo esc_attr( $css_var[0] ) . ':' . esc_attr( str_replace( '$', $val[ $css_var[2] ], $css_var[1] ) ) . ';'; |
|
82 | + $val = Kirki_Values::get_value( $args[ 'kirki_config' ], $id ); |
|
83 | + foreach ( $args[ 'css_vars' ] as $css_var ) { |
|
84 | + if ( isset( $css_var[ 2 ] ) && is_array( $val ) && isset( $val[ $css_var[ 2 ] ] ) ) { |
|
85 | + echo esc_attr( $css_var[ 0 ] ) . ':' . esc_attr( str_replace( '$', $val[ $css_var[ 2 ] ], $css_var[ 1 ] ) ) . ';'; |
|
86 | 86 | } else { |
87 | - echo esc_attr( $css_var[0] ) . ':' . esc_attr( str_replace( '$', $val, $css_var[1] ) ) . ';'; |
|
87 | + echo esc_attr( $css_var[ 0 ] ) . ':' . esc_attr( str_replace( '$', $val, $css_var[ 1 ] ) ) . ';'; |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | } |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | $fields = Kirki::$fields; |
107 | 107 | $data = array(); |
108 | 108 | foreach ( $fields as $field ) { |
109 | - if ( isset( $field['transport'] ) && 'postMessage' === $field['transport'] && isset( $field['css_vars'] ) && ! empty( $field['css_vars'] ) ) { |
|
110 | - $data[] = $field; |
|
109 | + if ( isset( $field[ 'transport' ] ) && 'postMessage' === $field[ 'transport' ] && isset( $field[ 'css_vars' ] ) && ! empty( $field[ 'css_vars' ] ) ) { |
|
110 | + $data[ ] = $field; |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | wp_localize_script( 'kirki_auto_css_vars', 'kirkiCssVarFields', $data ); |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | protected function set_default() { |
50 | 50 | |
51 | 51 | // Accomodate the use of font-weight and convert to variant. |
52 | - if ( isset( $this->default['font-weight'] ) ) { |
|
53 | - $this->default['variant'] = ( 'regular' === $this->default['font-weight'] ) ? 400 : (string) intval( $this->default['font-weight'] ); |
|
52 | + if ( isset( $this->default[ 'font-weight' ] ) ) { |
|
53 | + $this->default[ 'variant' ] = ( 'regular' === $this->default[ 'font-weight' ] ) ? 400 : (string) intval( $this->default[ 'font-weight' ] ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | // Make sure letter-spacing has units. |
57 | - if ( isset( $this->default['letter-spacing'] ) && is_numeric( $this->default['letter-spacing'] ) && $this->default['letter-spacing'] ) { |
|
58 | - $this->default['letter-spacing'] .= 'px'; |
|
57 | + if ( isset( $this->default[ 'letter-spacing' ] ) && is_numeric( $this->default[ 'letter-spacing' ] ) && $this->default[ 'letter-spacing' ] ) { |
|
58 | + $this->default[ 'letter-spacing' ] .= 'px'; |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | foreach ( $this->output as $output ) { |
107 | 107 | |
108 | 108 | // If 'element' or 'property' are not defined, skip this. |
109 | - if ( ! isset( $output['element'] ) ) { |
|
109 | + if ( ! isset( $output[ 'element' ] ) ) { |
|
110 | 110 | continue; |
111 | 111 | } |
112 | - if ( is_array( $output['element'] ) ) { |
|
113 | - $output['element'] = implode( ',', $output['element'] ); |
|
112 | + if ( is_array( $output[ 'element' ] ) ) { |
|
113 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // If we got this far, it's safe to add this. |
117 | - $js_vars[] = $output; |
|
117 | + $js_vars[ ] = $output; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | // Did we manage to get all the items from 'output'? |
@@ -146,26 +146,26 @@ discard block |
||
146 | 146 | foreach ( $value as $key => $val ) { |
147 | 147 | switch ( $key ) { |
148 | 148 | case 'font-family': |
149 | - $value['font-family'] = esc_attr( $val ); |
|
149 | + $value[ 'font-family' ] = esc_attr( $val ); |
|
150 | 150 | break; |
151 | 151 | case 'font-weight': |
152 | - if ( isset( $value['variant'] ) ) { |
|
152 | + if ( isset( $value[ 'variant' ] ) ) { |
|
153 | 153 | break; |
154 | 154 | } |
155 | - $value['variant'] = $val; |
|
156 | - if ( isset( $value['font-style'] ) && 'italic' === $value['font-style'] ) { |
|
157 | - $value['variant'] = ( '400' !== $val || 400 !== $val ) ? $value['variant'] . 'italic' : 'italic'; |
|
155 | + $value[ 'variant' ] = $val; |
|
156 | + if ( isset( $value[ 'font-style' ] ) && 'italic' === $value[ 'font-style' ] ) { |
|
157 | + $value[ 'variant' ] = ( '400' !== $val || 400 !== $val ) ? $value[ 'variant' ] . 'italic' : 'italic'; |
|
158 | 158 | } |
159 | 159 | break; |
160 | 160 | case 'variant': |
161 | 161 | // Use 'regular' instead of 400 for font-variant. |
162 | - $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; |
|
162 | + $value[ 'variant' ] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; |
|
163 | 163 | // Get font-weight from variant. |
164 | - $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
165 | - $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? 400 : absint( $value['font-weight'] ); |
|
164 | + $value[ 'font-weight' ] = filter_var( $value[ 'variant' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
165 | + $value[ 'font-weight' ] = ( 'regular' === $value[ 'variant' ] || 'italic' === $value[ 'variant' ] ) ? 400 : absint( $value[ 'font-weight' ] ); |
|
166 | 166 | // Get font-style from variant. |
167 | - if ( ! isset( $value['font-style'] ) ) { |
|
168 | - $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; |
|
167 | + if ( ! isset( $value[ 'font-style' ] ) ) { |
|
168 | + $value[ 'font-style' ] = ( false === strpos( $value[ 'variant' ], 'italic' ) ) ? 'normal' : 'italic'; |
|
169 | 169 | } |
170 | 170 | break; |
171 | 171 | case 'font-size': |
@@ -176,21 +176,21 @@ discard block |
||
176 | 176 | break; |
177 | 177 | case 'text-align': |
178 | 178 | if ( ! in_array( $val, array( '', 'inherit', 'left', 'center', 'right', 'justify' ), true ) ) { |
179 | - $value['text-align'] = ''; |
|
179 | + $value[ 'text-align' ] = ''; |
|
180 | 180 | } |
181 | 181 | break; |
182 | 182 | case 'text-transform': |
183 | 183 | if ( ! in_array( $val, array( '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ), true ) ) { |
184 | - $value['text-transform'] = ''; |
|
184 | + $value[ 'text-transform' ] = ''; |
|
185 | 185 | } |
186 | 186 | break; |
187 | 187 | case 'text-decoration': |
188 | 188 | if ( ! in_array( $val, array( '', 'none', 'underline', 'overline', 'line-through', 'initial', 'inherit' ), true ) ) { |
189 | - $value['text-transform'] = ''; |
|
189 | + $value[ 'text-transform' ] = ''; |
|
190 | 190 | } |
191 | 191 | break; |
192 | 192 | case 'color': |
193 | - $value['color'] = '' === $value['color'] ? '' : ariColor::newColor( $val )->toCSS( 'hex' ); |
|
193 | + $value[ 'color' ] = '' === $value[ 'color' ] ? '' : ariColor::newColor( $val )->toCSS( 'hex' ); |
|
194 | 194 | break; |
195 | 195 | } |
196 | 196 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $config = apply_filters( 'kirki_config', array() ); |
78 | 78 | |
79 | 79 | // If we have set $config['disable_google_fonts'] to true then do not proceed any further. |
80 | - if ( isset( $config['disable_google_fonts'] ) && true === $config['disable_google_fonts'] ) { |
|
80 | + if ( isset( $config[ 'disable_google_fonts' ] ) && true === $config[ 'disable_google_fonts' ] ) { |
|
81 | 81 | return; |
82 | 82 | } |
83 | 83 | |
@@ -115,57 +115,57 @@ discard block |
||
115 | 115 | global $wp_customize; |
116 | 116 | |
117 | 117 | // Process typography fields. |
118 | - if ( isset( $args['type'] ) && 'kirki-typography' === $args['type'] ) { |
|
118 | + if ( isset( $args[ 'type' ] ) && 'kirki-typography' === $args[ 'type' ] ) { |
|
119 | 119 | |
120 | 120 | // Get the value. |
121 | 121 | $value = Kirki_Values::get_sanitized_field_value( $args ); |
122 | 122 | |
123 | - if ( isset( $value['downloadFont'] ) && $value['downloadFont'] ) { |
|
124 | - $this->hosted_fonts[] = $value['font-family']; |
|
123 | + if ( isset( $value[ 'downloadFont' ] ) && $value[ 'downloadFont' ] ) { |
|
124 | + $this->hosted_fonts[ ] = $value[ 'font-family' ]; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | // If we don't have a font-family then we can skip this. |
128 | - if ( ! $wp_customize && ( ! isset( $value['font-family'] ) || in_array( $value['font-family'], $this->hosted_fonts, true ) ) ) { |
|
128 | + if ( ! $wp_customize && ( ! isset( $value[ 'font-family' ] ) || in_array( $value[ 'font-family' ], $this->hosted_fonts, true ) ) ) { |
|
129 | 129 | return; |
130 | 130 | } |
131 | 131 | |
132 | 132 | // If not a google-font, then we can skip this. |
133 | - if ( ! isset( $value['font-family'] ) || ! Kirki_Fonts::is_google_font( $value['font-family'] ) ) { |
|
133 | + if ( ! isset( $value[ 'font-family' ] ) || ! Kirki_Fonts::is_google_font( $value[ 'font-family' ] ) ) { |
|
134 | 134 | return; |
135 | 135 | } |
136 | 136 | |
137 | 137 | // Set a default value for variants. |
138 | - if ( ! isset( $value['variant'] ) ) { |
|
139 | - $value['variant'] = 'regular'; |
|
138 | + if ( ! isset( $value[ 'variant' ] ) ) { |
|
139 | + $value[ 'variant' ] = 'regular'; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | // Add the requested google-font. |
143 | - if ( ! isset( $this->fonts[ $value['font-family'] ] ) ) { |
|
144 | - $this->fonts[ $value['font-family'] ] = array(); |
|
143 | + if ( ! isset( $this->fonts[ $value[ 'font-family' ] ] ) ) { |
|
144 | + $this->fonts[ $value[ 'font-family' ] ] = array(); |
|
145 | 145 | } |
146 | - if ( ! in_array( $value['variant'], $this->fonts[ $value['font-family'] ], true ) ) { |
|
147 | - $this->fonts[ $value['font-family'] ][] = $value['variant']; |
|
146 | + if ( ! in_array( $value[ 'variant' ], $this->fonts[ $value[ 'font-family' ] ], true ) ) { |
|
147 | + $this->fonts[ $value[ 'font-family' ] ][ ] = $value[ 'variant' ]; |
|
148 | 148 | } |
149 | 149 | // Are we force-loading all variants? |
150 | 150 | if ( true === self::$force_load_all_variants ) { |
151 | 151 | $all_variants = Kirki_Fonts::get_all_variants(); |
152 | - $args['choices']['variant'] = array_keys( $all_variants ); |
|
152 | + $args[ 'choices' ][ 'variant' ] = array_keys( $all_variants ); |
|
153 | 153 | } |
154 | 154 | |
155 | - if ( ! empty( $args['choices']['variant'] ) && is_array( $args['choices']['variant'] ) ) { |
|
156 | - foreach ( $args['choices']['variant'] as $extra_variant ) { |
|
157 | - $this->fonts[ $value['font-family'] ][] = $extra_variant; |
|
155 | + if ( ! empty( $args[ 'choices' ][ 'variant' ] ) && is_array( $args[ 'choices' ][ 'variant' ] ) ) { |
|
156 | + foreach ( $args[ 'choices' ][ 'variant' ] as $extra_variant ) { |
|
157 | + $this->fonts[ $value[ 'font-family' ] ][ ] = $extra_variant; |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Process non-typography fields. |
164 | - if ( isset( $args['output'] ) && is_array( $args['output'] ) ) { |
|
165 | - foreach ( $args['output'] as $output ) { |
|
164 | + if ( isset( $args[ 'output' ] ) && is_array( $args[ 'output' ] ) ) { |
|
165 | + foreach ( $args[ 'output' ] as $output ) { |
|
166 | 166 | |
167 | 167 | // If we don't have a typography-related output argument we can skip this. |
168 | - if ( ! isset( $output['property'] ) || ! in_array( $output['property'], array( 'font-family', 'font-weight' ), true ) ) { |
|
168 | + if ( ! isset( $output[ 'property' ] ) || ! in_array( $output[ 'property' ], array( 'font-family', 'font-weight' ), true ) ) { |
|
169 | 169 | continue; |
170 | 170 | } |
171 | 171 | |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | $value = Kirki_Values::get_sanitized_field_value( $args ); |
174 | 174 | |
175 | 175 | if ( is_string( $value ) ) { |
176 | - if ( 'font-family' === $output['property'] ) { |
|
176 | + if ( 'font-family' === $output[ 'property' ] ) { |
|
177 | 177 | if ( ! array_key_exists( $value, $this->fonts ) ) { |
178 | 178 | $this->fonts[ $value ] = array(); |
179 | 179 | } |
180 | - } elseif ( 'font-weight' === $output['property'] ) { |
|
180 | + } elseif ( 'font-weight' === $output[ 'property' ] ) { |
|
181 | 181 | foreach ( $this->fonts as $font => $variants ) { |
182 | 182 | if ( ! in_array( $value, $variants, true ) ) { |
183 | - $this->fonts[ $font ][] = $value; |
|
183 | + $this->fonts[ $font ][ ] = $value; |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | } |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | |
213 | 213 | // Get all valid font variants for this font. |
214 | 214 | $font_variants = array(); |
215 | - if ( isset( $this->google_fonts[ $font ]['variants'] ) ) { |
|
216 | - $font_variants = $this->google_fonts[ $font ]['variants']; |
|
215 | + if ( isset( $this->google_fonts[ $font ][ 'variants' ] ) ) { |
|
216 | + $font_variants = $this->google_fonts[ $font ][ 'variants' ]; |
|
217 | 217 | } |
218 | 218 | foreach ( $variants as $variant ) { |
219 | 219 |
@@ -76,13 +76,13 @@ |
||
76 | 76 | |
77 | 77 | $fields = Kirki::$fields; |
78 | 78 | foreach ( $fields as $field ) { |
79 | - if ( isset( $field['tooltip'] ) && ! empty( $field['tooltip'] ) ) { |
|
79 | + if ( isset( $field[ 'tooltip' ] ) && ! empty( $field[ 'tooltip' ] ) ) { |
|
80 | 80 | // Get the control ID and properly format it for the tooltips. |
81 | - $id = str_replace( '[', '-', str_replace( ']', '', $field['settings'] ) ); |
|
81 | + $id = str_replace( '[', '-', str_replace( ']', '', $field[ 'settings' ] ) ); |
|
82 | 82 | // Add the tooltips content. |
83 | 83 | $this->tooltips_content[ $id ] = array( |
84 | 84 | 'id' => $id, |
85 | - 'content' => wp_kses_post( $field['tooltip'] ), |
|
85 | + 'content' => wp_kses_post( $field[ 'tooltip' ] ), |
|
86 | 86 | ); |
87 | 87 | } |
88 | 88 | } |