@@ -39,14 +39,14 @@ |
||
39 | 39 | if ( is_array( $this->choices ) ) { |
40 | 40 | foreach ( $this->choices as $choice => $value ) { |
41 | 41 | if ( 'labels' !== $choice && true === $value ) { |
42 | - $this->json['choices'][ $choice ] = true; |
|
42 | + $this->json[ 'choices' ][ $choice ] = true; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
46 | - if ( is_array( $this->json['default'] ) ) { |
|
47 | - foreach ( $this->json['default'] as $key => $value ) { |
|
48 | - if ( isset( $this->json['choices'][ $key ] ) && ! isset( $this->json['value'][ $key ] ) ) { |
|
49 | - $this->json['value'][ $key ] = $value; |
|
46 | + if ( is_array( $this->json[ 'default' ] ) ) { |
|
47 | + foreach ( $this->json[ 'default' ] as $key => $value ) { |
|
48 | + if ( isset( $this->json[ 'choices' ][ $key ] ) && ! isset( $this->json[ 'value' ][ $key ] ) ) { |
|
49 | + $this->json[ 'value' ][ $key ] = $value; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
@@ -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 |
@@ -66,8 +66,8 @@ |
||
66 | 66 | $fields = Kirki::$fields; |
67 | 67 | $data = array(); |
68 | 68 | foreach ( $fields as $field ) { |
69 | - if ( isset( $field['transport'] ) && 'postMessage' === $field['transport'] && isset( $field['js_vars'] ) && ! empty( $field['js_vars'] ) && is_array( $field['js_vars'] ) && isset( $field['settings'] ) ) { |
|
70 | - $data[] = $field; |
|
69 | + if ( isset( $field[ 'transport' ] ) && 'postMessage' === $field[ 'transport' ] && isset( $field[ 'js_vars' ] ) && ! empty( $field[ 'js_vars' ] ) && is_array( $field[ 'js_vars' ] ) && isset( $field[ 'settings' ] ) ) { |
|
70 | + $data[ ] = $field; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | wp_localize_script( 'kirki_auto_postmessage', 'kirkiPostMessageFields', $data ); |
@@ -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 | } |
@@ -217,7 +217,8 @@ |
||
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'] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
220 | + if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { |
|
221 | +// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
221 | 222 | $skip = true; |
222 | 223 | } |
223 | 224 | } |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | * @return string|array |
82 | 82 | */ |
83 | 83 | protected function apply_sanitize_callback( $output, $value ) { |
84 | - if ( isset( $output['sanitize_callback'] ) && null !== $output['sanitize_callback'] ) { |
|
84 | + if ( isset( $output[ 'sanitize_callback' ] ) && null !== $output[ 'sanitize_callback' ] ) { |
|
85 | 85 | |
86 | 86 | // If the sanitize_callback is invalid, return the value. |
87 | - if ( ! is_callable( $output['sanitize_callback'] ) ) { |
|
87 | + if ( ! is_callable( $output[ 'sanitize_callback' ] ) ) { |
|
88 | 88 | return $value; |
89 | 89 | } |
90 | - return call_user_func( $output['sanitize_callback'], $this->value ); |
|
90 | + return call_user_func( $output[ 'sanitize_callback' ], $this->value ); |
|
91 | 91 | } |
92 | 92 | return $value; |
93 | 93 | } |
@@ -100,22 +100,22 @@ discard block |
||
100 | 100 | * @return string|array |
101 | 101 | */ |
102 | 102 | protected function apply_value_pattern( $output, $value ) { |
103 | - if ( isset( $output['value_pattern'] ) && ! empty( $output['value_pattern'] ) && is_string( $output['value_pattern'] ) ) { |
|
103 | + if ( isset( $output[ 'value_pattern' ] ) && ! empty( $output[ 'value_pattern' ] ) && is_string( $output[ 'value_pattern' ] ) ) { |
|
104 | 104 | if ( ! is_array( $value ) ) { |
105 | - $value = str_replace( '$', $value, $output['value_pattern'] ); |
|
105 | + $value = str_replace( '$', $value, $output[ 'value_pattern' ] ); |
|
106 | 106 | } |
107 | 107 | if ( is_array( $value ) ) { |
108 | 108 | foreach ( array_keys( $value ) as $value_k ) { |
109 | 109 | if ( ! is_string( $value[ $value_k ] ) ) { |
110 | 110 | continue; |
111 | 111 | } |
112 | - if ( isset( $output['choice'] ) ) { |
|
113 | - if ( $output['choice'] === $value_k ) { |
|
114 | - $value[ $output['choice'] ] = str_replace( '$', $value[ $output['choice'] ], $output['value_pattern'] ); |
|
112 | + if ( isset( $output[ 'choice' ] ) ) { |
|
113 | + if ( $output[ 'choice' ] === $value_k ) { |
|
114 | + $value[ $output[ 'choice' ] ] = str_replace( '$', $value[ $output[ 'choice' ] ], $output[ 'value_pattern' ] ); |
|
115 | 115 | } |
116 | 116 | continue; |
117 | 117 | } |
118 | - $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output['value_pattern'] ); |
|
118 | + $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output[ 'value_pattern' ] ); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | $value = $this->apply_pattern_replace( $output, $value ); |
@@ -131,14 +131,14 @@ discard block |
||
131 | 131 | * @return string|array |
132 | 132 | */ |
133 | 133 | protected function apply_pattern_replace( $output, $value ) { |
134 | - if ( isset( $output['pattern_replace'] ) && is_array( $output['pattern_replace'] ) ) { |
|
134 | + if ( isset( $output[ 'pattern_replace' ] ) && is_array( $output[ 'pattern_replace' ] ) ) { |
|
135 | 135 | $option_type = ( '' !== Kirki::get_config_param( $this->config_id, 'option_type' ) ) ? Kirki::get_config_param( $this->config_id, 'option_type' ) : 'theme_mod'; |
136 | 136 | $option_name = Kirki::get_config_param( $this->config_id, 'option_name' ); |
137 | 137 | $options = array(); |
138 | 138 | if ( $option_name ) { |
139 | 139 | $options = ( 'site_option' === $option_type ) ? get_site_option( $option_name ) : get_option( $option_name ); |
140 | 140 | } |
141 | - foreach ( $output['pattern_replace'] as $search => $replace ) { |
|
141 | + foreach ( $output[ 'pattern_replace' ] as $search => $replace ) { |
|
142 | 142 | $replacement = ''; |
143 | 143 | switch ( $option_type ) { |
144 | 144 | case 'option': |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | } |
199 | 199 | |
200 | 200 | // No need to proceed this if the current value is the same as in the "exclude" value. |
201 | - if ( isset( $output['exclude'] ) && is_array( $output['exclude'] ) ) { |
|
202 | - foreach ( $output['exclude'] as $exclude ) { |
|
201 | + if ( isset( $output[ 'exclude' ] ) && is_array( $output[ 'exclude' ] ) ) { |
|
202 | + foreach ( $output[ 'exclude' ] as $exclude ) { |
|
203 | 203 | if ( is_array( $value ) ) { |
204 | 204 | if ( is_array( $exclude ) ) { |
205 | 205 | $diff1 = array_diff( $value, $exclude ); |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | } |
212 | 212 | // If 'choice' is defined check for sub-values too. |
213 | 213 | // Fixes https://github.com/aristath/kirki/issues/1416. |
214 | - if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
214 | + if ( isset( $output[ 'choice' ] ) && isset( $value[ $output[ 'choice' ] ] ) && $exclude == $value[ $output[ 'choice' ] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
215 | 215 | $skip = true; |
216 | 216 | } |
217 | 217 | } |
@@ -232,10 +232,10 @@ discard block |
||
232 | 232 | // Apply any value patterns defined. |
233 | 233 | $value = $this->apply_value_pattern( $output, $value ); |
234 | 234 | |
235 | - if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
|
236 | - $output['element'] = array_unique( $output['element'] ); |
|
237 | - sort( $output['element'] ); |
|
238 | - $output['element'] = implode( ',', $output['element'] ); |
|
235 | + if ( isset( $output[ 'element' ] ) && is_array( $output[ 'element' ] ) ) { |
|
236 | + $output[ 'element' ] = array_unique( $output[ 'element' ] ); |
|
237 | + sort( $output[ 'element' ] ); |
|
238 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | $value = $this->process_value( $value, $output ); |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | if ( is_admin() && ! is_customize_preview() ) { |
244 | 244 | |
245 | 245 | // Check if this is an admin style. |
246 | - if ( ! isset( $output['context'] ) || ! in_array( 'editor', $output['context'] ) ) { |
|
246 | + if ( ! isset( $output[ 'context' ] ) || ! in_array( 'editor', $output[ 'context' ] ) ) { |
|
247 | 247 | continue; |
248 | 248 | } |
249 | - } elseif ( isset( $output['context'] ) && ! in_array( 'front', $output['context'] ) ) { |
|
249 | + } elseif ( isset( $output[ 'context' ] ) && ! in_array( 'front', $output[ 'context' ] ) ) { |
|
250 | 250 | |
251 | 251 | // Check if this is a frontend style. |
252 | 252 | continue; |
@@ -265,13 +265,13 @@ discard block |
||
265 | 265 | * @return null |
266 | 266 | */ |
267 | 267 | protected function process_output( $output, $value ) { |
268 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
268 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | - $output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global'; |
|
272 | - $output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : ''; |
|
273 | - $output['units'] = ( isset( $output['units'] ) ) ? $output['units'] : ''; |
|
274 | - $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; |
|
271 | + $output[ 'media_query' ] = ( isset( $output[ 'media_query' ] ) ) ? $output[ 'media_query' ] : 'global'; |
|
272 | + $output[ 'prefix' ] = ( isset( $output[ 'prefix' ] ) ) ? $output[ 'prefix' ] : ''; |
|
273 | + $output[ 'units' ] = ( isset( $output[ 'units' ] ) ) ? $output[ 'units' ] : ''; |
|
274 | + $output[ 'suffix' ] = ( isset( $output[ 'suffix' ] ) ) ? $output[ 'suffix' ] : ''; |
|
275 | 275 | |
276 | 276 | // Properties that can accept multiple values. |
277 | 277 | // Useful for example for gradients where all browsers use the "background-image" property |
@@ -280,15 +280,15 @@ discard block |
||
280 | 280 | 'background-image', |
281 | 281 | 'background', |
282 | 282 | ); |
283 | - if ( in_array( $output['property'], $accepts_multiple, true ) ) { |
|
284 | - if ( isset( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) && ! is_array( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) ) { |
|
285 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = (array) $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ]; |
|
283 | + if ( in_array( $output[ 'property' ], $accepts_multiple, true ) ) { |
|
284 | + if ( isset( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) && ! is_array( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) ) { |
|
285 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = (array) $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ]; |
|
286 | 286 | } |
287 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ][] = $output['prefix'] . $value . $output['units'] . $output['suffix']; |
|
287 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ][ ] = $output[ 'prefix' ] . $value . $output[ 'units' ] . $output[ 'suffix' ]; |
|
288 | 288 | return; |
289 | 289 | } |
290 | 290 | if ( is_string( $value ) || is_numeric( $value ) ) { |
291 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; |
|
291 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | * @return string|array |
328 | 328 | */ |
329 | 329 | protected function process_value( $value, $output ) { |
330 | - if ( isset( $output['property'] ) ) { |
|
331 | - return $this->process_property_value( $output['property'], $value ); |
|
330 | + if ( isset( $output[ 'property' ] ) ) { |
|
331 | + return $this->process_property_value( $output[ 'property' ], $value ); |
|
332 | 332 | } |
333 | 333 | return $value; |
334 | 334 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
44 | 44 | } |
45 | 45 | $data = get_plugin_data( KIRKI_PLUGIN_FILE ); |
46 | - $version = ( isset( $data['Version'] ) ) ? $data['Version'] : false; |
|
46 | + $version = ( isset( $data[ 'Version' ] ) ) ? $data[ 'Version' ] : false; |
|
47 | 47 | define( 'KIRKI_VERSION', $version ); |
48 | 48 | } |
49 | 49 |
@@ -67,28 +67,28 @@ |
||
67 | 67 | |
68 | 68 | // Get the classname we'll be using to create our setting(s). |
69 | 69 | $classname = false; |
70 | - if ( isset( $args['option_type'] ) && array_key_exists( $args['option_type'], $this->setting_types ) ) { |
|
71 | - $classname = $this->setting_types[ $args['option_type'] ]; |
|
70 | + if ( isset( $args[ 'option_type' ] ) && array_key_exists( $args[ 'option_type' ], $this->setting_types ) ) { |
|
71 | + $classname = $this->setting_types[ $args[ 'option_type' ] ]; |
|
72 | 72 | } |
73 | - if ( ! isset( $args['type'] ) || ! array_key_exists( $args['type'], $this->setting_types ) ) { |
|
74 | - $args['type'] = 'default'; |
|
73 | + if ( ! isset( $args[ 'type' ] ) || ! array_key_exists( $args[ 'type' ], $this->setting_types ) ) { |
|
74 | + $args[ 'type' ] = 'default'; |
|
75 | 75 | } |
76 | - $classname = ! $classname ? $this->setting_types[ $args['type'] ] : $classname; |
|
76 | + $classname = ! $classname ? $this->setting_types[ $args[ 'type' ] ] : $classname; |
|
77 | 77 | |
78 | 78 | // If settings are defined as an array, then we need to go through them |
79 | 79 | // and call add_setting for each one of them separately. |
80 | - if ( isset( $args['settings'] ) && is_array( $args['settings'] ) ) { |
|
80 | + if ( isset( $args[ 'settings' ] ) && is_array( $args[ 'settings' ] ) ) { |
|
81 | 81 | |
82 | 82 | // Make sure defaults have been defined. |
83 | - if ( ! isset( $args['default'] ) || ! is_array( $args['default'] ) ) { |
|
84 | - $args['default'] = array(); |
|
83 | + if ( ! isset( $args[ 'default' ] ) || ! is_array( $args[ 'default' ] ) ) { |
|
84 | + $args[ 'default' ] = array(); |
|
85 | 85 | } |
86 | - foreach ( $args['settings'] as $key => $value ) { |
|
86 | + foreach ( $args[ 'settings' ] as $key => $value ) { |
|
87 | 87 | $default = ( isset( $defaults[ $key ] ) ) ? $defaults[ $key ] : ''; |
88 | - $this->add_setting( $classname, $value, $default, $args['option_type'], $args['capability'], $args['transport'], $args['sanitize_callback'] ); |
|
88 | + $this->add_setting( $classname, $value, $default, $args[ 'option_type' ], $args[ 'capability' ], $args[ 'transport' ], $args[ 'sanitize_callback' ] ); |
|
89 | 89 | } |
90 | 90 | } |
91 | - $this->add_setting( $classname, $args['settings'], $args['default'], $args['option_type'], $args['capability'], $args['transport'], $args['sanitize_callback'] ); |
|
91 | + $this->add_setting( $classname, $args[ 'settings' ], $args[ 'default' ], $args[ 'option_type' ], $args[ 'capability' ], $args[ 'transport' ], $args[ 'sanitize_callback' ] ); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | // Get defaults from the class. |
93 | 93 | $defaults = get_class_vars( __CLASS__ ); |
94 | 94 | // Skip what we don't need in this context. |
95 | - unset( $defaults['config_final'] ); |
|
96 | - unset( $defaults['instances'] ); |
|
95 | + unset( $defaults[ 'config_final' ] ); |
|
96 | + unset( $defaults[ 'instances' ] ); |
|
97 | 97 | // Apply any kirki_config global filters. |
98 | 98 | $defaults = apply_filters( 'kirki_config', $defaults ); |
99 | 99 | // Merge our args with the defaults. |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | public static function get_config_ids() { |
162 | 162 | $configs = array(); |
163 | 163 | foreach ( self::$instances as $instance ) { |
164 | - $configs[] = $instance->id; |
|
164 | + $configs[ ] = $instance->id; |
|
165 | 165 | } |
166 | 166 | return array_unique( $configs ); |
167 | 167 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | } |
64 | 64 | // Allow disabling the custom loader using the kirki_config filter. |
65 | 65 | $config = apply_filters( 'kirki_config', array() ); |
66 | - if ( isset( $config['disable_loader'] ) && true === $config['disable_loader'] ) { |
|
66 | + if ( isset( $config[ 'disable_loader' ] ) && true === $config[ 'disable_loader' ] ) { |
|
67 | 67 | return; |
68 | 68 | } |
69 | 69 | // Add the "loading" icon. |