@@ -39,18 +39,18 @@ |
||
| 39 | 39 | |
| 40 | 40 | foreach ( array_keys( $value ) as $key ) { |
| 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 | } |
@@ -149,39 +149,39 @@ |
||
| 149 | 149 | // Get the basics from the parent class. |
| 150 | 150 | parent::to_json(); |
| 151 | 151 | // Default. |
| 152 | - $this->json['default'] = $this->setting->default; |
|
| 152 | + $this->json[ 'default' ] = $this->setting->default; |
|
| 153 | 153 | if ( isset( $this->default ) ) { |
| 154 | - $this->json['default'] = $this->default; |
|
| 154 | + $this->json[ 'default' ] = $this->default; |
|
| 155 | 155 | } |
| 156 | 156 | // Required. |
| 157 | - $this->json['required'] = $this->required; |
|
| 157 | + $this->json[ 'required' ] = $this->required; |
|
| 158 | 158 | // Output. |
| 159 | - $this->json['output'] = $this->output; |
|
| 159 | + $this->json[ 'output' ] = $this->output; |
|
| 160 | 160 | // Value. |
| 161 | - $this->json['value'] = $this->value(); |
|
| 161 | + $this->json[ 'value' ] = $this->value(); |
|
| 162 | 162 | // Choices. |
| 163 | - $this->json['choices'] = $this->choices; |
|
| 163 | + $this->json[ 'choices' ] = $this->choices; |
|
| 164 | 164 | // The link. |
| 165 | - $this->json['link'] = $this->get_link(); |
|
| 165 | + $this->json[ 'link' ] = $this->get_link(); |
|
| 166 | 166 | // The ID. |
| 167 | - $this->json['id'] = $this->id; |
|
| 167 | + $this->json[ 'id' ] = $this->id; |
|
| 168 | 168 | // Translation strings. |
| 169 | - $this->json['l10n'] = $this->l10n(); |
|
| 169 | + $this->json[ 'l10n' ] = $this->l10n(); |
|
| 170 | 170 | // The ajaxurl in case we need it. |
| 171 | - $this->json['ajaxurl'] = admin_url( 'admin-ajax.php' ); |
|
| 171 | + $this->json[ 'ajaxurl' ] = admin_url( 'admin-ajax.php' ); |
|
| 172 | 172 | // Input attributes. |
| 173 | - $this->json['inputAttrs'] = ''; |
|
| 173 | + $this->json[ 'inputAttrs' ] = ''; |
|
| 174 | 174 | foreach ( $this->input_attrs as $attr => $value ) { |
| 175 | - $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 175 | + $this->json[ 'inputAttrs' ] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 176 | 176 | } |
| 177 | 177 | // The kirki-config. |
| 178 | - $this->json['kirkiConfig'] = $this->kirki_config; |
|
| 178 | + $this->json[ 'kirkiConfig' ] = $this->kirki_config; |
|
| 179 | 179 | // The option-type. |
| 180 | - $this->json['kirkiOptionType'] = $this->option_type; |
|
| 180 | + $this->json[ 'kirkiOptionType' ] = $this->option_type; |
|
| 181 | 181 | // The option-name. |
| 182 | - $this->json['kirkiOptionName'] = $this->option_name; |
|
| 182 | + $this->json[ 'kirkiOptionName' ] = $this->option_name; |
|
| 183 | 183 | // The preset. |
| 184 | - $this->json['preset'] = $this->preset; |
|
| 184 | + $this->json[ 'preset' ] = $this->preset; |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | // Apply the kirki_config filter. |
| 64 | 64 | $config = apply_filters( 'kirki_config', array() ); |
| 65 | - if ( isset( $config['url_path'] ) ) { |
|
| 66 | - Kirki::$url = $config['url_path']; |
|
| 65 | + if ( isset( $config[ 'url_path' ] ) ) { |
|
| 66 | + Kirki::$url = $config[ 'url_path' ]; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // Make sure the right protocol is used. |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | $this->control_types = $this->default_control_types(); |
| 145 | 145 | if ( ! class_exists( 'WP_Customize_Code_Editor_Control' ) ) { |
| 146 | - unset( $this->control_types['code_editor'] ); |
|
| 146 | + unset( $this->control_types[ 'code_editor' ] ); |
|
| 147 | 147 | } |
| 148 | 148 | foreach ( $this->control_types as $key => $classname ) { |
| 149 | 149 | if ( ! class_exists( $classname ) ) { |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | if ( ! empty( Kirki::$panels ) ) { |
| 175 | 175 | foreach ( Kirki::$panels as $panel_args ) { |
| 176 | 176 | // Extra checks for nested panels. |
| 177 | - if ( isset( $panel_args['panel'] ) ) { |
|
| 178 | - if ( isset( Kirki::$panels[ $panel_args['panel'] ] ) ) { |
|
| 177 | + if ( isset( $panel_args[ 'panel' ] ) ) { |
|
| 178 | + if ( isset( Kirki::$panels[ $panel_args[ 'panel' ] ] ) ) { |
|
| 179 | 179 | // Set the type to nested. |
| 180 | - $panel_args['type'] = 'kirki-nested'; |
|
| 180 | + $panel_args[ 'type' ] = 'kirki-nested'; |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
@@ -195,14 +195,14 @@ discard block |
||
| 195 | 195 | if ( ! empty( Kirki::$sections ) ) { |
| 196 | 196 | foreach ( Kirki::$sections as $section_args ) { |
| 197 | 197 | // Extra checks for nested sections. |
| 198 | - if ( isset( $section_args['section'] ) ) { |
|
| 199 | - if ( isset( Kirki::$sections[ $section_args['section'] ] ) ) { |
|
| 198 | + if ( isset( $section_args[ 'section' ] ) ) { |
|
| 199 | + if ( isset( Kirki::$sections[ $section_args[ 'section' ] ] ) ) { |
|
| 200 | 200 | // Set the type to nested. |
| 201 | - $section_args['type'] = 'kirki-nested'; |
|
| 201 | + $section_args[ 'type' ] = 'kirki-nested'; |
|
| 202 | 202 | // We need to check if the parent section is nested inside a panel. |
| 203 | - $parent_section = Kirki::$sections[ $section_args['section'] ]; |
|
| 204 | - if ( isset( $parent_section['panel'] ) ) { |
|
| 205 | - $section_args['panel'] = $parent_section['panel']; |
|
| 203 | + $parent_section = Kirki::$sections[ $section_args[ 'section' ] ]; |
|
| 204 | + if ( isset( $parent_section[ 'panel' ] ) ) { |
|
| 205 | + $section_args[ 'panel' ] = $parent_section[ 'panel' ]; |
|
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | } |
@@ -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 ); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | // If 'choice' is defined check for sub-values too. |
| 219 | 219 | // Fixes https://github.com/aristath/kirki/issues/1416. |
| 220 | 220 | // @codingStandardsIgnoreLine WordPress.PHP.StrictComparisons.LooseComparison |
| 221 | - if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
| 221 | + if ( isset( $output[ 'choice' ] ) && isset( $value[ $output[ 'choice' ] ] ) && $exclude == $value[ $output[ 'choice' ] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
| 222 | 222 | $skip = true; |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -239,10 +239,10 @@ discard block |
||
| 239 | 239 | // Apply any value patterns defined. |
| 240 | 240 | $value = $this->apply_value_pattern( $output, $value ); |
| 241 | 241 | |
| 242 | - if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
|
| 243 | - $output['element'] = array_unique( $output['element'] ); |
|
| 244 | - sort( $output['element'] ); |
|
| 245 | - $output['element'] = implode( ',', $output['element'] ); |
|
| 242 | + if ( isset( $output[ 'element' ] ) && is_array( $output[ 'element' ] ) ) { |
|
| 243 | + $output[ 'element' ] = array_unique( $output[ 'element' ] ); |
|
| 244 | + sort( $output[ 'element' ] ); |
|
| 245 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | $value = $this->process_value( $value, $output ); |
@@ -260,13 +260,13 @@ discard block |
||
| 260 | 260 | * @return null |
| 261 | 261 | */ |
| 262 | 262 | protected function process_output( $output, $value ) { |
| 263 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
| 263 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
| 264 | 264 | return; |
| 265 | 265 | } |
| 266 | - $output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global'; |
|
| 267 | - $output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : ''; |
|
| 268 | - $output['units'] = ( isset( $output['units'] ) ) ? $output['units'] : ''; |
|
| 269 | - $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; |
|
| 266 | + $output[ 'media_query' ] = ( isset( $output[ 'media_query' ] ) ) ? $output[ 'media_query' ] : 'global'; |
|
| 267 | + $output[ 'prefix' ] = ( isset( $output[ 'prefix' ] ) ) ? $output[ 'prefix' ] : ''; |
|
| 268 | + $output[ 'units' ] = ( isset( $output[ 'units' ] ) ) ? $output[ 'units' ] : ''; |
|
| 269 | + $output[ 'suffix' ] = ( isset( $output[ 'suffix' ] ) ) ? $output[ 'suffix' ] : ''; |
|
| 270 | 270 | |
| 271 | 271 | // Properties that can accept multiple values. |
| 272 | 272 | // Useful for example for gradients where all browsers use the "background-image" property |
@@ -275,15 +275,15 @@ discard block |
||
| 275 | 275 | 'background-image', |
| 276 | 276 | 'background', |
| 277 | 277 | ); |
| 278 | - if ( in_array( $output['property'], $accepts_multiple, true ) ) { |
|
| 279 | - if ( isset( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) && ! is_array( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) ) { |
|
| 280 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = (array) $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ]; |
|
| 278 | + if ( in_array( $output[ 'property' ], $accepts_multiple, true ) ) { |
|
| 279 | + if ( isset( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) && ! is_array( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) ) { |
|
| 280 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = (array) $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ]; |
|
| 281 | 281 | } |
| 282 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ][] = $output['prefix'] . $value . $output['units'] . $output['suffix']; |
|
| 282 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ][ ] = $output[ 'prefix' ] . $value . $output[ 'units' ] . $output[ 'suffix' ]; |
|
| 283 | 283 | return; |
| 284 | 284 | } |
| 285 | 285 | if ( is_string( $value ) || is_numeric( $value ) ) { |
| 286 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; |
|
| 286 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | * @return string|array |
| 323 | 323 | */ |
| 324 | 324 | protected function process_value( $value, $output ) { |
| 325 | - if ( isset( $output['property'] ) ) { |
|
| 326 | - return $this->process_property_value( $output['property'], $value ); |
|
| 325 | + if ( isset( $output[ 'property' ] ) ) { |
|
| 326 | + return $this->process_property_value( $output[ 'property' ], $value ); |
|
| 327 | 327 | } |
| 328 | 328 | return $value; |
| 329 | 329 | } |