@@ -36,12 +36,12 @@ |
||
36 | 36 | foreach ( array( 'background-image', 'background-color', 'background-repeat', 'background-position', 'background-size', 'background-attachment' ) as $property ) { |
37 | 37 | |
38 | 38 | // See https://github.com/aristath/kirki/issues/1808. |
39 | - if ( 'background-color' === $property && isset( $value['background-color'] ) && $value['background-color'] && ( ! isset( $value['background-image'] ) || empty( $value['background-image'] ) ) ) { |
|
40 | - $this->styles[ $output['media_query'] ][ $output['element'] ]['background'] = $output['prefix'] . $this->process_property_value( $property, $value[ $property ] ) . $output['suffix']; |
|
39 | + if ( 'background-color' === $property && isset( $value[ 'background-color' ] ) && $value[ 'background-color' ] && ( ! isset( $value[ 'background-image' ] ) || empty( $value[ 'background-image' ] ) ) ) { |
|
40 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ 'background' ] = $output[ 'prefix' ] . $this->process_property_value( $property, $value[ $property ] ) . $output[ 'suffix' ]; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | if ( isset( $value[ $property ] ) && ! empty( $value[ $property ] ) ) { |
44 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $this->process_property_value( $property, $value[ $property ] ) . $output['suffix']; |
|
44 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $property ] = $output[ 'prefix' ] . $this->process_property_value( $property, $value[ $property ] ) . $output[ 'suffix' ]; |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $config = apply_filters( 'kirki_config', array() ); |
78 | 78 | |
79 | 79 | // If we have set $config['disable_google_fonts'] to true then do not proceed any further. |
80 | - if ( isset( $config['disable_google_fonts'] ) && true === $config['disable_google_fonts'] ) { |
|
80 | + if ( isset( $config[ 'disable_google_fonts' ] ) && true === $config[ 'disable_google_fonts' ] ) { |
|
81 | 81 | return; |
82 | 82 | } |
83 | 83 | |
@@ -115,57 +115,57 @@ discard block |
||
115 | 115 | global $wp_customize; |
116 | 116 | |
117 | 117 | // Process typography fields. |
118 | - if ( isset( $args['type'] ) && 'kirki-typography' === $args['type'] ) { |
|
118 | + if ( isset( $args[ 'type' ] ) && 'kirki-typography' === $args[ 'type' ] ) { |
|
119 | 119 | |
120 | 120 | // Get the value. |
121 | 121 | $value = Kirki_Values::get_sanitized_field_value( $args ); |
122 | 122 | |
123 | - if ( isset( $value['downloadFont'] ) && $value['downloadFont'] ) { |
|
124 | - $this->hosted_fonts[] = $value['font-family']; |
|
123 | + if ( isset( $value[ 'downloadFont' ] ) && $value[ 'downloadFont' ] ) { |
|
124 | + $this->hosted_fonts[ ] = $value[ 'font-family' ]; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | // If we don't have a font-family then we can skip this. |
128 | - if ( ! $wp_customize && ( ! isset( $value['font-family'] ) || in_array( $value['font-family'], $this->hosted_fonts, true ) ) ) { |
|
128 | + if ( ! $wp_customize && ( ! isset( $value[ 'font-family' ] ) || in_array( $value[ 'font-family' ], $this->hosted_fonts, true ) ) ) { |
|
129 | 129 | return; |
130 | 130 | } |
131 | 131 | |
132 | 132 | // If not a google-font, then we can skip this. |
133 | - if ( ! isset( $value['font-family'] ) || ! Kirki_Fonts::is_google_font( $value['font-family'] ) ) { |
|
133 | + if ( ! isset( $value[ 'font-family' ] ) || ! Kirki_Fonts::is_google_font( $value[ 'font-family' ] ) ) { |
|
134 | 134 | return; |
135 | 135 | } |
136 | 136 | |
137 | 137 | // Set a default value for variants. |
138 | - if ( ! isset( $value['variant'] ) ) { |
|
139 | - $value['variant'] = 'regular'; |
|
138 | + if ( ! isset( $value[ 'variant' ] ) ) { |
|
139 | + $value[ 'variant' ] = 'regular'; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | // Add the requested google-font. |
143 | - if ( ! isset( $this->fonts[ $value['font-family'] ] ) ) { |
|
144 | - $this->fonts[ $value['font-family'] ] = array(); |
|
143 | + if ( ! isset( $this->fonts[ $value[ 'font-family' ] ] ) ) { |
|
144 | + $this->fonts[ $value[ 'font-family' ] ] = array(); |
|
145 | 145 | } |
146 | - if ( ! in_array( $value['variant'], $this->fonts[ $value['font-family'] ], true ) ) { |
|
147 | - $this->fonts[ $value['font-family'] ][] = $value['variant']; |
|
146 | + if ( ! in_array( $value[ 'variant' ], $this->fonts[ $value[ 'font-family' ] ], true ) ) { |
|
147 | + $this->fonts[ $value[ 'font-family' ] ][ ] = $value[ 'variant' ]; |
|
148 | 148 | } |
149 | 149 | // Are we force-loading all variants? |
150 | 150 | if ( true === self::$force_load_all_variants ) { |
151 | 151 | $all_variants = Kirki_Fonts::get_all_variants(); |
152 | - $args['choices']['variant'] = array_keys( $all_variants ); |
|
152 | + $args[ 'choices' ][ 'variant' ] = array_keys( $all_variants ); |
|
153 | 153 | } |
154 | 154 | |
155 | - if ( ! empty( $args['choices']['variant'] ) && is_array( $args['choices']['variant'] ) ) { |
|
156 | - foreach ( $args['choices']['variant'] as $extra_variant ) { |
|
157 | - $this->fonts[ $value['font-family'] ][] = $extra_variant; |
|
155 | + if ( ! empty( $args[ 'choices' ][ 'variant' ] ) && is_array( $args[ 'choices' ][ 'variant' ] ) ) { |
|
156 | + foreach ( $args[ 'choices' ][ 'variant' ] as $extra_variant ) { |
|
157 | + $this->fonts[ $value[ 'font-family' ] ][ ] = $extra_variant; |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Process non-typography fields. |
164 | - if ( isset( $args['output'] ) && is_array( $args['output'] ) ) { |
|
165 | - foreach ( $args['output'] as $output ) { |
|
164 | + if ( isset( $args[ 'output' ] ) && is_array( $args[ 'output' ] ) ) { |
|
165 | + foreach ( $args[ 'output' ] as $output ) { |
|
166 | 166 | |
167 | 167 | // If we don't have a typography-related output argument we can skip this. |
168 | - if ( ! isset( $output['property'] ) || ! in_array( $output['property'], array( 'font-family', 'font-weight' ), true ) ) { |
|
168 | + if ( ! isset( $output[ 'property' ] ) || ! in_array( $output[ 'property' ], array( 'font-family', 'font-weight' ), true ) ) { |
|
169 | 169 | continue; |
170 | 170 | } |
171 | 171 | |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | $value = Kirki_Values::get_sanitized_field_value( $args ); |
174 | 174 | |
175 | 175 | if ( is_string( $value ) ) { |
176 | - if ( 'font-family' === $output['property'] ) { |
|
176 | + if ( 'font-family' === $output[ 'property' ] ) { |
|
177 | 177 | if ( ! array_key_exists( $value, $this->fonts ) ) { |
178 | 178 | $this->fonts[ $value ] = array(); |
179 | 179 | } |
180 | - } elseif ( 'font-weight' === $output['property'] ) { |
|
180 | + } elseif ( 'font-weight' === $output[ 'property' ] ) { |
|
181 | 181 | foreach ( $this->fonts as $font => $variants ) { |
182 | 182 | if ( ! in_array( $value, $variants, true ) ) { |
183 | - $this->fonts[ $font ][] = $value; |
|
183 | + $this->fonts[ $font ][ ] = $value; |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | } |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | |
213 | 213 | // Get all valid font variants for this font. |
214 | 214 | $font_variants = array(); |
215 | - if ( isset( $this->google_fonts[ $font ]['variants'] ) ) { |
|
216 | - $font_variants = $this->google_fonts[ $font ]['variants']; |
|
215 | + if ( isset( $this->google_fonts[ $font ][ 'variants' ] ) ) { |
|
216 | + $font_variants = $this->google_fonts[ $font ][ 'variants' ]; |
|
217 | 217 | } |
218 | 218 | foreach ( $variants as $variant ) { |
219 | 219 |
@@ -69,14 +69,14 @@ |
||
69 | 69 | |
70 | 70 | // Start parsing the fields. |
71 | 71 | foreach ( $fields as $field ) { |
72 | - if ( isset( $field['partial_refresh'] ) && ! empty( $field['partial_refresh'] ) ) { |
|
72 | + if ( isset( $field[ 'partial_refresh' ] ) && ! empty( $field[ 'partial_refresh' ] ) ) { |
|
73 | 73 | // Start going through each item in the array of partial refreshes. |
74 | - foreach ( $field['partial_refresh'] as $partial_refresh => $partial_refresh_args ) { |
|
74 | + foreach ( $field[ 'partial_refresh' ] as $partial_refresh => $partial_refresh_args ) { |
|
75 | 75 | // If we have all we need, create the selective refresh call. |
76 | - if ( isset( $partial_refresh_args['render_callback'] ) && isset( $partial_refresh_args['selector'] ) ) { |
|
76 | + if ( isset( $partial_refresh_args[ 'render_callback' ] ) && isset( $partial_refresh_args[ 'selector' ] ) ) { |
|
77 | 77 | $partial_refresh_args = wp_parse_args( |
78 | 78 | $partial_refresh_args, array( |
79 | - 'settings' => $field['settings'], |
|
79 | + 'settings' => $field[ 'settings' ], |
|
80 | 80 | ) |
81 | 81 | ); |
82 | 82 | $wp_customize->selective_refresh->add_partial( $partial_refresh, $partial_refresh_args ); |
@@ -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( |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | // Find the class that will handle the outpout for this field. |
166 | 166 | $classname = 'Kirki_Output'; |
167 | 167 | $field_output_classes = apply_filters( |
168 | - "kirki_{$field['kirki_config']}_output_control_classnames", array( |
|
168 | + "kirki_{$field[ 'kirki_config' ]}_output_control_classnames", array( |
|
169 | 169 | 'kirki-background' => 'Kirki_Output_Field_Background', |
170 | 170 | 'kirki-dimensions' => 'Kirki_Output_Field_Dimensions', |
171 | 171 | 'kirki-image' => 'Kirki_Output_Field_Image', |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | if ( array_key_exists( self::$field_type, $field_output_classes ) ) { |
177 | 177 | $classname = $field_output_classes[ self::$field_type ]; |
178 | 178 | } |
179 | - $obj = new $classname( $field['kirki_config'], self::$output, self::$value, $field ); |
|
179 | + $obj = new $classname( $field[ 'kirki_config' ], self::$output, self::$value, $field ); |
|
180 | 180 | return $obj->get_styles(); |
181 | 181 | |
182 | 182 | } |
@@ -73,14 +73,14 @@ |
||
73 | 73 | 'logoImage' => '', |
74 | 74 | 'description' => '', |
75 | 75 | ); |
76 | - if ( isset( $config['logo_image'] ) && '' !== $config['logo_image'] ) { |
|
77 | - $vars['logoImage'] = esc_url_raw( $config['logo_image'] ); |
|
76 | + if ( isset( $config[ 'logo_image' ] ) && '' !== $config[ 'logo_image' ] ) { |
|
77 | + $vars[ 'logoImage' ] = esc_url_raw( $config[ 'logo_image' ] ); |
|
78 | 78 | } |
79 | - if ( isset( $config['description'] ) && '' !== $config['description'] ) { |
|
80 | - $vars['description'] = esc_textarea( $config['description'] ); |
|
79 | + if ( isset( $config[ 'description' ] ) && '' !== $config[ 'description' ] ) { |
|
80 | + $vars[ 'description' ] = esc_textarea( $config[ 'description' ] ); |
|
81 | 81 | } |
82 | 82 | |
83 | - if ( ! empty( $vars['logoImage'] ) || ! empty( $vars['description'] ) ) { |
|
83 | + if ( ! empty( $vars[ 'logoImage' ] ) || ! empty( $vars[ 'description' ] ) ) { |
|
84 | 84 | wp_register_script( 'kirki-branding', Kirki::$url . '/modules/customizer-branding/branding.js', array(), KIRKI_VERSION, false ); |
85 | 85 | wp_localize_script( 'kirki-branding', 'kirkiBranding', $vars ); |
86 | 86 | wp_enqueue_script( 'kirki-branding' ); |
@@ -51,10 +51,10 @@ |
||
51 | 51 | ) |
52 | 52 | ); |
53 | 53 | |
54 | - $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) ); |
|
55 | - $array['content'] = $this->get_content(); |
|
56 | - $array['active'] = $this->active(); |
|
57 | - $array['instanceNumber'] = $this->instance_number; |
|
54 | + $array[ 'title' ] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) ); |
|
55 | + $array[ 'content' ] = $this->get_content(); |
|
56 | + $array[ 'active' ] = $this->active(); |
|
57 | + $array[ 'instanceNumber' ] = $this->instance_number; |
|
58 | 58 | |
59 | 59 | return $array; |
60 | 60 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | // Handle the arguments, merge one by one. |
38 | 38 | $args = func_get_args(); |
39 | - $array = $args[0]; |
|
39 | + $array = $args[ 0 ]; |
|
40 | 40 | if ( ! is_array( $array ) ) { |
41 | 41 | return $array; |
42 | 42 | } |
@@ -92,27 +92,27 @@ discard block |
||
92 | 92 | |
93 | 93 | if ( 'ftpext' === $method ) { |
94 | 94 | // If defined, set it to that, Else, set to NULL. |
95 | - $credentials['hostname'] = defined( 'FTP_HOST' ) ? preg_replace( '|\w+://|', '', FTP_HOST ) : null; |
|
96 | - $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : null; |
|
97 | - $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : null; |
|
95 | + $credentials[ 'hostname' ] = defined( 'FTP_HOST' ) ? preg_replace( '|\w+://|', '', FTP_HOST ) : null; |
|
96 | + $credentials[ 'username' ] = defined( 'FTP_USER' ) ? FTP_USER : null; |
|
97 | + $credentials[ 'password' ] = defined( 'FTP_PASS' ) ? FTP_PASS : null; |
|
98 | 98 | |
99 | 99 | // Set FTP port. |
100 | - if ( strpos( $credentials['hostname'], ':' ) && null !== $credentials['hostname'] ) { |
|
101 | - list( $credentials['hostname'], $credentials['port'] ) = explode( ':', $credentials['hostname'], 2 ); |
|
102 | - if ( ! is_numeric( $credentials['port'] ) ) { |
|
103 | - unset( $credentials['port'] ); |
|
100 | + if ( strpos( $credentials[ 'hostname' ], ':' ) && null !== $credentials[ 'hostname' ] ) { |
|
101 | + list( $credentials[ 'hostname' ], $credentials[ 'port' ] ) = explode( ':', $credentials[ 'hostname' ], 2 ); |
|
102 | + if ( ! is_numeric( $credentials[ 'port' ] ) ) { |
|
103 | + unset( $credentials[ 'port' ] ); |
|
104 | 104 | } |
105 | 105 | } else { |
106 | - unset( $credentials['port'] ); |
|
106 | + unset( $credentials[ 'port' ] ); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Set connection type. |
110 | 110 | if ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' === $method ) { |
111 | - $credentials['connection_type'] = 'ftps'; |
|
111 | + $credentials[ 'connection_type' ] = 'ftps'; |
|
112 | 112 | } elseif ( ! array_filter( $credentials ) ) { |
113 | - $credentials['connection_type'] = null; |
|
113 | + $credentials[ 'connection_type' ] = null; |
|
114 | 114 | } else { |
115 | - $credentials['connection_type'] = 'ftp'; |
|
115 | + $credentials[ 'connection_type' ] = 'ftp'; |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | if ( ! empty( $attachment ) ) { |
152 | - return $attachment[0]; |
|
152 | + return $attachment[ 0 ]; |
|
153 | 153 | } |
154 | 154 | return 0; |
155 | 155 | } |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | $image = wp_get_attachment_image_src( $image_id, 'full' ); |
167 | 167 | |
168 | 168 | return array( |
169 | - 'url' => $image[0], |
|
170 | - 'width' => $image[1], |
|
171 | - 'height' => $image[2], |
|
172 | - 'thumbnail' => $image[3], |
|
169 | + 'url' => $image[ 0 ], |
|
170 | + 'width' => $image[ 1 ], |
|
171 | + 'height' => $image[ 2 ], |
|
172 | + 'thumbnail' => $image[ 3 ], |
|
173 | 173 | ); |
174 | 174 | |
175 | 175 | } |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | 'suppress_filters' => false, |
191 | 191 | ) |
192 | 192 | ); |
193 | - } elseif ( is_array( $args ) && ! isset( $args['suppress_filters'] ) ) { |
|
194 | - $args['suppress_filters'] = false; |
|
193 | + } elseif ( is_array( $args ) && ! isset( $args[ 'suppress_filters' ] ) ) { |
|
194 | + $args[ 'suppress_filters' ] = false; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | // Get the posts. |
@@ -341,41 +341,41 @@ discard block |
||
341 | 341 | $key = absint( $context ) / 100; |
342 | 342 | if ( 'A100' === $context ) { |
343 | 343 | $key = 10; |
344 | - unset( $colors['grey'] ); |
|
344 | + unset( $colors[ 'grey' ] ); |
|
345 | 345 | } elseif ( 'A200' === $context ) { |
346 | 346 | $key = 11; |
347 | - unset( $colors['grey'] ); |
|
347 | + unset( $colors[ 'grey' ] ); |
|
348 | 348 | } elseif ( 'A400' === $context ) { |
349 | 349 | $key = 12; |
350 | - unset( $colors['grey'] ); |
|
350 | + unset( $colors[ 'grey' ] ); |
|
351 | 351 | } elseif ( 'A700' === $context ) { |
352 | 352 | $key = 13; |
353 | - unset( $colors['grey'] ); |
|
353 | + unset( $colors[ 'grey' ] ); |
|
354 | 354 | } |
355 | - unset( $colors['primary'] ); |
|
355 | + unset( $colors[ 'primary' ] ); |
|
356 | 356 | $position_colors = array(); |
357 | 357 | foreach ( $colors as $color_family ) { |
358 | 358 | if ( isset( $color_family[ $key ] ) ) { |
359 | - $position_colors[] = $color_family[ $key ]; |
|
359 | + $position_colors[ ] = $color_family[ $key ]; |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | return $position_colors; |
363 | 363 | case 'all': |
364 | - unset( $colors['primary'] ); |
|
364 | + unset( $colors[ 'primary' ] ); |
|
365 | 365 | $all_colors = array(); |
366 | 366 | foreach ( $colors as $color_family ) { |
367 | 367 | foreach ( $color_family as $color ) { |
368 | - $all_colors[] = $color; |
|
368 | + $all_colors[ ] = $color; |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | return $all_colors; |
372 | 372 | case 'primary': |
373 | - return $colors['primary']; |
|
373 | + return $colors[ 'primary' ]; |
|
374 | 374 | default: |
375 | 375 | if ( isset( $colors[ $context ] ) ) { |
376 | 376 | return $colors[ $context ]; |
377 | 377 | } |
378 | - return $colors['primary']; |
|
378 | + return $colors[ 'primary' ]; |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 |
@@ -20,8 +20,8 @@ |
||
20 | 20 | * @access protected |
21 | 21 | */ |
22 | 22 | protected function process_value() { |
23 | - if ( is_array( $this->value ) && isset( $this->value['url'] ) ) { |
|
24 | - $this->value = $this->value['url']; |
|
23 | + if ( is_array( $this->value ) && isset( $this->value[ 'url' ] ) ) { |
|
24 | + $this->value = $this->value[ 'url' ]; |
|
25 | 25 | } |
26 | 26 | if ( false === strpos( $this->value, 'gradient' ) && false === strpos( $this->value, 'url(' ) ) { |
27 | 27 | if ( empty( $this->value ) ) { |
@@ -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 ); |
@@ -253,13 +253,13 @@ discard block |
||
253 | 253 | * @return null |
254 | 254 | */ |
255 | 255 | protected function process_output( $output, $value ) { |
256 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
256 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | - $output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global'; |
|
260 | - $output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : ''; |
|
261 | - $output['units'] = ( isset( $output['units'] ) ) ? $output['units'] : ''; |
|
262 | - $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; |
|
259 | + $output[ 'media_query' ] = ( isset( $output[ 'media_query' ] ) ) ? $output[ 'media_query' ] : 'global'; |
|
260 | + $output[ 'prefix' ] = ( isset( $output[ 'prefix' ] ) ) ? $output[ 'prefix' ] : ''; |
|
261 | + $output[ 'units' ] = ( isset( $output[ 'units' ] ) ) ? $output[ 'units' ] : ''; |
|
262 | + $output[ 'suffix' ] = ( isset( $output[ 'suffix' ] ) ) ? $output[ 'suffix' ] : ''; |
|
263 | 263 | |
264 | 264 | // Properties that can accept multiple values. |
265 | 265 | // Useful for example for gradients where all browsers use the "background-image" property |
@@ -268,15 +268,15 @@ discard block |
||
268 | 268 | 'background-image', |
269 | 269 | 'background', |
270 | 270 | ); |
271 | - if ( in_array( $output['property'], $accepts_multiple, true ) ) { |
|
272 | - if ( isset( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) && ! is_array( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) ) { |
|
273 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = (array) $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ]; |
|
271 | + if ( in_array( $output[ 'property' ], $accepts_multiple, true ) ) { |
|
272 | + if ( isset( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) && ! is_array( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) ) { |
|
273 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = (array) $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ]; |
|
274 | 274 | } |
275 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ][] = $output['prefix'] . $value . $output['units'] . $output['suffix']; |
|
275 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ][ ] = $output[ 'prefix' ] . $value . $output[ 'units' ] . $output[ 'suffix' ]; |
|
276 | 276 | return; |
277 | 277 | } |
278 | 278 | if ( is_string( $value ) || is_numeric( $value ) ) { |
279 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; |
|
279 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
@@ -315,8 +315,8 @@ discard block |
||
315 | 315 | * @return string|array |
316 | 316 | */ |
317 | 317 | protected function process_value( $value, $output ) { |
318 | - if ( isset( $output['property'] ) ) { |
|
319 | - return $this->process_property_value( $output['property'], $value ); |
|
318 | + if ( isset( $output[ 'property' ] ) ) { |
|
319 | + return $this->process_property_value( $output[ 'property' ], $value ); |
|
320 | 320 | } |
321 | 321 | return $value; |
322 | 322 | } |