@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | // Format date values. |
241 | 241 | foreach ( $format_date as $key ) { |
242 | 242 | // Date created is stored UTC, date modified is stored WP local time. |
243 | - $datetime = 'date_created' === $key ? get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $data[ $key ]->getTimestamp() ) ) : $data[ $key ]; |
|
244 | - $data[ $key ] = wc_rest_prepare_date_response( $datetime, false ); |
|
245 | - $data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime ); |
|
243 | + $datetime = 'date_created' === $key ? get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $data[$key]->getTimestamp() ) ) : $data[$key]; |
|
244 | + $data[$key] = wc_rest_prepare_date_response( $datetime, false ); |
|
245 | + $data[$key . '_gmt'] = wc_rest_prepare_date_response( $datetime ); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | return array( |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | 'name' => 'display_name', |
288 | 288 | 'registered_date' => 'registered', |
289 | 289 | ); |
290 | - $prepared_args['orderby'] = $orderby_possibles[ $request['orderby'] ]; |
|
290 | + $prepared_args['orderby'] = $orderby_possibles[$request['orderby']]; |
|
291 | 291 | $prepared_args['search'] = $request['search']; |
292 | 292 | |
293 | 293 | if ( '' !== $prepared_args['search'] ) { |
@@ -604,8 +604,8 @@ discard block |
||
604 | 604 | // Customer billing address. |
605 | 605 | if ( isset( $request['billing'] ) ) { |
606 | 606 | foreach ( array_keys( $schema['properties']['billing']['properties'] ) as $field ) { |
607 | - if ( isset( $request['billing'][ $field ] ) && is_callable( array( $customer, "set_billing_{$field}" ) ) ) { |
|
608 | - $customer->{"set_billing_{$field}"}( $request['billing'][ $field ] ); |
|
607 | + if ( isset( $request['billing'][$field] ) && is_callable( array( $customer, "set_billing_{$field}" ) ) ) { |
|
608 | + $customer->{"set_billing_{$field}"}( $request['billing'][$field] ); |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 | } |
@@ -613,8 +613,8 @@ discard block |
||
613 | 613 | // Customer shipping address. |
614 | 614 | if ( isset( $request['shipping'] ) ) { |
615 | 615 | foreach ( array_keys( $schema['properties']['shipping']['properties'] ) as $field ) { |
616 | - if ( isset( $request['shipping'][ $field ] ) && is_callable( array( $customer, "set_shipping_{$field}" ) ) ) { |
|
617 | - $customer->{"set_shipping_{$field}"}( $request['shipping'][ $field ] ); |
|
616 | + if ( isset( $request['shipping'][$field] ) && is_callable( array( $customer, "set_shipping_{$field}" ) ) ) { |
|
617 | + $customer->{"set_shipping_{$field}"}( $request['shipping'][$field] ); |
|
618 | 618 | } |
619 | 619 | } |
620 | 620 | } |
@@ -309,17 +309,17 @@ discard block |
||
309 | 309 | $instance_settings = $method->instance_settings; |
310 | 310 | $errors_found = false; |
311 | 311 | foreach ( $method->get_instance_form_fields() as $key => $field ) { |
312 | - if ( isset( $request['settings'][ $key ] ) ) { |
|
312 | + if ( isset( $request['settings'][$key] ) ) { |
|
313 | 313 | if ( is_callable( array( $this, 'validate_setting_' . $field['type'] . '_field' ) ) ) { |
314 | - $value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][ $key ], $field ); |
|
314 | + $value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][$key], $field ); |
|
315 | 315 | } else { |
316 | - $value = $this->validate_setting_text_field( $request['settings'][ $key ], $field ); |
|
316 | + $value = $this->validate_setting_text_field( $request['settings'][$key], $field ); |
|
317 | 317 | } |
318 | 318 | if ( is_wp_error( $value ) ) { |
319 | 319 | $errors_found = true; |
320 | 320 | break; |
321 | 321 | } |
322 | - $instance_settings[ $key ] = $value; |
|
322 | + $instance_settings[$key] = $value; |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | 'label' => $field['title'], |
398 | 398 | 'description' => empty( $field['description'] ) ? '' : $field['description'], |
399 | 399 | 'type' => $field['type'], |
400 | - 'value' => $item->instance_settings[ $id ], |
|
400 | + 'value' => $item->instance_settings[$id], |
|
401 | 401 | 'default' => empty( $field['default'] ) ? '' : $field['default'], |
402 | 402 | 'tip' => empty( $field['description'] ) ? '' : $field['description'], |
403 | 403 | 'placeholder' => empty( $field['placeholder'] ) ? '' : $field['placeholder'], |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | if ( ! empty( $field['options'] ) ) { |
406 | 406 | $data['options'] = $field['options']; |
407 | 407 | } |
408 | - $settings[ $id ] = $data; |
|
408 | + $settings[$id] = $data; |
|
409 | 409 | } |
410 | 410 | return $settings; |
411 | 411 | } |
@@ -46,25 +46,25 @@ |
||
46 | 46 | public function get_public_item_schema() { |
47 | 47 | $schema = parent::get_public_item_schema(); |
48 | 48 | |
49 | - $schema['properties']['blog'] = array( |
|
49 | + $schema['properties']['blog'] = array( |
|
50 | 50 | 'description' => __( 'Blog id of the record on the multisite.', 'woocommerce' ), |
51 | 51 | 'type' => 'integer', |
52 | 52 | 'context' => array( 'view' ), |
53 | 53 | 'readonly' => true, |
54 | 54 | ); |
55 | - $schema['properties']['edit_url'] = array( |
|
55 | + $schema['properties']['edit_url'] = array( |
|
56 | 56 | 'description' => __( 'URL to edit the order', 'woocommerce' ), |
57 | 57 | 'type' => 'string', |
58 | 58 | 'context' => array( 'view' ), |
59 | 59 | 'readonly' => true, |
60 | 60 | ); |
61 | - $schema['properties']['customer'][] = array( |
|
61 | + $schema['properties']['customer'][] = array( |
|
62 | 62 | 'description' => __( 'Name of the customer for the order', 'woocommerce' ), |
63 | 63 | 'type' => 'string', |
64 | 64 | 'context' => array( 'view' ), |
65 | 65 | 'readonly' => true, |
66 | 66 | ); |
67 | - $schema['properties']['status_name'][] = array( |
|
67 | + $schema['properties']['status_name'][] = array( |
|
68 | 68 | 'description' => __( 'Order Status', 'woocommerce' ), |
69 | 69 | 'type' => 'string', |
70 | 70 | 'context' => array( 'view' ), |
@@ -166,17 +166,17 @@ discard block |
||
166 | 166 | if ( isset( $request['settings'] ) ) { |
167 | 167 | $errors_found = false; |
168 | 168 | foreach ( $gateway->form_fields as $key => $field ) { |
169 | - if ( isset( $request['settings'][ $key ] ) ) { |
|
169 | + if ( isset( $request['settings'][$key] ) ) { |
|
170 | 170 | if ( is_callable( array( $this, 'validate_setting_' . $field['type'] . '_field' ) ) ) { |
171 | - $value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][ $key ], $field ); |
|
171 | + $value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][$key], $field ); |
|
172 | 172 | } else { |
173 | - $value = $this->validate_setting_text_field( $request['settings'][ $key ], $field ); |
|
173 | + $value = $this->validate_setting_text_field( $request['settings'][$key], $field ); |
|
174 | 174 | } |
175 | 175 | if ( is_wp_error( $value ) ) { |
176 | 176 | $errors_found = true; |
177 | 177 | break; |
178 | 178 | } |
179 | - $settings[ $key ] = $value; |
|
179 | + $settings[$key] = $value; |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | // Update order. |
211 | 211 | if ( isset( $request['order'] ) ) { |
212 | 212 | $order = (array) get_option( 'woocommerce_gateway_order' ); |
213 | - $order[ $gateway->id ] = $request['order']; |
|
213 | + $order[$gateway->id] = $request['order']; |
|
214 | 214 | update_option( 'woocommerce_gateway_order', $order ); |
215 | 215 | $gateway->order = absint( $request['order'] ); |
216 | 216 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | 'id' => $gateway->id, |
252 | 252 | 'title' => $gateway->title, |
253 | 253 | 'description' => $gateway->description, |
254 | - 'order' => isset( $order[ $gateway->id ] ) ? $order[ $gateway->id ] : '', |
|
254 | + 'order' => isset( $order[$gateway->id] ) ? $order[$gateway->id] : '', |
|
255 | 255 | 'enabled' => ( 'yes' === $gateway->enabled ), |
256 | 256 | 'method_title' => $gateway->get_method_title(), |
257 | 257 | 'method_description' => $gateway->get_method_description(), |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | 'label' => empty( $field['label'] ) ? $field['title'] : $field['label'], |
303 | 303 | 'description' => empty( $field['description'] ) ? '' : $field['description'], |
304 | 304 | 'type' => $field['type'], |
305 | - 'value' => empty( $gateway->settings[ $id ] ) ? '' : $gateway->settings[ $id ], |
|
305 | + 'value' => empty( $gateway->settings[$id] ) ? '' : $gateway->settings[$id], |
|
306 | 306 | 'default' => empty( $field['default'] ) ? '' : $field['default'], |
307 | 307 | 'tip' => empty( $field['description'] ) ? '' : $field['description'], |
308 | 308 | 'placeholder' => empty( $field['placeholder'] ) ? '' : $field['placeholder'], |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | if ( ! empty( $field['options'] ) ) { |
311 | 311 | $data['options'] = $field['options']; |
312 | 312 | } |
313 | - $settings[ $id ] = $data; |
|
313 | + $settings[$id] = $data; |
|
314 | 314 | } |
315 | 315 | return $settings; |
316 | 316 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | |
91 | 91 | $currency = array( |
92 | 92 | 'code' => $code, |
93 | - 'name' => $currencies[ $code ], |
|
93 | + 'name' => $currencies[$code], |
|
94 | 94 | 'symbol' => get_woocommerce_currency_symbol( $code ), |
95 | 95 | ); |
96 | 96 |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | - $continent_list = $continents[ $continent_code ]; |
|
85 | + $continent_list = $continents[$continent_code]; |
|
86 | 86 | |
87 | 87 | $continent = array( |
88 | 88 | 'code' => $continent_code, |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | |
92 | 92 | $local_countries = array(); |
93 | 93 | foreach ( $continent_list['countries'] as $country_code ) { |
94 | - if ( isset( $countries[ $country_code ] ) ) { |
|
94 | + if ( isset( $countries[$country_code] ) ) { |
|
95 | 95 | $country = array( |
96 | 96 | 'code' => $country_code, |
97 | - 'name' => $countries[ $country_code ], |
|
97 | + 'name' => $countries[$country_code], |
|
98 | 98 | ); |
99 | 99 | |
100 | 100 | // If we have detailed locale information include that in the response. |
101 | 101 | if ( array_key_exists( $country_code, $locale_info ) ) { |
102 | 102 | // Defensive programming against unexpected changes in locale-info.php. |
103 | 103 | $country_data = wp_parse_args( |
104 | - $locale_info[ $country_code ], |
|
104 | + $locale_info[$country_code], |
|
105 | 105 | array( |
106 | 106 | 'currency_code' => 'USD', |
107 | 107 | 'currency_pos' => 'left', |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | $local_states = array(); |
120 | - if ( isset( $states[ $country_code ] ) ) { |
|
121 | - foreach ( $states[ $country_code ] as $state_code => $state_name ) { |
|
120 | + if ( isset( $states[$country_code] ) ) { |
|
121 | + foreach ( $states[$country_code] as $state_code => $state_name ) { |
|
122 | 122 | $local_states[] = array( |
123 | 123 | 'code' => $state_code, |
124 | 124 | 'name' => $state_name, |
@@ -81,12 +81,12 @@ |
||
81 | 81 | |
82 | 82 | $country = array( |
83 | 83 | 'code' => $country_code, |
84 | - 'name' => $countries[ $country_code ], |
|
84 | + 'name' => $countries[$country_code], |
|
85 | 85 | ); |
86 | 86 | |
87 | 87 | $local_states = array(); |
88 | - if ( isset( $states[ $country_code ] ) ) { |
|
89 | - foreach ( $states[ $country_code ] as $state_code => $state_name ) { |
|
88 | + if ( isset( $states[$country_code] ) ) { |
|
89 | + foreach ( $states[$country_code] as $state_code => $state_name ) { |
|
90 | 90 | $local_states[] = array( |
91 | 91 | 'code' => $state_code, |
92 | 92 | 'name' => $state_name, |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | // Get the option value. |
173 | 173 | if ( is_array( $option_key ) ) { |
174 | 174 | $option = get_option( $option_key[0] ); |
175 | - $setting['value'] = isset( $option[ $option_key[1] ] ) ? $option[ $option_key[1] ] : $default; |
|
175 | + $setting['value'] = isset( $option[$option_key[1]] ) ? $option[$option_key[1]] : $default; |
|
176 | 176 | } else { |
177 | 177 | $admin_setting_value = \WC_Admin_Settings::get_option( $option_key, $default ); |
178 | 178 | $setting['value'] = $admin_setting_value; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $setting['type'] = 'select'; |
186 | 186 | $setting['options'] = $this->get_countries_and_states(); |
187 | 187 | } elseif ( 'single_select_page' === $setting['type'] ) { |
188 | - $pages = get_pages( |
|
188 | + $pages = get_pages( |
|
189 | 189 | array( |
190 | 190 | 'sort_column' => 'menu_order', |
191 | 191 | 'sort_order' => 'ASC', |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | ); |
195 | 195 | $options = array(); |
196 | 196 | foreach ( $pages as $page ) { |
197 | - $options[ $page->ID ] = ! empty( $page->post_title ) ? $page->post_title : '#' . $page->ID; |
|
197 | + $options[$page->ID] = ! empty( $page->post_title ) ? $page->post_title : '#' . $page->ID; |
|
198 | 198 | } |
199 | 199 | $setting['type'] = 'select'; |
200 | 200 | $setting['options'] = $options; |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | |
224 | 224 | if ( $states ) { |
225 | 225 | foreach ( $states as $state_key => $state_value ) { |
226 | - $output[ $key . ':' . $state_key ] = $value . ' - ' . $state_value; |
|
226 | + $output[$key . ':' . $state_key] = $value . ' - ' . $state_value; |
|
227 | 227 | } |
228 | 228 | } else { |
229 | - $output[ $key ] = $value; |
|
229 | + $output[$key] = $value; |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | return $output; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | return new \WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce' ), array( 'status' => 404 ) ); |
258 | 258 | } |
259 | 259 | |
260 | - $setting = $settings[ $array_key[0] ]; |
|
260 | + $setting = $settings[$array_key[0]]; |
|
261 | 261 | |
262 | 262 | if ( ! $this->is_setting_type_valid( $setting['type'] ) ) { |
263 | 263 | return new \WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce' ), array( 'status' => 404 ) ); |
@@ -327,11 +327,11 @@ discard block |
||
327 | 327 | $setting['value'] = $value; |
328 | 328 | $option_key = $setting['option_key']; |
329 | 329 | $prev = get_option( $option_key[0] ); |
330 | - $prev[ $option_key[1] ] = $request['value']; |
|
330 | + $prev[$option_key[1]] = $request['value']; |
|
331 | 331 | update_option( $option_key[0], $prev ); |
332 | 332 | } else { |
333 | 333 | $update_data = array(); |
334 | - $update_data[ $setting['option_key'] ] = $value; |
|
334 | + $update_data[$setting['option_key']] = $value; |
|
335 | 335 | $setting['value'] = $value; |
336 | 336 | \WC_Admin_Settings::save_fields( array( $setting ), $update_data ); |
337 | 337 | } |
@@ -447,10 +447,10 @@ discard block |
||
447 | 447 | */ |
448 | 448 | public function cast_image_width( $setting ) { |
449 | 449 | foreach ( array( 'default', 'value' ) as $key ) { |
450 | - if ( isset( $setting[ $key ] ) ) { |
|
451 | - $setting[ $key ]['width'] = intval( $setting[ $key ]['width'] ); |
|
452 | - $setting[ $key ]['height'] = intval( $setting[ $key ]['height'] ); |
|
453 | - $setting[ $key ]['crop'] = (bool) $setting[ $key ]['crop']; |
|
450 | + if ( isset( $setting[$key] ) ) { |
|
451 | + $setting[$key]['width'] = intval( $setting[$key]['width'] ); |
|
452 | + $setting[$key]['height'] = intval( $setting[$key]['height'] ); |
|
453 | + $setting[$key]['crop'] = (bool) $setting[$key]['crop']; |
|
454 | 454 | } |
455 | 455 | } |
456 | 456 | return $setting; |
@@ -490,17 +490,17 @@ discard block |
||
490 | 490 | public function is_setting_type_valid( $type ) { |
491 | 491 | return in_array( |
492 | 492 | $type, array( |
493 | - 'text', // Validates with validate_setting_text_field. |
|
494 | - 'email', // Validates with validate_setting_text_field. |
|
495 | - 'number', // Validates with validate_setting_text_field. |
|
496 | - 'color', // Validates with validate_setting_text_field. |
|
497 | - 'password', // Validates with validate_setting_text_field. |
|
498 | - 'textarea', // Validates with validate_setting_textarea_field. |
|
499 | - 'select', // Validates with validate_setting_select_field. |
|
500 | - 'multiselect', // Validates with validate_setting_multiselect_field. |
|
501 | - 'radio', // Validates with validate_setting_radio_field (-> validate_setting_select_field). |
|
502 | - 'checkbox', // Validates with validate_setting_checkbox_field. |
|
503 | - 'image_width', // Validates with validate_setting_image_width_field. |
|
493 | + 'text', // Validates with validate_setting_text_field. |
|
494 | + 'email', // Validates with validate_setting_text_field. |
|
495 | + 'number', // Validates with validate_setting_text_field. |
|
496 | + 'color', // Validates with validate_setting_text_field. |
|
497 | + 'password', // Validates with validate_setting_text_field. |
|
498 | + 'textarea', // Validates with validate_setting_textarea_field. |
|
499 | + 'select', // Validates with validate_setting_select_field. |
|
500 | + 'multiselect', // Validates with validate_setting_multiselect_field. |
|
501 | + 'radio', // Validates with validate_setting_radio_field (-> validate_setting_select_field). |
|
502 | + 'checkbox', // Validates with validate_setting_checkbox_field. |
|
503 | + 'image_width', // Validates with validate_setting_image_width_field. |
|
504 | 504 | 'thumbnail_cropping', // Validates with validate_setting_text_field. |
505 | 505 | ) |
506 | 506 | ); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | continue; |
69 | 69 | } |
70 | 70 | |
71 | - $schema['properties'][ $field_name ] = $field_options['schema']; |
|
71 | + $schema['properties'][$field_name] = $field_options['schema']; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | $schema['properties'] = apply_filters( 'woocommerce_rest_' . $object_type . '_schema', $schema['properties'] ); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $schema = $this->get_public_item_schema(); |
149 | 149 | foreach ( $schema['properties'] as $arg => $options ) { |
150 | 150 | if ( isset( $options['default'] ) ) { |
151 | - $defaults[ $arg ] = $options['default']; |
|
151 | + $defaults[$arg] = $options['default']; |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | $_item->set_default_params( $defaults ); |