Passed
Push — master ( a518b9...854ac9 )
by Mike
03:28
created
src/Server.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	 *
23 23
 	 * @var array
24 24
 	 */
25
-	protected $controllers = [];
25
+	protected $controllers = [ ];
26 26
 
27 27
 	/**
28 28
 	 * Hook into WordPress ready to init the REST API as needed.
Please login to merge, or discard this patch.
src/Controllers/Version4/Data.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@
 block discarded – undo
102 102
 
103 103
 		foreach ( $resources as $resource ) {
104 104
 			$item   = $this->prepare_item_for_response( (object) $resource, $request );
105
-			$data[] = $this->prepare_response_for_collection( $item );
105
+			$data[ ] = $this->prepare_response_for_collection( $item );
106 106
 		}
107 107
 
108 108
 		return rest_ensure_response( $data );
Please login to merge, or discard this patch.
src/Controllers/Version4/SystemStatusTools.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -572,7 +572,7 @@
 block discarded – undo
572 572
 	protected function clear_sessions() {
573 573
 		global $wpdb;
574 574
 
575
-		$wpdb->query( "TRUNCATE {$wpdb->prefix}woocommerce_sessions" );
575
+		$wpdb->query( "truncate {$wpdb->prefix}woocommerce_sessions" );
576 576
 		$result = absint( $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key='_woocommerce_persistent_cart_" . get_current_blog_id() . "';" ) ); // WPCS: unprepared SQL ok.
577 577
 		wp_cache_flush();
578 578
 		/* translators: %d: amount of sessions */
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
 		// Jetpack does the image resizing heavy lifting so you don't have to.
166 166
 		if ( ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) || ! apply_filters( 'woocommerce_background_image_regeneration', true ) ) {
167
-			unset( $tools['regenerate_thumbnails'] );
167
+			unset( $tools[ 'regenerate_thumbnails' ] );
168 168
 		}
169 169
 
170 170
 		return apply_filters( 'woocommerce_debug_tools', $tools );
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
 	public function get_items( $request ) {
180 180
 		$tools = array();
181 181
 		foreach ( $this->get_tools() as $id => $tool ) {
182
-			$tools[] = $this->prepare_response_for_collection(
182
+			$tools[ ] = $this->prepare_response_for_collection(
183 183
 				$this->prepare_item_for_response(
184 184
 					array(
185 185
 						'id'          => $id,
186
-						'name'        => $tool['name'],
187
-						'action'      => $tool['button'],
188
-						'description' => $tool['desc'],
186
+						'name'        => $tool[ 'name' ],
187
+						'action'      => $tool[ 'button' ],
188
+						'description' => $tool[ 'desc' ],
189 189
 					),
190 190
 					$request
191 191
 				)
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	public function get_item( $request ) {
206 206
 		$tools = $this->get_tools();
207
-		if ( empty( $tools[ $request['id'] ] ) ) {
207
+		if ( empty( $tools[ $request[ 'id' ] ] ) ) {
208 208
 			return new \WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
209 209
 		}
210
-		$tool = $tools[ $request['id'] ];
210
+		$tool = $tools[ $request[ 'id' ] ];
211 211
 		return rest_ensure_response(
212 212
 			$this->prepare_item_for_response(
213 213
 				array(
214
-					'id'          => $request['id'],
215
-					'name'        => $tool['name'],
216
-					'action'      => $tool['button'],
217
-					'description' => $tool['desc'],
214
+					'id'          => $request[ 'id' ],
215
+					'name'        => $tool[ 'name' ],
216
+					'action'      => $tool[ 'button' ],
217
+					'description' => $tool[ 'desc' ],
218 218
 				),
219 219
 				$request
220 220
 			)
@@ -229,19 +229,19 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	public function update_item( $request ) {
231 231
 		$tools = $this->get_tools();
232
-		if ( empty( $tools[ $request['id'] ] ) ) {
232
+		if ( empty( $tools[ $request[ 'id' ] ] ) ) {
233 233
 			return new \WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
234 234
 		}
235 235
 
236
-		$tool = $tools[ $request['id'] ];
236
+		$tool = $tools[ $request[ 'id' ] ];
237 237
 		$tool = array(
238
-			'id'          => $request['id'],
239
-			'name'        => $tool['name'],
240
-			'action'      => $tool['button'],
241
-			'description' => $tool['desc'],
238
+			'id'          => $request[ 'id' ],
239
+			'name'        => $tool[ 'name' ],
240
+			'action'      => $tool[ 'button' ],
241
+			'description' => $tool[ 'desc' ],
242 242
 		);
243 243
 
244
-		$execute_return = $this->execute_tool( $request['id'] );
244
+		$execute_return = $this->execute_tool( $request[ 'id' ] );
245 245
 		$tool           = array_merge( $tool, $execute_return );
246 246
 
247 247
 		/**
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 		$base  = '/' . $this->namespace . '/' . $this->rest_base;
331 331
 		$links = array(
332 332
 			'item' => array(
333
-				'href'       => rest_url( trailingslashit( $base ) . $item['id'] ),
333
+				'href'       => rest_url( trailingslashit( $base ) . $item[ 'id' ] ),
334 334
 				'embeddable' => true,
335 335
 			),
336 336
 		);
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 				throw new Exception( __( 'There was an error calling this tool. There is no callback present.', 'woocommerce-rest-api' ) );
366 366
 			}
367 367
 
368
-			$callback = isset( $tools[ $tool ]['callback'] ) ? $tools[ $tool ]['callback'] : array( $this, $tool );
368
+			$callback = isset( $tools[ $tool ][ 'callback' ] ) ? $tools[ $tool ][ 'callback' ] : array( $this, $tool );
369 369
 
370 370
 			if ( ! is_callable( $callback ) ) {
371 371
 				throw new Exception( __( 'There was an error calling this tool. Invalid callback.', 'woocommerce-rest-api' ) );
Please login to merge, or discard this patch.
src/Controllers/Version4/Requests/AbstractObjectRequest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
 
58 58
 		if ( ! is_null( $meta_data ) ) {
59 59
 			foreach ( $meta_data as $meta ) {
60
-				$object->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' );
60
+				$object->update_meta_data( $meta[ 'key' ], $meta[ 'value' ], isset( $meta[ 'id' ] ) ? $meta[ 'id' ] : '' );
61 61
 			}
62 62
 		}
63 63
 	}
Please login to merge, or discard this patch.
src/Controllers/Version4/Requests/CustomerRequest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		];
55 55
 
56 56
 		$request_props = array_intersect_key( $this->request, array_flip( $props ) );
57
-		$prop_values   = [];
57
+		$prop_values   = [ ];
58 58
 
59 59
 		foreach ( $request_props as $prop => $value ) {
60 60
 			switch ( $prop ) {
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 * @return array
95 95
 	 */
96 96
 	protected function parse_address_field( $data, $object, $type = 'billing' ) {
97
-		$address = [];
97
+		$address = [ ];
98 98
 		foreach ( $data as $key => $value ) {
99 99
 			if ( is_callable( array( $object, "set_{$type}_{$key}" ) ) ) {
100 100
 				$address[ "{$type}_{$key}" ] = $value;
Please login to merge, or discard this patch.
src/Controllers/Version4/Requests/ProductVariationRequest.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -77,22 +77,22 @@  discard block
 block discarded – undo
77 77
 		];
78 78
 
79 79
 		$request_props = array_intersect_key( $this->request, array_flip( $props ) );
80
-		$prop_values   = [];
80
+		$prop_values   = [ ];
81 81
 
82 82
 		foreach ( $request_props as $prop => $value ) {
83 83
 			switch ( $prop ) {
84 84
 				case 'image':
85
-					$prop_values['image_id'] = $this->parse_image_field( $value, $object );
85
+					$prop_values[ 'image_id' ] = $this->parse_image_field( $value, $object );
86 86
 					break;
87 87
 				case 'attributes':
88
-					$prop_values['attributes'] = $this->parse_attributes_field( $value, $object );
88
+					$prop_values[ 'attributes' ] = $this->parse_attributes_field( $value, $object );
89 89
 					break;
90 90
 				case 'dimensions':
91 91
 					$dimensions  = $this->parse_dimensions_fields( $value );
92 92
 					$prop_values = array_merge( $prop_values, $dimensions );
93 93
 					break;
94 94
 				case 'shipping_class':
95
-					$prop_values['shipping_class_id'] = $this->parse_shipping_class( $value, $object );
95
+					$prop_values[ 'shipping_class_id' ] = $this->parse_shipping_class( $value, $object );
96 96
 					break;
97 97
 				default:
98 98
 					$prop_values[ $prop ] = $value;
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 			$attribute_name = '';
121 121
 
122 122
 			// Check ID for global attributes or name for product attributes.
123
-			if ( ! empty( $attribute['id'] ) ) {
124
-				$attribute_id   = absint( $attribute['id'] );
123
+			if ( ! empty( $attribute[ 'id' ] ) ) {
124
+				$attribute_id   = absint( $attribute[ 'id' ] );
125 125
 				$attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id );
126
-			} elseif ( ! empty( $attribute['name'] ) ) {
127
-				$attribute_name = sanitize_title( $attribute['name'] );
126
+			} elseif ( ! empty( $attribute[ 'name' ] ) ) {
127
+				$attribute_name = sanitize_title( $attribute[ 'name' ] );
128 128
 			}
129 129
 
130 130
 			if ( ! $attribute_id && ! $attribute_name ) {
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 			}
137 137
 
138 138
 			$attribute_key   = sanitize_title( $parent_attributes[ $attribute_name ]->get_name() );
139
-			$attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : '';
139
+			$attribute_value = isset( $attribute[ 'option' ] ) ? wc_clean( stripslashes( $attribute[ 'option' ] ) ) : '';
140 140
 
141 141
 			if ( $parent_attributes[ $attribute_name ]->is_taxonomy() ) {
142 142
 				// If dealing with a taxonomy, we need to get the slug from the name posted to the API.
@@ -168,19 +168,19 @@  discard block
 block discarded – undo
168 168
 			return '';
169 169
 		}
170 170
 
171
-		$attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0;
171
+		$attachment_id = isset( $image[ 'id' ] ) ? absint( $image[ 'id' ] ) : 0;
172 172
 		$attachment    = new ImageAttachment( $attachment_id, $object->get_id() );
173 173
 
174
-		if ( 0 === $attachment->id && ! empty( $image['src'] ) ) {
175
-			$attachment->upload_image_from_src( $image['src'] );
174
+		if ( 0 === $attachment->id && ! empty( $image[ 'src' ] ) ) {
175
+			$attachment->upload_image_from_src( $image[ 'src' ] );
176 176
 		}
177 177
 
178
-		if ( ! empty( $image['alt'] ) ) {
179
-			$attachment->update_alt_text( $image['alt'] );
178
+		if ( ! empty( $image[ 'alt' ] ) ) {
179
+			$attachment->update_alt_text( $image[ 'alt' ] );
180 180
 		}
181 181
 
182
-		if ( ! empty( $image['name'] ) ) {
183
-			$attachment->update_name( $image['name'] );
182
+		if ( ! empty( $image[ 'name' ] ) ) {
183
+			$attachment->update_name( $image[ 'name' ] );
184 184
 		}
185 185
 
186 186
 		return $attachment->id;
Please login to merge, or discard this patch.
src/Controllers/Version4/Requests/ProductRequest.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		];
130 130
 
131 131
 		$request_props = array_intersect_key( $this->request, array_flip( $props ) );
132
-		$prop_values   = [];
132
+		$prop_values   = [ ];
133 133
 
134 134
 		foreach ( $request_props as $prop => $value ) {
135 135
 			switch ( $prop ) {
@@ -146,20 +146,20 @@  discard block
 block discarded – undo
146 146
 					$prop_values = array_merge( $prop_values, $images );
147 147
 					break;
148 148
 				case 'categories':
149
-					$prop_values['category_ids'] = wp_list_pluck( $value, 'id' );
149
+					$prop_values[ 'category_ids' ] = wp_list_pluck( $value, 'id' );
150 150
 					break;
151 151
 				case 'tags':
152
-					$prop_values['tag_ids'] = wp_list_pluck( $value, 'id' );
152
+					$prop_values[ 'tag_ids' ] = wp_list_pluck( $value, 'id' );
153 153
 					break;
154 154
 				case 'attributes':
155
-					$prop_values['attributes'] = $this->parse_attributes_field( $value );
155
+					$prop_values[ 'attributes' ] = $this->parse_attributes_field( $value );
156 156
 					break;
157 157
 				case 'dimensions':
158 158
 					$dimensions  = $this->parse_dimensions_fields( $value );
159 159
 					$prop_values = array_merge( $prop_values, $dimensions );
160 160
 					break;
161 161
 				case 'shipping_class':
162
-					$prop_values['shipping_class_id'] = $this->parse_shipping_class( $value, $object );
162
+					$prop_values[ 'shipping_class_id' ] = $this->parse_shipping_class( $value, $object );
163 163
 					break;
164 164
 				default:
165 165
 					$prop_values[ $prop ] = $value;
@@ -248,34 +248,34 @@  discard block
 block discarded – undo
248 248
 		$attributes = array();
249 249
 
250 250
 		foreach ( $raw_attributes as $attribute ) {
251
-			if ( ! empty( $attribute['id'] ) ) {
252
-				$attribute_id   = absint( $attribute['id'] );
251
+			if ( ! empty( $attribute[ 'id' ] ) ) {
252
+				$attribute_id   = absint( $attribute[ 'id' ] );
253 253
 				$attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id );
254
-			} elseif ( ! empty( $attribute['name'] ) ) {
254
+			} elseif ( ! empty( $attribute[ 'name' ] ) ) {
255 255
 				$attribute_id   = 0;
256
-				$attribute_name = wc_clean( $attribute['name'] );
256
+				$attribute_name = wc_clean( $attribute[ 'name' ] );
257 257
 			}
258 258
 
259
-			if ( ! $attribute_name || ! isset( $attribute['options'] ) ) {
259
+			if ( ! $attribute_name || ! isset( $attribute[ 'options' ] ) ) {
260 260
 				continue;
261 261
 			}
262 262
 
263
-			if ( ! is_array( $attribute['options'] ) ) {
264
-				$attribute['options'] = explode( \WC_DELIMITER, $attribute['options'] );
263
+			if ( ! is_array( $attribute[ 'options' ] ) ) {
264
+				$attribute[ 'options' ] = explode( \WC_DELIMITER, $attribute[ 'options' ] );
265 265
 			}
266 266
 
267 267
 			if ( $attribute_id ) {
268
-				$attribute['options'] = array_filter( array_map( 'wc_sanitize_term_text_based', $attribute['options'] ), 'strlen' );
268
+				$attribute[ 'options' ] = array_filter( array_map( 'wc_sanitize_term_text_based', $attribute[ 'options' ] ), 'strlen' );
269 269
 			}
270 270
 
271 271
 			$attribute_object = new \WC_Product_Attribute();
272 272
 			$attribute_object->set_id( $attribute_id );
273 273
 			$attribute_object->set_name( $attribute_name );
274
-			$attribute_object->set_options( $attribute['options'] );
275
-			$attribute_object->set_position( isset( $attribute['position'] ) ? (string) absint( $attribute['position'] ) : '0' );
276
-			$attribute_object->set_visible( ! empty( $attribute['visible'] ) ? 1 : 0 );
277
-			$attribute_object->set_variation( ! empty( $attribute['variation'] ) ? 1 : 0 );
278
-			$attributes[] = $attribute_object;
274
+			$attribute_object->set_options( $attribute[ 'options' ] );
275
+			$attribute_object->set_position( isset( $attribute[ 'position' ] ) ? (string) absint( $attribute[ 'position' ] ) : '0' );
276
+			$attribute_object->set_visible( ! empty( $attribute[ 'visible' ] ) ? 1 : 0 );
277
+			$attribute_object->set_variation( ! empty( $attribute[ 'variation' ] ) ? 1 : 0 );
278
+			$attributes[ ] = $attribute_object;
279 279
 		}
280 280
 		return $attributes;
281 281
 	}
@@ -291,35 +291,35 @@  discard block
 block discarded – undo
291 291
 	protected function parse_images_field( $images, $object ) {
292 292
 		$response = [
293 293
 			'image_id'          => '',
294
-			'gallery_image_ids' => [],
294
+			'gallery_image_ids' => [ ],
295 295
 		];
296 296
 
297
-		$images = is_array( $images ) ? array_filter( $images ) : [];
297
+		$images = is_array( $images ) ? array_filter( $images ) : [ ];
298 298
 
299 299
 		if ( empty( $images ) ) {
300 300
 			return $response;
301 301
 		}
302 302
 
303 303
 		foreach ( $images as $index => $image ) {
304
-			$attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0;
304
+			$attachment_id = isset( $image[ 'id' ] ) ? absint( $image[ 'id' ] ) : 0;
305 305
 			$attachment    = new ImageAttachment( $attachment_id, $object->get_id() );
306 306
 
307
-			if ( 0 === $attachment->id && ! empty( $image['src'] ) ) {
308
-				$attachment->upload_image_from_src( $image['src'] );
307
+			if ( 0 === $attachment->id && ! empty( $image[ 'src' ] ) ) {
308
+				$attachment->upload_image_from_src( $image[ 'src' ] );
309 309
 			}
310 310
 
311
-			if ( ! empty( $image['alt'] ) ) {
312
-				$attachment->update_alt_text( $image['alt'] );
311
+			if ( ! empty( $image[ 'alt' ] ) ) {
312
+				$attachment->update_alt_text( $image[ 'alt' ] );
313 313
 			}
314 314
 
315
-			if ( ! empty( $image['name'] ) ) {
316
-				$attachment->update_name( $image['name'] );
315
+			if ( ! empty( $image[ 'name' ] ) ) {
316
+				$attachment->update_name( $image[ 'name' ] );
317 317
 			}
318 318
 
319 319
 			if ( 0 === $index ) {
320
-				$response['image_id'] = $attachment->id;
320
+				$response[ 'image_id' ] = $attachment->id;
321 321
 			} else {
322
-				$response['gallery_image_ids'][] = $attachment->id;
322
+				$response[ 'gallery_image_ids' ][ ] = $attachment->id;
323 323
 			}
324 324
 		}
325 325
 
@@ -333,18 +333,18 @@  discard block
 block discarded – undo
333 333
 	 * @return array
334 334
 	 */
335 335
 	protected function parse_dimensions_fields( $dimensions ) {
336
-		$response = [];
336
+		$response = [ ];
337 337
 
338
-		if ( isset( $dimensions['length'] ) ) {
339
-			$response['length'] = $dimensions['length'];
338
+		if ( isset( $dimensions[ 'length' ] ) ) {
339
+			$response[ 'length' ] = $dimensions[ 'length' ];
340 340
 		}
341 341
 
342
-		if ( isset( $dimensions['width'] ) ) {
343
-			$response['width'] = $dimensions['width'];
342
+		if ( isset( $dimensions[ 'width' ] ) ) {
343
+			$response[ 'width' ] = $dimensions[ 'width' ];
344 344
 		}
345 345
 
346
-		if ( isset( $dimensions['height'] ) ) {
347
-			$response['height'] = $dimensions['height'];
346
+		if ( isset( $dimensions[ 'height' ] ) ) {
347
+			$response[ 'height' ] = $dimensions[ 'height' ];
348 348
 		}
349 349
 
350 350
 		return $response;
@@ -371,15 +371,15 @@  discard block
 block discarded – undo
371 371
 	protected function parse_downloads_field( $downloads ) {
372 372
 		$files = array();
373 373
 		foreach ( $downloads as $key => $file ) {
374
-			if ( empty( $file['file'] ) ) {
374
+			if ( empty( $file[ 'file' ] ) ) {
375 375
 				continue;
376 376
 			}
377 377
 
378 378
 			$download = new \WC_Product_Download();
379
-			$download->set_id( ! empty( $file['id'] ) ? $file['id'] : wp_generate_uuid4() );
380
-			$download->set_name( $file['name'] ? $file['name'] : wc_get_filename_from_url( $file['file'] ) );
381
-			$download->set_file( $file['file'] );
382
-			$files[] = $download;
379
+			$download->set_id( ! empty( $file[ 'id' ] ) ? $file[ 'id' ] : wp_generate_uuid4() );
380
+			$download->set_name( $file[ 'name' ] ? $file[ 'name' ] : wc_get_filename_from_url( $file[ 'file' ] ) );
381
+			$download->set_file( $file[ 'file' ] );
382
+			$files[ ] = $download;
383 383
 		}
384 384
 		return $files;
385 385
 	}
@@ -400,11 +400,11 @@  discard block
 block discarded – undo
400 400
 			$attribute_name = '';
401 401
 
402 402
 			// Check ID for global attributes or name for product attributes.
403
-			if ( ! empty( $attribute['id'] ) ) {
404
-				$attribute_id   = absint( $attribute['id'] );
403
+			if ( ! empty( $attribute[ 'id' ] ) ) {
404
+				$attribute_id   = absint( $attribute[ 'id' ] );
405 405
 				$attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id );
406
-			} elseif ( ! empty( $attribute['name'] ) ) {
407
-				$attribute_name = sanitize_title( $attribute['name'] );
406
+			} elseif ( ! empty( $attribute[ 'name' ] ) ) {
407
+				$attribute_name = sanitize_title( $attribute[ 'name' ] );
408 408
 			}
409 409
 
410 410
 			if ( ! $attribute_id && ! $attribute_name ) {
@@ -414,10 +414,10 @@  discard block
 block discarded – undo
414 414
 			if ( isset( $attributes[ $attribute_name ] ) ) {
415 415
 				$_attribute = $attributes[ $attribute_name ];
416 416
 
417
-				if ( $_attribute['is_variation'] ) {
418
-					$value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : '';
417
+				if ( $_attribute[ 'is_variation' ] ) {
418
+					$value = isset( $attribute[ 'option' ] ) ? wc_clean( stripslashes( $attribute[ 'option' ] ) ) : '';
419 419
 
420
-					if ( ! empty( $_attribute['is_taxonomy'] ) ) {
420
+					if ( ! empty( $_attribute[ 'is_taxonomy' ] ) ) {
421 421
 						// If dealing with a taxonomy, we need to get the slug from the name posted to the API.
422 422
 						$term = get_term_by( 'name', $value, $attribute_name );
423 423
 
Please login to merge, or discard this patch.
src/Controllers/Version4/ProductCategories.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		if ( $image_id ) {
57 57
 			$attachment = get_post( $image_id );
58 58
 
59
-			$data['image'] = array(
59
+			$data[ 'image' ] = array(
60 60
 				'id'                => (int) $image_id,
61 61
 				'date_created'      => wc_rest_prepare_date_response( $attachment->post_date ),
62 62
 				'date_created_gmt'  => wc_rest_prepare_date_response( $attachment->post_date_gmt ),
@@ -82,17 +82,17 @@  discard block
 block discarded – undo
82 82
 	protected function update_term_meta_fields( $term, $request ) {
83 83
 		$id = (int) $term->term_id;
84 84
 
85
-		if ( isset( $request['display'] ) ) {
86
-			update_term_meta( $id, 'display_type', 'default' === $request['display'] ? '' : $request['display'] );
85
+		if ( isset( $request[ 'display' ] ) ) {
86
+			update_term_meta( $id, 'display_type', 'default' === $request[ 'display' ] ? '' : $request[ 'display' ] );
87 87
 		}
88 88
 
89
-		if ( isset( $request['menu_order'] ) ) {
90
-			update_term_meta( $id, 'order', $request['menu_order'] );
89
+		if ( isset( $request[ 'menu_order' ] ) ) {
90
+			update_term_meta( $id, 'order', $request[ 'menu_order' ] );
91 91
 		}
92 92
 
93
-		if ( isset( $request['image'] ) ) {
94
-			if ( empty( $request['image']['id'] ) && ! empty( $request['image']['src'] ) ) {
95
-				$upload = wc_rest_upload_image_from_url( esc_url_raw( $request['image']['src'] ) );
93
+		if ( isset( $request[ 'image' ] ) ) {
94
+			if ( empty( $request[ 'image' ][ 'id' ] ) && ! empty( $request[ 'image' ][ 'src' ] ) ) {
95
+				$upload = wc_rest_upload_image_from_url( esc_url_raw( $request[ 'image' ][ 'src' ] ) );
96 96
 
97 97
 				if ( is_wp_error( $upload ) ) {
98 98
 					return $upload;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 
101 101
 				$image_id = wc_rest_set_uploaded_image_as_attachment( $upload );
102 102
 			} else {
103
-				$image_id = isset( $request['image']['id'] ) ? absint( $request['image']['id'] ) : 0;
103
+				$image_id = isset( $request[ 'image' ][ 'id' ] ) ? absint( $request[ 'image' ][ 'id' ] ) : 0;
104 104
 			}
105 105
 
106 106
 			// Check if image_id is a valid image attachment before updating the term meta.
@@ -108,16 +108,16 @@  discard block
 block discarded – undo
108 108
 				update_term_meta( $id, 'thumbnail_id', $image_id );
109 109
 
110 110
 				// Set the image alt.
111
-				if ( ! empty( $request['image']['alt'] ) ) {
112
-					update_post_meta( $image_id, '_wp_attachment_image_alt', wc_clean( $request['image']['alt'] ) );
111
+				if ( ! empty( $request[ 'image' ][ 'alt' ] ) ) {
112
+					update_post_meta( $image_id, '_wp_attachment_image_alt', wc_clean( $request[ 'image' ][ 'alt' ] ) );
113 113
 				}
114 114
 
115 115
 				// Set the image title.
116
-				if ( ! empty( $request['image']['name'] ) ) {
116
+				if ( ! empty( $request[ 'image' ][ 'name' ] ) ) {
117 117
 					wp_update_post(
118 118
 						array(
119 119
 							'ID'         => $image_id,
120
-							'post_title' => wc_clean( $request['image']['name'] ),
120
+							'post_title' => wc_clean( $request[ 'image' ][ 'name' ] ),
121 121
 						)
122 122
 					);
123 123
 				}
Please login to merge, or discard this patch.
src/Controllers/Version4/Settings.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -83,19 +83,19 @@  discard block
 block discarded – undo
83 83
 		foreach ( $groups as $group ) {
84 84
 			$sub_groups = array();
85 85
 			foreach ( $groups as $_group ) {
86
-				if ( ! empty( $_group['parent_id'] ) && $group['id'] === $_group['parent_id'] ) {
87
-					$sub_groups[] = $_group['id'];
86
+				if ( ! empty( $_group[ 'parent_id' ] ) && $group[ 'id' ] === $_group[ 'parent_id' ] ) {
87
+					$sub_groups[ ] = $_group[ 'id' ];
88 88
 				}
89 89
 			}
90
-			$group['sub_groups'] = $sub_groups;
90
+			$group[ 'sub_groups' ] = $sub_groups;
91 91
 
92 92
 			$group = wp_parse_args( $group, $defaults );
93
-			if ( ! is_null( $group['id'] ) && ! is_null( $group['label'] ) ) {
93
+			if ( ! is_null( $group[ 'id' ] ) && ! is_null( $group[ 'label' ] ) ) {
94 94
 				$group_obj  = $this->filter_group( $group );
95 95
 				$group_data = $this->prepare_item_for_response( $group_obj, $request );
96 96
 				$group_data = $this->prepare_response_for_collection( $group_data );
97 97
 
98
-				$filtered_groups[] = $group_data;
98
+				$filtered_groups[ ] = $group_data;
99 99
 			}
100 100
 		}
101 101
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 		$base  = '/' . $this->namespace . '/' . $this->rest_base;
115 115
 		$links = array(
116 116
 			'options' => array(
117
-				'href' => rest_url( trailingslashit( $base ) . $item['id'] ),
117
+				'href' => rest_url( trailingslashit( $base ) . $item[ 'id' ] ),
118 118
 			),
119 119
 		);
120 120
 
Please login to merge, or discard this patch.