@@ -140,18 +140,18 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function get_items( $request ) { |
| 142 | 142 | $args = array(); |
| 143 | - $args['order'] = $request['order']; |
|
| 144 | - $args['orderby'] = $request['orderby']; |
|
| 145 | - $args['status'] = 'all' === $request['status'] ? '' : $request['status']; |
|
| 146 | - $args['include'] = implode( ',', $request['include'] ); |
|
| 147 | - $args['exclude'] = implode( ',', $request['exclude'] ); |
|
| 148 | - $args['limit'] = $request['per_page']; |
|
| 149 | - $args['search'] = $request['search']; |
|
| 150 | - $args['before'] = $request['before']; |
|
| 151 | - $args['after'] = $request['after']; |
|
| 152 | - |
|
| 153 | - if ( empty( $request['offset'] ) ) { |
|
| 154 | - $args['offset'] = 1 < $request['page'] ? ( $request['page'] - 1 ) * $args['limit'] : 0; |
|
| 143 | + $args[ 'order' ] = $request[ 'order' ]; |
|
| 144 | + $args[ 'orderby' ] = $request[ 'orderby' ]; |
|
| 145 | + $args[ 'status' ] = 'all' === $request[ 'status' ] ? '' : $request[ 'status' ]; |
|
| 146 | + $args[ 'include' ] = implode( ',', $request[ 'include' ] ); |
|
| 147 | + $args[ 'exclude' ] = implode( ',', $request[ 'exclude' ] ); |
|
| 148 | + $args[ 'limit' ] = $request[ 'per_page' ]; |
|
| 149 | + $args[ 'search' ] = $request[ 'search' ]; |
|
| 150 | + $args[ 'before' ] = $request[ 'before' ]; |
|
| 151 | + $args[ 'after' ] = $request[ 'after' ]; |
|
| 152 | + |
|
| 153 | + if ( empty( $request[ 'offset' ] ) ) { |
|
| 154 | + $args[ 'offset' ] = 1 < $request[ 'page' ] ? ( $request[ 'page' ] - 1 ) * $args[ 'limit' ] : 0; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -161,8 +161,8 @@ discard block |
||
| 161 | 161 | * @param \WP_REST_Request $request The current request. |
| 162 | 162 | */ |
| 163 | 163 | $prepared_args = apply_filters( 'woocommerce_rest_webhook_query', $args, $request ); |
| 164 | - unset( $prepared_args['page'] ); |
|
| 165 | - $prepared_args['paginate'] = true; |
|
| 164 | + unset( $prepared_args[ 'page' ] ); |
|
| 165 | + $prepared_args[ 'paginate' ] = true; |
|
| 166 | 166 | |
| 167 | 167 | // Get the webhooks. |
| 168 | 168 | $webhooks = array(); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | $data = $this->prepare_item_for_response( $object, $request ); |
| 181 | - $webhooks[] = $this->prepare_response_for_collection( $data ); |
|
| 181 | + $webhooks[ ] = $this->prepare_response_for_collection( $data ); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * @return \WP_Error|\WP_REST_Response |
| 214 | 214 | */ |
| 215 | 215 | public function get_item( $request ) { |
| 216 | - $object = $this->get_object( (int) $request['id'] ); |
|
| 216 | + $object = $this->get_object( (int) $request[ 'id' ] ); |
|
| 217 | 217 | |
| 218 | 218 | if ( ! $object || 0 === $object->get_id() ) { |
| 219 | 219 | return new \WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
@@ -229,18 +229,18 @@ discard block |
||
| 229 | 229 | * @return \WP_Error|\WP_REST_Response |
| 230 | 230 | */ |
| 231 | 231 | public function create_item( $request ) { |
| 232 | - if ( ! empty( $request['id'] ) ) { |
|
| 232 | + if ( ! empty( $request[ 'id' ] ) ) { |
|
| 233 | 233 | /* translators: %s: post type */ |
| 234 | 234 | return new \WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) ); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | // Validate topic. |
| 238 | - if ( empty( $request['topic'] ) || ! wc_is_webhook_valid_topic( strtolower( $request['topic'] ) ) ) { |
|
| 238 | + if ( empty( $request[ 'topic' ] ) || ! wc_is_webhook_valid_topic( strtolower( $request[ 'topic' ] ) ) ) { |
|
| 239 | 239 | return new \WP_Error( "woocommerce_rest_{$this->post_type}_invalid_topic", __( 'Webhook topic is required and must be valid.', 'woocommerce' ), array( 'status' => 400 ) ); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | // Validate delivery URL. |
| 243 | - if ( empty( $request['delivery_url'] ) || ! wc_is_valid_url( $request['delivery_url'] ) ) { |
|
| 243 | + if ( empty( $request[ 'delivery_url' ] ) || ! wc_is_valid_url( $request[ 'delivery_url' ] ) ) { |
|
| 244 | 244 | return new \WP_Error( "woocommerce_rest_{$this->post_type}_invalid_delivery_url", __( 'Webhook delivery URL must be a valid URL starting with http:// or https://.', 'woocommerce' ), array( 'status' => 400 ) ); |
| 245 | 245 | } |
| 246 | 246 | |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | $webhook->set_name( $post->post_title ); |
| 254 | 254 | $webhook->set_user_id( $post->post_author ); |
| 255 | 255 | $webhook->set_status( 'publish' === $post->post_status ? 'active' : 'disabled' ); |
| 256 | - $webhook->set_topic( $request['topic'] ); |
|
| 257 | - $webhook->set_delivery_url( $request['delivery_url'] ); |
|
| 258 | - $webhook->set_secret( ! empty( $request['secret'] ) ? $request['secret'] : wp_generate_password( 50, true, true ) ); |
|
| 256 | + $webhook->set_topic( $request[ 'topic' ] ); |
|
| 257 | + $webhook->set_delivery_url( $request[ 'delivery_url' ] ); |
|
| 258 | + $webhook->set_secret( ! empty( $request[ 'secret' ] ) ? $request[ 'secret' ] : wp_generate_password( 50, true, true ) ); |
|
| 259 | 259 | $webhook->set_api_version( $this->get_default_api_version() ); |
| 260 | 260 | $webhook->save(); |
| 261 | 261 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * @return \WP_Error|\WP_REST_Response |
| 290 | 290 | */ |
| 291 | 291 | public function update_item( $request ) { |
| 292 | - $id = (int) $request['id']; |
|
| 292 | + $id = (int) $request[ 'id' ]; |
|
| 293 | 293 | $webhook = wc_get_webhook( $id ); |
| 294 | 294 | |
| 295 | 295 | if ( empty( $webhook ) || is_null( $webhook ) ) { |
@@ -297,32 +297,32 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | // Update topic. |
| 300 | - if ( ! empty( $request['topic'] ) ) { |
|
| 301 | - if ( wc_is_webhook_valid_topic( strtolower( $request['topic'] ) ) ) { |
|
| 302 | - $webhook->set_topic( $request['topic'] ); |
|
| 300 | + if ( ! empty( $request[ 'topic' ] ) ) { |
|
| 301 | + if ( wc_is_webhook_valid_topic( strtolower( $request[ 'topic' ] ) ) ) { |
|
| 302 | + $webhook->set_topic( $request[ 'topic' ] ); |
|
| 303 | 303 | } else { |
| 304 | 304 | return new \WP_Error( "woocommerce_rest_{$this->post_type}_invalid_topic", __( 'Webhook topic must be valid.', 'woocommerce' ), array( 'status' => 400 ) ); |
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | // Update delivery URL. |
| 309 | - if ( ! empty( $request['delivery_url'] ) ) { |
|
| 310 | - if ( wc_is_valid_url( $request['delivery_url'] ) ) { |
|
| 311 | - $webhook->set_delivery_url( $request['delivery_url'] ); |
|
| 309 | + if ( ! empty( $request[ 'delivery_url' ] ) ) { |
|
| 310 | + if ( wc_is_valid_url( $request[ 'delivery_url' ] ) ) { |
|
| 311 | + $webhook->set_delivery_url( $request[ 'delivery_url' ] ); |
|
| 312 | 312 | } else { |
| 313 | 313 | return new \WP_Error( "woocommerce_rest_{$this->post_type}_invalid_delivery_url", __( 'Webhook delivery URL must be a valid URL starting with http:// or https://.', 'woocommerce' ), array( 'status' => 400 ) ); |
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | // Update secret. |
| 318 | - if ( ! empty( $request['secret'] ) ) { |
|
| 319 | - $webhook->set_secret( $request['secret'] ); |
|
| 318 | + if ( ! empty( $request[ 'secret' ] ) ) { |
|
| 319 | + $webhook->set_secret( $request[ 'secret' ] ); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | // Update status. |
| 323 | - if ( ! empty( $request['status'] ) ) { |
|
| 324 | - if ( wc_is_webhook_valid_status( strtolower( $request['status'] ) ) ) { |
|
| 325 | - $webhook->set_status( $request['status'] ); |
|
| 323 | + if ( ! empty( $request[ 'status' ] ) ) { |
|
| 324 | + if ( wc_is_webhook_valid_status( strtolower( $request[ 'status' ] ) ) ) { |
|
| 325 | + $webhook->set_status( $request[ 'status' ] ); |
|
| 326 | 326 | } else { |
| 327 | 327 | return new \WP_Error( "woocommerce_rest_{$this->post_type}_invalid_status", __( 'Webhook status must be valid.', 'woocommerce' ), array( 'status' => 400 ) ); |
| 328 | 328 | } |
@@ -363,8 +363,8 @@ discard block |
||
| 363 | 363 | * @return \WP_REST_Response|\WP_Error |
| 364 | 364 | */ |
| 365 | 365 | public function delete_item( $request ) { |
| 366 | - $id = (int) $request['id']; |
|
| 367 | - $force = isset( $request['force'] ) ? (bool) $request['force'] : false; |
|
| 366 | + $id = (int) $request[ 'id' ]; |
|
| 367 | + $force = isset( $request[ 'force' ] ) ? (bool) $request[ 'force' ] : false; |
|
| 368 | 368 | |
| 369 | 369 | // We don't support trashing for this type, error out. |
| 370 | 370 | if ( ! $force ) { |
@@ -414,13 +414,13 @@ discard block |
||
| 414 | 414 | $data = new \stdClass(); |
| 415 | 415 | |
| 416 | 416 | // Post ID. |
| 417 | - if ( isset( $request['id'] ) ) { |
|
| 418 | - $data->ID = absint( $request['id'] ); |
|
| 417 | + if ( isset( $request[ 'id' ] ) ) { |
|
| 418 | + $data->ID = absint( $request[ 'id' ] ); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | // Validate required POST fields. |
| 422 | 422 | if ( 'POST' === $request->get_method() && empty( $data->ID ) ) { |
| 423 | - $data->post_title = ! empty( $request['name'] ) ? $request['name'] : sprintf( __( 'Webhook created on %s', 'woocommerce' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Webhook created on date parsed by strftime', 'woocommerce' ) ) ); // @codingStandardsIgnoreLine |
|
| 423 | + $data->post_title = ! empty( $request[ 'name' ] ) ? $request[ 'name' ] : sprintf( __( 'Webhook created on %s', 'woocommerce' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Webhook created on date parsed by strftime', 'woocommerce' ) ) ); // @codingStandardsIgnoreLine |
|
| 424 | 424 | |
| 425 | 425 | // Post author. |
| 426 | 426 | $data->post_author = get_current_user_id(); |
@@ -433,8 +433,8 @@ discard block |
||
| 433 | 433 | } else { |
| 434 | 434 | |
| 435 | 435 | // Allow edit post title. |
| 436 | - if ( ! empty( $request['name'] ) ) { |
|
| 437 | - $data->post_title = $request['name']; |
|
| 436 | + if ( ! empty( $request[ 'name' ] ) ) { |
|
| 437 | + $data->post_title = $request[ 'name' ]; |
|
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | |
@@ -606,21 +606,21 @@ discard block |
||
| 606 | 606 | public function get_collection_params() { |
| 607 | 607 | $params = parent::get_collection_params(); |
| 608 | 608 | |
| 609 | - $params['context']['default'] = 'view'; |
|
| 609 | + $params[ 'context' ][ 'default' ] = 'view'; |
|
| 610 | 610 | |
| 611 | - $params['after'] = array( |
|
| 611 | + $params[ 'after' ] = array( |
|
| 612 | 612 | 'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ), |
| 613 | 613 | 'type' => 'string', |
| 614 | 614 | 'format' => 'date-time', |
| 615 | 615 | 'validate_callback' => 'rest_validate_request_arg', |
| 616 | 616 | ); |
| 617 | - $params['before'] = array( |
|
| 617 | + $params[ 'before' ] = array( |
|
| 618 | 618 | 'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ), |
| 619 | 619 | 'type' => 'string', |
| 620 | 620 | 'format' => 'date-time', |
| 621 | 621 | 'validate_callback' => 'rest_validate_request_arg', |
| 622 | 622 | ); |
| 623 | - $params['exclude'] = array( |
|
| 623 | + $params[ 'exclude' ] = array( |
|
| 624 | 624 | 'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ), |
| 625 | 625 | 'type' => 'array', |
| 626 | 626 | 'items' => array( |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | 'default' => array(), |
| 630 | 630 | 'sanitize_callback' => 'wp_parse_id_list', |
| 631 | 631 | ); |
| 632 | - $params['include'] = array( |
|
| 632 | + $params[ 'include' ] = array( |
|
| 633 | 633 | 'description' => __( 'Limit result set to specific ids.', 'woocommerce' ), |
| 634 | 634 | 'type' => 'array', |
| 635 | 635 | 'items' => array( |
@@ -638,20 +638,20 @@ discard block |
||
| 638 | 638 | 'default' => array(), |
| 639 | 639 | 'sanitize_callback' => 'wp_parse_id_list', |
| 640 | 640 | ); |
| 641 | - $params['offset'] = array( |
|
| 641 | + $params[ 'offset' ] = array( |
|
| 642 | 642 | 'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ), |
| 643 | 643 | 'type' => 'integer', |
| 644 | 644 | 'sanitize_callback' => 'absint', |
| 645 | 645 | 'validate_callback' => 'rest_validate_request_arg', |
| 646 | 646 | ); |
| 647 | - $params['order'] = array( |
|
| 647 | + $params[ 'order' ] = array( |
|
| 648 | 648 | 'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ), |
| 649 | 649 | 'type' => 'string', |
| 650 | 650 | 'default' => 'desc', |
| 651 | 651 | 'enum' => array( 'asc', 'desc' ), |
| 652 | 652 | 'validate_callback' => 'rest_validate_request_arg', |
| 653 | 653 | ); |
| 654 | - $params['orderby'] = array( |
|
| 654 | + $params[ 'orderby' ] = array( |
|
| 655 | 655 | 'description' => __( 'Sort collection by object attribute.', 'woocommerce' ), |
| 656 | 656 | 'type' => 'string', |
| 657 | 657 | 'default' => 'date', |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | ), |
| 663 | 663 | 'validate_callback' => 'rest_validate_request_arg', |
| 664 | 664 | ); |
| 665 | - $params['status'] = array( |
|
| 665 | + $params[ 'status' ] = array( |
|
| 666 | 666 | 'default' => 'all', |
| 667 | 667 | 'description' => __( 'Limit result set to webhooks assigned a specific status.', 'woocommerce' ), |
| 668 | 668 | 'type' => 'string', |
@@ -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' ), |
| 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' ), |
| 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' ), |
| 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' ), |
| 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' ), |
| 1179 | 1179 | 'type' => 'string', |
| 1180 | 1180 | 'validate_callback' => 'rest_validate_request_arg', |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | foreach ( $wc_shipping->get_shipping_methods() as $id => $shipping_method ) { |
| 85 | 85 | $method = $this->prepare_item_for_response( $shipping_method, $request ); |
| 86 | 86 | $method = $this->prepare_response_for_collection( $method ); |
| 87 | - $response[] = $method; |
|
| 87 | + $response[ ] = $method; |
|
| 88 | 88 | } |
| 89 | 89 | return rest_ensure_response( $response ); |
| 90 | 90 | } |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | public function get_item( $request ) { |
| 99 | 99 | $wc_shipping = \WC_Shipping::instance(); |
| 100 | 100 | $methods = $wc_shipping->get_shipping_methods(); |
| 101 | - if ( empty( $methods[ $request['id'] ] ) ) { |
|
| 101 | + if ( empty( $methods[ $request[ 'id' ] ] ) ) { |
|
| 102 | 102 | return new \WP_Error( 'woocommerce_rest_shipping_method_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - $method = $methods[ $request['id'] ]; |
|
| 105 | + $method = $methods[ $request[ 'id' ] ]; |
|
| 106 | 106 | $response = $this->prepare_item_for_response( $method, $request ); |
| 107 | 107 | |
| 108 | 108 | return rest_ensure_response( $response ); |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | * @param array $methods Supported methods. read, create. |
| 56 | 56 | */ |
| 57 | 57 | protected function register_items_route( $methods = [ 'read', 'create' ] ) { |
| 58 | - $routes = []; |
|
| 59 | - $routes['schema'] = [ $this, 'get_public_item_schema' ]; |
|
| 58 | + $routes = [ ]; |
|
| 59 | + $routes[ 'schema' ] = [ $this, 'get_public_item_schema' ]; |
|
| 60 | 60 | |
| 61 | 61 | if ( in_array( 'read', $methods, true ) ) { |
| 62 | - $routes[] = array( |
|
| 62 | + $routes[ ] = array( |
|
| 63 | 63 | 'methods' => \WP_REST_Server::READABLE, |
| 64 | 64 | 'callback' => array( $this, 'get_items' ), |
| 65 | 65 | 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | if ( in_array( 'create', $methods, true ) ) { |
| 71 | - $routes[] = array( |
|
| 71 | + $routes[ ] = array( |
|
| 72 | 72 | 'methods' => \WP_REST_Server::CREATABLE, |
| 73 | 73 | 'callback' => array( $this, 'create_item' ), |
| 74 | 74 | 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | * @param array $methods Supported methods. read, create. |
| 91 | 91 | */ |
| 92 | 92 | protected function register_item_route( $methods = [ 'read', 'edit', 'delete' ] ) { |
| 93 | - $routes = []; |
|
| 94 | - $routes['schema'] = [ $this, 'get_public_item_schema' ]; |
|
| 95 | - $routes['args'] = [ |
|
| 93 | + $routes = [ ]; |
|
| 94 | + $routes[ 'schema' ] = [ $this, 'get_public_item_schema' ]; |
|
| 95 | + $routes[ 'args' ] = [ |
|
| 96 | 96 | 'id' => [ |
| 97 | 97 | 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), |
| 98 | 98 | 'type' => 'integer', |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | ]; |
| 101 | 101 | |
| 102 | 102 | if ( in_array( 'read', $methods, true ) ) { |
| 103 | - $routes[] = array( |
|
| 103 | + $routes[ ] = array( |
|
| 104 | 104 | 'methods' => \WP_REST_Server::READABLE, |
| 105 | 105 | 'callback' => array( $this, 'get_item' ), |
| 106 | 106 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | if ( in_array( 'edit', $methods, true ) ) { |
| 118 | - $routes[] = array( |
|
| 118 | + $routes[ ] = array( |
|
| 119 | 119 | 'methods' => \WP_REST_Server::EDITABLE, |
| 120 | 120 | 'callback' => array( $this, 'update_item' ), |
| 121 | 121 | 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | if ( in_array( 'delete', $methods, true ) ) { |
| 127 | - $routes[] = array( |
|
| 127 | + $routes[ ] = array( |
|
| 128 | 128 | 'methods' => \WP_REST_Server::DELETABLE, |
| 129 | 129 | 'callback' => array( $this, 'delete_item' ), |
| 130 | 130 | 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | protected function add_additional_fields_schema( $schema ) { |
| 156 | 156 | $schema = parent::add_additional_fields_schema( $schema ); |
| 157 | - $object_type = $schema['title']; |
|
| 158 | - $schema['properties'] = apply_filters( 'woocommerce_rest_' . $object_type . '_schema', $schema['properties'] ); |
|
| 157 | + $object_type = $schema[ 'title' ]; |
|
| 158 | + $schema[ 'properties' ] = apply_filters( 'woocommerce_rest_' . $object_type . '_schema', $schema[ 'properties' ] ); |
|
| 159 | 159 | return $schema; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * @return string |
| 272 | 272 | */ |
| 273 | 273 | protected function get_request_context( $request ) { |
| 274 | - return ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
| 274 | + return ! empty( $request[ 'context' ] ) ? $request[ 'context' ] : 'view'; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | protected function get_item_title() { |
| 314 | 314 | $schema = $this->get_item_schema(); |
| 315 | - return $schema['title']; |
|
| 315 | + return $schema[ 'title' ]; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -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' ), 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 | } |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | // Check if WooCommerce.com account is connected. |
| 37 | 37 | $woo_com_connected = 'no'; |
| 38 | 38 | $helper_options = get_option( 'woocommerce_helper_data', array() ); |
| 39 | - if ( array_key_exists( 'auth', $helper_options ) && ! empty( $helper_options['auth'] ) ) { |
|
| 39 | + if ( array_key_exists( 'auth', $helper_options ) && ! empty( $helper_options[ 'auth' ] ) ) { |
|
| 40 | 40 | $woo_com_connected = 'yes'; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -55,19 +55,19 @@ discard block |
||
| 55 | 55 | * @return array |
| 56 | 56 | */ |
| 57 | 57 | public function get_dropin_and_mu_plugin_data() { |
| 58 | - $plugins = [ |
|
| 59 | - 'dropins' => [], |
|
| 60 | - 'mu_plugins' => [], |
|
| 58 | + $plugins = [ |
|
| 59 | + 'dropins' => [ ], |
|
| 60 | + 'mu_plugins' => [ ], |
|
| 61 | 61 | ]; |
| 62 | 62 | |
| 63 | 63 | foreach ( get_dropins() as $plugin => $data ) { |
| 64 | - $data['plugin_file'] = $plugin; |
|
| 65 | - $plugins['dropins'][] = $this->format_plugin_data( $data ); |
|
| 64 | + $data[ 'plugin_file' ] = $plugin; |
|
| 65 | + $plugins[ 'dropins' ][ ] = $this->format_plugin_data( $data ); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | foreach ( get_mu_plugins() as $plugin => $data ) { |
| 69 | - $data['plugin_file'] = $plugin; |
|
| 70 | - $plugins['mu_plugins'][] = $this->format_plugin_data( $data ); |
|
| 69 | + $data[ 'plugin_file' ] = $plugin; |
|
| 70 | + $plugins[ 'mu_plugins' ][ ] = $this->format_plugin_data( $data ); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | return $plugins; |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | protected function get_inactive_plugins() { |
| 98 | 98 | $plugins = get_plugins(); |
| 99 | 99 | $active_plugins = $this->get_active_plugins(); |
| 100 | - $inactive_plugins = []; |
|
| 100 | + $inactive_plugins = [ ]; |
|
| 101 | 101 | |
| 102 | 102 | foreach ( $plugins as $plugin => $data ) { |
| 103 | 103 | if ( in_array( $plugin, $active_plugins, true ) ) { |
| 104 | 104 | continue; |
| 105 | 105 | } |
| 106 | - $inactive_plugins[] = $plugin; |
|
| 106 | + $inactive_plugins[ ] = $plugin; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | return $inactive_plugins; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | protected function get_plugin_data( $plugin ) { |
| 119 | 119 | $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
| 120 | - $data['plugin_file'] = $plugin; |
|
| 120 | + $data[ 'plugin_file' ] = $plugin; |
|
| 121 | 121 | return $data; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -128,22 +128,22 @@ discard block |
||
| 128 | 128 | * @return array Formatted data. |
| 129 | 129 | */ |
| 130 | 130 | protected function format_plugin_data( $data ) { |
| 131 | - $version_latest = $data['Version']; |
|
| 131 | + $version_latest = $data[ 'Version' ]; |
|
| 132 | 132 | |
| 133 | 133 | // Find latest version. |
| 134 | - if ( isset( $this->available_updates[ $data['plugin_file'] ]->update->new_version ) ) { |
|
| 135 | - $version_latest = $this->available_updates[ $data['plugin_file'] ]->update->new_version; |
|
| 134 | + if ( isset( $this->available_updates[ $data[ 'plugin_file' ] ]->update->new_version ) ) { |
|
| 135 | + $version_latest = $this->available_updates[ $data[ 'plugin_file' ] ]->update->new_version; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | return array( |
| 139 | - 'plugin' => $data['plugin_file'], |
|
| 140 | - 'name' => $data['Name'], |
|
| 141 | - 'version' => $data['Version'], |
|
| 139 | + 'plugin' => $data[ 'plugin_file' ], |
|
| 140 | + 'name' => $data[ 'Name' ], |
|
| 141 | + 'version' => $data[ 'Version' ], |
|
| 142 | 142 | 'version_latest' => $version_latest, |
| 143 | - 'url' => $data['PluginURI'], |
|
| 144 | - 'author_name' => $data['AuthorName'], |
|
| 145 | - 'author_url' => esc_url_raw( $data['AuthorURI'] ), |
|
| 146 | - 'network_activated' => $data['Network'], |
|
| 143 | + 'url' => $data[ 'PluginURI' ], |
|
| 144 | + 'author_name' => $data[ 'AuthorName' ], |
|
| 145 | + 'author_url' => esc_url_raw( $data[ 'AuthorURI' ] ), |
|
| 146 | + 'network_activated' => $data[ 'Network' ], |
|
| 147 | 147 | ); |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -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' ); |
| 161 | 161 | } |
@@ -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. |