@@ -42,8 +42,8 @@ |
||
42 | 42 | if ( false !== strpos( $this->value, ' ' ) ) { |
43 | 43 | $xy = explode( ' ', $this->value ); |
44 | 44 | |
45 | - $x = trim( $xy[0] ); |
|
46 | - $y = trim( $xy[1] ); |
|
45 | + $x = trim( $xy[ 0 ] ); |
|
46 | + $y = trim( $xy[ 1 ] ); |
|
47 | 47 | |
48 | 48 | // If x is not left/center/right, we need to sanitize it. |
49 | 49 | if ( ! in_array( $x, $x_dimensions, true ) ) { |
@@ -21,8 +21,8 @@ |
||
21 | 21 | */ |
22 | 22 | protected function process_value() { |
23 | 23 | |
24 | - if ( is_array( $this->value ) && isset( $this->value['url'] ) ) { |
|
25 | - $this->value = $this->value['url']; |
|
24 | + if ( is_array( $this->value ) && isset( $this->value[ 'url' ] ) ) { |
|
25 | + $this->value = $this->value[ 'url' ]; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | if ( false === strpos( $this->value, 'gradient' ) && false === strpos( $this->value, 'url(' ) ) { |
@@ -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 |