@@ -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, |
@@ -117,11 +117,11 @@ |
||
117 | 117 | public function get_item( $request ) { |
118 | 118 | $wc_shipping = \WC_Shipping::instance(); |
119 | 119 | $methods = $wc_shipping->get_shipping_methods(); |
120 | - if ( empty( $methods[ $request['id'] ] ) ) { |
|
120 | + if ( empty( $methods[$request['id']] ) ) { |
|
121 | 121 | return new \WP_Error( 'woocommerce_rest_shipping_method_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); |
122 | 122 | } |
123 | 123 | |
124 | - $method = $methods[ $request['id'] ]; |
|
124 | + $method = $methods[$request['id']]; |
|
125 | 125 | $response = $this->prepare_item_for_response( $method, $request ); |
126 | 126 | |
127 | 127 | return rest_ensure_response( $response ); |
@@ -259,15 +259,15 @@ discard block |
||
259 | 259 | * set the parameter's value on the query $prepared_args. |
260 | 260 | */ |
261 | 261 | foreach ( $parameter_mappings as $api_param => $wp_param ) { |
262 | - if ( isset( $registered[ $api_param ], $request[ $api_param ] ) ) { |
|
263 | - $prepared_args[ $wp_param ] = $request[ $api_param ]; |
|
262 | + if ( isset( $registered[$api_param], $request[$api_param] ) ) { |
|
263 | + $prepared_args[$wp_param] = $request[$api_param]; |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Ensure certain parameter values default to empty strings. |
268 | 268 | foreach ( array( 'author_email', 'search' ) as $param ) { |
269 | - if ( ! isset( $prepared_args[ $param ] ) ) { |
|
270 | - $prepared_args[ $param ] = ''; |
|
269 | + if ( ! isset( $prepared_args[$param] ) ) { |
|
270 | + $prepared_args[$param] = ''; |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | $avatar_sizes = rest_get_avatar_sizes(); |
895 | 895 | |
896 | 896 | foreach ( $avatar_sizes as $size ) { |
897 | - $avatar_properties[ $size ] = array( |
|
897 | + $avatar_properties[$size] = array( |
|
898 | 898 | /* translators: %d: avatar image size in pixels */ |
899 | 899 | 'description' => sprintf( __( 'Avatar URL with image size of %d pixels.', 'woocommerce' ), $size ), |
900 | 900 | 'type' => 'string', |
@@ -924,17 +924,17 @@ discard block |
||
924 | 924 | |
925 | 925 | $params['context']['default'] = 'view'; |
926 | 926 | |
927 | - $params['after'] = array( |
|
927 | + $params['after'] = array( |
|
928 | 928 | 'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ), |
929 | 929 | 'type' => 'string', |
930 | 930 | 'format' => 'date-time', |
931 | 931 | ); |
932 | - $params['before'] = array( |
|
932 | + $params['before'] = array( |
|
933 | 933 | 'description' => __( 'Limit response to reviews published before a given ISO8601 compliant date.', 'woocommerce' ), |
934 | 934 | 'type' => 'string', |
935 | 935 | 'format' => 'date-time', |
936 | 936 | ); |
937 | - $params['exclude'] = array( |
|
937 | + $params['exclude'] = array( |
|
938 | 938 | 'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ), |
939 | 939 | 'type' => 'array', |
940 | 940 | 'items' => array( |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | ), |
943 | 943 | 'default' => array(), |
944 | 944 | ); |
945 | - $params['include'] = array( |
|
945 | + $params['include'] = array( |
|
946 | 946 | 'description' => __( 'Limit result set to specific IDs.', 'woocommerce' ), |
947 | 947 | 'type' => 'array', |
948 | 948 | 'items' => array( |
@@ -950,11 +950,11 @@ discard block |
||
950 | 950 | ), |
951 | 951 | 'default' => array(), |
952 | 952 | ); |
953 | - $params['offset'] = array( |
|
953 | + $params['offset'] = array( |
|
954 | 954 | 'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ), |
955 | 955 | 'type' => 'integer', |
956 | 956 | ); |
957 | - $params['order'] = array( |
|
957 | + $params['order'] = array( |
|
958 | 958 | 'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ), |
959 | 959 | 'type' => 'string', |
960 | 960 | 'default' => 'desc', |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | 'desc', |
964 | 964 | ), |
965 | 965 | ); |
966 | - $params['orderby'] = array( |
|
966 | + $params['orderby'] = array( |
|
967 | 967 | 'description' => __( 'Sort collection by object attribute.', 'woocommerce' ), |
968 | 968 | 'type' => 'string', |
969 | 969 | 'default' => 'date_gmt', |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | 'product', |
976 | 976 | ), |
977 | 977 | ); |
978 | - $params['reviewer'] = array( |
|
978 | + $params['reviewer'] = array( |
|
979 | 979 | 'description' => __( 'Limit result set to reviews assigned to specific user IDs.', 'woocommerce' ), |
980 | 980 | 'type' => 'array', |
981 | 981 | 'items' => array( |
@@ -989,13 +989,13 @@ discard block |
||
989 | 989 | 'type' => 'integer', |
990 | 990 | ), |
991 | 991 | ); |
992 | - $params['reviewer_email'] = array( |
|
992 | + $params['reviewer_email'] = array( |
|
993 | 993 | 'default' => null, |
994 | 994 | 'description' => __( 'Limit result set to that from a specific author email.', 'woocommerce' ), |
995 | 995 | 'format' => 'email', |
996 | 996 | 'type' => 'string', |
997 | 997 | ); |
998 | - $params['product'] = array( |
|
998 | + $params['product'] = array( |
|
999 | 999 | 'default' => array(), |
1000 | 1000 | 'description' => __( 'Limit result set to reviews assigned to specific product IDs.', 'woocommerce' ), |
1001 | 1001 | 'type' => 'array', |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | 'type' => 'integer', |
1004 | 1004 | ), |
1005 | 1005 | ); |
1006 | - $params['status'] = array( |
|
1006 | + $params['status'] = array( |
|
1007 | 1007 | 'default' => 'approved', |
1008 | 1008 | 'description' => __( 'Limit result set to reviews assigned a specific status.', 'woocommerce' ), |
1009 | 1009 | 'sanitize_callback' => 'sanitize_key', |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | 'id' => 'tax_rate_id', |
215 | 215 | 'order' => 'tax_rate_order', |
216 | 216 | ); |
217 | - $prepared_args['orderby'] = $orderby_possibles[ $request['orderby'] ]; |
|
217 | + $prepared_args['orderby'] = $orderby_possibles[$request['orderby']]; |
|
218 | 218 | $prepared_args['class'] = $request['class']; |
219 | 219 | $prepared_args['code'] = $request['code']; |
220 | 220 | $prepared_args['include'] = $request['include']; |
@@ -329,12 +329,12 @@ discard block |
||
329 | 329 | $key = 'tax_rate' === $field ? 'rate' : str_replace( 'tax_rate_', '', $field ); |
330 | 330 | |
331 | 331 | // Remove data that was not posted. |
332 | - if ( ! isset( $request[ $key ] ) ) { |
|
332 | + if ( ! isset( $request[$key] ) ) { |
|
333 | 333 | continue; |
334 | 334 | } |
335 | 335 | |
336 | 336 | // Test new data against current data. |
337 | - if ( $current && $current->$field === $request[ $key ] ) { |
|
337 | + if ( $current && $current->$field === $request[$key] ) { |
|
338 | 338 | continue; |
339 | 339 | } |
340 | 340 | |
@@ -344,13 +344,13 @@ discard block |
||
344 | 344 | case 'tax_rate_compound': |
345 | 345 | case 'tax_rate_shipping': |
346 | 346 | case 'tax_rate_order': |
347 | - $data[ $field ] = absint( $request[ $key ] ); |
|
347 | + $data[$field] = absint( $request[$key] ); |
|
348 | 348 | break; |
349 | 349 | case 'tax_rate_class': |
350 | - $data[ $field ] = 'standard' !== $request['tax_rate_class'] ? $request['tax_rate_class'] : ''; |
|
350 | + $data[$field] = 'standard' !== $request['tax_rate_class'] ? $request['tax_rate_class'] : ''; |
|
351 | 351 | break; |
352 | 352 | default: |
353 | - $data[ $field ] = wc_clean( $request[ $key ] ); |
|
353 | + $data[$field] = wc_clean( $request[$key] ); |
|
354 | 354 | break; |
355 | 355 | } |
356 | 356 | } |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | |
544 | 544 | if ( ! is_wp_error( $tax ) && ! is_null( $tax ) ) { |
545 | 545 | foreach ( $locales as $locale ) { |
546 | - $data[ $locale->location_type ] = $locale->location_code; |
|
546 | + $data[$locale->location_type] = $locale->location_code; |
|
547 | 547 | } |
548 | 548 | } |
549 | 549 | |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | 'type' => 'string', |
728 | 728 | 'validate_callback' => 'rest_validate_request_arg', |
729 | 729 | ); |
730 | - $params['code'] = array( |
|
730 | + $params['code'] = array( |
|
731 | 731 | 'description' => __( 'Search by similar tax code.', 'woocommerce' ), |
732 | 732 | 'type' => 'string', |
733 | 733 | 'validate_callback' => 'rest_validate_request_arg', |
@@ -37,8 +37,8 @@ |
||
37 | 37 | public function register_rest_routes() { |
38 | 38 | foreach ( $this->get_rest_namespaces() as $namespace => $controllers ) { |
39 | 39 | foreach ( $controllers as $controller_name => $controller_class ) { |
40 | - $this->controllers[ $namespace ][ $controller_name ] = new $controller_class(); |
|
41 | - $this->controllers[ $namespace ][ $controller_name ]->register_routes(); |
|
40 | + $this->controllers[$namespace][$controller_name] = new $controller_class(); |
|
41 | + $this->controllers[$namespace][$controller_name]->register_routes(); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
@@ -236,10 +236,10 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function get_item( $request ) { |
238 | 238 | $tools = $this->get_tools(); |
239 | - if ( empty( $tools[ $request['id'] ] ) ) { |
|
239 | + if ( empty( $tools[$request['id']] ) ) { |
|
240 | 240 | return new \WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
241 | 241 | } |
242 | - $tool = $tools[ $request['id'] ]; |
|
242 | + $tool = $tools[$request['id']]; |
|
243 | 243 | return rest_ensure_response( |
244 | 244 | $this->prepare_item_for_response( |
245 | 245 | array( |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public function update_item( $request ) { |
263 | 263 | $tools = $this->get_tools(); |
264 | - if ( empty( $tools[ $request['id'] ] ) ) { |
|
264 | + if ( empty( $tools[$request['id']] ) ) { |
|
265 | 265 | return new \WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
266 | 266 | } |
267 | 267 | |
268 | - $tool = $tools[ $request['id'] ]; |
|
268 | + $tool = $tools[$request['id']]; |
|
269 | 269 | $tool = array( |
270 | 270 | 'id' => $request['id'], |
271 | 271 | 'name' => $tool['name'], |
@@ -411,11 +411,11 @@ discard block |
||
411 | 411 | $tools = $this->get_tools(); |
412 | 412 | |
413 | 413 | try { |
414 | - if ( ! isset( $tools[ $tool ] ) ) { |
|
414 | + if ( ! isset( $tools[$tool] ) ) { |
|
415 | 415 | throw new Exception( __( 'There was an error calling this tool. There is no callback present.', 'woocommerce' ) ); |
416 | 416 | } |
417 | 417 | |
418 | - $callback = isset( $tools[ $tool ]['callback'] ) ? $tools[ $tool ]['callback'] : array( $this, $tool ); |
|
418 | + $callback = isset( $tools[$tool]['callback'] ) ? $tools[$tool]['callback'] : array( $this, $tool ); |
|
419 | 419 | |
420 | 420 | if ( ! is_callable( $callback ) ) { |
421 | 421 | throw new Exception( __( 'There was an error calling this tool. Invalid callback.', 'woocommerce' ) ); |
@@ -572,7 +572,7 @@ |
||
572 | 572 | protected function clear_sessions() { |
573 | 573 | global $wpdb; |
574 | 574 | |
575 | - $wpdb->query( "TRUNCATE {$wpdb->prefix}woocommerce_sessions" ); |
|
575 | + $wpdb->query( "truncate {$wpdb->prefix}woocommerce_sessions" ); |
|
576 | 576 | $result = absint( $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key='_woocommerce_persistent_cart_" . get_current_blog_id() . "';" ) ); // WPCS: unprepared SQL ok. |
577 | 577 | wp_cache_flush(); |
578 | 578 | /* translators: %d: amount of sessions */ |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * Register the routes for customers. |
28 | 28 | */ |
29 | 29 | public function register_routes() { |
30 | - $this->register_items_route( [ 'read' ] ); |
|
30 | + $this->register_items_route( ['read'] ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |