@@ -24,8 +24,8 @@ |
||
24 | 24 | if ( ! is_array( $this->choices ) ) { |
25 | 25 | $this->choices = array(); |
26 | 26 | } |
27 | - $this->choices['element'] = 'input'; |
|
28 | - $this->choices['type'] = 'text'; |
|
27 | + $this->choices[ 'element' ] = 'input'; |
|
28 | + $this->choices[ 'type' ] = 'text'; |
|
29 | 29 | |
30 | 30 | } |
31 | 31 |
@@ -53,17 +53,17 @@ |
||
53 | 53 | } |
54 | 54 | if ( true === $this->alpha ) { |
55 | 55 | _doing_it_wrong( 'Kirki::add_field', esc_attr__( 'Do not use "alpha" as an argument in color controls. Use "choices[alpha]" instead.', 'kirki' ), '3.0.10' ); |
56 | - $this->choices['alpha'] = true; |
|
56 | + $this->choices[ 'alpha' ] = true; |
|
57 | 57 | } |
58 | - if ( ! isset( $this->choices['alpha'] ) || true !== $this->choices['alpha'] ) { |
|
59 | - $this->choices['alpha'] = true; |
|
58 | + if ( ! isset( $this->choices[ 'alpha' ] ) || true !== $this->choices[ 'alpha' ] ) { |
|
59 | + $this->choices[ 'alpha' ] = true; |
|
60 | 60 | if ( property_exists( $this, 'default' ) && ! empty( $this->default ) && false === strpos( 'rgba', $this->default ) ) { |
61 | - $this->choices['alpha'] = false; |
|
61 | + $this->choices[ 'alpha' ] = false; |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | - if ( ( ! isset( $this->choices['mode'] ) ) || ( 'hex' !== $this->choices['mode'] || 'hue' !== $this->choices['mode'] ) ) { |
|
66 | - $this->choices['mode'] = 'hex'; |
|
65 | + if ( ( ! isset( $this->choices[ 'mode' ] ) ) || ( 'hex' !== $this->choices[ 'mode' ] || 'hue' !== $this->choices[ 'mode' ] ) ) { |
|
66 | + $this->choices[ 'mode' ] = 'hex'; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 |
@@ -53,7 +53,7 @@ |
||
53 | 53 | $sanitized_value = array(); |
54 | 54 | foreach ( $value as $sub_value ) { |
55 | 55 | if ( isset( $this->choices[ $sub_value ] ) ) { |
56 | - $sanitized_value[] = esc_attr( $sub_value ); |
|
56 | + $sanitized_value[ ] = esc_attr( $sub_value ); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | return $sanitized_value; |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | return array(); |
55 | 55 | } |
56 | 56 | return array( |
57 | - 'background-color' => ( isset( $value['background-color'] ) ) ? esc_attr( $value['background-color'] ) : '', |
|
58 | - 'background-image' => ( isset( $value['background-image'] ) ) ? esc_url_raw( $value['background-image'] ) : '', |
|
59 | - 'background-repeat' => ( isset( $value['background-repeat'] ) ) ? esc_attr( $value['background-repeat'] ) : '', |
|
60 | - 'background-position' => ( isset( $value['background-position'] ) ) ? esc_attr( $value['background-position'] ) : '', |
|
61 | - 'background-size' => ( isset( $value['background-size'] ) ) ? esc_attr( $value['background-size'] ) : '', |
|
62 | - 'background-attachment' => ( isset( $value['background-attachment'] ) ) ? esc_attr( $value['background-attachment'] ) : '', |
|
57 | + 'background-color' => ( isset( $value[ 'background-color' ] ) ) ? esc_attr( $value[ 'background-color' ] ) : '', |
|
58 | + 'background-image' => ( isset( $value[ 'background-image' ] ) ) ? esc_url_raw( $value[ 'background-image' ] ) : '', |
|
59 | + 'background-repeat' => ( isset( $value[ 'background-repeat' ] ) ) ? esc_attr( $value[ 'background-repeat' ] ) : '', |
|
60 | + 'background-position' => ( isset( $value[ 'background-position' ] ) ) ? esc_attr( $value[ 'background-position' ] ) : '', |
|
61 | + 'background-size' => ( isset( $value[ 'background-size' ] ) ) ? esc_attr( $value[ 'background-size' ] ) : '', |
|
62 | + 'background-attachment' => ( isset( $value[ 'background-attachment' ] ) ) ? esc_attr( $value[ 'background-attachment' ] ) : '', |
|
63 | 63 | ); |
64 | 64 | } |
65 | 65 | |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | foreach ( $this->output as $output ) { |
94 | 94 | |
95 | 95 | // If 'element' is not defined, skip this. |
96 | - if ( ! isset( $output['element'] ) ) { |
|
96 | + if ( ! isset( $output[ 'element' ] ) ) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | - if ( is_array( $output['element'] ) ) { |
|
100 | - $output['element'] = implode( ',', $output['element'] ); |
|
99 | + if ( is_array( $output[ 'element' ] ) ) { |
|
100 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // If there's a sanitize_callback defined, skip this. |
104 | - if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) ) { |
|
104 | + if ( isset( $output[ 'sanitize_callback' ] ) && ! empty( $output[ 'sanitize_callback' ] ) ) { |
|
105 | 105 | continue; |
106 | 106 | } |
107 | 107 | |
108 | 108 | // If we got this far, it's safe to add this. |
109 | - $js_vars[] = $output; |
|
109 | + $js_vars[ ] = $output; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | // Did we manage to get all the items from 'output'? |
@@ -36,8 +36,8 @@ |
||
36 | 36 | if ( ! is_array( $this->choices ) ) { |
37 | 37 | $this->choices = array(); |
38 | 38 | } |
39 | - if ( ! isset( $this->choices['element'] ) ) { |
|
40 | - $this->choices['element'] = 'input'; |
|
39 | + if ( ! isset( $this->choices[ 'element' ] ) ) { |
|
40 | + $this->choices[ 'element' ] = 'input'; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | if ( ! is_array( $this->choices ) ) { |
25 | 25 | $this->choices = array(); |
26 | 26 | } |
27 | - $this->choices['alpha'] = true; |
|
27 | + $this->choices[ 'alpha' ] = true; |
|
28 | 28 | |
29 | 29 | } |
30 | 30 | } |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | ) |
53 | 53 | ); |
54 | 54 | // Make sure min, max & step are all numeric. |
55 | - $this->choices['min'] = filter_var( $this->choices['min'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
56 | - $this->choices['max'] = filter_var( $this->choices['max'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
57 | - $this->choices['step'] = filter_var( $this->choices['step'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
55 | + $this->choices[ 'min' ] = filter_var( $this->choices[ 'min' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
56 | + $this->choices[ 'max' ] = filter_var( $this->choices[ 'max' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
57 | + $this->choices[ 'step' ] = filter_var( $this->choices[ 'step' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | $value = filter_var( $value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
72 | 72 | |
73 | 73 | // Minimum & maximum value limits. |
74 | - if ( $value < $this->choices['min'] || $value > $this->choices['max'] ) { |
|
75 | - return max( min( $value, $this->choices['max'] ), $this->choices['min'] ); |
|
74 | + if ( $value < $this->choices[ 'min' ] || $value > $this->choices[ 'max' ] ) { |
|
75 | + return max( min( $value, $this->choices[ 'max' ] ), $this->choices[ 'min' ] ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | // Only multiple of steps. |
79 | - $steps = ( $value - $this->choices['min'] ) / $this->choices['step']; |
|
79 | + $steps = ( $value - $this->choices[ 'min' ] ) / $this->choices[ 'step' ]; |
|
80 | 80 | if ( ! is_int( $steps ) ) { |
81 | - $value = $this->choices['min'] + ( round( $steps ) * $this->choices['step'] ); |
|
81 | + $value = $this->choices[ 'min' ] + ( round( $steps ) * $this->choices[ 'step' ] ); |
|
82 | 82 | } |
83 | 83 | return $value; |
84 | 84 | } |
@@ -31,8 +31,8 @@ |
||
31 | 31 | if ( ! is_array( $this->choices ) ) { |
32 | 32 | $this->choices = array(); |
33 | 33 | } |
34 | - $this->choices['element'] = 'textarea'; |
|
35 | - $this->choices['rows'] = '5'; |
|
34 | + $this->choices[ 'element' ] = 'textarea'; |
|
35 | + $this->choices[ 'rows' ] = '5'; |
|
36 | 36 | |
37 | 37 | } |
38 | 38 |
@@ -66,10 +66,10 @@ |
||
66 | 66 | */ |
67 | 67 | protected function set_choices() { |
68 | 68 | |
69 | - $this->choices['controls'] = array(); |
|
69 | + $this->choices[ 'controls' ] = array(); |
|
70 | 70 | if ( is_array( $this->default ) ) { |
71 | 71 | foreach ( $this->default as $key => $value ) { |
72 | - $this->choices['controls'][ $key ] = true; |
|
72 | + $this->choices[ 'controls' ][ $key ] = true; |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | } |