@@ -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 ) ) ) { |
|
128 | + if ( ! $wp_customize && ( ! isset( $value[ 'font-family' ] ) || in_array( $value[ 'font-family' ], $this->hosted_fonts ) ) ) { |
|
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 |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | public function custom_css() { |
69 | 69 | |
70 | 70 | $config = apply_filters( 'kirki_config', array() ); |
71 | - if ( ! isset( $config['color_accent'] ) && ! isset( $config['color_back'] ) ) { |
|
71 | + if ( ! isset( $config[ 'color_accent' ] ) && ! isset( $config[ 'color_back' ] ) ) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | - $back = isset( $config['color_back'] ) ? $config['color_back'] : false; |
|
74 | + $back = isset( $config[ 'color_back' ] ) ? $config[ 'color_back' ] : false; |
|
75 | 75 | |
76 | 76 | $text_on_back = ''; |
77 | 77 | $border_on_back = ''; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $hover_on_back = ( 90 < $back_obj->lightness ) ? $back_obj->getNew( 'lightness', $back_obj->lightness - 3 )->toCSS( $back_obj->mode ) : $back_obj->getNew( 'lightness', $back_obj->lightness + 3 )->toCSS( $back_obj->mode ); |
94 | 94 | $arrows_on_back = ( 50 > $back_obj->lightness ) ? $back_obj->getNew( 'lightness', $back_obj->lightness + 30 )->toCSS( $back_obj->mode ) : $back_obj->getNew( 'lightness', $back_obj->lightness - 30 )->toCSS( $back_obj->mode ); |
95 | 95 | } |
96 | - $accent = ( isset( $config['color_accent'] ) ) ? $config['color_accent'] : false; |
|
96 | + $accent = ( isset( $config[ 'color_accent' ] ) ) ? $config[ 'color_accent' ] : false; |
|
97 | 97 | if ( $accent ) { |
98 | 98 | $accent_obj = ariColor::newColor( $accent ); |
99 | 99 | $text_on_accent = ( 60 > $accent_obj->lightness ) ? $accent_obj->getNew( 'lightness', $accent_obj->lightness + 60 )->toCSS( $accent_obj->mode ) : $accent_obj->getNew( 'lightness', $accent_obj->lightness - 60 )->toCSS( $accent_obj->mode ); |
@@ -405,18 +405,18 @@ discard block |
||
405 | 405 | color: #444 !important; |
406 | 406 | } |
407 | 407 | |
408 | - <?php if ( isset( $config['width'] ) ) : ?> |
|
408 | + <?php if ( isset( $config[ 'width' ] ) ) : ?> |
|
409 | 409 | .wp-full-overlay-sidebar { |
410 | - width: <?php echo esc_attr( $config['width'] ); ?>; |
|
410 | + width: <?php echo esc_attr( $config[ 'width' ] ); ?>; |
|
411 | 411 | } |
412 | 412 | .expanded .wp-full-overlay-footer { |
413 | - width: <?php echo esc_attr( $config['width'] ); ?>; |
|
413 | + width: <?php echo esc_attr( $config[ 'width' ] ); ?>; |
|
414 | 414 | } |
415 | 415 | .wp-full-overlay.expanded { |
416 | - margin-left: <?php echo esc_attr( $config['width'] ); ?>; |
|
416 | + margin-left: <?php echo esc_attr( $config[ 'width' ] ); ?>; |
|
417 | 417 | } |
418 | 418 | .wp-full-overlay.collapsed .wp-full-overlay-sidebar { |
419 | - margin-left: -<?php echo esc_attr( $config['width'] ); ?>; |
|
419 | + margin-left: -<?php echo esc_attr( $config[ 'width' ] ); ?>; |
|
420 | 420 | } |
421 | 421 | <?php endif; ?> |
422 | 422 | </style> |
@@ -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. |
@@ -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 ); |