@@ -76,7 +76,7 @@ |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | if ( array_key_exists( $class, self::$classmap ) ) { |
| 79 | - return include self::$classmap[ $class ]; |
|
| 79 | + return include self::$classmap[$class]; |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -141,19 +141,19 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | // Format decimal values. |
| 143 | 143 | foreach ( $format_decimal as $key ) { |
| 144 | - $data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] ); |
|
| 144 | + $data[$key] = wc_format_decimal( $data[$key], $this->request['dp'] ); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // Format date values. |
| 148 | 148 | foreach ( $format_date as $key ) { |
| 149 | - $datetime = $data[ $key ]; |
|
| 150 | - $data[ $key ] = wc_rest_prepare_date_response( $datetime, false ); |
|
| 151 | - $data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime ); |
|
| 149 | + $datetime = $data[$key]; |
|
| 150 | + $data[$key] = wc_rest_prepare_date_response( $datetime, false ); |
|
| 151 | + $data[$key . '_gmt'] = wc_rest_prepare_date_response( $datetime ); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // Format line items. |
| 155 | 155 | foreach ( $format_line_items as $key ) { |
| 156 | - $data[ $key ] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[ $key ] ) ); |
|
| 156 | + $data[$key] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[$key] ) ); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | return array( |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | $line_tax = array(); |
| 295 | 295 | |
| 296 | 296 | foreach ( $item_line_taxes['total'] as $tax_rate_id => $tax ) { |
| 297 | - $line_tax[ $tax_rate_id ] = array( |
|
| 297 | + $line_tax[$tax_rate_id] = array( |
|
| 298 | 298 | 'id' => $tax_rate_id, |
| 299 | 299 | 'total' => $tax, |
| 300 | 300 | 'subtotal' => '', |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | foreach ( $item_line_taxes['subtotal'] as $tax_rate_id => $tax ) { |
| 305 | - $line_tax[ $tax_rate_id ]['subtotal'] = $tax; |
|
| 305 | + $line_tax[$tax_rate_id]['subtotal'] = $tax; |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | $line_item['taxes'] = array_values( $line_tax ); |
@@ -148,19 +148,19 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | // Format decimal values. |
| 150 | 150 | foreach ( $format_decimal as $key ) { |
| 151 | - $data[ $key ] = wc_format_decimal( $data[ $key ], 2 ); |
|
| 151 | + $data[$key] = wc_format_decimal( $data[$key], 2 ); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // Format date values. |
| 155 | 155 | foreach ( $format_date as $key ) { |
| 156 | - $datetime = $data[ $key ]; |
|
| 157 | - $data[ $key ] = wc_rest_prepare_date_response( $datetime, false ); |
|
| 158 | - $data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime ); |
|
| 156 | + $datetime = $data[$key]; |
|
| 157 | + $data[$key] = wc_rest_prepare_date_response( $datetime, false ); |
|
| 158 | + $data[$key . '_gmt'] = wc_rest_prepare_date_response( $datetime ); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // Format null values. |
| 162 | 162 | foreach ( $format_null as $key ) { |
| 163 | - $data[ $key ] = $data[ $key ] ? $data[ $key ] : null; |
|
| 163 | + $data[$key] = $data[$key] ? $data[$key] : null; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | return array( |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | // Handle all writable props. |
| 268 | 268 | foreach ( $data_keys as $key ) { |
| 269 | - $value = $request[ $key ]; |
|
| 269 | + $value = $request[$key]; |
|
| 270 | 270 | |
| 271 | 271 | if ( ! is_null( $value ) ) { |
| 272 | 272 | switch ( $key ) { |
@@ -232,7 +232,7 @@ |
||
| 232 | 232 | foreach ( $classes as $key => $class ) { |
| 233 | 233 | if ( sanitize_title( $class ) === $tax_class['slug'] ) { |
| 234 | 234 | $tax_class['name'] = $class; |
| 235 | - unset( $classes[ $key ] ); |
|
| 235 | + unset( $classes[$key] ); |
|
| 236 | 236 | $deleted = true; |
| 237 | 237 | break; |
| 238 | 238 | } |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | $max_pages = ceil( $total_terms / $per_page ); |
| 354 | 354 | $response->header( 'X-WP-TotalPages', (int) $max_pages ); |
| 355 | 355 | |
| 356 | - $base = str_replace( '(?P<attribute_id>[\d]+)', $request['attribute_id'], $this->rest_base ); |
|
| 356 | + $base = str_replace( '(?P<attribute_id>[\d]+)', $request['attribute_id'], $this->rest_base ); |
|
| 357 | 357 | $base = add_query_arg( $request->get_query_params(), rest_url( '/' . $this->namespace . '/' . $base ) ); |
| 358 | 358 | if ( $page > 1 ) { |
| 359 | 359 | $prev_page = $page - 1; |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | 'validate_callback' => 'rest_validate_request_arg', |
| 729 | 729 | ); |
| 730 | 730 | } |
| 731 | - $params['order'] = array( |
|
| 731 | + $params['order'] = array( |
|
| 732 | 732 | 'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ), |
| 733 | 733 | 'type' => 'string', |
| 734 | 734 | 'sanitize_callback' => 'sanitize_key', |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | ), |
| 740 | 740 | 'validate_callback' => 'rest_validate_request_arg', |
| 741 | 741 | ); |
| 742 | - $params['orderby'] = array( |
|
| 742 | + $params['orderby'] = array( |
|
| 743 | 743 | 'description' => __( 'Sort collection by resource attribute.', 'woocommerce' ), |
| 744 | 744 | 'type' => 'string', |
| 745 | 745 | 'sanitize_callback' => 'sanitize_key', |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | 'default' => null, |
| 776 | 776 | 'validate_callback' => 'rest_validate_request_arg', |
| 777 | 777 | ); |
| 778 | - $params['slug'] = array( |
|
| 778 | + $params['slug'] = array( |
|
| 779 | 779 | 'description' => __( 'Limit result set to resources with a specific slug.', 'woocommerce' ), |
| 780 | 780 | 'type' => 'string', |
| 781 | 781 | 'validate_callback' => 'rest_validate_request_arg', |
@@ -722,13 +722,13 @@ discard block |
||
| 722 | 722 | |
| 723 | 723 | $params['context']['default'] = 'view'; |
| 724 | 724 | |
| 725 | - $params['after'] = array( |
|
| 725 | + $params['after'] = array( |
|
| 726 | 726 | 'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ), |
| 727 | 727 | 'type' => 'string', |
| 728 | 728 | 'format' => 'date-time', |
| 729 | 729 | 'validate_callback' => 'rest_validate_request_arg', |
| 730 | 730 | ); |
| 731 | - $params['before'] = array( |
|
| 731 | + $params['before'] = array( |
|
| 732 | 732 | 'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ), |
| 733 | 733 | 'type' => 'string', |
| 734 | 734 | 'format' => 'date-time', |
@@ -752,13 +752,13 @@ discard block |
||
| 752 | 752 | 'default' => array(), |
| 753 | 753 | 'sanitize_callback' => 'wp_parse_id_list', |
| 754 | 754 | ); |
| 755 | - $params['offset'] = array( |
|
| 755 | + $params['offset'] = array( |
|
| 756 | 756 | 'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ), |
| 757 | 757 | 'type' => 'integer', |
| 758 | 758 | 'sanitize_callback' => 'absint', |
| 759 | 759 | 'validate_callback' => 'rest_validate_request_arg', |
| 760 | 760 | ); |
| 761 | - $params['order'] = array( |
|
| 761 | + $params['order'] = array( |
|
| 762 | 762 | 'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ), |
| 763 | 763 | 'type' => 'string', |
| 764 | 764 | 'default' => 'desc', |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | ), |
| 777 | 777 | 'validate_callback' => 'rest_validate_request_arg', |
| 778 | 778 | ); |
| 779 | - $params['status'] = array( |
|
| 779 | + $params['status'] = array( |
|
| 780 | 780 | 'default' => 'all', |
| 781 | 781 | 'description' => __( 'Limit result set to webhooks assigned a specific status.', 'woocommerce' ), |
| 782 | 782 | 'type' => 'string', |
@@ -421,8 +421,8 @@ discard block |
||
| 421 | 421 | $beginning_offset = strlen( $attrib_prefix ); |
| 422 | 422 | $attrib_name_end = strpos( $attrib_name_match[0], '>', $attrib_name_match[1] ); |
| 423 | 423 | $attrib_name = substr( $attrib_name_match[0], $beginning_offset, $attrib_name_end - $beginning_offset ); |
| 424 | - if ( isset( $request[ $attrib_name ] ) ) { |
|
| 425 | - $base = str_replace( "(?P<$attrib_name>[\d]+)", $request[ $attrib_name ], $base ); |
|
| 424 | + if ( isset( $request[$attrib_name] ) ) { |
|
| 425 | + $base = str_replace( "(?P<$attrib_name>[\d]+)", $request[$attrib_name], $base ); |
|
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | $valid_vars = array_flip( $this->get_allowed_query_vars() ); |
| 727 | 727 | $query_args = array(); |
| 728 | 728 | foreach ( $valid_vars as $var => $index ) { |
| 729 | - if ( isset( $prepared_args[ $var ] ) ) { |
|
| 729 | + if ( isset( $prepared_args[$var] ) ) { |
|
| 730 | 730 | /** |
| 731 | 731 | * Filter the query_vars used in `get_items` for the constructed query. |
| 732 | 732 | * |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | * |
| 735 | 735 | * @param mixed $prepared_args[ $var ] The query_var value. |
| 736 | 736 | */ |
| 737 | - $query_args[ $var ] = apply_filters( "woocommerce_rest_query_var_{$var}", $prepared_args[ $var ] ); |
|
| 737 | + $query_args[$var] = apply_filters( "woocommerce_rest_query_var_{$var}", $prepared_args[$var] ); |
|
| 738 | 738 | } |
| 739 | 739 | } |
| 740 | 740 | |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | // Format date values. |
| 241 | 241 | foreach ( $format_date as $key ) { |
| 242 | 242 | // Date created is stored UTC, date modified is stored WP local time. |
| 243 | - $datetime = 'date_created' === $key ? get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $data[ $key ]->getTimestamp() ) ) : $data[ $key ]; |
|
| 244 | - $data[ $key ] = wc_rest_prepare_date_response( $datetime, false ); |
|
| 245 | - $data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime ); |
|
| 243 | + $datetime = 'date_created' === $key ? get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $data[$key]->getTimestamp() ) ) : $data[$key]; |
|
| 244 | + $data[$key] = wc_rest_prepare_date_response( $datetime, false ); |
|
| 245 | + $data[$key . '_gmt'] = wc_rest_prepare_date_response( $datetime ); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | return array( |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | 'name' => 'display_name', |
| 288 | 288 | 'registered_date' => 'registered', |
| 289 | 289 | ); |
| 290 | - $prepared_args['orderby'] = $orderby_possibles[ $request['orderby'] ]; |
|
| 290 | + $prepared_args['orderby'] = $orderby_possibles[$request['orderby']]; |
|
| 291 | 291 | $prepared_args['search'] = $request['search']; |
| 292 | 292 | |
| 293 | 293 | if ( '' !== $prepared_args['search'] ) { |
@@ -604,8 +604,8 @@ discard block |
||
| 604 | 604 | // Customer billing address. |
| 605 | 605 | if ( isset( $request['billing'] ) ) { |
| 606 | 606 | foreach ( array_keys( $schema['properties']['billing']['properties'] ) as $field ) { |
| 607 | - if ( isset( $request['billing'][ $field ] ) && is_callable( array( $customer, "set_billing_{$field}" ) ) ) { |
|
| 608 | - $customer->{"set_billing_{$field}"}( $request['billing'][ $field ] ); |
|
| 607 | + if ( isset( $request['billing'][$field] ) && is_callable( array( $customer, "set_billing_{$field}" ) ) ) { |
|
| 608 | + $customer->{"set_billing_{$field}"}( $request['billing'][$field] ); |
|
| 609 | 609 | } |
| 610 | 610 | } |
| 611 | 611 | } |
@@ -613,8 +613,8 @@ discard block |
||
| 613 | 613 | // Customer shipping address. |
| 614 | 614 | if ( isset( $request['shipping'] ) ) { |
| 615 | 615 | foreach ( array_keys( $schema['properties']['shipping']['properties'] ) as $field ) { |
| 616 | - if ( isset( $request['shipping'][ $field ] ) && is_callable( array( $customer, "set_shipping_{$field}" ) ) ) { |
|
| 617 | - $customer->{"set_shipping_{$field}"}( $request['shipping'][ $field ] ); |
|
| 616 | + if ( isset( $request['shipping'][$field] ) && is_callable( array( $customer, "set_shipping_{$field}" ) ) ) { |
|
| 617 | + $customer->{"set_shipping_{$field}"}( $request['shipping'][$field] ); |
|
| 618 | 618 | } |
| 619 | 619 | } |
| 620 | 620 | } |
@@ -309,17 +309,17 @@ discard block |
||
| 309 | 309 | $instance_settings = $method->instance_settings; |
| 310 | 310 | $errors_found = false; |
| 311 | 311 | foreach ( $method->get_instance_form_fields() as $key => $field ) { |
| 312 | - if ( isset( $request['settings'][ $key ] ) ) { |
|
| 312 | + if ( isset( $request['settings'][$key] ) ) { |
|
| 313 | 313 | if ( is_callable( array( $this, 'validate_setting_' . $field['type'] . '_field' ) ) ) { |
| 314 | - $value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][ $key ], $field ); |
|
| 314 | + $value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][$key], $field ); |
|
| 315 | 315 | } else { |
| 316 | - $value = $this->validate_setting_text_field( $request['settings'][ $key ], $field ); |
|
| 316 | + $value = $this->validate_setting_text_field( $request['settings'][$key], $field ); |
|
| 317 | 317 | } |
| 318 | 318 | if ( is_wp_error( $value ) ) { |
| 319 | 319 | $errors_found = true; |
| 320 | 320 | break; |
| 321 | 321 | } |
| 322 | - $instance_settings[ $key ] = $value; |
|
| 322 | + $instance_settings[$key] = $value; |
|
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | 'label' => $field['title'], |
| 398 | 398 | 'description' => empty( $field['description'] ) ? '' : $field['description'], |
| 399 | 399 | 'type' => $field['type'], |
| 400 | - 'value' => $item->instance_settings[ $id ], |
|
| 400 | + 'value' => $item->instance_settings[$id], |
|
| 401 | 401 | 'default' => empty( $field['default'] ) ? '' : $field['default'], |
| 402 | 402 | 'tip' => empty( $field['description'] ) ? '' : $field['description'], |
| 403 | 403 | 'placeholder' => empty( $field['placeholder'] ) ? '' : $field['placeholder'], |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | if ( ! empty( $field['options'] ) ) { |
| 406 | 406 | $data['options'] = $field['options']; |
| 407 | 407 | } |
| 408 | - $settings[ $id ] = $data; |
|
| 408 | + $settings[$id] = $data; |
|
| 409 | 409 | } |
| 410 | 410 | return $settings; |
| 411 | 411 | } |