@@ -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 | } |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | |
377 | 377 | // Price filter. |
378 | 378 | if ( ! empty( $request['min_price'] ) || ! empty( $request['max_price'] ) ) { |
379 | - $args['meta_query'] = $this->add_meta_query( $args, wc_get_min_max_price_meta_query( $request ) ); // WPCS: slow query ok. |
|
379 | + $args['meta_query'] = $this->add_meta_query( $args, wc_get_min_max_price_meta_query( $request ) ); // WPCS: slow query ok. |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | // Filter product based on stock_status. |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | // Use 0 when there's no on sale products to avoid return all products. |
399 | 399 | $on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids; |
400 | 400 | |
401 | - $args[ $on_sale_key ] += $on_sale_ids; |
|
401 | + $args[$on_sale_key] += $on_sale_ids; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | // Force the post_type argument, since it's not a user input variable. |
@@ -578,14 +578,14 @@ discard block |
||
578 | 578 | continue; |
579 | 579 | } |
580 | 580 | |
581 | - if ( ! isset( $parent_attributes[ $attribute_name ] ) || ! $parent_attributes[ $attribute_name ]->get_variation() ) { |
|
581 | + if ( ! isset( $parent_attributes[$attribute_name] ) || ! $parent_attributes[$attribute_name]->get_variation() ) { |
|
582 | 582 | continue; |
583 | 583 | } |
584 | 584 | |
585 | - $attribute_key = sanitize_title( $parent_attributes[ $attribute_name ]->get_name() ); |
|
585 | + $attribute_key = sanitize_title( $parent_attributes[$attribute_name]->get_name() ); |
|
586 | 586 | $attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : ''; |
587 | 587 | |
588 | - if ( $parent_attributes[ $attribute_name ]->is_taxonomy() ) { |
|
588 | + if ( $parent_attributes[$attribute_name]->is_taxonomy() ) { |
|
589 | 589 | // If dealing with a taxonomy, we need to get the slug from the name posted to the API. |
590 | 590 | $term = get_term_by( 'name', $attribute_value, $attribute_name ); |
591 | 591 | |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | } |
597 | 597 | } |
598 | 598 | |
599 | - $attributes[ $attribute_key ] = $attribute_value; |
|
599 | + $attributes[$attribute_key] = $attribute_value; |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | $variation->set_attributes( $attributes ); |
@@ -758,9 +758,9 @@ discard block |
||
758 | 758 | $body_params = array(); |
759 | 759 | |
760 | 760 | foreach ( array( 'update', 'create', 'delete' ) as $batch_type ) { |
761 | - if ( ! empty( $items[ $batch_type ] ) ) { |
|
761 | + if ( ! empty( $items[$batch_type] ) ) { |
|
762 | 762 | $injected_items = array(); |
763 | - foreach ( $items[ $batch_type ] as $item ) { |
|
763 | + foreach ( $items[$batch_type] as $item ) { |
|
764 | 764 | $injected_items[] = is_array( $item ) ? array_merge( |
765 | 765 | array( |
766 | 766 | 'product_id' => $product_id, |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | $item |
769 | 769 | ) : $item; |
770 | 770 | } |
771 | - $body_params[ $batch_type ] = $injected_items; |
|
771 | + $body_params[$batch_type] = $injected_items; |
|
772 | 772 | } |
773 | 773 | } |
774 | 774 |