@@ -142,10 +142,10 @@ discard block |
||
| 142 | 142 | $js_var['index_key'] = $key; |
| 143 | 143 | $callback = $this->get_callback( $args ); |
| 144 | 144 | if ( is_callable( $callback ) ) { |
| 145 | - $field['scripts'][ $key ] = call_user_func_array( $callback, array( $js_var, $args ) ); |
|
| 145 | + $field['scripts'][$key] = call_user_func_array( $callback, array( $js_var, $args ) ); |
|
| 146 | 146 | continue; |
| 147 | 147 | } |
| 148 | - $field['scripts'][ $key ] = $this->script_var( $js_var ); |
|
| 148 | + $field['scripts'][$key] = $this->script_var( $js_var ); |
|
| 149 | 149 | } |
| 150 | 150 | $combo_extra_script = ''; |
| 151 | 151 | $combo_css_script = ''; |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | protected function script_html_var( $args ) { |
| 179 | 179 | |
| 180 | - $script = ( isset( $args['choice'] ) ) ? "newval=newval['{$args['choice']}'];" : ''; |
|
| 180 | + $script = ( isset( $args['choice'] ) ) ? "newval=newval['{$args['choice']}'];" : ''; |
|
| 181 | 181 | |
| 182 | 182 | // Apply the value_pattern. |
| 183 | 183 | if ( isset( $args['value_pattern'] ) && '' !== $args['value_pattern'] ) { |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $property_script = ''; |
| 252 | 252 | |
| 253 | 253 | // Define choice. |
| 254 | - $choice = ( isset( $args['choice'] ) && '' !== $args['choice'] ) ? $args['choice'] : ''; |
|
| 254 | + $choice = ( isset( $args['choice'] ) && '' !== $args['choice'] ) ? $args['choice'] : ''; |
|
| 255 | 255 | |
| 256 | 256 | $value_key = 'newval' . $args['index_key']; |
| 257 | 257 | $property_script .= $value_key . '=newval;'; |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | 'font-weight' => 'fontWeight', |
| 345 | 345 | 'font-style' => 'fontStyle', |
| 346 | 346 | ); |
| 347 | - $choice_condition = ( isset( $args['choice'] ) && '' !== $args['choice'] && isset( $css_build_array[ $args['choice'] ] ) ); |
|
| 347 | + $choice_condition = ( isset( $args['choice'] ) && '' !== $args['choice'] && isset( $css_build_array[$args['choice']] ) ); |
|
| 348 | 348 | $script .= ( ! $choice_condition ) ? $webfont_loader : ''; |
| 349 | 349 | foreach ( $css_build_array as $property => $var ) { |
| 350 | 350 | if ( $choice_condition && $property !== $args['choice'] ) { |
@@ -101,16 +101,16 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | if ( is_array( $value ) ) { |
| 103 | 103 | foreach ( array_keys( $value ) as $value_k ) { |
| 104 | - if ( ! is_string( $value[ $value_k ] ) ) { |
|
| 104 | + if ( ! is_string( $value[$value_k] ) ) { |
|
| 105 | 105 | continue; |
| 106 | 106 | } |
| 107 | 107 | if ( isset( $output['choice'] ) ) { |
| 108 | 108 | if ( $output['choice'] === $value_k ) { |
| 109 | - $value[ $output['choice'] ] = str_replace( '$', $value[ $output['choice'] ], $output['value_pattern'] ); |
|
| 109 | + $value[$output['choice']] = str_replace( '$', $value[$output['choice']], $output['value_pattern'] ); |
|
| 110 | 110 | } |
| 111 | 111 | continue; |
| 112 | 112 | } |
| 113 | - $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output['value_pattern'] ); |
|
| 113 | + $value[$value_k] = str_replace( '$', $value[$value_k], $output['value_pattern'] ); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | $value = $this->apply_pattern_replace( $output, $value ); |
@@ -140,16 +140,16 @@ discard block |
||
| 140 | 140 | if ( is_array( $options ) ) { |
| 141 | 141 | if ( $option_name ) { |
| 142 | 142 | $subkey = str_replace( array( $option_name, '[', ']' ), '', $replace ); |
| 143 | - $replacement = ( isset( $options[ $subkey ] ) ) ? $options[ $subkey ] : ''; |
|
| 143 | + $replacement = ( isset( $options[$subkey] ) ) ? $options[$subkey] : ''; |
|
| 144 | 144 | break; |
| 145 | 145 | } |
| 146 | - $replacement = ( isset( $options[ $replace ] ) ) ? $options[ $replace ] : ''; |
|
| 146 | + $replacement = ( isset( $options[$replace] ) ) ? $options[$replace] : ''; |
|
| 147 | 147 | break; |
| 148 | 148 | } |
| 149 | 149 | $replacement = get_option( $replace ); |
| 150 | 150 | break; |
| 151 | 151 | case 'site_option': |
| 152 | - $replacement = ( is_array( $options ) && isset( $options[ $replace ] ) ) ? $options[ $replace ] : get_site_option( $replace ); |
|
| 152 | + $replacement = ( is_array( $options ) && isset( $options[$replace] ) ) ? $options[$replace] : get_site_option( $replace ); |
|
| 153 | 153 | break; |
| 154 | 154 | case 'user_meta': |
| 155 | 155 | $user_id = get_current_user_id(); |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | $replacement = ( false === $replacement ) ? '' : $replacement; |
| 165 | 165 | if ( is_array( $value ) ) { |
| 166 | 166 | foreach ( $value as $k => $v ) { |
| 167 | - if ( isset( $value[ $v ] ) ) { |
|
| 168 | - $value[ $k ] = str_replace( $search, $replacement, $value[ $v ] ); |
|
| 167 | + if ( isset( $value[$v] ) ) { |
|
| 168 | + $value[$k] = str_replace( $search, $replacement, $value[$v] ); |
|
| 169 | 169 | } else { |
| 170 | - $value[ $k ] = str_replace( $search, $replacement, $v ); |
|
| 170 | + $value[$k] = str_replace( $search, $replacement, $v ); |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | return $value; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | } |
| 211 | 211 | // If 'choice' is defined check for sub-values too. |
| 212 | 212 | // Fixes https://github.com/aristath/kirki/issues/1416. |
| 213 | - if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { |
|
| 213 | + if ( isset( $output['choice'] ) && isset( $value[$output['choice']] ) && $exclude == $value[$output['choice']] ) { |
|
| 214 | 214 | $skip = true; |
| 215 | 215 | } |
| 216 | 216 | } |
@@ -268,13 +268,13 @@ discard block |
||
| 268 | 268 | 'background', |
| 269 | 269 | ); |
| 270 | 270 | if ( in_array( $output['property'], $accepts_multiple, true ) ) { |
| 271 | - if ( isset( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) && ! is_array( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) ) { |
|
| 272 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = (array) $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ]; |
|
| 271 | + if ( isset( $this->styles[$output['media_query']][$output['element']][$output['property']] ) && ! is_array( $this->styles[$output['media_query']][$output['element']][$output['property']] ) ) { |
|
| 272 | + $this->styles[$output['media_query']][$output['element']][$output['property']] = (array) $this->styles[$output['media_query']][$output['element']][$output['property']]; |
|
| 273 | 273 | } |
| 274 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ][] = $output['prefix'] . $value . $output['units'] . $output['suffix']; |
|
| 274 | + $this->styles[$output['media_query']][$output['element']][$output['property']][] = $output['prefix'] . $value . $output['units'] . $output['suffix']; |
|
| 275 | 275 | return; |
| 276 | 276 | } |
| 277 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; |
|
| 277 | + $this->styles[$output['media_query']][$output['element']][$output['property']] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | ) |
| 297 | 297 | ); |
| 298 | 298 | if ( array_key_exists( $property, $properties ) ) { |
| 299 | - $classname = $properties[ $property ]; |
|
| 299 | + $classname = $properties[$property]; |
|
| 300 | 300 | $obj = new $classname( $property, $value ); |
| 301 | 301 | return $obj->get_value(); |
| 302 | 302 | } |
@@ -257,13 +257,13 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | // Get the config arguments, and merge them with the defaults. |
| 259 | 259 | $config_defaults = ( isset( Kirki::$config['global'] ) ) ? Kirki::$config['global'] : array(); |
| 260 | - if ( 'global' !== $this->kirki_config && isset( Kirki::$config[ $this->kirki_config ] ) ) { |
|
| 261 | - $config_defaults = Kirki::$config[ $this->kirki_config ]; |
|
| 260 | + if ( 'global' !== $this->kirki_config && isset( Kirki::$config[$this->kirki_config] ) ) { |
|
| 261 | + $config_defaults = Kirki::$config[$this->kirki_config]; |
|
| 262 | 262 | } |
| 263 | 263 | $config_defaults = ( is_array( $config_defaults ) ) ? $config_defaults : array(); |
| 264 | 264 | foreach ( $config_defaults as $key => $value ) { |
| 265 | - if ( isset( $defaults[ $key ] ) && ! empty( $value ) && $value !== $defaults[ $key ] ) { |
|
| 266 | - $defaults[ $key ] = $value; |
|
| 265 | + if ( isset( $defaults[$key] ) && ! empty( $value ) && $value !== $defaults[$key] ) { |
|
| 266 | + $defaults[$key] = $value; |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
@@ -308,11 +308,11 @@ discard block |
||
| 308 | 308 | // Get all arguments with their values. |
| 309 | 309 | $args = get_object_vars( $this ); |
| 310 | 310 | foreach ( array_keys( $args ) as $key ) { |
| 311 | - $args[ $key ] = $this->$key; |
|
| 311 | + $args[$key] = $this->$key; |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | // Add the field to the static $fields variable properly indexed. |
| 315 | - Kirki::$fields[ $this->settings ] = $args; |
|
| 315 | + Kirki::$fields[$this->settings] = $args; |
|
| 316 | 316 | |
| 317 | 317 | } |
| 318 | 318 | |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | if ( ! is_array( $args ) || ! isset( $args['selector'] ) || ! isset( $args['render_callback'] ) || ! is_callable( $args['render_callback'] ) ) { |
| 408 | 408 | /* translators: %1$s represents the field ID where the error occurs. */ |
| 409 | 409 | _doing_it_wrong( __METHOD__, sprintf( esc_attr__( '"partial_refresh" invalid entry in field %s', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' ); |
| 410 | - unset( $this->partial_refresh[ $id ] ); |
|
| 410 | + unset( $this->partial_refresh[$id] ); |
|
| 411 | 411 | continue; |
| 412 | 412 | } |
| 413 | 413 | } |
@@ -435,10 +435,10 @@ discard block |
||
| 435 | 435 | } |
| 436 | 436 | $settings = array(); |
| 437 | 437 | foreach ( $this->settings as $setting_key => $setting_value ) { |
| 438 | - $settings[ $setting_key ] = $setting_value; |
|
| 438 | + $settings[$setting_key] = $setting_value; |
|
| 439 | 439 | // If we're using serialized options then we need to spice this up. |
| 440 | 440 | if ( 'option' === $this->option_type && '' !== $this->option_name && ( false === strpos( $setting_key, '[' ) ) ) { |
| 441 | - $settings[ $setting_key ] = "{$this->option_name}[{$setting_value}]"; |
|
| 441 | + $settings[$setting_key] = "{$this->option_name}[{$setting_value}]"; |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | $this->settings = $settings; |
@@ -550,27 +550,27 @@ discard block |
||
| 550 | 550 | } |
| 551 | 551 | foreach ( $this->output as $key => $output ) { |
| 552 | 552 | if ( empty( $output ) || ! isset( $output['element'] ) ) { |
| 553 | - unset( $this->output[ $key ] ); |
|
| 553 | + unset( $this->output[$key] ); |
|
| 554 | 554 | continue; |
| 555 | 555 | } |
| 556 | 556 | if ( ! isset( $output['sanitize_callback'] ) && isset( $output['callback'] ) ) { |
| 557 | - $this->output[ $key ]['sanitize_callback'] = $output['callback']; |
|
| 557 | + $this->output[$key]['sanitize_callback'] = $output['callback']; |
|
| 558 | 558 | } |
| 559 | 559 | // Convert element arrays to strings. |
| 560 | 560 | if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
| 561 | - $this->output[ $key ]['element'] = array_unique( $this->output[ $key ]['element'] ); |
|
| 562 | - sort( $this->output[ $key ]['element'] ); |
|
| 561 | + $this->output[$key]['element'] = array_unique( $this->output[$key]['element'] ); |
|
| 562 | + sort( $this->output[$key]['element'] ); |
|
| 563 | 563 | |
| 564 | 564 | // Trim each element in the array. |
| 565 | - foreach ( $this->output[ $key ]['element'] as $index => $element ) { |
|
| 566 | - $this->output[ $key ]['element'][ $index ] = trim( $element ); |
|
| 565 | + foreach ( $this->output[$key]['element'] as $index => $element ) { |
|
| 566 | + $this->output[$key]['element'][$index] = trim( $element ); |
|
| 567 | 567 | } |
| 568 | - $this->output[ $key ]['element'] = implode( ',', $this->output[ $key ]['element'] ); |
|
| 568 | + $this->output[$key]['element'] = implode( ',', $this->output[$key]['element'] ); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | // Fix for https://github.com/aristath/kirki/issues/1659#issuecomment-346229751. |
| 572 | - $this->output[ $key ]['element'] = str_replace( array( "\t", "\n", "\r", "\0", "\x0B" ), ' ', $this->output[ $key ]['element'] ); |
|
| 573 | - $this->output[ $key ]['element'] = trim( preg_replace( '/\s+/', ' ', $this->output[ $key ]['element'] ) ); |
|
| 572 | + $this->output[$key]['element'] = str_replace( array( "\t", "\n", "\r", "\0", "\x0B" ), ' ', $this->output[$key]['element'] ); |
|
| 573 | + $this->output[$key]['element'] = trim( preg_replace( '/\s+/', ' ', $this->output[$key]['element'] ) ); |
|
| 574 | 574 | } |
| 575 | 575 | } |
| 576 | 576 | |