@@ -53,8 +53,8 @@ |
||
53 | 53 | public function to_json() { |
54 | 54 | parent::to_json(); |
55 | 55 | |
56 | - $this->json['palette'] = $this->palette; |
|
57 | - $this->json['choices']['alpha'] = ( isset( $this->choices['alpha'] ) && $this->choices['alpha'] ) ? 'true' : 'false'; |
|
58 | - $this->json['mode'] = $this->mode; |
|
56 | + $this->json[ 'palette' ] = $this->palette; |
|
57 | + $this->json[ 'choices' ][ 'alpha' ] = ( isset( $this->choices[ 'alpha' ] ) && $this->choices[ 'alpha' ] ) ? 'true' : 'false'; |
|
58 | + $this->json[ 'mode' ] = $this->mode; |
|
59 | 59 | } |
60 | 60 | } |
@@ -76,28 +76,28 @@ discard block |
||
76 | 76 | |
77 | 77 | if ( empty( $this->button_label ) ) { |
78 | 78 | /* translators: %s represents the label of the row. */ |
79 | - $this->button_label = sprintf( esc_attr__( 'Add new %s', 'kirki' ), $this->row_label['value'] ); |
|
79 | + $this->button_label = sprintf( esc_attr__( 'Add new %s', 'kirki' ), $this->row_label[ 'value' ] ); |
|
80 | 80 | } |
81 | 81 | |
82 | - if ( empty( $args['fields'] ) || ! is_array( $args['fields'] ) ) { |
|
83 | - $args['fields'] = array(); |
|
82 | + if ( empty( $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) { |
|
83 | + $args[ 'fields' ] = array(); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // An array to store keys of fields that need to be filtered. |
87 | 87 | $media_fields_to_filter = array(); |
88 | 88 | |
89 | - foreach ( $args['fields'] as $key => $value ) { |
|
90 | - if ( ! isset( $value['default'] ) ) { |
|
91 | - $args['fields'][ $key ]['default'] = ''; |
|
89 | + foreach ( $args[ 'fields' ] as $key => $value ) { |
|
90 | + if ( ! isset( $value[ 'default' ] ) ) { |
|
91 | + $args[ 'fields' ][ $key ][ 'default' ] = ''; |
|
92 | 92 | } |
93 | - if ( ! isset( $value['label'] ) ) { |
|
94 | - $args['fields'][ $key ]['label'] = ''; |
|
93 | + if ( ! isset( $value[ 'label' ] ) ) { |
|
94 | + $args[ 'fields' ][ $key ][ 'label' ] = ''; |
|
95 | 95 | } |
96 | - $args['fields'][ $key ]['id'] = $key; |
|
96 | + $args[ 'fields' ][ $key ][ 'id' ] = $key; |
|
97 | 97 | |
98 | 98 | // We check if the filed is an uploaded media ( image , file, video, etc.. ). |
99 | - if ( isset( $value['type'] ) ) { |
|
100 | - switch ( $value['type'] ) { |
|
99 | + if ( isset( $value[ 'type' ] ) ) { |
|
100 | + switch ( $value[ 'type' ] ) { |
|
101 | 101 | case 'image': |
102 | 102 | case 'cropped_image': |
103 | 103 | case 'upload': |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | ) |
118 | 118 | ); |
119 | 119 | // Hackily add in the data link parameter. |
120 | - $dropdown = str_replace( '<select', '<select data-field="' . esc_attr( $args['fields'][ $key ]['id'] ) . '"' . $this->get_link(), $dropdown ); |
|
121 | - $args['fields'][ $key ]['dropdown'] = $dropdown; |
|
120 | + $dropdown = str_replace( '<select', '<select data-field="' . esc_attr( $args[ 'fields' ][ $key ][ 'id' ] ) . '"' . $this->get_link(), $dropdown ); |
|
121 | + $args[ 'fields' ][ $key ][ 'dropdown' ] = $dropdown; |
|
122 | 122 | break; |
123 | 123 | } |
124 | 124 | } |
125 | 125 | } // End foreach(). |
126 | 126 | |
127 | - $this->fields = $args['fields']; |
|
127 | + $this->fields = $args[ 'fields' ]; |
|
128 | 128 | |
129 | 129 | // Now we are going to filter the fields. |
130 | 130 | // First we create a copy of the value that would be used otherwise. |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | |
185 | 185 | $fields = $this->fields; |
186 | 186 | |
187 | - $this->json['fields'] = $fields; |
|
188 | - $this->json['row_label'] = $this->row_label; |
|
187 | + $this->json[ 'fields' ] = $fields; |
|
188 | + $this->json[ 'row_label' ] = $this->row_label; |
|
189 | 189 | |
190 | 190 | // If filtered_value has been set and is not empty we use it instead of the actual value. |
191 | 191 | if ( is_array( $this->filtered_value ) && ! empty( $this->filtered_value ) ) { |
192 | - $this->json['value'] = $this->filtered_value; |
|
192 | + $this->json[ 'value' ] = $this->filtered_value; |
|
193 | 193 | } |
194 | - $this->json['value'] = apply_filters( "kirki/controls/repeater/value/{$this->id}", $this->json['value'] ); |
|
194 | + $this->json[ 'value' ] = apply_filters( "kirki/controls/repeater/value/{$this->id}", $this->json[ 'value' ] ); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | |
215 | 215 | <ul class="repeater-fields"></ul> |
216 | 216 | |
217 | - <?php if ( isset( $this->choices['limit'] ) ) : ?> |
|
217 | + <?php if ( isset( $this->choices[ 'limit' ] ) ) : ?> |
|
218 | 218 | <?php // @codingStandardsIgnoreLine ?> |
219 | 219 | <?php /* translators: %s represents the number of rows we're limiting the repeater to allow. */ ?> |
220 | - <p class="limit"><?php printf( esc_attr__( 'Limit: %s rows', 'kirki' ), esc_html( $this->choices['limit'] ) ); ?></p> |
|
220 | + <p class="limit"><?php printf( esc_attr__( 'Limit: %s rows', 'kirki' ), esc_html( $this->choices[ 'limit' ] ) ); ?></p> |
|
221 | 221 | <?php endif; ?> |
222 | 222 | <button class="button-secondary repeater-add"><?php echo esc_html( $this->button_label ); ?></button> |
223 | 223 | |
@@ -447,24 +447,24 @@ discard block |
||
447 | 447 | protected function row_label( $args ) { |
448 | 448 | |
449 | 449 | // Validating args for row labels. |
450 | - if ( isset( $args['row_label'] ) && is_array( $args['row_label'] ) && ! empty( $args['row_label'] ) ) { |
|
450 | + if ( isset( $args[ 'row_label' ] ) && is_array( $args[ 'row_label' ] ) && ! empty( $args[ 'row_label' ] ) ) { |
|
451 | 451 | |
452 | 452 | // Validating row label type. |
453 | - if ( isset( $args['row_label']['type'] ) && ( 'text' === $args['row_label']['type'] || 'field' === $args['row_label']['type'] ) ) { |
|
454 | - $this->row_label['type'] = $args['row_label']['type']; |
|
453 | + if ( isset( $args[ 'row_label' ][ 'type' ] ) && ( 'text' === $args[ 'row_label' ][ 'type' ] || 'field' === $args[ 'row_label' ][ 'type' ] ) ) { |
|
454 | + $this->row_label[ 'type' ] = $args[ 'row_label' ][ 'type' ]; |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | // Validating row label type. |
458 | - if ( isset( $args['row_label']['value'] ) && ! empty( $args['row_label']['value'] ) ) { |
|
459 | - $this->row_label['value'] = esc_attr( $args['row_label']['value'] ); |
|
458 | + if ( isset( $args[ 'row_label' ][ 'value' ] ) && ! empty( $args[ 'row_label' ][ 'value' ] ) ) { |
|
459 | + $this->row_label[ 'value' ] = esc_attr( $args[ 'row_label' ][ 'value' ] ); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | // Validating row label field. |
463 | - if ( isset( $args['row_label']['field'] ) && ! empty( $args['row_label']['field'] ) && isset( $args['fields'][ esc_attr( $args['row_label']['field'] ) ] ) ) { |
|
464 | - $this->row_label['field'] = esc_attr( $args['row_label']['field'] ); |
|
463 | + if ( isset( $args[ 'row_label' ][ 'field' ] ) && ! empty( $args[ 'row_label' ][ 'field' ] ) && isset( $args[ 'fields' ][ esc_attr( $args[ 'row_label' ][ 'field' ] ) ] ) ) { |
|
464 | + $this->row_label[ 'field' ] = esc_attr( $args[ 'row_label' ][ 'field' ] ); |
|
465 | 465 | } else { |
466 | 466 | // If from field is not set correctly, making sure standard is set as the type. |
467 | - $this->row_label['type'] = 'text'; |
|
467 | + $this->row_label[ 'type' ] = 'text'; |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | if ( Kirki_Util::get_wp_version() >= 4.9 ) { |
40 | 40 | return; |
41 | 41 | } |
42 | - $custom_fonts_array = ( isset( $this->choices['fonts'] ) && ( isset( $this->choices['fonts']['google'] ) || isset( $this->choices['fonts']['standard'] ) ) && ( ! empty( $this->choices['fonts']['google'] ) || ! empty( $this->choices['fonts']['standard'] ) ) ); |
|
42 | + $custom_fonts_array = ( isset( $this->choices[ 'fonts' ] ) && ( isset( $this->choices[ 'fonts' ][ 'google' ] ) || isset( $this->choices[ 'fonts' ][ 'standard' ] ) ) && ( ! empty( $this->choices[ 'fonts' ][ 'google' ] ) || ! empty( $this->choices[ 'fonts' ][ 'standard' ] ) ) ); |
|
43 | 43 | $localize_script_var = ( $custom_fonts_array ) ? 'kirkiFonts' . $this->id : 'kirkiAllFonts'; |
44 | 44 | wp_localize_script( |
45 | 45 | 'kirki-script', $localize_script_var, array( |
@@ -57,25 +57,25 @@ discard block |
||
57 | 57 | public function to_json() { |
58 | 58 | parent::to_json(); |
59 | 59 | |
60 | - if ( is_array( $this->json['value'] ) ) { |
|
61 | - foreach ( array_keys( $this->json['value'] ) as $key ) { |
|
62 | - if ( ! in_array( $key, array( 'variant', 'font-weight', 'font-style' ), true ) && ! isset( $this->json['default'][ $key ] ) ) { |
|
63 | - unset( $this->json['value'][ $key ] ); |
|
60 | + if ( is_array( $this->json[ 'value' ] ) ) { |
|
61 | + foreach ( array_keys( $this->json[ 'value' ] ) as $key ) { |
|
62 | + if ( ! in_array( $key, array( 'variant', 'font-weight', 'font-style' ), true ) && ! isset( $this->json[ 'default' ][ $key ] ) ) { |
|
63 | + unset( $this->json[ 'value' ][ $key ] ); |
|
64 | 64 | } |
65 | 65 | // Fix for https://wordpress.org/support/topic/white-font-after-updateing-to-3-0-16. |
66 | - if ( ! isset( $this->json['default'][ $key ] ) ) { |
|
67 | - unset( $this->json['value'][ $key ] ); |
|
66 | + if ( ! isset( $this->json[ 'default' ][ $key ] ) ) { |
|
67 | + unset( $this->json[ 'value' ][ $key ] ); |
|
68 | 68 | } |
69 | 69 | // Fix for https://github.com/aristath/kirki/issues/1405. |
70 | - if ( isset( $this->json['default'][ $key ] ) && false === $this->json['default'][ $key ] ) { |
|
71 | - unset( $this->json['value'][ $key ] ); |
|
70 | + if ( isset( $this->json[ 'default' ][ $key ] ) && false === $this->json[ 'default' ][ $key ] ) { |
|
71 | + unset( $this->json[ 'value' ][ $key ] ); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - $this->json['show_variants'] = ( true === Kirki_Fonts_Google::$force_load_all_variants ) ? false : true; |
|
77 | - $this->json['show_subsets'] = ( true === Kirki_Fonts_Google::$force_load_all_subsets ) ? false : true; |
|
78 | - $this->json['languages'] = Kirki_Fonts::get_google_font_subsets(); |
|
76 | + $this->json[ 'show_variants' ] = ( true === Kirki_Fonts_Google::$force_load_all_variants ) ? false : true; |
|
77 | + $this->json[ 'show_subsets' ] = ( true === Kirki_Fonts_Google::$force_load_all_subsets ) ? false : true; |
|
78 | + $this->json[ 'languages' ] = Kirki_Fonts::get_google_font_subsets(); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -282,12 +282,12 @@ discard block |
||
282 | 282 | $final_variants = array(); |
283 | 283 | foreach ( $variants as $variant ) { |
284 | 284 | if ( is_string( $variant ) ) { |
285 | - $final_variants[] = array( |
|
285 | + $final_variants[ ] = array( |
|
286 | 286 | 'id' => $variant, |
287 | 287 | 'label' => isset( $all_variants[ $variant ] ) ? $all_variants[ $variant ] : $variant, |
288 | 288 | ); |
289 | - } elseif ( is_array( $variant ) && isset( $variant['id'] ) && isset( $variant['label'] ) ) { |
|
290 | - $final_variants[] = $variant; |
|
289 | + } elseif ( is_array( $variant ) && isset( $variant[ 'id' ] ) && isset( $variant[ 'label' ] ) ) { |
|
290 | + $final_variants[ ] = $variant; |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | return $final_variants; |
@@ -305,8 +305,8 @@ discard block |
||
305 | 305 | $standard_fonts = Kirki_Fonts::get_standard_fonts(); |
306 | 306 | |
307 | 307 | $std_user_keys = array(); |
308 | - if ( isset( $this->choices['fonts'] ) && isset( $this->choices['fonts']['standard'] ) ) { |
|
309 | - $std_user_keys = $this->choices['fonts']['standard']; |
|
308 | + if ( isset( $this->choices[ 'fonts' ] ) && isset( $this->choices[ 'fonts' ][ 'standard' ] ) ) { |
|
309 | + $std_user_keys = $this->choices[ 'fonts' ][ 'standard' ]; |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | $standard_fonts_final = array(); |
@@ -319,15 +319,15 @@ discard block |
||
319 | 319 | ) |
320 | 320 | ); |
321 | 321 | foreach ( $standard_fonts as $key => $font ) { |
322 | - if ( ( ! empty( $std_user_keys ) && ! in_array( $key, $std_user_keys, true ) ) || ! isset( $font['stack'] ) || ! isset( $font['label'] ) ) { |
|
322 | + if ( ( ! empty( $std_user_keys ) && ! in_array( $key, $std_user_keys, true ) ) || ! isset( $font[ 'stack' ] ) || ! isset( $font[ 'label' ] ) ) { |
|
323 | 323 | continue; |
324 | 324 | } |
325 | - $standard_fonts_final[] = array( |
|
326 | - 'family' => $font['stack'], |
|
327 | - 'label' => $font['label'], |
|
325 | + $standard_fonts_final[ ] = array( |
|
326 | + 'family' => $font[ 'stack' ], |
|
327 | + 'label' => $font[ 'label' ], |
|
328 | 328 | 'subsets' => array(), |
329 | 329 | 'is_standard' => true, |
330 | - 'variants' => ( isset( $font['variants'] ) ) ? $this->format_variants_array( $font['variants'] ) : $default_variants, |
|
330 | + 'variants' => ( isset( $font[ 'variants' ] ) ) ? $this->format_variants_array( $font[ 'variants' ] ) : $default_variants, |
|
331 | 331 | ); |
332 | 332 | } |
333 | 333 | return $standard_fonts_final; |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | $all_subsets = Kirki_Fonts::get_google_font_subsets(); |
348 | 348 | |
349 | 349 | $gf_user_keys = array(); |
350 | - if ( isset( $this->choices['fonts'] ) && isset( $this->choices['fonts']['google'] ) ) { |
|
351 | - $gf_user_keys = $this->choices['fonts']['google']; |
|
350 | + if ( isset( $this->choices[ 'fonts' ] ) && isset( $this->choices[ 'fonts' ][ 'google' ] ) ) { |
|
351 | + $gf_user_keys = $this->choices[ 'fonts' ][ 'google' ]; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | $google_fonts_final = array(); |
@@ -357,15 +357,15 @@ discard block |
||
357 | 357 | continue; |
358 | 358 | } |
359 | 359 | |
360 | - $label = ( isset( $args['label'] ) ) ? $args['label'] : $family; |
|
361 | - $variants = ( isset( $args['variants'] ) ) ? $args['variants'] : array( 'regular', '700' ); |
|
362 | - $subsets = ( isset( $args['subsets'] ) ) ? $args['subsets'] : array(); |
|
360 | + $label = ( isset( $args[ 'label' ] ) ) ? $args[ 'label' ] : $family; |
|
361 | + $variants = ( isset( $args[ 'variants' ] ) ) ? $args[ 'variants' ] : array( 'regular', '700' ); |
|
362 | + $subsets = ( isset( $args[ 'subsets' ] ) ) ? $args[ 'subsets' ] : array(); |
|
363 | 363 | |
364 | 364 | $available_variants = array(); |
365 | 365 | if ( is_array( $variants ) ) { |
366 | 366 | foreach ( $variants as $variant ) { |
367 | 367 | if ( array_key_exists( $variant, $all_variants ) ) { |
368 | - $available_variants[] = array( |
|
368 | + $available_variants[ ] = array( |
|
369 | 369 | 'id' => $variant, |
370 | 370 | 'label' => $all_variants[ $variant ], |
371 | 371 | ); |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | if ( is_array( $subsets ) ) { |
378 | 378 | foreach ( $subsets as $subset ) { |
379 | 379 | if ( array_key_exists( $subset, $all_subsets ) ) { |
380 | - $available_subsets[] = array( |
|
380 | + $available_subsets[ ] = array( |
|
381 | 381 | 'id' => $subset, |
382 | 382 | 'label' => $all_subsets[ $subset ], |
383 | 383 | ); |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
388 | - $google_fonts_final[] = array( |
|
388 | + $google_fonts_final[ ] = array( |
|
389 | 389 | 'family' => $family, |
390 | 390 | 'label' => $label, |
391 | 391 | 'variants' => $available_variants, |
@@ -53,7 +53,7 @@ |
||
53 | 53 | public function to_json() { |
54 | 54 | parent::to_json(); |
55 | 55 | |
56 | - $this->json['multiple'] = $this->multiple; |
|
57 | - $this->json['placeholder'] = $this->placeholder; |
|
56 | + $this->json[ 'multiple' ] = $this->multiple; |
|
57 | + $this->json[ 'placeholder' ] = $this->placeholder; |
|
58 | 58 | } |
59 | 59 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $config = apply_filters( 'kirki/config', array() ); |
77 | 77 | |
78 | 78 | // If we have set $config['disable_google_fonts'] to true then do not proceed any further. |
79 | - if ( isset( $config['disable_google_fonts'] ) && true === $config['disable_google_fonts'] ) { |
|
79 | + if ( isset( $config[ 'disable_google_fonts' ] ) && true === $config[ 'disable_google_fonts' ] ) { |
|
80 | 80 | return; |
81 | 81 | } |
82 | 82 | |
@@ -113,64 +113,64 @@ discard block |
||
113 | 113 | public function generate_google_font( $args ) { |
114 | 114 | |
115 | 115 | // Process typography fields. |
116 | - if ( isset( $args['type'] ) && 'kirki-typography' === $args['type'] ) { |
|
116 | + if ( isset( $args[ 'type' ] ) && 'kirki-typography' === $args[ 'type' ] ) { |
|
117 | 117 | |
118 | 118 | // Get the value. |
119 | 119 | $value = Kirki_Values::get_sanitized_field_value( $args ); |
120 | 120 | |
121 | 121 | // If we don't have a font-family then we can skip this. |
122 | - if ( ! isset( $value['font-family'] ) ) { |
|
122 | + if ( ! isset( $value[ 'font-family' ] ) ) { |
|
123 | 123 | return; |
124 | 124 | } |
125 | 125 | |
126 | 126 | // If not a google-font, then we can skip this. |
127 | - if ( ! Kirki_Fonts::is_google_font( $value['font-family'] ) ) { |
|
127 | + if ( ! Kirki_Fonts::is_google_font( $value[ 'font-family' ] ) ) { |
|
128 | 128 | return; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // Set a default value for variants. |
132 | - if ( ! isset( $value['variant'] ) ) { |
|
133 | - $value['variant'] = 'regular'; |
|
132 | + if ( ! isset( $value[ 'variant' ] ) ) { |
|
133 | + $value[ 'variant' ] = 'regular'; |
|
134 | 134 | } |
135 | - if ( isset( $value['subsets'] ) ) { |
|
135 | + if ( isset( $value[ 'subsets' ] ) ) { |
|
136 | 136 | |
137 | 137 | // Add the subset directly to the array of subsets in the Kirki_GoogleFonts_Manager object. |
138 | 138 | // Subsets must be applied to ALL fonts if possible. |
139 | - if ( ! is_array( $value['subsets'] ) ) { |
|
140 | - $this->subsets[] = $value['subsets']; |
|
139 | + if ( ! is_array( $value[ 'subsets' ] ) ) { |
|
140 | + $this->subsets[ ] = $value[ 'subsets' ]; |
|
141 | 141 | } else { |
142 | - foreach ( $value['subsets'] as $subset ) { |
|
143 | - $this->subsets[] = $subset; |
|
142 | + foreach ( $value[ 'subsets' ] as $subset ) { |
|
143 | + $this->subsets[ ] = $subset; |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Add the requested google-font. |
149 | - if ( ! isset( $this->fonts[ $value['font-family'] ] ) ) { |
|
150 | - $this->fonts[ $value['font-family'] ] = array(); |
|
149 | + if ( ! isset( $this->fonts[ $value[ 'font-family' ] ] ) ) { |
|
150 | + $this->fonts[ $value[ 'font-family' ] ] = array(); |
|
151 | 151 | } |
152 | - if ( ! in_array( $value['variant'], $this->fonts[ $value['font-family'] ], true ) ) { |
|
153 | - $this->fonts[ $value['font-family'] ][] = $value['variant']; |
|
152 | + if ( ! in_array( $value[ 'variant' ], $this->fonts[ $value[ 'font-family' ] ], true ) ) { |
|
153 | + $this->fonts[ $value[ 'font-family' ] ][ ] = $value[ 'variant' ]; |
|
154 | 154 | } |
155 | 155 | // Are we force-loading all variants? |
156 | 156 | if ( true === self::$force_load_all_variants ) { |
157 | 157 | $all_variants = Kirki_Fonts::get_all_variants(); |
158 | - $args['choices']['variant'] = array_keys( $all_variants ); |
|
158 | + $args[ 'choices' ][ 'variant' ] = array_keys( $all_variants ); |
|
159 | 159 | } |
160 | 160 | |
161 | - if ( ! empty( $args['choices']['variant'] ) && is_array( $args['choices']['variant'] ) ) { |
|
162 | - foreach ( $args['choices']['variant'] as $extra_variant ) { |
|
163 | - $this->fonts[ $value['font-family'] ][] = $extra_variant; |
|
161 | + if ( ! empty( $args[ 'choices' ][ 'variant' ] ) && is_array( $args[ 'choices' ][ 'variant' ] ) ) { |
|
162 | + foreach ( $args[ 'choices' ][ 'variant' ] as $extra_variant ) { |
|
163 | + $this->fonts[ $value[ 'font-family' ] ][ ] = $extra_variant; |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | } else { |
167 | 167 | |
168 | 168 | // Process non-typography fields. |
169 | - if ( isset( $args['output'] ) && is_array( $args['output'] ) ) { |
|
170 | - foreach ( $args['output'] as $output ) { |
|
169 | + if ( isset( $args[ 'output' ] ) && is_array( $args[ 'output' ] ) ) { |
|
170 | + foreach ( $args[ 'output' ] as $output ) { |
|
171 | 171 | |
172 | 172 | // If we don't have a typography-related output argument we can skip this. |
173 | - if ( ! isset( $output['property'] ) || ! in_array( $output['property'], array( 'font-family', 'font-weight', 'font-subset', 'subset', 'subsets' ), true ) ) { |
|
173 | + if ( ! isset( $output[ 'property' ] ) || ! in_array( $output[ 'property' ], array( 'font-family', 'font-weight', 'font-subset', 'subset', 'subsets' ), true ) ) { |
|
174 | 174 | continue; |
175 | 175 | } |
176 | 176 | |
@@ -178,25 +178,25 @@ discard block |
||
178 | 178 | $value = Kirki_Values::get_sanitized_field_value( $args ); |
179 | 179 | |
180 | 180 | if ( is_string( $value ) ) { |
181 | - if ( 'font-family' === $output['property'] ) { |
|
181 | + if ( 'font-family' === $output[ 'property' ] ) { |
|
182 | 182 | if ( ! array_key_exists( $value, $this->fonts ) ) { |
183 | 183 | $this->fonts[ $value ] = array(); |
184 | 184 | } |
185 | - } elseif ( 'font-weight' === $output['property'] ) { |
|
185 | + } elseif ( 'font-weight' === $output[ 'property' ] ) { |
|
186 | 186 | foreach ( $this->fonts as $font => $variants ) { |
187 | 187 | if ( ! in_array( $value, $variants, true ) ) { |
188 | - $this->fonts[ $font ][] = $value; |
|
188 | + $this->fonts[ $font ][ ] = $value; |
|
189 | 189 | } |
190 | 190 | } |
191 | - } elseif ( 'font-subset' === $output['property'] || 'subset' === $output['property'] || 'subsets' === $output['property'] ) { |
|
191 | + } elseif ( 'font-subset' === $output[ 'property' ] || 'subset' === $output[ 'property' ] || 'subsets' === $output[ 'property' ] ) { |
|
192 | 192 | if ( ! is_array( $value ) ) { |
193 | 193 | if ( ! in_array( $value, $this->subsets, true ) ) { |
194 | - $this->subsets[] = $value; |
|
194 | + $this->subsets[ ] = $value; |
|
195 | 195 | } |
196 | 196 | } else { |
197 | 197 | foreach ( $value as $subset ) { |
198 | 198 | if ( ! in_array( $subset, $this->subsets, true ) ) { |
199 | - $this->subsets[] = $subset; |
|
199 | + $this->subsets[ ] = $subset; |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | } |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | |
232 | 232 | // Get all valid font variants for this font. |
233 | 233 | $font_variants = array(); |
234 | - if ( isset( $this->google_fonts[ $font ]['variants'] ) ) { |
|
235 | - $font_variants = $this->google_fonts[ $font ]['variants']; |
|
234 | + if ( isset( $this->google_fonts[ $font ][ 'variants' ] ) ) { |
|
235 | + $font_variants = $this->google_fonts[ $font ][ 'variants' ]; |
|
236 | 236 | } |
237 | 237 | foreach ( $variants as $variant ) { |
238 | 238 | |
@@ -247,10 +247,10 @@ discard block |
||
247 | 247 | |
248 | 248 | // Check if the selected subsets exist, even in one of the selected fonts. |
249 | 249 | // If they don't, then they have to be removed otherwise the link will fail. |
250 | - if ( isset( $this->google_fonts[ $font ]['subsets'] ) ) { |
|
250 | + if ( isset( $this->google_fonts[ $font ][ 'subsets' ] ) ) { |
|
251 | 251 | foreach ( $this->subsets as $subset ) { |
252 | - if ( in_array( $subset, $this->google_fonts[ $font ]['subsets'], true ) ) { |
|
253 | - $valid_subsets[] = $subset; |
|
252 | + if ( in_array( $subset, $this->google_fonts[ $font ][ 'subsets' ], true ) ) { |
|
253 | + $valid_subsets[ ] = $subset; |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | wp_enqueue_script( 'kirki_auto_postmessage', trailingslashit( Kirki::$url ) . 'modules/postmessage/postmessage.js', array( 'jquery', 'customize-preview' ), KIRKI_VERSION, true ); |
75 | 75 | $fields = Kirki::$fields; |
76 | 76 | foreach ( $fields as $field ) { |
77 | - if ( isset( $field['transport'] ) && 'postMessage' === $field['transport'] && isset( $field['js_vars'] ) && ! empty( $field['js_vars'] ) && is_array( $field['js_vars'] ) && isset( $field['settings'] ) ) { |
|
77 | + if ( isset( $field[ 'transport' ] ) && 'postMessage' === $field[ 'transport' ] && isset( $field[ 'js_vars' ] ) && ! empty( $field[ 'js_vars' ] ) && is_array( $field[ 'js_vars' ] ) && isset( $field[ 'settings' ] ) ) { |
|
78 | 78 | $this->script .= $this->script( $field ); |
79 | 79 | } |
80 | 80 | } |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | */ |
93 | 93 | protected function script( $args ) { |
94 | 94 | |
95 | - $script = 'wp.customize(\'' . $args['settings'] . '\',function(value){value.bind(function(newval){'; |
|
95 | + $script = 'wp.customize(\'' . $args[ 'settings' ] . '\',function(value){value.bind(function(newval){'; |
|
96 | 96 | |
97 | 97 | $add_css = false; |
98 | - foreach ( $args['js_vars'] as $js_var ) { |
|
99 | - if ( ! isset( $js_var['function'] ) || 'html' !== $js_var['function'] ) { |
|
98 | + foreach ( $args[ 'js_vars' ] as $js_var ) { |
|
99 | + if ( ! isset( $js_var[ 'function' ] ) || 'html' !== $js_var[ 'function' ] ) { |
|
100 | 100 | $add_css = true; |
101 | 101 | } |
102 | 102 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | // append unique style tag if not exist |
107 | 107 | // The style ID. |
108 | - $style_id = 'kirki-postmessage-' . str_replace( array( '[', ']' ), '', $args['settings'] ); |
|
108 | + $style_id = 'kirki-postmessage-' . str_replace( array( '[', ']' ), '', $args[ 'settings' ] ); |
|
109 | 109 | $script .= 'if(null===document.getElementById(\'' . $style_id . '\')||\'undefined\'===typeof document.getElementById(\'' . $style_id . '\')){jQuery(\'head\').append(\'<style id="' . $style_id . '"></style>\');}'; |
110 | 110 | } |
111 | 111 | |
@@ -116,46 +116,46 @@ discard block |
||
116 | 116 | 'scripts' => array(), |
117 | 117 | ); |
118 | 118 | // Loop through the js_vars and generate the script. |
119 | - foreach ( $args['js_vars'] as $key => $js_var ) { |
|
119 | + foreach ( $args[ 'js_vars' ] as $key => $js_var ) { |
|
120 | 120 | |
121 | 121 | // Skip styles if "exclude" is defined and value is excluded. |
122 | - if ( isset( $js_var['exclude'] ) ) { |
|
123 | - $js_var['exclude'] = (array) $js_var['exclude']; |
|
122 | + if ( isset( $js_var[ 'exclude' ] ) ) { |
|
123 | + $js_var[ 'exclude' ] = (array) $js_var[ 'exclude' ]; |
|
124 | 124 | $script .= 'exclude=false;'; |
125 | - foreach ( $js_var['exclude'] as $exclussion ) { |
|
125 | + foreach ( $js_var[ 'exclude' ] as $exclussion ) { |
|
126 | 126 | $script .= "if(newval=='{$exclussion}'||(''==='{$exclussion}'&&_.isObject(newval)&&_.isEmpty(newval))){exclude=true;}"; |
127 | 127 | } |
128 | 128 | } |
129 | - if ( isset( $js_var['element'] ) ) { |
|
129 | + if ( isset( $js_var[ 'element' ] ) ) { |
|
130 | 130 | // Array to string. |
131 | - if ( is_array( $js_var['element'] ) ) { |
|
132 | - $js_var['element'] = implode( ',', $js_var['element'] ); |
|
131 | + if ( is_array( $js_var[ 'element' ] ) ) { |
|
132 | + $js_var[ 'element' ] = implode( ',', $js_var[ 'element' ] ); |
|
133 | 133 | } |
134 | 134 | // Replace single quotes with double quotes to avoid issues with the compiled JS. |
135 | - $js_var['element'] = str_replace( '\'', '"', $js_var['element'] ); |
|
135 | + $js_var[ 'element' ] = str_replace( '\'', '"', $js_var[ 'element' ] ); |
|
136 | 136 | } |
137 | - if ( isset( $js_var['function'] ) && 'html' === $js_var['function'] ) { |
|
137 | + if ( isset( $js_var[ 'function' ] ) && 'html' === $js_var[ 'function' ] ) { |
|
138 | 138 | $script .= $this->script_html_var( $js_var ); |
139 | 139 | continue; |
140 | 140 | } |
141 | - $js_var['index_key'] = $key; |
|
141 | + $js_var[ 'index_key' ] = $key; |
|
142 | 142 | $callback = $this->get_callback( $args ); |
143 | 143 | if ( is_callable( $callback ) ) { |
144 | - $field['scripts'][ $key ] = call_user_func_array( $callback, array( $js_var, $args ) ); |
|
144 | + $field[ 'scripts' ][ $key ] = call_user_func_array( $callback, array( $js_var, $args ) ); |
|
145 | 145 | continue; |
146 | 146 | } |
147 | - $field['scripts'][ $key ] = $this->script_var( $js_var ); |
|
147 | + $field[ 'scripts' ][ $key ] = $this->script_var( $js_var ); |
|
148 | 148 | } |
149 | 149 | $combo_extra_script = ''; |
150 | 150 | $combo_css_script = ''; |
151 | - foreach ( $field['scripts'] as $script_array ) { |
|
152 | - $combo_extra_script .= $script_array['script']; |
|
153 | - $combo_css_script .= ( 'css' !== $combo_css_script ) ? $script_array['css'] : ''; |
|
151 | + foreach ( $field[ 'scripts' ] as $script_array ) { |
|
152 | + $combo_extra_script .= $script_array[ 'script' ]; |
|
153 | + $combo_css_script .= ( 'css' !== $combo_css_script ) ? $script_array[ 'css' ] : ''; |
|
154 | 154 | } |
155 | 155 | $text = ( 'css' === $combo_css_script ) ? 'css' : '\'' . $combo_css_script . '\''; |
156 | 156 | |
157 | 157 | $script .= $combo_extra_script . "var cssContent={$text};"; |
158 | - if ( isset( $js_var['exclude'] ) ) { |
|
158 | + if ( isset( $js_var[ 'exclude' ] ) ) { |
|
159 | 159 | $script .= 'if(true===exclude){cssContent="";}'; |
160 | 160 | } |
161 | 161 | if ( $add_css ) { |
@@ -174,18 +174,18 @@ discard block |
||
174 | 174 | */ |
175 | 175 | protected function script_html_var( $args ) { |
176 | 176 | |
177 | - $script = ( isset( $args['choice'] ) ) ? "newval=newval['{$args['choice']}'];" : ''; |
|
177 | + $script = ( isset( $args[ 'choice' ] ) ) ? "newval=newval['{$args[ 'choice' ]}'];" : ''; |
|
178 | 178 | |
179 | 179 | // Apply the value_pattern. |
180 | - if ( isset( $args['value_pattern'] ) && '' !== $args['value_pattern'] ) { |
|
180 | + if ( isset( $args[ 'value_pattern' ] ) && '' !== $args[ 'value_pattern' ] ) { |
|
181 | 181 | $script .= $this->value_pattern_replacements( 'newval', $args ); |
182 | 182 | } |
183 | 183 | |
184 | - if ( isset( $args['attr'] ) ) { |
|
185 | - $script .= "jQuery('{$args['element']}').attr('{$args['attr']}',newval);"; |
|
184 | + if ( isset( $args[ 'attr' ] ) ) { |
|
185 | + $script .= "jQuery('{$args[ 'element' ]}').attr('{$args[ 'attr' ]}',newval);"; |
|
186 | 186 | return $script; |
187 | 187 | } |
188 | - $script .= "jQuery('{$args['element']}').html(newval);"; |
|
188 | + $script .= "jQuery('{$args[ 'element' ]}').html(newval);"; |
|
189 | 189 | return $script; |
190 | 190 | } |
191 | 191 | |
@@ -200,34 +200,34 @@ discard block |
||
200 | 200 | $script = ''; |
201 | 201 | $property_script = ''; |
202 | 202 | |
203 | - $value_key = 'newval' . $args['index_key']; |
|
203 | + $value_key = 'newval' . $args[ 'index_key' ]; |
|
204 | 204 | $property_script .= $value_key . '=newval;'; |
205 | 205 | |
206 | 206 | $args = $this->get_args( $args ); |
207 | 207 | |
208 | 208 | // Apply callback to the value if a callback is defined. |
209 | - if ( ! empty( $args['js_callback'] ) && is_array( $args['js_callback'] ) && isset( $args['js_callback'][0] ) && ! empty( $args['js_callback'][0] ) ) { |
|
210 | - $script .= $value_key . '=' . $args['js_callback'][0] . '(' . $value_key . ',' . $args['js_callback'][1] . ');'; |
|
209 | + if ( ! empty( $args[ 'js_callback' ] ) && is_array( $args[ 'js_callback' ] ) && isset( $args[ 'js_callback' ][ 0 ] ) && ! empty( $args[ 'js_callback' ][ 0 ] ) ) { |
|
210 | + $script .= $value_key . '=' . $args[ 'js_callback' ][ 0 ] . '(' . $value_key . ',' . $args[ 'js_callback' ][ 1 ] . ');'; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | // Apply the value_pattern. |
214 | - if ( '' !== $args['value_pattern'] ) { |
|
214 | + if ( '' !== $args[ 'value_pattern' ] ) { |
|
215 | 215 | $script .= $this->value_pattern_replacements( $value_key, $args ); |
216 | 216 | } |
217 | 217 | |
218 | 218 | // Tweak to add url() for background-images. |
219 | - if ( 'background-image' === $args['property'] && ( ! isset( $args['value_pattern'] ) || false === strpos( $args['value_pattern'], 'gradient' ) ) ) { |
|
219 | + if ( 'background-image' === $args[ 'property' ] && ( ! isset( $args[ 'value_pattern' ] ) || false === strpos( $args[ 'value_pattern' ], 'gradient' ) ) ) { |
|
220 | 220 | $script .= 'if(-1===' . $value_key . '.indexOf(\'url(\')){' . $value_key . '=\'url("\'+' . $value_key . '+\'")\';}'; |
221 | 221 | } |
222 | 222 | |
223 | 223 | // Apply prefix. |
224 | 224 | $value = $value_key; |
225 | - if ( '' !== $args['prefix'] ) { |
|
226 | - $value = "'" . $args['prefix'] . "'+" . $value_key; |
|
225 | + if ( '' !== $args[ 'prefix' ] ) { |
|
226 | + $value = "'" . $args[ 'prefix' ] . "'+" . $value_key; |
|
227 | 227 | } |
228 | - $css = $args['element'] . '{' . $args['property'] . ':\'+' . $value . '+\'' . $args['units'] . $args['suffix'] . ';}'; |
|
229 | - if ( isset( $args['media_query'] ) ) { |
|
230 | - $css = $args['media_query'] . '{' . $css . '}'; |
|
228 | + $css = $args[ 'element' ] . '{' . $args[ 'property' ] . ':\'+' . $value . '+\'' . $args[ 'units' ] . $args[ 'suffix' ] . ';}'; |
|
229 | + if ( isset( $args[ 'media_query' ] ) ) { |
|
230 | + $css = $args[ 'media_query' ] . '{' . $css . '}'; |
|
231 | 231 | } |
232 | 232 | return array( |
233 | 233 | 'script' => $property_script . $script, |
@@ -244,60 +244,60 @@ discard block |
||
244 | 244 | */ |
245 | 245 | protected function script_var_array( $args ) { |
246 | 246 | |
247 | - $script = ( 0 === $args['index_key'] ) ? 'css=\'\';' : ''; |
|
247 | + $script = ( 0 === $args[ 'index_key' ] ) ? 'css=\'\';' : ''; |
|
248 | 248 | $property_script = ''; |
249 | 249 | |
250 | 250 | // Define choice. |
251 | - $choice = ( isset( $args['choice'] ) && '' !== $args['choice'] ) ? $args['choice'] : ''; |
|
251 | + $choice = ( isset( $args[ 'choice' ] ) && '' !== $args[ 'choice' ] ) ? $args[ 'choice' ] : ''; |
|
252 | 252 | |
253 | - $value_key = 'newval' . $args['index_key']; |
|
253 | + $value_key = 'newval' . $args[ 'index_key' ]; |
|
254 | 254 | $property_script .= $value_key . '=newval;'; |
255 | 255 | |
256 | 256 | $args = $this->get_args( $args ); |
257 | 257 | |
258 | 258 | // Apply callback to the value if a callback is defined. |
259 | - if ( ! empty( $args['js_callback'] ) && is_array( $args['js_callback'] ) && isset( $args['js_callback'][0] ) && ! empty( $args['js_callback'][0] ) ) { |
|
260 | - $script .= $value_key . '=' . $args['js_callback'][0] . '(' . $value_key . ',' . $args['js_callback'][1] . ');'; |
|
259 | + if ( ! empty( $args[ 'js_callback' ] ) && is_array( $args[ 'js_callback' ] ) && isset( $args[ 'js_callback' ][ 0 ] ) && ! empty( $args[ 'js_callback' ][ 0 ] ) ) { |
|
260 | + $script .= $value_key . '=' . $args[ 'js_callback' ][ 0 ] . '(' . $value_key . ',' . $args[ 'js_callback' ][ 1 ] . ');'; |
|
261 | 261 | } |
262 | 262 | $script .= '_.each(' . $value_key . ', function(subValue,subKey){'; |
263 | 263 | |
264 | 264 | // Apply the value_pattern. |
265 | - if ( '' !== $args['value_pattern'] ) { |
|
265 | + if ( '' !== $args[ 'value_pattern' ] ) { |
|
266 | 266 | $script .= $this->value_pattern_replacements( 'subValue', $args ); |
267 | 267 | } |
268 | 268 | |
269 | 269 | // Tweak to add url() for background-images. |
270 | 270 | if ( '' === $choice || 'background-image' === $choice ) { |
271 | - $script .= 'if(\'background-image\'===\'' . $args['property'] . '\'||\'background-image\'===subKey){if(-1===subValue.indexOf(\'url(\')){subValue=\'url("\'+subValue+\'")\';}}'; |
|
271 | + $script .= 'if(\'background-image\'===\'' . $args[ 'property' ] . '\'||\'background-image\'===subKey){if(-1===subValue.indexOf(\'url(\')){subValue=\'url("\'+subValue+\'")\';}}'; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | // Apply prefix. |
275 | 275 | $value = $value_key; |
276 | - if ( '' !== $args['prefix'] ) { |
|
277 | - $value = '\'' . $args['prefix'] . '\'+subValue'; |
|
276 | + if ( '' !== $args[ 'prefix' ] ) { |
|
277 | + $value = '\'' . $args[ 'prefix' ] . '\'+subValue'; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | // Mostly used for padding, margin & position properties. |
281 | 281 | $direction_script = 'if(_.contains([\'top\',\'bottom\',\'left\',\'right\'],subKey)){'; |
282 | - $direction_script .= 'css+=\'' . $args['element'] . '{' . $args['property'] . '-\'+subKey+\':\'+subValue+\'' . $args['units'] . $args['suffix'] . ';}\';}'; |
|
282 | + $direction_script .= 'css+=\'' . $args[ 'element' ] . '{' . $args[ 'property' ] . '-\'+subKey+\':\'+subValue+\'' . $args[ 'units' ] . $args[ 'suffix' ] . ';}\';}'; |
|
283 | 283 | // Allows us to apply this just for a specific choice in the array of the values. |
284 | 284 | if ( '' !== $choice ) { |
285 | 285 | $choice_is_direction = ( false !== strpos( $choice, 'top' ) || false !== strpos( $choice, 'bottom' ) || false !== strpos( $choice, 'left' ) || false !== strpos( $choice, 'right' ) ); |
286 | 286 | // The script. |
287 | 287 | $script .= 'if(\'' . $choice . '\'===subKey){'; |
288 | 288 | $script .= ( $choice_is_direction ) ? $direction_script . 'else{' : ''; |
289 | - $script .= 'css+=\'' . $args['element'] . '{' . $args['property'] . ':\'+subValue+\';}\';'; |
|
289 | + $script .= 'css+=\'' . $args[ 'element' ] . '{' . $args[ 'property' ] . ':\'+subValue+\';}\';'; |
|
290 | 290 | $script .= ( $choice_is_direction ) ? '}' : ''; |
291 | 291 | $script .= '}'; |
292 | 292 | } else { |
293 | 293 | |
294 | 294 | // This is where most object-based fields will go. |
295 | - $script .= $direction_script . 'else{css+=\'' . $args['element'] . '{\'+subKey+\':\'+subValue+\'' . $args['units'] . $args['suffix'] . ';}\';}'; |
|
295 | + $script .= $direction_script . 'else{css+=\'' . $args[ 'element' ] . '{\'+subKey+\':\'+subValue+\'' . $args[ 'units' ] . $args[ 'suffix' ] . ';}\';}'; |
|
296 | 296 | } |
297 | 297 | $script .= '});'; |
298 | 298 | |
299 | - if ( isset( $args['media_query'] ) ) { |
|
300 | - $script .= 'css=\'' . $args['media_query'] . '{\'+css+\'}\';'; |
|
299 | + if ( isset( $args[ 'media_query' ] ) ) { |
|
300 | + $script .= 'css=\'' . $args[ 'media_query' ] . '{\'+css+\'}\';'; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | return array( |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $webfont_loader = 'sc=\'a\';jQuery(\'head\').append(sc.replace(\'a\',\'<\')+\'script>if(!_.isUndefined(WebFont)&&fontFamily){WebFont.load({google:{families:["\'+fontFamily.replace( /\"/g, \'"\' )+\':\'+variant+subsetsString+\'"]}});}\'+sc.replace(\'a\',\'<\')+\'/script>\');'; |
327 | 327 | |
328 | 328 | // Add the css. |
329 | - $css_build_array = array( |
|
329 | + $css_build_array = array( |
|
330 | 330 | 'font-family' => 'fontFamily', |
331 | 331 | 'font-size' => 'fontSize', |
332 | 332 | 'line-height' => 'lineHeight', |
@@ -339,41 +339,41 @@ discard block |
||
339 | 339 | 'font-weight' => 'fontWeight', |
340 | 340 | 'font-style' => 'fontStyle', |
341 | 341 | ); |
342 | - $choice_condition = ( isset( $args['choice'] ) && '' !== $args['choice'] && isset( $css_build_array[ $args['choice'] ] ) ); |
|
342 | + $choice_condition = ( isset( $args[ 'choice' ] ) && '' !== $args[ 'choice' ] && isset( $css_build_array[ $args[ 'choice' ] ] ) ); |
|
343 | 343 | $script .= ( ! $choice_condition ) ? $webfont_loader : ''; |
344 | 344 | foreach ( $css_build_array as $property => $var ) { |
345 | - if ( $choice_condition && $property !== $args['choice'] ) { |
|
345 | + if ( $choice_condition && $property !== $args[ 'choice' ] ) { |
|
346 | 346 | continue; |
347 | 347 | } |
348 | 348 | // Fixes https://github.com/aristath/kirki/issues/1436. |
349 | - if ( ! isset( $field['default'] ) || ( |
|
350 | - ( 'font-family' === $property && ! isset( $field['default']['font-family'] ) ) || |
|
351 | - ( 'font-size' === $property && ! isset( $field['default']['font-size'] ) ) || |
|
352 | - ( 'line-height' === $property && ! isset( $field['default']['line-height'] ) ) || |
|
353 | - ( 'letter-spacing' === $property && ! isset( $field['default']['letter-spacing'] ) ) || |
|
354 | - ( 'word-spacing' === $property && ! isset( $field['default']['word-spacing'] ) ) || |
|
355 | - ( 'text-align' === $property && ! isset( $field['default']['text-align'] ) ) || |
|
356 | - ( 'text-transform' === $property && ! isset( $field['default']['text-transform'] ) ) || |
|
357 | - ( 'text-decoration' === $property && ! isset( $field['default']['text-decoration'] ) ) || |
|
358 | - ( 'color' === $property && ! isset( $field['default']['color'] ) ) || |
|
359 | - ( 'font-weight' === $property && ! isset( $field['default']['variant'] ) && ! isset( $field['default']['font-weight'] ) ) || |
|
360 | - ( 'font-style' === $property && ! isset( $field['default']['variant'] ) && ! isset( $field['default']['font-style'] ) ) |
|
349 | + if ( ! isset( $field[ 'default' ] ) || ( |
|
350 | + ( 'font-family' === $property && ! isset( $field[ 'default' ][ 'font-family' ] ) ) || |
|
351 | + ( 'font-size' === $property && ! isset( $field[ 'default' ][ 'font-size' ] ) ) || |
|
352 | + ( 'line-height' === $property && ! isset( $field[ 'default' ][ 'line-height' ] ) ) || |
|
353 | + ( 'letter-spacing' === $property && ! isset( $field[ 'default' ][ 'letter-spacing' ] ) ) || |
|
354 | + ( 'word-spacing' === $property && ! isset( $field[ 'default' ][ 'word-spacing' ] ) ) || |
|
355 | + ( 'text-align' === $property && ! isset( $field[ 'default' ][ 'text-align' ] ) ) || |
|
356 | + ( 'text-transform' === $property && ! isset( $field[ 'default' ][ 'text-transform' ] ) ) || |
|
357 | + ( 'text-decoration' === $property && ! isset( $field[ 'default' ][ 'text-decoration' ] ) ) || |
|
358 | + ( 'color' === $property && ! isset( $field[ 'default' ][ 'color' ] ) ) || |
|
359 | + ( 'font-weight' === $property && ! isset( $field[ 'default' ][ 'variant' ] ) && ! isset( $field[ 'default' ][ 'font-weight' ] ) ) || |
|
360 | + ( 'font-style' === $property && ! isset( $field[ 'default' ][ 'variant' ] ) && ! isset( $field[ 'default' ][ 'font-style' ] ) ) |
|
361 | 361 | ) ) { |
362 | 362 | continue; |
363 | 363 | } |
364 | - $script .= ( $choice_condition && 'font-family' === $args['choice'] ) ? $webfont_loader : ''; |
|
364 | + $script .= ( $choice_condition && 'font-family' === $args[ 'choice' ] ) ? $webfont_loader : ''; |
|
365 | 365 | |
366 | - if ( 'font-family' === $property || ( isset( $args['choice'] ) && 'font-family' === $args['choice'] ) ) { |
|
366 | + if ( 'font-family' === $property || ( isset( $args[ 'choice' ] ) && 'font-family' === $args[ 'choice' ] ) ) { |
|
367 | 367 | $css .= 'fontFamilyCSS=fontFamily;if(0<fontFamily.indexOf(\' \')&&-1===fontFamily.indexOf(\'"\')){fontFamilyCSS=\'"\'+fontFamily+\'"\';}'; |
368 | 368 | $var = 'fontFamilyCSS'; |
369 | 369 | } |
370 | - $var = ( ( empty( $args['prefix'] ) ) ? '' : '\'' . $args['prefix'] . '\'+' ) . $var . ( ( empty( $args['units'] ) ) ? '' : '+\'' . $args['units'] . '\'' ) . ( ( empty( $args['suffix'] ) ) ? '' : '+\'' . $args['suffix'] . '\'' ); |
|
371 | - $css .= 'css+=(\'\'!==' . $var . ')?\'' . $args['element'] . '\'+\'{' . $property . ':\'+' . $var . '+\';}\':\'\';'; |
|
370 | + $var = ( ( empty( $args[ 'prefix' ] ) ) ? '' : '\'' . $args[ 'prefix' ] . '\'+' ) . $var . ( ( empty( $args[ 'units' ] ) ) ? '' : '+\'' . $args[ 'units' ] . '\'' ) . ( ( empty( $args[ 'suffix' ] ) ) ? '' : '+\'' . $args[ 'suffix' ] . '\'' ); |
|
371 | + $css .= 'css+=(\'\'!==' . $var . ')?\'' . $args[ 'element' ] . '\'+\'{' . $property . ':\'+' . $var . '+\';}\':\'\';'; |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | $script .= $css; |
375 | - if ( isset( $args['media_query'] ) ) { |
|
376 | - $script .= 'css=\'' . $args['media_query'] . '{\'+css+\'}\';'; |
|
375 | + if ( isset( $args[ 'media_query' ] ) ) { |
|
376 | + $script .= 'css=\'' . $args[ 'media_query' ] . '{\'+css+\'}\';'; |
|
377 | 377 | } |
378 | 378 | return array( |
379 | 379 | 'script' => $script, |
@@ -391,8 +391,8 @@ discard block |
||
391 | 391 | protected function script_var_image( $args ) { |
392 | 392 | $return = $this->script_var( $args ); |
393 | 393 | return array( |
394 | - 'script' => 'newval=(!_.isUndefined(newval.url))?newval.url:newval;' . $return['script'], |
|
395 | - 'css' => $return['css'], |
|
394 | + 'script' => 'newval=(!_.isUndefined(newval.url))?newval.url:newval;' . $return[ 'script' ], |
|
395 | + 'css' => $return[ 'css' ], |
|
396 | 396 | ); |
397 | 397 | } |
398 | 398 | |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | |
409 | 409 | $script = ''; |
410 | 410 | |
411 | - if ( isset( $args['type'] ) ) { |
|
412 | - switch ( $args['type'] ) { |
|
411 | + if ( isset( $args[ 'type' ] ) ) { |
|
412 | + switch ( $args[ 'type' ] ) { |
|
413 | 413 | case 'kirki-typography': |
414 | 414 | $script .= 'fontFamily=(_.isUndefined(newval[\'font-family\']))?\'\':newval[\'font-family\'];variant=(_.isUndefined(newval.variant))?\'400\':newval.variant;subsets=(_.isUndefined(newval.subsets))?[]:newval.subsets;subsetsString=(_.isObject(newval.subsets))?\':\'+newval.subsets.join(\',\'):\'\';fontSize=(_.isUndefined(newval[\'font-size\']))?\'\':newval[\'font-size\'];lineHeight=(_.isUndefined(newval[\'line-height\']))?\'\':newval[\'line-height\'];letterSpacing=(_.isUndefined(newval[\'letter-spacing\']))?\'\':newval[\'letter-spacing\'];wordSpacing=(_.isUndefined(newval[\'word-spacing\']))?\'\':newval[\'word-spacing\'];textAlign=(_.isUndefined(newval[\'text-align\']))?\'\':newval[\'text-align\'];textTransform=(_.isUndefined(newval[\'text-transform\']))?\'\':newval[\'text-transform\'];textDecoration=(_.isUndefined(newval[\'text-decoration\']))?\'\':newval[\'text-decoration\'];color=(_.isUndefined(newval.color))?\'\':newval.color;fw=(!_.isString(newval.variant))?\'400\':newval.variant.match(/\d/g);fontWeight=(!_.isObject(fw))?400:fw.join(\'\');fontStyle=(-1!==variant.indexOf(\'italic\'))?\'italic\':\'normal\';css=\'\';'; |
415 | 415 | break; |
@@ -442,17 +442,17 @@ discard block |
||
442 | 442 | ); |
443 | 443 | |
444 | 444 | // Element should be a string. |
445 | - if ( is_array( $args['element'] ) ) { |
|
446 | - $args['element'] = implode( ',', $args['element'] ); |
|
445 | + if ( is_array( $args[ 'element' ] ) ) { |
|
446 | + $args[ 'element' ] = implode( ',', $args[ 'element' ] ); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | // Make sure arguments that are passed-on to callbacks are strings. |
450 | - if ( is_array( $args['js_callback'] ) && isset( $args['js_callback'][1] ) && is_array( $args['js_callback'][1] ) ) { |
|
451 | - $args['js_callback'][1] = wp_json_encode( $args['js_callback'][1] ); |
|
450 | + if ( is_array( $args[ 'js_callback' ] ) && isset( $args[ 'js_callback' ][ 1 ] ) && is_array( $args[ 'js_callback' ][ 1 ] ) ) { |
|
451 | + $args[ 'js_callback' ][ 1 ] = wp_json_encode( $args[ 'js_callback' ][ 1 ] ); |
|
452 | 452 | } |
453 | 453 | |
454 | - if ( ! isset( $args['js_callback'][1] ) ) { |
|
455 | - $args['js_callback'][1] = ''; |
|
454 | + if ( ! isset( $args[ 'js_callback' ][ 1 ] ) ) { |
|
455 | + $args[ 'js_callback' ][ 1 ] = ''; |
|
456 | 456 | } |
457 | 457 | return $args; |
458 | 458 | |
@@ -470,15 +470,15 @@ discard block |
||
470 | 470 | private function value_pattern_replacements( $value, $js_vars ) { |
471 | 471 | $script = ''; |
472 | 472 | $alias = $value; |
473 | - if ( ! isset( $js_vars['value_pattern'] ) ) { |
|
473 | + if ( ! isset( $js_vars[ 'value_pattern' ] ) ) { |
|
474 | 474 | return $value; |
475 | 475 | } |
476 | - $value = $js_vars['value_pattern']; |
|
477 | - if ( isset( $js_vars['pattern_replace'] ) ) { |
|
476 | + $value = $js_vars[ 'value_pattern' ]; |
|
477 | + if ( isset( $js_vars[ 'pattern_replace' ] ) ) { |
|
478 | 478 | $script .= 'settings=window.wp.customize.get();'; |
479 | - foreach ( $js_vars['pattern_replace'] as $search => $replace ) { |
|
479 | + foreach ( $js_vars[ 'pattern_replace' ] as $search => $replace ) { |
|
480 | 480 | $replace = '\'+settings["' . $replace . '"]+\''; |
481 | - $value = str_replace( $search, $replace, $js_vars['value_pattern'] ); |
|
481 | + $value = str_replace( $search, $replace, $js_vars[ 'value_pattern' ] ); |
|
482 | 482 | $value = trim( $value, '+' ); |
483 | 483 | } |
484 | 484 | } |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | */ |
499 | 499 | protected function get_callback( $args ) { |
500 | 500 | |
501 | - switch ( $args['type'] ) { |
|
501 | + switch ( $args[ 'type' ] ) { |
|
502 | 502 | case 'kirki-background': |
503 | 503 | case 'kirki-dimensions': |
504 | 504 | case 'kirki-multicolor': |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | */ |
24 | 24 | protected function process_output( $output, $value ) { |
25 | 25 | |
26 | - $output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global'; |
|
27 | - $output['element'] = ( isset( $output['element'] ) ) ? $output['element'] : 'body'; |
|
28 | - $output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : ''; |
|
29 | - $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; |
|
26 | + $output[ 'media_query' ] = ( isset( $output[ 'media_query' ] ) ) ? $output[ 'media_query' ] : 'global'; |
|
27 | + $output[ 'element' ] = ( isset( $output[ 'element' ] ) ) ? $output[ 'element' ] : 'body'; |
|
28 | + $output[ 'prefix' ] = ( isset( $output[ 'prefix' ] ) ) ? $output[ 'prefix' ] : ''; |
|
29 | + $output[ 'suffix' ] = ( isset( $output[ 'suffix' ] ) ) ? $output[ 'suffix' ] : ''; |
|
30 | 30 | |
31 | 31 | $value = Kirki_Field_Typography::sanitize( $value ); |
32 | 32 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | foreach ( $properties as $property ) { |
49 | 49 | |
50 | 50 | // Early exit if the value is not in the defaults. |
51 | - if ( ! isset( $this->field['default'][ $property ] ) ) { |
|
51 | + if ( ! isset( $this->field[ 'default' ][ $property ] ) ) { |
|
52 | 52 | continue; |
53 | 53 | } |
54 | 54 | |
@@ -58,37 +58,37 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | // Early exit if we use "choice" but not for this property. |
61 | - if ( isset( $output['choice'] ) && $output['choice'] !== $property ) { |
|
61 | + if ( isset( $output[ 'choice' ] ) && $output[ 'choice' ] !== $property ) { |
|
62 | 62 | continue; |
63 | 63 | } |
64 | 64 | |
65 | 65 | // Take care of variants. |
66 | - if ( 'variant' === $property && isset( $value['variant'] ) && ! empty( $value['variant'] ) ) { |
|
66 | + if ( 'variant' === $property && isset( $value[ 'variant' ] ) && ! empty( $value[ 'variant' ] ) ) { |
|
67 | 67 | |
68 | 68 | // Get the font_weight. |
69 | - $font_weight = str_replace( 'italic', '', $value['variant'] ); |
|
69 | + $font_weight = str_replace( 'italic', '', $value[ 'variant' ] ); |
|
70 | 70 | $font_weight = ( in_array( $font_weight, array( '', 'regular' ), true ) ) ? '400' : $font_weight; |
71 | 71 | |
72 | 72 | // Is this italic? |
73 | - $is_italic = ( false !== strpos( $value['variant'], 'italic' ) ); |
|
74 | - $this->styles[ $output['media_query'] ][ $output['element'] ]['font-weight'] = $font_weight; |
|
73 | + $is_italic = ( false !== strpos( $value[ 'variant' ], 'italic' ) ); |
|
74 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ 'font-weight' ] = $font_weight; |
|
75 | 75 | if ( $is_italic ) { |
76 | - $this->styles[ $output['media_query'] ][ $output['element'] ]['font-style'] = 'italic'; |
|
76 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ 'font-style' ] = 'italic'; |
|
77 | 77 | } |
78 | 78 | continue; |
79 | 79 | } |
80 | 80 | |
81 | 81 | $property_value = $this->process_property_value( $property, $value[ $property ] ); |
82 | 82 | if ( 'font-family' === $property ) { |
83 | - $value['font-backup'] = ( isset( $value['font-backup'] ) ) ? $value['font-backup'] : ''; |
|
83 | + $value[ 'font-backup' ] = ( isset( $value[ 'font-backup' ] ) ) ? $value[ 'font-backup' ] : ''; |
|
84 | 84 | $property_value = $this->process_property_value( $property, array( |
85 | - $value['font-family'], |
|
86 | - $value['font-backup'], |
|
85 | + $value[ 'font-family' ], |
|
86 | + $value[ 'font-backup' ], |
|
87 | 87 | ) ); |
88 | 88 | } |
89 | - $property = ( isset( $output['choice'] ) && isset( $output['property'] ) ) ? $output['property'] : $property; |
|
90 | - $property_value = ( is_array( $property_value ) && isset( $property_value[0] ) ) ? $property_value[0] : $property_value; |
|
91 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $property_value . $output['suffix']; |
|
89 | + $property = ( isset( $output[ 'choice' ] ) && isset( $output[ 'property' ] ) ) ? $output[ 'property' ] : $property; |
|
90 | + $property_value = ( is_array( $property_value ) && isset( $property_value[ 0 ] ) ) ? $property_value[ 0 ] : $property_value; |
|
91 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $property ] = $output[ 'prefix' ] . $property_value . $output[ 'suffix' ]; |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | public static function css( $field ) { |
147 | 147 | |
148 | 148 | // Set class vars. |
149 | - self::$settings = $field['settings']; |
|
150 | - self::$callback = $field['sanitize_callback']; |
|
151 | - self::$field_type = $field['type']; |
|
152 | - self::$output = $field['output']; |
|
149 | + self::$settings = $field[ 'settings' ]; |
|
150 | + self::$callback = $field[ 'sanitize_callback' ]; |
|
151 | + self::$field_type = $field[ 'type' ]; |
|
152 | + self::$output = $field[ 'output' ]; |
|
153 | 153 | if ( ! is_array( self::$output ) ) { |
154 | 154 | self::$output = array( |
155 | 155 | array( |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | // Find the class that will handle the outpout for this field. |
166 | 166 | $classname = 'Kirki_Output'; |
167 | - $field_output_classes = apply_filters( "kirki/{$field['kirki_config']}/output/control-classnames", array( |
|
167 | + $field_output_classes = apply_filters( "kirki/{$field[ 'kirki_config' ]}/output/control-classnames", array( |
|
168 | 168 | 'kirki-background' => 'Kirki_Output_Field_Background', |
169 | 169 | 'kirki-dimensions' => 'Kirki_Output_Field_Dimensions', |
170 | 170 | 'kirki-image' => 'Kirki_Output_Field_Image', |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | if ( array_key_exists( self::$field_type, $field_output_classes ) ) { |
175 | 175 | $classname = $field_output_classes[ self::$field_type ]; |
176 | 176 | } |
177 | - $obj = new $classname( $field['kirki_config'], self::$output, self::$value, $field ); |
|
177 | + $obj = new $classname( $field[ 'kirki_config' ], self::$output, self::$value, $field ); |
|
178 | 178 | return $obj->get_styles(); |
179 | 179 | |
180 | 180 | } |
@@ -72,8 +72,8 @@ |
||
72 | 72 | $collapsible_fields = array(); |
73 | 73 | $fields = Kirki::$fields; |
74 | 74 | foreach ( $fields as $field ) { |
75 | - if ( isset( $field['collapsible'] ) && true === $field['collapsible'] && isset( $field['settings'] ) && isset( $field['label'] ) ) { |
|
76 | - $collapsible_fields[ $field['settings'] ] = $field['label']; |
|
75 | + if ( isset( $field[ 'collapsible' ] ) && true === $field[ 'collapsible' ] && isset( $field[ 'settings' ] ) && isset( $field[ 'label' ] ) ) { |
|
76 | + $collapsible_fields[ $field[ 'settings' ] ] = $field[ 'label' ]; |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | $collapsible_fields = array_unique( $collapsible_fields ); |