@@ -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 | } |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | protected function set_default() { |
50 | 50 | |
51 | 51 | // Accomodate the use of font-weight and convert to variant. |
52 | - if ( isset( $this->default['font-weight'] ) ) { |
|
53 | - $this->default['variant'] = ( 'regular' === $this->default['font-weight'] ) ? 400 : (string) intval( $this->default['font-weight'] ); |
|
52 | + if ( isset( $this->default[ 'font-weight' ] ) ) { |
|
53 | + $this->default[ 'variant' ] = ( 'regular' === $this->default[ 'font-weight' ] ) ? 400 : (string) intval( $this->default[ 'font-weight' ] ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | // Make sure letter-spacing has units. |
57 | - if ( isset( $this->default['letter-spacing'] ) && is_numeric( $this->default['letter-spacing'] ) && $this->default['letter-spacing'] ) { |
|
58 | - $this->default['letter-spacing'] .= 'px'; |
|
57 | + if ( isset( $this->default[ 'letter-spacing' ] ) && is_numeric( $this->default[ 'letter-spacing' ] ) && $this->default[ 'letter-spacing' ] ) { |
|
58 | + $this->default[ 'letter-spacing' ] .= 'px'; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | // Make sure we use "subsets" instead of "subset". |
62 | - if ( isset( $this->default['subset'] ) && ! empty( $this->default['subset'] ) && ( ! isset( $this->default['subsets'] ) || empty( $this->default['subsets'] ) ) ) { |
|
63 | - $this->default['subsets'] = $this->default['subset']; |
|
62 | + if ( isset( $this->default[ 'subset' ] ) && ! empty( $this->default[ 'subset' ] ) && ( ! isset( $this->default[ 'subsets' ] ) || empty( $this->default[ 'subsets' ] ) ) ) { |
|
63 | + $this->default[ 'subsets' ] = $this->default[ 'subset' ]; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | foreach ( $this->output as $output ) { |
112 | 112 | |
113 | 113 | // If 'element' or 'property' are not defined, skip this. |
114 | - if ( ! isset( $output['element'] ) ) { |
|
114 | + if ( ! isset( $output[ 'element' ] ) ) { |
|
115 | 115 | continue; |
116 | 116 | } |
117 | - if ( is_array( $output['element'] ) ) { |
|
118 | - $output['element'] = implode( ',', $output['element'] ); |
|
117 | + if ( is_array( $output[ 'element' ] ) ) { |
|
118 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | // If we got this far, it's safe to add this. |
122 | - $js_vars[] = $output; |
|
122 | + $js_vars[ ] = $output; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | // Did we manage to get all the items from 'output'? |
@@ -151,45 +151,45 @@ discard block |
||
151 | 151 | foreach ( $value as $key => $val ) { |
152 | 152 | switch ( $key ) { |
153 | 153 | case 'font-family': |
154 | - $value['font-family'] = esc_attr( $val ); |
|
154 | + $value[ 'font-family' ] = esc_attr( $val ); |
|
155 | 155 | break; |
156 | 156 | case 'font-weight': |
157 | - if ( isset( $value['variant'] ) ) { |
|
157 | + if ( isset( $value[ 'variant' ] ) ) { |
|
158 | 158 | break; |
159 | 159 | } |
160 | - $value['variant'] = $val; |
|
161 | - if ( isset( $value['font-style'] ) && 'italic' === $value['font-style'] ) { |
|
162 | - $value['variant'] = ( '400' !== $val || 400 !== $val ) ? $value['variant'] . 'italic' : 'italic'; |
|
160 | + $value[ 'variant' ] = $val; |
|
161 | + if ( isset( $value[ 'font-style' ] ) && 'italic' === $value[ 'font-style' ] ) { |
|
162 | + $value[ 'variant' ] = ( '400' !== $val || 400 !== $val ) ? $value[ 'variant' ] . 'italic' : 'italic'; |
|
163 | 163 | } |
164 | 164 | break; |
165 | 165 | case 'variant': |
166 | 166 | // Use 'regular' instead of 400 for font-variant. |
167 | - $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; |
|
167 | + $value[ 'variant' ] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; |
|
168 | 168 | // Get font-weight from variant. |
169 | - $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
170 | - $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? 400 : absint( $value['font-weight'] ); |
|
169 | + $value[ 'font-weight' ] = filter_var( $value[ 'variant' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
170 | + $value[ 'font-weight' ] = ( 'regular' === $value[ 'variant' ] || 'italic' === $value[ 'variant' ] ) ? 400 : absint( $value[ 'font-weight' ] ); |
|
171 | 171 | // Get font-style from variant. |
172 | - if ( ! isset( $value['font-style'] ) ) { |
|
173 | - $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; |
|
172 | + if ( ! isset( $value[ 'font-style' ] ) ) { |
|
173 | + $value[ 'font-style' ] = ( false === strpos( $value[ 'variant' ], 'italic' ) ) ? 'normal' : 'italic'; |
|
174 | 174 | } |
175 | 175 | break; |
176 | 176 | case 'subset': |
177 | 177 | // Make sure the saved value is "subsets" (plural) and not "subset". |
178 | 178 | // This is for compatibility with older versions. |
179 | - if ( ! empty( $value['subset'] ) && ! isset( $value['subsets'] ) || empty( $value['subset'] ) ) { |
|
180 | - $value['subsets'] = $value['subset']; |
|
179 | + if ( ! empty( $value[ 'subset' ] ) && ! isset( $value[ 'subsets' ] ) || empty( $value[ 'subset' ] ) ) { |
|
180 | + $value[ 'subsets' ] = $value[ 'subset' ]; |
|
181 | 181 | } |
182 | - unset( $value['subset'] ); |
|
182 | + unset( $value[ 'subset' ] ); |
|
183 | 183 | // Make sure we're using a valid subset. |
184 | 184 | $valid_subsets = Kirki_Fonts::get_google_font_subsets(); |
185 | 185 | $subsets_ok = array(); |
186 | - $value['subsets'] = (array) $value['subsets']; |
|
187 | - foreach ( $value['subsets'] as $subset ) { |
|
186 | + $value[ 'subsets' ] = (array) $value[ 'subsets' ]; |
|
187 | + foreach ( $value[ 'subsets' ] as $subset ) { |
|
188 | 188 | if ( array_key_exists( $subset, $valid_subsets ) ) { |
189 | - $subsets_ok[] = $subset; |
|
189 | + $subsets_ok[ ] = $subset; |
|
190 | 190 | } |
191 | 191 | } |
192 | - $value['subsets'] = $subsets_ok; |
|
192 | + $value[ 'subsets' ] = $subsets_ok; |
|
193 | 193 | break; |
194 | 194 | case 'font-size': |
195 | 195 | case 'letter-spacing': |
@@ -199,21 +199,21 @@ discard block |
||
199 | 199 | break; |
200 | 200 | case 'text-align': |
201 | 201 | if ( ! in_array( $val, array( 'inherit', 'left', 'center', 'right', 'justify' ), true ) ) { |
202 | - $value['text-align'] = 'inherit'; |
|
202 | + $value[ 'text-align' ] = 'inherit'; |
|
203 | 203 | } |
204 | 204 | break; |
205 | 205 | case 'text-transform': |
206 | 206 | if ( ! in_array( $val, array( 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ), true ) ) { |
207 | - $value['text-transform'] = 'none'; |
|
207 | + $value[ 'text-transform' ] = 'none'; |
|
208 | 208 | } |
209 | 209 | break; |
210 | 210 | case 'text-decoration': |
211 | 211 | if ( ! in_array( $val, array( 'none', 'underline', 'overline', 'line-through', 'initial', 'inherit' ), true ) ) { |
212 | - $value['text-transform'] = 'none'; |
|
212 | + $value[ 'text-transform' ] = 'none'; |
|
213 | 213 | } |
214 | 214 | break; |
215 | 215 | case 'color': |
216 | - $value['color'] = ariColor::newColor( $val )->toCSS( 'hex' ); |
|
216 | + $value[ 'color' ] = ariColor::newColor( $val )->toCSS( 'hex' ); |
|
217 | 217 | break; |
218 | 218 | } // End switch(). |
219 | 219 | } // End foreach(). |
@@ -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 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @return mixed |
34 | 34 | */ |
35 | 35 | protected function get_root_value( $default = null ) { |
36 | - $id_base = $this->id_data['base']; |
|
36 | + $id_base = $this->id_data[ 'base' ]; |
|
37 | 37 | |
38 | 38 | // Get all user-meta. |
39 | 39 | // We'll use this to check if the value is set or not, |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return bool Whether the multidimensional root was updated successfully. |
61 | 61 | */ |
62 | 62 | protected function set_root_value( $value ) { |
63 | - $id_base = $this->id_data['base']; |
|
63 | + $id_base = $this->id_data[ 'base' ]; |
|
64 | 64 | |
65 | 65 | // First delete the current user-meta. |
66 | 66 | // We're doing this to avoid duplicate entries. |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $plugins = get_plugins(); |
46 | 46 | $_plugin = ''; |
47 | 47 | foreach ( $plugins as $plugin => $args ) { |
48 | - if ( ! $is_plugin && isset( $args['Name'] ) && ( 'Kirki' === $args['Name'] || 'Kirki Toolkit' === $args['Name'] ) ) { |
|
48 | + if ( ! $is_plugin && isset( $args[ 'Name' ] ) && ( 'Kirki' === $args[ 'Name' ] || 'Kirki Toolkit' === $args[ 'Name' ] ) ) { |
|
49 | 49 | $is_plugin = true; |
50 | 50 | $_plugin = $plugin; |
51 | 51 | } |
@@ -82,26 +82,26 @@ discard block |
||
82 | 82 | foreach ( Kirki::$fields as $field ) { |
83 | 83 | |
84 | 84 | // Check if we have variables for this field. |
85 | - if ( isset( $field['variables'] ) && $field['variables'] && ! empty( $field['variables'] ) ) { |
|
85 | + if ( isset( $field[ 'variables' ] ) && $field[ 'variables' ] && ! empty( $field[ 'variables' ] ) ) { |
|
86 | 86 | |
87 | 87 | // Loop through the array of variables. |
88 | - foreach ( $field['variables'] as $field_variable ) { |
|
88 | + foreach ( $field[ 'variables' ] as $field_variable ) { |
|
89 | 89 | |
90 | 90 | // Is the variable ['name'] defined? If yes, then we can proceed. |
91 | - if ( isset( $field_variable['name'] ) ) { |
|
91 | + if ( isset( $field_variable[ 'name' ] ) ) { |
|
92 | 92 | |
93 | 93 | // Sanitize the variable name. |
94 | - $variable_name = esc_attr( $field_variable['name'] ); |
|
94 | + $variable_name = esc_attr( $field_variable[ 'name' ] ); |
|
95 | 95 | |
96 | 96 | // Do we have a callback function defined? If not then set $variable_callback to false. |
97 | - $variable_callback = ( isset( $field_variable['callback'] ) && is_callable( $field_variable['callback'] ) ) ? $field_variable['callback'] : false; |
|
97 | + $variable_callback = ( isset( $field_variable[ 'callback' ] ) && is_callable( $field_variable[ 'callback' ] ) ) ? $field_variable[ 'callback' ] : false; |
|
98 | 98 | |
99 | 99 | // If we have a variable_callback defined then get the value of the option |
100 | 100 | // and run it through the callback function. |
101 | 101 | // If no callback is defined (false) then just get the value. |
102 | - $variables[ $variable_name ] = Kirki_Values::get_value( $field['settings'] ); |
|
102 | + $variables[ $variable_name ] = Kirki_Values::get_value( $field[ 'settings' ] ); |
|
103 | 103 | if ( $variable_callback ) { |
104 | - $variables[ $variable_name ] = call_user_func( $field_variable['callback'], Kirki_Values::get_value( $field['settings'] ) ); |
|
104 | + $variables[ $variable_name ] = call_user_func( $field_variable[ 'callback' ], Kirki_Values::get_value( $field[ 'settings' ] ) ); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
@@ -128,31 +128,31 @@ discard block |
||
128 | 128 | if ( |
129 | 129 | self::is_plugin() || |
130 | 130 | false === strpos( $url, 'wordpress.org' ) || ( |
131 | - ! isset( $request['body'] ) || |
|
132 | - ! isset( $request['body']['plugins'] ) || |
|
133 | - ! isset( $request['body']['translations'] ) || |
|
134 | - ! isset( $request['body']['locale'] ) || |
|
135 | - ! isset( $request['body']['all'] ) |
|
131 | + ! isset( $request[ 'body' ] ) || |
|
132 | + ! isset( $request[ 'body' ][ 'plugins' ] ) || |
|
133 | + ! isset( $request[ 'body' ][ 'translations' ] ) || |
|
134 | + ! isset( $request[ 'body' ][ 'locale' ] ) || |
|
135 | + ! isset( $request[ 'body' ][ 'all' ] ) |
|
136 | 136 | ) |
137 | 137 | ) { |
138 | 138 | return $request; |
139 | 139 | } |
140 | 140 | |
141 | - $plugins = json_decode( $request['body']['plugins'], true ); |
|
142 | - if ( ! isset( $plugins['plugins'] ) ) { |
|
141 | + $plugins = json_decode( $request[ 'body' ][ 'plugins' ], true ); |
|
142 | + if ( ! isset( $plugins[ 'plugins' ] ) ) { |
|
143 | 143 | return $request; |
144 | 144 | } |
145 | 145 | $exists = false; |
146 | - foreach ( $plugins['plugins'] as $plugin ) { |
|
147 | - if ( isset( $plugin['Name'] ) && 'Kirki Toolkit' === $plugin['Name'] ) { |
|
146 | + foreach ( $plugins[ 'plugins' ] as $plugin ) { |
|
147 | + if ( isset( $plugin[ 'Name' ] ) && 'Kirki Toolkit' === $plugin[ 'Name' ] ) { |
|
148 | 148 | $exists = true; |
149 | 149 | } |
150 | 150 | } |
151 | 151 | // Inject data. |
152 | 152 | if ( ! $exists && defined( 'KIRKI_PLUGIN_FILE' ) ) { |
153 | - $plugins['plugins']['kirki/kirki.php'] = get_plugin_data( KIRKI_PLUGIN_FILE ); |
|
153 | + $plugins[ 'plugins' ][ 'kirki/kirki.php' ] = get_plugin_data( KIRKI_PLUGIN_FILE ); |
|
154 | 154 | } |
155 | - $request['body']['plugins'] = wp_json_encode( $plugins ); |
|
155 | + $request[ 'body' ][ 'plugins' ] = wp_json_encode( $plugins ); |
|
156 | 156 | return $request; |
157 | 157 | } |
158 | 158 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | // We only need the major version. |
175 | 175 | if ( 'major' === $context ) { |
176 | 176 | $version_parts = explode( '.', $wp_version ); |
177 | - return ( $only_numeric ) ? absint( $version_parts[0] ) : $version_parts[0]; |
|
177 | + return ( $only_numeric ) ? absint( $version_parts[ 0 ] ) : $version_parts[ 0 ]; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | // If we got this far, we want the full monty. |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | if ( false !== strpos( $wp_version, '-' ) ) { |
184 | 184 | // We're on a dev version. |
185 | 185 | $version_parts = explode( '-', $wp_version ); |
186 | - return floatval( $version_parts[0] ); |
|
186 | + return floatval( $version_parts[ 0 ] ); |
|
187 | 187 | } |
188 | 188 | return floatval( $wp_version ); |
189 | 189 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @return mixed |
34 | 34 | */ |
35 | 35 | protected function get_root_value( $default = null ) { |
36 | - return get_site_option( $this->id_data['base'], $default ); |
|
36 | + return get_site_option( $this->id_data[ 'base' ], $default ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @return bool Whether the multidimensional root was updated successfully. |
46 | 46 | */ |
47 | 47 | protected function set_root_value( $value ) { |
48 | - return update_site_option( $this->id_data['base'], $value ); |
|
48 | + return update_site_option( $this->id_data[ 'base' ], $value ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -119,7 +119,7 @@ |
||
119 | 119 | global $l10n; |
120 | 120 | if ( isset( $l10n[ $this->get_theme_textdomain() ] ) ) { |
121 | 121 | // @codingStandardsIgnoreLine WordPress.Variables.GlobalVariables.OverrideProhibited |
122 | - $l10n['kirki'] = $l10n[ $this->get_theme_textdomain() ]; |
|
122 | + $l10n[ 'kirki' ] = $l10n[ $this->get_theme_textdomain() ]; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | // Check if the domain is "kirki". |
@@ -227,28 +227,28 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function __construct( $config_id = 'global', $args = array() ) { |
229 | 229 | |
230 | - if ( isset( $args['setting'] ) && ! empty( $args['setting'] ) && ( ! isset( $args['settings'] ) || empty( $args['settings'] ) ) ) { |
|
230 | + if ( isset( $args[ 'setting' ] ) && ! empty( $args[ 'setting' ] ) && ( ! isset( $args[ 'settings' ] ) || empty( $args[ 'settings' ] ) ) ) { |
|
231 | 231 | /* translators: %s represents the field ID where the error occurs. */ |
232 | - _doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Typo found in field %s - setting instead of settings.', 'kirki' ), esc_attr( $args['settings'] ) ), '3.0.10' ); |
|
233 | - $args['settings'] = $args['setting']; |
|
234 | - unset( $args['setting'] ); |
|
232 | + _doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Typo found in field %s - setting instead of settings.', 'kirki' ), esc_attr( $args[ 'settings' ] ) ), '3.0.10' ); |
|
233 | + $args[ 'settings' ] = $args[ 'setting' ]; |
|
234 | + unset( $args[ 'setting' ] ); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | // In case the user only provides 1 argument, |
238 | 238 | // assume that the provided argument is $args and set $config_id = 'global'. |
239 | 239 | if ( is_array( $config_id ) && empty( $args ) ) { |
240 | 240 | /* translators: %1$s represents the field ID where the error occurs. %2$s is the URL in the documentation site. */ |
241 | - _doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' ); |
|
241 | + _doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args[ 'settings' ] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' ); |
|
242 | 242 | $args = $config_id; |
243 | 243 | $config_id = 'global'; |
244 | 244 | } |
245 | 245 | |
246 | - $args['kirki_config'] = $config_id; |
|
246 | + $args[ 'kirki_config' ] = $config_id; |
|
247 | 247 | |
248 | 248 | $this->kirki_config = trim( esc_attr( $config_id ) ); |
249 | 249 | if ( '' === $config_id ) { |
250 | 250 | /* translators: %1$s represents the field ID where the error occurs. %2$s is the URL in the documentation site. */ |
251 | - _doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' ); |
|
251 | + _doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args[ 'settings' ] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' ); |
|
252 | 252 | $this->kirki_config = 'global'; |
253 | 253 | } |
254 | 254 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | $defaults = get_class_vars( __CLASS__ ); |
257 | 257 | |
258 | 258 | // Get the config arguments, and merge them with the defaults. |
259 | - $config_defaults = ( isset( Kirki::$config['global'] ) ) ? Kirki::$config['global'] : array(); |
|
259 | + $config_defaults = ( isset( Kirki::$config[ 'global' ] ) ) ? Kirki::$config[ 'global' ] : array(); |
|
260 | 260 | if ( 'global' !== $this->kirki_config && isset( Kirki::$config[ $this->kirki_config ] ) ) { |
261 | 261 | $config_defaults = Kirki::$config[ $this->kirki_config ]; |
262 | 262 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | $this->partial_refresh = array(); |
405 | 405 | } |
406 | 406 | foreach ( $this->partial_refresh as $id => $args ) { |
407 | - if ( ! is_array( $args ) || ! isset( $args['selector'] ) || ! isset( $args['render_callback'] ) || ! is_callable( $args['render_callback'] ) ) { |
|
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 | 410 | unset( $this->partial_refresh[ $id ] ); |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | } |
443 | 443 | } |
444 | 444 | $this->settings = $settings; |
445 | - if ( isset( $this->settings['kirki_placeholder_setting'] ) ) { |
|
446 | - $this->settings = $this->settings['kirki_placeholder_setting']; |
|
445 | + if ( isset( $this->settings[ 'kirki_placeholder_setting' ] ) ) { |
|
446 | + $this->settings = $this->settings[ 'kirki_placeholder_setting' ]; |
|
447 | 447 | } |
448 | 448 | } |
449 | 449 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | protected function set_active_callback() { |
458 | 458 | |
459 | 459 | if ( is_array( $this->active_callback ) && ! is_callable( $this->active_callback ) ) { |
460 | - if ( isset( $this->active_callback[0] ) ) { |
|
460 | + if ( isset( $this->active_callback[ 0 ] ) ) { |
|
461 | 461 | $this->required = $this->active_callback; |
462 | 462 | } |
463 | 463 | } |
@@ -543,34 +543,34 @@ discard block |
||
543 | 543 | ); |
544 | 544 | } |
545 | 545 | // Convert to array of arrays if needed. |
546 | - if ( isset( $this->output['element'] ) ) { |
|
546 | + if ( isset( $this->output[ 'element' ] ) ) { |
|
547 | 547 | /* translators: The field ID where the error occurs. */ |
548 | 548 | _doing_it_wrong( __METHOD__, sprintf( esc_attr__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' ); |
549 | 549 | $this->output = array( $this->output ); |
550 | 550 | } |
551 | 551 | foreach ( $this->output as $key => $output ) { |
552 | - if ( empty( $output ) || ! isset( $output['element'] ) ) { |
|
552 | + if ( empty( $output ) || ! isset( $output[ 'element' ] ) ) { |
|
553 | 553 | unset( $this->output[ $key ] ); |
554 | 554 | continue; |
555 | 555 | } |
556 | - if ( ! isset( $output['sanitize_callback'] ) && isset( $output['callback'] ) ) { |
|
557 | - $this->output[ $key ]['sanitize_callback'] = $output['callback']; |
|
556 | + if ( ! isset( $output[ 'sanitize_callback' ] ) && isset( $output[ 'callback' ] ) ) { |
|
557 | + $this->output[ $key ][ 'sanitize_callback' ] = $output[ 'callback' ]; |
|
558 | 558 | } |
559 | 559 | // Convert element arrays to strings. |
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'] ); |
|
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' ] ); |
|
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 | |
@@ -603,23 +603,23 @@ discard block |
||
603 | 603 | |
604 | 604 | // Start going through each item in the $output array. |
605 | 605 | foreach ( $this->output as $output ) { |
606 | - $output['function'] = ( isset( $output['function'] ) ) ? $output['function'] : 'style'; |
|
606 | + $output[ 'function' ] = ( isset( $output[ 'function' ] ) ) ? $output[ 'function' ] : 'style'; |
|
607 | 607 | |
608 | 608 | // If 'element' or 'property' are not defined, skip this. |
609 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
609 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
610 | 610 | continue; |
611 | 611 | } |
612 | - if ( is_array( $output['element'] ) ) { |
|
613 | - $output['element'] = implode( ',', $output['element'] ); |
|
612 | + if ( is_array( $output[ 'element' ] ) ) { |
|
613 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | // If there's a sanitize_callback defined skip this, unless we also have a js_callback defined. |
617 | - if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) && ! isset( $output['js_callback'] ) ) { |
|
617 | + if ( isset( $output[ 'sanitize_callback' ] ) && ! empty( $output[ 'sanitize_callback' ] ) && ! isset( $output[ 'js_callback' ] ) ) { |
|
618 | 618 | continue; |
619 | 619 | } |
620 | 620 | |
621 | 621 | // If we got this far, it's safe to add this. |
622 | - $js_vars[] = $output; |
|
622 | + $js_vars[ ] = $output; |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | // Did we manage to get all the items from 'output'? |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | $variable = ( is_string( $this->variables ) && ! empty( $this->variables ) ) ? $this->variables : false; |
645 | 645 | $this->variables = array(); |
646 | 646 | if ( $variable && empty( $this->variables ) ) { |
647 | - $this->variables[0]['name'] = $variable; |
|
647 | + $this->variables[ 0 ][ 'name' ] = $variable; |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | } |