@@ -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 | ); |
@@ -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; |
@@ -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' ), |
@@ -351,8 +351,8 @@ discard block |
||
| 351 | 351 | 'low_in_stock', |
| 352 | 352 | ); |
| 353 | 353 | foreach ( $custom_keys as $key ) { |
| 354 | - if ( ! empty( $request[ $key ] ) ) { |
|
| 355 | - $args[ $key ] = $request[ $key ]; |
|
| 354 | + if ( ! empty( $request[$key] ) ) { |
|
| 355 | + $args[$key] = $request[$key]; |
|
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | 358 | |
@@ -369,11 +369,11 @@ discard block |
||
| 369 | 369 | |
| 370 | 370 | // Set tax_query for each passed arg. |
| 371 | 371 | foreach ( $taxonomies as $taxonomy => $key ) { |
| 372 | - if ( ! empty( $request[ $key ] ) ) { |
|
| 372 | + if ( ! empty( $request[$key] ) ) { |
|
| 373 | 373 | $tax_query[] = array( |
| 374 | 374 | 'taxonomy' => $taxonomy, |
| 375 | 375 | 'field' => 'term_id', |
| 376 | - 'terms' => $request[ $key ], |
|
| 376 | + 'terms' => $request[$key], |
|
| 377 | 377 | ); |
| 378 | 378 | } |
| 379 | 379 | } |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | // Use 0 when there's no on sale products to avoid return all products. |
| 437 | 437 | $on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids; |
| 438 | 438 | |
| 439 | - $args[ $on_sale_key ] += $on_sale_ids; |
|
| 439 | + $args[$on_sale_key] += $on_sale_ids; |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | // Force the post_type argument, since it's not a user input variable. |
@@ -470,16 +470,16 @@ discard block |
||
| 470 | 470 | protected function prepare_links( $object, $request ) { |
| 471 | 471 | $links = array( |
| 472 | 472 | 'self' => array( |
| 473 | - 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ), // @codingStandardsIgnoreLine. |
|
| 473 | + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ), // @codingStandardsIgnoreLine. |
|
| 474 | 474 | ), |
| 475 | 475 | 'collection' => array( |
| 476 | - 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), // @codingStandardsIgnoreLine. |
|
| 476 | + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), // @codingStandardsIgnoreLine. |
|
| 477 | 477 | ), |
| 478 | 478 | ); |
| 479 | 479 | |
| 480 | 480 | if ( $object->get_parent_id() ) { |
| 481 | 481 | $links['up'] = array( |
| 482 | - 'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $object->get_parent_id() ) ), // @codingStandardsIgnoreLine. |
|
| 482 | + 'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $object->get_parent_id() ) ), // @codingStandardsIgnoreLine. |
|
| 483 | 483 | ); |
| 484 | 484 | } |
| 485 | 485 | |
@@ -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 | ), |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | $props_to_set = array_intersect_key( $values, array_flip( $prop_keys ) ); |
| 506 | 506 | $props_to_set = array_filter( |
| 507 | 507 | $props_to_set, |
| 508 | - function ( $prop ) use ( $object ) { |
|
| 508 | + function( $prop ) use ( $object ) { |
|
| 509 | 509 | return is_callable( array( $object, "set_$prop" ) ); |
| 510 | 510 | }, |
| 511 | 511 | ARRAY_FILTER_USE_KEY |
@@ -612,14 +612,14 @@ discard block |
||
| 612 | 612 | continue; |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - if ( ! isset( $parent_attributes[ $attribute_name ] ) || ! $parent_attributes[ $attribute_name ]->get_variation() ) { |
|
| 615 | + if ( ! isset( $parent_attributes[$attribute_name] ) || ! $parent_attributes[$attribute_name]->get_variation() ) { |
|
| 616 | 616 | continue; |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | - $attribute_key = sanitize_title( $parent_attributes[ $attribute_name ]->get_name() ); |
|
| 619 | + $attribute_key = sanitize_title( $parent_attributes[$attribute_name]->get_name() ); |
|
| 620 | 620 | $attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : ''; |
| 621 | 621 | |
| 622 | - if ( $parent_attributes[ $attribute_name ]->is_taxonomy() ) { |
|
| 622 | + if ( $parent_attributes[$attribute_name]->is_taxonomy() ) { |
|
| 623 | 623 | // If dealing with a taxonomy, we need to get the slug from the name posted to the API. |
| 624 | 624 | $term = get_term_by( 'name', $attribute_value, $attribute_name ); |
| 625 | 625 | |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | } |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - $attributes[ $attribute_key ] = $attribute_value; |
|
| 633 | + $attributes[$attribute_key] = $attribute_value; |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | $object->set_attributes( $attributes ); |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | $props_to_set = array_intersect_key( $values, array_flip( $prop_keys ) ); |
| 837 | 837 | $props_to_set = array_filter( |
| 838 | 838 | $props_to_set, |
| 839 | - function ( $prop ) use ( $object ) { |
|
| 839 | + function( $prop ) use ( $object ) { |
|
| 840 | 840 | return is_callable( array( $object, "set_$prop" ) ); |
| 841 | 841 | }, |
| 842 | 842 | ARRAY_FILTER_USE_KEY |
@@ -1013,10 +1013,10 @@ discard block |
||
| 1013 | 1013 | $attribute = false; |
| 1014 | 1014 | |
| 1015 | 1015 | // pa_ attributes. |
| 1016 | - if ( isset( $attributes[ wc_attribute_taxonomy_name( $slug ) ] ) ) { |
|
| 1017 | - $attribute = $attributes[ wc_attribute_taxonomy_name( $slug ) ]; |
|
| 1018 | - } elseif ( isset( $attributes[ $slug ] ) ) { |
|
| 1019 | - $attribute = $attributes[ $slug ]; |
|
| 1016 | + if ( isset( $attributes[wc_attribute_taxonomy_name( $slug )] ) ) { |
|
| 1017 | + $attribute = $attributes[wc_attribute_taxonomy_name( $slug )]; |
|
| 1018 | + } elseif ( isset( $attributes[$slug] ) ) { |
|
| 1019 | + $attribute = $attributes[$slug]; |
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | if ( ! $attribute ) { |
@@ -1383,8 +1383,8 @@ discard block |
||
| 1383 | 1383 | continue; |
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 1386 | - if ( isset( $attributes[ $attribute_name ] ) ) { |
|
| 1387 | - $_attribute = $attributes[ $attribute_name ]; |
|
| 1386 | + if ( isset( $attributes[$attribute_name] ) ) { |
|
| 1387 | + $_attribute = $attributes[$attribute_name]; |
|
| 1388 | 1388 | |
| 1389 | 1389 | if ( $_attribute['is_variation'] ) { |
| 1390 | 1390 | $value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : ''; |
@@ -1401,7 +1401,7 @@ discard block |
||
| 1401 | 1401 | } |
| 1402 | 1402 | |
| 1403 | 1403 | if ( $value ) { |
| 1404 | - $default_attributes[ $attribute_name ] = $value; |
|
| 1404 | + $default_attributes[$attribute_name] = $value; |
|
| 1405 | 1405 | } |
| 1406 | 1406 | } |
| 1407 | 1407 | } |