@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $config_ids = Kirki_Config::get_config_ids(); |
54 | 54 | global $kirki_deprecated_filters_iteration; |
55 | 55 | foreach ( $config_ids as $config_id ) { |
56 | - foreach( array( |
|
56 | + foreach ( array( |
|
57 | 57 | '/dynamic_css', |
58 | 58 | '/output/control-classnames', |
59 | 59 | '/css/skip_hidden', |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | $kirki_deprecated_filters_iteration = array( $config_id, $filter_suffix ); |
65 | 65 | add_filter( "kirki_{$config_id}_{$filter_suffix}", function( $args ) { |
66 | 66 | global $kirki_deprecated_filters_iteration; |
67 | - $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] ); |
|
68 | - return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[0]}/{$kirki_deprecated_filters_iteration[1]}", $args ); |
|
67 | + $kirki_deprecated_filters_iteration[ 1 ] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[ 1 ] ); |
|
68 | + return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[ 0 ]}/{$kirki_deprecated_filters_iteration[ 1 ]}", $args ); |
|
69 | 69 | }, 99 ); |
70 | - if ( false !== strpos( $kirki_deprecated_filters_iteration[1], '-' ) ) { |
|
71 | - $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] ); |
|
70 | + if ( false !== strpos( $kirki_deprecated_filters_iteration[ 1 ], '-' ) ) { |
|
71 | + $kirki_deprecated_filters_iteration[ 1 ] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[ 1 ] ); |
|
72 | 72 | add_filter( "kirki_{$config_id}_{$filter_suffix}", function( $args ) { |
73 | 73 | global $kirki_deprecated_filters_iteration; |
74 | - $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] ); |
|
75 | - return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[0]}/{$kirki_deprecated_filters_iteration[1]}", $args ); |
|
74 | + $kirki_deprecated_filters_iteration[ 1 ] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[ 1 ] ); |
|
75 | + return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[ 0 ]}/{$kirki_deprecated_filters_iteration[ 1 ]}", $args ); |
|
76 | 76 | }, 99 ); |
77 | 77 | } |
78 | 78 | } |
@@ -59,10 +59,10 @@ 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 | - $language = $this->choices['language']; |
|
65 | + $language = $this->choices[ 'language' ]; |
|
66 | 66 | switch ( $language ) { |
67 | 67 | case 'json': |
68 | 68 | case 'xml': |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | $language = 'text/x-' . $language; |
91 | 91 | break; |
92 | 92 | } |
93 | - if ( ! isset( $this->editor_settings['codemirror'] ) ) { |
|
94 | - $this->editor_settings['codemirror'] = array(); |
|
93 | + if ( ! isset( $this->editor_settings[ 'codemirror' ] ) ) { |
|
94 | + $this->editor_settings[ 'codemirror' ] = array(); |
|
95 | 95 | } |
96 | - if ( ! isset( $this->editor_settings['codemirror']['mode'] ) ) { |
|
97 | - $this->editor_settings['codemirror']['mode'] = $language; |
|
96 | + if ( ! isset( $this->editor_settings[ 'codemirror' ][ 'mode' ] ) ) { |
|
97 | + $this->editor_settings[ 'codemirror' ][ 'mode' ] = $language; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | if ( ! is_array( $this->choices ) ) { |
61 | 61 | $this->choices = (array) $this->choices; |
62 | 62 | } |
63 | - if ( ! isset( $this->choices['save_as'] ) ) { |
|
64 | - $this->choices['save_as'] = 'url'; |
|
63 | + if ( ! isset( $this->choices[ 'save_as' ] ) ) { |
|
64 | + $this->choices[ 'save_as' ] = 'url'; |
|
65 | 65 | } |
66 | - if ( ! isset( $this->choices['labels'] ) ) { |
|
67 | - $this->choices['labels'] = array(); |
|
66 | + if ( ! isset( $this->choices[ 'labels' ] ) ) { |
|
67 | + $this->choices[ 'labels' ] = array(); |
|
68 | 68 | } |
69 | 69 | $this->set_button_labels(); |
70 | - $this->choices['labels'] = wp_parse_args( $this->choices['labels'], $this->button_labels ); |
|
70 | + $this->choices[ 'labels' ] = wp_parse_args( $this->choices[ 'labels' ], $this->button_labels ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function sanitize( $value ) { |
95 | 95 | |
96 | - if ( isset( $this->choices['save_as'] ) && 'array' === $this->choices['save_as'] ) { |
|
96 | + if ( isset( $this->choices[ 'save_as' ] ) && 'array' === $this->choices[ 'save_as' ] ) { |
|
97 | 97 | return array( |
98 | - 'id' => ( isset( $value['id'] ) && '' !== $value['id'] ) ? (int) $value['id'] : '', |
|
99 | - 'url' => ( isset( $value['url'] ) && '' !== $value['url'] ) ? esc_url_raw( $value['url'] ) : '', |
|
100 | - 'width' => ( isset( $value['width'] ) && '' !== $value['width'] ) ? (int) $value['width'] : '', |
|
101 | - 'height' => ( isset( $value['height'] ) && '' !== $value['height'] ) ? (int) $value['height'] : '', |
|
98 | + 'id' => ( isset( $value[ 'id' ] ) && '' !== $value[ 'id' ] ) ? (int) $value[ 'id' ] : '', |
|
99 | + 'url' => ( isset( $value[ 'url' ] ) && '' !== $value[ 'url' ] ) ? esc_url_raw( $value[ 'url' ] ) : '', |
|
100 | + 'width' => ( isset( $value[ 'width' ] ) && '' !== $value[ 'width' ] ) ? (int) $value[ 'width' ] : '', |
|
101 | + 'height' => ( isset( $value[ 'height' ] ) && '' !== $value[ 'height' ] ) ? (int) $value[ 'height' ] : '', |
|
102 | 102 | ); |
103 | 103 | } |
104 | - if ( isset( $this->choices['save_as'] ) && 'id' === $this->choices['save_as'] ) { |
|
104 | + if ( isset( $this->choices[ 'save_as' ] ) && 'id' === $this->choices[ 'save_as' ] ) { |
|
105 | 105 | return absint( $value ); |
106 | 106 | } |
107 | 107 | if ( is_string( $value ) ) { |
@@ -32,6 +32,6 @@ |
||
32 | 32 | */ |
33 | 33 | public function to_json() { |
34 | 34 | parent::to_json(); |
35 | - $this->json['required'] = $this->required; |
|
35 | + $this->json[ 'required' ] = $this->required; |
|
36 | 36 | } |
37 | 37 | } |
@@ -32,6 +32,6 @@ |
||
32 | 32 | */ |
33 | 33 | public function to_json() { |
34 | 34 | parent::to_json(); |
35 | - $this->json['required'] = $this->required; |
|
35 | + $this->json[ 'required' ] = $this->required; |
|
36 | 36 | } |
37 | 37 | } |
@@ -136,37 +136,37 @@ |
||
136 | 136 | // Get the basics from the parent class. |
137 | 137 | parent::to_json(); |
138 | 138 | // Default. |
139 | - $this->json['default'] = $this->setting->default; |
|
139 | + $this->json[ 'default' ] = $this->setting->default; |
|
140 | 140 | if ( isset( $this->default ) ) { |
141 | - $this->json['default'] = $this->default; |
|
141 | + $this->json[ 'default' ] = $this->default; |
|
142 | 142 | } |
143 | 143 | // Required. |
144 | - $this->json['required'] = $this->required; |
|
144 | + $this->json[ 'required' ] = $this->required; |
|
145 | 145 | // Output. |
146 | - $this->json['output'] = $this->output; |
|
146 | + $this->json[ 'output' ] = $this->output; |
|
147 | 147 | // Value. |
148 | - $this->json['value'] = $this->value(); |
|
148 | + $this->json[ 'value' ] = $this->value(); |
|
149 | 149 | // Choices. |
150 | - $this->json['choices'] = $this->choices; |
|
150 | + $this->json[ 'choices' ] = $this->choices; |
|
151 | 151 | // The link. |
152 | - $this->json['link'] = $this->get_link(); |
|
152 | + $this->json[ 'link' ] = $this->get_link(); |
|
153 | 153 | // The ID. |
154 | - $this->json['id'] = $this->id; |
|
154 | + $this->json[ 'id' ] = $this->id; |
|
155 | 155 | // Translation strings. |
156 | - $this->json['l10n'] = $this->l10n(); |
|
156 | + $this->json[ 'l10n' ] = $this->l10n(); |
|
157 | 157 | // The ajaxurl in case we need it. |
158 | - $this->json['ajaxurl'] = admin_url( 'admin-ajax.php' ); |
|
158 | + $this->json[ 'ajaxurl' ] = admin_url( 'admin-ajax.php' ); |
|
159 | 159 | // Input attributes. |
160 | - $this->json['inputAttrs'] = ''; |
|
160 | + $this->json[ 'inputAttrs' ] = ''; |
|
161 | 161 | foreach ( $this->input_attrs as $attr => $value ) { |
162 | - $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
162 | + $this->json[ 'inputAttrs' ] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
163 | 163 | } |
164 | 164 | // The kirki-config. |
165 | - $this->json['kirkiConfig'] = $this->kirki_config; |
|
165 | + $this->json[ 'kirkiConfig' ] = $this->kirki_config; |
|
166 | 166 | // The option-type. |
167 | - $this->json['kirkiOptionType'] = $this->option_type; |
|
167 | + $this->json[ 'kirkiOptionType' ] = $this->option_type; |
|
168 | 168 | // The option-name. |
169 | - $this->json['kirkiOptionName'] = $this->option_name; |
|
169 | + $this->json[ 'kirkiOptionName' ] = $this->option_name; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -35,23 +35,23 @@ discard block |
||
35 | 35 | public function to_json() { |
36 | 36 | parent::to_json(); |
37 | 37 | |
38 | - if ( is_array( $this->json['value'] ) ) { |
|
39 | - foreach ( array_keys( $this->json['value'] ) as $key ) { |
|
40 | - if ( ! in_array( $key, array( 'variant', 'font-weight', 'font-style' ), true ) && ! isset( $this->json['default'][ $key ] ) ) { |
|
41 | - unset( $this->json['value'][ $key ] ); |
|
38 | + if ( is_array( $this->json[ 'value' ] ) ) { |
|
39 | + foreach ( array_keys( $this->json[ 'value' ] ) as $key ) { |
|
40 | + if ( ! in_array( $key, array( 'variant', 'font-weight', 'font-style' ), true ) && ! isset( $this->json[ 'default' ][ $key ] ) ) { |
|
41 | + unset( $this->json[ 'value' ][ $key ] ); |
|
42 | 42 | } |
43 | 43 | // Fix for https://wordpress.org/support/topic/white-font-after-updateing-to-3-0-16. |
44 | - if ( ! isset( $this->json['default'][ $key ] ) ) { |
|
45 | - unset( $this->json['value'][ $key ] ); |
|
44 | + if ( ! isset( $this->json[ 'default' ][ $key ] ) ) { |
|
45 | + unset( $this->json[ 'value' ][ $key ] ); |
|
46 | 46 | } |
47 | 47 | // Fix for https://github.com/aristath/kirki/issues/1405. |
48 | - if ( isset( $this->json['default'][ $key ] ) && false === $this->json['default'][ $key ] ) { |
|
49 | - unset( $this->json['value'][ $key ] ); |
|
48 | + if ( isset( $this->json[ 'default' ][ $key ] ) && false === $this->json[ 'default' ][ $key ] ) { |
|
49 | + unset( $this->json[ 'value' ][ $key ] ); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | - $this->json['show_variants'] = ( true === Kirki_Fonts_Google::$force_load_all_variants ) ? false : true; |
|
54 | + $this->json[ 'show_variants' ] = ( true === Kirki_Fonts_Google::$force_load_all_variants ) ? false : true; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | $final_variants = array(); |
239 | 239 | foreach ( $variants as $variant ) { |
240 | 240 | if ( is_string( $variant ) ) { |
241 | - $final_variants[] = array( |
|
241 | + $final_variants[ ] = array( |
|
242 | 242 | 'id' => $variant, |
243 | 243 | 'label' => isset( $all_variants[ $variant ] ) ? $all_variants[ $variant ] : $variant, |
244 | 244 | ); |
245 | - } elseif ( is_array( $variant ) && isset( $variant['id'] ) && isset( $variant['label'] ) ) { |
|
246 | - $final_variants[] = $variant; |
|
245 | + } elseif ( is_array( $variant ) && isset( $variant[ 'id' ] ) && isset( $variant[ 'label' ] ) ) { |
|
246 | + $final_variants[ ] = $variant; |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | return $final_variants; |
@@ -137,11 +137,11 @@ |
||
137 | 137 | |
138 | 138 | $google_fonts = array(); |
139 | 139 | if ( is_array( $fonts ) ) { |
140 | - foreach ( $fonts['items'] as $font ) { |
|
141 | - $google_fonts[ $font['family'] ] = array( |
|
142 | - 'label' => $font['family'], |
|
143 | - 'variants' => $font['variants'], |
|
144 | - 'category' => $font['category'], |
|
140 | + foreach ( $fonts[ 'items' ] as $font ) { |
|
141 | + $google_fonts[ $font[ 'family' ] ] = array( |
|
142 | + 'label' => $font[ 'family' ], |
|
143 | + 'variants' => $font[ 'variants' ], |
|
144 | + 'category' => $font[ 'category' ], |
|
145 | 145 | ); |
146 | 146 | } |
147 | 147 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $config = apply_filters( 'kirki_config', array() ); |
60 | 60 | |
61 | 61 | // If we have set $config['disable_google_fonts'] to true then do not proceed any further. |
62 | - if ( isset( $config['disable_google_fonts'] ) && true === $config['disable_google_fonts'] ) { |
|
62 | + if ( isset( $config[ 'disable_google_fonts' ] ) && true === $config[ 'disable_google_fonts' ] ) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
@@ -95,53 +95,53 @@ discard block |
||
95 | 95 | public function generate_google_font( $args ) { |
96 | 96 | |
97 | 97 | // Process typography fields. |
98 | - if ( isset( $args['type'] ) && 'kirki-typography' === $args['type'] ) { |
|
98 | + if ( isset( $args[ 'type' ] ) && 'kirki-typography' === $args[ 'type' ] ) { |
|
99 | 99 | |
100 | 100 | // Get the value. |
101 | 101 | $value = Kirki_Values::get_sanitized_field_value( $args ); |
102 | 102 | |
103 | 103 | // If we don't have a font-family then we can skip this. |
104 | - if ( ! isset( $value['font-family'] ) ) { |
|
104 | + if ( ! isset( $value[ 'font-family' ] ) ) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
108 | 108 | // If not a google-font, then we can skip this. |
109 | - if ( ! Kirki_Fonts::is_google_font( $value['font-family'] ) ) { |
|
109 | + if ( ! Kirki_Fonts::is_google_font( $value[ 'font-family' ] ) ) { |
|
110 | 110 | return; |
111 | 111 | } |
112 | 112 | |
113 | 113 | // Set a default value for variants. |
114 | - if ( ! isset( $value['variant'] ) ) { |
|
115 | - $value['variant'] = 'regular'; |
|
114 | + if ( ! isset( $value[ 'variant' ] ) ) { |
|
115 | + $value[ 'variant' ] = 'regular'; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | // Add the requested google-font. |
119 | - if ( ! isset( $this->fonts[ $value['font-family'] ] ) ) { |
|
120 | - $this->fonts[ $value['font-family'] ] = array(); |
|
119 | + if ( ! isset( $this->fonts[ $value[ 'font-family' ] ] ) ) { |
|
120 | + $this->fonts[ $value[ 'font-family' ] ] = array(); |
|
121 | 121 | } |
122 | - if ( ! in_array( $value['variant'], $this->fonts[ $value['font-family'] ], true ) ) { |
|
123 | - $this->fonts[ $value['font-family'] ][] = $value['variant']; |
|
122 | + if ( ! in_array( $value[ 'variant' ], $this->fonts[ $value[ 'font-family' ] ], true ) ) { |
|
123 | + $this->fonts[ $value[ 'font-family' ] ][ ] = $value[ 'variant' ]; |
|
124 | 124 | } |
125 | 125 | // Are we force-loading all variants? |
126 | 126 | if ( true === self::$force_load_all_variants ) { |
127 | 127 | $all_variants = Kirki_Fonts::get_all_variants(); |
128 | - $args['choices']['variant'] = array_keys( $all_variants ); |
|
128 | + $args[ 'choices' ][ 'variant' ] = array_keys( $all_variants ); |
|
129 | 129 | } |
130 | 130 | |
131 | - if ( ! empty( $args['choices']['variant'] ) && is_array( $args['choices']['variant'] ) ) { |
|
132 | - foreach ( $args['choices']['variant'] as $extra_variant ) { |
|
133 | - $this->fonts[ $value['font-family'] ][] = $extra_variant; |
|
131 | + if ( ! empty( $args[ 'choices' ][ 'variant' ] ) && is_array( $args[ 'choices' ][ 'variant' ] ) ) { |
|
132 | + foreach ( $args[ 'choices' ][ 'variant' ] as $extra_variant ) { |
|
133 | + $this->fonts[ $value[ 'font-family' ] ][ ] = $extra_variant; |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | return; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Process non-typography fields. |
140 | - if ( isset( $args['output'] ) && is_array( $args['output'] ) ) { |
|
141 | - foreach ( $args['output'] as $output ) { |
|
140 | + if ( isset( $args[ 'output' ] ) && is_array( $args[ 'output' ] ) ) { |
|
141 | + foreach ( $args[ 'output' ] as $output ) { |
|
142 | 142 | |
143 | 143 | // If we don't have a typography-related output argument we can skip this. |
144 | - if ( ! isset( $output['property'] ) || ! in_array( $output['property'], array( 'font-family', 'font-weight' ), true ) ) { |
|
144 | + if ( ! isset( $output[ 'property' ] ) || ! in_array( $output[ 'property' ], array( 'font-family', 'font-weight' ), true ) ) { |
|
145 | 145 | continue; |
146 | 146 | } |
147 | 147 | |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | $value = Kirki_Values::get_sanitized_field_value( $args ); |
150 | 150 | |
151 | 151 | if ( is_string( $value ) ) { |
152 | - if ( 'font-family' === $output['property'] ) { |
|
152 | + if ( 'font-family' === $output[ 'property' ] ) { |
|
153 | 153 | if ( ! array_key_exists( $value, $this->fonts ) ) { |
154 | 154 | $this->fonts[ $value ] = array(); |
155 | 155 | } |
156 | - } elseif ( 'font-weight' === $output['property'] ) { |
|
156 | + } elseif ( 'font-weight' === $output[ 'property' ] ) { |
|
157 | 157 | foreach ( $this->fonts as $font => $variants ) { |
158 | 158 | if ( ! in_array( $value, $variants, true ) ) { |
159 | - $this->fonts[ $font ][] = $value; |
|
159 | + $this->fonts[ $font ][ ] = $value; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | } |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | |
189 | 189 | // Get all valid font variants for this font. |
190 | 190 | $font_variants = array(); |
191 | - if ( isset( $this->google_fonts[ $font ]['variants'] ) ) { |
|
192 | - $font_variants = $this->google_fonts[ $font ]['variants']; |
|
191 | + if ( isset( $this->google_fonts[ $font ][ 'variants' ] ) ) { |
|
192 | + $font_variants = $this->google_fonts[ $font ][ 'variants' ]; |
|
193 | 193 | } |
194 | 194 | foreach ( $variants as $variant ) { |
195 | 195 |