@@ -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', |
@@ -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 | /** |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | // Get the option value. |
174 | 174 | if ( is_array( $option_key ) ) { |
175 | 175 | $option = get_option( $option_key[0] ); |
176 | - $setting['value'] = isset( $option[ $option_key[1] ] ) ? $option[ $option_key[1] ] : $default; |
|
176 | + $setting['value'] = isset( $option[$option_key[1]] ) ? $option[$option_key[1]] : $default; |
|
177 | 177 | } else { |
178 | 178 | $admin_setting_value = \WC_Admin_Settings::get_option( $option_key, $default ); |
179 | 179 | $setting['value'] = $admin_setting_value; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $setting['type'] = 'select'; |
187 | 187 | $setting['options'] = $this->get_countries_and_states(); |
188 | 188 | } elseif ( 'single_select_page' === $setting['type'] ) { |
189 | - $pages = get_pages( |
|
189 | + $pages = get_pages( |
|
190 | 190 | array( |
191 | 191 | 'sort_column' => 'menu_order', |
192 | 192 | 'sort_order' => 'ASC', |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | ); |
196 | 196 | $options = array(); |
197 | 197 | foreach ( $pages as $page ) { |
198 | - $options[ $page->ID ] = ! empty( $page->post_title ) ? $page->post_title : '#' . $page->ID; |
|
198 | + $options[$page->ID] = ! empty( $page->post_title ) ? $page->post_title : '#' . $page->ID; |
|
199 | 199 | } |
200 | 200 | $setting['type'] = 'select'; |
201 | 201 | $setting['options'] = $options; |
@@ -224,10 +224,10 @@ discard block |
||
224 | 224 | |
225 | 225 | if ( $states ) { |
226 | 226 | foreach ( $states as $state_key => $state_value ) { |
227 | - $output[ $key . ':' . $state_key ] = $value . ' - ' . $state_value; |
|
227 | + $output[$key . ':' . $state_key] = $value . ' - ' . $state_value; |
|
228 | 228 | } |
229 | 229 | } else { |
230 | - $output[ $key ] = $value; |
|
230 | + $output[$key] = $value; |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | return $output; |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | return new \WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce' ), array( 'status' => 404 ) ); |
259 | 259 | } |
260 | 260 | |
261 | - $setting = $settings[ $array_key[0] ]; |
|
261 | + $setting = $settings[$array_key[0]]; |
|
262 | 262 | |
263 | 263 | if ( ! $this->is_setting_type_valid( $setting['type'] ) ) { |
264 | 264 | return new \WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce' ), array( 'status' => 404 ) ); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | protected function get_batch_of_items_from_request( $request, $batch_type ) { |
284 | 284 | $params = $request->get_params(); |
285 | 285 | |
286 | - if ( ! isset( $params[ $batch_type ] ) ) { |
|
286 | + if ( ! isset( $params[$batch_type] ) ) { |
|
287 | 287 | return array(); |
288 | 288 | } |
289 | 289 | |
@@ -291,11 +291,11 @@ discard block |
||
291 | 291 | * Since our batch settings update is group-specific and matches based on the route, |
292 | 292 | * we inject the URL parameters (containing group) into the batch items |
293 | 293 | */ |
294 | - $items = array_filter( $params[ $batch_type ] ); |
|
294 | + $items = array_filter( $params[$batch_type] ); |
|
295 | 295 | |
296 | 296 | if ( 'update' === $batch_type ) { |
297 | 297 | foreach ( $items as $key => $item ) { |
298 | - $items[ $key ] = array_merge( $request->get_url_params(), $item ); |
|
298 | + $items[$key] = array_merge( $request->get_url_params(), $item ); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
@@ -330,11 +330,11 @@ discard block |
||
330 | 330 | $setting['value'] = $value; |
331 | 331 | $option_key = $setting['option_key']; |
332 | 332 | $prev = get_option( $option_key[0] ); |
333 | - $prev[ $option_key[1] ] = $request['value']; |
|
333 | + $prev[$option_key[1]] = $request['value']; |
|
334 | 334 | update_option( $option_key[0], $prev ); |
335 | 335 | } else { |
336 | 336 | $update_data = array(); |
337 | - $update_data[ $setting['option_key'] ] = $value; |
|
337 | + $update_data[$setting['option_key']] = $value; |
|
338 | 338 | $setting['value'] = $value; |
339 | 339 | \WC_Admin_Settings::save_fields( array( $setting ), $update_data ); |
340 | 340 | } |
@@ -448,10 +448,10 @@ discard block |
||
448 | 448 | */ |
449 | 449 | public function cast_image_width( $setting ) { |
450 | 450 | foreach ( array( 'default', 'value' ) as $key ) { |
451 | - if ( isset( $setting[ $key ] ) ) { |
|
452 | - $setting[ $key ]['width'] = intval( $setting[ $key ]['width'] ); |
|
453 | - $setting[ $key ]['height'] = intval( $setting[ $key ]['height'] ); |
|
454 | - $setting[ $key ]['crop'] = (bool) $setting[ $key ]['crop']; |
|
451 | + if ( isset( $setting[$key] ) ) { |
|
452 | + $setting[$key]['width'] = intval( $setting[$key]['width'] ); |
|
453 | + $setting[$key]['height'] = intval( $setting[$key]['height'] ); |
|
454 | + $setting[$key]['crop'] = (bool) $setting[$key]['crop']; |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | return $setting; |
@@ -491,17 +491,17 @@ discard block |
||
491 | 491 | public function is_setting_type_valid( $type ) { |
492 | 492 | return in_array( |
493 | 493 | $type, array( |
494 | - 'text', // Validates with validate_setting_text_field. |
|
495 | - 'email', // Validates with validate_setting_text_field. |
|
496 | - 'number', // Validates with validate_setting_text_field. |
|
497 | - 'color', // Validates with validate_setting_text_field. |
|
498 | - 'password', // Validates with validate_setting_text_field. |
|
499 | - 'textarea', // Validates with validate_setting_textarea_field. |
|
500 | - 'select', // Validates with validate_setting_select_field. |
|
501 | - 'multiselect', // Validates with validate_setting_multiselect_field. |
|
502 | - 'radio', // Validates with validate_setting_radio_field (-> validate_setting_select_field). |
|
503 | - 'checkbox', // Validates with validate_setting_checkbox_field. |
|
504 | - 'image_width', // Validates with validate_setting_image_width_field. |
|
494 | + 'text', // Validates with validate_setting_text_field. |
|
495 | + 'email', // Validates with validate_setting_text_field. |
|
496 | + 'number', // Validates with validate_setting_text_field. |
|
497 | + 'color', // Validates with validate_setting_text_field. |
|
498 | + 'password', // Validates with validate_setting_text_field. |
|
499 | + 'textarea', // Validates with validate_setting_textarea_field. |
|
500 | + 'select', // Validates with validate_setting_select_field. |
|
501 | + 'multiselect', // Validates with validate_setting_multiselect_field. |
|
502 | + 'radio', // Validates with validate_setting_radio_field (-> validate_setting_select_field). |
|
503 | + 'checkbox', // Validates with validate_setting_checkbox_field. |
|
504 | + 'image_width', // Validates with validate_setting_image_width_field. |
|
505 | 505 | 'thumbnail_cropping', // Validates with validate_setting_text_field. |
506 | 506 | ) |
507 | 507 | ); |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @param array $methods Supported methods. read, create. |
47 | 47 | */ |
48 | - protected function register_items_route( $methods = [ 'read', 'create' ] ) { |
|
48 | + protected function register_items_route( $methods = ['read', 'create'] ) { |
|
49 | 49 | $routes = []; |
50 | - $routes['schema'] = [ $this, 'get_public_item_schema' ]; |
|
50 | + $routes['schema'] = [$this, 'get_public_item_schema']; |
|
51 | 51 | |
52 | 52 | if ( in_array( 'read', $methods, true ) ) { |
53 | 53 | $routes[] = array( |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param array $methods Supported methods. read, create. |
82 | 82 | */ |
83 | - protected function register_item_route( $methods = [ 'read', 'edit', 'delete' ] ) { |
|
83 | + protected function register_item_route( $methods = ['read', 'edit', 'delete'] ) { |
|
84 | 84 | $routes = []; |
85 | - $routes['schema'] = [ $this, 'get_public_item_schema' ]; |
|
85 | + $routes['schema'] = [$this, 'get_public_item_schema']; |
|
86 | 86 | $routes['args'] = [ |
87 | 87 | 'id' => [ |
88 | 88 | 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | 'low_in_stock', |
261 | 261 | ); |
262 | 262 | foreach ( $custom_keys as $key ) { |
263 | - if ( ! empty( $request[ $key ] ) ) { |
|
264 | - $args[ $key ] = $request[ $key ]; |
|
263 | + if ( ! empty( $request[$key] ) ) { |
|
264 | + $args[$key] = $request[$key]; |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | // Use 0 when there's no on sale products to avoid return all products. |
285 | 285 | $on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids; |
286 | 286 | |
287 | - $args[ $on_sale_key ] += $on_sale_ids; |
|
287 | + $args[$on_sale_key] += $on_sale_ids; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | // Force the post_type argument, since it's not a user input variable. |
@@ -447,15 +447,15 @@ discard block |
||
447 | 447 | $url_params = $request->get_url_params(); |
448 | 448 | $product_id = $url_params['product_id']; |
449 | 449 | |
450 | - if ( ! isset( $params[ $batch_type ] ) ) { |
|
450 | + if ( ! isset( $params[$batch_type] ) ) { |
|
451 | 451 | return array(); |
452 | 452 | } |
453 | 453 | |
454 | - $items = array_filter( $params[ $batch_type ] ); |
|
454 | + $items = array_filter( $params[$batch_type] ); |
|
455 | 455 | |
456 | 456 | if ( 'update' === $batch_type || 'create' === $batch_type ) { |
457 | 457 | foreach ( $items as $key => $item ) { |
458 | - $items[ $key ] = array_merge( |
|
458 | + $items[$key] = array_merge( |
|
459 | 459 | array( |
460 | 460 | 'product_id' => $product_id, |
461 | 461 | ), |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $prop_values['shipping_class_id'] = $this->parse_shipping_class( $value, $object ); |
94 | 94 | break; |
95 | 95 | default: |
96 | - $prop_values[ $prop ] = $value; |
|
96 | + $prop_values[$prop] = $value; |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | continue; |
130 | 130 | } |
131 | 131 | |
132 | - if ( ! isset( $parent_attributes[ $attribute_name ] ) || ! $parent_attributes[ $attribute_name ]->get_variation() ) { |
|
132 | + if ( ! isset( $parent_attributes[$attribute_name] ) || ! $parent_attributes[$attribute_name]->get_variation() ) { |
|
133 | 133 | continue; |
134 | 134 | } |
135 | 135 | |
136 | - $attribute_key = sanitize_title( $parent_attributes[ $attribute_name ]->get_name() ); |
|
136 | + $attribute_key = sanitize_title( $parent_attributes[$attribute_name]->get_name() ); |
|
137 | 137 | $attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : ''; |
138 | 138 | |
139 | - if ( $parent_attributes[ $attribute_name ]->is_taxonomy() ) { |
|
139 | + if ( $parent_attributes[$attribute_name]->is_taxonomy() ) { |
|
140 | 140 | // If dealing with a taxonomy, we need to get the slug from the name posted to the API. |
141 | 141 | $term = get_term_by( 'name', $attribute_value, $attribute_name ); |
142 | 142 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | - $attributes[ $attribute_key ] = $attribute_value; |
|
150 | + $attributes[$attribute_key] = $attribute_value; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return $attributes; |
@@ -37,7 +37,7 @@ |
||
37 | 37 | * @param mixed $default Default to return if not set. |
38 | 38 | */ |
39 | 39 | protected function get_param( $name, $default = null ) { |
40 | - return isset( $this->request[ $name ] ) ? $this->request[ $name ] : $default; |
|
40 | + return isset( $this->request[$name] ) ? $this->request[$name] : $default; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |