Test Failed
Push — master ( 44764d...6dc399 )
by Mike
04:21
created
src/RestApi/Version3/class-wc-rest-customer-downloads-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 Customers controller class.
Please login to merge, or discard this patch.
src/RestApi/Version3/class-wc-rest-coupons-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 Coupons controller class.
Please login to merge, or discard this patch.
src/RestApi/Version3/class-wc-rest-controller.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @see     https://developer.wordpress.org/rest-api/extending-the-rest-api/controller-classes/
17 17
  */
18 18
 
19
-if ( ! defined( 'ABSPATH' ) ) {
19
+if ( ! defined('ABSPATH')) {
20 20
 	exit;
21 21
 }
22 22
 
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return array
54 54
 	 */
55
-	protected function add_additional_fields_schema( $schema ) {
56
-		if ( empty( $schema['title'] ) ) {
55
+	protected function add_additional_fields_schema($schema) {
56
+		if (empty($schema['title'])) {
57 57
 			return $schema;
58 58
 		}
59 59
 
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
 		 */
63 63
 		$object_type = $schema['title'];
64 64
 
65
-		$additional_fields = $this->get_additional_fields( $object_type );
65
+		$additional_fields = $this->get_additional_fields($object_type);
66 66
 
67
-		foreach ( $additional_fields as $field_name => $field_options ) {
68
-			if ( ! $field_options['schema'] ) {
67
+		foreach ($additional_fields as $field_name => $field_options) {
68
+			if ( ! $field_options['schema']) {
69 69
 				continue;
70 70
 			}
71 71
 
72
-			$schema['properties'][ $field_name ] = $field_options['schema'];
72
+			$schema['properties'][$field_name] = $field_options['schema'];
73 73
 		}
74 74
 
75
-		$schema['properties'] = apply_filters( 'woocommerce_rest_' . $object_type . '_schema', $schema['properties'] );
75
+		$schema['properties'] = apply_filters('woocommerce_rest_' . $object_type . '_schema', $schema['properties']);
76 76
 
77 77
 		return $schema;
78 78
 	}
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @return string
84 84
 	 */
85 85
 	protected function get_normalized_rest_base() {
86
-		return preg_replace( '/\(.*\)\//i', '', $this->rest_base );
86
+		return preg_replace('/\(.*\)\//i', '', $this->rest_base);
87 87
 	}
88 88
 
89 89
 	/**
@@ -92,25 +92,25 @@  discard block
 block discarded – undo
92 92
 	 * @param array $items Request items.
93 93
 	 * @return bool|WP_Error
94 94
 	 */
95
-	protected function check_batch_limit( $items ) {
96
-		$limit = apply_filters( 'woocommerce_rest_batch_items_limit', 100, $this->get_normalized_rest_base() );
95
+	protected function check_batch_limit($items) {
96
+		$limit = apply_filters('woocommerce_rest_batch_items_limit', 100, $this->get_normalized_rest_base());
97 97
 		$total = 0;
98 98
 
99
-		if ( ! empty( $items['create'] ) ) {
100
-			$total += count( $items['create'] );
99
+		if ( ! empty($items['create'])) {
100
+			$total += count($items['create']);
101 101
 		}
102 102
 
103
-		if ( ! empty( $items['update'] ) ) {
104
-			$total += count( $items['update'] );
103
+		if ( ! empty($items['update'])) {
104
+			$total += count($items['update']);
105 105
 		}
106 106
 
107
-		if ( ! empty( $items['delete'] ) ) {
108
-			$total += count( $items['delete'] );
107
+		if ( ! empty($items['delete'])) {
108
+			$total += count($items['delete']);
109 109
 		}
110 110
 
111
-		if ( $total > $limit ) {
111
+		if ($total > $limit) {
112 112
 			/* translators: %s: items limit */
113
-			return new WP_Error( 'woocommerce_rest_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'woocommerce' ), $limit ), array( 'status' => 413 ) );
113
+			return new WP_Error('woocommerce_rest_request_entity_too_large', sprintf(__('Unable to accept more than %s items for this request.', 'woocommerce'), $limit), array('status' => 413));
114 114
 		}
115 115
 
116 116
 		return true;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 * @param WP_REST_Request $request Full details about the request.
123 123
 	 * @return array Of WP_Error or WP_REST_Response.
124 124
 	 */
125
-	public function batch_items( $request ) {
125
+	public function batch_items($request) {
126 126
 		/**
127 127
 		 * REST Server
128 128
 		 *
@@ -131,34 +131,34 @@  discard block
 block discarded – undo
131 131
 		global $wp_rest_server;
132 132
 
133 133
 		// Get the request params.
134
-		$items    = array_filter( $request->get_params() );
134
+		$items    = array_filter($request->get_params());
135 135
 		$response = array();
136 136
 
137 137
 		// Check batch limit.
138
-		$limit = $this->check_batch_limit( $items );
139
-		if ( is_wp_error( $limit ) ) {
138
+		$limit = $this->check_batch_limit($items);
139
+		if (is_wp_error($limit)) {
140 140
 			return $limit;
141 141
 		}
142 142
 
143
-		if ( ! empty( $items['create'] ) ) {
144
-			foreach ( $items['create'] as $item ) {
145
-				$_item = new WP_REST_Request( 'POST' );
143
+		if ( ! empty($items['create'])) {
144
+			foreach ($items['create'] as $item) {
145
+				$_item = new WP_REST_Request('POST');
146 146
 
147 147
 				// Default parameters.
148 148
 				$defaults = array();
149 149
 				$schema   = $this->get_public_item_schema();
150
-				foreach ( $schema['properties'] as $arg => $options ) {
151
-					if ( isset( $options['default'] ) ) {
152
-						$defaults[ $arg ] = $options['default'];
150
+				foreach ($schema['properties'] as $arg => $options) {
151
+					if (isset($options['default'])) {
152
+						$defaults[$arg] = $options['default'];
153 153
 					}
154 154
 				}
155
-				$_item->set_default_params( $defaults );
155
+				$_item->set_default_params($defaults);
156 156
 
157 157
 				// Set request parameters.
158
-				$_item->set_body_params( $item );
159
-				$_response = $this->create_item( $_item );
158
+				$_item->set_body_params($item);
159
+				$_response = $this->create_item($_item);
160 160
 
161
-				if ( is_wp_error( $_response ) ) {
161
+				if (is_wp_error($_response)) {
162 162
 					$response['create'][] = array(
163 163
 						'id'    => 0,
164 164
 						'error' => array(
@@ -168,18 +168,18 @@  discard block
 block discarded – undo
168 168
 						),
169 169
 					);
170 170
 				} else {
171
-					$response['create'][] = $wp_rest_server->response_to_data( $_response, '' );
171
+					$response['create'][] = $wp_rest_server->response_to_data($_response, '');
172 172
 				}
173 173
 			}
174 174
 		}
175 175
 
176
-		if ( ! empty( $items['update'] ) ) {
177
-			foreach ( $items['update'] as $item ) {
178
-				$_item = new WP_REST_Request( 'PUT' );
179
-				$_item->set_body_params( $item );
180
-				$_response = $this->update_item( $_item );
176
+		if ( ! empty($items['update'])) {
177
+			foreach ($items['update'] as $item) {
178
+				$_item = new WP_REST_Request('PUT');
179
+				$_item->set_body_params($item);
180
+				$_response = $this->update_item($_item);
181 181
 
182
-				if ( is_wp_error( $_response ) ) {
182
+				if (is_wp_error($_response)) {
183 183
 					$response['update'][] = array(
184 184
 						'id'    => $item['id'],
185 185
 						'error' => array(
@@ -189,29 +189,29 @@  discard block
 block discarded – undo
189 189
 						),
190 190
 					);
191 191
 				} else {
192
-					$response['update'][] = $wp_rest_server->response_to_data( $_response, '' );
192
+					$response['update'][] = $wp_rest_server->response_to_data($_response, '');
193 193
 				}
194 194
 			}
195 195
 		}
196 196
 
197
-		if ( ! empty( $items['delete'] ) ) {
198
-			foreach ( $items['delete'] as $id ) {
197
+		if ( ! empty($items['delete'])) {
198
+			foreach ($items['delete'] as $id) {
199 199
 				$id = (int) $id;
200 200
 
201
-				if ( 0 === $id ) {
201
+				if (0 === $id) {
202 202
 					continue;
203 203
 				}
204 204
 
205
-				$_item = new WP_REST_Request( 'DELETE' );
205
+				$_item = new WP_REST_Request('DELETE');
206 206
 				$_item->set_query_params(
207 207
 					array(
208 208
 						'id'    => $id,
209 209
 						'force' => true,
210 210
 					)
211 211
 				);
212
-				$_response = $this->delete_item( $_item );
212
+				$_response = $this->delete_item($_item);
213 213
 
214
-				if ( is_wp_error( $_response ) ) {
214
+				if (is_wp_error($_response)) {
215 215
 					$response['delete'][] = array(
216 216
 						'id'    => $id,
217 217
 						'error' => array(
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 						),
222 222
 					);
223 223
 				} else {
224
-					$response['delete'][] = $wp_rest_server->response_to_data( $_response, '' );
224
+					$response['delete'][] = $wp_rest_server->response_to_data($_response, '');
225 225
 				}
226 226
 			}
227 227
 		}
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
 	 * @param array  $setting Setting.
238 238
 	 * @return string
239 239
 	 */
240
-	public function validate_setting_text_field( $value, $setting ) {
241
-		$value = is_null( $value ) ? '' : $value;
242
-		return wp_kses_post( trim( stripslashes( $value ) ) );
240
+	public function validate_setting_text_field($value, $setting) {
241
+		$value = is_null($value) ? '' : $value;
242
+		return wp_kses_post(trim(stripslashes($value)));
243 243
 	}
244 244
 
245 245
 	/**
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
 	 * @param array  $setting Setting.
251 251
 	 * @return string|WP_Error
252 252
 	 */
253
-	public function validate_setting_select_field( $value, $setting ) {
254
-		if ( array_key_exists( $value, $setting['options'] ) ) {
253
+	public function validate_setting_select_field($value, $setting) {
254
+		if (array_key_exists($value, $setting['options'])) {
255 255
 			return $value;
256 256
 		} else {
257
-			return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) );
257
+			return new WP_Error('rest_setting_value_invalid', __('An invalid setting value was passed.', 'woocommerce'), array('status' => 400));
258 258
 		}
259 259
 	}
260 260
 
@@ -266,18 +266,18 @@  discard block
 block discarded – undo
266 266
 	 * @param array $setting Setting.
267 267
 	 * @return array|WP_Error
268 268
 	 */
269
-	public function validate_setting_multiselect_field( $values, $setting ) {
270
-		if ( empty( $values ) ) {
269
+	public function validate_setting_multiselect_field($values, $setting) {
270
+		if (empty($values)) {
271 271
 			return array();
272 272
 		}
273 273
 
274
-		if ( ! is_array( $values ) ) {
275
-			return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) );
274
+		if ( ! is_array($values)) {
275
+			return new WP_Error('rest_setting_value_invalid', __('An invalid setting value was passed.', 'woocommerce'), array('status' => 400));
276 276
 		}
277 277
 
278 278
 		$final_values = array();
279
-		foreach ( $values as $value ) {
280
-			if ( array_key_exists( $value, $setting['options'] ) ) {
279
+		foreach ($values as $value) {
280
+			if (array_key_exists($value, $setting['options'])) {
281 281
 				$final_values[] = $value;
282 282
 			}
283 283
 		}
@@ -293,19 +293,19 @@  discard block
 block discarded – undo
293 293
 	 * @param array $setting Setting.
294 294
 	 * @return string|WP_Error
295 295
 	 */
296
-	public function validate_setting_image_width_field( $values, $setting ) {
297
-		if ( ! is_array( $values ) ) {
298
-			return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) );
296
+	public function validate_setting_image_width_field($values, $setting) {
297
+		if ( ! is_array($values)) {
298
+			return new WP_Error('rest_setting_value_invalid', __('An invalid setting value was passed.', 'woocommerce'), array('status' => 400));
299 299
 		}
300 300
 
301 301
 		$current = $setting['value'];
302
-		if ( isset( $values['width'] ) ) {
303
-			$current['width'] = intval( $values['width'] );
302
+		if (isset($values['width'])) {
303
+			$current['width'] = intval($values['width']);
304 304
 		}
305
-		if ( isset( $values['height'] ) ) {
306
-			$current['height'] = intval( $values['height'] );
305
+		if (isset($values['height'])) {
306
+			$current['height'] = intval($values['height']);
307 307
 		}
308
-		if ( isset( $values['crop'] ) ) {
308
+		if (isset($values['crop'])) {
309 309
 			$current['crop'] = (bool) $values['crop'];
310 310
 		}
311 311
 		return $current;
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 	 * @param array  $setting Setting.
320 320
 	 * @return string|WP_Error
321 321
 	 */
322
-	public function validate_setting_radio_field( $value, $setting ) {
323
-		return $this->validate_setting_select_field( $value, $setting );
322
+	public function validate_setting_radio_field($value, $setting) {
323
+		return $this->validate_setting_select_field($value, $setting);
324 324
 	}
325 325
 
326 326
 	/**
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
 	 * @param array  $setting Setting.
332 332
 	 * @return string|WP_Error
333 333
 	 */
334
-	public function validate_setting_checkbox_field( $value, $setting ) {
335
-		if ( in_array( $value, array( 'yes', 'no' ) ) ) {
334
+	public function validate_setting_checkbox_field($value, $setting) {
335
+		if (in_array($value, array('yes', 'no'))) {
336 336
 			return $value;
337
-		} elseif ( empty( $value ) ) {
338
-			$value = isset( $setting['default'] ) ? $setting['default'] : 'no';
337
+		} elseif (empty($value)) {
338
+			$value = isset($setting['default']) ? $setting['default'] : 'no';
339 339
 			return $value;
340 340
 		} else {
341
-			return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) );
341
+			return new WP_Error('rest_setting_value_invalid', __('An invalid setting value was passed.', 'woocommerce'), array('status' => 400));
342 342
 		}
343 343
 	}
344 344
 
@@ -350,10 +350,10 @@  discard block
 block discarded – undo
350 350
 	 * @param array  $setting Setting.
351 351
 	 * @return string
352 352
 	 */
353
-	public function validate_setting_textarea_field( $value, $setting ) {
354
-		$value = is_null( $value ) ? '' : $value;
353
+	public function validate_setting_textarea_field($value, $setting) {
354
+		$value = is_null($value) ? '' : $value;
355 355
 		return wp_kses(
356
-			trim( stripslashes( $value ) ),
356
+			trim(stripslashes($value)),
357 357
 			array_merge(
358 358
 				array(
359 359
 					'iframe' => array(
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 						'class' => true,
364 364
 					),
365 365
 				),
366
-				wp_kses_allowed_html( 'post' )
366
+				wp_kses_allowed_html('post')
367 367
 			)
368 368
 		);
369 369
 	}
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * @param array $meta_query Meta query.
377 377
 	 * @return array
378 378
 	 */
379
-	protected function add_meta_query( $args, $meta_query ) {
380
-		if ( empty( $args['meta_query'] ) ) {
379
+	protected function add_meta_query($args, $meta_query) {
380
+		if (empty($args['meta_query'])) {
381 381
 			$args['meta_query'] = array();
382 382
 		}
383 383
 
@@ -398,25 +398,25 @@  discard block
 block discarded – undo
398 398
 			'type'       => 'object',
399 399
 			'properties' => array(
400 400
 				'create' => array(
401
-					'description' => __( 'List of created resources.', 'woocommerce' ),
401
+					'description' => __('List of created resources.', 'woocommerce'),
402 402
 					'type'        => 'array',
403
-					'context'     => array( 'view', 'edit' ),
403
+					'context'     => array('view', 'edit'),
404 404
 					'items'       => array(
405 405
 						'type'    => 'object',
406 406
 					),
407 407
 				),
408 408
 				'update' => array(
409
-					'description' => __( 'List of updated resources.', 'woocommerce' ),
409
+					'description' => __('List of updated resources.', 'woocommerce'),
410 410
 					'type'        => 'array',
411
-					'context'     => array( 'view', 'edit' ),
411
+					'context'     => array('view', 'edit'),
412 412
 					'items'       => array(
413 413
 						'type'    => 'object',
414 414
 					),
415 415
 				),
416 416
 				'delete' => array(
417
-					'description' => __( 'List of delete resources.', 'woocommerce' ),
417
+					'description' => __('List of delete resources.', 'woocommerce'),
418 418
 					'type'        => 'array',
419
-					'context'     => array( 'view', 'edit' ),
419
+					'context'     => array('view', 'edit'),
420 420
 					'items'       => array(
421 421
 						'type'    => 'integer',
422 422
 					),
@@ -436,32 +436,32 @@  discard block
 block discarded – undo
436 436
 	 * @param WP_REST_Request $request Full details about the request.
437 437
 	 * @return array Fields to be included in the response.
438 438
 	 */
439
-	public function get_fields_for_response( $request ) {
439
+	public function get_fields_for_response($request) {
440 440
 		$schema = $this->get_item_schema();
441
-		$fields = isset( $schema['properties'] ) ? array_keys( $schema['properties'] ) : array();
441
+		$fields = isset($schema['properties']) ? array_keys($schema['properties']) : array();
442 442
 
443 443
 		$additional_fields = $this->get_additional_fields();
444
-		foreach ( $additional_fields as $field_name => $field_options ) {
444
+		foreach ($additional_fields as $field_name => $field_options) {
445 445
 			// For back-compat, include any field with an empty schema
446 446
 			// because it won't be present in $this->get_item_schema().
447
-			if ( is_null( $field_options['schema'] ) ) {
447
+			if (is_null($field_options['schema'])) {
448 448
 				$fields[] = $field_name;
449 449
 			}
450 450
 		}
451 451
 
452
-		if ( ! isset( $request['_fields'] ) ) {
452
+		if ( ! isset($request['_fields'])) {
453 453
 			return $fields;
454 454
 		}
455
-		$requested_fields = is_array( $request['_fields'] ) ? $request['_fields'] : preg_split( '/[\s,]+/', $request['_fields'] );
456
-		if ( 0 === count( $requested_fields ) ) {
455
+		$requested_fields = is_array($request['_fields']) ? $request['_fields'] : preg_split('/[\s,]+/', $request['_fields']);
456
+		if (0 === count($requested_fields)) {
457 457
 			return $fields;
458 458
 		}
459 459
 		// Trim off outside whitespace from the comma delimited list.
460
-		$requested_fields = array_map( 'trim', $requested_fields );
460
+		$requested_fields = array_map('trim', $requested_fields);
461 461
 		// Always persist 'id', because it can be needed for add_additional_fields_to_object().
462
-		if ( in_array( 'id', $fields, true ) ) {
462
+		if (in_array('id', $fields, true)) {
463 463
 			$requested_fields[] = 'id';
464 464
 		}
465
-		return array_intersect( $fields, $requested_fields );
465
+		return array_intersect($fields, $requested_fields);
466 466
 	}
467 467
 }
Please login to merge, or discard this patch.
src/RestApi/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/RestApi/Version3/class-wc-rest-crud-controller.php 1 patch
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @version  3.0.0
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	 * @param  int $id Object ID.
39 39
 	 * @return object WC_Data object or WP_Error object.
40 40
 	 */
41
-	protected function get_object( $id ) {
41
+	protected function get_object($id) {
42 42
 		// translators: %s: Class method name.
43
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
43
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce'), __METHOD__), array('status' => 405));
44 44
 	}
45 45
 
46 46
 	/**
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 	 * @param  WP_REST_Request $request Full details about the request.
50 50
 	 * @return WP_Error|boolean
51 51
 	 */
52
-	public function get_item_permissions_check( $request ) {
53
-		$object = $this->get_object( (int) $request['id'] );
52
+	public function get_item_permissions_check($request) {
53
+		$object = $this->get_object((int) $request['id']);
54 54
 
55
-		if ( $object && 0 !== $object->get_id() && ! wc_rest_check_post_permissions( $this->post_type, 'read', $object->get_id() ) ) {
56
-			return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
55
+		if ($object && 0 !== $object->get_id() && ! wc_rest_check_post_permissions($this->post_type, 'read', $object->get_id())) {
56
+			return new WP_Error('woocommerce_rest_cannot_view', __('Sorry, you cannot view this resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
57 57
 		}
58 58
 
59 59
 		return true;
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 	 * @param  WP_REST_Request $request Full details about the request.
66 66
 	 * @return WP_Error|boolean
67 67
 	 */
68
-	public function update_item_permissions_check( $request ) {
69
-		$object = $this->get_object( (int) $request['id'] );
68
+	public function update_item_permissions_check($request) {
69
+		$object = $this->get_object((int) $request['id']);
70 70
 
71
-		if ( $object && 0 !== $object->get_id() && ! wc_rest_check_post_permissions( $this->post_type, 'edit', $object->get_id() ) ) {
72
-			return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
71
+		if ($object && 0 !== $object->get_id() && ! wc_rest_check_post_permissions($this->post_type, 'edit', $object->get_id())) {
72
+			return new WP_Error('woocommerce_rest_cannot_edit', __('Sorry, you are not allowed to edit this resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
73 73
 		}
74 74
 
75 75
 		return true;
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 	 * @param  WP_REST_Request $request Full details about the request.
82 82
 	 * @return bool|WP_Error
83 83
 	 */
84
-	public function delete_item_permissions_check( $request ) {
85
-		$object = $this->get_object( (int) $request['id'] );
84
+	public function delete_item_permissions_check($request) {
85
+		$object = $this->get_object((int) $request['id']);
86 86
 
87
-		if ( $object && 0 !== $object->get_id() && ! wc_rest_check_post_permissions( $this->post_type, 'delete', $object->get_id() ) ) {
88
-			return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
87
+		if ($object && 0 !== $object->get_id() && ! wc_rest_check_post_permissions($this->post_type, 'delete', $object->get_id())) {
88
+			return new WP_Error('woocommerce_rest_cannot_delete', __('Sorry, you are not allowed to delete this resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
89 89
 		}
90 90
 
91 91
 		return true;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @param  object $object Object.
98 98
 	 * @return string
99 99
 	 */
100
-	protected function get_permalink( $object ) {
100
+	protected function get_permalink($object) {
101 101
 		return '';
102 102
 	}
103 103
 
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
 	 * @param  WP_REST_Request $request Request object.
110 110
 	 * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
111 111
 	 */
112
-	protected function prepare_object_for_response( $object, $request ) {
112
+	protected function prepare_object_for_response($object, $request) {
113 113
 		// translators: %s: Class method name.
114
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
114
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce'), __METHOD__), array('status' => 405));
115 115
 	}
116 116
 
117 117
 	/**
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 	 * @param  bool            $creating If is creating a new object.
123 123
 	 * @return WP_Error|WC_Data The prepared item, or WP_Error object on failure.
124 124
 	 */
125
-	protected function prepare_object_for_database( $request, $creating = false ) {
125
+	protected function prepare_object_for_database($request, $creating = false) {
126 126
 		// translators: %s: Class method name.
127
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
127
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce'), __METHOD__), array('status' => 405));
128 128
 	}
129 129
 
130 130
 	/**
@@ -133,18 +133,18 @@  discard block
 block discarded – undo
133 133
 	 * @param WP_REST_Request $request Full details about the request.
134 134
 	 * @return WP_Error|WP_REST_Response
135 135
 	 */
136
-	public function get_item( $request ) {
137
-		$object = $this->get_object( (int) $request['id'] );
136
+	public function get_item($request) {
137
+		$object = $this->get_object((int) $request['id']);
138 138
 
139
-		if ( ! $object || 0 === $object->get_id() ) {
140
-			return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
139
+		if ( ! $object || 0 === $object->get_id()) {
140
+			return new WP_Error("woocommerce_rest_{$this->post_type}_invalid_id", __('Invalid ID.', 'woocommerce'), array('status' => 404));
141 141
 		}
142 142
 
143
-		$data     = $this->prepare_object_for_response( $object, $request );
144
-		$response = rest_ensure_response( $data );
143
+		$data     = $this->prepare_object_for_response($object, $request);
144
+		$response = rest_ensure_response($data);
145 145
 
146
-		if ( $this->public ) {
147
-			$response->link_header( 'alternate', $this->get_permalink( $object ), array( 'type' => 'text/html' ) );
146
+		if ($this->public) {
147
+			$response->link_header('alternate', $this->get_permalink($object), array('type' => 'text/html'));
148 148
 		}
149 149
 
150 150
 		return $response;
@@ -158,21 +158,21 @@  discard block
 block discarded – undo
158 158
 	 * @param  bool            $creating If is creating a new object.
159 159
 	 * @return WC_Data|WP_Error
160 160
 	 */
161
-	protected function save_object( $request, $creating = false ) {
161
+	protected function save_object($request, $creating = false) {
162 162
 		try {
163
-			$object = $this->prepare_object_for_database( $request, $creating );
163
+			$object = $this->prepare_object_for_database($request, $creating);
164 164
 
165
-			if ( is_wp_error( $object ) ) {
165
+			if (is_wp_error($object)) {
166 166
 				return $object;
167 167
 			}
168 168
 
169 169
 			$object->save();
170 170
 
171
-			return $this->get_object( $object->get_id() );
172
-		} catch ( WC_Data_Exception $e ) {
173
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
174
-		} catch ( WC_REST_Exception $e ) {
175
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
171
+			return $this->get_object($object->get_id());
172
+		} catch (WC_Data_Exception $e) {
173
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), $e->getErrorData());
174
+		} catch (WC_REST_Exception $e) {
175
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
176 176
 		}
177 177
 	}
178 178
 
@@ -182,26 +182,26 @@  discard block
 block discarded – undo
182 182
 	 * @param WP_REST_Request $request Full details about the request.
183 183
 	 * @return WP_Error|WP_REST_Response
184 184
 	 */
185
-	public function create_item( $request ) {
186
-		if ( ! empty( $request['id'] ) ) {
185
+	public function create_item($request) {
186
+		if ( ! empty($request['id'])) {
187 187
 			/* translators: %s: post type */
188
-			return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
188
+			return new WP_Error("woocommerce_rest_{$this->post_type}_exists", sprintf(__('Cannot create existing %s.', 'woocommerce'), $this->post_type), array('status' => 400));
189 189
 		}
190 190
 
191
-		$object = $this->save_object( $request, true );
191
+		$object = $this->save_object($request, true);
192 192
 
193
-		if ( is_wp_error( $object ) ) {
193
+		if (is_wp_error($object)) {
194 194
 			return $object;
195 195
 		}
196 196
 
197 197
 		try {
198
-			$this->update_additional_fields_for_object( $object, $request );
199
-		} catch ( WC_Data_Exception $e ) {
198
+			$this->update_additional_fields_for_object($object, $request);
199
+		} catch (WC_Data_Exception $e) {
200 200
 			$object->delete();
201
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
202
-		} catch ( WC_REST_Exception $e ) {
201
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), $e->getErrorData());
202
+		} catch (WC_REST_Exception $e) {
203 203
 			$object->delete();
204
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
204
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
205 205
 		}
206 206
 
207 207
 		/**
@@ -211,13 +211,13 @@  discard block
 block discarded – undo
211 211
 		 * @param WP_REST_Request $request   Request object.
212 212
 		 * @param boolean         $creating  True when creating object, false when updating.
213 213
 		 */
214
-		do_action( "woocommerce_rest_insert_{$this->post_type}_object", $object, $request, true );
214
+		do_action("woocommerce_rest_insert_{$this->post_type}_object", $object, $request, true);
215 215
 
216
-		$request->set_param( 'context', 'edit' );
217
-		$response = $this->prepare_object_for_response( $object, $request );
218
-		$response = rest_ensure_response( $response );
219
-		$response->set_status( 201 );
220
-		$response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ) );
216
+		$request->set_param('context', 'edit');
217
+		$response = $this->prepare_object_for_response($object, $request);
218
+		$response = rest_ensure_response($response);
219
+		$response->set_status(201);
220
+		$response->header('Location', rest_url(sprintf('/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id())));
221 221
 
222 222
 		return $response;
223 223
 	}
@@ -228,25 +228,25 @@  discard block
 block discarded – undo
228 228
 	 * @param WP_REST_Request $request Full details about the request.
229 229
 	 * @return WP_Error|WP_REST_Response
230 230
 	 */
231
-	public function update_item( $request ) {
232
-		$object = $this->get_object( (int) $request['id'] );
231
+	public function update_item($request) {
232
+		$object = $this->get_object((int) $request['id']);
233 233
 
234
-		if ( ! $object || 0 === $object->get_id() ) {
235
-			return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 400 ) );
234
+		if ( ! $object || 0 === $object->get_id()) {
235
+			return new WP_Error("woocommerce_rest_{$this->post_type}_invalid_id", __('Invalid ID.', 'woocommerce'), array('status' => 400));
236 236
 		}
237 237
 
238
-		$object = $this->save_object( $request, false );
238
+		$object = $this->save_object($request, false);
239 239
 
240
-		if ( is_wp_error( $object ) ) {
240
+		if (is_wp_error($object)) {
241 241
 			return $object;
242 242
 		}
243 243
 
244 244
 		try {
245
-			$this->update_additional_fields_for_object( $object, $request );
246
-		} catch ( WC_Data_Exception $e ) {
247
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
248
-		} catch ( WC_REST_Exception $e ) {
249
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
245
+			$this->update_additional_fields_for_object($object, $request);
246
+		} catch (WC_Data_Exception $e) {
247
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), $e->getErrorData());
248
+		} catch (WC_REST_Exception $e) {
249
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
250 250
 		}
251 251
 
252 252
 		/**
@@ -256,11 +256,11 @@  discard block
 block discarded – undo
256 256
 		 * @param WP_REST_Request $request   Request object.
257 257
 		 * @param boolean         $creating  True when creating object, false when updating.
258 258
 		 */
259
-		do_action( "woocommerce_rest_insert_{$this->post_type}_object", $object, $request, false );
259
+		do_action("woocommerce_rest_insert_{$this->post_type}_object", $object, $request, false);
260 260
 
261
-		$request->set_param( 'context', 'edit' );
262
-		$response = $this->prepare_object_for_response( $object, $request );
263
-		return rest_ensure_response( $response );
261
+		$request->set_param('context', 'edit');
262
+		$response = $this->prepare_object_for_response($object, $request);
263
+		return rest_ensure_response($response);
264 264
 	}
265 265
 
266 266
 	/**
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 * @param  WP_REST_Request $request Full details about the request.
271 271
 	 * @return array
272 272
 	 */
273
-	protected function prepare_objects_query( $request ) {
273
+	protected function prepare_objects_query($request) {
274 274
 		$args                        = array();
275 275
 		$args['offset']              = $request['offset'];
276 276
 		$args['order']               = $request['order'];
@@ -284,18 +284,18 @@  discard block
 block discarded – undo
284 284
 		$args['post_parent__not_in'] = $request['parent_exclude'];
285 285
 		$args['s']                   = $request['search'];
286 286
 
287
-		if ( 'date' === $args['orderby'] ) {
287
+		if ('date' === $args['orderby']) {
288 288
 			$args['orderby'] = 'date ID';
289 289
 		}
290 290
 
291 291
 		$args['date_query'] = array();
292 292
 		// Set before into date query. Date query must be specified as an array of an array.
293
-		if ( isset( $request['before'] ) ) {
293
+		if (isset($request['before'])) {
294 294
 			$args['date_query'][0]['before'] = $request['before'];
295 295
 		}
296 296
 
297 297
 		// Set after into date query. Date query must be specified as an array of an array.
298
-		if ( isset( $request['after'] ) ) {
298
+		if (isset($request['after'])) {
299 299
 			$args['date_query'][0]['after'] = $request['after'];
300 300
 		}
301 301
 
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 		 * @param array           $args    Key value array of query var to query value.
312 312
 		 * @param WP_REST_Request $request The request used.
313 313
 		 */
314
-		$args = apply_filters( "woocommerce_rest_{$this->post_type}_object_query", $args, $request );
314
+		$args = apply_filters("woocommerce_rest_{$this->post_type}_object_query", $args, $request);
315 315
 
316
-		return $this->prepare_items_query( $args, $request );
316
+		return $this->prepare_items_query($args, $request);
317 317
 	}
318 318
 
319 319
 	/**
@@ -323,23 +323,23 @@  discard block
 block discarded – undo
323 323
 	 * @param  array $query_args Query args.
324 324
 	 * @return array
325 325
 	 */
326
-	protected function get_objects( $query_args ) {
326
+	protected function get_objects($query_args) {
327 327
 		$query  = new WP_Query();
328
-		$result = $query->query( $query_args );
328
+		$result = $query->query($query_args);
329 329
 
330 330
 		$total_posts = $query->found_posts;
331
-		if ( $total_posts < 1 ) {
331
+		if ($total_posts < 1) {
332 332
 			// Out-of-bounds, run the query again without LIMIT for total count.
333
-			unset( $query_args['paged'] );
333
+			unset($query_args['paged']);
334 334
 			$count_query = new WP_Query();
335
-			$count_query->query( $query_args );
335
+			$count_query->query($query_args);
336 336
 			$total_posts = $count_query->found_posts;
337 337
 		}
338 338
 
339 339
 		return array(
340
-			'objects' => array_map( array( $this, 'get_object' ), $result ),
340
+			'objects' => array_map(array($this, 'get_object'), $result),
341 341
 			'total'   => (int) $total_posts,
342
-			'pages'   => (int) ceil( $total_posts / (int) $query->query_vars['posts_per_page'] ),
342
+			'pages'   => (int) ceil($total_posts / (int) $query->query_vars['posts_per_page']),
343 343
 		);
344 344
 	}
345 345
 
@@ -349,55 +349,55 @@  discard block
 block discarded – undo
349 349
 	 * @param WP_REST_Request $request Full details about the request.
350 350
 	 * @return WP_Error|WP_REST_Response
351 351
 	 */
352
-	public function get_items( $request ) {
353
-		$query_args    = $this->prepare_objects_query( $request );
354
-		$query_results = $this->get_objects( $query_args );
352
+	public function get_items($request) {
353
+		$query_args    = $this->prepare_objects_query($request);
354
+		$query_results = $this->get_objects($query_args);
355 355
 
356 356
 		$objects = array();
357
-		foreach ( $query_results['objects'] as $object ) {
358
-			if ( ! wc_rest_check_post_permissions( $this->post_type, 'read', $object->get_id() ) ) {
357
+		foreach ($query_results['objects'] as $object) {
358
+			if ( ! wc_rest_check_post_permissions($this->post_type, 'read', $object->get_id())) {
359 359
 				continue;
360 360
 			}
361 361
 
362
-			$data = $this->prepare_object_for_response( $object, $request );
363
-			$objects[] = $this->prepare_response_for_collection( $data );
362
+			$data = $this->prepare_object_for_response($object, $request);
363
+			$objects[] = $this->prepare_response_for_collection($data);
364 364
 		}
365 365
 
366 366
 		$page      = (int) $query_args['paged'];
367 367
 		$max_pages = $query_results['pages'];
368 368
 
369
-		$response = rest_ensure_response( $objects );
370
-		$response->header( 'X-WP-Total', $query_results['total'] );
371
-		$response->header( 'X-WP-TotalPages', (int) $max_pages );
369
+		$response = rest_ensure_response($objects);
370
+		$response->header('X-WP-Total', $query_results['total']);
371
+		$response->header('X-WP-TotalPages', (int) $max_pages);
372 372
 
373 373
 		$base          = $this->rest_base;
374 374
 		$attrib_prefix = '(?P<';
375
-		if ( strpos( $base, $attrib_prefix ) !== false ) {
375
+		if (strpos($base, $attrib_prefix) !== false) {
376 376
 			$attrib_names = array();
377
-			preg_match( '/\(\?P<[^>]+>.*\)/', $base, $attrib_names, PREG_OFFSET_CAPTURE );
378
-			foreach ( $attrib_names as $attrib_name_match ) {
379
-				$beginning_offset = strlen( $attrib_prefix );
380
-				$attrib_name_end  = strpos( $attrib_name_match[0], '>', $attrib_name_match[1] );
381
-				$attrib_name      = substr( $attrib_name_match[0], $beginning_offset, $attrib_name_end - $beginning_offset );
382
-				if ( isset( $request[ $attrib_name ] ) ) {
383
-					$base  = str_replace( "(?P<$attrib_name>[\d]+)", $request[ $attrib_name ], $base );
377
+			preg_match('/\(\?P<[^>]+>.*\)/', $base, $attrib_names, PREG_OFFSET_CAPTURE);
378
+			foreach ($attrib_names as $attrib_name_match) {
379
+				$beginning_offset = strlen($attrib_prefix);
380
+				$attrib_name_end  = strpos($attrib_name_match[0], '>', $attrib_name_match[1]);
381
+				$attrib_name      = substr($attrib_name_match[0], $beginning_offset, $attrib_name_end - $beginning_offset);
382
+				if (isset($request[$attrib_name])) {
383
+					$base = str_replace("(?P<$attrib_name>[\d]+)", $request[$attrib_name], $base);
384 384
 				}
385 385
 			}
386 386
 		}
387
-		$base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $base ) ) );
387
+		$base = add_query_arg($request->get_query_params(), rest_url(sprintf('/%s/%s', $this->namespace, $base)));
388 388
 
389
-		if ( $page > 1 ) {
389
+		if ($page > 1) {
390 390
 			$prev_page = $page - 1;
391
-			if ( $prev_page > $max_pages ) {
391
+			if ($prev_page > $max_pages) {
392 392
 				$prev_page = $max_pages;
393 393
 			}
394
-			$prev_link = add_query_arg( 'page', $prev_page, $base );
395
-			$response->link_header( 'prev', $prev_link );
394
+			$prev_link = add_query_arg('page', $prev_page, $base);
395
+			$response->link_header('prev', $prev_link);
396 396
 		}
397
-		if ( $max_pages > $page ) {
397
+		if ($max_pages > $page) {
398 398
 			$next_page = $page + 1;
399
-			$next_link = add_query_arg( 'page', $next_page, $base );
400
-			$response->link_header( 'next', $next_link );
399
+			$next_link = add_query_arg('page', $next_page, $base);
400
+			$response->link_header('next', $next_link);
401 401
 		}
402 402
 
403 403
 		return $response;
@@ -409,16 +409,16 @@  discard block
 block discarded – undo
409 409
 	 * @param WP_REST_Request $request Full details about the request.
410 410
 	 * @return WP_REST_Response|WP_Error
411 411
 	 */
412
-	public function delete_item( $request ) {
412
+	public function delete_item($request) {
413 413
 		$force  = (bool) $request['force'];
414
-		$object = $this->get_object( (int) $request['id'] );
414
+		$object = $this->get_object((int) $request['id']);
415 415
 		$result = false;
416 416
 
417
-		if ( ! $object || 0 === $object->get_id() ) {
418
-			return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
417
+		if ( ! $object || 0 === $object->get_id()) {
418
+			return new WP_Error("woocommerce_rest_{$this->post_type}_invalid_id", __('Invalid ID.', 'woocommerce'), array('status' => 404));
419 419
 		}
420 420
 
421
-		$supports_trash = EMPTY_TRASH_DAYS > 0 && is_callable( array( $object, 'get_status' ) );
421
+		$supports_trash = EMPTY_TRASH_DAYS > 0 && is_callable(array($object, 'get_status'));
422 422
 
423 423
 		/**
424 424
 		 * Filter whether an object is trashable.
@@ -428,32 +428,32 @@  discard block
 block discarded – undo
428 428
 		 * @param boolean $supports_trash Whether the object type support trashing.
429 429
 		 * @param WC_Data $object         The object being considered for trashing support.
430 430
 		 */
431
-		$supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_object_trashable", $supports_trash, $object );
431
+		$supports_trash = apply_filters("woocommerce_rest_{$this->post_type}_object_trashable", $supports_trash, $object);
432 432
 
433
-		if ( ! wc_rest_check_post_permissions( $this->post_type, 'delete', $object->get_id() ) ) {
433
+		if ( ! wc_rest_check_post_permissions($this->post_type, 'delete', $object->get_id())) {
434 434
 			/* translators: %s: post type */
435
-			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() ) );
435
+			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()));
436 436
 		}
437 437
 
438
-		$request->set_param( 'context', 'edit' );
439
-		$response = $this->prepare_object_for_response( $object, $request );
438
+		$request->set_param('context', 'edit');
439
+		$response = $this->prepare_object_for_response($object, $request);
440 440
 
441 441
 		// If we're forcing, then delete permanently.
442
-		if ( $force ) {
443
-			$object->delete( true );
442
+		if ($force) {
443
+			$object->delete(true);
444 444
 			$result = 0 === $object->get_id();
445 445
 		} else {
446 446
 			// If we don't support trashing for this type, error out.
447
-			if ( ! $supports_trash ) {
447
+			if ( ! $supports_trash) {
448 448
 				/* translators: %s: post type */
449
-				return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array( 'status' => 501 ) );
449
+				return new WP_Error('woocommerce_rest_trash_not_supported', sprintf(__('The %s does not support trashing.', 'woocommerce'), $this->post_type), array('status' => 501));
450 450
 			}
451 451
 
452 452
 			// Otherwise, only trash if we haven't already.
453
-			if ( is_callable( array( $object, 'get_status' ) ) ) {
454
-				if ( 'trash' === $object->get_status() ) {
453
+			if (is_callable(array($object, 'get_status'))) {
454
+				if ('trash' === $object->get_status()) {
455 455
 					/* translators: %s: post type */
456
-					return new WP_Error( 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 410 ) );
456
+					return new WP_Error('woocommerce_rest_already_trashed', sprintf(__('The %s has already been deleted.', 'woocommerce'), $this->post_type), array('status' => 410));
457 457
 				}
458 458
 
459 459
 				$object->delete();
@@ -461,9 +461,9 @@  discard block
 block discarded – undo
461 461
 			}
462 462
 		}
463 463
 
464
-		if ( ! $result ) {
464
+		if ( ! $result) {
465 465
 			/* translators: %s: post type */
466
-			return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 500 ) );
466
+			return new WP_Error('woocommerce_rest_cannot_delete', sprintf(__('The %s cannot be deleted.', 'woocommerce'), $this->post_type), array('status' => 500));
467 467
 		}
468 468
 
469 469
 		/**
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 		 * @param WP_REST_Response $response The response data.
474 474
 		 * @param WP_REST_Request  $request  The request sent to the API.
475 475
 		 */
476
-		do_action( "woocommerce_rest_delete_{$this->post_type}_object", $object, $response, $request );
476
+		do_action("woocommerce_rest_delete_{$this->post_type}_object", $object, $response, $request);
477 477
 
478 478
 		return $response;
479 479
 	}
@@ -485,13 +485,13 @@  discard block
 block discarded – undo
485 485
 	 * @param WP_REST_Request $request Request object.
486 486
 	 * @return array                   Links for the given post.
487 487
 	 */
488
-	protected function prepare_links( $object, $request ) {
488
+	protected function prepare_links($object, $request) {
489 489
 		$links = array(
490 490
 			'self' => array(
491
-				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ),
491
+				'href' => rest_url(sprintf('/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id())),
492 492
 			),
493 493
 			'collection' => array(
494
-				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
494
+				'href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)),
495 495
 			),
496 496
 		);
497 497
 
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		$params['context']['default'] = 'view';
510 510
 
511 511
 		$params['page'] = array(
512
-			'description'        => __( 'Current page of the collection.', 'woocommerce' ),
512
+			'description'        => __('Current page of the collection.', 'woocommerce'),
513 513
 			'type'               => 'integer',
514 514
 			'default'            => 1,
515 515
 			'sanitize_callback'  => 'absint',
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 			'minimum'            => 1,
518 518
 		);
519 519
 		$params['per_page'] = array(
520
-			'description'        => __( 'Maximum number of items to be returned in result set.', 'woocommerce' ),
520
+			'description'        => __('Maximum number of items to be returned in result set.', 'woocommerce'),
521 521
 			'type'               => 'integer',
522 522
 			'default'            => 10,
523 523
 			'minimum'            => 1,
@@ -526,25 +526,25 @@  discard block
 block discarded – undo
526 526
 			'validate_callback'  => 'rest_validate_request_arg',
527 527
 		);
528 528
 		$params['search'] = array(
529
-			'description'        => __( 'Limit results to those matching a string.', 'woocommerce' ),
529
+			'description'        => __('Limit results to those matching a string.', 'woocommerce'),
530 530
 			'type'               => 'string',
531 531
 			'sanitize_callback'  => 'sanitize_text_field',
532 532
 			'validate_callback'  => 'rest_validate_request_arg',
533 533
 		);
534 534
 		$params['after'] = array(
535
-			'description'        => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
535
+			'description'        => __('Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce'),
536 536
 			'type'               => 'string',
537 537
 			'format'             => 'date-time',
538 538
 			'validate_callback'  => 'rest_validate_request_arg',
539 539
 		);
540 540
 		$params['before'] = array(
541
-			'description'        => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ),
541
+			'description'        => __('Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce'),
542 542
 			'type'               => 'string',
543 543
 			'format'             => 'date-time',
544 544
 			'validate_callback'  => 'rest_validate_request_arg',
545 545
 		);
546 546
 		$params['exclude'] = array(
547
-			'description'       => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
547
+			'description'       => __('Ensure result set excludes specific IDs.', 'woocommerce'),
548 548
 			'type'              => 'array',
549 549
 			'items'             => array(
550 550
 				'type'          => 'integer',
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 			'sanitize_callback' => 'wp_parse_id_list',
554 554
 		);
555 555
 		$params['include'] = array(
556
-			'description'       => __( 'Limit result set to specific ids.', 'woocommerce' ),
556
+			'description'       => __('Limit result set to specific ids.', 'woocommerce'),
557 557
 			'type'              => 'array',
558 558
 			'items'             => array(
559 559
 				'type'          => 'integer',
@@ -562,20 +562,20 @@  discard block
 block discarded – undo
562 562
 			'sanitize_callback' => 'wp_parse_id_list',
563 563
 		);
564 564
 		$params['offset'] = array(
565
-			'description'        => __( 'Offset the result set by a specific number of items.', 'woocommerce' ),
565
+			'description'        => __('Offset the result set by a specific number of items.', 'woocommerce'),
566 566
 			'type'               => 'integer',
567 567
 			'sanitize_callback'  => 'absint',
568 568
 			'validate_callback'  => 'rest_validate_request_arg',
569 569
 		);
570 570
 		$params['order'] = array(
571
-			'description'        => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
571
+			'description'        => __('Order sort attribute ascending or descending.', 'woocommerce'),
572 572
 			'type'               => 'string',
573 573
 			'default'            => 'desc',
574
-			'enum'               => array( 'asc', 'desc' ),
574
+			'enum'               => array('asc', 'desc'),
575 575
 			'validate_callback'  => 'rest_validate_request_arg',
576 576
 		);
577 577
 		$params['orderby'] = array(
578
-			'description'        => __( 'Sort collection by object attribute.', 'woocommerce' ),
578
+			'description'        => __('Sort collection by object attribute.', 'woocommerce'),
579 579
 			'type'               => 'string',
580 580
 			'default'            => 'date',
581 581
 			'enum'               => array(
@@ -588,9 +588,9 @@  discard block
 block discarded – undo
588 588
 			'validate_callback'  => 'rest_validate_request_arg',
589 589
 		);
590 590
 
591
-		if ( $this->hierarchical ) {
591
+		if ($this->hierarchical) {
592 592
 			$params['parent'] = array(
593
-				'description'       => __( 'Limit result set to those of particular parent IDs.', 'woocommerce' ),
593
+				'description'       => __('Limit result set to those of particular parent IDs.', 'woocommerce'),
594 594
 				'type'              => 'array',
595 595
 				'items'             => array(
596 596
 					'type'          => 'integer',
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 				'default'           => array(),
600 600
 			);
601 601
 			$params['parent_exclude'] = array(
602
-				'description'       => __( 'Limit result set to all items except those of a particular parent ID.', 'woocommerce' ),
602
+				'description'       => __('Limit result set to all items except those of a particular parent ID.', 'woocommerce'),
603 603
 				'type'              => 'array',
604 604
 				'items'             => array(
605 605
 					'type'          => 'integer',
@@ -622,6 +622,6 @@  discard block
 block discarded – undo
622 622
 		 * @param array        $query_params JSON Schema-formatted collection parameters.
623 623
 		 * @param WP_Post_Type $post_type    Post type object.
624 624
 		 */
625
-		return apply_filters( "rest_{$this->post_type}_collection_params", $params, $this->post_type );
625
+		return apply_filters("rest_{$this->post_type}_collection_params", $params, $this->post_type);
626 626
 	}
627 627
 }
Please login to merge, or discard this patch.
src/RestApi/Version3/class-wc-rest-tax-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 Tax Classes controller class.
Please login to merge, or discard this patch.
src/RestApi/Version3/class-wc-rest-network-orders-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.4.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * REST API Network Orders controller class.
Please login to merge, or discard this patch.
src/RestApi/Version3/class-wc-rest-product-tags-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 Tags controller class.
Please login to merge, or discard this patch.
src/RestApi/Version3/class-wc-rest-report-reviews-totals-controller.php 1 patch
Spacing   +17 added lines, -17 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 Reviews Totals controller class.
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
 			'meta_value' => '', // WPCS: slow query ok.
49 49
 		);
50 50
 
51
-		for ( $i = 1; $i <= 5; $i++ ) {
51
+		for ($i = 1; $i <= 5; $i++) {
52 52
 			$query_data['meta_value'] = $i;
53 53
 
54 54
 			$data[] = array(
55 55
 				'slug'  => 'rated_' . $i . '_out_of_5',
56 56
 				/* translators: %s: average rating */
57
-				'name'  => sprintf( __( 'Rated %s out of 5', 'woocommerce' ), $i ),
58
-				'total' => (int) get_comments( $query_data ),
57
+				'name'  => sprintf(__('Rated %s out of 5', 'woocommerce'), $i),
58
+				'total' => (int) get_comments($query_data),
59 59
 			);
60 60
 		}
61 61
 
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
 	 * @param  WP_REST_Request $request Request object.
70 70
 	 * @return WP_REST_Response $response Response data.
71 71
 	 */
72
-	public function prepare_item_for_response( $report, $request ) {
72
+	public function prepare_item_for_response($report, $request) {
73 73
 		$data = array(
74 74
 			'slug'  => $report->slug,
75 75
 			'name'  => $report->name,
76 76
 			'total' => $report->total,
77 77
 		);
78 78
 
79
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
80
-		$data    = $this->add_additional_fields_to_object( $data, $request );
81
-		$data    = $this->filter_response_by_context( $data, $context );
79
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
80
+		$data    = $this->add_additional_fields_to_object($data, $request);
81
+		$data    = $this->filter_response_by_context($data, $context);
82 82
 
83 83
 		// Wrap the data in a response object.
84
-		$response = rest_ensure_response( $data );
84
+		$response = rest_ensure_response($data);
85 85
 
86 86
 		/**
87 87
 		 * Filter a report returned from the API.
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		 * @param object           $report   The original report object.
93 93
 		 * @param WP_REST_Request  $request  Request used to generate the response.
94 94
 		 */
95
-		return apply_filters( 'woocommerce_rest_prepare_report_reviews_count', $response, $report, $request );
95
+		return apply_filters('woocommerce_rest_prepare_report_reviews_count', $response, $report, $request);
96 96
 	}
97 97
 
98 98
 	/**
@@ -107,26 +107,26 @@  discard block
 block discarded – undo
107 107
 			'type'       => 'object',
108 108
 			'properties' => array(
109 109
 				'slug'  => array(
110
-					'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce' ),
110
+					'description' => __('An alphanumeric identifier for the resource.', 'woocommerce'),
111 111
 					'type'        => 'string',
112
-					'context'     => array( 'view' ),
112
+					'context'     => array('view'),
113 113
 					'readonly'    => true,
114 114
 				),
115 115
 				'name'  => array(
116
-					'description' => __( 'Review type name.', 'woocommerce' ),
116
+					'description' => __('Review type name.', 'woocommerce'),
117 117
 					'type'        => 'string',
118
-					'context'     => array( 'view' ),
118
+					'context'     => array('view'),
119 119
 					'readonly'    => true,
120 120
 				),
121 121
 				'total' => array(
122
-					'description' => __( 'Amount of reviews.', 'woocommerce' ),
122
+					'description' => __('Amount of reviews.', 'woocommerce'),
123 123
 					'type'        => 'string',
124
-					'context'     => array( 'view' ),
124
+					'context'     => array('view'),
125 125
 					'readonly'    => true,
126 126
 				),
127 127
 			),
128 128
 		);
129 129
 
130
-		return $this->add_additional_fields_schema( $schema );
130
+		return $this->add_additional_fields_schema($schema);
131 131
 	}
132 132
 }
Please login to merge, or discard this patch.