@@ -102,8 +102,8 @@ |
||
| 102 | 102 | 'engine' => $table->engine, |
| 103 | 103 | ); |
| 104 | 104 | |
| 105 | - $database_size['data'] += $table->data; |
|
| 106 | - $database_size['index'] += $table->index; |
|
| 105 | + $database_size[ 'data' ] += $table->data; |
|
| 106 | + $database_size[ 'index' ] += $table->index; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // Return all database info. Described by JSON Schema. |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $pages_output = array(); |
| 72 | 72 | foreach ( $check_pages as $page_name => $values ) { |
| 73 | - $page_id = get_option( $values['option'] ); |
|
| 73 | + $page_id = get_option( $values[ 'option' ] ); |
|
| 74 | 74 | $page_set = false; |
| 75 | 75 | $page_exists = false; |
| 76 | 76 | $page_visible = false; |
@@ -89,22 +89,22 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Shortcode checks. |
| 92 | - if ( $values['shortcode'] && get_post( $page_id ) ) { |
|
| 92 | + if ( $values[ 'shortcode' ] && get_post( $page_id ) ) { |
|
| 93 | 93 | $shortcode_required = true; |
| 94 | 94 | $page = get_post( $page_id ); |
| 95 | - if ( strstr( $page->post_content, $values['shortcode'] ) ) { |
|
| 95 | + if ( strstr( $page->post_content, $values[ 'shortcode' ] ) ) { |
|
| 96 | 96 | $shortcode_present = true; |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Wrap up our findings into an output array. |
| 101 | - $pages_output[] = array( |
|
| 101 | + $pages_output[ ] = array( |
|
| 102 | 102 | 'page_name' => $page_name, |
| 103 | 103 | 'page_id' => $page_id, |
| 104 | 104 | 'page_set' => $page_set, |
| 105 | 105 | 'page_exists' => $page_exists, |
| 106 | 106 | 'page_visible' => $page_visible, |
| 107 | - 'shortcode' => $values['shortcode'], |
|
| 107 | + 'shortcode' => $values[ 'shortcode' ], |
|
| 108 | 108 | 'shortcode_required' => $shortcode_required, |
| 109 | 109 | 'shortcode_present' => $shortcode_present, |
| 110 | 110 | ); |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | $outdated_templates = true; |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | - $override_files[] = array( |
|
| 74 | + $override_files[ ] = array( |
|
| 75 | 75 | 'file' => str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ), |
| 76 | 76 | 'version' => $theme_version, |
| 77 | 77 | 'core_version' => $core_version, |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @return array Array of data in the correct format. |
| 130 | 130 | */ |
| 131 | 131 | protected function get_data_for_response( $object, $request ) { |
| 132 | - $order = wc_get_order( (int) $request['order_id'] ); |
|
| 132 | + $order = wc_get_order( (int) $request[ 'order_id' ] ); |
|
| 133 | 133 | |
| 134 | 134 | if ( ! $order ) { |
| 135 | 135 | throw new \WC_REST_Exception( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce-rest-api' ), 404 ); |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $format_decimal = array( 'amount' ); |
| 144 | 144 | $format_date = array( 'date_created' ); |
| 145 | 145 | $format_line_items = array( 'line_items' ); |
| 146 | - $dp = is_null( $request['dp'] ) ? wc_get_price_decimals() : absint( $request['dp'] ); |
|
| 146 | + $dp = is_null( $request[ 'dp' ] ) ? wc_get_price_decimals() : absint( $request[ 'dp' ] ); |
|
| 147 | 147 | |
| 148 | 148 | // Format decimal values. |
| 149 | 149 | foreach ( $format_decimal as $key ) { |
@@ -164,14 +164,14 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | return array( |
| 166 | 166 | 'id' => $object->get_id(), |
| 167 | - 'date_created' => $data['date_created'], |
|
| 168 | - 'date_created_gmt' => $data['date_created_gmt'], |
|
| 169 | - 'amount' => $data['amount'], |
|
| 170 | - 'reason' => $data['reason'], |
|
| 171 | - 'refunded_by' => $data['refunded_by'], |
|
| 172 | - 'refunded_payment' => $data['refunded_payment'], |
|
| 173 | - 'meta_data' => $data['meta_data'], |
|
| 174 | - 'line_items' => $data['line_items'], |
|
| 167 | + 'date_created' => $data[ 'date_created' ], |
|
| 168 | + 'date_created_gmt' => $data[ 'date_created_gmt' ], |
|
| 169 | + 'amount' => $data[ 'amount' ], |
|
| 170 | + 'reason' => $data[ 'reason' ], |
|
| 171 | + 'refunded_by' => $data[ 'refunded_by' ], |
|
| 172 | + 'refunded_payment' => $data[ 'refunded_payment' ], |
|
| 173 | + 'meta_data' => $data[ 'meta_data' ], |
|
| 174 | + 'line_items' => $data[ 'line_items' ], |
|
| 175 | 175 | ); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -185,45 +185,45 @@ discard block |
||
| 185 | 185 | protected function get_order_item_data( $item, $request ) { |
| 186 | 186 | $data = $item->get_data(); |
| 187 | 187 | $format_decimal = array( 'subtotal', 'subtotal_tax', 'total', 'total_tax', 'tax_total', 'shipping_tax_total' ); |
| 188 | - $dp = is_null( $request['dp'] ) ? wc_get_price_decimals() : absint( $request['dp'] ); |
|
| 188 | + $dp = is_null( $request[ 'dp' ] ) ? wc_get_price_decimals() : absint( $request[ 'dp' ] ); |
|
| 189 | 189 | |
| 190 | 190 | // Format decimal values. |
| 191 | 191 | foreach ( $format_decimal as $key ) { |
| 192 | 192 | if ( isset( $data[ $key ] ) ) { |
| 193 | - $data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] ); |
|
| 193 | + $data[ $key ] = wc_format_decimal( $data[ $key ], $this->request[ 'dp' ] ); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | // Add SKU and PRICE to products. |
| 198 | 198 | if ( is_callable( array( $item, 'get_product' ) ) ) { |
| 199 | - $data['sku'] = $item->get_product() ? $item->get_product()->get_sku() : null; |
|
| 200 | - $data['price'] = $item->get_quantity() ? $item->get_total() / $item->get_quantity() : 0; |
|
| 199 | + $data[ 'sku' ] = $item->get_product() ? $item->get_product()->get_sku() : null; |
|
| 200 | + $data[ 'price' ] = $item->get_quantity() ? $item->get_total() / $item->get_quantity() : 0; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | // Format taxes. |
| 204 | - if ( ! empty( $data['taxes']['total'] ) ) { |
|
| 204 | + if ( ! empty( $data[ 'taxes' ][ 'total' ] ) ) { |
|
| 205 | 205 | $taxes = array(); |
| 206 | 206 | |
| 207 | - foreach ( $data['taxes']['total'] as $tax_rate_id => $tax ) { |
|
| 208 | - $taxes[] = array( |
|
| 207 | + foreach ( $data[ 'taxes' ][ 'total' ] as $tax_rate_id => $tax ) { |
|
| 208 | + $taxes[ ] = array( |
|
| 209 | 209 | 'id' => $tax_rate_id, |
| 210 | 210 | 'total' => $tax, |
| 211 | - 'subtotal' => isset( $data['taxes']['subtotal'][ $tax_rate_id ] ) ? $data['taxes']['subtotal'][ $tax_rate_id ] : '', |
|
| 211 | + 'subtotal' => isset( $data[ 'taxes' ][ 'subtotal' ][ $tax_rate_id ] ) ? $data[ 'taxes' ][ 'subtotal' ][ $tax_rate_id ] : '', |
|
| 212 | 212 | ); |
| 213 | 213 | } |
| 214 | - $data['taxes'] = $taxes; |
|
| 215 | - } elseif ( isset( $data['taxes'] ) ) { |
|
| 216 | - $data['taxes'] = array(); |
|
| 214 | + $data[ 'taxes' ] = $taxes; |
|
| 215 | + } elseif ( isset( $data[ 'taxes' ] ) ) { |
|
| 216 | + $data[ 'taxes' ] = array(); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // Remove names for coupons, taxes and shipping. |
| 220 | - if ( isset( $data['code'] ) || isset( $data['rate_code'] ) || isset( $data['method_title'] ) ) { |
|
| 221 | - unset( $data['name'] ); |
|
| 220 | + if ( isset( $data[ 'code' ] ) || isset( $data[ 'rate_code' ] ) || isset( $data[ 'method_title' ] ) ) { |
|
| 221 | + unset( $data[ 'name' ] ); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | // Remove props we don't want to expose. |
| 225 | - unset( $data['order_id'] ); |
|
| 226 | - unset( $data['type'] ); |
|
| 225 | + unset( $data[ 'order_id' ] ); |
|
| 226 | + unset( $data[ 'type' ] ); |
|
| 227 | 227 | |
| 228 | 228 | return $data; |
| 229 | 229 | } |
@@ -262,8 +262,8 @@ discard block |
||
| 262 | 262 | protected function prepare_objects_query( $request ) { |
| 263 | 263 | $args = parent::prepare_objects_query( $request ); |
| 264 | 264 | |
| 265 | - $args['post_status'] = array_keys( wc_get_order_statuses() ); |
|
| 266 | - $args['post_parent__in'] = array( absint( $request['order_id'] ) ); |
|
| 265 | + $args[ 'post_status' ] = array_keys( wc_get_order_statuses() ); |
|
| 266 | + $args[ 'post_parent__in' ] = array( absint( $request[ 'order_id' ] ) ); |
|
| 267 | 267 | |
| 268 | 268 | return $args; |
| 269 | 269 | } |
@@ -275,18 +275,18 @@ discard block |
||
| 275 | 275 | * @return \WP_Error|\WP_REST_Response |
| 276 | 276 | */ |
| 277 | 277 | public function create_item( $request ) { |
| 278 | - if ( ! empty( $request['id'] ) ) { |
|
| 278 | + if ( ! empty( $request[ 'id' ] ) ) { |
|
| 279 | 279 | /* translators: %s: post type */ |
| 280 | 280 | return new \WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 400 ) ); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - $order_data = get_post( (int) $request['order_id'] ); |
|
| 283 | + $order_data = get_post( (int) $request[ 'order_id' ] ); |
|
| 284 | 284 | |
| 285 | 285 | if ( empty( $order_data ) ) { |
| 286 | 286 | return new \WP_Error( 'woocommerce_rest_invalid_order', __( 'Order is invalid', 'woocommerce-rest-api' ), 400 ); |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - if ( 0 > $request['amount'] ) { |
|
| 289 | + if ( 0 > $request[ 'amount' ] ) { |
|
| 290 | 290 | return new \WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce-rest-api' ), 400 ); |
| 291 | 291 | } |
| 292 | 292 | |
@@ -294,9 +294,9 @@ discard block |
||
| 294 | 294 | $refund = wc_create_refund( |
| 295 | 295 | array( |
| 296 | 296 | 'order_id' => $order_data->ID, |
| 297 | - 'amount' => $request['amount'], |
|
| 298 | - 'reason' => empty( $request['reason'] ) ? null : $request['reason'], |
|
| 299 | - 'refund_payment' => is_bool( $request['api_refund'] ) ? $request['api_refund'] : true, |
|
| 297 | + 'amount' => $request[ 'amount' ], |
|
| 298 | + 'reason' => empty( $request[ 'reason' ] ) ? null : $request[ 'reason' ], |
|
| 299 | + 'refund_payment' => is_bool( $request[ 'api_refund' ] ) ? $request[ 'api_refund' ] : true, |
|
| 300 | 300 | 'restock_items' => true, |
| 301 | 301 | ) |
| 302 | 302 | ); |
@@ -339,13 +339,13 @@ discard block |
||
| 339 | 339 | * @return \WP_Error|\WC_Data The prepared item, or \WP_Error object on failure. |
| 340 | 340 | */ |
| 341 | 341 | protected function prepare_object_for_database( $request, $creating = false ) { |
| 342 | - $order = wc_get_order( (int) $request['order_id'] ); |
|
| 342 | + $order = wc_get_order( (int) $request[ 'order_id' ] ); |
|
| 343 | 343 | |
| 344 | 344 | if ( ! $order ) { |
| 345 | 345 | return new \WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce-rest-api' ), 404 ); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - if ( 0 > $request['amount'] ) { |
|
| 348 | + if ( 0 > $request[ 'amount' ] ) { |
|
| 349 | 349 | return new \WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce-rest-api' ), 400 ); |
| 350 | 350 | } |
| 351 | 351 | |
@@ -353,10 +353,10 @@ discard block |
||
| 353 | 353 | $refund = wc_create_refund( |
| 354 | 354 | array( |
| 355 | 355 | 'order_id' => $order->get_id(), |
| 356 | - 'amount' => $request['amount'], |
|
| 357 | - 'reason' => empty( $request['reason'] ) ? null : $request['reason'], |
|
| 358 | - 'line_items' => empty( $request['line_items'] ) ? array() : $request['line_items'], |
|
| 359 | - 'refund_payment' => is_bool( $request['api_refund'] ) ? $request['api_refund'] : true, |
|
| 356 | + 'amount' => $request[ 'amount' ], |
|
| 357 | + 'reason' => empty( $request[ 'reason' ] ) ? null : $request[ 'reason' ], |
|
| 358 | + 'line_items' => empty( $request[ 'line_items' ] ) ? array() : $request[ 'line_items' ], |
|
| 359 | + 'refund_payment' => is_bool( $request[ 'api_refund' ] ) ? $request[ 'api_refund' ] : true, |
|
| 360 | 360 | 'restock_items' => true, |
| 361 | 361 | ) |
| 362 | 362 | ); |
@@ -369,9 +369,9 @@ discard block |
||
| 369 | 369 | return new \WP_Error( 'woocommerce_rest_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce-rest-api' ), 500 ); |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if ( ! empty( $request['meta_data'] ) && is_array( $request['meta_data'] ) ) { |
|
| 373 | - foreach ( $request['meta_data'] as $meta ) { |
|
| 374 | - $refund->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); |
|
| 372 | + if ( ! empty( $request[ 'meta_data' ] ) && is_array( $request[ 'meta_data' ] ) ) { |
|
| 373 | + foreach ( $request[ 'meta_data' ] as $meta ) { |
|
| 374 | + $refund->update_meta_data( $meta[ 'key' ], $meta[ 'value' ], isset( $meta[ 'id' ] ) ? $meta[ 'id' ] : '' ); |
|
| 375 | 375 | } |
| 376 | 376 | $refund->save_meta_data(); |
| 377 | 377 | } |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | public function get_collection_params() { |
| 651 | 651 | $params = parent::get_collection_params(); |
| 652 | 652 | |
| 653 | - $params['dp'] = array( |
|
| 653 | + $params[ 'dp' ] = array( |
|
| 654 | 654 | 'default' => wc_get_price_decimals(), |
| 655 | 655 | 'description' => __( 'Number of decimal points to use in each resource.', 'woocommerce-rest-api' ), |
| 656 | 656 | 'type' => 'integer', |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | 'validate_callback' => 'rest_validate_request_arg', |
| 659 | 659 | ); |
| 660 | 660 | |
| 661 | - unset( $params['status'], $params['customer'], $params['product'] ); |
|
| 661 | + unset( $params[ 'status' ], $params[ 'customer' ], $params[ 'product' ] ); |
|
| 662 | 662 | |
| 663 | 663 | return $params; |
| 664 | 664 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | foreach ( $attributes as $attribute_obj ) { |
| 128 | 128 | $attribute = $this->prepare_item_for_response( $attribute_obj, $request ); |
| 129 | 129 | $attribute = $this->prepare_response_for_collection( $attribute ); |
| 130 | - $data[] = $attribute; |
|
| 130 | + $data[ ] = $attribute; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | return rest_ensure_response( $data ); |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $id = wc_create_attribute( |
| 146 | 146 | array( |
| 147 | - 'name' => $request['name'], |
|
| 148 | - 'slug' => wc_sanitize_taxonomy_name( stripslashes( $request['slug'] ) ), |
|
| 149 | - 'type' => ! empty( $request['type'] ) ? $request['type'] : 'select', |
|
| 150 | - 'order_by' => ! empty( $request['order_by'] ) ? $request['order_by'] : 'menu_order', |
|
| 151 | - 'has_archives' => true === $request['has_archives'], |
|
| 147 | + 'name' => $request[ 'name' ], |
|
| 148 | + 'slug' => wc_sanitize_taxonomy_name( stripslashes( $request[ 'slug' ] ) ), |
|
| 149 | + 'type' => ! empty( $request[ 'type' ] ) ? $request[ 'type' ] : 'select', |
|
| 150 | + 'order_by' => ! empty( $request[ 'order_by' ] ) ? $request[ 'order_by' ] : 'menu_order', |
|
| 151 | + 'has_archives' => true === $request[ 'has_archives' ], |
|
| 152 | 152 | ) |
| 153 | 153 | ); |
| 154 | 154 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * @return \WP_REST_Request|\WP_Error |
| 191 | 191 | */ |
| 192 | 192 | public function get_item( $request ) { |
| 193 | - $attribute = $this->get_attribute( (int) $request['id'] ); |
|
| 193 | + $attribute = $this->get_attribute( (int) $request[ 'id' ] ); |
|
| 194 | 194 | |
| 195 | 195 | if ( is_wp_error( $attribute ) ) { |
| 196 | 196 | return $attribute; |
@@ -210,15 +210,15 @@ discard block |
||
| 210 | 210 | public function update_item( $request ) { |
| 211 | 211 | global $wpdb; |
| 212 | 212 | |
| 213 | - $id = (int) $request['id']; |
|
| 213 | + $id = (int) $request[ 'id' ]; |
|
| 214 | 214 | $edited = wc_update_attribute( |
| 215 | 215 | $id, |
| 216 | 216 | array( |
| 217 | - 'name' => $request['name'], |
|
| 218 | - 'slug' => wc_sanitize_taxonomy_name( stripslashes( $request['slug'] ) ), |
|
| 219 | - 'type' => $request['type'], |
|
| 220 | - 'order_by' => $request['order_by'], |
|
| 221 | - 'has_archives' => $request['has_archives'], |
|
| 217 | + 'name' => $request[ 'name' ], |
|
| 218 | + 'slug' => wc_sanitize_taxonomy_name( stripslashes( $request[ 'slug' ] ) ), |
|
| 219 | + 'type' => $request[ 'type' ], |
|
| 220 | + 'order_by' => $request[ 'order_by' ], |
|
| 221 | + 'has_archives' => $request[ 'has_archives' ], |
|
| 222 | 222 | ) |
| 223 | 223 | ); |
| 224 | 224 | |
@@ -257,14 +257,14 @@ discard block |
||
| 257 | 257 | * @return \WP_REST_Response|\WP_Error |
| 258 | 258 | */ |
| 259 | 259 | public function delete_item( $request ) { |
| 260 | - $force = isset( $request['force'] ) ? (bool) $request['force'] : false; |
|
| 260 | + $force = isset( $request[ 'force' ] ) ? (bool) $request[ 'force' ] : false; |
|
| 261 | 261 | |
| 262 | 262 | // We don't support trashing for this type, error out. |
| 263 | 263 | if ( ! $force ) { |
| 264 | 264 | return new \WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Resource does not support trashing.', 'woocommerce-rest-api' ), array( 'status' => 501 ) ); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - $attribute = $this->get_attribute( (int) $request['id'] ); |
|
| 267 | + $attribute = $this->get_attribute( (int) $request[ 'id' ] ); |
|
| 268 | 268 | |
| 269 | 269 | if ( is_wp_error( $attribute ) ) { |
| 270 | 270 | return $attribute; |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | */ |
| 404 | 404 | public function get_collection_params() { |
| 405 | 405 | $params = array(); |
| 406 | - $params['context'] = $this->get_context_param( array( 'default' => 'view' ) ); |
|
| 406 | + $params[ 'context' ] = $this->get_context_param( array( 'default' => 'view' ) ); |
|
| 407 | 407 | |
| 408 | 408 | return $params; |
| 409 | 409 | } |
@@ -419,8 +419,8 @@ discard block |
||
| 419 | 419 | return $this->attribute; |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | - if ( $request['id'] ) { |
|
| 423 | - $name = wc_attribute_taxonomy_name_by_id( (int) $request['id'] ); |
|
| 422 | + if ( $request[ 'id' ] ) { |
|
| 423 | + $name = wc_attribute_taxonomy_name_by_id( (int) $request[ 'id' ] ); |
|
| 424 | 424 | |
| 425 | 425 | $this->attribute = $name; |
| 426 | 426 | } |
@@ -74,32 +74,32 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | return array( |
| 76 | 76 | 'id' => $object->get_id(), |
| 77 | - 'code' => $data['code'], |
|
| 78 | - 'amount' => $data['amount'], |
|
| 79 | - 'date_created' => $data['date_created'], |
|
| 80 | - 'date_created_gmt' => $data['date_created_gmt'], |
|
| 81 | - 'date_modified' => $data['date_modified'], |
|
| 82 | - 'date_modified_gmt' => $data['date_modified_gmt'], |
|
| 83 | - 'discount_type' => $data['discount_type'], |
|
| 84 | - 'description' => $data['description'], |
|
| 85 | - 'date_expires' => $data['date_expires'], |
|
| 86 | - 'date_expires_gmt' => $data['date_expires_gmt'], |
|
| 87 | - 'usage_count' => $data['usage_count'], |
|
| 88 | - 'individual_use' => $data['individual_use'], |
|
| 89 | - 'product_ids' => $data['product_ids'], |
|
| 90 | - 'excluded_product_ids' => $data['excluded_product_ids'], |
|
| 91 | - 'usage_limit' => $data['usage_limit'], |
|
| 92 | - 'usage_limit_per_user' => $data['usage_limit_per_user'], |
|
| 93 | - 'limit_usage_to_x_items' => $data['limit_usage_to_x_items'], |
|
| 94 | - 'free_shipping' => $data['free_shipping'], |
|
| 95 | - 'product_categories' => $data['product_categories'], |
|
| 96 | - 'excluded_product_categories' => $data['excluded_product_categories'], |
|
| 97 | - 'exclude_sale_items' => $data['exclude_sale_items'], |
|
| 98 | - 'minimum_amount' => $data['minimum_amount'], |
|
| 99 | - 'maximum_amount' => $data['maximum_amount'], |
|
| 100 | - 'email_restrictions' => $data['email_restrictions'], |
|
| 101 | - 'used_by' => $data['used_by'], |
|
| 102 | - 'meta_data' => $data['meta_data'], |
|
| 77 | + 'code' => $data[ 'code' ], |
|
| 78 | + 'amount' => $data[ 'amount' ], |
|
| 79 | + 'date_created' => $data[ 'date_created' ], |
|
| 80 | + 'date_created_gmt' => $data[ 'date_created_gmt' ], |
|
| 81 | + 'date_modified' => $data[ 'date_modified' ], |
|
| 82 | + 'date_modified_gmt' => $data[ 'date_modified_gmt' ], |
|
| 83 | + 'discount_type' => $data[ 'discount_type' ], |
|
| 84 | + 'description' => $data[ 'description' ], |
|
| 85 | + 'date_expires' => $data[ 'date_expires' ], |
|
| 86 | + 'date_expires_gmt' => $data[ 'date_expires_gmt' ], |
|
| 87 | + 'usage_count' => $data[ 'usage_count' ], |
|
| 88 | + 'individual_use' => $data[ 'individual_use' ], |
|
| 89 | + 'product_ids' => $data[ 'product_ids' ], |
|
| 90 | + 'excluded_product_ids' => $data[ 'excluded_product_ids' ], |
|
| 91 | + 'usage_limit' => $data[ 'usage_limit' ], |
|
| 92 | + 'usage_limit_per_user' => $data[ 'usage_limit_per_user' ], |
|
| 93 | + 'limit_usage_to_x_items' => $data[ 'limit_usage_to_x_items' ], |
|
| 94 | + 'free_shipping' => $data[ 'free_shipping' ], |
|
| 95 | + 'product_categories' => $data[ 'product_categories' ], |
|
| 96 | + 'excluded_product_categories' => $data[ 'excluded_product_categories' ], |
|
| 97 | + 'exclude_sale_items' => $data[ 'exclude_sale_items' ], |
|
| 98 | + 'minimum_amount' => $data[ 'minimum_amount' ], |
|
| 99 | + 'maximum_amount' => $data[ 'maximum_amount' ], |
|
| 100 | + 'email_restrictions' => $data[ 'email_restrictions' ], |
|
| 101 | + 'used_by' => $data[ 'used_by' ], |
|
| 102 | + 'meta_data' => $data[ 'meta_data' ], |
|
| 103 | 103 | ); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -113,14 +113,14 @@ discard block |
||
| 113 | 113 | protected function prepare_objects_query( $request ) { |
| 114 | 114 | $args = parent::prepare_objects_query( $request ); |
| 115 | 115 | |
| 116 | - if ( ! empty( $request['code'] ) ) { |
|
| 117 | - $id = wc_get_coupon_id_by_code( $request['code'] ); |
|
| 118 | - $args['post__in'] = array( $id ); |
|
| 116 | + if ( ! empty( $request[ 'code' ] ) ) { |
|
| 117 | + $id = wc_get_coupon_id_by_code( $request[ 'code' ] ); |
|
| 118 | + $args[ 'post__in' ] = array( $id ); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if ( ! empty( $request['search'] ) ) { |
|
| 122 | - $args['search'] = $request['search']; |
|
| 123 | - $args['s'] = false; |
|
| 121 | + if ( ! empty( $request[ 'search' ] ) ) { |
|
| 122 | + $args[ 'search' ] = $request[ 'search' ]; |
|
| 123 | + $args[ 's' ] = false; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | return $args; |
@@ -134,13 +134,13 @@ discard block |
||
| 134 | 134 | * @return \WP_Error|\WC_Data |
| 135 | 135 | */ |
| 136 | 136 | protected function prepare_object_for_database( $request, $creating = false ) { |
| 137 | - $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; |
|
| 137 | + $id = isset( $request[ 'id' ] ) ? absint( $request[ 'id' ] ) : 0; |
|
| 138 | 138 | $coupon = new \WC_Coupon( $id ); |
| 139 | 139 | $schema = $this->get_item_schema(); |
| 140 | - $data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) ); |
|
| 140 | + $data_keys = array_keys( array_filter( $schema[ 'properties' ], array( $this, 'filter_writable_props' ) ) ); |
|
| 141 | 141 | |
| 142 | 142 | // Validate required POST fields. |
| 143 | - if ( $creating && empty( $request['code'] ) ) { |
|
| 143 | + if ( $creating && empty( $request[ 'code' ] ) ) { |
|
| 144 | 144 | return new \WP_Error( 'woocommerce_rest_empty_coupon_code', sprintf( __( 'The coupon code cannot be empty.', 'woocommerce-rest-api' ), 'code' ), array( 'status' => 400 ) ); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | case 'meta_data': |
| 165 | 165 | if ( is_array( $value ) ) { |
| 166 | 166 | foreach ( $value as $meta ) { |
| 167 | - $coupon->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : 0 ); |
|
| 167 | + $coupon->update_meta_data( $meta[ 'key' ], $meta[ 'value' ], isset( $meta[ 'id' ] ) ? $meta[ 'id' ] : 0 ); |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | break; |
@@ -404,14 +404,14 @@ discard block |
||
| 404 | 404 | public function get_collection_params() { |
| 405 | 405 | $params = parent::get_collection_params(); |
| 406 | 406 | |
| 407 | - $params['code'] = array( |
|
| 407 | + $params[ 'code' ] = array( |
|
| 408 | 408 | 'description' => __( 'Limit result set to resources with a specific code.', 'woocommerce-rest-api' ), |
| 409 | 409 | 'type' => 'string', |
| 410 | 410 | 'sanitize_callback' => 'sanitize_text_field', |
| 411 | 411 | 'validate_callback' => 'rest_validate_request_arg', |
| 412 | 412 | ); |
| 413 | 413 | |
| 414 | - $params['search'] = array( |
|
| 414 | + $params[ 'search' ] = array( |
|
| 415 | 415 | 'description' => __( 'Limit results to coupons with codes matching a given string.', 'woocommerce-rest-api' ), |
| 416 | 416 | 'type' => 'string', |
| 417 | 417 | 'validate_callback' => 'rest_validate_request_arg', |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | * @return bool |
| 428 | 428 | */ |
| 429 | 429 | protected function filter_writable_props( $schema ) { |
| 430 | - return empty( $schema['readonly'] ); |
|
| 430 | + return empty( $schema[ 'readonly' ] ); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | protected function get_data_for_response( $object, $request ) { |
| 68 | 68 | $formatter = new OrderResponse(); |
| 69 | 69 | |
| 70 | - if ( ! is_null( $request['dp'] ) ) { |
|
| 71 | - $formatter->set_dp( $request['dp'] ); |
|
| 70 | + if ( ! is_null( $request[ 'dp' ] ) ) { |
|
| 71 | + $formatter->set_dp( $request[ 'dp' ] ); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | return $formatter->prepare_response( $object, $this->get_request_context( $request ) ); |
@@ -92,13 +92,13 @@ discard block |
||
| 92 | 92 | ); |
| 93 | 93 | |
| 94 | 94 | if ( 0 !== (int) $item->get_customer_id() ) { |
| 95 | - $links['customer'] = array( |
|
| 95 | + $links[ 'customer' ] = array( |
|
| 96 | 96 | 'href' => rest_url( sprintf( '/%s/customers/%d', $this->namespace, $item->get_customer_id() ) ), |
| 97 | 97 | ); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | if ( 0 !== (int) $item->get_parent_id() ) { |
| 101 | - $links['up'] = array( |
|
| 101 | + $links[ 'up' ] = array( |
|
| 102 | 102 | 'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $item->get_parent_id() ) ), |
| 103 | 103 | ); |
| 104 | 104 | } |
@@ -117,71 +117,71 @@ discard block |
||
| 117 | 117 | global $wpdb; |
| 118 | 118 | |
| 119 | 119 | // This is needed to get around an array to string notice in \WC_REST_Orders_V2_Controller::prepare_objects_query. |
| 120 | - $statuses = $request['status']; |
|
| 121 | - unset( $request['status'] ); |
|
| 120 | + $statuses = $request[ 'status' ]; |
|
| 121 | + unset( $request[ 'status' ] ); |
|
| 122 | 122 | $args = parent::prepare_objects_query( $request ); |
| 123 | 123 | |
| 124 | - $args['post_status'] = array(); |
|
| 124 | + $args[ 'post_status' ] = array(); |
|
| 125 | 125 | foreach ( $statuses as $status ) { |
| 126 | 126 | if ( in_array( $status, $this->get_order_statuses(), true ) ) { |
| 127 | - $args['post_status'][] = 'wc-' . $status; |
|
| 127 | + $args[ 'post_status' ][ ] = 'wc-' . $status; |
|
| 128 | 128 | } elseif ( 'any' === $status ) { |
| 129 | 129 | // Set status to "any" and short-circuit out. |
| 130 | - $args['post_status'] = 'any'; |
|
| 130 | + $args[ 'post_status' ] = 'any'; |
|
| 131 | 131 | break; |
| 132 | 132 | } else { |
| 133 | - $args['post_status'][] = $status; |
|
| 133 | + $args[ 'post_status' ][ ] = $status; |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // Put the statuses back for further processing (next/prev links, etc). |
| 138 | - $request['status'] = $statuses; |
|
| 138 | + $request[ 'status' ] = $statuses; |
|
| 139 | 139 | |
| 140 | 140 | // Customer. |
| 141 | - if ( isset( $request['customer'] ) ) { |
|
| 142 | - if ( ! empty( $args['meta_query'] ) ) { |
|
| 143 | - $args['meta_query'] = array(); // WPCS: slow query ok. |
|
| 141 | + if ( isset( $request[ 'customer' ] ) ) { |
|
| 142 | + if ( ! empty( $args[ 'meta_query' ] ) ) { |
|
| 143 | + $args[ 'meta_query' ] = array(); // WPCS: slow query ok. |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $args['meta_query'][] = array( |
|
| 146 | + $args[ 'meta_query' ][ ] = array( |
|
| 147 | 147 | 'key' => '_customer_user', |
| 148 | - 'value' => $request['customer'], |
|
| 148 | + 'value' => $request[ 'customer' ], |
|
| 149 | 149 | 'type' => 'NUMERIC', |
| 150 | 150 | ); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Search by product. |
| 154 | - if ( ! empty( $request['product'] ) ) { |
|
| 154 | + if ( ! empty( $request[ 'product' ] ) ) { |
|
| 155 | 155 | $order_ids = $wpdb->get_col( |
| 156 | 156 | $wpdb->prepare( |
| 157 | 157 | "SELECT order_id |
| 158 | 158 | FROM {$wpdb->prefix}woocommerce_order_items |
| 159 | 159 | WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key = '_product_id' AND meta_value = %d ) |
| 160 | 160 | AND order_item_type = 'line_item'", |
| 161 | - $request['product'] |
|
| 161 | + $request[ 'product' ] |
|
| 162 | 162 | ) |
| 163 | 163 | ); |
| 164 | 164 | |
| 165 | 165 | // Force WP_Query return empty if don't found any order. |
| 166 | 166 | $order_ids = ! empty( $order_ids ) ? $order_ids : array( 0 ); |
| 167 | 167 | |
| 168 | - $args['post__in'] = $order_ids; |
|
| 168 | + $args[ 'post__in' ] = $order_ids; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // Search. |
| 172 | - if ( ! empty( $args['s'] ) ) { |
|
| 173 | - $order_ids = wc_order_search( $args['s'] ); |
|
| 172 | + if ( ! empty( $args[ 's' ] ) ) { |
|
| 173 | + $order_ids = wc_order_search( $args[ 's' ] ); |
|
| 174 | 174 | |
| 175 | 175 | if ( ! empty( $order_ids ) ) { |
| 176 | - unset( $args['s'] ); |
|
| 177 | - $args['post__in'] = array_merge( $order_ids, array( 0 ) ); |
|
| 176 | + unset( $args[ 's' ] ); |
|
| 177 | + $args[ 'post__in' ] = array_merge( $order_ids, array( 0 ) ); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Search by partial order number. |
| 182 | - if ( ! empty( $request['number'] ) ) { |
|
| 183 | - $partial_number = trim( $request['number'] ); |
|
| 184 | - $limit = intval( $args['posts_per_page'] ); |
|
| 182 | + if ( ! empty( $request[ 'number' ] ) ) { |
|
| 183 | + $partial_number = trim( $request[ 'number' ] ); |
|
| 184 | + $limit = intval( $args[ 'posts_per_page' ] ); |
|
| 185 | 185 | $order_ids = $wpdb->get_col( |
| 186 | 186 | $wpdb->prepare( |
| 187 | 187 | "SELECT ID |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | // Force \WP_Query return empty if don't found any order. |
| 198 | 198 | $order_ids = empty( $order_ids ) ? array( 0 ) : $order_ids; |
| 199 | - $args['post__in'] = $order_ids; |
|
| 199 | + $args[ 'post__in' ] = $order_ids; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | return $args; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | $object->calculate_totals(); |
| 257 | 257 | } else { |
| 258 | 258 | // If items have changed, recalculate order totals. |
| 259 | - if ( isset( $request['billing'] ) || isset( $request['shipping'] ) || isset( $request['line_items'] ) || isset( $request['shipping_lines'] ) || isset( $request['fee_lines'] ) || isset( $request['coupon_lines'] ) ) { |
|
| 259 | + if ( isset( $request[ 'billing' ] ) || isset( $request[ 'shipping' ] ) || isset( $request[ 'line_items' ] ) || isset( $request[ 'shipping_lines' ] ) || isset( $request[ 'fee_lines' ] ) || isset( $request[ 'coupon_lines' ] ) ) { |
|
| 260 | 260 | $object->calculate_totals( true ); |
| 261 | 261 | } |
| 262 | 262 | } |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | $object->save(); |
| 265 | 265 | |
| 266 | 266 | // Actions for after the order is saved. |
| 267 | - if ( true === $request['set_paid'] && ( $creating || $object->needs_payment() ) ) { |
|
| 267 | + if ( true === $request[ 'set_paid' ] && ( $creating || $object->needs_payment() ) ) { |
|
| 268 | 268 | $object->payment_complete(); |
| 269 | 269 | } |
| 270 | 270 | |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | $order_statuses = array(); |
| 286 | 286 | |
| 287 | 287 | foreach ( array_keys( wc_get_order_statuses() ) as $status ) { |
| 288 | - $order_statuses[] = str_replace( 'wc-', '', $status ); |
|
| 288 | + $order_statuses[ ] = str_replace( 'wc-', '', $status ); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | return $order_statuses; |
@@ -1144,7 +1144,7 @@ discard block |
||
| 1144 | 1144 | public function get_collection_params() { |
| 1145 | 1145 | $params = parent::get_collection_params(); |
| 1146 | 1146 | |
| 1147 | - $params['status'] = array( |
|
| 1147 | + $params[ 'status' ] = array( |
|
| 1148 | 1148 | 'default' => 'any', |
| 1149 | 1149 | 'description' => __( 'Limit result set to orders which have specific statuses.', 'woocommerce-rest-api' ), |
| 1150 | 1150 | 'type' => 'array', |
@@ -1154,19 +1154,19 @@ discard block |
||
| 1154 | 1154 | ), |
| 1155 | 1155 | 'validate_callback' => 'rest_validate_request_arg', |
| 1156 | 1156 | ); |
| 1157 | - $params['customer'] = array( |
|
| 1157 | + $params[ 'customer' ] = array( |
|
| 1158 | 1158 | 'description' => __( 'Limit result set to orders assigned a specific customer.', 'woocommerce-rest-api' ), |
| 1159 | 1159 | 'type' => 'integer', |
| 1160 | 1160 | 'sanitize_callback' => 'absint', |
| 1161 | 1161 | 'validate_callback' => 'rest_validate_request_arg', |
| 1162 | 1162 | ); |
| 1163 | - $params['product'] = array( |
|
| 1163 | + $params[ 'product' ] = array( |
|
| 1164 | 1164 | 'description' => __( 'Limit result set to orders assigned a specific product.', 'woocommerce-rest-api' ), |
| 1165 | 1165 | 'type' => 'integer', |
| 1166 | 1166 | 'sanitize_callback' => 'absint', |
| 1167 | 1167 | 'validate_callback' => 'rest_validate_request_arg', |
| 1168 | 1168 | ); |
| 1169 | - $params['dp'] = array( |
|
| 1169 | + $params[ 'dp' ] = array( |
|
| 1170 | 1170 | 'default' => wc_get_price_decimals(), |
| 1171 | 1171 | 'description' => __( 'Number of decimal points to use in each resource.', 'woocommerce-rest-api' ), |
| 1172 | 1172 | 'type' => 'integer', |
@@ -1174,7 +1174,7 @@ discard block |
||
| 1174 | 1174 | 'validate_callback' => 'rest_validate_request_arg', |
| 1175 | 1175 | ); |
| 1176 | 1176 | // This needs to remain a string to support extensions that filter Order Number. |
| 1177 | - $params['number'] = array( |
|
| 1177 | + $params[ 'number' ] = array( |
|
| 1178 | 1178 | 'description' => __( 'Limit result set to orders matching part of an order number.', 'woocommerce-rest-api' ), |
| 1179 | 1179 | 'type' => 'string', |
| 1180 | 1180 | 'validate_callback' => 'rest_validate_request_arg', |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $tax_classes = array(); |
| 94 | 94 | |
| 95 | 95 | // Add standard class. |
| 96 | - $tax_classes[] = array( |
|
| 96 | + $tax_classes[ ] = array( |
|
| 97 | 97 | 'slug' => 'standard', |
| 98 | 98 | 'name' => __( 'Standard rate', 'woocommerce-rest-api' ), |
| 99 | 99 | ); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $classes = \WC_Tax::get_tax_classes(); |
| 102 | 102 | |
| 103 | 103 | foreach ( $classes as $class ) { |
| 104 | - $tax_classes[] = array( |
|
| 104 | + $tax_classes[ ] = array( |
|
| 105 | 105 | 'slug' => sanitize_title( $class ), |
| 106 | 106 | 'name' => $class, |
| 107 | 107 | ); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | foreach ( $tax_classes as $tax_class ) { |
| 112 | 112 | $class = $this->prepare_item_for_response( $tax_class, $request ); |
| 113 | 113 | $class = $this->prepare_response_for_collection( $class ); |
| 114 | - $data[] = $class; |
|
| 114 | + $data[ ] = $class; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | return rest_ensure_response( $data ); |
@@ -127,13 +127,13 @@ discard block |
||
| 127 | 127 | $exists = false; |
| 128 | 128 | $classes = \WC_Tax::get_tax_classes(); |
| 129 | 129 | $tax_class = array( |
| 130 | - 'slug' => sanitize_title( $request['name'] ), |
|
| 131 | - 'name' => $request['name'], |
|
| 130 | + 'slug' => sanitize_title( $request[ 'name' ] ), |
|
| 131 | + 'name' => $request[ 'name' ], |
|
| 132 | 132 | ); |
| 133 | 133 | |
| 134 | 134 | // Check if class exists. |
| 135 | 135 | foreach ( $classes as $key => $class ) { |
| 136 | - if ( sanitize_title( $class ) === $tax_class['slug'] ) { |
|
| 136 | + if ( sanitize_title( $class ) === $tax_class[ 'slug' ] ) { |
|
| 137 | 137 | $exists = true; |
| 138 | 138 | break; |
| 139 | 139 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // Add the new class. |
| 148 | - $classes[] = $tax_class['name']; |
|
| 148 | + $classes[ ] = $tax_class[ 'name' ]; |
|
| 149 | 149 | |
| 150 | 150 | update_option( 'woocommerce_tax_classes', implode( "\n", $classes ) ); |
| 151 | 151 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $response = $this->prepare_item_for_response( $tax_class, $request ); |
| 165 | 165 | $response = rest_ensure_response( $response ); |
| 166 | 166 | $response->set_status( 201 ); |
| 167 | - $response->header( 'Location', rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->rest_base, $tax_class['slug'] ) ) ); |
|
| 167 | + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->rest_base, $tax_class[ 'slug' ] ) ) ); |
|
| 168 | 168 | |
| 169 | 169 | return $response; |
| 170 | 170 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | public function delete_item( $request ) { |
| 179 | 179 | global $wpdb; |
| 180 | 180 | |
| 181 | - $force = isset( $request['force'] ) ? (bool) $request['force'] : false; |
|
| 181 | + $force = isset( $request[ 'force' ] ) ? (bool) $request[ 'force' ] : false; |
|
| 182 | 182 | |
| 183 | 183 | // We don't support trashing for this type, error out. |
| 184 | 184 | if ( ! $force ) { |
@@ -186,15 +186,15 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | $tax_class = array( |
| 189 | - 'slug' => sanitize_title( $request['slug'] ), |
|
| 189 | + 'slug' => sanitize_title( $request[ 'slug' ] ), |
|
| 190 | 190 | 'name' => '', |
| 191 | 191 | ); |
| 192 | 192 | $classes = \WC_Tax::get_tax_classes(); |
| 193 | 193 | $deleted = false; |
| 194 | 194 | |
| 195 | 195 | foreach ( $classes as $key => $class ) { |
| 196 | - if ( sanitize_title( $class ) === $tax_class['slug'] ) { |
|
| 197 | - $tax_class['name'] = $class; |
|
| 196 | + if ( sanitize_title( $class ) === $tax_class[ 'slug' ] ) { |
|
| 197 | + $tax_class[ 'name' ] = $class; |
|
| 198 | 198 | unset( $classes[ $key ] ); |
| 199 | 199 | $deleted = true; |
| 200 | 200 | break; |
@@ -221,12 +221,12 @@ discard block |
||
| 221 | 221 | ON rates.tax_rate_id = locations.tax_rate_id |
| 222 | 222 | WHERE rates.tax_rate_class = %s |
| 223 | 223 | ", |
| 224 | - $tax_class['slug'] |
|
| 224 | + $tax_class[ 'slug' ] |
|
| 225 | 225 | ) |
| 226 | 226 | ); |
| 227 | 227 | |
| 228 | 228 | // Delete tax rates in the selected class. |
| 229 | - $wpdb->delete( $wpdb->prefix . 'woocommerce_tax_rates', array( 'tax_rate_class' => $tax_class['slug'] ), array( '%s' ) ); |
|
| 229 | + $wpdb->delete( $wpdb->prefix . 'woocommerce_tax_rates', array( 'tax_rate_class' => $tax_class[ 'slug' ] ), array( '%s' ) ); |
|
| 230 | 230 | |
| 231 | 231 | $response = new \WP_REST_Response(); |
| 232 | 232 | $response->set_data( |
@@ -44,18 +44,18 @@ discard block |
||
| 44 | 44 | 'curl_version' => $this->get_curl_version(), |
| 45 | 45 | 'suhosin_installed' => extension_loaded( 'suhosin' ), |
| 46 | 46 | 'max_upload_size' => wp_max_upload_size(), |
| 47 | - 'mysql_version' => $database_version['number'], |
|
| 48 | - 'mysql_version_string' => $database_version['string'], |
|
| 47 | + 'mysql_version' => $database_version[ 'number' ], |
|
| 48 | + 'mysql_version_string' => $database_version[ 'string' ], |
|
| 49 | 49 | 'default_timezone' => date_default_timezone_get(), |
| 50 | 50 | 'fsockopen_or_curl_enabled' => $this->fsockopen_or_curl_enabled(), |
| 51 | 51 | 'soapclient_enabled' => class_exists( 'SoapClient' ), |
| 52 | 52 | 'domdocument_enabled' => class_exists( 'DOMDocument' ), |
| 53 | 53 | 'gzip_enabled' => is_callable( 'gzopen' ), |
| 54 | 54 | 'mbstring_enabled' => extension_loaded( 'mbstring' ), |
| 55 | - 'remote_post_successful' => $post_request['success'], |
|
| 56 | - 'remote_post_response' => $post_request['response'], |
|
| 57 | - 'remote_get_successful' => $get_request['success'], |
|
| 58 | - 'remote_get_response' => $get_request['response'], |
|
| 55 | + 'remote_post_successful' => $post_request[ 'success' ], |
|
| 56 | + 'remote_post_response' => $post_request[ 'response' ], |
|
| 57 | + 'remote_get_successful' => $get_request[ 'success' ], |
|
| 58 | + 'remote_get_response' => $get_request[ 'response' ], |
|
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ) |
| 81 | 81 | ); |
| 82 | 82 | if ( ! is_wp_error( $response ) ) { |
| 83 | - $post_response_code = $response['response']['code']; |
|
| 83 | + $post_response_code = $response[ 'response' ][ 'code' ]; |
|
| 84 | 84 | } |
| 85 | 85 | set_transient( 'woocommerce_test_remote_post', $post_response_code, HOUR_IN_SECONDS ); |
| 86 | 86 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | if ( false === $get_response_code || is_wp_error( $get_response_code ) ) { |
| 110 | 110 | $response = wp_safe_remote_get( 'https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ) ); |
| 111 | 111 | if ( ! is_wp_error( $response ) ) { |
| 112 | - $get_response_code = $response['response']['code']; |
|
| 112 | + $get_response_code = $response[ 'response' ][ 'code' ]; |
|
| 113 | 113 | } |
| 114 | 114 | set_transient( 'woocommerce_test_remote_get', $get_response_code, HOUR_IN_SECONDS ); |
| 115 | 115 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @return string |
| 144 | 144 | */ |
| 145 | 145 | protected function get_server_software() { |
| 146 | - return isset( $_SERVER['SERVER_SOFTWARE'] ) ? wc_clean( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : ''; |
|
| 146 | + return isset( $_SERVER[ 'SERVER_SOFTWARE' ] ) ? wc_clean( wp_unslash( $_SERVER[ 'SERVER_SOFTWARE' ] ) ) : ''; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $curl_version = ''; |
| 156 | 156 | if ( function_exists( 'curl_version' ) ) { |
| 157 | 157 | $curl_version = curl_version(); |
| 158 | - $curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version']; |
|
| 158 | + $curl_version = $curl_version[ 'version' ] . ', ' . $curl_version[ 'ssl_version' ]; |
|
| 159 | 159 | } elseif ( extension_loaded( 'curl' ) ) { |
| 160 | 160 | $curl_version = __( 'cURL installed but unable to retrieve version.', 'woocommerce-rest-api' ); |
| 161 | 161 | } |