Test Failed
Push — master ( a5e4c3...7495fa )
by Mike
43:00
created
src/Server.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
 
8 8
 namespace WooCommerce\RestApi;
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-if ( file_exists( __DIR__ . '/../vendor/autoload.php' ) ) {
12
+if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
13 13
 	require __DIR__ . '/../vendor/autoload.php';
14 14
 } else {
15 15
 	return;
@@ -34,17 +34,17 @@  discard block
 block discarded – undo
34 34
 	 * Hook into WordPress ready to init the REST API as needed.
35 35
 	 */
36 36
 	public function init() {
37
-		add_action( 'rest_api_init', array( $this, 'register_rest_routes' ), 10 );
37
+		add_action('rest_api_init', array($this, 'register_rest_routes'), 10);
38 38
 	}
39 39
 
40 40
 	/**
41 41
 	 * Register REST API routes.
42 42
 	 */
43 43
 	public function register_rest_routes() {
44
-		foreach ( $this->get_rest_namespaces() as $namespace => $controllers ) {
45
-			foreach ( $controllers as $controller_name => $controller_class ) {
46
-				$this->controllers[ $namespace ][ $controller_name ] = new $controller_class();
47
-				$this->controllers[ $namespace ][ $controller_name ]->register_routes();
44
+		foreach ($this->get_rest_namespaces() as $namespace => $controllers) {
45
+			foreach ($controllers as $controller_name => $controller_class) {
46
+				$this->controllers[$namespace][$controller_name] = new $controller_class();
47
+				$this->controllers[$namespace][$controller_name]->register_routes();
48 48
 			}
49 49
 		}
50 50
 	}
Please login to merge, or discard this patch.
src/Controllers/Version3/class-wc-rest-order-refunds-controller.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since   2.6.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * REST API Order Refunds controller class.
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 	 * @param  bool            $creating If is creating a new object.
34 34
 	 * @return WP_Error|WC_Data The prepared item, or WP_Error object on failure.
35 35
 	 */
36
-	protected function prepare_object_for_database( $request, $creating = false ) {
37
-		$order = wc_get_order( (int) $request['order_id'] );
36
+	protected function prepare_object_for_database($request, $creating = false) {
37
+		$order = wc_get_order((int) $request['order_id']);
38 38
 
39
-		if ( ! $order ) {
40
-			return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce' ), 404 );
39
+		if ( ! $order) {
40
+			return new WP_Error('woocommerce_rest_invalid_order_id', __('Invalid order ID.', 'woocommerce'), 404);
41 41
 		}
42 42
 
43
-		if ( 0 > $request['amount'] ) {
44
-			return new WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce' ), 400 );
43
+		if (0 > $request['amount']) {
44
+			return new WP_Error('woocommerce_rest_invalid_order_refund', __('Refund amount must be greater than zero.', 'woocommerce'), 400);
45 45
 		}
46 46
 
47 47
 		// Create the refund.
@@ -49,24 +49,24 @@  discard block
 block discarded – undo
49 49
 			array(
50 50
 				'order_id'       => $order->get_id(),
51 51
 				'amount'         => $request['amount'],
52
-				'reason'         => empty( $request['reason'] ) ? null : $request['reason'],
53
-				'line_items'     => empty( $request['line_items'] ) ? array() : $request['line_items'],
54
-				'refund_payment' => is_bool( $request['api_refund'] ) ? $request['api_refund'] : true,
52
+				'reason'         => empty($request['reason']) ? null : $request['reason'],
53
+				'line_items'     => empty($request['line_items']) ? array() : $request['line_items'],
54
+				'refund_payment' => is_bool($request['api_refund']) ? $request['api_refund'] : true,
55 55
 				'restock_items'  => true,
56 56
 			)
57 57
 		);
58 58
 
59
-		if ( is_wp_error( $refund ) ) {
60
-			return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', $refund->get_error_message(), 500 );
59
+		if (is_wp_error($refund)) {
60
+			return new WP_Error('woocommerce_rest_cannot_create_order_refund', $refund->get_error_message(), 500);
61 61
 		}
62 62
 
63
-		if ( ! $refund ) {
64
-			return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce' ), 500 );
63
+		if ( ! $refund) {
64
+			return new WP_Error('woocommerce_rest_cannot_create_order_refund', __('Cannot create order refund, please try again.', 'woocommerce'), 500);
65 65
 		}
66 66
 
67
-		if ( ! empty( $request['meta_data'] ) && is_array( $request['meta_data'] ) ) {
68
-			foreach ( $request['meta_data'] as $meta ) {
69
-				$refund->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' );
67
+		if ( ! empty($request['meta_data']) && is_array($request['meta_data'])) {
68
+			foreach ($request['meta_data'] as $meta) {
69
+				$refund->update_meta_data($meta['key'], $meta['value'], isset($meta['id']) ? $meta['id'] : '');
70 70
 			}
71 71
 			$refund->save_meta_data();
72 72
 		}
@@ -81,6 +81,6 @@  discard block
 block discarded – undo
81 81
 		 * @param WP_REST_Request $request  Request object.
82 82
 		 * @param bool            $creating If is creating a new object.
83 83
 		 */
84
-		return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $refund, $request, $creating );
84
+		return apply_filters("woocommerce_rest_pre_insert_{$this->post_type}_object", $refund, $request, $creating);
85 85
 	}
86 86
 }
Please login to merge, or discard this patch.
Controllers/Version3/class-wc-rest-product-shipping-classes-controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
  * @since   2.6.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * REST API Product Shipping Classes controller class.
Please login to merge, or discard this patch.
src/Controllers/Version3/class-wc-rest-settings-controller.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since   3.0.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * REST API Settings controller class.
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	public function register_routes() {
32 32
 		parent::register_routes();
33
-		register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array(
33
+		register_rest_route($this->namespace, '/' . $this->rest_base . '/batch', array(
34 34
 			array(
35 35
 				'methods'             => WP_REST_Server::EDITABLE,
36
-				'callback'            => array( $this, 'batch_items' ),
37
-				'permission_callback' => array( $this, 'update_items_permissions_check' ),
36
+				'callback'            => array($this, 'batch_items'),
37
+				'permission_callback' => array($this, 'update_items_permissions_check'),
38 38
 			),
39
-			'schema' => array( $this, 'get_public_batch_schema' ),
40
-		) );
39
+			'schema' => array($this, 'get_public_batch_schema'),
40
+		));
41 41
 	}
42 42
 
43 43
 	/**
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
 	 * @param WP_REST_Request $request Full data about the request.
47 47
 	 * @return WP_Error|bool
48 48
 	 */
49
-	public function update_items_permissions_check( $request ) {
50
-		if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
51
-			return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
49
+	public function update_items_permissions_check($request) {
50
+		if ( ! wc_rest_check_manager_permissions('settings', 'edit')) {
51
+			return new WP_Error('woocommerce_rest_cannot_edit', __('Sorry, you cannot edit this resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
52 52
 		}
53 53
 
54 54
 		return true;
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 	 * @param  WP_REST_Request $request Request data.
61 61
 	 * @return WP_Error|WP_REST_Response
62 62
 	 */
63
-	public function update_item( $request ) {
63
+	public function update_item($request) {
64 64
 		$options_controller = new WC_REST_Setting_Options_Controller();
65
-		$response           = $options_controller->update_item( $request );
65
+		$response           = $options_controller->update_item($request);
66 66
 
67 67
 		return $response;
68 68
 	}
@@ -80,33 +80,33 @@  discard block
 block discarded – undo
80 80
 			'type'       => 'object',
81 81
 			'properties' => array(
82 82
 				'id'          => array(
83
-					'description' => __( 'A unique identifier that can be used to link settings together.', 'woocommerce' ),
83
+					'description' => __('A unique identifier that can be used to link settings together.', 'woocommerce'),
84 84
 					'type'        => 'string',
85
-					'context'     => array( 'view', 'edit' ),
85
+					'context'     => array('view', 'edit'),
86 86
 				),
87 87
 				'label'       => array(
88
-					'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ),
88
+					'description' => __('A human readable label for the setting used in interfaces.', 'woocommerce'),
89 89
 					'type'        => 'string',
90
-					'context'     => array( 'view', 'edit' ),
90
+					'context'     => array('view', 'edit'),
91 91
 				),
92 92
 				'description' => array(
93
-					'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ),
93
+					'description' => __('A human readable description for the setting used in interfaces.', 'woocommerce'),
94 94
 					'type'        => 'string',
95
-					'context'     => array( 'view', 'edit' ),
95
+					'context'     => array('view', 'edit'),
96 96
 				),
97 97
 				'parent_id'   => array(
98
-					'description' => __( 'ID of parent grouping.', 'woocommerce' ),
98
+					'description' => __('ID of parent grouping.', 'woocommerce'),
99 99
 					'type'        => 'string',
100
-					'context'     => array( 'view', 'edit' ),
100
+					'context'     => array('view', 'edit'),
101 101
 				),
102 102
 				'sub_groups'  => array(
103
-					'description' => __( 'IDs for settings sub groups.', 'woocommerce' ),
103
+					'description' => __('IDs for settings sub groups.', 'woocommerce'),
104 104
 					'type'        => 'string',
105
-					'context'     => array( 'view', 'edit' ),
105
+					'context'     => array('view', 'edit'),
106 106
 				),
107 107
 			),
108 108
 		);
109 109
 
110
-		return $this->add_additional_fields_schema( $schema );
110
+		return $this->add_additional_fields_schema($schema);
111 111
 	}
112 112
 }
Please login to merge, or discard this patch.
Controllers/Version3/class-wc-rest-shipping-zone-locations-controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
  * @since   3.0.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * REST API Shipping Zone Locations class.
Please login to merge, or discard this patch.
Controllers/Version3/class-wc-rest-report-products-totals-controller.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since   3.5.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * REST API Reports Products Totals controller class.
@@ -46,16 +46,16 @@  discard block
 block discarded – undo
46 46
 				'hide_empty' => false,
47 47
 			)
48 48
 		);
49
-		$data  = array();
49
+		$data = array();
50 50
 
51
-		foreach ( $terms as $product_type ) {
52
-			if ( ! isset( $types[ $product_type->name ] ) ) {
51
+		foreach ($terms as $product_type) {
52
+			if ( ! isset($types[$product_type->name])) {
53 53
 				continue;
54 54
 			}
55 55
 
56 56
 			$data[] = array(
57 57
 				'slug'  => $product_type->name,
58
-				'name'  => $types[ $product_type->name ],
58
+				'name'  => $types[$product_type->name],
59 59
 				'total' => (int) $product_type->count,
60 60
 			);
61 61
 		}
@@ -70,19 +70,19 @@  discard block
 block discarded – undo
70 70
 	 * @param  WP_REST_Request $request Request object.
71 71
 	 * @return WP_REST_Response $response Response data.
72 72
 	 */
73
-	public function prepare_item_for_response( $report, $request ) {
73
+	public function prepare_item_for_response($report, $request) {
74 74
 		$data = array(
75 75
 			'slug'  => $report->slug,
76 76
 			'name'  => $report->name,
77 77
 			'total' => $report->total,
78 78
 		);
79 79
 
80
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
81
-		$data    = $this->add_additional_fields_to_object( $data, $request );
82
-		$data    = $this->filter_response_by_context( $data, $context );
80
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
81
+		$data    = $this->add_additional_fields_to_object($data, $request);
82
+		$data    = $this->filter_response_by_context($data, $context);
83 83
 
84 84
 		// Wrap the data in a response object.
85
-		$response = rest_ensure_response( $data );
85
+		$response = rest_ensure_response($data);
86 86
 
87 87
 		/**
88 88
 		 * Filter a report returned from the API.
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 		 * @param object           $report   The original report object.
94 94
 		 * @param WP_REST_Request  $request  Request used to generate the response.
95 95
 		 */
96
-		return apply_filters( 'woocommerce_rest_prepare_report_products_count', $response, $report, $request );
96
+		return apply_filters('woocommerce_rest_prepare_report_products_count', $response, $report, $request);
97 97
 	}
98 98
 
99 99
 	/**
@@ -108,26 +108,26 @@  discard block
 block discarded – undo
108 108
 			'type'       => 'object',
109 109
 			'properties' => array(
110 110
 				'slug'  => array(
111
-					'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce' ),
111
+					'description' => __('An alphanumeric identifier for the resource.', 'woocommerce'),
112 112
 					'type'        => 'string',
113
-					'context'     => array( 'view' ),
113
+					'context'     => array('view'),
114 114
 					'readonly'    => true,
115 115
 				),
116 116
 				'name'  => array(
117
-					'description' => __( 'Product type name.', 'woocommerce' ),
117
+					'description' => __('Product type name.', 'woocommerce'),
118 118
 					'type'        => 'string',
119
-					'context'     => array( 'view' ),
119
+					'context'     => array('view'),
120 120
 					'readonly'    => true,
121 121
 				),
122 122
 				'total' => array(
123
-					'description' => __( 'Amount of products.', 'woocommerce' ),
123
+					'description' => __('Amount of products.', 'woocommerce'),
124 124
 					'type'        => 'string',
125
-					'context'     => array( 'view' ),
125
+					'context'     => array('view'),
126 126
 					'readonly'    => true,
127 127
 				),
128 128
 			),
129 129
 		);
130 130
 
131
-		return $this->add_additional_fields_schema( $schema );
131
+		return $this->add_additional_fields_schema($schema);
132 132
 	}
133 133
 }
Please login to merge, or discard this patch.
src/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
  * @since   3.0.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * REST API Shipping Zone Methods class.
Please login to merge, or discard this patch.
src/Controllers/Version3/class-wc-rest-posts-controller.php 1 patch
Spacing   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package WooCommerce/RestApi
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	 * @param  WP_REST_Request $request Full details about the request.
53 53
 	 * @return WP_Error|boolean
54 54
 	 */
55
-	public function get_items_permissions_check( $request ) {
56
-		if ( ! wc_rest_check_post_permissions( $this->post_type, 'read' ) ) {
57
-			return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
55
+	public function get_items_permissions_check($request) {
56
+		if ( ! wc_rest_check_post_permissions($this->post_type, 'read')) {
57
+			return new WP_Error('woocommerce_rest_cannot_view', __('Sorry, you cannot list resources.', 'woocommerce'), array('status' => rest_authorization_required_code()));
58 58
 		}
59 59
 
60 60
 		return true;
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 * @param  WP_REST_Request $request Full details about the request.
67 67
 	 * @return WP_Error|boolean
68 68
 	 */
69
-	public function create_item_permissions_check( $request ) {
70
-		if ( ! wc_rest_check_post_permissions( $this->post_type, 'create' ) ) {
71
-			return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
69
+	public function create_item_permissions_check($request) {
70
+		if ( ! wc_rest_check_post_permissions($this->post_type, 'create')) {
71
+			return new WP_Error('woocommerce_rest_cannot_create', __('Sorry, you are not allowed to create resources.', 'woocommerce'), array('status' => rest_authorization_required_code()));
72 72
 		}
73 73
 
74 74
 		return true;
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	 * @param  WP_REST_Request $request Full details about the request.
81 81
 	 * @return WP_Error|boolean
82 82
 	 */
83
-	public function get_item_permissions_check( $request ) {
84
-		$post = get_post( (int) $request['id'] );
83
+	public function get_item_permissions_check($request) {
84
+		$post = get_post((int) $request['id']);
85 85
 
86
-		if ( $post && ! wc_rest_check_post_permissions( $this->post_type, 'read', $post->ID ) ) {
87
-			return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
86
+		if ($post && ! wc_rest_check_post_permissions($this->post_type, 'read', $post->ID)) {
87
+			return new WP_Error('woocommerce_rest_cannot_view', __('Sorry, you cannot view this resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
88 88
 		}
89 89
 
90 90
 		return true;
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 	 * @param  WP_REST_Request $request Full details about the request.
97 97
 	 * @return WP_Error|boolean
98 98
 	 */
99
-	public function update_item_permissions_check( $request ) {
100
-		$post = get_post( (int) $request['id'] );
99
+	public function update_item_permissions_check($request) {
100
+		$post = get_post((int) $request['id']);
101 101
 
102
-		if ( $post && ! wc_rest_check_post_permissions( $this->post_type, 'edit', $post->ID ) ) {
103
-			return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
102
+		if ($post && ! wc_rest_check_post_permissions($this->post_type, 'edit', $post->ID)) {
103
+			return new WP_Error('woocommerce_rest_cannot_edit', __('Sorry, you are not allowed to edit this resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
104 104
 		}
105 105
 
106 106
 		return true;
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
 	 * @param  WP_REST_Request $request Full details about the request.
113 113
 	 * @return bool|WP_Error
114 114
 	 */
115
-	public function delete_item_permissions_check( $request ) {
116
-		$post = get_post( (int) $request['id'] );
115
+	public function delete_item_permissions_check($request) {
116
+		$post = get_post((int) $request['id']);
117 117
 
118
-		if ( $post && ! wc_rest_check_post_permissions( $this->post_type, 'delete', $post->ID ) ) {
119
-			return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
118
+		if ($post && ! wc_rest_check_post_permissions($this->post_type, 'delete', $post->ID)) {
119
+			return new WP_Error('woocommerce_rest_cannot_delete', __('Sorry, you are not allowed to delete this resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
120 120
 		}
121 121
 
122 122
 		return true;
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return boolean|WP_Error
131 131
 	 */
132
-	public function batch_items_permissions_check( $request ) {
133
-		if ( ! wc_rest_check_post_permissions( $this->post_type, 'batch' ) ) {
134
-			return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
132
+	public function batch_items_permissions_check($request) {
133
+		if ( ! wc_rest_check_post_permissions($this->post_type, 'batch')) {
134
+			return new WP_Error('woocommerce_rest_cannot_batch', __('Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
135 135
 		}
136 136
 
137 137
 		return true;
@@ -143,21 +143,21 @@  discard block
 block discarded – undo
143 143
 	 * @param WP_REST_Request $request Full details about the request.
144 144
 	 * @return WP_Error|WP_REST_Response
145 145
 	 */
146
-	public function get_item( $request ) {
146
+	public function get_item($request) {
147 147
 		$id   = (int) $request['id'];
148
-		$post = get_post( $id );
148
+		$post = get_post($id);
149 149
 
150
-		if ( ! empty( $post->post_type ) && 'product_variation' === $post->post_type && 'product' === $this->post_type ) {
151
-			return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce' ), array( 'status' => 404 ) );
152
-		} elseif ( empty( $id ) || empty( $post->ID ) || $post->post_type !== $this->post_type ) {
153
-			return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
150
+		if ( ! empty($post->post_type) && 'product_variation' === $post->post_type && 'product' === $this->post_type) {
151
+			return new WP_Error("woocommerce_rest_invalid_{$this->post_type}_id", __('To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce'), array('status' => 404));
152
+		} elseif (empty($id) || empty($post->ID) || $post->post_type !== $this->post_type) {
153
+			return new WP_Error("woocommerce_rest_invalid_{$this->post_type}_id", __('Invalid ID.', 'woocommerce'), array('status' => 404));
154 154
 		}
155 155
 
156
-		$data = $this->prepare_item_for_response( $post, $request );
157
-		$response = rest_ensure_response( $data );
156
+		$data = $this->prepare_item_for_response($post, $request);
157
+		$response = rest_ensure_response($data);
158 158
 
159
-		if ( $this->public ) {
160
-			$response->link_header( 'alternate', get_permalink( $id ), array( 'type' => 'text/html' ) );
159
+		if ($this->public) {
160
+			$response->link_header('alternate', get_permalink($id), array('type' => 'text/html'));
161 161
 		}
162 162
 
163 163
 		return $response;
@@ -169,39 +169,39 @@  discard block
 block discarded – undo
169 169
 	 * @param WP_REST_Request $request Full details about the request.
170 170
 	 * @return WP_Error|WP_REST_Response
171 171
 	 */
172
-	public function create_item( $request ) {
173
-		if ( ! empty( $request['id'] ) ) {
172
+	public function create_item($request) {
173
+		if ( ! empty($request['id'])) {
174 174
 			/* translators: %s: post type */
175
-			return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
175
+			return new WP_Error("woocommerce_rest_{$this->post_type}_exists", sprintf(__('Cannot create existing %s.', 'woocommerce'), $this->post_type), array('status' => 400));
176 176
 		}
177 177
 
178
-		$post = $this->prepare_item_for_database( $request );
179
-		if ( is_wp_error( $post ) ) {
178
+		$post = $this->prepare_item_for_database($request);
179
+		if (is_wp_error($post)) {
180 180
 			return $post;
181 181
 		}
182 182
 
183 183
 		$post->post_type = $this->post_type;
184
-		$post_id         = wp_insert_post( $post, true );
184
+		$post_id         = wp_insert_post($post, true);
185 185
 
186
-		if ( is_wp_error( $post_id ) ) {
186
+		if (is_wp_error($post_id)) {
187 187
 
188
-			if ( in_array( $post_id->get_error_code(), array( 'db_insert_error' ) ) ) {
189
-				$post_id->add_data( array( 'status' => 500 ) );
188
+			if (in_array($post_id->get_error_code(), array('db_insert_error'))) {
189
+				$post_id->add_data(array('status' => 500));
190 190
 			} else {
191
-				$post_id->add_data( array( 'status' => 400 ) );
191
+				$post_id->add_data(array('status' => 400));
192 192
 			}
193 193
 			return $post_id;
194 194
 		}
195 195
 		$post->ID = $post_id;
196
-		$post     = get_post( $post_id );
196
+		$post     = get_post($post_id);
197 197
 
198
-		$this->update_additional_fields_for_object( $post, $request );
198
+		$this->update_additional_fields_for_object($post, $request);
199 199
 
200 200
 		// Add meta fields.
201
-		$meta_fields = $this->add_post_meta_fields( $post, $request );
202
-		if ( is_wp_error( $meta_fields ) ) {
201
+		$meta_fields = $this->add_post_meta_fields($post, $request);
202
+		if (is_wp_error($meta_fields)) {
203 203
 			// Remove post.
204
-			$this->delete_post( $post );
204
+			$this->delete_post($post);
205 205
 
206 206
 			return $meta_fields;
207 207
 		}
@@ -213,13 +213,13 @@  discard block
 block discarded – undo
213 213
 		 * @param WP_REST_Request $request   Request object.
214 214
 		 * @param boolean         $creating  True when creating item, false when updating.
215 215
 		 */
216
-		do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, true );
216
+		do_action("woocommerce_rest_insert_{$this->post_type}", $post, $request, true);
217 217
 
218
-		$request->set_param( 'context', 'edit' );
219
-		$response = $this->prepare_item_for_response( $post, $request );
220
-		$response = rest_ensure_response( $response );
221
-		$response->set_status( 201 );
222
-		$response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $post_id ) ) );
218
+		$request->set_param('context', 'edit');
219
+		$response = $this->prepare_item_for_response($post, $request);
220
+		$response = rest_ensure_response($response);
221
+		$response->set_status(201);
222
+		$response->header('Location', rest_url(sprintf('/%s/%s/%d', $this->namespace, $this->rest_base, $post_id)));
223 223
 
224 224
 		return $response;
225 225
 	}
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	 * @param WP_REST_Request $request WP_REST_Request Object.
232 232
 	 * @return bool|WP_Error
233 233
 	 */
234
-	protected function add_post_meta_fields( $post, $request ) {
234
+	protected function add_post_meta_fields($post, $request) {
235 235
 		return true;
236 236
 	}
237 237
 
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @param WP_Post $post Post object.
242 242
 	 */
243
-	protected function delete_post( $post ) {
244
-		wp_delete_post( $post->ID, true );
243
+	protected function delete_post($post) {
244
+		wp_delete_post($post->ID, true);
245 245
 	}
246 246
 
247 247
 	/**
@@ -250,37 +250,37 @@  discard block
 block discarded – undo
250 250
 	 * @param WP_REST_Request $request Full details about the request.
251 251
 	 * @return WP_Error|WP_REST_Response
252 252
 	 */
253
-	public function update_item( $request ) {
253
+	public function update_item($request) {
254 254
 		$id   = (int) $request['id'];
255
-		$post = get_post( $id );
255
+		$post = get_post($id);
256 256
 
257
-		if ( ! empty( $post->post_type ) && 'product_variation' === $post->post_type && 'product' === $this->post_type ) {
258
-			return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce' ), array( 'status' => 404 ) );
259
-		} elseif ( empty( $id ) || empty( $post->ID ) || $post->post_type !== $this->post_type ) {
260
-			return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
257
+		if ( ! empty($post->post_type) && 'product_variation' === $post->post_type && 'product' === $this->post_type) {
258
+			return new WP_Error("woocommerce_rest_invalid_{$this->post_type}_id", __('To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce'), array('status' => 404));
259
+		} elseif (empty($id) || empty($post->ID) || $post->post_type !== $this->post_type) {
260
+			return new WP_Error("woocommerce_rest_{$this->post_type}_invalid_id", __('ID is invalid.', 'woocommerce'), array('status' => 400));
261 261
 		}
262 262
 
263
-		$post = $this->prepare_item_for_database( $request );
264
-		if ( is_wp_error( $post ) ) {
263
+		$post = $this->prepare_item_for_database($request);
264
+		if (is_wp_error($post)) {
265 265
 			return $post;
266 266
 		}
267 267
 		// Convert the post object to an array, otherwise wp_update_post will expect non-escaped input.
268
-		$post_id = wp_update_post( (array) $post, true );
269
-		if ( is_wp_error( $post_id ) ) {
270
-			if ( in_array( $post_id->get_error_code(), array( 'db_update_error' ) ) ) {
271
-				$post_id->add_data( array( 'status' => 500 ) );
268
+		$post_id = wp_update_post((array) $post, true);
269
+		if (is_wp_error($post_id)) {
270
+			if (in_array($post_id->get_error_code(), array('db_update_error'))) {
271
+				$post_id->add_data(array('status' => 500));
272 272
 			} else {
273
-				$post_id->add_data( array( 'status' => 400 ) );
273
+				$post_id->add_data(array('status' => 400));
274 274
 			}
275 275
 			return $post_id;
276 276
 		}
277 277
 
278
-		$post = get_post( $post_id );
279
-		$this->update_additional_fields_for_object( $post, $request );
278
+		$post = get_post($post_id);
279
+		$this->update_additional_fields_for_object($post, $request);
280 280
 
281 281
 		// Update meta fields.
282
-		$meta_fields = $this->update_post_meta_fields( $post, $request );
283
-		if ( is_wp_error( $meta_fields ) ) {
282
+		$meta_fields = $this->update_post_meta_fields($post, $request);
283
+		if (is_wp_error($meta_fields)) {
284 284
 			return $meta_fields;
285 285
 		}
286 286
 
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
 		 * @param WP_REST_Request $request   Request object.
292 292
 		 * @param boolean         $creating  True when creating item, false when updating.
293 293
 		 */
294
-		do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, false );
294
+		do_action("woocommerce_rest_insert_{$this->post_type}", $post, $request, false);
295 295
 
296
-		$request->set_param( 'context', 'edit' );
297
-		$response = $this->prepare_item_for_response( $post, $request );
298
-		return rest_ensure_response( $response );
296
+		$request->set_param('context', 'edit');
297
+		$response = $this->prepare_item_for_response($post, $request);
298
+		return rest_ensure_response($response);
299 299
 	}
300 300
 
301 301
 	/**
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	 * @param WP_REST_Request $request Full details about the request.
305 305
 	 * @return WP_Error|WP_REST_Response
306 306
 	 */
307
-	public function get_items( $request ) {
307
+	public function get_items($request) {
308 308
 		$args                         = array();
309 309
 		$args['offset']               = $request['offset'];
310 310
 		$args['order']                = $request['order'];
@@ -320,19 +320,19 @@  discard block
 block discarded – undo
320 320
 
321 321
 		$args['date_query'] = array();
322 322
 		// Set before into date query. Date query must be specified as an array of an array.
323
-		if ( isset( $request['before'] ) ) {
323
+		if (isset($request['before'])) {
324 324
 			$args['date_query'][0]['before'] = $request['before'];
325 325
 		}
326 326
 
327 327
 		// Set after into date query. Date query must be specified as an array of an array.
328
-		if ( isset( $request['after'] ) ) {
328
+		if (isset($request['after'])) {
329 329
 			$args['date_query'][0]['after'] = $request['after'];
330 330
 		}
331 331
 
332
-		if ( 'wc/v1' === $this->namespace ) {
333
-			if ( is_array( $request['filter'] ) ) {
334
-				$args = array_merge( $args, $request['filter'] );
335
-				unset( $args['filter'] );
332
+		if ('wc/v1' === $this->namespace) {
333
+			if (is_array($request['filter'])) {
334
+				$args = array_merge($args, $request['filter']);
335
+				unset($args['filter']);
336 336
 			}
337 337
 		}
338 338
 
@@ -348,59 +348,59 @@  discard block
 block discarded – undo
348 348
 		 * @param array           $args    Key value array of query var to query value.
349 349
 		 * @param WP_REST_Request $request The request used.
350 350
 		 */
351
-		$args = apply_filters( "woocommerce_rest_{$this->post_type}_query", $args, $request );
352
-		$query_args = $this->prepare_items_query( $args, $request );
351
+		$args = apply_filters("woocommerce_rest_{$this->post_type}_query", $args, $request);
352
+		$query_args = $this->prepare_items_query($args, $request);
353 353
 
354 354
 		$posts_query = new WP_Query();
355
-		$query_result = $posts_query->query( $query_args );
355
+		$query_result = $posts_query->query($query_args);
356 356
 
357 357
 		$posts = array();
358
-		foreach ( $query_result as $post ) {
359
-			if ( ! wc_rest_check_post_permissions( $this->post_type, 'read', $post->ID ) ) {
358
+		foreach ($query_result as $post) {
359
+			if ( ! wc_rest_check_post_permissions($this->post_type, 'read', $post->ID)) {
360 360
 				continue;
361 361
 			}
362 362
 
363
-			$data = $this->prepare_item_for_response( $post, $request );
364
-			$posts[] = $this->prepare_response_for_collection( $data );
363
+			$data = $this->prepare_item_for_response($post, $request);
364
+			$posts[] = $this->prepare_response_for_collection($data);
365 365
 		}
366 366
 
367 367
 		$page = (int) $query_args['paged'];
368 368
 		$total_posts = $posts_query->found_posts;
369 369
 
370
-		if ( $total_posts < 1 ) {
370
+		if ($total_posts < 1) {
371 371
 			// Out-of-bounds, run the query again without LIMIT for total count.
372
-			unset( $query_args['paged'] );
372
+			unset($query_args['paged']);
373 373
 			$count_query = new WP_Query();
374
-			$count_query->query( $query_args );
374
+			$count_query->query($query_args);
375 375
 			$total_posts = $count_query->found_posts;
376 376
 		}
377 377
 
378
-		$max_pages = ceil( $total_posts / (int) $query_args['posts_per_page'] );
378
+		$max_pages = ceil($total_posts / (int) $query_args['posts_per_page']);
379 379
 
380
-		$response = rest_ensure_response( $posts );
381
-		$response->header( 'X-WP-Total', (int) $total_posts );
382
-		$response->header( 'X-WP-TotalPages', (int) $max_pages );
380
+		$response = rest_ensure_response($posts);
381
+		$response->header('X-WP-Total', (int) $total_posts);
382
+		$response->header('X-WP-TotalPages', (int) $max_pages);
383 383
 
384 384
 		$request_params = $request->get_query_params();
385
-		if ( ! empty( $request_params['filter'] ) ) {
385
+		if ( ! empty($request_params['filter'])) {
386 386
 			// Normalize the pagination params.
387
-			unset( $request_params['filter']['posts_per_page'] );
388
-			unset( $request_params['filter']['paged'] );
387
+			unset($request_params['filter']['posts_per_page']);
388
+			unset($request_params['filter']['paged']);
389 389
 		}
390
-		$base = add_query_arg( $request_params, rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) );
390
+		$base = add_query_arg($request_params, rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)));
391 391
 
392
-		if ( $page > 1 ) {
392
+		if ($page > 1) {
393 393
 			$prev_page = $page - 1;
394
-			if ( $prev_page > $max_pages ) {
394
+			if ($prev_page > $max_pages) {
395 395
 				$prev_page = $max_pages;
396 396
 			}
397
-			$prev_link = add_query_arg( 'page', $prev_page, $base );
398
-			$response->link_header( 'prev', $prev_link );
397
+			$prev_link = add_query_arg('page', $prev_page, $base);
398
+			$response->link_header('prev', $prev_link);
399 399
 		}
400
-		if ( $max_pages > $page ) {
400
+		if ($max_pages > $page) {
401 401
 			$next_page = $page + 1;
402
-			$next_link = add_query_arg( 'page', $next_page, $base );
403
-			$response->link_header( 'next', $next_link );
402
+			$next_link = add_query_arg('page', $next_page, $base);
403
+			$response->link_header('next', $next_link);
404 404
 		}
405 405
 
406 406
 		return $response;
@@ -412,13 +412,13 @@  discard block
 block discarded – undo
412 412
 	 * @param WP_REST_Request $request Full details about the request.
413 413
 	 * @return WP_REST_Response|WP_Error
414 414
 	 */
415
-	public function delete_item( $request ) {
415
+	public function delete_item($request) {
416 416
 		$id    = (int) $request['id'];
417 417
 		$force = (bool) $request['force'];
418
-		$post  = get_post( $id );
418
+		$post  = get_post($id);
419 419
 
420
-		if ( empty( $id ) || empty( $post->ID ) || $post->post_type !== $this->post_type ) {
421
-			return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 404 ) );
420
+		if (empty($id) || empty($post->ID) || $post->post_type !== $this->post_type) {
421
+			return new WP_Error("woocommerce_rest_{$this->post_type}_invalid_id", __('ID is invalid.', 'woocommerce'), array('status' => 404));
422 422
 		}
423 423
 
424 424
 		$supports_trash = EMPTY_TRASH_DAYS > 0;
@@ -431,40 +431,40 @@  discard block
 block discarded – undo
431 431
 		 * @param boolean $supports_trash Whether the item type support trashing.
432 432
 		 * @param WP_Post $post           The Post object being considered for trashing support.
433 433
 		 */
434
-		$supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_trashable", $supports_trash, $post );
434
+		$supports_trash = apply_filters("woocommerce_rest_{$this->post_type}_trashable", $supports_trash, $post);
435 435
 
436
-		if ( ! wc_rest_check_post_permissions( $this->post_type, 'delete', $post->ID ) ) {
436
+		if ( ! wc_rest_check_post_permissions($this->post_type, 'delete', $post->ID)) {
437 437
 			/* translators: %s: post type */
438
-			return new WP_Error( "woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ), array( 'status' => rest_authorization_required_code() ) );
438
+			return new WP_Error("woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf(__('Sorry, you are not allowed to delete %s.', 'woocommerce'), $this->post_type), array('status' => rest_authorization_required_code()));
439 439
 		}
440 440
 
441
-		$request->set_param( 'context', 'edit' );
442
-		$response = $this->prepare_item_for_response( $post, $request );
441
+		$request->set_param('context', 'edit');
442
+		$response = $this->prepare_item_for_response($post, $request);
443 443
 
444 444
 		// If we're forcing, then delete permanently.
445
-		if ( $force ) {
446
-			$result = wp_delete_post( $id, true );
445
+		if ($force) {
446
+			$result = wp_delete_post($id, true);
447 447
 		} else {
448 448
 			// If we don't support trashing for this type, error out.
449
-			if ( ! $supports_trash ) {
449
+			if ( ! $supports_trash) {
450 450
 				/* translators: %s: post type */
451
-				return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array( 'status' => 501 ) );
451
+				return new WP_Error('woocommerce_rest_trash_not_supported', sprintf(__('The %s does not support trashing.', 'woocommerce'), $this->post_type), array('status' => 501));
452 452
 			}
453 453
 
454 454
 			// Otherwise, only trash if we haven't already.
455
-			if ( 'trash' === $post->post_status ) {
455
+			if ('trash' === $post->post_status) {
456 456
 				/* translators: %s: post type */
457
-				return new WP_Error( 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 410 ) );
457
+				return new WP_Error('woocommerce_rest_already_trashed', sprintf(__('The %s has already been deleted.', 'woocommerce'), $this->post_type), array('status' => 410));
458 458
 			}
459 459
 
460 460
 			// (Note that internally this falls through to `wp_delete_post` if
461 461
 			// the trash is disabled.)
462
-			$result = wp_trash_post( $id );
462
+			$result = wp_trash_post($id);
463 463
 		}
464 464
 
465
-		if ( ! $result ) {
465
+		if ( ! $result) {
466 466
 			/* translators: %s: post type */
467
-			return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 500 ) );
467
+			return new WP_Error('woocommerce_rest_cannot_delete', sprintf(__('The %s cannot be deleted.', 'woocommerce'), $this->post_type), array('status' => 500));
468 468
 		}
469 469
 
470 470
 		/**
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 		 * @param WP_REST_Response $response The response data.
475 475
 		 * @param WP_REST_Request  $request  The request sent to the API.
476 476
 		 */
477
-		do_action( "woocommerce_rest_delete_{$this->post_type}", $post, $response, $request );
477
+		do_action("woocommerce_rest_delete_{$this->post_type}", $post, $response, $request);
478 478
 
479 479
 		return $response;
480 480
 	}
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
 	 * @param WP_REST_Request $request Request object.
487 487
 	 * @return array Links for the given post.
488 488
 	 */
489
-	protected function prepare_links( $post, $request ) {
489
+	protected function prepare_links($post, $request) {
490 490
 		$links = array(
491 491
 			'self' => array(
492
-				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $post->ID ) ),
492
+				'href' => rest_url(sprintf('/%s/%s/%d', $this->namespace, $this->rest_base, $post->ID)),
493 493
 			),
494 494
 			'collection' => array(
495
-				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
495
+				'href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)),
496 496
 			),
497 497
 		);
498 498
 
@@ -507,12 +507,12 @@  discard block
 block discarded – undo
507 507
 	 * @param WP_REST_Request $request Request object.
508 508
 	 * @return array          $query_args
509 509
 	 */
510
-	protected function prepare_items_query( $prepared_args = array(), $request = null ) {
510
+	protected function prepare_items_query($prepared_args = array(), $request = null) {
511 511
 
512
-		$valid_vars = array_flip( $this->get_allowed_query_vars() );
512
+		$valid_vars = array_flip($this->get_allowed_query_vars());
513 513
 		$query_args = array();
514
-		foreach ( $valid_vars as $var => $index ) {
515
-			if ( isset( $prepared_args[ $var ] ) ) {
514
+		foreach ($valid_vars as $var => $index) {
515
+			if (isset($prepared_args[$var])) {
516 516
 				/**
517 517
 				 * Filter the query_vars used in `get_items` for the constructed query.
518 518
 				 *
@@ -520,17 +520,17 @@  discard block
 block discarded – undo
520 520
 				 *
521 521
 				 * @param mixed $prepared_args[ $var ] The query_var value.
522 522
 				 */
523
-				$query_args[ $var ] = apply_filters( "woocommerce_rest_query_var-{$var}", $prepared_args[ $var ] );
523
+				$query_args[$var] = apply_filters("woocommerce_rest_query_var-{$var}", $prepared_args[$var]);
524 524
 			}
525 525
 		}
526 526
 
527 527
 		$query_args['ignore_sticky_posts'] = true;
528 528
 
529
-		if ( 'include' === $query_args['orderby'] ) {
529
+		if ('include' === $query_args['orderby']) {
530 530
 			$query_args['orderby'] = 'post__in';
531
-		} elseif ( 'id' === $query_args['orderby'] ) {
531
+		} elseif ('id' === $query_args['orderby']) {
532 532
 			$query_args['orderby'] = 'ID'; // ID must be capitalized.
533
-		} elseif ( 'slug' === $query_args['orderby'] ) {
533
+		} elseif ('slug' === $query_args['orderby']) {
534 534
 			$query_args['orderby'] = 'name';
535 535
 		}
536 536
 
@@ -552,10 +552,10 @@  discard block
 block discarded – undo
552 552
 		 *
553 553
 		 * @param array  Array of allowed WP_Query query vars.
554 554
 		 */
555
-		$valid_vars = apply_filters( 'query_vars', $wp->public_query_vars );
555
+		$valid_vars = apply_filters('query_vars', $wp->public_query_vars);
556 556
 
557
-		$post_type_obj = get_post_type_object( $this->post_type );
558
-		if ( current_user_can( $post_type_obj->cap->edit_posts ) ) {
557
+		$post_type_obj = get_post_type_object($this->post_type);
558
+		if (current_user_can($post_type_obj->cap->edit_posts)) {
559 559
 			/**
560 560
 			 * Filter the allowed 'private' query vars for authorized users.
561 561
 			 *
@@ -569,8 +569,8 @@  discard block
 block discarded – undo
569 569
 			 * @param array $private_query_vars Array of allowed query vars for authorized users.
570 570
 			 * }
571 571
 			 */
572
-			$private = apply_filters( 'woocommerce_rest_private_query_vars', $wp->private_query_vars );
573
-			$valid_vars = array_merge( $valid_vars, $private );
572
+			$private = apply_filters('woocommerce_rest_private_query_vars', $wp->private_query_vars);
573
+			$valid_vars = array_merge($valid_vars, $private);
574 574
 		}
575 575
 		// Define our own in addition to WP's normal vars.
576 576
 		$rest_valid = array(
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 			'meta_compare',
591 591
 			'meta_value_num',
592 592
 		);
593
-		$valid_vars = array_merge( $valid_vars, $rest_valid );
593
+		$valid_vars = array_merge($valid_vars, $rest_valid);
594 594
 
595 595
 		/**
596 596
 		 * Filter allowed query vars for the REST API.
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 		 *    @param string $allowed_query_var The query var to allow.
606 606
 		 * }
607 607
 		 */
608
-		$valid_vars = apply_filters( 'woocommerce_rest_query_vars', $valid_vars );
608
+		$valid_vars = apply_filters('woocommerce_rest_query_vars', $valid_vars);
609 609
 
610 610
 		return $valid_vars;
611 611
 	}
@@ -621,19 +621,19 @@  discard block
 block discarded – undo
621 621
 		$params['context']['default'] = 'view';
622 622
 
623 623
 		$params['after'] = array(
624
-			'description'        => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
624
+			'description'        => __('Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce'),
625 625
 			'type'               => 'string',
626 626
 			'format'             => 'date-time',
627 627
 			'validate_callback'  => 'rest_validate_request_arg',
628 628
 		);
629 629
 		$params['before'] = array(
630
-			'description'        => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ),
630
+			'description'        => __('Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce'),
631 631
 			'type'               => 'string',
632 632
 			'format'             => 'date-time',
633 633
 			'validate_callback'  => 'rest_validate_request_arg',
634 634
 		);
635 635
 		$params['exclude'] = array(
636
-			'description'       => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
636
+			'description'       => __('Ensure result set excludes specific IDs.', 'woocommerce'),
637 637
 			'type'              => 'array',
638 638
 			'items'             => array(
639 639
 				'type'          => 'integer',
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 			'sanitize_callback' => 'wp_parse_id_list',
643 643
 		);
644 644
 		$params['include'] = array(
645
-			'description'       => __( 'Limit result set to specific ids.', 'woocommerce' ),
645
+			'description'       => __('Limit result set to specific ids.', 'woocommerce'),
646 646
 			'type'              => 'array',
647 647
 			'items'             => array(
648 648
 				'type'          => 'integer',
@@ -651,20 +651,20 @@  discard block
 block discarded – undo
651 651
 			'sanitize_callback' => 'wp_parse_id_list',
652 652
 		);
653 653
 		$params['offset'] = array(
654
-			'description'        => __( 'Offset the result set by a specific number of items.', 'woocommerce' ),
654
+			'description'        => __('Offset the result set by a specific number of items.', 'woocommerce'),
655 655
 			'type'               => 'integer',
656 656
 			'sanitize_callback'  => 'absint',
657 657
 			'validate_callback'  => 'rest_validate_request_arg',
658 658
 		);
659 659
 		$params['order'] = array(
660
-			'description'        => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
660
+			'description'        => __('Order sort attribute ascending or descending.', 'woocommerce'),
661 661
 			'type'               => 'string',
662 662
 			'default'            => 'desc',
663
-			'enum'               => array( 'asc', 'desc' ),
663
+			'enum'               => array('asc', 'desc'),
664 664
 			'validate_callback'  => 'rest_validate_request_arg',
665 665
 		);
666 666
 		$params['orderby'] = array(
667
-			'description'        => __( 'Sort collection by object attribute.', 'woocommerce' ),
667
+			'description'        => __('Sort collection by object attribute.', 'woocommerce'),
668 668
 			'type'               => 'string',
669 669
 			'default'            => 'date',
670 670
 			'enum'               => array(
@@ -677,11 +677,11 @@  discard block
 block discarded – undo
677 677
 			'validate_callback'  => 'rest_validate_request_arg',
678 678
 		);
679 679
 
680
-		$post_type_obj = get_post_type_object( $this->post_type );
680
+		$post_type_obj = get_post_type_object($this->post_type);
681 681
 
682
-		if ( isset( $post_type_obj->hierarchical ) && $post_type_obj->hierarchical ) {
682
+		if (isset($post_type_obj->hierarchical) && $post_type_obj->hierarchical) {
683 683
 			$params['parent'] = array(
684
-				'description'       => __( 'Limit result set to those of particular parent IDs.', 'woocommerce' ),
684
+				'description'       => __('Limit result set to those of particular parent IDs.', 'woocommerce'),
685 685
 				'type'              => 'array',
686 686
 				'items'             => array(
687 687
 					'type'          => 'integer',
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 				'default'           => array(),
691 691
 			);
692 692
 			$params['parent_exclude'] = array(
693
-				'description'       => __( 'Limit result set to all items except those of a particular parent ID.', 'woocommerce' ),
693
+				'description'       => __('Limit result set to all items except those of a particular parent ID.', 'woocommerce'),
694 694
 				'type'              => 'array',
695 695
 				'items'             => array(
696 696
 					'type'          => 'integer',
@@ -700,10 +700,10 @@  discard block
 block discarded – undo
700 700
 			);
701 701
 		}
702 702
 
703
-		if ( 'wc/v1' === $this->namespace ) {
703
+		if ('wc/v1' === $this->namespace) {
704 704
 			$params['filter'] = array(
705 705
 				'type'        => 'object',
706
-				'description' => __( 'Use WP Query arguments to modify the response; private query vars require appropriate authorization.', 'woocommerce' ),
706
+				'description' => __('Use WP Query arguments to modify the response; private query vars require appropriate authorization.', 'woocommerce'),
707 707
 			);
708 708
 		}
709 709
 
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 	 * @param WP_REST_Request $request Request object.
718 718
 	 * @return bool|WP_Error
719 719
 	 */
720
-	protected function update_post_meta_fields( $post, $request ) {
720
+	protected function update_post_meta_fields($post, $request) {
721 721
 		return true;
722 722
 	}
723 723
 }
Please login to merge, or discard this patch.
src/Controllers/Version3/class-wc-rest-shipping-methods-controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
  * @since   3.0.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * Shipping methods controller class.
Please login to merge, or discard this patch.