@@ -494,7 +494,7 @@ |
||
494 | 494 | break; |
495 | 495 | |
496 | 496 | case 'clear_sessions': |
497 | - $wpdb->query( "TRUNCATE {$wpdb->prefix}woocommerce_sessions" ); |
|
497 | + $wpdb->query( "truncate {$wpdb->prefix}woocommerce_sessions" ); |
|
498 | 498 | $result = absint( $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key='_woocommerce_persistent_cart_" . get_current_blog_id() . "';" ) ); // WPCS: unprepared SQL ok. |
499 | 499 | wp_cache_flush(); |
500 | 500 | /* translators: %d: amount of sessions */ |
@@ -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'], |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | |
529 | 529 | default: |
530 | 530 | $tools = $this->get_tools(); |
531 | - if ( isset( $tools[ $tool ]['callback'] ) ) { |
|
532 | - $callback = $tools[ $tool ]['callback']; |
|
531 | + if ( isset( $tools[$tool]['callback'] ) ) { |
|
532 | + $callback = $tools[$tool]['callback']; |
|
533 | 533 | $return = call_user_func( $callback ); |
534 | 534 | if ( is_string( $return ) ) { |
535 | 535 | $message = $return; |
@@ -76,7 +76,7 @@ |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | if ( array_key_exists( $class, self::$classmap ) ) { |
79 | - return include self::$classmap[ $class ]; |
|
79 | + return include self::$classmap[$class]; |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
@@ -141,19 +141,19 @@ discard block |
||
141 | 141 | |
142 | 142 | // Format decimal values. |
143 | 143 | foreach ( $format_decimal as $key ) { |
144 | - $data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] ); |
|
144 | + $data[$key] = wc_format_decimal( $data[$key], $this->request['dp'] ); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | // Format date values. |
148 | 148 | foreach ( $format_date as $key ) { |
149 | - $datetime = $data[ $key ]; |
|
150 | - $data[ $key ] = wc_rest_prepare_date_response( $datetime, false ); |
|
151 | - $data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime ); |
|
149 | + $datetime = $data[$key]; |
|
150 | + $data[$key] = wc_rest_prepare_date_response( $datetime, false ); |
|
151 | + $data[$key . '_gmt'] = wc_rest_prepare_date_response( $datetime ); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | // Format line items. |
155 | 155 | foreach ( $format_line_items as $key ) { |
156 | - $data[ $key ] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[ $key ] ) ); |
|
156 | + $data[$key] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[$key] ) ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | return array( |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | $line_tax = array(); |
295 | 295 | |
296 | 296 | foreach ( $item_line_taxes['total'] as $tax_rate_id => $tax ) { |
297 | - $line_tax[ $tax_rate_id ] = array( |
|
297 | + $line_tax[$tax_rate_id] = array( |
|
298 | 298 | 'id' => $tax_rate_id, |
299 | 299 | 'total' => $tax, |
300 | 300 | 'subtotal' => '', |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | } |
303 | 303 | |
304 | 304 | foreach ( $item_line_taxes['subtotal'] as $tax_rate_id => $tax ) { |
305 | - $line_tax[ $tax_rate_id ]['subtotal'] = $tax; |
|
305 | + $line_tax[$tax_rate_id]['subtotal'] = $tax; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | $line_item['taxes'] = array_values( $line_tax ); |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | |
70 | 70 | foreach ( $mappings as $section => $values ) { |
71 | 71 | foreach ( $values as $key => $value ) { |
72 | - if ( isset( $schema['properties'][ $section ]['properties'][ $key ]['type'] ) ) { |
|
73 | - settype( $values[ $key ], $schema['properties'][ $section ]['properties'][ $key ]['type'] ); |
|
72 | + if ( isset( $schema['properties'][$section]['properties'][$key]['type'] ) ) { |
|
73 | + settype( $values[$key], $schema['properties'][$section]['properties'][$key]['type'] ); |
|
74 | 74 | } |
75 | 75 | } |
76 | - settype( $values, $schema['properties'][ $section ]['type'] ); |
|
77 | - $response[ $section ] = $values; |
|
76 | + settype( $values, $schema['properties'][$section]['type'] ); |
|
77 | + $response[$section] = $values; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $response = $this->prepare_item_for_response( $response, $request ); |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | } |
765 | 765 | $table_type = in_array( $table->name, $core_tables, true ) ? 'woocommerce' : 'other'; |
766 | 766 | |
767 | - $tables[ $table_type ][ $table->name ] = array( |
|
767 | + $tables[$table_type][$table->name] = array( |
|
768 | 768 | 'data' => $table->data, |
769 | 769 | 'index' => $table->index, |
770 | 770 | 'engine' => $table->engine, |
@@ -880,8 +880,8 @@ discard block |
||
880 | 880 | $version_latest = $data['Version']; |
881 | 881 | |
882 | 882 | // Find latest version. |
883 | - if ( isset( $this->available_updates[ $plugin ]->update->new_version ) ) { |
|
884 | - $version_latest = $this->available_updates[ $plugin ]->update->new_version; |
|
883 | + if ( isset( $this->available_updates[$plugin]->update->new_version ) ) { |
|
884 | + $version_latest = $this->available_updates[$plugin]->update->new_version; |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | return array( |
@@ -1023,14 +1023,14 @@ discard block |
||
1023 | 1023 | $term_response = array(); |
1024 | 1024 | $terms = get_terms( 'product_type', array( 'hide_empty' => 0 ) ); |
1025 | 1025 | foreach ( $terms as $term ) { |
1026 | - $term_response[ $term->slug ] = strtolower( $term->name ); |
|
1026 | + $term_response[$term->slug] = strtolower( $term->name ); |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | // Get a list of terms used for product visibility. |
1030 | 1030 | $product_visibility_terms = array(); |
1031 | 1031 | $terms = get_terms( 'product_visibility', array( 'hide_empty' => 0 ) ); |
1032 | 1032 | foreach ( $terms as $term ) { |
1033 | - $product_visibility_terms[ $term->slug ] = strtolower( $term->name ); |
|
1033 | + $product_visibility_terms[$term->slug] = strtolower( $term->name ); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | // Check if WooCommerce.com account is connected. |
@@ -148,19 +148,19 @@ discard block |
||
148 | 148 | |
149 | 149 | // Format decimal values. |
150 | 150 | foreach ( $format_decimal as $key ) { |
151 | - $data[ $key ] = wc_format_decimal( $data[ $key ], 2 ); |
|
151 | + $data[$key] = wc_format_decimal( $data[$key], 2 ); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | // Format date values. |
155 | 155 | foreach ( $format_date as $key ) { |
156 | - $datetime = $data[ $key ]; |
|
157 | - $data[ $key ] = wc_rest_prepare_date_response( $datetime, false ); |
|
158 | - $data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime ); |
|
156 | + $datetime = $data[$key]; |
|
157 | + $data[$key] = wc_rest_prepare_date_response( $datetime, false ); |
|
158 | + $data[$key . '_gmt'] = wc_rest_prepare_date_response( $datetime ); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | // Format null values. |
162 | 162 | foreach ( $format_null as $key ) { |
163 | - $data[ $key ] = $data[ $key ] ? $data[ $key ] : null; |
|
163 | + $data[$key] = $data[$key] ? $data[$key] : null; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | return array( |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | // Handle all writable props. |
268 | 268 | foreach ( $data_keys as $key ) { |
269 | - $value = $request[ $key ]; |
|
269 | + $value = $request[$key]; |
|
270 | 270 | |
271 | 271 | if ( ! is_null( $value ) ) { |
272 | 272 | switch ( $key ) { |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | |
156 | 156 | // Format decimal values. |
157 | 157 | foreach ( $format_decimal as $key ) { |
158 | - if ( isset( $data[ $key ] ) ) { |
|
159 | - $data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] ); |
|
158 | + if ( isset( $data[$key] ) ) { |
|
159 | + $data[$key] = wc_format_decimal( $data[$key], $this->request['dp'] ); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $taxes[] = array( |
175 | 175 | 'id' => $tax_rate_id, |
176 | 176 | 'total' => $tax, |
177 | - 'subtotal' => isset( $data['taxes']['subtotal'][ $tax_rate_id ] ) ? $data['taxes']['subtotal'][ $tax_rate_id ] : '', |
|
177 | + 'subtotal' => isset( $data['taxes']['subtotal'][$tax_rate_id] ) ? $data['taxes']['subtotal'][$tax_rate_id] : '', |
|
178 | 178 | ); |
179 | 179 | } |
180 | 180 | $data['taxes'] = $taxes; |
@@ -209,14 +209,14 @@ discard block |
||
209 | 209 | |
210 | 210 | // Format decimal values. |
211 | 211 | foreach ( $format_decimal as $key ) { |
212 | - $data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] ); |
|
212 | + $data[$key] = wc_format_decimal( $data[$key], $this->request['dp'] ); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | // Format date values. |
216 | 216 | foreach ( $format_date as $key ) { |
217 | - $datetime = $data[ $key ]; |
|
218 | - $data[ $key ] = wc_rest_prepare_date_response( $datetime, false ); |
|
219 | - $data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime ); |
|
217 | + $datetime = $data[$key]; |
|
218 | + $data[$key] = wc_rest_prepare_date_response( $datetime, false ); |
|
219 | + $data[$key . '_gmt'] = wc_rest_prepare_date_response( $datetime ); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | // Format the order status. |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | // Format line items. |
226 | 226 | foreach ( $format_line_items as $key ) { |
227 | - $data[ $key ] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[ $key ] ) ); |
|
227 | + $data[$key] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[$key] ) ); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | // Refunds. |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | |
474 | 474 | // Handle all writable props. |
475 | 475 | foreach ( $data_keys as $key ) { |
476 | - $value = $request[ $key ]; |
|
476 | + $value = $request[$key]; |
|
477 | 477 | |
478 | 478 | if ( ! is_null( $value ) ) { |
479 | 479 | switch ( $key ) { |
@@ -639,8 +639,8 @@ discard block |
||
639 | 639 | * @param array $posted Request data. |
640 | 640 | */ |
641 | 641 | protected function maybe_set_item_prop( $item, $prop, $posted ) { |
642 | - if ( isset( $posted[ $prop ] ) ) { |
|
643 | - $item->{"set_$prop"}( $posted[ $prop ] ); |
|
642 | + if ( isset( $posted[$prop] ) ) { |
|
643 | + $item->{"set_$prop"}( $posted[$prop] ); |
|
644 | 644 | } |
645 | 645 | } |
646 | 646 | |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | $keys = array( 'product_id', 'method_id', 'method_title', 'name', 'code' ); |
832 | 832 | |
833 | 833 | foreach ( $keys as $key ) { |
834 | - if ( array_key_exists( $key, $item ) && is_null( $item[ $key ] ) ) { |
|
834 | + if ( array_key_exists( $key, $item ) && is_null( $item[$key] ) ) { |
|
835 | 835 | return true; |
836 | 836 | } |
837 | 837 | } |
@@ -1707,7 +1707,7 @@ discard block |
||
1707 | 1707 | public function get_collection_params() { |
1708 | 1708 | $params = parent::get_collection_params(); |
1709 | 1709 | |
1710 | - $params['status'] = array( |
|
1710 | + $params['status'] = array( |
|
1711 | 1711 | 'default' => 'any', |
1712 | 1712 | 'description' => __( 'Limit result set to orders which have specific statuses.', 'woocommerce' ), |
1713 | 1713 | 'type' => 'array', |
@@ -1723,13 +1723,13 @@ discard block |
||
1723 | 1723 | 'sanitize_callback' => 'absint', |
1724 | 1724 | 'validate_callback' => 'rest_validate_request_arg', |
1725 | 1725 | ); |
1726 | - $params['product'] = array( |
|
1726 | + $params['product'] = array( |
|
1727 | 1727 | 'description' => __( 'Limit result set to orders assigned a specific product.', 'woocommerce' ), |
1728 | 1728 | 'type' => 'integer', |
1729 | 1729 | 'sanitize_callback' => 'absint', |
1730 | 1730 | 'validate_callback' => 'rest_validate_request_arg', |
1731 | 1731 | ); |
1732 | - $params['dp'] = array( |
|
1732 | + $params['dp'] = array( |
|
1733 | 1733 | 'default' => wc_get_price_decimals(), |
1734 | 1734 | 'description' => __( 'Number of decimal points to use in each resource.', 'woocommerce' ), |
1735 | 1735 | 'type' => 'integer', |
@@ -232,7 +232,7 @@ |
||
232 | 232 | foreach ( $classes as $key => $class ) { |
233 | 233 | if ( sanitize_title( $class ) === $tax_class['slug'] ) { |
234 | 234 | $tax_class['name'] = $class; |
235 | - unset( $classes[ $key ] ); |
|
235 | + unset( $classes[$key] ); |
|
236 | 236 | $deleted = true; |
237 | 237 | break; |
238 | 238 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $max_pages = ceil( $total_terms / $per_page ); |
354 | 354 | $response->header( 'X-WP-TotalPages', (int) $max_pages ); |
355 | 355 | |
356 | - $base = str_replace( '(?P<attribute_id>[\d]+)', $request['attribute_id'], $this->rest_base ); |
|
356 | + $base = str_replace( '(?P<attribute_id>[\d]+)', $request['attribute_id'], $this->rest_base ); |
|
357 | 357 | $base = add_query_arg( $request->get_query_params(), rest_url( '/' . $this->namespace . '/' . $base ) ); |
358 | 358 | if ( $page > 1 ) { |
359 | 359 | $prev_page = $page - 1; |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | 'validate_callback' => 'rest_validate_request_arg', |
729 | 729 | ); |
730 | 730 | } |
731 | - $params['order'] = array( |
|
731 | + $params['order'] = array( |
|
732 | 732 | 'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ), |
733 | 733 | 'type' => 'string', |
734 | 734 | 'sanitize_callback' => 'sanitize_key', |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | ), |
740 | 740 | 'validate_callback' => 'rest_validate_request_arg', |
741 | 741 | ); |
742 | - $params['orderby'] = array( |
|
742 | + $params['orderby'] = array( |
|
743 | 743 | 'description' => __( 'Sort collection by resource attribute.', 'woocommerce' ), |
744 | 744 | 'type' => 'string', |
745 | 745 | 'sanitize_callback' => 'sanitize_key', |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | 'default' => null, |
776 | 776 | 'validate_callback' => 'rest_validate_request_arg', |
777 | 777 | ); |
778 | - $params['slug'] = array( |
|
778 | + $params['slug'] = array( |
|
779 | 779 | 'description' => __( 'Limit result set to resources with a specific slug.', 'woocommerce' ), |
780 | 780 | 'type' => 'string', |
781 | 781 | 'validate_callback' => 'rest_validate_request_arg', |
@@ -722,13 +722,13 @@ discard block |
||
722 | 722 | |
723 | 723 | $params['context']['default'] = 'view'; |
724 | 724 | |
725 | - $params['after'] = array( |
|
725 | + $params['after'] = array( |
|
726 | 726 | 'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ), |
727 | 727 | 'type' => 'string', |
728 | 728 | 'format' => 'date-time', |
729 | 729 | 'validate_callback' => 'rest_validate_request_arg', |
730 | 730 | ); |
731 | - $params['before'] = array( |
|
731 | + $params['before'] = array( |
|
732 | 732 | 'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ), |
733 | 733 | 'type' => 'string', |
734 | 734 | 'format' => 'date-time', |
@@ -752,13 +752,13 @@ discard block |
||
752 | 752 | 'default' => array(), |
753 | 753 | 'sanitize_callback' => 'wp_parse_id_list', |
754 | 754 | ); |
755 | - $params['offset'] = array( |
|
755 | + $params['offset'] = array( |
|
756 | 756 | 'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ), |
757 | 757 | 'type' => 'integer', |
758 | 758 | 'sanitize_callback' => 'absint', |
759 | 759 | 'validate_callback' => 'rest_validate_request_arg', |
760 | 760 | ); |
761 | - $params['order'] = array( |
|
761 | + $params['order'] = array( |
|
762 | 762 | 'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ), |
763 | 763 | 'type' => 'string', |
764 | 764 | 'default' => 'desc', |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | ), |
777 | 777 | 'validate_callback' => 'rest_validate_request_arg', |
778 | 778 | ); |
779 | - $params['status'] = array( |
|
779 | + $params['status'] = array( |
|
780 | 780 | 'default' => 'all', |
781 | 781 | 'description' => __( 'Limit result set to webhooks assigned a specific status.', 'woocommerce' ), |
782 | 782 | 'type' => 'string', |