@@ -35,7 +35,7 @@ |
||
35 | 35 | |
36 | 36 | foreach ( array( 'background-image', 'background-color', 'background-repeat', 'background-position', 'background-size', 'background-attachment' ) as $property ) { |
37 | 37 | if ( isset( $value[ $property ] ) && ! empty( $value[ $property ] ) ) { |
38 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $this->process_property_value( $property, $value[ $property ] ) . $output['suffix']; |
|
38 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $property ] = $output[ 'prefix' ] . $this->process_property_value( $property, $value[ $property ] ) . $output[ 'suffix' ]; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
@@ -39,18 +39,18 @@ |
||
39 | 39 | |
40 | 40 | foreach ( $value as $key => $sub_value ) { |
41 | 41 | |
42 | - $property = ( empty( $output['property'] ) ) ? $key : $output['property'] . '-' . $key; |
|
43 | - if ( isset( $output['choice'] ) && $output['property'] ) { |
|
44 | - if ( $key === $output['choice'] ) { |
|
45 | - $property = $output['property']; |
|
42 | + $property = ( empty( $output[ 'property' ] ) ) ? $key : $output[ 'property' ] . '-' . $key; |
|
43 | + if ( isset( $output[ 'choice' ] ) && $output[ 'property' ] ) { |
|
44 | + if ( $key === $output[ 'choice' ] ) { |
|
45 | + $property = $output[ 'property' ]; |
|
46 | 46 | } else { |
47 | 47 | continue; |
48 | 48 | } |
49 | 49 | } |
50 | - if ( false !== strpos( $output['property'], '%%' ) ) { |
|
51 | - $property = str_replace( '%%', $key, $output['property'] ); |
|
50 | + if ( false !== strpos( $output[ 'property' ], '%%' ) ) { |
|
51 | + $property = str_replace( '%%', $key, $output[ 'property' ] ); |
|
52 | 52 | } |
53 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $this->process_property_value( $property, $value[ $key ] ) . $output['suffix']; |
|
53 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $property ] = $output[ 'prefix' ] . $this->process_property_value( $property, $value[ $key ] ) . $output[ 'suffix' ]; |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | } |
@@ -26,28 +26,28 @@ |
||
26 | 26 | foreach ( $value as $key => $sub_value ) { |
27 | 27 | |
28 | 28 | // If "element" is not defined, there's no reason to continue. |
29 | - if ( ! isset( $output['element'] ) ) { |
|
29 | + if ( ! isset( $output[ 'element' ] ) ) { |
|
30 | 30 | continue; |
31 | 31 | } |
32 | 32 | |
33 | 33 | // If the "choice" is not the same as the $key in our loop, there's no reason to proceed. |
34 | - if ( isset( $output['choice'] ) && $key !== $output['choice'] ) { |
|
34 | + if ( isset( $output[ 'choice' ] ) && $key !== $output[ 'choice' ] ) { |
|
35 | 35 | continue; |
36 | 36 | } |
37 | 37 | |
38 | 38 | // If "property" is not defined, fallback to the $key. |
39 | - $property = ( ! isset( $output['property'] ) || empty( $output['property'] ) ) ? $key : $output['property']; |
|
39 | + $property = ( ! isset( $output[ 'property' ] ) || empty( $output[ 'property' ] ) ) ? $key : $output[ 'property' ]; |
|
40 | 40 | |
41 | 41 | // If "media_query" is not defined, use "global". |
42 | - if ( ! isset( $output['media_query'] ) || empty( $output['media_query'] ) ) { |
|
43 | - $output['media_query'] = 'global'; |
|
42 | + if ( ! isset( $output[ 'media_query' ] ) || empty( $output[ 'media_query' ] ) ) { |
|
43 | + $output[ 'media_query' ] = 'global'; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // If "suffix" is defined, add it to the value. |
47 | - $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; |
|
47 | + $output[ 'suffix' ] = ( isset( $output[ 'suffix' ] ) ) ? $output[ 'suffix' ] : ''; |
|
48 | 48 | |
49 | 49 | // Create the styles. |
50 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $sub_value . $output['suffix']; |
|
50 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $property ] = $sub_value . $output[ 'suffix' ]; |
|
51 | 51 | |
52 | 52 | } |
53 | 53 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | protected function process_output( $output, $value ) { |
25 | 25 | |
26 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
26 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
27 | 27 | return; |
28 | 28 | } |
29 | 29 | $output = wp_parse_args( $output, array( |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | 'suffix' => '', |
34 | 34 | ) ); |
35 | 35 | if ( is_array( $value ) ) { |
36 | - if ( isset( $output['choice'] ) && $output['choice'] ) { |
|
37 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value[ $output['choice'] ] ) . $output['units'] . $output['suffix']; |
|
36 | + if ( isset( $output[ 'choice' ] ) && $output[ 'choice' ] ) { |
|
37 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value[ $output[ 'choice' ] ] ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
38 | 38 | return; |
39 | 39 | } |
40 | - if ( isset( $value['url'] ) ) { |
|
41 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value['url'] ) . $output['units'] . $output['suffix']; |
|
40 | + if ( isset( $value[ 'url' ] ) ) { |
|
41 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value[ 'url' ] ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | return; |
45 | 45 | } |
46 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; |
|
46 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
47 | 47 | } |
48 | 48 | } |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | */ |
84 | 84 | protected function apply_sanitize_callback( $output, $value ) { |
85 | 85 | |
86 | - if ( isset( $output['sanitize_callback'] ) && null !== $output['sanitize_callback'] ) { |
|
86 | + if ( isset( $output[ 'sanitize_callback' ] ) && null !== $output[ 'sanitize_callback' ] ) { |
|
87 | 87 | |
88 | 88 | // If the sanitize_callback is invalid, return the value. |
89 | - if ( ! is_callable( $output['sanitize_callback'] ) ) { |
|
89 | + if ( ! is_callable( $output[ 'sanitize_callback' ] ) ) { |
|
90 | 90 | return $value; |
91 | 91 | } |
92 | - return call_user_func( $output['sanitize_callback'], $this->value ); |
|
92 | + return call_user_func( $output[ 'sanitize_callback' ], $this->value ); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | return $value; |
@@ -105,22 +105,22 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function apply_value_pattern( $output, $value ) { |
107 | 107 | |
108 | - if ( isset( $output['value_pattern'] ) && ! empty( $output['value_pattern'] ) && is_string( $output['value_pattern'] ) ) { |
|
108 | + if ( isset( $output[ 'value_pattern' ] ) && ! empty( $output[ 'value_pattern' ] ) && is_string( $output[ 'value_pattern' ] ) ) { |
|
109 | 109 | if ( ! is_array( $value ) ) { |
110 | - $value = str_replace( '$', $value, $output['value_pattern'] ); |
|
110 | + $value = str_replace( '$', $value, $output[ 'value_pattern' ] ); |
|
111 | 111 | } |
112 | 112 | if ( is_array( $value ) ) { |
113 | 113 | foreach ( array_keys( $value ) as $value_k ) { |
114 | 114 | if ( ! is_string( $value[ $value_k ] ) ) { |
115 | 115 | continue; |
116 | 116 | } |
117 | - if ( isset( $output['choice'] ) ) { |
|
118 | - if ( $output['choice'] === $value_k ) { |
|
119 | - $value[ $output['choice'] ] = str_replace( '$', $value[ $output['choice'] ], $output['value_pattern'] ); |
|
117 | + if ( isset( $output[ 'choice' ] ) ) { |
|
118 | + if ( $output[ 'choice' ] === $value_k ) { |
|
119 | + $value[ $output[ 'choice' ] ] = str_replace( '$', $value[ $output[ 'choice' ] ], $output[ 'value_pattern' ] ); |
|
120 | 120 | } |
121 | 121 | continue; |
122 | 122 | } |
123 | - $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output['value_pattern'] ); |
|
123 | + $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output[ 'value_pattern' ] ); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | $value = $this->apply_pattern_replace( $output, $value ); |
@@ -136,14 +136,14 @@ discard block |
||
136 | 136 | * @return string|array |
137 | 137 | */ |
138 | 138 | protected function apply_pattern_replace( $output, $value ) { |
139 | - if ( isset( $output['pattern_replace'] ) && is_array( $output['pattern_replace'] ) ) { |
|
139 | + if ( isset( $output[ 'pattern_replace' ] ) && is_array( $output[ 'pattern_replace' ] ) ) { |
|
140 | 140 | $option_type = ( '' !== Kirki::get_config_param( $this->config_id, 'option_type' ) ) ? Kirki::get_config_param( $this->config_id, 'option_type' ) : 'theme_mod'; |
141 | 141 | $option_name = Kirki::get_config_param( $this->config_id, 'option_name' ); |
142 | 142 | $options = array(); |
143 | 143 | if ( $option_name ) { |
144 | 144 | $options = ( 'site_option' === $option_type ) ? get_site_option( $option_name ) : get_option( $option_name ); |
145 | 145 | } |
146 | - foreach ( $output['pattern_replace'] as $search => $replace ) { |
|
146 | + foreach ( $output[ 'pattern_replace' ] as $search => $replace ) { |
|
147 | 147 | $replacement = ''; |
148 | 148 | switch ( $option_type ) { |
149 | 149 | case 'option': |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | } |
205 | 205 | |
206 | 206 | // No need to proceed this if the current value is the same as in the "exclude" value. |
207 | - if ( isset( $output['exclude'] ) && is_array( $output['exclude'] ) ) { |
|
208 | - foreach ( $output['exclude'] as $exclude ) { |
|
207 | + if ( isset( $output[ 'exclude' ] ) && is_array( $output[ 'exclude' ] ) ) { |
|
208 | + foreach ( $output[ 'exclude' ] as $exclude ) { |
|
209 | 209 | if ( is_array( $value ) ) { |
210 | 210 | if ( is_array( $exclude ) ) { |
211 | 211 | $diff1 = array_diff( $value, $exclude ); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | } |
218 | 218 | // If 'choice' is defined check for sub-values too. |
219 | 219 | // Fixes https://github.com/aristath/kirki/issues/1416. |
220 | - if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { |
|
220 | + if ( isset( $output[ 'choice' ] ) && isset( $value[ $output[ 'choice' ] ] ) && $exclude == $value[ $output[ 'choice' ] ] ) { |
|
221 | 221 | $skip = true; |
222 | 222 | } |
223 | 223 | } |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | // Apply any value patterns defined. |
239 | 239 | $value = $this->apply_value_pattern( $output, $value ); |
240 | 240 | |
241 | - if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
|
242 | - $output['element'] = array_unique( $output['element'] ); |
|
243 | - sort( $output['element'] ); |
|
244 | - $output['element'] = implode( ',', $output['element'] ); |
|
241 | + if ( isset( $output[ 'element' ] ) && is_array( $output[ 'element' ] ) ) { |
|
242 | + $output[ 'element' ] = array_unique( $output[ 'element' ] ); |
|
243 | + sort( $output[ 'element' ] ); |
|
244 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | $value = $this->process_value( $value, $output ); |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | * @return null |
260 | 260 | */ |
261 | 261 | protected function process_output( $output, $value ) { |
262 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
262 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
263 | 263 | return; |
264 | 264 | } |
265 | - $output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global'; |
|
266 | - $output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : ''; |
|
267 | - $output['units'] = ( isset( $output['units'] ) ) ? $output['units'] : ''; |
|
268 | - $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; |
|
265 | + $output[ 'media_query' ] = ( isset( $output[ 'media_query' ] ) ) ? $output[ 'media_query' ] : 'global'; |
|
266 | + $output[ 'prefix' ] = ( isset( $output[ 'prefix' ] ) ) ? $output[ 'prefix' ] : ''; |
|
267 | + $output[ 'units' ] = ( isset( $output[ 'units' ] ) ) ? $output[ 'units' ] : ''; |
|
268 | + $output[ 'suffix' ] = ( isset( $output[ 'suffix' ] ) ) ? $output[ 'suffix' ] : ''; |
|
269 | 269 | |
270 | 270 | // Properties that can accept multiple values. |
271 | 271 | // Useful for example for gradients where all browsers use the "background-image" property |
@@ -274,14 +274,14 @@ discard block |
||
274 | 274 | 'background-image', |
275 | 275 | 'background', |
276 | 276 | ); |
277 | - if ( in_array( $output['property'], $accepts_multiple, true ) ) { |
|
278 | - if ( isset( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) && ! is_array( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) ) { |
|
279 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = (array) $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ]; |
|
277 | + if ( in_array( $output[ 'property' ], $accepts_multiple, true ) ) { |
|
278 | + if ( isset( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) && ! is_array( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) ) { |
|
279 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = (array) $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ]; |
|
280 | 280 | } |
281 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ][] = $output['prefix'] . $value . $output['units'] . $output['suffix']; |
|
281 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ][ ] = $output[ 'prefix' ] . $value . $output[ 'units' ] . $output[ 'suffix' ]; |
|
282 | 282 | return; |
283 | 283 | } |
284 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; |
|
284 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | * @return string|array |
320 | 320 | */ |
321 | 321 | protected function process_value( $value, $output ) { |
322 | - if ( isset( $output['property'] ) ) { |
|
323 | - return $this->process_property_value( $output['property'], $value ); |
|
322 | + if ( isset( $output[ 'property' ] ) ) { |
|
323 | + return $this->process_property_value( $output[ 'property' ], $value ); |
|
324 | 324 | } |
325 | 325 | return $value; |
326 | 326 | } |
@@ -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 | } |
@@ -53,15 +53,15 @@ discard block |
||
53 | 53 | $upload_dir = wp_upload_dir(); |
54 | 54 | |
55 | 55 | $paths = array( |
56 | - 'file' => wp_normalize_path( $upload_dir['basedir'] . '/kirki-css/styles.css' ), |
|
57 | - 'folder' => wp_normalize_path( $upload_dir['basedir'] . '/kirki-css' ), |
|
56 | + 'file' => wp_normalize_path( $upload_dir[ 'basedir' ] . '/kirki-css/styles.css' ), |
|
57 | + 'folder' => wp_normalize_path( $upload_dir[ 'basedir' ] . '/kirki-css' ), |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | if ( 'file' === $context ) { |
61 | - return $paths['file']; |
|
61 | + return $paths[ 'file' ]; |
|
62 | 62 | } |
63 | 63 | if ( 'folder' === $context ) { |
64 | - return $paths['folder']; |
|
64 | + return $paths[ 'folder' ]; |
|
65 | 65 | } |
66 | 66 | return $paths; |
67 | 67 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | public function get_url() { |
78 | 78 | |
79 | 79 | $upload_dir = wp_upload_dir(); |
80 | - return esc_url_raw( $upload_dir['baseurl'] . '/kirki-css/styles.css' ); |
|
80 | + return esc_url_raw( $upload_dir[ 'baseurl' ] . '/kirki-css/styles.css' ); |
|
81 | 81 | |
82 | 82 | } |
83 | 83 |
@@ -145,7 +145,7 @@ |
||
145 | 145 | return false; |
146 | 146 | } |
147 | 147 | |
148 | - if ( ! isset( $response['response'] ) || ! is_array( $response['response'] ) || ! isset( $response['response']['code'] ) || 200 !== $response['response']['code'] ) { |
|
148 | + if ( ! isset( $response[ 'response' ] ) || ! is_array( $response[ 'response' ] ) || ! isset( $response[ 'response' ][ 'code' ] ) || 200 !== $response[ 'response' ][ 'code' ] ) { |
|
149 | 149 | return false; |
150 | 150 | } |
151 | 151 |
@@ -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 | } |