@@ -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 | } |
@@ -694,8 +694,8 @@ discard block |
||
| 694 | 694 | 'low_in_stock', |
| 695 | 695 | ); |
| 696 | 696 | foreach ( $custom_keys as $key ) { |
| 697 | - if ( ! empty( $request[ $key ] ) ) { |
|
| 698 | - $args[ $key ] = $request[ $key ]; |
|
| 697 | + if ( ! empty( $request[$key] ) ) { |
|
| 698 | + $args[$key] = $request[$key]; |
|
| 699 | 699 | } |
| 700 | 700 | } |
| 701 | 701 | |
@@ -712,11 +712,11 @@ discard block |
||
| 712 | 712 | |
| 713 | 713 | // Set tax_query for each passed arg. |
| 714 | 714 | foreach ( $taxonomies as $taxonomy => $key ) { |
| 715 | - if ( ! empty( $request[ $key ] ) ) { |
|
| 715 | + if ( ! empty( $request[$key] ) ) { |
|
| 716 | 716 | $tax_query[] = array( |
| 717 | 717 | 'taxonomy' => $taxonomy, |
| 718 | 718 | 'field' => 'term_id', |
| 719 | - 'terms' => $request[ $key ], |
|
| 719 | + 'terms' => $request[$key], |
|
| 720 | 720 | ); |
| 721 | 721 | } |
| 722 | 722 | } |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | // Use 0 when there's no on sale products to avoid return all products. |
| 780 | 780 | $on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids; |
| 781 | 781 | |
| 782 | - $args[ $on_sale_key ] += $on_sale_ids; |
|
| 782 | + $args[$on_sale_key] += $on_sale_ids; |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | // Force the post_type argument, since it's not a user input variable. |
@@ -923,10 +923,10 @@ discard block |
||
| 923 | 923 | $attribute = false; |
| 924 | 924 | |
| 925 | 925 | // pa_ attributes. |
| 926 | - if ( isset( $attributes[ wc_attribute_taxonomy_name( $slug ) ] ) ) { |
|
| 927 | - $attribute = $attributes[ wc_attribute_taxonomy_name( $slug ) ]; |
|
| 928 | - } elseif ( isset( $attributes[ $slug ] ) ) { |
|
| 929 | - $attribute = $attributes[ $slug ]; |
|
| 926 | + if ( isset( $attributes[wc_attribute_taxonomy_name( $slug )] ) ) { |
|
| 927 | + $attribute = $attributes[wc_attribute_taxonomy_name( $slug )]; |
|
| 928 | + } elseif ( isset( $attributes[$slug] ) ) { |
|
| 929 | + $attribute = $attributes[$slug]; |
|
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | if ( ! $attribute ) { |
@@ -1145,16 +1145,16 @@ discard block |
||
| 1145 | 1145 | protected function prepare_links( $object, $request ) { |
| 1146 | 1146 | $links = array( |
| 1147 | 1147 | 'self' => array( |
| 1148 | - 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ), // @codingStandardsIgnoreLine. |
|
| 1148 | + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ), // @codingStandardsIgnoreLine. |
|
| 1149 | 1149 | ), |
| 1150 | 1150 | 'collection' => array( |
| 1151 | - 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), // @codingStandardsIgnoreLine. |
|
| 1151 | + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), // @codingStandardsIgnoreLine. |
|
| 1152 | 1152 | ), |
| 1153 | 1153 | ); |
| 1154 | 1154 | |
| 1155 | 1155 | if ( $object->get_parent_id() ) { |
| 1156 | 1156 | $links['up'] = array( |
| 1157 | - 'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $object->get_parent_id() ) ), // @codingStandardsIgnoreLine. |
|
| 1157 | + 'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $object->get_parent_id() ) ), // @codingStandardsIgnoreLine. |
|
| 1158 | 1158 | ); |
| 1159 | 1159 | } |
| 1160 | 1160 | |
@@ -1358,8 +1358,8 @@ discard block |
||
| 1358 | 1358 | continue; |
| 1359 | 1359 | } |
| 1360 | 1360 | |
| 1361 | - if ( isset( $attributes[ $attribute_name ] ) ) { |
|
| 1362 | - $_attribute = $attributes[ $attribute_name ]; |
|
| 1361 | + if ( isset( $attributes[$attribute_name] ) ) { |
|
| 1362 | + $_attribute = $attributes[$attribute_name]; |
|
| 1363 | 1363 | |
| 1364 | 1364 | if ( $_attribute['is_variation'] ) { |
| 1365 | 1365 | $value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : ''; |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | 1378 | if ( $value ) { |
| 1379 | - $default_attributes[ $attribute_name ] = $value; |
|
| 1379 | + $default_attributes[$attribute_name] = $value; |
|
| 1380 | 1380 | } |
| 1381 | 1381 | } |
| 1382 | 1382 | } |
@@ -354,8 +354,8 @@ discard block |
||
| 354 | 354 | 'low_in_stock', |
| 355 | 355 | ); |
| 356 | 356 | foreach ( $custom_keys as $key ) { |
| 357 | - if ( ! empty( $request[ $key ] ) ) { |
|
| 358 | - $args[ $key ] = $request[ $key ]; |
|
| 357 | + if ( ! empty( $request[$key] ) ) { |
|
| 358 | + $args[$key] = $request[$key]; |
|
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | // Use 0 when there's no on sale products to avoid return all products. |
| 379 | 379 | $on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids; |
| 380 | 380 | |
| 381 | - $args[ $on_sale_key ] += $on_sale_ids; |
|
| 381 | + $args[$on_sale_key] += $on_sale_ids; |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | // Force the post_type argument, since it's not a user input variable. |
@@ -558,14 +558,14 @@ discard block |
||
| 558 | 558 | continue; |
| 559 | 559 | } |
| 560 | 560 | |
| 561 | - if ( ! isset( $parent_attributes[ $attribute_name ] ) || ! $parent_attributes[ $attribute_name ]->get_variation() ) { |
|
| 561 | + if ( ! isset( $parent_attributes[$attribute_name] ) || ! $parent_attributes[$attribute_name]->get_variation() ) { |
|
| 562 | 562 | continue; |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - $attribute_key = sanitize_title( $parent_attributes[ $attribute_name ]->get_name() ); |
|
| 565 | + $attribute_key = sanitize_title( $parent_attributes[$attribute_name]->get_name() ); |
|
| 566 | 566 | $attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : ''; |
| 567 | 567 | |
| 568 | - if ( $parent_attributes[ $attribute_name ]->is_taxonomy() ) { |
|
| 568 | + if ( $parent_attributes[$attribute_name]->is_taxonomy() ) { |
|
| 569 | 569 | // If dealing with a taxonomy, we need to get the slug from the name posted to the API. |
| 570 | 570 | $term = get_term_by( 'name', $attribute_value, $attribute_name ); |
| 571 | 571 | |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | } |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - $attributes[ $attribute_key ] = $attribute_value; |
|
| 579 | + $attributes[$attribute_key] = $attribute_value; |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | $variation->set_attributes( $attributes ); |
@@ -738,9 +738,9 @@ discard block |
||
| 738 | 738 | $body_params = array(); |
| 739 | 739 | |
| 740 | 740 | foreach ( array( 'update', 'create', 'delete' ) as $batch_type ) { |
| 741 | - if ( ! empty( $items[ $batch_type ] ) ) { |
|
| 741 | + if ( ! empty( $items[$batch_type] ) ) { |
|
| 742 | 742 | $injected_items = array(); |
| 743 | - foreach ( $items[ $batch_type ] as $item ) { |
|
| 743 | + foreach ( $items[$batch_type] as $item ) { |
|
| 744 | 744 | $injected_items[] = is_array( $item ) ? array_merge( |
| 745 | 745 | array( |
| 746 | 746 | 'product_id' => $product_id, |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | $item |
| 749 | 749 | ) : $item; |
| 750 | 750 | } |
| 751 | - $body_params[ $batch_type ] = $injected_items; |
|
| 751 | + $body_params[$batch_type] = $injected_items; |
|
| 752 | 752 | } |
| 753 | 753 | } |
| 754 | 754 | |
@@ -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 */ |