@@ -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 | ); |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | return $limit; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - $batches = [ 'create', 'update', 'delete' ]; |
|
| 28 | + $batches = ['create', 'update', 'delete']; |
|
| 29 | 29 | $response = []; |
| 30 | 30 | |
| 31 | 31 | foreach ( $batches as $batch ) { |
| 32 | - $response[ $batch ] = $this->{"batch_$batch"}( $this->get_batch_of_items_from_request( $request, $batch ) ); |
|
| 32 | + $response[$batch] = $this->{"batch_$batch"}( $this->get_batch_of_items_from_request( $request, $batch ) ); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | return array_filter( $response ); |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | protected function get_batch_of_items_from_request( $request, $batch_type ) { |
| 46 | 46 | $params = $request->get_params(); |
| 47 | 47 | |
| 48 | - if ( ! isset( $params[ $batch_type ] ) ) { |
|
| 48 | + if ( ! isset( $params[$batch_type] ) ) { |
|
| 49 | 49 | return array(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - return array_filter( $params[ $batch_type ] ); |
|
| 52 | + return array_filter( $params[$batch_type] ); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -141,13 +141,13 @@ discard block |
||
| 141 | 141 | protected function check_batch_limit( $items ) { |
| 142 | 142 | $limit = apply_filters( 'woocommerce_rest_batch_items_limit', 100, $this->get_normalized_rest_base() ); |
| 143 | 143 | $total = 0; |
| 144 | - $batches = [ 'create', 'update', 'delete' ]; |
|
| 144 | + $batches = ['create', 'update', 'delete']; |
|
| 145 | 145 | |
| 146 | 146 | foreach ( $batches as $batch ) { |
| 147 | - if ( ! isset( $items[ $batch ] ) ) { |
|
| 147 | + if ( ! isset( $items[$batch] ) ) { |
|
| 148 | 148 | continue; |
| 149 | 149 | } |
| 150 | - $total = $total + count( $items[ $batch ] ); |
|
| 150 | + $total = $total + count( $items[$batch] ); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | if ( $total > $limit ) { |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $schema = $this->get_public_item_schema(); |
| 169 | 169 | foreach ( $schema['properties'] as $arg => $options ) { |
| 170 | 170 | if ( isset( $options['default'] ) ) { |
| 171 | - $defaults[ $arg ] = $options['default']; |
|
| 171 | + $defaults[$arg] = $options['default']; |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | return $defaults; |
@@ -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 ); |
@@ -736,15 +736,15 @@ discard block |
||
| 736 | 736 | $url_params = $request->get_url_params(); |
| 737 | 737 | $product_id = $url_params['product_id']; |
| 738 | 738 | |
| 739 | - if ( ! isset( $params[ $batch_type ] ) ) { |
|
| 739 | + if ( ! isset( $params[$batch_type] ) ) { |
|
| 740 | 740 | return array(); |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - $items = array_filter( $params[ $batch_type ] ); |
|
| 743 | + $items = array_filter( $params[$batch_type] ); |
|
| 744 | 744 | |
| 745 | 745 | if ( 'update' === $batch_type || 'create' === $batch_type ) { |
| 746 | 746 | foreach ( $items as $key => $item ) { |
| 747 | - $items[ $key ] = array_merge( |
|
| 747 | + $items[$key] = array_merge( |
|
| 748 | 748 | array( |
| 749 | 749 | 'product_id' => $product_id, |
| 750 | 750 | ), |
@@ -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' ), |