@@ -37,7 +37,7 @@ |
||
37 | 37 | public function to_json() { |
38 | 38 | parent::to_json(); |
39 | 39 | |
40 | - $this->json['choices'] = wp_parse_args( $this->json['choices'], array( |
|
40 | + $this->json[ 'choices' ] = wp_parse_args( $this->json[ 'choices' ], array( |
|
41 | 41 | 'min' => '0', |
42 | 42 | 'max' => '100', |
43 | 43 | 'step' => '1', |
@@ -38,11 +38,11 @@ |
||
38 | 38 | parent::to_json(); |
39 | 39 | |
40 | 40 | // If no palette has been defined, use Material Design Palette. |
41 | - if ( ! isset( $this->json['choices']['colors'] ) || empty( $this->json['choices']['colors'] ) ) { |
|
42 | - $this->json['choices']['colors'] = Kirki_Helper::get_material_design_colors( 'primary' ); |
|
41 | + if ( ! isset( $this->json[ 'choices' ][ 'colors' ] ) || empty( $this->json[ 'choices' ][ 'colors' ] ) ) { |
|
42 | + $this->json[ 'choices' ][ 'colors' ] = Kirki_Helper::get_material_design_colors( 'primary' ); |
|
43 | 43 | } |
44 | - if ( ! isset( $this->json['choices']['size'] ) || empty( $this->json['choices']['size'] ) ) { |
|
45 | - $this->json['choices']['size'] = 20; |
|
44 | + if ( ! isset( $this->json[ 'choices' ][ 'size' ] ) || empty( $this->json[ 'choices' ][ 'size' ] ) ) { |
|
45 | + $this->json[ 'choices' ][ 'size' ] = 20; |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 |
@@ -24,8 +24,8 @@ |
||
24 | 24 | if ( ! is_array( $this->choices ) ) { |
25 | 25 | $this->choices = array(); |
26 | 26 | } |
27 | - $this->choices['element'] = 'input'; |
|
28 | - $this->choices['type'] = 'text'; |
|
27 | + $this->choices[ 'element' ] = 'input'; |
|
28 | + $this->choices[ 'type' ] = 'text'; |
|
29 | 29 | |
30 | 30 | } |
31 | 31 |
@@ -86,7 +86,7 @@ |
||
86 | 86 | $weights[ $key ] = str_replace( array( 'regular', 'bold', 'italic' ), array( '400', '', 'i' ), $value ); |
87 | 87 | } |
88 | 88 | } |
89 | - $fonts_to_load[] = $font . ':' . join( ',', $weights ); |
|
89 | + $fonts_to_load[ ] = $font . ':' . join( ',', $weights ); |
|
90 | 90 | } |
91 | 91 | wp_enqueue_script( 'webfont-loader', 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js', array(), KIRKI_VERSION ); |
92 | 92 | if ( empty( $fonts_to_load ) ) { |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | // Set a default class name. |
67 | 67 | $class_name = 'WP_Customize_Control'; |
68 | 68 | // Get the classname from the array of control classnames. |
69 | - if ( array_key_exists( $args['type'], self::$control_types ) ) { |
|
70 | - $class_name = self::$control_types[ $args['type'] ]; |
|
69 | + if ( array_key_exists( $args[ 'type' ], self::$control_types ) ) { |
|
70 | + $class_name = self::$control_types[ $args[ 'type' ] ]; |
|
71 | 71 | } |
72 | 72 | return $class_name; |
73 | 73 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | // Get the name of the class we're going to use. |
85 | 85 | $class_name = $this->get_control_class_name( $args ); |
86 | 86 | // Add the control. |
87 | - $this->wp_customize->add_control( new $class_name( $this->wp_customize, $args['settings'], $args ) ); |
|
87 | + $this->wp_customize->add_control( new $class_name( $this->wp_customize, $args[ 'settings' ], $args ) ); |
|
88 | 88 | |
89 | 89 | } |
90 | 90 |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | * @access protected |
60 | 60 | */ |
61 | 61 | protected function set_choices() { |
62 | - if ( ! isset( $this->choices['language'] ) ) { |
|
62 | + if ( ! isset( $this->choices[ 'language' ] ) ) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
66 | - switch ( $this->choices['language'] ) { |
|
66 | + switch ( $this->choices[ 'language' ] ) { |
|
67 | 67 | case 'css': |
68 | 68 | case 'html': |
69 | 69 | case 'htmlmixed': |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | case 'markdown': |
74 | 74 | case 'md': |
75 | 75 | case 'xml': |
76 | - if ( 'md' === $this->choices['language'] ) { |
|
77 | - $this->choices['language'] = 'markdown'; |
|
78 | - } elseif ( 'htm' === $this->choices['language'] || 'htmlmixed' === $this->choices['language'] ) { |
|
79 | - $this->choices['language'] = 'html'; |
|
76 | + if ( 'md' === $this->choices[ 'language' ] ) { |
|
77 | + $this->choices[ 'language' ] = 'markdown'; |
|
78 | + } elseif ( 'htm' === $this->choices[ 'language' ] || 'htmlmixed' === $this->choices[ 'language' ] ) { |
|
79 | + $this->choices[ 'language' ] = 'html'; |
|
80 | 80 | } |
81 | - $this->code_type = 'text/' . $this->choices['language']; |
|
82 | - if ( 'html' === $this->choices['language'] ) { |
|
83 | - $this->choices['language'] = 'htmlmixed'; |
|
81 | + $this->code_type = 'text/' . $this->choices[ 'language' ]; |
|
82 | + if ( 'html' === $this->choices[ 'language' ] ) { |
|
83 | + $this->choices[ 'language' ] = 'htmlmixed'; |
|
84 | 84 | } |
85 | 85 | break; |
86 | 86 | case 'http': |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | case 'php5': |
94 | 94 | case 'php7': |
95 | 95 | case 'phps': |
96 | - if ( 'js' === $this->choices['language'] ) { |
|
97 | - $this->choices['language'] = 'javascript'; |
|
98 | - } elseif ( in_array( $this->choices['language'], array( 'phtml', 'php3', 'php4', 'php5', 'php7', 'phps' ), true ) ) { |
|
99 | - $this->choices['language'] = 'php'; |
|
96 | + if ( 'js' === $this->choices[ 'language' ] ) { |
|
97 | + $this->choices[ 'language' ] = 'javascript'; |
|
98 | + } elseif ( in_array( $this->choices[ 'language' ], array( 'phtml', 'php3', 'php4', 'php5', 'php7', 'phps' ), true ) ) { |
|
99 | + $this->choices[ 'language' ] = 'php'; |
|
100 | 100 | } |
101 | - $this->code_type = 'application/' . $this->choices['language']; |
|
101 | + $this->code_type = 'application/' . $this->choices[ 'language' ]; |
|
102 | 102 | break; |
103 | 103 | case 'svg': |
104 | 104 | $this->code_type = 'image/svg-xml'; |
@@ -107,14 +107,14 @@ discard block |
||
107 | 107 | $this->code_type = 'text/plain'; |
108 | 108 | break; |
109 | 109 | default: |
110 | - $this->code_type = 'text/x-' . $this->choices['language']; |
|
110 | + $this->code_type = 'text/x-' . $this->choices[ 'language' ]; |
|
111 | 111 | break; |
112 | 112 | } |
113 | - if ( ! isset( $this->editor_settings['codemirror'] ) ) { |
|
114 | - $this->editor_settings['codemirror'] = array(); |
|
113 | + if ( ! isset( $this->editor_settings[ 'codemirror' ] ) ) { |
|
114 | + $this->editor_settings[ 'codemirror' ] = array(); |
|
115 | 115 | } |
116 | - if ( ! isset( $this->editor_settings['codemirror']['mode'] ) ) { |
|
117 | - $this->editor_settings['codemirror']['mode'] = $this->choices['language']; |
|
116 | + if ( ! isset( $this->editor_settings[ 'codemirror' ][ 'mode' ] ) ) { |
|
117 | + $this->editor_settings[ 'codemirror' ][ 'mode' ] = $this->choices[ 'language' ]; |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 |
@@ -97,15 +97,15 @@ discard block |
||
97 | 97 | unset( $value[ $row_id ][ $subfield_id ] ); |
98 | 98 | } |
99 | 99 | // Get the subfield-type. |
100 | - if ( ! isset( $this->fields[ $subfield_id ]['type'] ) ) { |
|
100 | + if ( ! isset( $this->fields[ $subfield_id ][ 'type' ] ) ) { |
|
101 | 101 | continue; |
102 | 102 | } |
103 | - $subfield_type = $this->fields[ $subfield_id ]['type']; |
|
103 | + $subfield_type = $this->fields[ $subfield_id ][ 'type' ]; |
|
104 | 104 | |
105 | 105 | // Allow using a sanitize-callback on a per-field basis. |
106 | - if ( isset( $this->fields[ $subfield_id ]['sanitize_callback'] ) ) { |
|
106 | + if ( isset( $this->fields[ $subfield_id ][ 'sanitize_callback' ] ) ) { |
|
107 | 107 | |
108 | - $subfield_value = call_user_func( $this->fields[ $subfield_id ]['sanitize_callback'], $subfield_value ); |
|
108 | + $subfield_value = call_user_func( $this->fields[ $subfield_id ][ 'sanitize_callback' ], $subfield_value ); |
|
109 | 109 | |
110 | 110 | } else { |
111 | 111 | |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | $subfield_value = (bool) $subfield_value; |
143 | 143 | break; |
144 | 144 | case 'select': |
145 | - if ( isset( $this->fields[ $subfield_id ]['multiple'] ) ) { |
|
146 | - if ( true === $this->fields[ $subfield_id ]['multiple'] ) { |
|
145 | + if ( isset( $this->fields[ $subfield_id ][ 'multiple' ] ) ) { |
|
146 | + if ( true === $this->fields[ $subfield_id ][ 'multiple' ] ) { |
|
147 | 147 | $multiple = 2; |
148 | 148 | } |
149 | - $multiple = (int) $this->fields[ $subfield_id ]['multiple']; |
|
149 | + $multiple = (int) $this->fields[ $subfield_id ][ 'multiple' ]; |
|
150 | 150 | if ( 1 < $multiple ) { |
151 | 151 | $subfield_value = (array) $subfield_value; |
152 | 152 | foreach ( $subfield_value as $sub_subfield_key => $sub_subfield_value ) { |
@@ -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 | } |
@@ -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, |