Test Failed
Push — master ( a5e4c3...7495fa )
by Mike
43:00
created
src/Controllers/Version3/class-wc-rest-system-status-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
  * System status controller class.
Please login to merge, or discard this patch.
src/Controllers/Version3/class-wc-rest-data-countries-controller.php 1 patch
Spacing   +46 added lines, -46 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 Data countries controller class.
@@ -42,26 +42,26 @@  discard block
 block discarded – undo
42 42
 			$this->namespace, '/' . $this->rest_base, array(
43 43
 				array(
44 44
 					'methods'             => WP_REST_Server::READABLE,
45
-					'callback'            => array( $this, 'get_items' ),
46
-					'permission_callback' => array( $this, 'get_items_permissions_check' ),
45
+					'callback'            => array($this, 'get_items'),
46
+					'permission_callback' => array($this, 'get_items_permissions_check'),
47 47
 				),
48
-				'schema' => array( $this, 'get_public_item_schema' ),
48
+				'schema' => array($this, 'get_public_item_schema'),
49 49
 			)
50 50
 		);
51 51
 		register_rest_route(
52 52
 			$this->namespace, '/' . $this->rest_base . '/(?P<location>[\w-]+)', array(
53 53
 				array(
54 54
 					'methods'             => WP_REST_Server::READABLE,
55
-					'callback'            => array( $this, 'get_item' ),
56
-					'permission_callback' => array( $this, 'get_items_permissions_check' ),
55
+					'callback'            => array($this, 'get_item'),
56
+					'permission_callback' => array($this, 'get_items_permissions_check'),
57 57
 					'args'                => array(
58 58
 						'location' => array(
59
-							'description' => __( 'ISO3166 alpha-2 country code.', 'woocommerce' ),
59
+							'description' => __('ISO3166 alpha-2 country code.', 'woocommerce'),
60 60
 							'type'        => 'string',
61 61
 						),
62 62
 					),
63 63
 				),
64
-				'schema' => array( $this, 'get_public_item_schema' ),
64
+				'schema' => array($this, 'get_public_item_schema'),
65 65
 			)
66 66
 		);
67 67
 	}
@@ -73,23 +73,23 @@  discard block
 block discarded – undo
73 73
 	 * @param  WP_REST_Request $request      Request data.
74 74
 	 * @return array|mixed Response data, ready for insertion into collection data.
75 75
 	 */
76
-	public function get_country( $country_code = false, $request ) {
76
+	public function get_country($country_code = false, $request) {
77 77
 		$countries = WC()->countries->get_countries();
78 78
 		$states    = WC()->countries->get_states();
79 79
 		$data      = array();
80 80
 
81
-		if ( ! array_key_exists( $country_code, $countries ) ) {
81
+		if ( ! array_key_exists($country_code, $countries)) {
82 82
 			return false;
83 83
 		}
84 84
 
85 85
 		$country = array(
86 86
 			'code' => $country_code,
87
-			'name' => $countries[ $country_code ],
87
+			'name' => $countries[$country_code],
88 88
 		);
89 89
 
90 90
 		$local_states = array();
91
-		if ( isset( $states[ $country_code ] ) ) {
92
-			foreach ( $states[ $country_code ] as $state_code => $state_name ) {
91
+		if (isset($states[$country_code])) {
92
+			foreach ($states[$country_code] as $state_code => $state_name) {
93 93
 				$local_states[] = array(
94 94
 					'code' => $state_code,
95 95
 					'name' => $state_name,
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
 	 * @param  WP_REST_Request $request Request data.
108 108
 	 * @return WP_Error|WP_REST_Response
109 109
 	 */
110
-	public function get_items( $request ) {
110
+	public function get_items($request) {
111 111
 		$countries = WC()->countries->get_countries();
112 112
 		$data      = array();
113 113
 
114
-		foreach ( array_keys( $countries ) as $country_code ) {
115
-			$country  = $this->get_country( $country_code, $request );
116
-			$response = $this->prepare_item_for_response( $country, $request );
117
-			$data[]   = $this->prepare_response_for_collection( $response );
114
+		foreach (array_keys($countries) as $country_code) {
115
+			$country  = $this->get_country($country_code, $request);
116
+			$response = $this->prepare_item_for_response($country, $request);
117
+			$data[]   = $this->prepare_response_for_collection($response);
118 118
 		}
119 119
 
120
-		return rest_ensure_response( $data );
120
+		return rest_ensure_response($data);
121 121
 	}
122 122
 
123 123
 	/**
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 	 * @param  WP_REST_Request $request Request data.
128 128
 	 * @return WP_Error|WP_REST_Response
129 129
 	 */
130
-	public function get_item( $request ) {
131
-		$data = $this->get_country( strtoupper( $request['location'] ), $request );
132
-		if ( empty( $data ) ) {
133
-			return new WP_Error( 'woocommerce_rest_data_invalid_location', __( 'There are no locations matching these parameters.', 'woocommerce' ), array( 'status' => 404 ) );
130
+	public function get_item($request) {
131
+		$data = $this->get_country(strtoupper($request['location']), $request);
132
+		if (empty($data)) {
133
+			return new WP_Error('woocommerce_rest_data_invalid_location', __('There are no locations matching these parameters.', 'woocommerce'), array('status' => 404));
134 134
 		}
135
-		return $this->prepare_item_for_response( $data, $request );
135
+		return $this->prepare_item_for_response($data, $request);
136 136
 	}
137 137
 
138 138
 	/**
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
 	 * @param WP_REST_Request $request Request object.
144 144
 	 * @return WP_REST_Response $response Response data.
145 145
 	 */
146
-	public function prepare_item_for_response( $item, $request ) {
147
-		$data     = $this->add_additional_fields_to_object( $item, $request );
148
-		$data     = $this->filter_response_by_context( $data, 'view' );
149
-		$response = rest_ensure_response( $data );
146
+	public function prepare_item_for_response($item, $request) {
147
+		$data     = $this->add_additional_fields_to_object($item, $request);
148
+		$data     = $this->filter_response_by_context($data, 'view');
149
+		$response = rest_ensure_response($data);
150 150
 
151
-		$response->add_links( $this->prepare_links( $item ) );
151
+		$response->add_links($this->prepare_links($item));
152 152
 
153 153
 		/**
154 154
 		 * Filter the states list for a country returned from the API.
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		 * @param array            $data     The original country's states list.
160 160
 		 * @param WP_REST_Request  $request  Request used to generate the response.
161 161
 		 */
162
-		return apply_filters( 'woocommerce_rest_prepare_data_country', $response, $item, $request );
162
+		return apply_filters('woocommerce_rest_prepare_data_country', $response, $item, $request);
163 163
 	}
164 164
 
165 165
 	/**
@@ -168,14 +168,14 @@  discard block
 block discarded – undo
168 168
 	 * @param object $item Data object.
169 169
 	 * @return array Links for the given country.
170 170
 	 */
171
-	protected function prepare_links( $item ) {
172
-		$country_code = strtolower( $item['code'] );
171
+	protected function prepare_links($item) {
172
+		$country_code = strtolower($item['code']);
173 173
 		$links        = array(
174 174
 			'self'       => array(
175
-				'href' => rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->rest_base, $country_code ) ),
175
+				'href' => rest_url(sprintf('/%s/%s/%s', $this->namespace, $this->rest_base, $country_code)),
176 176
 			),
177 177
 			'collection' => array(
178
-				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
178
+				'href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)),
179 179
 			),
180 180
 		);
181 181
 
@@ -197,36 +197,36 @@  discard block
 block discarded – undo
197 197
 			'properties' => array(
198 198
 				'code'   => array(
199 199
 					'type'        => 'string',
200
-					'description' => __( 'ISO3166 alpha-2 country code.', 'woocommerce' ),
201
-					'context'     => array( 'view' ),
200
+					'description' => __('ISO3166 alpha-2 country code.', 'woocommerce'),
201
+					'context'     => array('view'),
202 202
 					'readonly'    => true,
203 203
 				),
204 204
 				'name'   => array(
205 205
 					'type'        => 'string',
206
-					'description' => __( 'Full name of country.', 'woocommerce' ),
207
-					'context'     => array( 'view' ),
206
+					'description' => __('Full name of country.', 'woocommerce'),
207
+					'context'     => array('view'),
208 208
 					'readonly'    => true,
209 209
 				),
210 210
 				'states' => array(
211 211
 					'type'        => 'array',
212
-					'description' => __( 'List of states in this country.', 'woocommerce' ),
213
-					'context'     => array( 'view' ),
212
+					'description' => __('List of states in this country.', 'woocommerce'),
213
+					'context'     => array('view'),
214 214
 					'readonly'    => true,
215 215
 					'items'       => array(
216 216
 						'type'       => 'object',
217
-						'context'    => array( 'view' ),
217
+						'context'    => array('view'),
218 218
 						'readonly'   => true,
219 219
 						'properties' => array(
220 220
 							'code' => array(
221 221
 								'type'        => 'string',
222
-								'description' => __( 'State code.', 'woocommerce' ),
223
-								'context'     => array( 'view' ),
222
+								'description' => __('State code.', 'woocommerce'),
223
+								'context'     => array('view'),
224 224
 								'readonly'    => true,
225 225
 							),
226 226
 							'name' => array(
227 227
 								'type'        => 'string',
228
-								'description' => __( 'Full name of state.', 'woocommerce' ),
229
-								'context'     => array( 'view' ),
228
+								'description' => __('Full name of state.', 'woocommerce'),
229
+								'context'     => array('view'),
230 230
 								'readonly'    => true,
231 231
 							),
232 232
 						),
@@ -235,6 +235,6 @@  discard block
 block discarded – undo
235 235
 			),
236 236
 		);
237 237
 
238
-		return $this->add_additional_fields_schema( $schema );
238
+		return $this->add_additional_fields_schema($schema);
239 239
 	}
240 240
 }
Please login to merge, or discard this patch.
src/Controllers/Version3/class-wc-rest-system-status-tools-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
  * System status tools controller.
Please login to merge, or discard this patch.
src/Controllers/Version3/class-wc-rest-setting-options-controller.php 1 patch
Spacing   +53 added lines, -53 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 Setting Options controller class.
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 	 * @param string $setting_id Setting ID.
33 33
 	 * @return stdClass|WP_Error
34 34
 	 */
35
-	public function get_setting( $group_id, $setting_id ) {
36
-		$setting = parent::get_setting( $group_id, $setting_id );
37
-		if ( is_wp_error( $setting ) ) {
35
+	public function get_setting($group_id, $setting_id) {
36
+		$setting = parent::get_setting($group_id, $setting_id);
37
+		if (is_wp_error($setting)) {
38 38
 			return $setting;
39 39
 		}
40 40
 		$setting['group_id'] = $group_id;
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @param  string $key Key to check.
48 48
 	 * @return boolean
49 49
 	 */
50
-	public function allowed_setting_keys( $key ) {
50
+	public function allowed_setting_keys($key) {
51 51
 		return in_array(
52 52
 			$key, array(
53 53
 				'id',
@@ -71,39 +71,39 @@  discard block
 block discarded – undo
71 71
 	 * @param string $group_id Group ID.
72 72
 	 * @return array|WP_Error
73 73
 	 */
74
-	public function get_group_settings( $group_id ) {
75
-		if ( empty( $group_id ) ) {
76
-			return new WP_Error( 'rest_setting_setting_group_invalid', __( 'Invalid setting group.', 'woocommerce' ), array( 'status' => 404 ) );
74
+	public function get_group_settings($group_id) {
75
+		if (empty($group_id)) {
76
+			return new WP_Error('rest_setting_setting_group_invalid', __('Invalid setting group.', 'woocommerce'), array('status' => 404));
77 77
 		}
78 78
 
79
-		$settings = apply_filters( 'woocommerce_settings-' . $group_id, array() ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
79
+		$settings = apply_filters('woocommerce_settings-' . $group_id, array()); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
80 80
 
81
-		if ( empty( $settings ) ) {
82
-			return new WP_Error( 'rest_setting_setting_group_invalid', __( 'Invalid setting group.', 'woocommerce' ), array( 'status' => 404 ) );
81
+		if (empty($settings)) {
82
+			return new WP_Error('rest_setting_setting_group_invalid', __('Invalid setting group.', 'woocommerce'), array('status' => 404));
83 83
 		}
84 84
 
85 85
 		$filtered_settings = array();
86
-		foreach ( $settings as $setting ) {
86
+		foreach ($settings as $setting) {
87 87
 			$option_key = $setting['option_key'];
88
-			$setting    = $this->filter_setting( $setting );
89
-			$default    = isset( $setting['default'] ) ? $setting['default'] : '';
88
+			$setting    = $this->filter_setting($setting);
89
+			$default    = isset($setting['default']) ? $setting['default'] : '';
90 90
 			// Get the option value.
91
-			if ( is_array( $option_key ) ) {
92
-				$option           = get_option( $option_key[0] );
93
-				$setting['value'] = isset( $option[ $option_key[1] ] ) ? $option[ $option_key[1] ] : $default;
91
+			if (is_array($option_key)) {
92
+				$option           = get_option($option_key[0]);
93
+				$setting['value'] = isset($option[$option_key[1]]) ? $option[$option_key[1]] : $default;
94 94
 			} else {
95
-				$admin_setting_value = WC_Admin_Settings::get_option( $option_key, $default );
95
+				$admin_setting_value = WC_Admin_Settings::get_option($option_key, $default);
96 96
 				$setting['value']    = $admin_setting_value;
97 97
 			}
98 98
 
99
-			if ( 'multi_select_countries' === $setting['type'] ) {
99
+			if ('multi_select_countries' === $setting['type']) {
100 100
 				$setting['options'] = WC()->countries->get_countries();
101 101
 				$setting['type']    = 'multiselect';
102
-			} elseif ( 'single_select_country' === $setting['type'] ) {
102
+			} elseif ('single_select_country' === $setting['type']) {
103 103
 				$setting['type']    = 'select';
104 104
 				$setting['options'] = $this->get_countries_and_states();
105
-			} elseif ( 'single_select_page' === $setting['type'] ) {
106
-				$pages   = get_pages(
105
+			} elseif ('single_select_page' === $setting['type']) {
106
+				$pages = get_pages(
107 107
 					array(
108 108
 						'sort_column'  => 'menu_order',
109 109
 						'sort_order'   => 'ASC',
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 					)
112 112
 				);
113 113
 				$options = array();
114
-				foreach ( $pages as $page ) {
115
-					$options[ $page->ID ] = ! empty( $page->post_title ) ? $page->post_title : '#' . $page->ID;
114
+				foreach ($pages as $page) {
115
+					$options[$page->ID] = ! empty($page->post_title) ? $page->post_title : '#' . $page->ID;
116 116
 				}
117 117
 				$setting['type']    = 'select';
118 118
 				$setting['options'] = $options;
@@ -132,19 +132,19 @@  discard block
 block discarded – undo
132 132
 	 */
133 133
 	private function get_countries_and_states() {
134 134
 		$countries = WC()->countries->get_countries();
135
-		if ( ! $countries ) {
135
+		if ( ! $countries) {
136 136
 			return array();
137 137
 		}
138 138
 		$output = array();
139
-		foreach ( $countries as $key => $value ) {
140
-			$states = WC()->countries->get_states( $key );
139
+		foreach ($countries as $key => $value) {
140
+			$states = WC()->countries->get_states($key);
141 141
 
142
-			if ( $states ) {
143
-				foreach ( $states as $state_key => $state_value ) {
144
-					$output[ $key . ':' . $state_key ] = $value . ' - ' . $state_value;
142
+			if ($states) {
143
+				foreach ($states as $state_key => $state_value) {
144
+					$output[$key . ':' . $state_key] = $value . ' - ' . $state_value;
145 145
 				}
146 146
 			} else {
147
-				$output[ $key ] = $value;
147
+				$output[$key] = $value;
148 148
 			}
149 149
 		}
150 150
 		return $output;
@@ -162,89 +162,89 @@  discard block
 block discarded – undo
162 162
 			'type'       => 'object',
163 163
 			'properties' => array(
164 164
 				'id'          => array(
165
-					'description' => __( 'A unique identifier for the setting.', 'woocommerce' ),
165
+					'description' => __('A unique identifier for the setting.', 'woocommerce'),
166 166
 					'type'        => 'string',
167 167
 					'arg_options' => array(
168 168
 						'sanitize_callback' => 'sanitize_title',
169 169
 					),
170
-					'context'     => array( 'view', 'edit' ),
170
+					'context'     => array('view', 'edit'),
171 171
 					'readonly'    => true,
172 172
 				),
173 173
 				'group_id'    => array(
174
-					'description' => __( 'An identifier for the group this setting belongs to.', 'woocommerce' ),
174
+					'description' => __('An identifier for the group this setting belongs to.', 'woocommerce'),
175 175
 					'type'        => 'string',
176 176
 					'arg_options' => array(
177 177
 						'sanitize_callback' => 'sanitize_title',
178 178
 					),
179
-					'context'     => array( 'view', 'edit' ),
179
+					'context'     => array('view', 'edit'),
180 180
 					'readonly'    => true,
181 181
 				),
182 182
 				'label'       => array(
183
-					'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ),
183
+					'description' => __('A human readable label for the setting used in interfaces.', 'woocommerce'),
184 184
 					'type'        => 'string',
185 185
 					'arg_options' => array(
186 186
 						'sanitize_callback' => 'sanitize_text_field',
187 187
 					),
188
-					'context'     => array( 'view', 'edit' ),
188
+					'context'     => array('view', 'edit'),
189 189
 					'readonly'    => true,
190 190
 				),
191 191
 				'description' => array(
192
-					'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ),
192
+					'description' => __('A human readable description for the setting used in interfaces.', 'woocommerce'),
193 193
 					'type'        => 'string',
194 194
 					'arg_options' => array(
195 195
 						'sanitize_callback' => 'sanitize_text_field',
196 196
 					),
197
-					'context'     => array( 'view', 'edit' ),
197
+					'context'     => array('view', 'edit'),
198 198
 					'readonly'    => true,
199 199
 				),
200 200
 				'value'       => array(
201
-					'description' => __( 'Setting value.', 'woocommerce' ),
201
+					'description' => __('Setting value.', 'woocommerce'),
202 202
 					'type'        => 'mixed',
203
-					'context'     => array( 'view', 'edit' ),
203
+					'context'     => array('view', 'edit'),
204 204
 				),
205 205
 				'default'     => array(
206
-					'description' => __( 'Default value for the setting.', 'woocommerce' ),
206
+					'description' => __('Default value for the setting.', 'woocommerce'),
207 207
 					'type'        => 'mixed',
208
-					'context'     => array( 'view', 'edit' ),
208
+					'context'     => array('view', 'edit'),
209 209
 					'readonly'    => true,
210 210
 				),
211 211
 				'tip'         => array(
212
-					'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce' ),
212
+					'description' => __('Additional help text shown to the user about the setting.', 'woocommerce'),
213 213
 					'type'        => 'string',
214 214
 					'arg_options' => array(
215 215
 						'sanitize_callback' => 'sanitize_text_field',
216 216
 					),
217
-					'context'     => array( 'view', 'edit' ),
217
+					'context'     => array('view', 'edit'),
218 218
 					'readonly'    => true,
219 219
 				),
220 220
 				'placeholder' => array(
221
-					'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce' ),
221
+					'description' => __('Placeholder text to be displayed in text inputs.', 'woocommerce'),
222 222
 					'type'        => 'string',
223 223
 					'arg_options' => array(
224 224
 						'sanitize_callback' => 'sanitize_text_field',
225 225
 					),
226
-					'context'     => array( 'view', 'edit' ),
226
+					'context'     => array('view', 'edit'),
227 227
 					'readonly'    => true,
228 228
 				),
229 229
 				'type'        => array(
230
-					'description' => __( 'Type of setting.', 'woocommerce' ),
230
+					'description' => __('Type of setting.', 'woocommerce'),
231 231
 					'type'        => 'string',
232 232
 					'arg_options' => array(
233 233
 						'sanitize_callback' => 'sanitize_text_field',
234 234
 					),
235
-					'context'     => array( 'view', 'edit' ),
236
-					'enum'        => array( 'text', 'email', 'number', 'color', 'password', 'textarea', 'select', 'multiselect', 'radio', 'image_width', 'checkbox' ),
235
+					'context'     => array('view', 'edit'),
236
+					'enum'        => array('text', 'email', 'number', 'color', 'password', 'textarea', 'select', 'multiselect', 'radio', 'image_width', 'checkbox'),
237 237
 					'readonly'    => true,
238 238
 				),
239 239
 				'options'     => array(
240
-					'description' => __( 'Array of options (key value pairs) for inputs such as select, multiselect, and radio buttons.', 'woocommerce' ),
240
+					'description' => __('Array of options (key value pairs) for inputs such as select, multiselect, and radio buttons.', 'woocommerce'),
241 241
 					'type'        => 'object',
242
-					'context'     => array( 'view', 'edit' ),
242
+					'context'     => array('view', 'edit'),
243 243
 					'readonly'    => true,
244 244
 				),
245 245
 			),
246 246
 		);
247 247
 
248
-		return $this->add_additional_fields_schema( $schema );
248
+		return $this->add_additional_fields_schema($schema);
249 249
 	}
250 250
 }
Please login to merge, or discard this patch.
src/Controllers/Version3/class-wc-rest-report-coupons-totals-controller.php 1 patch
Spacing   +21 added lines, -21 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 Coupons Totals controller class.
@@ -41,25 +41,25 @@  discard block
 block discarded – undo
41 41
 	protected function get_reports() {
42 42
 		global $wpdb;
43 43
 
44
-		$data = get_transient( 'rest_api_coupons_type_count' );
45
-		if ( false !== $data ) {
44
+		$data = get_transient('rest_api_coupons_type_count');
45
+		if (false !== $data) {
46 46
 			return $data;
47 47
 		}
48 48
 
49 49
 		$types = wc_get_coupon_types();
50 50
 		$data  = array();
51 51
 
52
-		foreach ( $types as $slug => $name ) {
52
+		foreach ($types as $slug => $name) {
53 53
 			$results = $wpdb->get_results(
54
-				$wpdb->prepare( "
54
+				$wpdb->prepare("
55 55
 					SELECT count(meta_id) AS total
56 56
 					FROM $wpdb->postmeta
57 57
 					WHERE meta_key = 'discount_type'
58 58
 					AND meta_value = %s
59
-				", $slug )
59
+				", $slug)
60 60
 			);
61 61
 
62
-			$total = isset( $results[0] ) ? (int) $results[0]->total : 0;
62
+			$total = isset($results[0]) ? (int) $results[0]->total : 0;
63 63
 
64 64
 			$data[] = array(
65 65
 				'slug'  => $slug,
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 			);
69 69
 		}
70 70
 
71
-		set_transient( 'rest_api_coupons_type_count', $data, YEAR_IN_SECONDS );
71
+		set_transient('rest_api_coupons_type_count', $data, YEAR_IN_SECONDS);
72 72
 
73 73
 		return $data;
74 74
 	}
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
 	 * @param  WP_REST_Request $request Request object.
81 81
 	 * @return WP_REST_Response $response Response data.
82 82
 	 */
83
-	public function prepare_item_for_response( $report, $request ) {
83
+	public function prepare_item_for_response($report, $request) {
84 84
 		$data = array(
85 85
 			'slug'  => $report->slug,
86 86
 			'name'  => $report->name,
87 87
 			'total' => $report->total,
88 88
 		);
89 89
 
90
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
91
-		$data    = $this->add_additional_fields_to_object( $data, $request );
92
-		$data    = $this->filter_response_by_context( $data, $context );
90
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
91
+		$data    = $this->add_additional_fields_to_object($data, $request);
92
+		$data    = $this->filter_response_by_context($data, $context);
93 93
 
94 94
 		// Wrap the data in a response object.
95
-		$response = rest_ensure_response( $data );
95
+		$response = rest_ensure_response($data);
96 96
 
97 97
 		/**
98 98
 		 * Filter a report returned from the API.
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		 * @param object           $report   The original report object.
104 104
 		 * @param WP_REST_Request  $request  Request used to generate the response.
105 105
 		 */
106
-		return apply_filters( 'woocommerce_rest_prepare_report_coupons_count', $response, $report, $request );
106
+		return apply_filters('woocommerce_rest_prepare_report_coupons_count', $response, $report, $request);
107 107
 	}
108 108
 
109 109
 	/**
@@ -118,26 +118,26 @@  discard block
 block discarded – undo
118 118
 			'type'       => 'object',
119 119
 			'properties' => array(
120 120
 				'slug'  => array(
121
-					'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce' ),
121
+					'description' => __('An alphanumeric identifier for the resource.', 'woocommerce'),
122 122
 					'type'        => 'string',
123
-					'context'     => array( 'view' ),
123
+					'context'     => array('view'),
124 124
 					'readonly'    => true,
125 125
 				),
126 126
 				'name'  => array(
127
-					'description' => __( 'Coupon type name.', 'woocommerce' ),
127
+					'description' => __('Coupon type name.', 'woocommerce'),
128 128
 					'type'        => 'string',
129
-					'context'     => array( 'view' ),
129
+					'context'     => array('view'),
130 130
 					'readonly'    => true,
131 131
 				),
132 132
 				'total' => array(
133
-					'description' => __( 'Amount of coupons.', 'woocommerce' ),
133
+					'description' => __('Amount of coupons.', 'woocommerce'),
134 134
 					'type'        => 'string',
135
-					'context'     => array( 'view' ),
135
+					'context'     => array('view'),
136 136
 					'readonly'    => true,
137 137
 				),
138 138
 			),
139 139
 		);
140 140
 
141
-		return $this->add_additional_fields_schema( $schema );
141
+		return $this->add_additional_fields_schema($schema);
142 142
 	}
143 143
 }
Please login to merge, or discard this patch.
src/Controllers/Version3/class-wc-rest-data-continents-controller.php 1 patch
Spacing   +74 added lines, -74 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 Data continents controller class.
@@ -42,26 +42,26 @@  discard block
 block discarded – undo
42 42
 			$this->namespace, '/' . $this->rest_base, array(
43 43
 				array(
44 44
 					'methods'             => WP_REST_Server::READABLE,
45
-					'callback'            => array( $this, 'get_items' ),
46
-					'permission_callback' => array( $this, 'get_items_permissions_check' ),
45
+					'callback'            => array($this, 'get_items'),
46
+					'permission_callback' => array($this, 'get_items_permissions_check'),
47 47
 				),
48
-				'schema' => array( $this, 'get_public_item_schema' ),
48
+				'schema' => array($this, 'get_public_item_schema'),
49 49
 			)
50 50
 		);
51 51
 		register_rest_route(
52 52
 			$this->namespace, '/' . $this->rest_base . '/(?P<location>[\w-]+)', array(
53 53
 				array(
54 54
 					'methods'             => WP_REST_Server::READABLE,
55
-					'callback'            => array( $this, 'get_item' ),
56
-					'permission_callback' => array( $this, 'get_items_permissions_check' ),
55
+					'callback'            => array($this, 'get_item'),
56
+					'permission_callback' => array($this, 'get_items_permissions_check'),
57 57
 					'args'                => array(
58 58
 						'continent' => array(
59
-							'description' => __( '2 character continent code.', 'woocommerce' ),
59
+							'description' => __('2 character continent code.', 'woocommerce'),
60 60
 							'type'        => 'string',
61 61
 						),
62 62
 					),
63 63
 				),
64
-				'schema' => array( $this, 'get_public_item_schema' ),
64
+				'schema' => array($this, 'get_public_item_schema'),
65 65
 			)
66 66
 		);
67 67
 	}
@@ -74,18 +74,18 @@  discard block
 block discarded – undo
74 74
 	 * @param  WP_REST_Request $request        Request data.
75 75
 	 * @return array|mixed Response data, ready for insertion into collection data.
76 76
 	 */
77
-	public function get_continent( $continent_code = false, $request ) {
77
+	public function get_continent($continent_code = false, $request) {
78 78
 		$continents  = WC()->countries->get_continents();
79 79
 		$countries   = WC()->countries->get_countries();
80 80
 		$states      = WC()->countries->get_states();
81 81
 		$locale_info = include WC()->plugin_path() . '/i18n/locale-info.php';
82 82
 		$data        = array();
83 83
 
84
-		if ( ! array_key_exists( $continent_code, $continents ) ) {
84
+		if ( ! array_key_exists($continent_code, $continents)) {
85 85
 			return false;
86 86
 		}
87 87
 
88
-		$continent_list = $continents[ $continent_code ];
88
+		$continent_list = $continents[$continent_code];
89 89
 
90 90
 		$continent = array(
91 91
 			'code' => $continent_code,
@@ -93,18 +93,18 @@  discard block
 block discarded – undo
93 93
 		);
94 94
 
95 95
 		$local_countries = array();
96
-		foreach ( $continent_list['countries'] as $country_code ) {
97
-			if ( isset( $countries[ $country_code ] ) ) {
96
+		foreach ($continent_list['countries'] as $country_code) {
97
+			if (isset($countries[$country_code])) {
98 98
 				$country = array(
99 99
 					'code' => $country_code,
100
-					'name' => $countries[ $country_code ],
100
+					'name' => $countries[$country_code],
101 101
 				);
102 102
 
103 103
 				// If we have detailed locale information include that in the response.
104
-				if ( array_key_exists( $country_code, $locale_info ) ) {
104
+				if (array_key_exists($country_code, $locale_info)) {
105 105
 					// Defensive programming against unexpected changes in locale-info.php.
106 106
 					$country_data = wp_parse_args(
107
-						$locale_info[ $country_code ], array(
107
+						$locale_info[$country_code], array(
108 108
 							'currency_code'  => 'USD',
109 109
 							'currency_pos'   => 'left',
110 110
 							'decimal_sep'    => '.',
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
 						)
116 116
 					);
117 117
 
118
-					$country = array_merge( $country, $country_data );
118
+					$country = array_merge($country, $country_data);
119 119
 				}
120 120
 
121 121
 				$local_states = array();
122
-				if ( isset( $states[ $country_code ] ) ) {
123
-					foreach ( $states[ $country_code ] as $state_code => $state_name ) {
122
+				if (isset($states[$country_code])) {
123
+					foreach ($states[$country_code] as $state_code => $state_name) {
124 124
 						$local_states[] = array(
125 125
 							'code' => $state_code,
126 126
 							'name' => $state_name,
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 					'thousand_sep',
143 143
 					'weight_unit',
144 144
 				);
145
-				$country = array_intersect_key( $country, array_flip( $allowed ) );
145
+				$country = array_intersect_key($country, array_flip($allowed));
146 146
 
147 147
 				$local_countries[] = $country;
148 148
 			}
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
 	 * @param  WP_REST_Request $request Request data.
160 160
 	 * @return WP_Error|WP_REST_Response
161 161
 	 */
162
-	public function get_items( $request ) {
162
+	public function get_items($request) {
163 163
 		$continents = WC()->countries->get_continents();
164 164
 		$data       = array();
165 165
 
166
-		foreach ( array_keys( $continents ) as $continent_code ) {
167
-			$continent = $this->get_continent( $continent_code, $request );
168
-			$response  = $this->prepare_item_for_response( $continent, $request );
169
-			$data[]    = $this->prepare_response_for_collection( $response );
166
+		foreach (array_keys($continents) as $continent_code) {
167
+			$continent = $this->get_continent($continent_code, $request);
168
+			$response  = $this->prepare_item_for_response($continent, $request);
169
+			$data[]    = $this->prepare_response_for_collection($response);
170 170
 		}
171 171
 
172
-		return rest_ensure_response( $data );
172
+		return rest_ensure_response($data);
173 173
 	}
174 174
 
175 175
 	/**
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
 	 * @param  WP_REST_Request $request Request data.
180 180
 	 * @return WP_Error|WP_REST_Response
181 181
 	 */
182
-	public function get_item( $request ) {
183
-		$data = $this->get_continent( strtoupper( $request['location'] ), $request );
184
-		if ( empty( $data ) ) {
185
-			return new WP_Error( 'woocommerce_rest_data_invalid_location', __( 'There are no locations matching these parameters.', 'woocommerce' ), array( 'status' => 404 ) );
182
+	public function get_item($request) {
183
+		$data = $this->get_continent(strtoupper($request['location']), $request);
184
+		if (empty($data)) {
185
+			return new WP_Error('woocommerce_rest_data_invalid_location', __('There are no locations matching these parameters.', 'woocommerce'), array('status' => 404));
186 186
 		}
187
-		return $this->prepare_item_for_response( $data, $request );
187
+		return $this->prepare_item_for_response($data, $request);
188 188
 	}
189 189
 
190 190
 	/**
@@ -195,12 +195,12 @@  discard block
 block discarded – undo
195 195
 	 * @param WP_REST_Request $request Request object.
196 196
 	 * @return WP_REST_Response $response Response data.
197 197
 	 */
198
-	public function prepare_item_for_response( $item, $request ) {
199
-		$data     = $this->add_additional_fields_to_object( $item, $request );
200
-		$data     = $this->filter_response_by_context( $data, 'view' );
201
-		$response = rest_ensure_response( $data );
198
+	public function prepare_item_for_response($item, $request) {
199
+		$data     = $this->add_additional_fields_to_object($item, $request);
200
+		$data     = $this->filter_response_by_context($data, 'view');
201
+		$response = rest_ensure_response($data);
202 202
 
203
-		$response->add_links( $this->prepare_links( $item ) );
203
+		$response->add_links($this->prepare_links($item));
204 204
 
205 205
 		/**
206 206
 		 * Filter the location list returned from the API.
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 		 * @param array            $item     The original list of continent(s), countries, and states.
212 212
 		 * @param WP_REST_Request  $request  Request used to generate the response.
213 213
 		 */
214
-		return apply_filters( 'woocommerce_rest_prepare_data_continent', $response, $item, $request );
214
+		return apply_filters('woocommerce_rest_prepare_data_continent', $response, $item, $request);
215 215
 	}
216 216
 
217 217
 	/**
@@ -220,14 +220,14 @@  discard block
 block discarded – undo
220 220
 	 * @param object $item Data object.
221 221
 	 * @return array Links for the given continent.
222 222
 	 */
223
-	protected function prepare_links( $item ) {
224
-		$continent_code = strtolower( $item['code'] );
223
+	protected function prepare_links($item) {
224
+		$continent_code = strtolower($item['code']);
225 225
 		$links          = array(
226 226
 			'self'       => array(
227
-				'href' => rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->rest_base, $continent_code ) ),
227
+				'href' => rest_url(sprintf('/%s/%s/%s', $this->namespace, $this->rest_base, $continent_code)),
228 228
 			),
229 229
 			'collection' => array(
230
-				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
230
+				'href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)),
231 231
 			),
232 232
 		);
233 233
 		return $links;
@@ -247,88 +247,88 @@  discard block
 block discarded – undo
247 247
 			'properties' => array(
248 248
 				'code'      => array(
249 249
 					'type'        => 'string',
250
-					'description' => __( '2 character continent code.', 'woocommerce' ),
251
-					'context'     => array( 'view' ),
250
+					'description' => __('2 character continent code.', 'woocommerce'),
251
+					'context'     => array('view'),
252 252
 					'readonly'    => true,
253 253
 				),
254 254
 				'name'      => array(
255 255
 					'type'        => 'string',
256
-					'description' => __( 'Full name of continent.', 'woocommerce' ),
257
-					'context'     => array( 'view' ),
256
+					'description' => __('Full name of continent.', 'woocommerce'),
257
+					'context'     => array('view'),
258 258
 					'readonly'    => true,
259 259
 				),
260 260
 				'countries' => array(
261 261
 					'type'        => 'array',
262
-					'description' => __( 'List of countries on this continent.', 'woocommerce' ),
263
-					'context'     => array( 'view' ),
262
+					'description' => __('List of countries on this continent.', 'woocommerce'),
263
+					'context'     => array('view'),
264 264
 					'readonly'    => true,
265 265
 					'items'       => array(
266 266
 						'type'       => 'object',
267
-						'context'    => array( 'view' ),
267
+						'context'    => array('view'),
268 268
 						'readonly'   => true,
269 269
 						'properties' => array(
270 270
 							'code'           => array(
271 271
 								'type'        => 'string',
272
-								'description' => __( 'ISO3166 alpha-2 country code.', 'woocommerce' ),
273
-								'context'     => array( 'view' ),
272
+								'description' => __('ISO3166 alpha-2 country code.', 'woocommerce'),
273
+								'context'     => array('view'),
274 274
 								'readonly'    => true,
275 275
 							),
276 276
 							'currency_code'  => array(
277 277
 								'type'        => 'string',
278
-								'description' => __( 'Default ISO4127 alpha-3 currency code for the country.', 'woocommerce' ),
279
-								'context'     => array( 'view' ),
278
+								'description' => __('Default ISO4127 alpha-3 currency code for the country.', 'woocommerce'),
279
+								'context'     => array('view'),
280 280
 								'readonly'    => true,
281 281
 							),
282 282
 							'currency_pos'   => array(
283 283
 								'type'        => 'string',
284
-								'description' => __( 'Currency symbol position for this country.', 'woocommerce' ),
285
-								'context'     => array( 'view' ),
284
+								'description' => __('Currency symbol position for this country.', 'woocommerce'),
285
+								'context'     => array('view'),
286 286
 								'readonly'    => true,
287 287
 							),
288 288
 							'decimal_sep'    => array(
289 289
 								'type'        => 'string',
290
-								'description' => __( 'Decimal separator for displayed prices for this country.', 'woocommerce' ),
291
-								'context'     => array( 'view' ),
290
+								'description' => __('Decimal separator for displayed prices for this country.', 'woocommerce'),
291
+								'context'     => array('view'),
292 292
 								'readonly'    => true,
293 293
 							),
294 294
 							'dimension_unit' => array(
295 295
 								'type'        => 'string',
296
-								'description' => __( 'The unit lengths are defined in for this country.', 'woocommerce' ),
297
-								'context'     => array( 'view' ),
296
+								'description' => __('The unit lengths are defined in for this country.', 'woocommerce'),
297
+								'context'     => array('view'),
298 298
 								'readonly'    => true,
299 299
 							),
300 300
 							'name'           => array(
301 301
 								'type'        => 'string',
302
-								'description' => __( 'Full name of country.', 'woocommerce' ),
303
-								'context'     => array( 'view' ),
302
+								'description' => __('Full name of country.', 'woocommerce'),
303
+								'context'     => array('view'),
304 304
 								'readonly'    => true,
305 305
 							),
306 306
 							'num_decimals'   => array(
307 307
 								'type'        => 'integer',
308
-								'description' => __( 'Number of decimal points shown in displayed prices for this country.', 'woocommerce' ),
309
-								'context'     => array( 'view' ),
308
+								'description' => __('Number of decimal points shown in displayed prices for this country.', 'woocommerce'),
309
+								'context'     => array('view'),
310 310
 								'readonly'    => true,
311 311
 							),
312 312
 							'states'         => array(
313 313
 								'type'        => 'array',
314
-								'description' => __( 'List of states in this country.', 'woocommerce' ),
315
-								'context'     => array( 'view' ),
314
+								'description' => __('List of states in this country.', 'woocommerce'),
315
+								'context'     => array('view'),
316 316
 								'readonly'    => true,
317 317
 								'items'       => array(
318 318
 									'type'       => 'object',
319
-									'context'    => array( 'view' ),
319
+									'context'    => array('view'),
320 320
 									'readonly'   => true,
321 321
 									'properties' => array(
322 322
 										'code' => array(
323 323
 											'type'        => 'string',
324
-											'description' => __( 'State code.', 'woocommerce' ),
325
-											'context'     => array( 'view' ),
324
+											'description' => __('State code.', 'woocommerce'),
325
+											'context'     => array('view'),
326 326
 											'readonly'    => true,
327 327
 										),
328 328
 										'name' => array(
329 329
 											'type'        => 'string',
330
-											'description' => __( 'Full name of state.', 'woocommerce' ),
331
-											'context'     => array( 'view' ),
330
+											'description' => __('Full name of state.', 'woocommerce'),
331
+											'context'     => array('view'),
332 332
 											'readonly'    => true,
333 333
 										),
334 334
 									),
@@ -336,14 +336,14 @@  discard block
 block discarded – undo
336 336
 							),
337 337
 							'thousand_sep'   => array(
338 338
 								'type'        => 'string',
339
-								'description' => __( 'Thousands separator for displayed prices in this country.', 'woocommerce' ),
340
-								'context'     => array( 'view' ),
339
+								'description' => __('Thousands separator for displayed prices in this country.', 'woocommerce'),
340
+								'context'     => array('view'),
341 341
 								'readonly'    => true,
342 342
 							),
343 343
 							'weight_unit'    => array(
344 344
 								'type'        => 'string',
345
-								'description' => __( 'The unit weights are defined in for this country.', 'woocommerce' ),
346
-								'context'     => array( 'view' ),
345
+								'description' => __('The unit weights are defined in for this country.', 'woocommerce'),
346
+								'context'     => array('view'),
347 347
 								'readonly'    => true,
348 348
 							),
349 349
 						),
@@ -352,6 +352,6 @@  discard block
 block discarded – undo
352 352
 			),
353 353
 		);
354 354
 
355
-		return $this->add_additional_fields_schema( $schema );
355
+		return $this->add_additional_fields_schema($schema);
356 356
 	}
357 357
 }
Please login to merge, or discard this patch.
src/Controllers/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.
src/Controllers/Version1/class-wc-rest-orders-v1-controller.php 1 patch
Spacing   +480 added lines, -480 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @since    3.0.0
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -47,74 +47,74 @@  discard block
 block discarded – undo
47 47
 	 * Initialize orders actions.
48 48
 	 */
49 49
 	public function __construct() {
50
-		add_filter( "woocommerce_rest_{$this->post_type}_query", array( $this, 'query_args' ), 10, 2 );
50
+		add_filter("woocommerce_rest_{$this->post_type}_query", array($this, 'query_args'), 10, 2);
51 51
 	}
52 52
 
53 53
 	/**
54 54
 	 * Register the routes for orders.
55 55
 	 */
56 56
 	public function register_routes() {
57
-		register_rest_route( $this->namespace, '/' . $this->rest_base, array(
57
+		register_rest_route($this->namespace, '/' . $this->rest_base, array(
58 58
 			array(
59 59
 				'methods'             => WP_REST_Server::READABLE,
60
-				'callback'            => array( $this, 'get_items' ),
61
-				'permission_callback' => array( $this, 'get_items_permissions_check' ),
60
+				'callback'            => array($this, 'get_items'),
61
+				'permission_callback' => array($this, 'get_items_permissions_check'),
62 62
 				'args'                => $this->get_collection_params(),
63 63
 			),
64 64
 			array(
65 65
 				'methods'             => WP_REST_Server::CREATABLE,
66
-				'callback'            => array( $this, 'create_item' ),
67
-				'permission_callback' => array( $this, 'create_item_permissions_check' ),
68
-				'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
66
+				'callback'            => array($this, 'create_item'),
67
+				'permission_callback' => array($this, 'create_item_permissions_check'),
68
+				'args'                => $this->get_endpoint_args_for_item_schema(WP_REST_Server::CREATABLE),
69 69
 			),
70
-			'schema' => array( $this, 'get_public_item_schema' ),
71
-		) );
70
+			'schema' => array($this, 'get_public_item_schema'),
71
+		));
72 72
 
73
-		register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
73
+		register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
74 74
 			'args' => array(
75 75
 				'id' => array(
76
-					'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
76
+					'description' => __('Unique identifier for the resource.', 'woocommerce'),
77 77
 					'type'        => 'integer',
78 78
 				),
79 79
 			),
80 80
 			array(
81 81
 				'methods'             => WP_REST_Server::READABLE,
82
-				'callback'            => array( $this, 'get_item' ),
83
-				'permission_callback' => array( $this, 'get_item_permissions_check' ),
82
+				'callback'            => array($this, 'get_item'),
83
+				'permission_callback' => array($this, 'get_item_permissions_check'),
84 84
 				'args'                => array(
85
-					'context' => $this->get_context_param( array( 'default' => 'view' ) ),
85
+					'context' => $this->get_context_param(array('default' => 'view')),
86 86
 				),
87 87
 			),
88 88
 			array(
89 89
 				'methods'             => WP_REST_Server::EDITABLE,
90
-				'callback'            => array( $this, 'update_item' ),
91
-				'permission_callback' => array( $this, 'update_item_permissions_check' ),
92
-				'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
90
+				'callback'            => array($this, 'update_item'),
91
+				'permission_callback' => array($this, 'update_item_permissions_check'),
92
+				'args'                => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE),
93 93
 			),
94 94
 			array(
95 95
 				'methods'             => WP_REST_Server::DELETABLE,
96
-				'callback'            => array( $this, 'delete_item' ),
97
-				'permission_callback' => array( $this, 'delete_item_permissions_check' ),
96
+				'callback'            => array($this, 'delete_item'),
97
+				'permission_callback' => array($this, 'delete_item_permissions_check'),
98 98
 				'args'                => array(
99 99
 					'force' => array(
100 100
 						'default'     => false,
101 101
 						'type'        => 'boolean',
102
-						'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
102
+						'description' => __('Whether to bypass trash and force deletion.', 'woocommerce'),
103 103
 					),
104 104
 				),
105 105
 			),
106
-			'schema' => array( $this, 'get_public_item_schema' ),
107
-		) );
106
+			'schema' => array($this, 'get_public_item_schema'),
107
+		));
108 108
 
109
-		register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array(
109
+		register_rest_route($this->namespace, '/' . $this->rest_base . '/batch', array(
110 110
 			array(
111 111
 				'methods'             => WP_REST_Server::EDITABLE,
112
-				'callback'            => array( $this, 'batch_items' ),
113
-				'permission_callback' => array( $this, 'batch_items_permissions_check' ),
114
-				'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
112
+				'callback'            => array($this, 'batch_items'),
113
+				'permission_callback' => array($this, 'batch_items_permissions_check'),
114
+				'args'                => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE),
115 115
 			),
116
-			'schema' => array( $this, 'get_public_batch_schema' ),
117
-		) );
116
+			'schema' => array($this, 'get_public_batch_schema'),
117
+		));
118 118
 	}
119 119
 
120 120
 	/**
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 	 * @param WP_REST_Request $request Request object.
125 125
 	 * @return WP_REST_Response $data
126 126
 	 */
127
-	public function prepare_item_for_response( $post, $request ) {
128
-		$order = wc_get_order( $post );
129
-		$dp    = is_null( $request['dp'] ) ? wc_get_price_decimals() : absint( $request['dp'] );
127
+	public function prepare_item_for_response($post, $request) {
128
+		$order = wc_get_order($post);
129
+		$dp    = is_null($request['dp']) ? wc_get_price_decimals() : absint($request['dp']);
130 130
 
131 131
 		$data = array(
132 132
 			'id'                   => $order->get_id(),
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
 			'currency'             => $order->get_currency(),
138 138
 			'version'              => $order->get_version(),
139 139
 			'prices_include_tax'   => $order->get_prices_include_tax(),
140
-			'date_created'         => wc_rest_prepare_date_response( $order->get_date_created() ),  // v1 API used UTC.
141
-			'date_modified'        => wc_rest_prepare_date_response( $order->get_date_modified() ), // v1 API used UTC.
140
+			'date_created'         => wc_rest_prepare_date_response($order->get_date_created()), // v1 API used UTC.
141
+			'date_modified'        => wc_rest_prepare_date_response($order->get_date_modified()), // v1 API used UTC.
142 142
 			'customer_id'          => $order->get_customer_id(),
143
-			'discount_total'       => wc_format_decimal( $order->get_total_discount(), $dp ),
144
-			'discount_tax'         => wc_format_decimal( $order->get_discount_tax(), $dp ),
145
-			'shipping_total'       => wc_format_decimal( $order->get_shipping_total(), $dp ),
146
-			'shipping_tax'         => wc_format_decimal( $order->get_shipping_tax(), $dp ),
147
-			'cart_tax'             => wc_format_decimal( $order->get_cart_tax(), $dp ),
148
-			'total'                => wc_format_decimal( $order->get_total(), $dp ),
149
-			'total_tax'            => wc_format_decimal( $order->get_total_tax(), $dp ),
143
+			'discount_total'       => wc_format_decimal($order->get_total_discount(), $dp),
144
+			'discount_tax'         => wc_format_decimal($order->get_discount_tax(), $dp),
145
+			'shipping_total'       => wc_format_decimal($order->get_shipping_total(), $dp),
146
+			'shipping_tax'         => wc_format_decimal($order->get_shipping_tax(), $dp),
147
+			'cart_tax'             => wc_format_decimal($order->get_cart_tax(), $dp),
148
+			'total'                => wc_format_decimal($order->get_total(), $dp),
149
+			'total_tax'            => wc_format_decimal($order->get_total_tax(), $dp),
150 150
 			'billing'              => array(),
151 151
 			'shipping'             => array(),
152 152
 			'payment_method'       => $order->get_payment_method(),
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 			'customer_user_agent'  => $order->get_customer_user_agent(),
157 157
 			'created_via'          => $order->get_created_via(),
158 158
 			'customer_note'        => $order->get_customer_note(),
159
-			'date_completed'       => wc_rest_prepare_date_response( $order->get_date_completed(), false ), // v1 API used local time.
160
-			'date_paid'            => wc_rest_prepare_date_response( $order->get_date_paid(), false ), // v1 API used local time.
159
+			'date_completed'       => wc_rest_prepare_date_response($order->get_date_completed(), false), // v1 API used local time.
160
+			'date_paid'            => wc_rest_prepare_date_response($order->get_date_paid(), false), // v1 API used local time.
161 161
 			'cart_hash'            => $order->get_cart_hash(),
162 162
 			'line_items'           => array(),
163 163
 			'tax_lines'            => array(),
@@ -168,18 +168,18 @@  discard block
 block discarded – undo
168 168
 		);
169 169
 
170 170
 		// Add addresses.
171
-		$data['billing']  = $order->get_address( 'billing' );
172
-		$data['shipping'] = $order->get_address( 'shipping' );
171
+		$data['billing']  = $order->get_address('billing');
172
+		$data['shipping'] = $order->get_address('shipping');
173 173
 
174 174
 		// Add line items.
175
-		foreach ( $order->get_items() as $item_id => $item ) {
176
-			$product      = $order->get_product_from_item( $item );
175
+		foreach ($order->get_items() as $item_id => $item) {
176
+			$product      = $order->get_product_from_item($item);
177 177
 			$product_id   = 0;
178 178
 			$variation_id = 0;
179 179
 			$product_sku  = null;
180 180
 
181 181
 			// Check if the product exists.
182
-			if ( is_object( $product ) ) {
182
+			if (is_object($product)) {
183 183
 				$product_id   = $item->get_product_id();
184 184
 				$variation_id = $item->get_variation_id();
185 185
 				$product_sku  = $product->get_sku();
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
 
190 190
 			$hideprefix = 'true' === $request['all_item_meta'] ? null : '_';
191 191
 
192
-			foreach ( $item->get_formatted_meta_data( $hideprefix, true ) as $meta_key => $formatted_meta ) {
192
+			foreach ($item->get_formatted_meta_data($hideprefix, true) as $meta_key => $formatted_meta) {
193 193
 				$item_meta[] = array(
194 194
 					'key'   => $formatted_meta->key,
195 195
 					'label' => $formatted_meta->display_key,
196
-					'value' => wc_clean( $formatted_meta->display_value ),
196
+					'value' => wc_clean($formatted_meta->display_value),
197 197
 				);
198 198
 			}
199 199
 
@@ -203,71 +203,71 @@  discard block
 block discarded – undo
203 203
 				'sku'          => $product_sku,
204 204
 				'product_id'   => (int) $product_id,
205 205
 				'variation_id' => (int) $variation_id,
206
-				'quantity'     => wc_stock_amount( $item['qty'] ),
207
-				'tax_class'    => ! empty( $item['tax_class'] ) ? $item['tax_class'] : '',
208
-				'price'        => wc_format_decimal( $order->get_item_total( $item, false, false ), $dp ),
209
-				'subtotal'     => wc_format_decimal( $order->get_line_subtotal( $item, false, false ), $dp ),
210
-				'subtotal_tax' => wc_format_decimal( $item['line_subtotal_tax'], $dp ),
211
-				'total'        => wc_format_decimal( $order->get_line_total( $item, false, false ), $dp ),
212
-				'total_tax'    => wc_format_decimal( $item['line_tax'], $dp ),
206
+				'quantity'     => wc_stock_amount($item['qty']),
207
+				'tax_class'    => ! empty($item['tax_class']) ? $item['tax_class'] : '',
208
+				'price'        => wc_format_decimal($order->get_item_total($item, false, false), $dp),
209
+				'subtotal'     => wc_format_decimal($order->get_line_subtotal($item, false, false), $dp),
210
+				'subtotal_tax' => wc_format_decimal($item['line_subtotal_tax'], $dp),
211
+				'total'        => wc_format_decimal($order->get_line_total($item, false, false), $dp),
212
+				'total_tax'    => wc_format_decimal($item['line_tax'], $dp),
213 213
 				'taxes'        => array(),
214 214
 				'meta'         => $item_meta,
215 215
 			);
216 216
 
217
-			$item_line_taxes = maybe_unserialize( $item['line_tax_data'] );
218
-			if ( isset( $item_line_taxes['total'] ) ) {
217
+			$item_line_taxes = maybe_unserialize($item['line_tax_data']);
218
+			if (isset($item_line_taxes['total'])) {
219 219
 				$line_tax = array();
220 220
 
221
-				foreach ( $item_line_taxes['total'] as $tax_rate_id => $tax ) {
222
-					$line_tax[ $tax_rate_id ] = array(
221
+				foreach ($item_line_taxes['total'] as $tax_rate_id => $tax) {
222
+					$line_tax[$tax_rate_id] = array(
223 223
 						'id'       => $tax_rate_id,
224 224
 						'total'    => $tax,
225 225
 						'subtotal' => '',
226 226
 					);
227 227
 				}
228 228
 
229
-				foreach ( $item_line_taxes['subtotal'] as $tax_rate_id => $tax ) {
230
-					$line_tax[ $tax_rate_id ]['subtotal'] = $tax;
229
+				foreach ($item_line_taxes['subtotal'] as $tax_rate_id => $tax) {
230
+					$line_tax[$tax_rate_id]['subtotal'] = $tax;
231 231
 				}
232 232
 
233
-				$line_item['taxes'] = array_values( $line_tax );
233
+				$line_item['taxes'] = array_values($line_tax);
234 234
 			}
235 235
 
236 236
 			$data['line_items'][] = $line_item;
237 237
 		}
238 238
 
239 239
 		// Add taxes.
240
-		foreach ( $order->get_items( 'tax' ) as $key => $tax ) {
240
+		foreach ($order->get_items('tax') as $key => $tax) {
241 241
 			$tax_line = array(
242 242
 				'id'                 => $key,
243 243
 				'rate_code'          => $tax['name'],
244 244
 				'rate_id'            => $tax['rate_id'],
245
-				'label'              => isset( $tax['label'] ) ? $tax['label'] : $tax['name'],
245
+				'label'              => isset($tax['label']) ? $tax['label'] : $tax['name'],
246 246
 				'compound'           => (bool) $tax['compound'],
247
-				'tax_total'          => wc_format_decimal( $tax['tax_amount'], $dp ),
248
-				'shipping_tax_total' => wc_format_decimal( $tax['shipping_tax_amount'], $dp ),
247
+				'tax_total'          => wc_format_decimal($tax['tax_amount'], $dp),
248
+				'shipping_tax_total' => wc_format_decimal($tax['shipping_tax_amount'], $dp),
249 249
 			);
250 250
 
251 251
 			$data['tax_lines'][] = $tax_line;
252 252
 		}
253 253
 
254 254
 		// Add shipping.
255
-		foreach ( $order->get_shipping_methods() as $shipping_item_id => $shipping_item ) {
255
+		foreach ($order->get_shipping_methods() as $shipping_item_id => $shipping_item) {
256 256
 			$shipping_line = array(
257 257
 				'id'           => $shipping_item_id,
258 258
 				'method_title' => $shipping_item['name'],
259 259
 				'method_id'    => $shipping_item['method_id'],
260
-				'total'        => wc_format_decimal( $shipping_item['cost'], $dp ),
261
-				'total_tax'    => wc_format_decimal( '', $dp ),
260
+				'total'        => wc_format_decimal($shipping_item['cost'], $dp),
261
+				'total_tax'    => wc_format_decimal('', $dp),
262 262
 				'taxes'        => array(),
263 263
 			);
264 264
 
265 265
 			$shipping_taxes = $shipping_item->get_taxes();
266 266
 
267
-			if ( ! empty( $shipping_taxes['total'] ) ) {
268
-				$shipping_line['total_tax'] = wc_format_decimal( array_sum( $shipping_taxes['total'] ), $dp );
267
+			if ( ! empty($shipping_taxes['total'])) {
268
+				$shipping_line['total_tax'] = wc_format_decimal(array_sum($shipping_taxes['total']), $dp);
269 269
 
270
-				foreach ( $shipping_taxes['total'] as $tax_rate_id => $tax ) {
270
+				foreach ($shipping_taxes['total'] as $tax_rate_id => $tax) {
271 271
 					$shipping_line['taxes'][] = array(
272 272
 						'id'       => $tax_rate_id,
273 273
 						'total'    => $tax,
@@ -279,70 +279,70 @@  discard block
 block discarded – undo
279 279
 		}
280 280
 
281 281
 		// Add fees.
282
-		foreach ( $order->get_fees() as $fee_item_id => $fee_item ) {
282
+		foreach ($order->get_fees() as $fee_item_id => $fee_item) {
283 283
 			$fee_line = array(
284 284
 				'id'         => $fee_item_id,
285 285
 				'name'       => $fee_item['name'],
286
-				'tax_class'  => ! empty( $fee_item['tax_class'] ) ? $fee_item['tax_class'] : '',
286
+				'tax_class'  => ! empty($fee_item['tax_class']) ? $fee_item['tax_class'] : '',
287 287
 				'tax_status' => 'taxable',
288
-				'total'      => wc_format_decimal( $order->get_line_total( $fee_item ), $dp ),
289
-				'total_tax'  => wc_format_decimal( $order->get_line_tax( $fee_item ), $dp ),
288
+				'total'      => wc_format_decimal($order->get_line_total($fee_item), $dp),
289
+				'total_tax'  => wc_format_decimal($order->get_line_tax($fee_item), $dp),
290 290
 				'taxes'      => array(),
291 291
 			);
292 292
 
293
-			$fee_line_taxes = maybe_unserialize( $fee_item['line_tax_data'] );
294
-			if ( isset( $fee_line_taxes['total'] ) ) {
293
+			$fee_line_taxes = maybe_unserialize($fee_item['line_tax_data']);
294
+			if (isset($fee_line_taxes['total'])) {
295 295
 				$fee_tax = array();
296 296
 
297
-				foreach ( $fee_line_taxes['total'] as $tax_rate_id => $tax ) {
298
-					$fee_tax[ $tax_rate_id ] = array(
297
+				foreach ($fee_line_taxes['total'] as $tax_rate_id => $tax) {
298
+					$fee_tax[$tax_rate_id] = array(
299 299
 						'id'       => $tax_rate_id,
300 300
 						'total'    => $tax,
301 301
 						'subtotal' => '',
302 302
 					);
303 303
 				}
304 304
 
305
-				if ( isset( $fee_line_taxes['subtotal'] ) ) {
306
-					foreach ( $fee_line_taxes['subtotal'] as $tax_rate_id => $tax ) {
307
-						$fee_tax[ $tax_rate_id ]['subtotal'] = $tax;
305
+				if (isset($fee_line_taxes['subtotal'])) {
306
+					foreach ($fee_line_taxes['subtotal'] as $tax_rate_id => $tax) {
307
+						$fee_tax[$tax_rate_id]['subtotal'] = $tax;
308 308
 					}
309 309
 				}
310 310
 
311
-				$fee_line['taxes'] = array_values( $fee_tax );
311
+				$fee_line['taxes'] = array_values($fee_tax);
312 312
 			}
313 313
 
314 314
 			$data['fee_lines'][] = $fee_line;
315 315
 		}
316 316
 
317 317
 		// Add coupons.
318
-		foreach ( $order->get_items( 'coupon' ) as $coupon_item_id => $coupon_item ) {
318
+		foreach ($order->get_items('coupon') as $coupon_item_id => $coupon_item) {
319 319
 			$coupon_line = array(
320 320
 				'id'           => $coupon_item_id,
321 321
 				'code'         => $coupon_item['name'],
322
-				'discount'     => wc_format_decimal( $coupon_item['discount_amount'], $dp ),
323
-				'discount_tax' => wc_format_decimal( $coupon_item['discount_amount_tax'], $dp ),
322
+				'discount'     => wc_format_decimal($coupon_item['discount_amount'], $dp),
323
+				'discount_tax' => wc_format_decimal($coupon_item['discount_amount_tax'], $dp),
324 324
 			);
325 325
 
326 326
 			$data['coupon_lines'][] = $coupon_line;
327 327
 		}
328 328
 
329 329
 		// Add refunds.
330
-		foreach ( $order->get_refunds() as $refund ) {
330
+		foreach ($order->get_refunds() as $refund) {
331 331
 			$data['refunds'][] = array(
332 332
 				'id'     => $refund->get_id(),
333 333
 				'refund' => $refund->get_reason() ? $refund->get_reason() : '',
334
-				'total'  => '-' . wc_format_decimal( $refund->get_amount(), $dp ),
334
+				'total'  => '-' . wc_format_decimal($refund->get_amount(), $dp),
335 335
 			);
336 336
 		}
337 337
 
338
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
339
-		$data    = $this->add_additional_fields_to_object( $data, $request );
340
-		$data    = $this->filter_response_by_context( $data, $context );
338
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
339
+		$data    = $this->add_additional_fields_to_object($data, $request);
340
+		$data    = $this->filter_response_by_context($data, $context);
341 341
 
342 342
 		// Wrap the data in a response object.
343
-		$response = rest_ensure_response( $data );
343
+		$response = rest_ensure_response($data);
344 344
 
345
-		$response->add_links( $this->prepare_links( $order, $request ) );
345
+		$response->add_links($this->prepare_links($order, $request));
346 346
 
347 347
 		/**
348 348
 		 * Filter the data for a response.
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 		 * @param WP_Post            $post       Post object.
355 355
 		 * @param WP_REST_Request    $request    Request object.
356 356
 		 */
357
-		return apply_filters( "woocommerce_rest_prepare_{$this->post_type}", $response, $post, $request );
357
+		return apply_filters("woocommerce_rest_prepare_{$this->post_type}", $response, $post, $request);
358 358
 	}
359 359
 
360 360
 	/**
@@ -364,23 +364,23 @@  discard block
 block discarded – undo
364 364
 	 * @param WP_REST_Request $request Request object.
365 365
 	 * @return array Links for the given order.
366 366
 	 */
367
-	protected function prepare_links( $order, $request ) {
367
+	protected function prepare_links($order, $request) {
368 368
 		$links = array(
369 369
 			'self' => array(
370
-				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $order->get_id() ) ),
370
+				'href' => rest_url(sprintf('/%s/%s/%d', $this->namespace, $this->rest_base, $order->get_id())),
371 371
 			),
372 372
 			'collection' => array(
373
-				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
373
+				'href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)),
374 374
 			),
375 375
 		);
376
-		if ( 0 !== (int) $order->get_user_id() ) {
376
+		if (0 !== (int) $order->get_user_id()) {
377 377
 			$links['customer'] = array(
378
-				'href' => rest_url( sprintf( '/%s/customers/%d', $this->namespace, $order->get_user_id() ) ),
378
+				'href' => rest_url(sprintf('/%s/customers/%d', $this->namespace, $order->get_user_id())),
379 379
 			);
380 380
 		}
381
-		if ( 0 !== (int) $order->get_parent_id() ) {
381
+		if (0 !== (int) $order->get_parent_id()) {
382 382
 			$links['up'] = array(
383
-				'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $order->get_parent_id() ) ),
383
+				'href' => rest_url(sprintf('/%s/orders/%d', $this->namespace, $order->get_parent_id())),
384 384
 			);
385 385
 		}
386 386
 		return $links;
@@ -393,18 +393,18 @@  discard block
 block discarded – undo
393 393
 	 * @param WP_REST_Request $request
394 394
 	 * @return array
395 395
 	 */
396
-	public function query_args( $args, $request ) {
396
+	public function query_args($args, $request) {
397 397
 		global $wpdb;
398 398
 
399 399
 		// Set post_status.
400
-		if ( 'any' !== $request['status'] ) {
400
+		if ('any' !== $request['status']) {
401 401
 			$args['post_status'] = 'wc-' . $request['status'];
402 402
 		} else {
403 403
 			$args['post_status'] = 'any';
404 404
 		}
405 405
 
406
-		if ( isset( $request['customer'] ) ) {
407
-			if ( ! empty( $args['meta_query'] ) ) {
406
+		if (isset($request['customer'])) {
407
+			if ( ! empty($args['meta_query'])) {
408 408
 				$args['meta_query'] = array();
409 409
 			}
410 410
 
@@ -416,27 +416,27 @@  discard block
 block discarded – undo
416 416
 		}
417 417
 
418 418
 		// Search by product.
419
-		if ( ! empty( $request['product'] ) ) {
420
-			$order_ids = $wpdb->get_col( $wpdb->prepare( "
419
+		if ( ! empty($request['product'])) {
420
+			$order_ids = $wpdb->get_col($wpdb->prepare("
421 421
 				SELECT order_id
422 422
 				FROM {$wpdb->prefix}woocommerce_order_items
423 423
 				WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key = '_product_id' AND meta_value = %d )
424 424
 				AND order_item_type = 'line_item'
425
-			 ", $request['product'] ) );
425
+			 ", $request['product']));
426 426
 
427 427
 			// Force WP_Query return empty if don't found any order.
428
-			$order_ids = ! empty( $order_ids ) ? $order_ids : array( 0 );
428
+			$order_ids = ! empty($order_ids) ? $order_ids : array(0);
429 429
 
430 430
 			$args['post__in'] = $order_ids;
431 431
 		}
432 432
 
433 433
 		// Search.
434
-		if ( ! empty( $args['s'] ) ) {
435
-			$order_ids = wc_order_search( $args['s'] );
434
+		if ( ! empty($args['s'])) {
435
+			$order_ids = wc_order_search($args['s']);
436 436
 
437
-			if ( ! empty( $order_ids ) ) {
438
-				unset( $args['s'] );
439
-				$args['post__in'] = array_merge( $order_ids, array( 0 ) );
437
+			if ( ! empty($order_ids)) {
438
+				unset($args['s']);
439
+				$args['post__in'] = array_merge($order_ids, array(0));
440 440
 			}
441 441
 		}
442 442
 
@@ -449,41 +449,41 @@  discard block
 block discarded – undo
449 449
 	 * @param  WP_REST_Request $request Request object.
450 450
 	 * @return WP_Error|WC_Order $data Object.
451 451
 	 */
452
-	protected function prepare_item_for_database( $request ) {
453
-		$id        = isset( $request['id'] ) ? absint( $request['id'] ) : 0;
454
-		$order     = new WC_Order( $id );
452
+	protected function prepare_item_for_database($request) {
453
+		$id        = isset($request['id']) ? absint($request['id']) : 0;
454
+		$order     = new WC_Order($id);
455 455
 		$schema    = $this->get_item_schema();
456
-		$data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) );
456
+		$data_keys = array_keys(array_filter($schema['properties'], array($this, 'filter_writable_props')));
457 457
 
458 458
 		// Handle all writable props
459
-		foreach ( $data_keys as $key ) {
460
-			$value = $request[ $key ];
459
+		foreach ($data_keys as $key) {
460
+			$value = $request[$key];
461 461
 
462
-			if ( ! is_null( $value ) ) {
463
-				switch ( $key ) {
462
+			if ( ! is_null($value)) {
463
+				switch ($key) {
464 464
 					case 'billing' :
465 465
 					case 'shipping' :
466
-						$this->update_address( $order, $value, $key );
466
+						$this->update_address($order, $value, $key);
467 467
 						break;
468 468
 					case 'line_items' :
469 469
 					case 'shipping_lines' :
470 470
 					case 'fee_lines' :
471 471
 					case 'coupon_lines' :
472
-						if ( is_array( $value ) ) {
473
-							foreach ( $value as $item ) {
474
-								if ( is_array( $item ) ) {
475
-									if ( $this->item_is_null( $item ) || ( isset( $item['quantity'] ) && 0 === $item['quantity'] ) ) {
476
-										$order->remove_item( $item['id'] );
472
+						if (is_array($value)) {
473
+							foreach ($value as $item) {
474
+								if (is_array($item)) {
475
+									if ($this->item_is_null($item) || (isset($item['quantity']) && 0 === $item['quantity'])) {
476
+										$order->remove_item($item['id']);
477 477
 									} else {
478
-										$this->set_item( $order, $key, $item );
478
+										$this->set_item($order, $key, $item);
479 479
 									}
480 480
 								}
481 481
 							}
482 482
 						}
483 483
 						break;
484 484
 					default :
485
-						if ( is_callable( array( $order, "set_{$key}" ) ) ) {
486
-							$order->{"set_{$key}"}( $value );
485
+						if (is_callable(array($order, "set_{$key}"))) {
486
+							$order->{"set_{$key}"}($value);
487 487
 						}
488 488
 						break;
489 489
 				}
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 		 * @param WC_Order           $order      The order object.
500 500
 		 * @param WP_REST_Request    $request    Request object.
501 501
 		 */
502
-		return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}", $order, $request );
502
+		return apply_filters("woocommerce_rest_pre_insert_{$this->post_type}", $order, $request);
503 503
 	}
504 504
 
505 505
 	/**
@@ -508,8 +508,8 @@  discard block
 block discarded – undo
508 508
 	 * @param array $data
509 509
 	 * @return WC_Order
510 510
 	 */
511
-	protected function create_base_order( $data ) {
512
-		return wc_create_order( $data );
511
+	protected function create_base_order($data) {
512
+		return wc_create_order($data);
513 513
 	}
514 514
 
515 515
 	/**
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
 	 * @param  array $schema
518 518
 	 * @return bool
519 519
 	 */
520
-	protected function filter_writable_props( $schema ) {
521
-		return empty( $schema['readonly'] );
520
+	protected function filter_writable_props($schema) {
521
+		return empty($schema['readonly']);
522 522
 	}
523 523
 
524 524
 	/**
@@ -527,34 +527,34 @@  discard block
 block discarded – undo
527 527
 	 * @param WP_REST_Request $request Full details about the request.
528 528
 	 * @return int|WP_Error
529 529
 	 */
530
-	protected function create_order( $request ) {
530
+	protected function create_order($request) {
531 531
 		try {
532 532
 			// Make sure customer exists.
533
-			if ( ! is_null( $request['customer_id'] ) && 0 !== $request['customer_id'] && false === get_user_by( 'id', $request['customer_id'] ) ) {
534
-				throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id',__( 'Customer ID is invalid.', 'woocommerce' ), 400 );
533
+			if ( ! is_null($request['customer_id']) && 0 !== $request['customer_id'] && false === get_user_by('id', $request['customer_id'])) {
534
+				throw new WC_REST_Exception('woocommerce_rest_invalid_customer_id', __('Customer ID is invalid.', 'woocommerce'), 400);
535 535
 			}
536 536
 
537 537
 			// Make sure customer is part of blog.
538
-			if ( is_multisite() && ! is_user_member_of_blog( $request['customer_id'] ) ) {
539
-				add_user_to_blog( get_current_blog_id(), $request['customer_id'], 'customer' );
538
+			if (is_multisite() && ! is_user_member_of_blog($request['customer_id'])) {
539
+				add_user_to_blog(get_current_blog_id(), $request['customer_id'], 'customer');
540 540
 			}
541 541
 
542
-			$order = $this->prepare_item_for_database( $request );
543
-			$order->set_created_via( 'rest-api' );
544
-			$order->set_prices_include_tax( 'yes' === get_option( 'woocommerce_prices_include_tax' ) );
542
+			$order = $this->prepare_item_for_database($request);
543
+			$order->set_created_via('rest-api');
544
+			$order->set_prices_include_tax('yes' === get_option('woocommerce_prices_include_tax'));
545 545
 			$order->calculate_totals();
546 546
 			$order->save();
547 547
 
548 548
 			// Handle set paid.
549
-			if ( true === $request['set_paid'] ) {
550
-				$order->payment_complete( $request['transaction_id'] );
549
+			if (true === $request['set_paid']) {
550
+				$order->payment_complete($request['transaction_id']);
551 551
 			}
552 552
 
553 553
 			return $order->get_id();
554
-		} catch ( WC_Data_Exception $e ) {
555
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
556
-		} catch ( WC_REST_Exception $e ) {
557
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
554
+		} catch (WC_Data_Exception $e) {
555
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), $e->getErrorData());
556
+		} catch (WC_REST_Exception $e) {
557
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
558 558
 		}
559 559
 	}
560 560
 
@@ -564,26 +564,26 @@  discard block
 block discarded – undo
564 564
 	 * @param WP_REST_Request $request Full details about the request.
565 565
 	 * @return int|WP_Error
566 566
 	 */
567
-	protected function update_order( $request ) {
567
+	protected function update_order($request) {
568 568
 		try {
569
-			$order = $this->prepare_item_for_database( $request );
569
+			$order = $this->prepare_item_for_database($request);
570 570
 			$order->save();
571 571
 
572 572
 			// Handle set paid.
573
-			if ( $order->needs_payment() && true === $request['set_paid'] ) {
574
-				$order->payment_complete( $request['transaction_id'] );
573
+			if ($order->needs_payment() && true === $request['set_paid']) {
574
+				$order->payment_complete($request['transaction_id']);
575 575
 			}
576 576
 
577 577
 			// If items have changed, recalculate order totals.
578
-			if ( isset( $request['billing'] ) || isset( $request['shipping'] ) || isset( $request['line_items'] ) || isset( $request['shipping_lines'] ) || isset( $request['fee_lines'] ) || isset( $request['coupon_lines'] ) ) {
579
-				$order->calculate_totals( true );
578
+			if (isset($request['billing']) || isset($request['shipping']) || isset($request['line_items']) || isset($request['shipping_lines']) || isset($request['fee_lines']) || isset($request['coupon_lines'])) {
579
+				$order->calculate_totals(true);
580 580
 			}
581 581
 
582 582
 			return $order->get_id();
583
-		} catch ( WC_Data_Exception $e ) {
584
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
585
-		} catch ( WC_REST_Exception $e ) {
586
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
583
+		} catch (WC_Data_Exception $e) {
584
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), $e->getErrorData());
585
+		} catch (WC_REST_Exception $e) {
586
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
587 587
 		}
588 588
 	}
589 589
 
@@ -594,10 +594,10 @@  discard block
 block discarded – undo
594 594
 	 * @param array $posted
595 595
 	 * @param string $type
596 596
 	 */
597
-	protected function update_address( $order, $posted, $type = 'billing' ) {
598
-		foreach ( $posted as $key => $value ) {
599
-			if ( is_callable( array( $order, "set_{$type}_{$key}" ) ) ) {
600
-				$order->{"set_{$type}_{$key}"}( $value );
597
+	protected function update_address($order, $posted, $type = 'billing') {
598
+		foreach ($posted as $key => $value) {
599
+			if (is_callable(array($order, "set_{$type}_{$key}"))) {
600
+				$order->{"set_{$type}_{$key}"}($value);
601 601
 			}
602 602
 		}
603 603
 	}
@@ -610,15 +610,15 @@  discard block
 block discarded – undo
610 610
 	 * @return int
611 611
 	 * @throws WC_REST_Exception
612 612
 	 */
613
-	protected function get_product_id( $posted ) {
614
-		if ( ! empty( $posted['sku'] ) ) {
615
-			$product_id = (int) wc_get_product_id_by_sku( $posted['sku'] );
616
-		} elseif ( ! empty( $posted['product_id'] ) && empty( $posted['variation_id'] ) ) {
613
+	protected function get_product_id($posted) {
614
+		if ( ! empty($posted['sku'])) {
615
+			$product_id = (int) wc_get_product_id_by_sku($posted['sku']);
616
+		} elseif ( ! empty($posted['product_id']) && empty($posted['variation_id'])) {
617 617
 			$product_id = (int) $posted['product_id'];
618
-		} elseif ( ! empty( $posted['variation_id'] ) ) {
618
+		} elseif ( ! empty($posted['variation_id'])) {
619 619
 			$product_id = (int) $posted['variation_id'];
620 620
 		} else {
621
-			throw new WC_REST_Exception( 'woocommerce_rest_required_product_reference', __( 'Product ID or SKU is required.', 'woocommerce' ), 400 );
621
+			throw new WC_REST_Exception('woocommerce_rest_required_product_reference', __('Product ID or SKU is required.', 'woocommerce'), 400);
622 622
 		}
623 623
 		return $product_id;
624 624
 	}
@@ -629,9 +629,9 @@  discard block
 block discarded – undo
629 629
 	 * @param string $prop
630 630
 	 * @param array $posted Request data.
631 631
 	 */
632
-	protected function maybe_set_item_prop( $item, $prop, $posted ) {
633
-		if ( isset( $posted[ $prop ] ) ) {
634
-			$item->{"set_$prop"}( $posted[ $prop ] );
632
+	protected function maybe_set_item_prop($item, $prop, $posted) {
633
+		if (isset($posted[$prop])) {
634
+			$item->{"set_$prop"}($posted[$prop]);
635 635
 		}
636 636
 	}
637 637
 
@@ -641,9 +641,9 @@  discard block
 block discarded – undo
641 641
 	 * @param string[] $props
642 642
 	 * @param array $posted Request data.
643 643
 	 */
644
-	protected function maybe_set_item_props( $item, $props, $posted ) {
645
-		foreach ( $props as $prop ) {
646
-			$this->maybe_set_item_prop( $item, $prop, $posted );
644
+	protected function maybe_set_item_props($item, $props, $posted) {
645
+		foreach ($props as $prop) {
646
+			$this->maybe_set_item_prop($item, $prop, $posted);
647 647
 		}
648 648
 	}
649 649
 
@@ -656,22 +656,22 @@  discard block
 block discarded – undo
656 656
 	 * @return WC_Order_Item_Product
657 657
 	 * @throws WC_REST_Exception Invalid data, server error.
658 658
 	 */
659
-	protected function prepare_line_items( $posted, $action = 'create' ) {
660
-		$item    = new WC_Order_Item_Product( ! empty( $posted['id'] ) ? $posted['id'] : '' );
661
-		$product = wc_get_product( $this->get_product_id( $posted ) );
662
-
663
-		if ( $product !== $item->get_product() ) {
664
-			$item->set_product( $product );
665
-
666
-			if ( 'create' === $action ) {
667
-				$quantity = isset( $posted['quantity'] ) ? $posted['quantity'] : 1;
668
-				$total    = wc_get_price_excluding_tax( $product, array( 'qty' => $quantity ) );
669
-				$item->set_total( $total );
670
-				$item->set_subtotal( $total );
659
+	protected function prepare_line_items($posted, $action = 'create') {
660
+		$item    = new WC_Order_Item_Product( ! empty($posted['id']) ? $posted['id'] : '');
661
+		$product = wc_get_product($this->get_product_id($posted));
662
+
663
+		if ($product !== $item->get_product()) {
664
+			$item->set_product($product);
665
+
666
+			if ('create' === $action) {
667
+				$quantity = isset($posted['quantity']) ? $posted['quantity'] : 1;
668
+				$total    = wc_get_price_excluding_tax($product, array('qty' => $quantity));
669
+				$item->set_total($total);
670
+				$item->set_subtotal($total);
671 671
 			}
672 672
 		}
673 673
 
674
-		$this->maybe_set_item_props( $item, array( 'name', 'quantity', 'total', 'subtotal', 'tax_class' ), $posted );
674
+		$this->maybe_set_item_props($item, array('name', 'quantity', 'total', 'subtotal', 'tax_class'), $posted);
675 675
 
676 676
 		return $item;
677 677
 	}
@@ -685,16 +685,16 @@  discard block
 block discarded – undo
685 685
 	 * @return WC_Order_Item_Shipping
686 686
 	 * @throws WC_REST_Exception Invalid data, server error.
687 687
 	 */
688
-	protected function prepare_shipping_lines( $posted, $action ) {
689
-		$item = new WC_Order_Item_Shipping( ! empty( $posted['id'] ) ? $posted['id'] : '' );
688
+	protected function prepare_shipping_lines($posted, $action) {
689
+		$item = new WC_Order_Item_Shipping( ! empty($posted['id']) ? $posted['id'] : '');
690 690
 
691
-		if ( 'create' === $action ) {
692
-			if ( empty( $posted['method_id'] ) ) {
693
-				throw new WC_REST_Exception( 'woocommerce_rest_invalid_shipping_item', __( 'Shipping method ID is required.', 'woocommerce' ), 400 );
691
+		if ('create' === $action) {
692
+			if (empty($posted['method_id'])) {
693
+				throw new WC_REST_Exception('woocommerce_rest_invalid_shipping_item', __('Shipping method ID is required.', 'woocommerce'), 400);
694 694
 			}
695 695
 		}
696 696
 
697
-		$this->maybe_set_item_props( $item, array( 'method_id', 'method_title', 'total' ), $posted );
697
+		$this->maybe_set_item_props($item, array('method_id', 'method_title', 'total'), $posted);
698 698
 
699 699
 		return $item;
700 700
 	}
@@ -708,16 +708,16 @@  discard block
 block discarded – undo
708 708
 	 * @return WC_Order_Item_Fee
709 709
 	 * @throws WC_REST_Exception Invalid data, server error.
710 710
 	 */
711
-	protected function prepare_fee_lines( $posted, $action ) {
712
-		$item = new WC_Order_Item_Fee( ! empty( $posted['id'] ) ? $posted['id'] : '' );
711
+	protected function prepare_fee_lines($posted, $action) {
712
+		$item = new WC_Order_Item_Fee( ! empty($posted['id']) ? $posted['id'] : '');
713 713
 
714
-		if ( 'create' === $action ) {
715
-			if ( empty( $posted['name'] ) ) {
716
-				throw new WC_REST_Exception( 'woocommerce_rest_invalid_fee_item', __( 'Fee name is required.', 'woocommerce' ), 400 );
714
+		if ('create' === $action) {
715
+			if (empty($posted['name'])) {
716
+				throw new WC_REST_Exception('woocommerce_rest_invalid_fee_item', __('Fee name is required.', 'woocommerce'), 400);
717 717
 			}
718 718
 		}
719 719
 
720
-		$this->maybe_set_item_props( $item, array( 'name', 'tax_class', 'tax_status', 'total' ), $posted );
720
+		$this->maybe_set_item_props($item, array('name', 'tax_class', 'tax_status', 'total'), $posted);
721 721
 
722 722
 		return $item;
723 723
 	}
@@ -731,16 +731,16 @@  discard block
 block discarded – undo
731 731
 	 * @return WC_Order_Item_Coupon
732 732
 	 * @throws WC_REST_Exception Invalid data, server error.
733 733
 	 */
734
-	protected function prepare_coupon_lines( $posted, $action ) {
735
-		$item = new WC_Order_Item_Coupon( ! empty( $posted['id'] ) ? $posted['id'] : '' );
734
+	protected function prepare_coupon_lines($posted, $action) {
735
+		$item = new WC_Order_Item_Coupon( ! empty($posted['id']) ? $posted['id'] : '');
736 736
 
737
-		if ( 'create' === $action ) {
738
-			if ( empty( $posted['code'] ) ) {
739
-				throw new WC_REST_Exception( 'woocommerce_rest_invalid_coupon_coupon', __( 'Coupon code is required.', 'woocommerce' ), 400 );
737
+		if ('create' === $action) {
738
+			if (empty($posted['code'])) {
739
+				throw new WC_REST_Exception('woocommerce_rest_invalid_coupon_coupon', __('Coupon code is required.', 'woocommerce'), 400);
740 740
 			}
741 741
 		}
742 742
 
743
-		$this->maybe_set_item_props( $item, array( 'code', 'discount' ), $posted );
743
+		$this->maybe_set_item_props($item, array('code', 'discount'), $posted);
744 744
 
745 745
 		return $item;
746 746
 	}
@@ -755,10 +755,10 @@  discard block
 block discarded – undo
755 755
 	 * @param array $posted item provided in the request body
756 756
 	 * @throws WC_REST_Exception If item ID is not associated with order
757 757
 	 */
758
-	protected function set_item( $order, $item_type, $posted ) {
758
+	protected function set_item($order, $item_type, $posted) {
759 759
 		global $wpdb;
760 760
 
761
-		if ( ! empty( $posted['id'] ) ) {
761
+		if ( ! empty($posted['id'])) {
762 762
 			$action = 'update';
763 763
 		} else {
764 764
 			$action = 'create';
@@ -767,29 +767,29 @@  discard block
 block discarded – undo
767 767
 		$method = 'prepare_' . $item_type;
768 768
 
769 769
 		// Verify provided line item ID is associated with order.
770
-		if ( 'update' === $action ) {
770
+		if ('update' === $action) {
771 771
 			$result = $wpdb->get_row(
772
-				$wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d AND order_id = %d",
773
-				absint( $posted['id'] ),
774
-				absint( $order->get_id() )
772
+				$wpdb->prepare("SELECT * FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d AND order_id = %d",
773
+				absint($posted['id']),
774
+				absint($order->get_id())
775 775
 			) );
776
-			if ( is_null( $result ) ) {
777
-				throw new WC_REST_Exception( 'woocommerce_rest_invalid_item_id', __( 'Order item ID provided is not associated with order.', 'woocommerce' ), 400 );
776
+			if (is_null($result)) {
777
+				throw new WC_REST_Exception('woocommerce_rest_invalid_item_id', __('Order item ID provided is not associated with order.', 'woocommerce'), 400);
778 778
 			}
779 779
 		}
780 780
 
781 781
 		// Prepare item data
782
-		$item = $this->$method( $posted, $action );
782
+		$item = $this->$method($posted, $action);
783 783
 
784 784
 		/**
785 785
 		 * Action hook to adjust item before save.
786 786
 		 * @since 3.0.0
787 787
 		 */
788
-		do_action( 'woocommerce_rest_set_order_item', $item, $posted );
788
+		do_action('woocommerce_rest_set_order_item', $item, $posted);
789 789
 
790 790
 		// Save or add to order
791
-		if ( 'create' === $action ) {
792
-			$order->add_item( $item );
791
+		if ('create' === $action) {
792
+			$order->add_item($item);
793 793
 		} else {
794 794
 			$item->save();
795 795
 		}
@@ -802,11 +802,11 @@  discard block
 block discarded – undo
802 802
 	 * @param array $item Item provided in the request body.
803 803
 	 * @return bool True if the item resource ID is null, false otherwise.
804 804
 	 */
805
-	protected function item_is_null( $item ) {
806
-		$keys = array( 'product_id', 'method_id', 'method_title', 'name', 'code' );
805
+	protected function item_is_null($item) {
806
+		$keys = array('product_id', 'method_id', 'method_title', 'name', 'code');
807 807
 
808
-		foreach ( $keys as $key ) {
809
-			if ( array_key_exists( $key, $item ) && is_null( $item[ $key ] ) ) {
808
+		foreach ($keys as $key) {
809
+			if (array_key_exists($key, $item) && is_null($item[$key])) {
810 810
 				return true;
811 811
 			}
812 812
 		}
@@ -820,19 +820,19 @@  discard block
 block discarded – undo
820 820
 	 * @param WP_REST_Request $request Full details about the request.
821 821
 	 * @return WP_Error|WP_REST_Response
822 822
 	 */
823
-	public function create_item( $request ) {
824
-		if ( ! empty( $request['id'] ) ) {
823
+	public function create_item($request) {
824
+		if ( ! empty($request['id'])) {
825 825
 			/* translators: %s: post type */
826
-			return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
826
+			return new WP_Error("woocommerce_rest_{$this->post_type}_exists", sprintf(__('Cannot create existing %s.', 'woocommerce'), $this->post_type), array('status' => 400));
827 827
 		}
828 828
 
829
-		$order_id = $this->create_order( $request );
830
-		if ( is_wp_error( $order_id ) ) {
829
+		$order_id = $this->create_order($request);
830
+		if (is_wp_error($order_id)) {
831 831
 			return $order_id;
832 832
 		}
833 833
 
834
-		$post = get_post( $order_id );
835
-		$this->update_additional_fields_for_object( $post, $request );
834
+		$post = get_post($order_id);
835
+		$this->update_additional_fields_for_object($post, $request);
836 836
 
837 837
 		/**
838 838
 		 * Fires after a single item is created or updated via the REST API.
@@ -841,12 +841,12 @@  discard block
 block discarded – undo
841 841
 		 * @param WP_REST_Request $request   Request object.
842 842
 		 * @param boolean         $creating  True when creating item, false when updating.
843 843
 		 */
844
-		do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, true );
845
-		$request->set_param( 'context', 'edit' );
846
-		$response = $this->prepare_item_for_response( $post, $request );
847
-		$response = rest_ensure_response( $response );
848
-		$response->set_status( 201 );
849
-		$response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $post->ID ) ) );
844
+		do_action("woocommerce_rest_insert_{$this->post_type}", $post, $request, true);
845
+		$request->set_param('context', 'edit');
846
+		$response = $this->prepare_item_for_response($post, $request);
847
+		$response = rest_ensure_response($response);
848
+		$response->set_status(201);
849
+		$response->header('Location', rest_url(sprintf('/%s/%s/%d', $this->namespace, $this->rest_base, $post->ID)));
850 850
 
851 851
 		return $response;
852 852
 	}
@@ -857,21 +857,21 @@  discard block
 block discarded – undo
857 857
 	 * @param WP_REST_Request $request Full details about the request.
858 858
 	 * @return WP_Error|WP_REST_Response
859 859
 	 */
860
-	public function update_item( $request ) {
860
+	public function update_item($request) {
861 861
 		try {
862 862
 			$post_id = (int) $request['id'];
863 863
 
864
-			if ( empty( $post_id ) || get_post_type( $post_id ) !== $this->post_type ) {
865
-				return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
864
+			if (empty($post_id) || get_post_type($post_id) !== $this->post_type) {
865
+				return new WP_Error("woocommerce_rest_{$this->post_type}_invalid_id", __('ID is invalid.', 'woocommerce'), array('status' => 400));
866 866
 			}
867 867
 
868
-			$order_id = $this->update_order( $request );
869
-			if ( is_wp_error( $order_id ) ) {
868
+			$order_id = $this->update_order($request);
869
+			if (is_wp_error($order_id)) {
870 870
 				return $order_id;
871 871
 			}
872 872
 
873
-			$post = get_post( $order_id );
874
-			$this->update_additional_fields_for_object( $post, $request );
873
+			$post = get_post($order_id);
874
+			$this->update_additional_fields_for_object($post, $request);
875 875
 
876 876
 			/**
877 877
 			 * Fires after a single item is created or updated via the REST API.
@@ -880,13 +880,13 @@  discard block
 block discarded – undo
880 880
 			 * @param WP_REST_Request $request   Request object.
881 881
 			 * @param boolean         $creating  True when creating item, false when updating.
882 882
 			 */
883
-			do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, false );
884
-			$request->set_param( 'context', 'edit' );
885
-			$response = $this->prepare_item_for_response( $post, $request );
886
-			return rest_ensure_response( $response );
883
+			do_action("woocommerce_rest_insert_{$this->post_type}", $post, $request, false);
884
+			$request->set_param('context', 'edit');
885
+			$response = $this->prepare_item_for_response($post, $request);
886
+			return rest_ensure_response($response);
887 887
 
888
-		} catch ( Exception $e ) {
889
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
888
+		} catch (Exception $e) {
889
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
890 890
 		}
891 891
 	}
892 892
 
@@ -897,8 +897,8 @@  discard block
 block discarded – undo
897 897
 	protected function get_order_statuses() {
898 898
 		$order_statuses = array();
899 899
 
900
-		foreach ( array_keys( wc_get_order_statuses() ) as $status ) {
901
-			$order_statuses[] = str_replace( 'wc-', '', $status );
900
+		foreach (array_keys(wc_get_order_statuses()) as $status) {
901
+			$order_statuses[] = str_replace('wc-', '', $status);
902 902
 		}
903 903
 
904 904
 		return $order_statuses;
@@ -916,419 +916,419 @@  discard block
 block discarded – undo
916 916
 			'type'       => 'object',
917 917
 			'properties' => array(
918 918
 				'id' => array(
919
-					'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
919
+					'description' => __('Unique identifier for the resource.', 'woocommerce'),
920 920
 					'type'        => 'integer',
921
-					'context'     => array( 'view', 'edit' ),
921
+					'context'     => array('view', 'edit'),
922 922
 					'readonly'    => true,
923 923
 				),
924 924
 				'parent_id' => array(
925
-					'description' => __( 'Parent order ID.', 'woocommerce' ),
925
+					'description' => __('Parent order ID.', 'woocommerce'),
926 926
 					'type'        => 'integer',
927
-					'context'     => array( 'view', 'edit' ),
927
+					'context'     => array('view', 'edit'),
928 928
 				),
929 929
 				'status' => array(
930
-					'description' => __( 'Order status.', 'woocommerce' ),
930
+					'description' => __('Order status.', 'woocommerce'),
931 931
 					'type'        => 'string',
932 932
 					'default'     => 'pending',
933 933
 					'enum'        => $this->get_order_statuses(),
934
-					'context'     => array( 'view', 'edit' ),
934
+					'context'     => array('view', 'edit'),
935 935
 				),
936 936
 				'order_key' => array(
937
-					'description' => __( 'Order key.', 'woocommerce' ),
937
+					'description' => __('Order key.', 'woocommerce'),
938 938
 					'type'        => 'string',
939
-					'context'     => array( 'view', 'edit' ),
939
+					'context'     => array('view', 'edit'),
940 940
 					'readonly'    => true,
941 941
 				),
942 942
 				'number' => array(
943
-					'description' => __( 'Order number.', 'woocommerce' ),
943
+					'description' => __('Order number.', 'woocommerce'),
944 944
 					'type'        => 'string',
945
-					'context'     => array( 'view', 'edit' ),
945
+					'context'     => array('view', 'edit'),
946 946
 					'readonly'    => true,
947 947
 				),
948 948
 				'currency' => array(
949
-					'description' => __( 'Currency the order was created with, in ISO format.', 'woocommerce' ),
949
+					'description' => __('Currency the order was created with, in ISO format.', 'woocommerce'),
950 950
 					'type'        => 'string',
951 951
 					'default'     => get_woocommerce_currency(),
952
-					'enum'        => array_keys( get_woocommerce_currencies() ),
953
-					'context'     => array( 'view', 'edit' ),
952
+					'enum'        => array_keys(get_woocommerce_currencies()),
953
+					'context'     => array('view', 'edit'),
954 954
 				),
955 955
 				'version' => array(
956
-					'description' => __( 'Version of WooCommerce which last updated the order.', 'woocommerce' ),
956
+					'description' => __('Version of WooCommerce which last updated the order.', 'woocommerce'),
957 957
 					'type'        => 'integer',
958
-					'context'     => array( 'view', 'edit' ),
958
+					'context'     => array('view', 'edit'),
959 959
 					'readonly'    => true,
960 960
 				),
961 961
 				'prices_include_tax' => array(
962
-					'description' => __( 'True the prices included tax during checkout.', 'woocommerce' ),
962
+					'description' => __('True the prices included tax during checkout.', 'woocommerce'),
963 963
 					'type'        => 'boolean',
964
-					'context'     => array( 'view', 'edit' ),
964
+					'context'     => array('view', 'edit'),
965 965
 					'readonly'    => true,
966 966
 				),
967 967
 				'date_created' => array(
968
-					'description' => __( "The date the order was created, as GMT.", 'woocommerce' ),
968
+					'description' => __("The date the order was created, as GMT.", 'woocommerce'),
969 969
 					'type'        => 'date-time',
970
-					'context'     => array( 'view', 'edit' ),
970
+					'context'     => array('view', 'edit'),
971 971
 					'readonly'    => true,
972 972
 				),
973 973
 				'date_modified' => array(
974
-					'description' => __( "The date the order was last modified, as GMT.", 'woocommerce' ),
974
+					'description' => __("The date the order was last modified, as GMT.", 'woocommerce'),
975 975
 					'type'        => 'date-time',
976
-					'context'     => array( 'view', 'edit' ),
976
+					'context'     => array('view', 'edit'),
977 977
 					'readonly'    => true,
978 978
 				),
979 979
 				'customer_id' => array(
980
-					'description' => __( 'User ID who owns the order. 0 for guests.', 'woocommerce' ),
980
+					'description' => __('User ID who owns the order. 0 for guests.', 'woocommerce'),
981 981
 					'type'        => 'integer',
982 982
 					'default'     => 0,
983
-					'context'     => array( 'view', 'edit' ),
983
+					'context'     => array('view', 'edit'),
984 984
 				),
985 985
 				'discount_total' => array(
986
-					'description' => __( 'Total discount amount for the order.', 'woocommerce' ),
986
+					'description' => __('Total discount amount for the order.', 'woocommerce'),
987 987
 					'type'        => 'string',
988
-					'context'     => array( 'view', 'edit' ),
988
+					'context'     => array('view', 'edit'),
989 989
 					'readonly'    => true,
990 990
 				),
991 991
 				'discount_tax' => array(
992
-					'description' => __( 'Total discount tax amount for the order.', 'woocommerce' ),
992
+					'description' => __('Total discount tax amount for the order.', 'woocommerce'),
993 993
 					'type'        => 'string',
994
-					'context'     => array( 'view', 'edit' ),
994
+					'context'     => array('view', 'edit'),
995 995
 					'readonly'    => true,
996 996
 				),
997 997
 				'shipping_total' => array(
998
-					'description' => __( 'Total shipping amount for the order.', 'woocommerce' ),
998
+					'description' => __('Total shipping amount for the order.', 'woocommerce'),
999 999
 					'type'        => 'string',
1000
-					'context'     => array( 'view', 'edit' ),
1000
+					'context'     => array('view', 'edit'),
1001 1001
 					'readonly'    => true,
1002 1002
 				),
1003 1003
 				'shipping_tax' => array(
1004
-					'description' => __( 'Total shipping tax amount for the order.', 'woocommerce' ),
1004
+					'description' => __('Total shipping tax amount for the order.', 'woocommerce'),
1005 1005
 					'type'        => 'string',
1006
-					'context'     => array( 'view', 'edit' ),
1006
+					'context'     => array('view', 'edit'),
1007 1007
 					'readonly'    => true,
1008 1008
 				),
1009 1009
 				'cart_tax' => array(
1010
-					'description' => __( 'Sum of line item taxes only.', 'woocommerce' ),
1010
+					'description' => __('Sum of line item taxes only.', 'woocommerce'),
1011 1011
 					'type'        => 'string',
1012
-					'context'     => array( 'view', 'edit' ),
1012
+					'context'     => array('view', 'edit'),
1013 1013
 					'readonly'    => true,
1014 1014
 				),
1015 1015
 				'total' => array(
1016
-					'description' => __( 'Grand total.', 'woocommerce' ),
1016
+					'description' => __('Grand total.', 'woocommerce'),
1017 1017
 					'type'        => 'string',
1018
-					'context'     => array( 'view', 'edit' ),
1018
+					'context'     => array('view', 'edit'),
1019 1019
 					'readonly'    => true,
1020 1020
 				),
1021 1021
 				'total_tax' => array(
1022
-					'description' => __( 'Sum of all taxes.', 'woocommerce' ),
1022
+					'description' => __('Sum of all taxes.', 'woocommerce'),
1023 1023
 					'type'        => 'string',
1024
-					'context'     => array( 'view', 'edit' ),
1024
+					'context'     => array('view', 'edit'),
1025 1025
 					'readonly'    => true,
1026 1026
 				),
1027 1027
 				'billing' => array(
1028
-					'description' => __( 'Billing address.', 'woocommerce' ),
1028
+					'description' => __('Billing address.', 'woocommerce'),
1029 1029
 					'type'        => 'object',
1030
-					'context'     => array( 'view', 'edit' ),
1030
+					'context'     => array('view', 'edit'),
1031 1031
 					'properties'  => array(
1032 1032
 						'first_name' => array(
1033
-							'description' => __( 'First name.', 'woocommerce' ),
1033
+							'description' => __('First name.', 'woocommerce'),
1034 1034
 							'type'        => 'string',
1035
-							'context'     => array( 'view', 'edit' ),
1035
+							'context'     => array('view', 'edit'),
1036 1036
 						),
1037 1037
 						'last_name' => array(
1038
-							'description' => __( 'Last name.', 'woocommerce' ),
1038
+							'description' => __('Last name.', 'woocommerce'),
1039 1039
 							'type'        => 'string',
1040
-							'context'     => array( 'view', 'edit' ),
1040
+							'context'     => array('view', 'edit'),
1041 1041
 						),
1042 1042
 						'company' => array(
1043
-							'description' => __( 'Company name.', 'woocommerce' ),
1043
+							'description' => __('Company name.', 'woocommerce'),
1044 1044
 							'type'        => 'string',
1045
-							'context'     => array( 'view', 'edit' ),
1045
+							'context'     => array('view', 'edit'),
1046 1046
 						),
1047 1047
 						'address_1' => array(
1048
-							'description' => __( 'Address line 1.', 'woocommerce' ),
1048
+							'description' => __('Address line 1.', 'woocommerce'),
1049 1049
 							'type'        => 'string',
1050
-							'context'     => array( 'view', 'edit' ),
1050
+							'context'     => array('view', 'edit'),
1051 1051
 						),
1052 1052
 						'address_2' => array(
1053
-							'description' => __( 'Address line 2.', 'woocommerce' ),
1053
+							'description' => __('Address line 2.', 'woocommerce'),
1054 1054
 							'type'        => 'string',
1055
-							'context'     => array( 'view', 'edit' ),
1055
+							'context'     => array('view', 'edit'),
1056 1056
 						),
1057 1057
 						'city' => array(
1058
-							'description' => __( 'City name.', 'woocommerce' ),
1058
+							'description' => __('City name.', 'woocommerce'),
1059 1059
 							'type'        => 'string',
1060
-							'context'     => array( 'view', 'edit' ),
1060
+							'context'     => array('view', 'edit'),
1061 1061
 						),
1062 1062
 						'state' => array(
1063
-							'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
1063
+							'description' => __('ISO code or name of the state, province or district.', 'woocommerce'),
1064 1064
 							'type'        => 'string',
1065
-							'context'     => array( 'view', 'edit' ),
1065
+							'context'     => array('view', 'edit'),
1066 1066
 						),
1067 1067
 						'postcode' => array(
1068
-							'description' => __( 'Postal code.', 'woocommerce' ),
1068
+							'description' => __('Postal code.', 'woocommerce'),
1069 1069
 							'type'        => 'string',
1070
-							'context'     => array( 'view', 'edit' ),
1070
+							'context'     => array('view', 'edit'),
1071 1071
 						),
1072 1072
 						'country' => array(
1073
-							'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ),
1073
+							'description' => __('Country code in ISO 3166-1 alpha-2 format.', 'woocommerce'),
1074 1074
 							'type'        => 'string',
1075
-							'context'     => array( 'view', 'edit' ),
1075
+							'context'     => array('view', 'edit'),
1076 1076
 						),
1077 1077
 						'email' => array(
1078
-							'description' => __( 'Email address.', 'woocommerce' ),
1078
+							'description' => __('Email address.', 'woocommerce'),
1079 1079
 							'type'        => 'string',
1080 1080
 							'format'      => 'email',
1081
-							'context'     => array( 'view', 'edit' ),
1081
+							'context'     => array('view', 'edit'),
1082 1082
 						),
1083 1083
 						'phone' => array(
1084
-							'description' => __( 'Phone number.', 'woocommerce' ),
1084
+							'description' => __('Phone number.', 'woocommerce'),
1085 1085
 							'type'        => 'string',
1086
-							'context'     => array( 'view', 'edit' ),
1086
+							'context'     => array('view', 'edit'),
1087 1087
 						),
1088 1088
 					),
1089 1089
 				),
1090 1090
 				'shipping' => array(
1091
-					'description' => __( 'Shipping address.', 'woocommerce' ),
1091
+					'description' => __('Shipping address.', 'woocommerce'),
1092 1092
 					'type'        => 'object',
1093
-					'context'     => array( 'view', 'edit' ),
1093
+					'context'     => array('view', 'edit'),
1094 1094
 					'properties'  => array(
1095 1095
 						'first_name' => array(
1096
-							'description' => __( 'First name.', 'woocommerce' ),
1096
+							'description' => __('First name.', 'woocommerce'),
1097 1097
 							'type'        => 'string',
1098
-							'context'     => array( 'view', 'edit' ),
1098
+							'context'     => array('view', 'edit'),
1099 1099
 						),
1100 1100
 						'last_name' => array(
1101
-							'description' => __( 'Last name.', 'woocommerce' ),
1101
+							'description' => __('Last name.', 'woocommerce'),
1102 1102
 							'type'        => 'string',
1103
-							'context'     => array( 'view', 'edit' ),
1103
+							'context'     => array('view', 'edit'),
1104 1104
 						),
1105 1105
 						'company' => array(
1106
-							'description' => __( 'Company name.', 'woocommerce' ),
1106
+							'description' => __('Company name.', 'woocommerce'),
1107 1107
 							'type'        => 'string',
1108
-							'context'     => array( 'view', 'edit' ),
1108
+							'context'     => array('view', 'edit'),
1109 1109
 						),
1110 1110
 						'address_1' => array(
1111
-							'description' => __( 'Address line 1.', 'woocommerce' ),
1111
+							'description' => __('Address line 1.', 'woocommerce'),
1112 1112
 							'type'        => 'string',
1113
-							'context'     => array( 'view', 'edit' ),
1113
+							'context'     => array('view', 'edit'),
1114 1114
 						),
1115 1115
 						'address_2' => array(
1116
-							'description' => __( 'Address line 2.', 'woocommerce' ),
1116
+							'description' => __('Address line 2.', 'woocommerce'),
1117 1117
 							'type'        => 'string',
1118
-							'context'     => array( 'view', 'edit' ),
1118
+							'context'     => array('view', 'edit'),
1119 1119
 						),
1120 1120
 						'city' => array(
1121
-							'description' => __( 'City name.', 'woocommerce' ),
1121
+							'description' => __('City name.', 'woocommerce'),
1122 1122
 							'type'        => 'string',
1123
-							'context'     => array( 'view', 'edit' ),
1123
+							'context'     => array('view', 'edit'),
1124 1124
 						),
1125 1125
 						'state' => array(
1126
-							'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
1126
+							'description' => __('ISO code or name of the state, province or district.', 'woocommerce'),
1127 1127
 							'type'        => 'string',
1128
-							'context'     => array( 'view', 'edit' ),
1128
+							'context'     => array('view', 'edit'),
1129 1129
 						),
1130 1130
 						'postcode' => array(
1131
-							'description' => __( 'Postal code.', 'woocommerce' ),
1131
+							'description' => __('Postal code.', 'woocommerce'),
1132 1132
 							'type'        => 'string',
1133
-							'context'     => array( 'view', 'edit' ),
1133
+							'context'     => array('view', 'edit'),
1134 1134
 						),
1135 1135
 						'country' => array(
1136
-							'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ),
1136
+							'description' => __('Country code in ISO 3166-1 alpha-2 format.', 'woocommerce'),
1137 1137
 							'type'        => 'string',
1138
-							'context'     => array( 'view', 'edit' ),
1138
+							'context'     => array('view', 'edit'),
1139 1139
 						),
1140 1140
 					),
1141 1141
 				),
1142 1142
 				'payment_method' => array(
1143
-					'description' => __( 'Payment method ID.', 'woocommerce' ),
1143
+					'description' => __('Payment method ID.', 'woocommerce'),
1144 1144
 					'type'        => 'string',
1145
-					'context'     => array( 'view', 'edit' ),
1145
+					'context'     => array('view', 'edit'),
1146 1146
 				),
1147 1147
 				'payment_method_title' => array(
1148
-					'description' => __( 'Payment method title.', 'woocommerce' ),
1148
+					'description' => __('Payment method title.', 'woocommerce'),
1149 1149
 					'type'        => 'string',
1150
-					'context'     => array( 'view', 'edit' ),
1150
+					'context'     => array('view', 'edit'),
1151 1151
 					'arg_options' => array(
1152 1152
 						'sanitize_callback' => 'sanitize_text_field',
1153 1153
 					),
1154 1154
 				),
1155 1155
 				'set_paid' => array(
1156
-					'description' => __( 'Define if the order is paid. It will set the status to processing and reduce stock items.', 'woocommerce' ),
1156
+					'description' => __('Define if the order is paid. It will set the status to processing and reduce stock items.', 'woocommerce'),
1157 1157
 					'type'        => 'boolean',
1158 1158
 					'default'     => false,
1159
-					'context'     => array( 'edit' ),
1159
+					'context'     => array('edit'),
1160 1160
 				),
1161 1161
 				'transaction_id' => array(
1162
-					'description' => __( 'Unique transaction ID.', 'woocommerce' ),
1162
+					'description' => __('Unique transaction ID.', 'woocommerce'),
1163 1163
 					'type'        => 'string',
1164
-					'context'     => array( 'view', 'edit' ),
1164
+					'context'     => array('view', 'edit'),
1165 1165
 				),
1166 1166
 				'customer_ip_address' => array(
1167
-					'description' => __( "Customer's IP address.", 'woocommerce' ),
1167
+					'description' => __("Customer's IP address.", 'woocommerce'),
1168 1168
 					'type'        => 'string',
1169
-					'context'     => array( 'view', 'edit' ),
1169
+					'context'     => array('view', 'edit'),
1170 1170
 					'readonly'    => true,
1171 1171
 				),
1172 1172
 				'customer_user_agent' => array(
1173
-					'description' => __( 'User agent of the customer.', 'woocommerce' ),
1173
+					'description' => __('User agent of the customer.', 'woocommerce'),
1174 1174
 					'type'        => 'string',
1175
-					'context'     => array( 'view', 'edit' ),
1175
+					'context'     => array('view', 'edit'),
1176 1176
 					'readonly'    => true,
1177 1177
 				),
1178 1178
 				'created_via' => array(
1179
-					'description' => __( 'Shows where the order was created.', 'woocommerce' ),
1179
+					'description' => __('Shows where the order was created.', 'woocommerce'),
1180 1180
 					'type'        => 'string',
1181
-					'context'     => array( 'view', 'edit' ),
1181
+					'context'     => array('view', 'edit'),
1182 1182
 					'readonly'    => true,
1183 1183
 				),
1184 1184
 				'customer_note' => array(
1185
-					'description' => __( 'Note left by customer during checkout.', 'woocommerce' ),
1185
+					'description' => __('Note left by customer during checkout.', 'woocommerce'),
1186 1186
 					'type'        => 'string',
1187
-					'context'     => array( 'view', 'edit' ),
1187
+					'context'     => array('view', 'edit'),
1188 1188
 				),
1189 1189
 				'date_completed' => array(
1190
-					'description' => __( "The date the order was completed, in the site's timezone.", 'woocommerce' ),
1190
+					'description' => __("The date the order was completed, in the site's timezone.", 'woocommerce'),
1191 1191
 					'type'        => 'date-time',
1192
-					'context'     => array( 'view', 'edit' ),
1192
+					'context'     => array('view', 'edit'),
1193 1193
 					'readonly'    => true,
1194 1194
 				),
1195 1195
 				'date_paid' => array(
1196
-					'description' => __( "The date the order was paid, in the site's timezone.", 'woocommerce' ),
1196
+					'description' => __("The date the order was paid, in the site's timezone.", 'woocommerce'),
1197 1197
 					'type'        => 'date-time',
1198
-					'context'     => array( 'view', 'edit' ),
1198
+					'context'     => array('view', 'edit'),
1199 1199
 					'readonly'    => true,
1200 1200
 				),
1201 1201
 				'cart_hash' => array(
1202
-					'description' => __( 'MD5 hash of cart items to ensure orders are not modified.', 'woocommerce' ),
1202
+					'description' => __('MD5 hash of cart items to ensure orders are not modified.', 'woocommerce'),
1203 1203
 					'type'        => 'string',
1204
-					'context'     => array( 'view', 'edit' ),
1204
+					'context'     => array('view', 'edit'),
1205 1205
 					'readonly'    => true,
1206 1206
 				),
1207 1207
 				'line_items' => array(
1208
-					'description' => __( 'Line items data.', 'woocommerce' ),
1208
+					'description' => __('Line items data.', 'woocommerce'),
1209 1209
 					'type'        => 'array',
1210
-					'context'     => array( 'view', 'edit' ),
1210
+					'context'     => array('view', 'edit'),
1211 1211
 					'items'       => array(
1212 1212
 						'type'       => 'object',
1213 1213
 						'properties' => array(
1214 1214
 							'id' => array(
1215
-								'description' => __( 'Item ID.', 'woocommerce' ),
1215
+								'description' => __('Item ID.', 'woocommerce'),
1216 1216
 								'type'        => 'integer',
1217
-								'context'     => array( 'view', 'edit' ),
1217
+								'context'     => array('view', 'edit'),
1218 1218
 								'readonly'    => true,
1219 1219
 							),
1220 1220
 							'name' => array(
1221
-								'description' => __( 'Product name.', 'woocommerce' ),
1221
+								'description' => __('Product name.', 'woocommerce'),
1222 1222
 								'type'        => 'mixed',
1223
-								'context'     => array( 'view', 'edit' ),
1223
+								'context'     => array('view', 'edit'),
1224 1224
 								'readonly'    => true,
1225 1225
 							),
1226 1226
 							'sku' => array(
1227
-								'description' => __( 'Product SKU.', 'woocommerce' ),
1227
+								'description' => __('Product SKU.', 'woocommerce'),
1228 1228
 								'type'        => 'string',
1229
-								'context'     => array( 'view', 'edit' ),
1229
+								'context'     => array('view', 'edit'),
1230 1230
 								'readonly'    => true,
1231 1231
 							),
1232 1232
 							'product_id' => array(
1233
-								'description' => __( 'Product ID.', 'woocommerce' ),
1233
+								'description' => __('Product ID.', 'woocommerce'),
1234 1234
 								'type'        => 'mixed',
1235
-								'context'     => array( 'view', 'edit' ),
1235
+								'context'     => array('view', 'edit'),
1236 1236
 							),
1237 1237
 							'variation_id' => array(
1238
-								'description' => __( 'Variation ID, if applicable.', 'woocommerce' ),
1238
+								'description' => __('Variation ID, if applicable.', 'woocommerce'),
1239 1239
 								'type'        => 'integer',
1240
-								'context'     => array( 'view', 'edit' ),
1240
+								'context'     => array('view', 'edit'),
1241 1241
 							),
1242 1242
 							'quantity' => array(
1243
-								'description' => __( 'Quantity ordered.', 'woocommerce' ),
1243
+								'description' => __('Quantity ordered.', 'woocommerce'),
1244 1244
 								'type'        => 'integer',
1245
-								'context'     => array( 'view', 'edit' ),
1245
+								'context'     => array('view', 'edit'),
1246 1246
 							),
1247 1247
 							'tax_class' => array(
1248
-								'description' => __( 'Tax class of product.', 'woocommerce' ),
1248
+								'description' => __('Tax class of product.', 'woocommerce'),
1249 1249
 								'type'        => 'string',
1250
-								'context'     => array( 'view', 'edit' ),
1250
+								'context'     => array('view', 'edit'),
1251 1251
 								'readonly'    => true,
1252 1252
 							),
1253 1253
 							'price' => array(
1254
-								'description' => __( 'Product price.', 'woocommerce' ),
1254
+								'description' => __('Product price.', 'woocommerce'),
1255 1255
 								'type'        => 'string',
1256
-								'context'     => array( 'view', 'edit' ),
1256
+								'context'     => array('view', 'edit'),
1257 1257
 								'readonly'    => true,
1258 1258
 							),
1259 1259
 							'subtotal' => array(
1260
-								'description' => __( 'Line subtotal (before discounts).', 'woocommerce' ),
1260
+								'description' => __('Line subtotal (before discounts).', 'woocommerce'),
1261 1261
 								'type'        => 'string',
1262
-								'context'     => array( 'view', 'edit' ),
1262
+								'context'     => array('view', 'edit'),
1263 1263
 							),
1264 1264
 							'subtotal_tax' => array(
1265
-								'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce' ),
1265
+								'description' => __('Line subtotal tax (before discounts).', 'woocommerce'),
1266 1266
 								'type'        => 'string',
1267
-								'context'     => array( 'view', 'edit' ),
1267
+								'context'     => array('view', 'edit'),
1268 1268
 							),
1269 1269
 							'total' => array(
1270
-								'description' => __( 'Line total (after discounts).', 'woocommerce' ),
1270
+								'description' => __('Line total (after discounts).', 'woocommerce'),
1271 1271
 								'type'        => 'string',
1272
-								'context'     => array( 'view', 'edit' ),
1272
+								'context'     => array('view', 'edit'),
1273 1273
 							),
1274 1274
 							'total_tax' => array(
1275
-								'description' => __( 'Line total tax (after discounts).', 'woocommerce' ),
1275
+								'description' => __('Line total tax (after discounts).', 'woocommerce'),
1276 1276
 								'type'        => 'string',
1277
-								'context'     => array( 'view', 'edit' ),
1277
+								'context'     => array('view', 'edit'),
1278 1278
 							),
1279 1279
 							'taxes' => array(
1280
-								'description' => __( 'Line taxes.', 'woocommerce' ),
1280
+								'description' => __('Line taxes.', 'woocommerce'),
1281 1281
 								'type'        => 'array',
1282
-								'context'     => array( 'view', 'edit' ),
1282
+								'context'     => array('view', 'edit'),
1283 1283
 								'readonly'    => true,
1284 1284
 								'items'       => array(
1285 1285
 									'type'       => 'object',
1286 1286
 									'properties' => array(
1287 1287
 										'id' => array(
1288
-											'description' => __( 'Tax rate ID.', 'woocommerce' ),
1288
+											'description' => __('Tax rate ID.', 'woocommerce'),
1289 1289
 											'type'        => 'integer',
1290
-											'context'     => array( 'view', 'edit' ),
1290
+											'context'     => array('view', 'edit'),
1291 1291
 											'readonly'    => true,
1292 1292
 										),
1293 1293
 										'total' => array(
1294
-											'description' => __( 'Tax total.', 'woocommerce' ),
1294
+											'description' => __('Tax total.', 'woocommerce'),
1295 1295
 											'type'        => 'string',
1296
-											'context'     => array( 'view', 'edit' ),
1296
+											'context'     => array('view', 'edit'),
1297 1297
 											'readonly'    => true,
1298 1298
 										),
1299 1299
 										'subtotal' => array(
1300
-											'description' => __( 'Tax subtotal.', 'woocommerce' ),
1300
+											'description' => __('Tax subtotal.', 'woocommerce'),
1301 1301
 											'type'        => 'string',
1302
-											'context'     => array( 'view', 'edit' ),
1302
+											'context'     => array('view', 'edit'),
1303 1303
 											'readonly'    => true,
1304 1304
 										),
1305 1305
 									),
1306 1306
 								),
1307 1307
 							),
1308 1308
 							'meta' => array(
1309
-								'description' => __( 'Line item meta data.', 'woocommerce' ),
1309
+								'description' => __('Line item meta data.', 'woocommerce'),
1310 1310
 								'type'        => 'array',
1311
-								'context'     => array( 'view', 'edit' ),
1311
+								'context'     => array('view', 'edit'),
1312 1312
 								'readonly'    => true,
1313 1313
 								'items'       => array(
1314 1314
 									'type'       => 'object',
1315 1315
 									'properties' => array(
1316 1316
 										'key' => array(
1317
-											'description' => __( 'Meta key.', 'woocommerce' ),
1317
+											'description' => __('Meta key.', 'woocommerce'),
1318 1318
 											'type'        => 'string',
1319
-											'context'     => array( 'view', 'edit' ),
1319
+											'context'     => array('view', 'edit'),
1320 1320
 											'readonly'    => true,
1321 1321
 										),
1322 1322
 										'label' => array(
1323
-											'description' => __( 'Meta label.', 'woocommerce' ),
1323
+											'description' => __('Meta label.', 'woocommerce'),
1324 1324
 											'type'        => 'string',
1325
-											'context'     => array( 'view', 'edit' ),
1325
+											'context'     => array('view', 'edit'),
1326 1326
 											'readonly'    => true,
1327 1327
 										),
1328 1328
 										'value' => array(
1329
-											'description' => __( 'Meta value.', 'woocommerce' ),
1329
+											'description' => __('Meta value.', 'woocommerce'),
1330 1330
 											'type'        => 'mixed',
1331
-											'context'     => array( 'view', 'edit' ),
1331
+											'context'     => array('view', 'edit'),
1332 1332
 											'readonly'    => true,
1333 1333
 										),
1334 1334
 									),
@@ -1338,110 +1338,110 @@  discard block
 block discarded – undo
1338 1338
 					),
1339 1339
 				),
1340 1340
 				'tax_lines' => array(
1341
-					'description' => __( 'Tax lines data.', 'woocommerce' ),
1341
+					'description' => __('Tax lines data.', 'woocommerce'),
1342 1342
 					'type'        => 'array',
1343
-					'context'     => array( 'view', 'edit' ),
1343
+					'context'     => array('view', 'edit'),
1344 1344
 					'readonly'    => true,
1345 1345
 					'items'       => array(
1346 1346
 						'type'       => 'object',
1347 1347
 						'properties' => array(
1348 1348
 							'id' => array(
1349
-								'description' => __( 'Item ID.', 'woocommerce' ),
1349
+								'description' => __('Item ID.', 'woocommerce'),
1350 1350
 								'type'        => 'integer',
1351
-								'context'     => array( 'view', 'edit' ),
1351
+								'context'     => array('view', 'edit'),
1352 1352
 								'readonly'    => true,
1353 1353
 							),
1354 1354
 							'rate_code' => array(
1355
-								'description' => __( 'Tax rate code.', 'woocommerce' ),
1355
+								'description' => __('Tax rate code.', 'woocommerce'),
1356 1356
 								'type'        => 'string',
1357
-								'context'     => array( 'view', 'edit' ),
1357
+								'context'     => array('view', 'edit'),
1358 1358
 								'readonly'    => true,
1359 1359
 							),
1360 1360
 							'rate_id' => array(
1361
-								'description' => __( 'Tax rate ID.', 'woocommerce' ),
1361
+								'description' => __('Tax rate ID.', 'woocommerce'),
1362 1362
 								'type'        => 'string',
1363
-								'context'     => array( 'view', 'edit' ),
1363
+								'context'     => array('view', 'edit'),
1364 1364
 								'readonly'    => true,
1365 1365
 							),
1366 1366
 							'label' => array(
1367
-								'description' => __( 'Tax rate label.', 'woocommerce' ),
1367
+								'description' => __('Tax rate label.', 'woocommerce'),
1368 1368
 								'type'        => 'string',
1369
-								'context'     => array( 'view', 'edit' ),
1369
+								'context'     => array('view', 'edit'),
1370 1370
 								'readonly'    => true,
1371 1371
 							),
1372 1372
 							'compound' => array(
1373
-								'description' => __( 'Show if is a compound tax rate.', 'woocommerce' ),
1373
+								'description' => __('Show if is a compound tax rate.', 'woocommerce'),
1374 1374
 								'type'        => 'boolean',
1375
-								'context'     => array( 'view', 'edit' ),
1375
+								'context'     => array('view', 'edit'),
1376 1376
 								'readonly'    => true,
1377 1377
 							),
1378 1378
 							'tax_total' => array(
1379
-								'description' => __( 'Tax total (not including shipping taxes).', 'woocommerce' ),
1379
+								'description' => __('Tax total (not including shipping taxes).', 'woocommerce'),
1380 1380
 								'type'        => 'string',
1381
-								'context'     => array( 'view', 'edit' ),
1381
+								'context'     => array('view', 'edit'),
1382 1382
 								'readonly'    => true,
1383 1383
 							),
1384 1384
 							'shipping_tax_total' => array(
1385
-								'description' => __( 'Shipping tax total.', 'woocommerce' ),
1385
+								'description' => __('Shipping tax total.', 'woocommerce'),
1386 1386
 								'type'        => 'string',
1387
-								'context'     => array( 'view', 'edit' ),
1387
+								'context'     => array('view', 'edit'),
1388 1388
 								'readonly'    => true,
1389 1389
 							),
1390 1390
 						),
1391 1391
 					),
1392 1392
 				),
1393 1393
 				'shipping_lines' => array(
1394
-					'description' => __( 'Shipping lines data.', 'woocommerce' ),
1394
+					'description' => __('Shipping lines data.', 'woocommerce'),
1395 1395
 					'type'        => 'array',
1396
-					'context'     => array( 'view', 'edit' ),
1396
+					'context'     => array('view', 'edit'),
1397 1397
 					'items'       => array(
1398 1398
 						'type'       => 'object',
1399 1399
 						'properties' => array(
1400 1400
 							'id' => array(
1401
-								'description' => __( 'Item ID.', 'woocommerce' ),
1401
+								'description' => __('Item ID.', 'woocommerce'),
1402 1402
 								'type'        => 'integer',
1403
-								'context'     => array( 'view', 'edit' ),
1403
+								'context'     => array('view', 'edit'),
1404 1404
 								'readonly'    => true,
1405 1405
 							),
1406 1406
 							'method_title' => array(
1407
-								'description' => __( 'Shipping method name.', 'woocommerce' ),
1407
+								'description' => __('Shipping method name.', 'woocommerce'),
1408 1408
 								'type'        => 'mixed',
1409
-								'context'     => array( 'view', 'edit' ),
1409
+								'context'     => array('view', 'edit'),
1410 1410
 							),
1411 1411
 							'method_id' => array(
1412
-								'description' => __( 'Shipping method ID.', 'woocommerce' ),
1412
+								'description' => __('Shipping method ID.', 'woocommerce'),
1413 1413
 								'type'        => 'mixed',
1414
-								'context'     => array( 'view', 'edit' ),
1414
+								'context'     => array('view', 'edit'),
1415 1415
 							),
1416 1416
 							'total' => array(
1417
-								'description' => __( 'Line total (after discounts).', 'woocommerce' ),
1417
+								'description' => __('Line total (after discounts).', 'woocommerce'),
1418 1418
 								'type'        => 'string',
1419
-								'context'     => array( 'view', 'edit' ),
1419
+								'context'     => array('view', 'edit'),
1420 1420
 							),
1421 1421
 							'total_tax' => array(
1422
-								'description' => __( 'Line total tax (after discounts).', 'woocommerce' ),
1422
+								'description' => __('Line total tax (after discounts).', 'woocommerce'),
1423 1423
 								'type'        => 'string',
1424
-								'context'     => array( 'view', 'edit' ),
1424
+								'context'     => array('view', 'edit'),
1425 1425
 								'readonly'    => true,
1426 1426
 							),
1427 1427
 							'taxes' => array(
1428
-								'description' => __( 'Line taxes.', 'woocommerce' ),
1428
+								'description' => __('Line taxes.', 'woocommerce'),
1429 1429
 								'type'        => 'array',
1430
-								'context'     => array( 'view', 'edit' ),
1430
+								'context'     => array('view', 'edit'),
1431 1431
 								'readonly'    => true,
1432 1432
 								'items'       => array(
1433 1433
 									'type'       => 'object',
1434 1434
 									'properties' => array(
1435 1435
 										'id' => array(
1436
-											'description' => __( 'Tax rate ID.', 'woocommerce' ),
1436
+											'description' => __('Tax rate ID.', 'woocommerce'),
1437 1437
 											'type'        => 'integer',
1438
-											'context'     => array( 'view', 'edit' ),
1438
+											'context'     => array('view', 'edit'),
1439 1439
 											'readonly'    => true,
1440 1440
 										),
1441 1441
 										'total' => array(
1442
-											'description' => __( 'Tax total.', 'woocommerce' ),
1442
+											'description' => __('Tax total.', 'woocommerce'),
1443 1443
 											'type'        => 'string',
1444
-											'context'     => array( 'view', 'edit' ),
1444
+											'context'     => array('view', 'edit'),
1445 1445
 											'readonly'    => true,
1446 1446
 										),
1447 1447
 									),
@@ -1451,68 +1451,68 @@  discard block
 block discarded – undo
1451 1451
 					),
1452 1452
 				),
1453 1453
 				'fee_lines' => array(
1454
-					'description' => __( 'Fee lines data.', 'woocommerce' ),
1454
+					'description' => __('Fee lines data.', 'woocommerce'),
1455 1455
 					'type'        => 'array',
1456
-					'context'     => array( 'view', 'edit' ),
1456
+					'context'     => array('view', 'edit'),
1457 1457
 					'items'       => array(
1458 1458
 						'type'       => 'object',
1459 1459
 						'properties' => array(
1460 1460
 							'id' => array(
1461
-								'description' => __( 'Item ID.', 'woocommerce' ),
1461
+								'description' => __('Item ID.', 'woocommerce'),
1462 1462
 								'type'        => 'integer',
1463
-								'context'     => array( 'view', 'edit' ),
1463
+								'context'     => array('view', 'edit'),
1464 1464
 								'readonly'    => true,
1465 1465
 							),
1466 1466
 							'name' => array(
1467
-								'description' => __( 'Fee name.', 'woocommerce' ),
1467
+								'description' => __('Fee name.', 'woocommerce'),
1468 1468
 								'type'        => 'mixed',
1469
-								'context'     => array( 'view', 'edit' ),
1469
+								'context'     => array('view', 'edit'),
1470 1470
 							),
1471 1471
 							'tax_class' => array(
1472
-								'description' => __( 'Tax class of fee.', 'woocommerce' ),
1472
+								'description' => __('Tax class of fee.', 'woocommerce'),
1473 1473
 								'type'        => 'string',
1474
-								'context'     => array( 'view', 'edit' ),
1474
+								'context'     => array('view', 'edit'),
1475 1475
 							),
1476 1476
 							'tax_status' => array(
1477
-								'description' => __( 'Tax status of fee.', 'woocommerce' ),
1477
+								'description' => __('Tax status of fee.', 'woocommerce'),
1478 1478
 								'type'        => 'string',
1479
-								'context'     => array( 'view', 'edit' ),
1480
-								'enum'        => array( 'taxable', 'none' ),
1479
+								'context'     => array('view', 'edit'),
1480
+								'enum'        => array('taxable', 'none'),
1481 1481
 							),
1482 1482
 							'total' => array(
1483
-								'description' => __( 'Line total (after discounts).', 'woocommerce' ),
1483
+								'description' => __('Line total (after discounts).', 'woocommerce'),
1484 1484
 								'type'        => 'string',
1485
-								'context'     => array( 'view', 'edit' ),
1485
+								'context'     => array('view', 'edit'),
1486 1486
 							),
1487 1487
 							'total_tax' => array(
1488
-								'description' => __( 'Line total tax (after discounts).', 'woocommerce' ),
1488
+								'description' => __('Line total tax (after discounts).', 'woocommerce'),
1489 1489
 								'type'        => 'string',
1490
-								'context'     => array( 'view', 'edit' ),
1490
+								'context'     => array('view', 'edit'),
1491 1491
 							),
1492 1492
 							'taxes' => array(
1493
-								'description' => __( 'Line taxes.', 'woocommerce' ),
1493
+								'description' => __('Line taxes.', 'woocommerce'),
1494 1494
 								'type'        => 'array',
1495
-								'context'     => array( 'view', 'edit' ),
1495
+								'context'     => array('view', 'edit'),
1496 1496
 								'readonly'    => true,
1497 1497
 								'items'       => array(
1498 1498
 									'type'       => 'object',
1499 1499
 									'properties' => array(
1500 1500
 										'id' => array(
1501
-											'description' => __( 'Tax rate ID.', 'woocommerce' ),
1501
+											'description' => __('Tax rate ID.', 'woocommerce'),
1502 1502
 											'type'        => 'integer',
1503
-											'context'     => array( 'view', 'edit' ),
1503
+											'context'     => array('view', 'edit'),
1504 1504
 											'readonly'    => true,
1505 1505
 										),
1506 1506
 										'total' => array(
1507
-											'description' => __( 'Tax total.', 'woocommerce' ),
1507
+											'description' => __('Tax total.', 'woocommerce'),
1508 1508
 											'type'        => 'string',
1509
-											'context'     => array( 'view', 'edit' ),
1509
+											'context'     => array('view', 'edit'),
1510 1510
 											'readonly'    => true,
1511 1511
 										),
1512 1512
 										'subtotal' => array(
1513
-											'description' => __( 'Tax subtotal.', 'woocommerce' ),
1513
+											'description' => __('Tax subtotal.', 'woocommerce'),
1514 1514
 											'type'        => 'string',
1515
-											'context'     => array( 'view', 'edit' ),
1515
+											'context'     => array('view', 'edit'),
1516 1516
 											'readonly'    => true,
1517 1517
 										),
1518 1518
 									),
@@ -1522,61 +1522,61 @@  discard block
 block discarded – undo
1522 1522
 					),
1523 1523
 				),
1524 1524
 				'coupon_lines' => array(
1525
-					'description' => __( 'Coupons line data.', 'woocommerce' ),
1525
+					'description' => __('Coupons line data.', 'woocommerce'),
1526 1526
 					'type'        => 'array',
1527
-					'context'     => array( 'view', 'edit' ),
1527
+					'context'     => array('view', 'edit'),
1528 1528
 					'items'       => array(
1529 1529
 						'type'       => 'object',
1530 1530
 						'properties' => array(
1531 1531
 							'id' => array(
1532
-								'description' => __( 'Item ID.', 'woocommerce' ),
1532
+								'description' => __('Item ID.', 'woocommerce'),
1533 1533
 								'type'        => 'integer',
1534
-								'context'     => array( 'view', 'edit' ),
1534
+								'context'     => array('view', 'edit'),
1535 1535
 								'readonly'    => true,
1536 1536
 							),
1537 1537
 							'code' => array(
1538
-								'description' => __( 'Coupon code.', 'woocommerce' ),
1538
+								'description' => __('Coupon code.', 'woocommerce'),
1539 1539
 								'type'        => 'mixed',
1540
-								'context'     => array( 'view', 'edit' ),
1540
+								'context'     => array('view', 'edit'),
1541 1541
 							),
1542 1542
 							'discount' => array(
1543
-								'description' => __( 'Discount total.', 'woocommerce' ),
1543
+								'description' => __('Discount total.', 'woocommerce'),
1544 1544
 								'type'        => 'string',
1545
-								'context'     => array( 'view', 'edit' ),
1545
+								'context'     => array('view', 'edit'),
1546 1546
 							),
1547 1547
 							'discount_tax' => array(
1548
-								'description' => __( 'Discount total tax.', 'woocommerce' ),
1548
+								'description' => __('Discount total tax.', 'woocommerce'),
1549 1549
 								'type'        => 'string',
1550
-								'context'     => array( 'view', 'edit' ),
1550
+								'context'     => array('view', 'edit'),
1551 1551
 								'readonly'    => true,
1552 1552
 							),
1553 1553
 						),
1554 1554
 					),
1555 1555
 				),
1556 1556
 				'refunds' => array(
1557
-					'description' => __( 'List of refunds.', 'woocommerce' ),
1557
+					'description' => __('List of refunds.', 'woocommerce'),
1558 1558
 					'type'        => 'array',
1559
-					'context'     => array( 'view', 'edit' ),
1559
+					'context'     => array('view', 'edit'),
1560 1560
 					'readonly'    => true,
1561 1561
 					'items'       => array(
1562 1562
 						'type'       => 'object',
1563 1563
 						'properties' => array(
1564 1564
 							'id' => array(
1565
-								'description' => __( 'Refund ID.', 'woocommerce' ),
1565
+								'description' => __('Refund ID.', 'woocommerce'),
1566 1566
 								'type'        => 'integer',
1567
-								'context'     => array( 'view', 'edit' ),
1567
+								'context'     => array('view', 'edit'),
1568 1568
 								'readonly'    => true,
1569 1569
 							),
1570 1570
 							'reason' => array(
1571
-								'description' => __( 'Refund reason.', 'woocommerce' ),
1571
+								'description' => __('Refund reason.', 'woocommerce'),
1572 1572
 								'type'        => 'string',
1573
-								'context'     => array( 'view', 'edit' ),
1573
+								'context'     => array('view', 'edit'),
1574 1574
 								'readonly'    => true,
1575 1575
 							),
1576 1576
 							'total' => array(
1577
-								'description' => __( 'Refund total.', 'woocommerce' ),
1577
+								'description' => __('Refund total.', 'woocommerce'),
1578 1578
 								'type'        => 'string',
1579
-								'context'     => array( 'view', 'edit' ),
1579
+								'context'     => array('view', 'edit'),
1580 1580
 								'readonly'    => true,
1581 1581
 							),
1582 1582
 						),
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
 			),
1586 1586
 		);
1587 1587
 
1588
-		return $this->add_additional_fields_schema( $schema );
1588
+		return $this->add_additional_fields_schema($schema);
1589 1589
 	}
1590 1590
 
1591 1591
 	/**
@@ -1598,27 +1598,27 @@  discard block
 block discarded – undo
1598 1598
 
1599 1599
 		$params['status'] = array(
1600 1600
 			'default'           => 'any',
1601
-			'description'       => __( 'Limit result set to orders assigned a specific status.', 'woocommerce' ),
1601
+			'description'       => __('Limit result set to orders assigned a specific status.', 'woocommerce'),
1602 1602
 			'type'              => 'string',
1603
-			'enum'              => array_merge( array( 'any' ), $this->get_order_statuses() ),
1603
+			'enum'              => array_merge(array('any'), $this->get_order_statuses()),
1604 1604
 			'sanitize_callback' => 'sanitize_key',
1605 1605
 			'validate_callback' => 'rest_validate_request_arg',
1606 1606
 		);
1607 1607
 		$params['customer'] = array(
1608
-			'description'       => __( 'Limit result set to orders assigned a specific customer.', 'woocommerce' ),
1608
+			'description'       => __('Limit result set to orders assigned a specific customer.', 'woocommerce'),
1609 1609
 			'type'              => 'integer',
1610 1610
 			'sanitize_callback' => 'absint',
1611 1611
 			'validate_callback' => 'rest_validate_request_arg',
1612 1612
 		);
1613 1613
 		$params['product'] = array(
1614
-			'description'       => __( 'Limit result set to orders assigned a specific product.', 'woocommerce' ),
1614
+			'description'       => __('Limit result set to orders assigned a specific product.', 'woocommerce'),
1615 1615
 			'type'              => 'integer',
1616 1616
 			'sanitize_callback' => 'absint',
1617 1617
 			'validate_callback' => 'rest_validate_request_arg',
1618 1618
 		);
1619 1619
 		$params['dp'] = array(
1620 1620
 			'default'           => wc_get_price_decimals(),
1621
-			'description'       => __( 'Number of decimal points to use in each resource.', 'woocommerce' ),
1621
+			'description'       => __('Number of decimal points to use in each resource.', 'woocommerce'),
1622 1622
 			'type'              => 'integer',
1623 1623
 			'sanitize_callback' => 'absint',
1624 1624
 			'validate_callback' => 'rest_validate_request_arg',
Please login to merge, or discard this patch.
src/Controllers/Version1/class-wc-rest-products-v1-controller.php 1 patch
Spacing   +842 added lines, -842 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @since    3.0.0
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -47,75 +47,75 @@  discard block
 block discarded – undo
47 47
 	 * Initialize product actions.
48 48
 	 */
49 49
 	public function __construct() {
50
-		add_filter( "woocommerce_rest_{$this->post_type}_query", array( $this, 'query_args' ), 10, 2 );
51
-		add_action( "woocommerce_rest_insert_{$this->post_type}", array( $this, 'clear_transients' ) );
50
+		add_filter("woocommerce_rest_{$this->post_type}_query", array($this, 'query_args'), 10, 2);
51
+		add_action("woocommerce_rest_insert_{$this->post_type}", array($this, 'clear_transients'));
52 52
 	}
53 53
 
54 54
 	/**
55 55
 	 * Register the routes for products.
56 56
 	 */
57 57
 	public function register_routes() {
58
-		register_rest_route( $this->namespace, '/' . $this->rest_base, array(
58
+		register_rest_route($this->namespace, '/' . $this->rest_base, array(
59 59
 			array(
60 60
 				'methods'             => WP_REST_Server::READABLE,
61
-				'callback'            => array( $this, 'get_items' ),
62
-				'permission_callback' => array( $this, 'get_items_permissions_check' ),
61
+				'callback'            => array($this, 'get_items'),
62
+				'permission_callback' => array($this, 'get_items_permissions_check'),
63 63
 				'args'                => $this->get_collection_params(),
64 64
 			),
65 65
 			array(
66 66
 				'methods'             => WP_REST_Server::CREATABLE,
67
-				'callback'            => array( $this, 'create_item' ),
68
-				'permission_callback' => array( $this, 'create_item_permissions_check' ),
69
-				'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
67
+				'callback'            => array($this, 'create_item'),
68
+				'permission_callback' => array($this, 'create_item_permissions_check'),
69
+				'args'                => $this->get_endpoint_args_for_item_schema(WP_REST_Server::CREATABLE),
70 70
 			),
71
-			'schema' => array( $this, 'get_public_item_schema' ),
72
-		) );
71
+			'schema' => array($this, 'get_public_item_schema'),
72
+		));
73 73
 
74
-		register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
74
+		register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
75 75
 			'args' => array(
76 76
 				'id' => array(
77
-					'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
77
+					'description' => __('Unique identifier for the resource.', 'woocommerce'),
78 78
 					'type'        => 'integer',
79 79
 				),
80 80
 			),
81 81
 			array(
82 82
 				'methods'             => WP_REST_Server::READABLE,
83
-				'callback'            => array( $this, 'get_item' ),
84
-				'permission_callback' => array( $this, 'get_item_permissions_check' ),
83
+				'callback'            => array($this, 'get_item'),
84
+				'permission_callback' => array($this, 'get_item_permissions_check'),
85 85
 				'args'                => array(
86
-					'context' => $this->get_context_param( array( 'default' => 'view' ) ),
86
+					'context' => $this->get_context_param(array('default' => 'view')),
87 87
 				),
88 88
 			),
89 89
 			array(
90 90
 				'methods'             => WP_REST_Server::EDITABLE,
91
-				'callback'            => array( $this, 'update_item' ),
92
-				'permission_callback' => array( $this, 'update_item_permissions_check' ),
93
-				'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
91
+				'callback'            => array($this, 'update_item'),
92
+				'permission_callback' => array($this, 'update_item_permissions_check'),
93
+				'args'                => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE),
94 94
 			),
95 95
 			array(
96 96
 				'methods'             => WP_REST_Server::DELETABLE,
97
-				'callback'            => array( $this, 'delete_item' ),
98
-				'permission_callback' => array( $this, 'delete_item_permissions_check' ),
97
+				'callback'            => array($this, 'delete_item'),
98
+				'permission_callback' => array($this, 'delete_item_permissions_check'),
99 99
 				'args'                => array(
100 100
 					'force' => array(
101 101
 						'default'     => false,
102
-						'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
102
+						'description' => __('Whether to bypass trash and force deletion.', 'woocommerce'),
103 103
 						'type'        => 'boolean',
104 104
 					),
105 105
 				),
106 106
 			),
107
-			'schema' => array( $this, 'get_public_item_schema' ),
108
-		) );
107
+			'schema' => array($this, 'get_public_item_schema'),
108
+		));
109 109
 
110
-		register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array(
110
+		register_rest_route($this->namespace, '/' . $this->rest_base . '/batch', array(
111 111
 			array(
112 112
 				'methods'             => WP_REST_Server::EDITABLE,
113
-				'callback'            => array( $this, 'batch_items' ),
114
-				'permission_callback' => array( $this, 'batch_items_permissions_check' ),
115
-				'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
113
+				'callback'            => array($this, 'batch_items'),
114
+				'permission_callback' => array($this, 'batch_items_permissions_check'),
115
+				'args'                => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE),
116 116
 			),
117
-			'schema' => array( $this, 'get_public_batch_schema' ),
118
-		) );
117
+			'schema' => array($this, 'get_public_batch_schema'),
118
+		));
119 119
 	}
120 120
 
121 121
 	/**
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @return array
125 125
 	 */
126 126
 	protected function get_post_types() {
127
-		return array( 'product', 'product_variation' );
127
+		return array('product', 'product_variation');
128 128
 	}
129 129
 
130 130
 	/**
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @param WP_REST_Request $request Request data.
135 135
 	 * @return array
136 136
 	 */
137
-	public function query_args( $args, $request ) {
137
+	public function query_args($args, $request) {
138 138
 		// Set post_status.
139 139
 		$args['post_status'] = $request['status'];
140 140
 
@@ -150,22 +150,22 @@  discard block
 block discarded – undo
150 150
 		);
151 151
 
152 152
 		// Set tax_query for each passed arg.
153
-		foreach ( $taxonomies as $taxonomy => $key ) {
154
-			if ( ! empty( $request[ $key ] ) && is_array( $request[ $key ] ) ) {
155
-				$request[ $key ] = array_filter( $request[ $key ] );
153
+		foreach ($taxonomies as $taxonomy => $key) {
154
+			if ( ! empty($request[$key]) && is_array($request[$key])) {
155
+				$request[$key] = array_filter($request[$key]);
156 156
 			}
157 157
 
158
-			if ( ! empty( $request[ $key ] ) ) {
158
+			if ( ! empty($request[$key])) {
159 159
 				$tax_query[] = array(
160 160
 					'taxonomy' => $taxonomy,
161 161
 					'field'    => 'term_id',
162
-					'terms'    => $request[ $key ],
162
+					'terms'    => $request[$key],
163 163
 				);
164 164
 			}
165 165
 		}
166 166
 
167 167
 		// Filter product type by slug.
168
-		if ( ! empty( $request['type'] ) ) {
168
+		if ( ! empty($request['type'])) {
169 169
 			$tax_query[] = array(
170 170
 				'taxonomy' => 'product_type',
171 171
 				'field'    => 'slug',
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 		}
175 175
 
176 176
 		// Filter by attribute and term.
177
-		if ( ! empty( $request['attribute'] ) && ! empty( $request['attribute_term'] ) ) {
178
-			if ( in_array( $request['attribute'], wc_get_attribute_taxonomy_names(), true ) ) {
177
+		if ( ! empty($request['attribute']) && ! empty($request['attribute_term'])) {
178
+			if (in_array($request['attribute'], wc_get_attribute_taxonomy_names(), true)) {
179 179
 				$tax_query[] = array(
180 180
 					'taxonomy' => $request['attribute'],
181 181
 					'field'    => 'term_id',
@@ -184,34 +184,34 @@  discard block
 block discarded – undo
184 184
 			}
185 185
 		}
186 186
 
187
-		if ( ! empty( $tax_query ) ) {
187
+		if ( ! empty($tax_query)) {
188 188
 			$args['tax_query'] = $tax_query;
189 189
 		}
190 190
 
191 191
 		// Filter by sku.
192
-		if ( ! empty( $request['sku'] ) ) {
193
-			$skus = explode( ',', $request['sku'] );
192
+		if ( ! empty($request['sku'])) {
193
+			$skus = explode(',', $request['sku']);
194 194
 			// Include the current string as a SKU too.
195
-			if ( 1 < count( $skus ) ) {
195
+			if (1 < count($skus)) {
196 196
 				$skus[] = $request['sku'];
197 197
 			}
198 198
 
199
-			$args['meta_query'] = $this->add_meta_query( $args, array(
199
+			$args['meta_query'] = $this->add_meta_query($args, array(
200 200
 				'key'     => '_sku',
201 201
 				'value'   => $skus,
202 202
 				'compare' => 'IN',
203
-			) );
203
+			));
204 204
 		}
205 205
 
206 206
 		// Apply all WP_Query filters again.
207
-		if ( is_array( $request['filter'] ) ) {
208
-			$args = array_merge( $args, $request['filter'] );
209
-			unset( $args['filter'] );
207
+		if (is_array($request['filter'])) {
208
+			$args = array_merge($args, $request['filter']);
209
+			unset($args['filter']);
210 210
 		}
211 211
 
212 212
 		// Force the post_type argument, since it's not a user input variable.
213
-		if ( ! empty( $request['sku'] ) ) {
214
-			$args['post_type'] = array( 'product', 'product_variation' );
213
+		if ( ! empty($request['sku'])) {
214
+			$args['post_type'] = array('product', 'product_variation');
215 215
 		} else {
216 216
 			$args['post_type'] = $this->post_type;
217 217
 		}
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
 	 * @param WC_Product|WC_Product_Variation $product Product instance.
226 226
 	 * @return array
227 227
 	 */
228
-	protected function get_downloads( $product ) {
228
+	protected function get_downloads($product) {
229 229
 		$downloads = array();
230 230
 
231
-		if ( $product->is_downloadable() ) {
232
-			foreach ( $product->get_downloads() as $file_id => $file ) {
231
+		if ($product->is_downloadable()) {
232
+			foreach ($product->get_downloads() as $file_id => $file) {
233 233
 				$downloads[] = array(
234 234
 					'id'   => $file_id, // MD5 hash.
235 235
 					'name' => $file['name'],
@@ -248,10 +248,10 @@  discard block
 block discarded – undo
248 248
 	 * @param string     $taxonomy Taxonomy slug.
249 249
 	 * @return array
250 250
 	 */
251
-	protected function get_taxonomy_terms( $product, $taxonomy = 'cat' ) {
251
+	protected function get_taxonomy_terms($product, $taxonomy = 'cat') {
252 252
 		$terms = array();
253 253
 
254
-		foreach ( wc_get_object_terms( $product->get_id(), 'product_' . $taxonomy ) as $term ) {
254
+		foreach (wc_get_object_terms($product->get_id(), 'product_' . $taxonomy) as $term) {
255 255
 			$terms[] = array(
256 256
 				'id'   => $term->term_id,
257 257
 				'name' => $term->name,
@@ -268,50 +268,50 @@  discard block
 block discarded – undo
268 268
 	 * @param WC_Product|WC_Product_Variation $product Product instance.
269 269
 	 * @return array
270 270
 	 */
271
-	protected function get_images( $product ) {
271
+	protected function get_images($product) {
272 272
 		$images = array();
273 273
 		$attachment_ids = array();
274 274
 
275 275
 		// Add featured image.
276
-		if ( $product->get_image_id() ) {
276
+		if ($product->get_image_id()) {
277 277
 			$attachment_ids[] = $product->get_image_id();
278 278
 		}
279 279
 
280 280
 		// Add gallery images.
281
-		$attachment_ids = array_merge( $attachment_ids, $product->get_gallery_image_ids() );
281
+		$attachment_ids = array_merge($attachment_ids, $product->get_gallery_image_ids());
282 282
 
283 283
 		// Build image data.
284
-		foreach ( $attachment_ids as $position => $attachment_id ) {
285
-			$attachment_post = get_post( $attachment_id );
286
-			if ( is_null( $attachment_post ) ) {
284
+		foreach ($attachment_ids as $position => $attachment_id) {
285
+			$attachment_post = get_post($attachment_id);
286
+			if (is_null($attachment_post)) {
287 287
 				continue;
288 288
 			}
289 289
 
290
-			$attachment = wp_get_attachment_image_src( $attachment_id, 'full' );
291
-			if ( ! is_array( $attachment ) ) {
290
+			$attachment = wp_get_attachment_image_src($attachment_id, 'full');
291
+			if ( ! is_array($attachment)) {
292 292
 				continue;
293 293
 			}
294 294
 
295 295
 			$images[] = array(
296 296
 				'id'            => (int) $attachment_id,
297
-				'date_created'  => wc_rest_prepare_date_response( $attachment_post->post_date_gmt ),
298
-				'date_modified' => wc_rest_prepare_date_response( $attachment_post->post_modified_gmt ),
299
-				'src'           => current( $attachment ),
300
-				'name'          => get_the_title( $attachment_id ),
301
-				'alt'           => get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ),
297
+				'date_created'  => wc_rest_prepare_date_response($attachment_post->post_date_gmt),
298
+				'date_modified' => wc_rest_prepare_date_response($attachment_post->post_modified_gmt),
299
+				'src'           => current($attachment),
300
+				'name'          => get_the_title($attachment_id),
301
+				'alt'           => get_post_meta($attachment_id, '_wp_attachment_image_alt', true),
302 302
 				'position'      => (int) $position,
303 303
 			);
304 304
 		}
305 305
 
306 306
 		// Set a placeholder image if the product has no images set.
307
-		if ( empty( $images ) ) {
307
+		if (empty($images)) {
308 308
 			$images[] = array(
309 309
 				'id'            => 0,
310
-				'date_created'  => wc_rest_prepare_date_response( current_time( 'mysql' ) ), // Default to now.
311
-				'date_modified' => wc_rest_prepare_date_response( current_time( 'mysql' ) ),
310
+				'date_created'  => wc_rest_prepare_date_response(current_time('mysql')), // Default to now.
311
+				'date_modified' => wc_rest_prepare_date_response(current_time('mysql')),
312 312
 				'src'           => wc_placeholder_img_src(),
313
-				'name'          => __( 'Placeholder', 'woocommerce' ),
314
-				'alt'           => __( 'Placeholder', 'woocommerce' ),
313
+				'name'          => __('Placeholder', 'woocommerce'),
314
+				'alt'           => __('Placeholder', 'woocommerce'),
315 315
 				'position'      => 0,
316 316
 			);
317 317
 		}
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
 	 * @param  string $name Taxonomy name.
326 326
 	 * @return string
327 327
 	 */
328
-	protected function get_attribute_taxonomy_label( $name ) {
329
-		$tax    = get_taxonomy( $name );
330
-		$labels = get_taxonomy_labels( $tax );
328
+	protected function get_attribute_taxonomy_label($name) {
329
+		$tax    = get_taxonomy($name);
330
+		$labels = get_taxonomy_labels($tax);
331 331
 
332 332
 		return $labels->singular_name;
333 333
 	}
@@ -338,21 +338,21 @@  discard block
 block discarded – undo
338 338
 	 * @param WC_Product $product Product instance.
339 339
 	 * @return array
340 340
 	 */
341
-	protected function get_default_attributes( $product ) {
341
+	protected function get_default_attributes($product) {
342 342
 		$default = array();
343 343
 
344
-		if ( $product->is_type( 'variable' ) ) {
345
-			foreach ( array_filter( (array) $product->get_default_attributes(), 'strlen' ) as $key => $value ) {
346
-				if ( 0 === strpos( $key, 'pa_' ) ) {
344
+		if ($product->is_type('variable')) {
345
+			foreach (array_filter((array) $product->get_default_attributes(), 'strlen') as $key => $value) {
346
+				if (0 === strpos($key, 'pa_')) {
347 347
 					$default[] = array(
348
-						'id'     => wc_attribute_taxonomy_id_by_name( $key ),
349
-						'name'   => $this->get_attribute_taxonomy_label( $key ),
348
+						'id'     => wc_attribute_taxonomy_id_by_name($key),
349
+						'name'   => $this->get_attribute_taxonomy_label($key),
350 350
 						'option' => $value,
351 351
 					);
352 352
 				} else {
353 353
 					$default[] = array(
354 354
 						'id'     => 0,
355
-						'name'   => wc_attribute_taxonomy_slug( $key ),
355
+						'name'   => wc_attribute_taxonomy_slug($key),
356 356
 						'option' => $value,
357 357
 					);
358 358
 				}
@@ -369,11 +369,11 @@  discard block
 block discarded – undo
369 369
 	 * @param array $attribute  Attribute data.
370 370
 	 * @return array
371 371
 	 */
372
-	protected function get_attribute_options( $product_id, $attribute ) {
373
-		if ( isset( $attribute['is_taxonomy'] ) && $attribute['is_taxonomy'] ) {
374
-			return wc_get_product_terms( $product_id, $attribute['name'], array( 'fields' => 'names' ) );
375
-		} elseif ( isset( $attribute['value'] ) ) {
376
-			return array_map( 'trim', explode( '|', $attribute['value'] ) );
372
+	protected function get_attribute_options($product_id, $attribute) {
373
+		if (isset($attribute['is_taxonomy']) && $attribute['is_taxonomy']) {
374
+			return wc_get_product_terms($product_id, $attribute['name'], array('fields' => 'names'));
375
+		} elseif (isset($attribute['value'])) {
376
+			return array_map('trim', explode('|', $attribute['value']));
377 377
 		}
378 378
 
379 379
 		return array();
@@ -385,25 +385,25 @@  discard block
 block discarded – undo
385 385
 	 * @param WC_Product|WC_Product_Variation $product Product instance.
386 386
 	 * @return array
387 387
 	 */
388
-	protected function get_attributes( $product ) {
388
+	protected function get_attributes($product) {
389 389
 		$attributes = array();
390 390
 
391
-		if ( $product->is_type( 'variation' ) ) {
391
+		if ($product->is_type('variation')) {
392 392
 			// Variation attributes.
393
-			foreach ( $product->get_variation_attributes() as $attribute_name => $attribute ) {
394
-				$name = str_replace( 'attribute_', '', $attribute_name );
393
+			foreach ($product->get_variation_attributes() as $attribute_name => $attribute) {
394
+				$name = str_replace('attribute_', '', $attribute_name);
395 395
 
396
-				if ( ! $attribute ) {
396
+				if ( ! $attribute) {
397 397
 					continue;
398 398
 				}
399 399
 
400 400
 				// Taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_`.
401
-				if ( 0 === strpos( $attribute_name, 'attribute_pa_' ) ) {
402
-					$option_term = get_term_by( 'slug', $attribute, $name );
401
+				if (0 === strpos($attribute_name, 'attribute_pa_')) {
402
+					$option_term = get_term_by('slug', $attribute, $name);
403 403
 					$attributes[] = array(
404
-						'id'     => wc_attribute_taxonomy_id_by_name( $name ),
405
-						'name'   => $this->get_attribute_taxonomy_label( $name ),
406
-						'option' => $option_term && ! is_wp_error( $option_term ) ? $option_term->name : $attribute,
404
+						'id'     => wc_attribute_taxonomy_id_by_name($name),
405
+						'name'   => $this->get_attribute_taxonomy_label($name),
406
+						'option' => $option_term && ! is_wp_error($option_term) ? $option_term->name : $attribute,
407 407
 					);
408 408
 				} else {
409 409
 					$attributes[] = array(
@@ -414,15 +414,15 @@  discard block
 block discarded – undo
414 414
 				}
415 415
 			}
416 416
 		} else {
417
-			foreach ( $product->get_attributes() as $attribute ) {
418
-				if ( $attribute['is_taxonomy'] ) {
417
+			foreach ($product->get_attributes() as $attribute) {
418
+				if ($attribute['is_taxonomy']) {
419 419
 					$attributes[] = array(
420
-						'id'        => wc_attribute_taxonomy_id_by_name( $attribute['name'] ),
421
-						'name'      => $this->get_attribute_taxonomy_label( $attribute['name'] ),
420
+						'id'        => wc_attribute_taxonomy_id_by_name($attribute['name']),
421
+						'name'      => $this->get_attribute_taxonomy_label($attribute['name']),
422 422
 						'position'  => (int) $attribute['position'],
423 423
 						'visible'   => (bool) $attribute['is_visible'],
424 424
 						'variation' => (bool) $attribute['is_variation'],
425
-						'options'   => $this->get_attribute_options( $product->get_id(), $attribute ),
425
+						'options'   => $this->get_attribute_options($product->get_id(), $attribute),
426 426
 					);
427 427
 				} else {
428 428
 					$attributes[] = array(
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 						'position'  => (int) $attribute['position'],
432 432
 						'visible'   => (bool) $attribute['is_visible'],
433 433
 						'variation' => (bool) $attribute['is_variation'],
434
-						'options'   => $this->get_attribute_options( $product->get_id(), $attribute ),
434
+						'options'   => $this->get_attribute_options($product->get_id(), $attribute),
435 435
 					);
436 436
 				}
437 437
 			}
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 	 * @param WC_Product $product Product instance.
448 448
 	 * @return int
449 449
 	 */
450
-	protected function get_product_menu_order( $product ) {
450
+	protected function get_product_menu_order($product) {
451 451
 		return $product->get_menu_order();
452 452
 	}
453 453
 
@@ -457,38 +457,38 @@  discard block
 block discarded – undo
457 457
 	 * @param WC_Product $product Product instance.
458 458
 	 * @return array
459 459
 	 */
460
-	protected function get_product_data( $product ) {
460
+	protected function get_product_data($product) {
461 461
 		$data = array(
462 462
 			'id'                    => $product->get_id(),
463 463
 			'name'                  => $product->get_name(),
464 464
 			'slug'                  => $product->get_slug(),
465 465
 			'permalink'             => $product->get_permalink(),
466
-			'date_created'          => wc_rest_prepare_date_response( $product->get_date_created() ),
467
-			'date_modified'         => wc_rest_prepare_date_response( $product->get_date_modified() ),
466
+			'date_created'          => wc_rest_prepare_date_response($product->get_date_created()),
467
+			'date_modified'         => wc_rest_prepare_date_response($product->get_date_modified()),
468 468
 			'type'                  => $product->get_type(),
469 469
 			'status'                => $product->get_status(),
470 470
 			'featured'              => $product->is_featured(),
471 471
 			'catalog_visibility'    => $product->get_catalog_visibility(),
472
-			'description'           => wpautop( do_shortcode( $product->get_description() ) ),
473
-			'short_description'     => apply_filters( 'woocommerce_short_description', $product->get_short_description() ),
472
+			'description'           => wpautop(do_shortcode($product->get_description())),
473
+			'short_description'     => apply_filters('woocommerce_short_description', $product->get_short_description()),
474 474
 			'sku'                   => $product->get_sku(),
475 475
 			'price'                 => $product->get_price(),
476 476
 			'regular_price'         => $product->get_regular_price(),
477 477
 			'sale_price'            => $product->get_sale_price() ? $product->get_sale_price() : '',
478
-			'date_on_sale_from'     => $product->get_date_on_sale_from() ? date( 'Y-m-d', $product->get_date_on_sale_from()->getTimestamp() ) : '',
479
-			'date_on_sale_to'       => $product->get_date_on_sale_to() ? date( 'Y-m-d', $product->get_date_on_sale_to()->getTimestamp() ) : '',
478
+			'date_on_sale_from'     => $product->get_date_on_sale_from() ? date('Y-m-d', $product->get_date_on_sale_from()->getTimestamp()) : '',
479
+			'date_on_sale_to'       => $product->get_date_on_sale_to() ? date('Y-m-d', $product->get_date_on_sale_to()->getTimestamp()) : '',
480 480
 			'price_html'            => $product->get_price_html(),
481 481
 			'on_sale'               => $product->is_on_sale(),
482 482
 			'purchasable'           => $product->is_purchasable(),
483 483
 			'total_sales'           => $product->get_total_sales(),
484 484
 			'virtual'               => $product->is_virtual(),
485 485
 			'downloadable'          => $product->is_downloadable(),
486
-			'downloads'             => $this->get_downloads( $product ),
486
+			'downloads'             => $this->get_downloads($product),
487 487
 			'download_limit'        => $product->get_download_limit(),
488 488
 			'download_expiry'       => $product->get_download_expiry(),
489 489
 			'download_type'         => 'standard',
490
-			'external_url'          => $product->is_type( 'external' ) ? $product->get_product_url() : '',
491
-			'button_text'           => $product->is_type( 'external' ) ? $product->get_button_text() : '',
490
+			'external_url'          => $product->is_type('external') ? $product->get_product_url() : '',
491
+			'button_text'           => $product->is_type('external') ? $product->get_button_text() : '',
492 492
 			'tax_status'            => $product->get_tax_status(),
493 493
 			'tax_class'             => $product->get_tax_class(),
494 494
 			'manage_stock'          => $product->managing_stock(),
@@ -509,18 +509,18 @@  discard block
 block discarded – undo
509 509
 			'shipping_class'        => $product->get_shipping_class(),
510 510
 			'shipping_class_id'     => $product->get_shipping_class_id(),
511 511
 			'reviews_allowed'       => $product->get_reviews_allowed(),
512
-			'average_rating'        => wc_format_decimal( $product->get_average_rating(), 2 ),
512
+			'average_rating'        => wc_format_decimal($product->get_average_rating(), 2),
513 513
 			'rating_count'          => $product->get_rating_count(),
514
-			'related_ids'           => array_map( 'absint', array_values( wc_get_related_products( $product->get_id() ) ) ),
515
-			'upsell_ids'            => array_map( 'absint', $product->get_upsell_ids() ),
516
-			'cross_sell_ids'        => array_map( 'absint', $product->get_cross_sell_ids() ),
514
+			'related_ids'           => array_map('absint', array_values(wc_get_related_products($product->get_id()))),
515
+			'upsell_ids'            => array_map('absint', $product->get_upsell_ids()),
516
+			'cross_sell_ids'        => array_map('absint', $product->get_cross_sell_ids()),
517 517
 			'parent_id'             => $product->get_parent_id(),
518
-			'purchase_note'         => wpautop( do_shortcode( wp_kses_post( $product->get_purchase_note() ) ) ),
519
-			'categories'            => $this->get_taxonomy_terms( $product ),
520
-			'tags'                  => $this->get_taxonomy_terms( $product, 'tag' ),
521
-			'images'                => $this->get_images( $product ),
522
-			'attributes'            => $this->get_attributes( $product ),
523
-			'default_attributes'    => $this->get_default_attributes( $product ),
518
+			'purchase_note'         => wpautop(do_shortcode(wp_kses_post($product->get_purchase_note()))),
519
+			'categories'            => $this->get_taxonomy_terms($product),
520
+			'tags'                  => $this->get_taxonomy_terms($product, 'tag'),
521
+			'images'                => $this->get_images($product),
522
+			'attributes'            => $this->get_attributes($product),
523
+			'default_attributes'    => $this->get_default_attributes($product),
524 524
 			'variations'            => array(),
525 525
 			'grouped_products'      => array(),
526 526
 			'menu_order'            => $product->get_menu_order(),
@@ -535,32 +535,32 @@  discard block
 block discarded – undo
535 535
 	 * @param WC_Product $product Product instance.
536 536
 	 * @return array
537 537
 	 */
538
-	protected function get_variation_data( $product ) {
538
+	protected function get_variation_data($product) {
539 539
 		$variations = array();
540 540
 
541
-		foreach ( $product->get_children() as $child_id ) {
542
-			$variation = wc_get_product( $child_id );
543
-			if ( ! $variation || ! $variation->exists() ) {
541
+		foreach ($product->get_children() as $child_id) {
542
+			$variation = wc_get_product($child_id);
543
+			if ( ! $variation || ! $variation->exists()) {
544 544
 				continue;
545 545
 			}
546 546
 
547 547
 			$variations[] = array(
548 548
 				'id'                 => $variation->get_id(),
549
-				'date_created'       => wc_rest_prepare_date_response( $variation->get_date_created() ),
550
-				'date_modified'      => wc_rest_prepare_date_response( $variation->get_date_modified() ),
549
+				'date_created'       => wc_rest_prepare_date_response($variation->get_date_created()),
550
+				'date_modified'      => wc_rest_prepare_date_response($variation->get_date_modified()),
551 551
 				'permalink'          => $variation->get_permalink(),
552 552
 				'sku'                => $variation->get_sku(),
553 553
 				'price'              => $variation->get_price(),
554 554
 				'regular_price'      => $variation->get_regular_price(),
555 555
 				'sale_price'         => $variation->get_sale_price(),
556
-				'date_on_sale_from'  => $variation->get_date_on_sale_from() ? date( 'Y-m-d', $variation->get_date_on_sale_from()->getTimestamp() ) : '',
557
-				'date_on_sale_to'    => $variation->get_date_on_sale_to() ? date( 'Y-m-d', $variation->get_date_on_sale_to()->getTimestamp() ) : '',
556
+				'date_on_sale_from'  => $variation->get_date_on_sale_from() ? date('Y-m-d', $variation->get_date_on_sale_from()->getTimestamp()) : '',
557
+				'date_on_sale_to'    => $variation->get_date_on_sale_to() ? date('Y-m-d', $variation->get_date_on_sale_to()->getTimestamp()) : '',
558 558
 				'on_sale'            => $variation->is_on_sale(),
559 559
 				'purchasable'        => $variation->is_purchasable(),
560 560
 				'visible'            => $variation->is_visible(),
561 561
 				'virtual'            => $variation->is_virtual(),
562 562
 				'downloadable'       => $variation->is_downloadable(),
563
-				'downloads'          => $this->get_downloads( $variation ),
563
+				'downloads'          => $this->get_downloads($variation),
564 564
 				'download_limit'     => '' !== $variation->get_download_limit() ? (int) $variation->get_download_limit() : -1,
565 565
 				'download_expiry'    => '' !== $variation->get_download_expiry() ? (int) $variation->get_download_expiry() : -1,
566 566
 				'tax_status'         => $variation->get_tax_status(),
@@ -579,8 +579,8 @@  discard block
 block discarded – undo
579 579
 				),
580 580
 				'shipping_class'     => $variation->get_shipping_class(),
581 581
 				'shipping_class_id'  => $variation->get_shipping_class_id(),
582
-				'image'              => $this->get_images( $variation ),
583
-				'attributes'         => $this->get_attributes( $variation ),
582
+				'image'              => $this->get_images($variation),
583
+				'attributes'         => $this->get_attributes($variation),
584 584
 			);
585 585
 		}
586 586
 
@@ -594,28 +594,28 @@  discard block
 block discarded – undo
594 594
 	 * @param WP_REST_Request $request Request object.
595 595
 	 * @return WP_REST_Response
596 596
 	 */
597
-	public function prepare_item_for_response( $post, $request ) {
598
-		$product = wc_get_product( $post );
599
-		$data    = $this->get_product_data( $product );
597
+	public function prepare_item_for_response($post, $request) {
598
+		$product = wc_get_product($post);
599
+		$data    = $this->get_product_data($product);
600 600
 
601 601
 		// Add variations to variable products.
602
-		if ( $product->is_type( 'variable' ) && $product->has_child() ) {
603
-			$data['variations'] = $this->get_variation_data( $product );
602
+		if ($product->is_type('variable') && $product->has_child()) {
603
+			$data['variations'] = $this->get_variation_data($product);
604 604
 		}
605 605
 
606 606
 		// Add grouped products data.
607
-		if ( $product->is_type( 'grouped' ) && $product->has_child() ) {
607
+		if ($product->is_type('grouped') && $product->has_child()) {
608 608
 			$data['grouped_products'] = $product->get_children();
609 609
 		}
610 610
 
611
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
612
-		$data    = $this->add_additional_fields_to_object( $data, $request );
613
-		$data    = $this->filter_response_by_context( $data, $context );
611
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
612
+		$data    = $this->add_additional_fields_to_object($data, $request);
613
+		$data    = $this->filter_response_by_context($data, $context);
614 614
 
615 615
 		// Wrap the data in a response object.
616
-		$response = rest_ensure_response( $data );
616
+		$response = rest_ensure_response($data);
617 617
 
618
-		$response->add_links( $this->prepare_links( $product, $request ) );
618
+		$response->add_links($this->prepare_links($product, $request));
619 619
 
620 620
 		/**
621 621
 		 * Filter the data for a response.
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 		 * @param WP_Post            $post       Post object.
628 628
 		 * @param WP_REST_Request    $request    Request object.
629 629
 		 */
630
-		return apply_filters( "woocommerce_rest_prepare_{$this->post_type}", $response, $post, $request );
630
+		return apply_filters("woocommerce_rest_prepare_{$this->post_type}", $response, $post, $request);
631 631
 	}
632 632
 
633 633
 	/**
@@ -637,19 +637,19 @@  discard block
 block discarded – undo
637 637
 	 * @param WP_REST_Request $request Request object.
638 638
 	 * @return array Links for the given product.
639 639
 	 */
640
-	protected function prepare_links( $product, $request ) {
640
+	protected function prepare_links($product, $request) {
641 641
 		$links = array(
642 642
 			'self' => array(
643
-				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $product->get_id() ) ),
643
+				'href' => rest_url(sprintf('/%s/%s/%d', $this->namespace, $this->rest_base, $product->get_id())),
644 644
 			),
645 645
 			'collection' => array(
646
-				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
646
+				'href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)),
647 647
 			),
648 648
 		);
649 649
 
650
-		if ( $product->get_parent_id() ) {
650
+		if ($product->get_parent_id()) {
651 651
 			$links['up'] = array(
652
-				'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $product->get_parent_id() ) ),
652
+				'href' => rest_url(sprintf('/%s/products/%d', $this->namespace, $product->get_parent_id())),
653 653
 			);
654 654
 		}
655 655
 
@@ -662,57 +662,57 @@  discard block
 block discarded – undo
662 662
 	 * @param WP_REST_Request $request Request object.
663 663
 	 * @return WP_Error|stdClass $data Post object.
664 664
 	 */
665
-	protected function prepare_item_for_database( $request ) {
666
-		$id = isset( $request['id'] ) ? absint( $request['id'] ) : 0;
665
+	protected function prepare_item_for_database($request) {
666
+		$id = isset($request['id']) ? absint($request['id']) : 0;
667 667
 
668 668
 		// Type is the most important part here because we need to be using the correct class and methods.
669
-		if ( isset( $request['type'] ) ) {
670
-			$classname = WC_Product_Factory::get_classname_from_product_type( $request['type'] );
669
+		if (isset($request['type'])) {
670
+			$classname = WC_Product_Factory::get_classname_from_product_type($request['type']);
671 671
 
672
-			if ( ! class_exists( $classname ) ) {
672
+			if ( ! class_exists($classname)) {
673 673
 				$classname = 'WC_Product_Simple';
674 674
 			}
675 675
 
676
-			$product = new $classname( $id );
677
-		} elseif ( isset( $request['id'] ) ) {
678
-			$product = wc_get_product( $id );
676
+			$product = new $classname($id);
677
+		} elseif (isset($request['id'])) {
678
+			$product = wc_get_product($id);
679 679
 		} else {
680 680
 			$product = new WC_Product_Simple();
681 681
 		}
682 682
 
683 683
 		// Post title.
684
-		if ( isset( $request['name'] ) ) {
685
-			$product->set_name( wp_filter_post_kses( $request['name'] ) );
684
+		if (isset($request['name'])) {
685
+			$product->set_name(wp_filter_post_kses($request['name']));
686 686
 		}
687 687
 
688 688
 		// Post content.
689
-		if ( isset( $request['description'] ) ) {
690
-			$product->set_description( wp_filter_post_kses( $request['description'] ) );
689
+		if (isset($request['description'])) {
690
+			$product->set_description(wp_filter_post_kses($request['description']));
691 691
 		}
692 692
 
693 693
 		// Post excerpt.
694
-		if ( isset( $request['short_description'] ) ) {
695
-			$product->set_short_description( wp_filter_post_kses( $request['short_description'] ) );
694
+		if (isset($request['short_description'])) {
695
+			$product->set_short_description(wp_filter_post_kses($request['short_description']));
696 696
 		}
697 697
 
698 698
 		// Post status.
699
-		if ( isset( $request['status'] ) ) {
700
-			$product->set_status( get_post_status_object( $request['status'] ) ? $request['status'] : 'draft' );
699
+		if (isset($request['status'])) {
700
+			$product->set_status(get_post_status_object($request['status']) ? $request['status'] : 'draft');
701 701
 		}
702 702
 
703 703
 		// Post slug.
704
-		if ( isset( $request['slug'] ) ) {
705
-			$product->set_slug( $request['slug'] );
704
+		if (isset($request['slug'])) {
705
+			$product->set_slug($request['slug']);
706 706
 		}
707 707
 
708 708
 		// Menu order.
709
-		if ( isset( $request['menu_order'] ) ) {
710
-			$product->set_menu_order( $request['menu_order'] );
709
+		if (isset($request['menu_order'])) {
710
+			$product->set_menu_order($request['menu_order']);
711 711
 		}
712 712
 
713 713
 		// Comment status.
714
-		if ( isset( $request['reviews_allowed'] ) ) {
715
-			$product->set_reviews_allowed( $request['reviews_allowed'] );
714
+		if (isset($request['reviews_allowed'])) {
715
+			$product->set_reviews_allowed($request['reviews_allowed']);
716 716
 		}
717 717
 
718 718
 		/**
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 		 *                                       for inserting or updating the database.
726 726
 		 * @param WP_REST_Request $request       Request object.
727 727
 		 */
728
-		return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}", $product, $request );
728
+		return apply_filters("woocommerce_rest_pre_insert_{$this->post_type}", $product, $request);
729 729
 	}
730 730
 
731 731
 	/**
@@ -734,18 +734,18 @@  discard block
 block discarded – undo
734 734
 	 * @param WP_REST_Request $request Full details about the request.
735 735
 	 * @return WP_Error|WP_REST_Response
736 736
 	 */
737
-	public function create_item( $request ) {
738
-		if ( ! empty( $request['id'] ) ) {
739
-			return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
737
+	public function create_item($request) {
738
+		if ( ! empty($request['id'])) {
739
+			return new WP_Error("woocommerce_rest_{$this->post_type}_exists", sprintf(__('Cannot create existing %s.', 'woocommerce'), $this->post_type), array('status' => 400));
740 740
 		}
741 741
 
742 742
 		$product_id = 0;
743 743
 
744 744
 		try {
745
-			$product_id = $this->save_product( $request );
746
-			$post       = get_post( $product_id );
747
-			$this->update_additional_fields_for_object( $post, $request );
748
-			$this->update_post_meta_fields( $post, $request );
745
+			$product_id = $this->save_product($request);
746
+			$post       = get_post($product_id);
747
+			$this->update_additional_fields_for_object($post, $request);
748
+			$this->update_post_meta_fields($post, $request);
749 749
 
750 750
 			/**
751 751
 			 * Fires after a single item is created or updated via the REST API.
@@ -754,20 +754,20 @@  discard block
 block discarded – undo
754 754
 			 * @param WP_REST_Request $request   Request object.
755 755
 			 * @param boolean         $creating  True when creating item, false when updating.
756 756
 			 */
757
-			do_action( 'woocommerce_rest_insert_product', $post, $request, true );
758
-			$request->set_param( 'context', 'edit' );
759
-			$response = $this->prepare_item_for_response( $post, $request );
760
-			$response = rest_ensure_response( $response );
761
-			$response->set_status( 201 );
762
-			$response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $post->ID ) ) );
757
+			do_action('woocommerce_rest_insert_product', $post, $request, true);
758
+			$request->set_param('context', 'edit');
759
+			$response = $this->prepare_item_for_response($post, $request);
760
+			$response = rest_ensure_response($response);
761
+			$response->set_status(201);
762
+			$response->header('Location', rest_url(sprintf('/%s/%s/%d', $this->namespace, $this->rest_base, $post->ID)));
763 763
 
764 764
 			return $response;
765
-		} catch ( WC_Data_Exception $e ) {
766
-			$this->delete_post( $product_id );
767
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
768
-		} catch ( WC_REST_Exception $e ) {
769
-			$this->delete_post( $product_id );
770
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
765
+		} catch (WC_Data_Exception $e) {
766
+			$this->delete_post($product_id);
767
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), $e->getErrorData());
768
+		} catch (WC_REST_Exception $e) {
769
+			$this->delete_post($product_id);
770
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
771 771
 		}
772 772
 	}
773 773
 
@@ -777,18 +777,18 @@  discard block
 block discarded – undo
777 777
 	 * @param WP_REST_Request $request Full details about the request.
778 778
 	 * @return WP_Error|WP_REST_Response
779 779
 	 */
780
-	public function update_item( $request ) {
780
+	public function update_item($request) {
781 781
 		$post_id = (int) $request['id'];
782 782
 
783
-		if ( empty( $post_id ) || get_post_type( $post_id ) !== $this->post_type ) {
784
-			return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
783
+		if (empty($post_id) || get_post_type($post_id) !== $this->post_type) {
784
+			return new WP_Error("woocommerce_rest_{$this->post_type}_invalid_id", __('ID is invalid.', 'woocommerce'), array('status' => 400));
785 785
 		}
786 786
 
787 787
 		try {
788
-			$product_id = $this->save_product( $request );
789
-			$post       = get_post( $product_id );
790
-			$this->update_additional_fields_for_object( $post, $request );
791
-			$this->update_post_meta_fields( $post, $request );
788
+			$product_id = $this->save_product($request);
789
+			$post       = get_post($product_id);
790
+			$this->update_additional_fields_for_object($post, $request);
791
+			$this->update_post_meta_fields($post, $request);
792 792
 
793 793
 			/**
794 794
 			 * Fires after a single item is created or updated via the REST API.
@@ -797,15 +797,15 @@  discard block
 block discarded – undo
797 797
 			 * @param WP_REST_Request $request   Request object.
798 798
 			 * @param boolean         $creating  True when creating item, false when updating.
799 799
 			 */
800
-			do_action( 'woocommerce_rest_insert_product', $post, $request, false );
801
-			$request->set_param( 'context', 'edit' );
802
-			$response = $this->prepare_item_for_response( $post, $request );
800
+			do_action('woocommerce_rest_insert_product', $post, $request, false);
801
+			$request->set_param('context', 'edit');
802
+			$response = $this->prepare_item_for_response($post, $request);
803 803
 
804
-			return rest_ensure_response( $response );
805
-		} catch ( WC_Data_Exception $e ) {
806
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
807
-		} catch ( WC_REST_Exception $e ) {
808
-			return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
804
+			return rest_ensure_response($response);
805
+		} catch (WC_Data_Exception $e) {
806
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), $e->getErrorData());
807
+		} catch (WC_REST_Exception $e) {
808
+			return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
809 809
 		}
810 810
 	}
811 811
 
@@ -815,8 +815,8 @@  discard block
 block discarded – undo
815 815
 	 * @param WP_REST_Request $request Full details about the request.
816 816
 	 * @return int
817 817
 	 */
818
-	public function save_product( $request ) {
819
-		$product = $this->prepare_item_for_database( $request );
818
+	public function save_product($request) {
819
+		$product = $this->prepare_item_for_database($request);
820 820
 		return $product->save();
821 821
 	}
822 822
 
@@ -828,10 +828,10 @@  discard block
 block discarded – undo
828 828
 	 * @param array $images
829 829
 	 * @throws WC_REST_Exception
830 830
 	 */
831
-	protected function save_product_images( $product_id, $images ) {
832
-		$product = wc_get_product( $product_id );
831
+	protected function save_product_images($product_id, $images) {
832
+		$product = wc_get_product($product_id);
833 833
 
834
-		return set_product_images( $product, $images );
834
+		return set_product_images($product, $images);
835 835
 	}
836 836
 
837 837
 	/**
@@ -842,54 +842,54 @@  discard block
 block discarded – undo
842 842
 	 * @param array      $images  Images data.
843 843
 	 * @return WC_Product
844 844
 	 */
845
-	protected function set_product_images( $product, $images ) {
846
-		if ( is_array( $images ) ) {
845
+	protected function set_product_images($product, $images) {
846
+		if (is_array($images)) {
847 847
 			$gallery = array();
848 848
 
849
-			foreach ( $images as $image ) {
850
-				$attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0;
849
+			foreach ($images as $image) {
850
+				$attachment_id = isset($image['id']) ? absint($image['id']) : 0;
851 851
 
852
-				if ( 0 === $attachment_id && isset( $image['src'] ) ) {
853
-					$upload = wc_rest_upload_image_from_url( esc_url_raw( $image['src'] ) );
852
+				if (0 === $attachment_id && isset($image['src'])) {
853
+					$upload = wc_rest_upload_image_from_url(esc_url_raw($image['src']));
854 854
 
855
-					if ( is_wp_error( $upload ) ) {
856
-						if ( ! apply_filters( 'woocommerce_rest_suppress_image_upload_error', false, $upload, $product->get_id(), $images ) ) {
857
-							throw new WC_REST_Exception( 'woocommerce_product_image_upload_error', $upload->get_error_message(), 400 );
855
+					if (is_wp_error($upload)) {
856
+						if ( ! apply_filters('woocommerce_rest_suppress_image_upload_error', false, $upload, $product->get_id(), $images)) {
857
+							throw new WC_REST_Exception('woocommerce_product_image_upload_error', $upload->get_error_message(), 400);
858 858
 						} else {
859 859
 							continue;
860 860
 						}
861 861
 					}
862 862
 
863
-					$attachment_id = wc_rest_set_uploaded_image_as_attachment( $upload, $product->get_id() );
863
+					$attachment_id = wc_rest_set_uploaded_image_as_attachment($upload, $product->get_id());
864 864
 				}
865 865
 
866
-				if ( ! wp_attachment_is_image( $attachment_id ) ) {
867
-					throw new WC_REST_Exception( 'woocommerce_product_invalid_image_id', sprintf( __( '#%s is an invalid image ID.', 'woocommerce' ), $attachment_id ), 400 );
866
+				if ( ! wp_attachment_is_image($attachment_id)) {
867
+					throw new WC_REST_Exception('woocommerce_product_invalid_image_id', sprintf(__('#%s is an invalid image ID.', 'woocommerce'), $attachment_id), 400);
868 868
 				}
869 869
 
870
-				if ( isset( $image['position'] ) && 0 === absint( $image['position'] ) ) {
871
-					$product->set_image_id( $attachment_id );
870
+				if (isset($image['position']) && 0 === absint($image['position'])) {
871
+					$product->set_image_id($attachment_id);
872 872
 				} else {
873 873
 					$gallery[] = $attachment_id;
874 874
 				}
875 875
 
876 876
 				// Set the image alt if present.
877
-				if ( ! empty( $image['alt'] ) ) {
878
-					update_post_meta( $attachment_id, '_wp_attachment_image_alt', wc_clean( $image['alt'] ) );
877
+				if ( ! empty($image['alt'])) {
878
+					update_post_meta($attachment_id, '_wp_attachment_image_alt', wc_clean($image['alt']));
879 879
 				}
880 880
 
881 881
 				// Set the image name if present.
882
-				if ( ! empty( $image['name'] ) ) {
883
-					wp_update_post( array( 'ID' => $attachment_id, 'post_title' => $image['name'] ) );
882
+				if ( ! empty($image['name'])) {
883
+					wp_update_post(array('ID' => $attachment_id, 'post_title' => $image['name']));
884 884
 				}
885 885
 			}
886 886
 
887
-			if ( ! empty( $gallery ) ) {
888
-				$product->set_gallery_image_ids( $gallery );
887
+			if ( ! empty($gallery)) {
888
+				$product->set_gallery_image_ids($gallery);
889 889
 			}
890 890
 		} else {
891
-			$product->set_image_id( '' );
892
-			$product->set_gallery_image_ids( array() );
891
+			$product->set_image_id('');
892
+			$product->set_gallery_image_ids(array());
893 893
 		}
894 894
 
895 895
 		return $product;
@@ -902,39 +902,39 @@  discard block
 block discarded – undo
902 902
 	 * @param array      $data    Shipping data.
903 903
 	 * @return WC_Product
904 904
 	 */
905
-	protected function save_product_shipping_data( $product, $data ) {
905
+	protected function save_product_shipping_data($product, $data) {
906 906
 		// Virtual.
907
-		if ( isset( $data['virtual'] ) && true === $data['virtual'] ) {
908
-			$product->set_weight( '' );
909
-			$product->set_height( '' );
910
-			$product->set_length( '' );
911
-			$product->set_width( '' );
907
+		if (isset($data['virtual']) && true === $data['virtual']) {
908
+			$product->set_weight('');
909
+			$product->set_height('');
910
+			$product->set_length('');
911
+			$product->set_width('');
912 912
 		} else {
913
-			if ( isset( $data['weight'] ) ) {
914
-				$product->set_weight( $data['weight'] );
913
+			if (isset($data['weight'])) {
914
+				$product->set_weight($data['weight']);
915 915
 			}
916 916
 
917 917
 			// Height.
918
-			if ( isset( $data['dimensions']['height'] ) ) {
919
-				$product->set_height( $data['dimensions']['height'] );
918
+			if (isset($data['dimensions']['height'])) {
919
+				$product->set_height($data['dimensions']['height']);
920 920
 			}
921 921
 
922 922
 			// Width.
923
-			if ( isset( $data['dimensions']['width'] ) ) {
924
-				$product->set_width( $data['dimensions']['width'] );
923
+			if (isset($data['dimensions']['width'])) {
924
+				$product->set_width($data['dimensions']['width']);
925 925
 			}
926 926
 
927 927
 			// Length.
928
-			if ( isset( $data['dimensions']['length'] ) ) {
929
-				$product->set_length( $data['dimensions']['length'] );
928
+			if (isset($data['dimensions']['length'])) {
929
+				$product->set_length($data['dimensions']['length']);
930 930
 			}
931 931
 		}
932 932
 
933 933
 		// Shipping class.
934
-		if ( isset( $data['shipping_class'] ) ) {
934
+		if (isset($data['shipping_class'])) {
935 935
 			$data_store        = $product->get_data_store();
936
-			$shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $data['shipping_class'] ) );
937
-			$product->set_shipping_class_id( $shipping_class_id );
936
+			$shipping_class_id = $data_store->get_shipping_class_id_by_slug(wc_clean($data['shipping_class']));
937
+			$product->set_shipping_class_id($shipping_class_id);
938 938
 		}
939 939
 
940 940
 		return $product;
@@ -948,24 +948,24 @@  discard block
 block discarded – undo
948 948
 	 * @param int        $deprecated Deprecated since 3.0.
949 949
 	 * @return WC_Product
950 950
 	 */
951
-	protected function save_downloadable_files( $product, $downloads, $deprecated = 0 ) {
952
-		if ( $deprecated ) {
953
-			wc_deprecated_argument( 'variation_id', '3.0', 'save_downloadable_files() not requires a variation_id anymore.' );
951
+	protected function save_downloadable_files($product, $downloads, $deprecated = 0) {
952
+		if ($deprecated) {
953
+			wc_deprecated_argument('variation_id', '3.0', 'save_downloadable_files() not requires a variation_id anymore.');
954 954
 		}
955 955
 
956 956
 		$files = array();
957
-		foreach ( $downloads as $key => $file ) {
958
-			if ( empty( $file['file'] ) ) {
957
+		foreach ($downloads as $key => $file) {
958
+			if (empty($file['file'])) {
959 959
 				continue;
960 960
 			}
961 961
 
962 962
 			$download = new WC_Product_Download();
963
-			$download->set_id( ! empty( $file['id'] ) ? $file['id'] : wp_generate_uuid4() );
964
-			$download->set_name( $file['name'] ? $file['name'] : wc_get_filename_from_url( $file['file'] ) );
965
-			$download->set_file( apply_filters( 'woocommerce_file_download_path', $file['file'], $product, $key ) );
966
-			$files[]  = $download;
963
+			$download->set_id( ! empty($file['id']) ? $file['id'] : wp_generate_uuid4());
964
+			$download->set_name($file['name'] ? $file['name'] : wc_get_filename_from_url($file['file']));
965
+			$download->set_file(apply_filters('woocommerce_file_download_path', $file['file'], $product, $key));
966
+			$files[] = $download;
967 967
 		}
968
-		$product->set_downloads( $files );
968
+		$product->set_downloads($files);
969 969
 
970 970
 		return $product;
971 971
 	}
@@ -978,13 +978,13 @@  discard block
 block discarded – undo
978 978
 	 * @param string     $taxonomy Taxonomy name.
979 979
 	 * @return WC_Product
980 980
 	 */
981
-	protected function save_taxonomy_terms( $product, $terms, $taxonomy = 'cat' ) {
982
-		$term_ids = wp_list_pluck( $terms, 'id' );
981
+	protected function save_taxonomy_terms($product, $terms, $taxonomy = 'cat') {
982
+		$term_ids = wp_list_pluck($terms, 'id');
983 983
 
984
-		if ( 'cat' === $taxonomy ) {
985
-			$product->set_category_ids( $term_ids );
986
-		} elseif ( 'tag' === $taxonomy ) {
987
-			$product->set_tag_ids( $term_ids );
984
+		if ('cat' === $taxonomy) {
985
+			$product->set_category_ids($term_ids);
986
+		} elseif ('tag' === $taxonomy) {
987
+			$product->set_tag_ids($term_ids);
988 988
 		}
989 989
 
990 990
 		return $product;
@@ -999,52 +999,52 @@  discard block
 block discarded – undo
999 999
 	 * @param WP_REST_Request $request Request data.
1000 1000
 	 * @return WC_Product
1001 1001
 	 */
1002
-	protected function save_default_attributes( $product, $request ) {
1003
-		if ( isset( $request['default_attributes'] ) && is_array( $request['default_attributes'] ) ) {
1002
+	protected function save_default_attributes($product, $request) {
1003
+		if (isset($request['default_attributes']) && is_array($request['default_attributes'])) {
1004 1004
 			$attributes         = $product->get_attributes();
1005 1005
 			$default_attributes = array();
1006 1006
 
1007
-			foreach ( $request['default_attributes'] as $attribute ) {
1007
+			foreach ($request['default_attributes'] as $attribute) {
1008 1008
 				$attribute_id   = 0;
1009 1009
 				$attribute_name = '';
1010 1010
 
1011 1011
 				// Check ID for global attributes or name for product attributes.
1012
-				if ( ! empty( $attribute['id'] ) ) {
1013
-					$attribute_id   = absint( $attribute['id'] );
1014
-					$attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id );
1015
-				} elseif ( ! empty( $attribute['name'] ) ) {
1016
-					$attribute_name = sanitize_title( $attribute['name'] );
1012
+				if ( ! empty($attribute['id'])) {
1013
+					$attribute_id   = absint($attribute['id']);
1014
+					$attribute_name = wc_attribute_taxonomy_name_by_id($attribute_id);
1015
+				} elseif ( ! empty($attribute['name'])) {
1016
+					$attribute_name = sanitize_title($attribute['name']);
1017 1017
 				}
1018 1018
 
1019
-				if ( ! $attribute_id && ! $attribute_name ) {
1019
+				if ( ! $attribute_id && ! $attribute_name) {
1020 1020
 					continue;
1021 1021
 				}
1022 1022
 
1023
-				if ( isset( $attributes[ $attribute_name ] ) ) {
1024
-					$_attribute = $attributes[ $attribute_name ];
1023
+				if (isset($attributes[$attribute_name])) {
1024
+					$_attribute = $attributes[$attribute_name];
1025 1025
 
1026
-					if ( $_attribute['is_variation'] ) {
1027
-						$value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : '';
1026
+					if ($_attribute['is_variation']) {
1027
+						$value = isset($attribute['option']) ? wc_clean(stripslashes($attribute['option'])) : '';
1028 1028
 
1029
-						if ( ! empty( $_attribute['is_taxonomy'] ) ) {
1029
+						if ( ! empty($_attribute['is_taxonomy'])) {
1030 1030
 							// If dealing with a taxonomy, we need to get the slug from the name posted to the API.
1031
-							$term = get_term_by( 'name', $value, $attribute_name );
1031
+							$term = get_term_by('name', $value, $attribute_name);
1032 1032
 
1033
-							if ( $term && ! is_wp_error( $term ) ) {
1033
+							if ($term && ! is_wp_error($term)) {
1034 1034
 								$value = $term->slug;
1035 1035
 							} else {
1036
-								$value = sanitize_title( $value );
1036
+								$value = sanitize_title($value);
1037 1037
 							}
1038 1038
 						}
1039 1039
 
1040
-						if ( $value ) {
1041
-							$default_attributes[ $attribute_name ] = $value;
1040
+						if ($value) {
1041
+							$default_attributes[$attribute_name] = $value;
1042 1042
 						}
1043 1043
 					}
1044 1044
 				}
1045 1045
 			}
1046 1046
 
1047
-			$product->set_default_attributes( $default_attributes );
1047
+			$product->set_default_attributes($default_attributes);
1048 1048
 		}
1049 1049
 
1050 1050
 		return $product;
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 	 * @return bool
1060 1060
 	 * @throws WC_REST_Exception
1061 1061
 	 */
1062
-	protected function save_product_meta( $product, $request ) {
1063
-		$product = $this->set_product_meta( $product, $request );
1062
+	protected function save_product_meta($product, $request) {
1063
+		$product = $this->set_product_meta($product, $request);
1064 1064
 		$product->save();
1065 1065
 
1066 1066
 		return true;
@@ -1074,281 +1074,281 @@  discard block
 block discarded – undo
1074 1074
 	 * @param WP_REST_Request $request Request data.
1075 1075
 	 * @return WC_Product
1076 1076
 	 */
1077
-	protected function set_product_meta( $product, $request ) {
1077
+	protected function set_product_meta($product, $request) {
1078 1078
 		// Virtual.
1079
-		if ( isset( $request['virtual'] ) ) {
1080
-			$product->set_virtual( $request['virtual'] );
1079
+		if (isset($request['virtual'])) {
1080
+			$product->set_virtual($request['virtual']);
1081 1081
 		}
1082 1082
 
1083 1083
 		// Tax status.
1084
-		if ( isset( $request['tax_status'] ) ) {
1085
-			$product->set_tax_status( $request['tax_status'] );
1084
+		if (isset($request['tax_status'])) {
1085
+			$product->set_tax_status($request['tax_status']);
1086 1086
 		}
1087 1087
 
1088 1088
 		// Tax Class.
1089
-		if ( isset( $request['tax_class'] ) ) {
1090
-			$product->set_tax_class( $request['tax_class'] );
1089
+		if (isset($request['tax_class'])) {
1090
+			$product->set_tax_class($request['tax_class']);
1091 1091
 		}
1092 1092
 
1093 1093
 		// Catalog Visibility.
1094
-		if ( isset( $request['catalog_visibility'] ) ) {
1095
-			$product->set_catalog_visibility( $request['catalog_visibility'] );
1094
+		if (isset($request['catalog_visibility'])) {
1095
+			$product->set_catalog_visibility($request['catalog_visibility']);
1096 1096
 		}
1097 1097
 
1098 1098
 		// Purchase Note.
1099
-		if ( isset( $request['purchase_note'] ) ) {
1100
-			$product->set_purchase_note( wp_kses_post( wp_unslash( $request['purchase_note'] ) ) );
1099
+		if (isset($request['purchase_note'])) {
1100
+			$product->set_purchase_note(wp_kses_post(wp_unslash($request['purchase_note'])));
1101 1101
 		}
1102 1102
 
1103 1103
 		// Featured Product.
1104
-		if ( isset( $request['featured'] ) ) {
1105
-			$product->set_featured( $request['featured'] );
1104
+		if (isset($request['featured'])) {
1105
+			$product->set_featured($request['featured']);
1106 1106
 		}
1107 1107
 
1108 1108
 		// Shipping data.
1109
-		$product = $this->save_product_shipping_data( $product, $request );
1109
+		$product = $this->save_product_shipping_data($product, $request);
1110 1110
 
1111 1111
 		// SKU.
1112
-		if ( isset( $request['sku'] ) ) {
1113
-			$product->set_sku( wc_clean( $request['sku'] ) );
1112
+		if (isset($request['sku'])) {
1113
+			$product->set_sku(wc_clean($request['sku']));
1114 1114
 		}
1115 1115
 
1116 1116
 		// Attributes.
1117
-		if ( isset( $request['attributes'] ) ) {
1117
+		if (isset($request['attributes'])) {
1118 1118
 			$attributes = array();
1119 1119
 
1120
-			foreach ( $request['attributes'] as $attribute ) {
1120
+			foreach ($request['attributes'] as $attribute) {
1121 1121
 				$attribute_id   = 0;
1122 1122
 				$attribute_name = '';
1123 1123
 
1124 1124
 				// Check ID for global attributes or name for product attributes.
1125
-				if ( ! empty( $attribute['id'] ) ) {
1126
-					$attribute_id   = absint( $attribute['id'] );
1127
-					$attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id );
1128
-				} elseif ( ! empty( $attribute['name'] ) ) {
1129
-					$attribute_name = wc_clean( $attribute['name'] );
1125
+				if ( ! empty($attribute['id'])) {
1126
+					$attribute_id   = absint($attribute['id']);
1127
+					$attribute_name = wc_attribute_taxonomy_name_by_id($attribute_id);
1128
+				} elseif ( ! empty($attribute['name'])) {
1129
+					$attribute_name = wc_clean($attribute['name']);
1130 1130
 				}
1131 1131
 
1132
-				if ( ! $attribute_id && ! $attribute_name ) {
1132
+				if ( ! $attribute_id && ! $attribute_name) {
1133 1133
 					continue;
1134 1134
 				}
1135 1135
 
1136
-				if ( $attribute_id ) {
1136
+				if ($attribute_id) {
1137 1137
 
1138
-					if ( isset( $attribute['options'] ) ) {
1138
+					if (isset($attribute['options'])) {
1139 1139
 						$options = $attribute['options'];
1140 1140
 
1141
-						if ( ! is_array( $attribute['options'] ) ) {
1141
+						if ( ! is_array($attribute['options'])) {
1142 1142
 							// Text based attributes - Posted values are term names.
1143
-							$options = explode( WC_DELIMITER, $options );
1143
+							$options = explode(WC_DELIMITER, $options);
1144 1144
 						}
1145 1145
 
1146
-						$values = array_map( 'wc_sanitize_term_text_based', $options );
1147
-						$values = array_filter( $values, 'strlen' );
1146
+						$values = array_map('wc_sanitize_term_text_based', $options);
1147
+						$values = array_filter($values, 'strlen');
1148 1148
 					} else {
1149 1149
 						$values = array();
1150 1150
 					}
1151 1151
 
1152
-					if ( ! empty( $values ) ) {
1152
+					if ( ! empty($values)) {
1153 1153
 						// Add attribute to array, but don't set values.
1154 1154
 						$attribute_object = new WC_Product_Attribute();
1155
-						$attribute_object->set_id( $attribute_id );
1156
-						$attribute_object->set_name( $attribute_name );
1157
-						$attribute_object->set_options( $values );
1158
-						$attribute_object->set_position( isset( $attribute['position'] ) ? (string) absint( $attribute['position'] ) : '0' );
1159
-						$attribute_object->set_visible( ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0 );
1160
-						$attribute_object->set_variation( ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0 );
1155
+						$attribute_object->set_id($attribute_id);
1156
+						$attribute_object->set_name($attribute_name);
1157
+						$attribute_object->set_options($values);
1158
+						$attribute_object->set_position(isset($attribute['position']) ? (string) absint($attribute['position']) : '0');
1159
+						$attribute_object->set_visible((isset($attribute['visible']) && $attribute['visible']) ? 1 : 0);
1160
+						$attribute_object->set_variation((isset($attribute['variation']) && $attribute['variation']) ? 1 : 0);
1161 1161
 						$attributes[] = $attribute_object;
1162 1162
 					}
1163
-				} elseif ( isset( $attribute['options'] ) ) {
1163
+				} elseif (isset($attribute['options'])) {
1164 1164
 					// Custom attribute - Add attribute to array and set the values.
1165
-					if ( is_array( $attribute['options'] ) ) {
1165
+					if (is_array($attribute['options'])) {
1166 1166
 						$values = $attribute['options'];
1167 1167
 					} else {
1168
-						$values = explode( WC_DELIMITER, $attribute['options'] );
1168
+						$values = explode(WC_DELIMITER, $attribute['options']);
1169 1169
 					}
1170 1170
 					$attribute_object = new WC_Product_Attribute();
1171
-					$attribute_object->set_name( $attribute_name );
1172
-					$attribute_object->set_options( $values );
1173
-					$attribute_object->set_position( isset( $attribute['position'] ) ? (string) absint( $attribute['position'] ) : '0' );
1174
-					$attribute_object->set_visible( ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0 );
1175
-					$attribute_object->set_variation( ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0 );
1171
+					$attribute_object->set_name($attribute_name);
1172
+					$attribute_object->set_options($values);
1173
+					$attribute_object->set_position(isset($attribute['position']) ? (string) absint($attribute['position']) : '0');
1174
+					$attribute_object->set_visible((isset($attribute['visible']) && $attribute['visible']) ? 1 : 0);
1175
+					$attribute_object->set_variation((isset($attribute['variation']) && $attribute['variation']) ? 1 : 0);
1176 1176
 					$attributes[] = $attribute_object;
1177 1177
 				}
1178 1178
 			}
1179
-			$product->set_attributes( $attributes );
1179
+			$product->set_attributes($attributes);
1180 1180
 		}
1181 1181
 
1182 1182
 		// Sales and prices.
1183
-		if ( in_array( $product->get_type(), array( 'variable', 'grouped' ), true ) ) {
1184
-			$product->set_regular_price( '' );
1185
-			$product->set_sale_price( '' );
1186
-			$product->set_date_on_sale_to( '' );
1187
-			$product->set_date_on_sale_from( '' );
1188
-			$product->set_price( '' );
1183
+		if (in_array($product->get_type(), array('variable', 'grouped'), true)) {
1184
+			$product->set_regular_price('');
1185
+			$product->set_sale_price('');
1186
+			$product->set_date_on_sale_to('');
1187
+			$product->set_date_on_sale_from('');
1188
+			$product->set_price('');
1189 1189
 		} else {
1190 1190
 			// Regular Price.
1191
-			if ( isset( $request['regular_price'] ) ) {
1192
-				$product->set_regular_price( $request['regular_price'] );
1191
+			if (isset($request['regular_price'])) {
1192
+				$product->set_regular_price($request['regular_price']);
1193 1193
 			}
1194 1194
 
1195 1195
 			// Sale Price.
1196
-			if ( isset( $request['sale_price'] ) ) {
1197
-				$product->set_sale_price( $request['sale_price'] );
1196
+			if (isset($request['sale_price'])) {
1197
+				$product->set_sale_price($request['sale_price']);
1198 1198
 			}
1199 1199
 
1200
-			if ( isset( $request['date_on_sale_from'] ) ) {
1201
-				$product->set_date_on_sale_from( $request['date_on_sale_from'] );
1200
+			if (isset($request['date_on_sale_from'])) {
1201
+				$product->set_date_on_sale_from($request['date_on_sale_from']);
1202 1202
 			}
1203 1203
 
1204
-			if ( isset( $request['date_on_sale_to'] ) ) {
1205
-				$product->set_date_on_sale_to( $request['date_on_sale_to'] );
1204
+			if (isset($request['date_on_sale_to'])) {
1205
+				$product->set_date_on_sale_to($request['date_on_sale_to']);
1206 1206
 			}
1207 1207
 		}
1208 1208
 
1209 1209
 		// Product parent ID for groups.
1210
-		if ( isset( $request['parent_id'] ) ) {
1211
-			$product->set_parent_id( $request['parent_id'] );
1210
+		if (isset($request['parent_id'])) {
1211
+			$product->set_parent_id($request['parent_id']);
1212 1212
 		}
1213 1213
 
1214 1214
 		// Sold individually.
1215
-		if ( isset( $request['sold_individually'] ) ) {
1216
-			$product->set_sold_individually( $request['sold_individually'] );
1215
+		if (isset($request['sold_individually'])) {
1216
+			$product->set_sold_individually($request['sold_individually']);
1217 1217
 		}
1218 1218
 
1219 1219
 		// Stock status.
1220
-		if ( isset( $request['in_stock'] ) ) {
1220
+		if (isset($request['in_stock'])) {
1221 1221
 			$stock_status = true === $request['in_stock'] ? 'instock' : 'outofstock';
1222 1222
 		} else {
1223 1223
 			$stock_status = $product->get_stock_status();
1224 1224
 		}
1225 1225
 
1226 1226
 		// Stock data.
1227
-		if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) {
1227
+		if ('yes' === get_option('woocommerce_manage_stock')) {
1228 1228
 			// Manage stock.
1229
-			if ( isset( $request['manage_stock'] ) ) {
1230
-				$product->set_manage_stock( $request['manage_stock'] );
1229
+			if (isset($request['manage_stock'])) {
1230
+				$product->set_manage_stock($request['manage_stock']);
1231 1231
 			}
1232 1232
 
1233 1233
 			// Backorders.
1234
-			if ( isset( $request['backorders'] ) ) {
1235
-				$product->set_backorders( $request['backorders'] );
1234
+			if (isset($request['backorders'])) {
1235
+				$product->set_backorders($request['backorders']);
1236 1236
 			}
1237 1237
 
1238
-			if ( $product->is_type( 'grouped' ) ) {
1239
-				$product->set_manage_stock( 'no' );
1240
-				$product->set_backorders( 'no' );
1241
-				$product->set_stock_quantity( '' );
1242
-				$product->set_stock_status( $stock_status );
1243
-			} elseif ( $product->is_type( 'external' ) ) {
1244
-				$product->set_manage_stock( 'no' );
1245
-				$product->set_backorders( 'no' );
1246
-				$product->set_stock_quantity( '' );
1247
-				$product->set_stock_status( 'instock' );
1248
-			} elseif ( $product->get_manage_stock() ) {
1238
+			if ($product->is_type('grouped')) {
1239
+				$product->set_manage_stock('no');
1240
+				$product->set_backorders('no');
1241
+				$product->set_stock_quantity('');
1242
+				$product->set_stock_status($stock_status);
1243
+			} elseif ($product->is_type('external')) {
1244
+				$product->set_manage_stock('no');
1245
+				$product->set_backorders('no');
1246
+				$product->set_stock_quantity('');
1247
+				$product->set_stock_status('instock');
1248
+			} elseif ($product->get_manage_stock()) {
1249 1249
 				// Stock status is always determined by children so sync later.
1250
-				if ( ! $product->is_type( 'variable' ) ) {
1251
-					$product->set_stock_status( $stock_status );
1250
+				if ( ! $product->is_type('variable')) {
1251
+					$product->set_stock_status($stock_status);
1252 1252
 				}
1253 1253
 
1254 1254
 				// Stock quantity.
1255
-				if ( isset( $request['stock_quantity'] ) ) {
1256
-					$product->set_stock_quantity( wc_stock_amount( $request['stock_quantity'] ) );
1257
-				} elseif ( isset( $request['inventory_delta'] ) ) {
1258
-					$stock_quantity  = wc_stock_amount( $product->get_stock_quantity() );
1259
-					$stock_quantity += wc_stock_amount( $request['inventory_delta'] );
1260
-					$product->set_stock_quantity( wc_stock_amount( $stock_quantity ) );
1255
+				if (isset($request['stock_quantity'])) {
1256
+					$product->set_stock_quantity(wc_stock_amount($request['stock_quantity']));
1257
+				} elseif (isset($request['inventory_delta'])) {
1258
+					$stock_quantity  = wc_stock_amount($product->get_stock_quantity());
1259
+					$stock_quantity += wc_stock_amount($request['inventory_delta']);
1260
+					$product->set_stock_quantity(wc_stock_amount($stock_quantity));
1261 1261
 				}
1262 1262
 			} else {
1263 1263
 				// Don't manage stock.
1264
-				$product->set_manage_stock( 'no' );
1265
-				$product->set_stock_quantity( '' );
1266
-				$product->set_stock_status( $stock_status );
1264
+				$product->set_manage_stock('no');
1265
+				$product->set_stock_quantity('');
1266
+				$product->set_stock_status($stock_status);
1267 1267
 			}
1268
-		} elseif ( ! $product->is_type( 'variable' ) ) {
1269
-			$product->set_stock_status( $stock_status );
1268
+		} elseif ( ! $product->is_type('variable')) {
1269
+			$product->set_stock_status($stock_status);
1270 1270
 		}
1271 1271
 
1272 1272
 		// Upsells.
1273
-		if ( isset( $request['upsell_ids'] ) ) {
1273
+		if (isset($request['upsell_ids'])) {
1274 1274
 			$upsells = array();
1275 1275
 			$ids     = $request['upsell_ids'];
1276 1276
 
1277
-			if ( ! empty( $ids ) ) {
1278
-				foreach ( $ids as $id ) {
1279
-					if ( $id && $id > 0 ) {
1277
+			if ( ! empty($ids)) {
1278
+				foreach ($ids as $id) {
1279
+					if ($id && $id > 0) {
1280 1280
 						$upsells[] = $id;
1281 1281
 					}
1282 1282
 				}
1283 1283
 			}
1284 1284
 
1285
-			$product->set_upsell_ids( $upsells );
1285
+			$product->set_upsell_ids($upsells);
1286 1286
 		}
1287 1287
 
1288 1288
 		// Cross sells.
1289
-		if ( isset( $request['cross_sell_ids'] ) ) {
1289
+		if (isset($request['cross_sell_ids'])) {
1290 1290
 			$crosssells = array();
1291 1291
 			$ids        = $request['cross_sell_ids'];
1292 1292
 
1293
-			if ( ! empty( $ids ) ) {
1294
-				foreach ( $ids as $id ) {
1295
-					if ( $id && $id > 0 ) {
1293
+			if ( ! empty($ids)) {
1294
+				foreach ($ids as $id) {
1295
+					if ($id && $id > 0) {
1296 1296
 						$crosssells[] = $id;
1297 1297
 					}
1298 1298
 				}
1299 1299
 			}
1300 1300
 
1301
-			$product->set_cross_sell_ids( $crosssells );
1301
+			$product->set_cross_sell_ids($crosssells);
1302 1302
 		}
1303 1303
 
1304 1304
 		// Product categories.
1305
-		if ( isset( $request['categories'] ) && is_array( $request['categories'] ) ) {
1306
-			$product = $this->save_taxonomy_terms( $product, $request['categories'] );
1305
+		if (isset($request['categories']) && is_array($request['categories'])) {
1306
+			$product = $this->save_taxonomy_terms($product, $request['categories']);
1307 1307
 		}
1308 1308
 
1309 1309
 		// Product tags.
1310
-		if ( isset( $request['tags'] ) && is_array( $request['tags'] ) ) {
1311
-			$product = $this->save_taxonomy_terms( $product, $request['tags'], 'tag' );
1310
+		if (isset($request['tags']) && is_array($request['tags'])) {
1311
+			$product = $this->save_taxonomy_terms($product, $request['tags'], 'tag');
1312 1312
 		}
1313 1313
 
1314 1314
 		// Downloadable.
1315
-		if ( isset( $request['downloadable'] ) ) {
1316
-			$product->set_downloadable( $request['downloadable'] );
1315
+		if (isset($request['downloadable'])) {
1316
+			$product->set_downloadable($request['downloadable']);
1317 1317
 		}
1318 1318
 
1319 1319
 		// Downloadable options.
1320
-		if ( $product->get_downloadable() ) {
1320
+		if ($product->get_downloadable()) {
1321 1321
 
1322 1322
 			// Downloadable files.
1323
-			if ( isset( $request['downloads'] ) && is_array( $request['downloads'] ) ) {
1324
-				$product = $this->save_downloadable_files( $product, $request['downloads'] );
1323
+			if (isset($request['downloads']) && is_array($request['downloads'])) {
1324
+				$product = $this->save_downloadable_files($product, $request['downloads']);
1325 1325
 			}
1326 1326
 
1327 1327
 			// Download limit.
1328
-			if ( isset( $request['download_limit'] ) ) {
1329
-				$product->set_download_limit( $request['download_limit'] );
1328
+			if (isset($request['download_limit'])) {
1329
+				$product->set_download_limit($request['download_limit']);
1330 1330
 			}
1331 1331
 
1332 1332
 			// Download expiry.
1333
-			if ( isset( $request['download_expiry'] ) ) {
1334
-				$product->set_download_expiry( $request['download_expiry'] );
1333
+			if (isset($request['download_expiry'])) {
1334
+				$product->set_download_expiry($request['download_expiry']);
1335 1335
 			}
1336 1336
 		}
1337 1337
 
1338 1338
 		// Product url and button text for external products.
1339
-		if ( $product->is_type( 'external' ) ) {
1340
-			if ( isset( $request['external_url'] ) ) {
1341
-				$product->set_product_url( $request['external_url'] );
1339
+		if ($product->is_type('external')) {
1340
+			if (isset($request['external_url'])) {
1341
+				$product->set_product_url($request['external_url']);
1342 1342
 			}
1343 1343
 
1344
-			if ( isset( $request['button_text'] ) ) {
1345
-				$product->set_button_text( $request['button_text'] );
1344
+			if (isset($request['button_text'])) {
1345
+				$product->set_button_text($request['button_text']);
1346 1346
 			}
1347 1347
 		}
1348 1348
 
1349 1349
 		// Save default attributes for variable products.
1350
-		if ( $product->is_type( 'variable' ) ) {
1351
-			$product = $this->save_default_attributes( $product, $request );
1350
+		if ($product->is_type('variable')) {
1351
+			$product = $this->save_default_attributes($product, $request);
1352 1352
 		}
1353 1353
 
1354 1354
 		return $product;
@@ -1362,177 +1362,177 @@  discard block
 block discarded – undo
1362 1362
 	 * @param WP_REST_Request $request          Request data.
1363 1363
 	 * @return bool
1364 1364
 	 */
1365
-	protected function save_variations_data( $product, $request ) {
1366
-		foreach ( $request['variations'] as $menu_order => $data ) {
1367
-			$variation = new WC_Product_Variation( isset( $data['id'] ) ? absint( $data['id'] ) : 0 );
1365
+	protected function save_variations_data($product, $request) {
1366
+		foreach ($request['variations'] as $menu_order => $data) {
1367
+			$variation = new WC_Product_Variation(isset($data['id']) ? absint($data['id']) : 0);
1368 1368
 
1369 1369
 			// Create initial name and status.
1370
-			if ( ! $variation->get_slug() ) {
1370
+			if ( ! $variation->get_slug()) {
1371 1371
 				/* translators: 1: variation id 2: product name */
1372
-				$variation->set_name( sprintf( __( 'Variation #%1$s of %2$s', 'woocommerce' ), $variation->get_id(), $product->get_name() ) );
1373
-				$variation->set_status( isset( $data['visible'] ) && false === $data['visible'] ? 'private' : 'publish' );
1372
+				$variation->set_name(sprintf(__('Variation #%1$s of %2$s', 'woocommerce'), $variation->get_id(), $product->get_name()));
1373
+				$variation->set_status(isset($data['visible']) && false === $data['visible'] ? 'private' : 'publish');
1374 1374
 			}
1375 1375
 
1376 1376
 			// Parent ID.
1377
-			$variation->set_parent_id( $product->get_id() );
1377
+			$variation->set_parent_id($product->get_id());
1378 1378
 
1379 1379
 			// Menu order.
1380
-			$variation->set_menu_order( $menu_order );
1380
+			$variation->set_menu_order($menu_order);
1381 1381
 
1382 1382
 			// Status.
1383
-			if ( isset( $data['visible'] ) ) {
1384
-				$variation->set_status( false === $data['visible'] ? 'private' : 'publish' );
1383
+			if (isset($data['visible'])) {
1384
+				$variation->set_status(false === $data['visible'] ? 'private' : 'publish');
1385 1385
 			}
1386 1386
 
1387 1387
 			// SKU.
1388
-			if ( isset( $data['sku'] ) ) {
1389
-				$variation->set_sku( wc_clean( $data['sku'] ) );
1388
+			if (isset($data['sku'])) {
1389
+				$variation->set_sku(wc_clean($data['sku']));
1390 1390
 			}
1391 1391
 
1392 1392
 			// Thumbnail.
1393
-			if ( isset( $data['image'] ) && is_array( $data['image'] ) ) {
1393
+			if (isset($data['image']) && is_array($data['image'])) {
1394 1394
 				$image = $data['image'];
1395
-				$image = current( $image );
1396
-				if ( is_array( $image ) ) {
1395
+				$image = current($image);
1396
+				if (is_array($image)) {
1397 1397
 					$image['position'] = 0;
1398 1398
 				}
1399 1399
 
1400
-				$variation = $this->set_product_images( $variation, array( $image ) );
1400
+				$variation = $this->set_product_images($variation, array($image));
1401 1401
 			}
1402 1402
 
1403 1403
 			// Virtual variation.
1404
-			if ( isset( $data['virtual'] ) ) {
1405
-				$variation->set_virtual( $data['virtual'] );
1404
+			if (isset($data['virtual'])) {
1405
+				$variation->set_virtual($data['virtual']);
1406 1406
 			}
1407 1407
 
1408 1408
 			// Downloadable variation.
1409
-			if ( isset( $data['downloadable'] ) ) {
1410
-				$variation->set_downloadable( $data['downloadable'] );
1409
+			if (isset($data['downloadable'])) {
1410
+				$variation->set_downloadable($data['downloadable']);
1411 1411
 			}
1412 1412
 
1413 1413
 			// Downloads.
1414
-			if ( $variation->get_downloadable() ) {
1414
+			if ($variation->get_downloadable()) {
1415 1415
 				// Downloadable files.
1416
-				if ( isset( $data['downloads'] ) && is_array( $data['downloads'] ) ) {
1417
-					$variation = $this->save_downloadable_files( $variation, $data['downloads'] );
1416
+				if (isset($data['downloads']) && is_array($data['downloads'])) {
1417
+					$variation = $this->save_downloadable_files($variation, $data['downloads']);
1418 1418
 				}
1419 1419
 
1420 1420
 				// Download limit.
1421
-				if ( isset( $data['download_limit'] ) ) {
1422
-					$variation->set_download_limit( $data['download_limit'] );
1421
+				if (isset($data['download_limit'])) {
1422
+					$variation->set_download_limit($data['download_limit']);
1423 1423
 				}
1424 1424
 
1425 1425
 				// Download expiry.
1426
-				if ( isset( $data['download_expiry'] ) ) {
1427
-					$variation->set_download_expiry( $data['download_expiry'] );
1426
+				if (isset($data['download_expiry'])) {
1427
+					$variation->set_download_expiry($data['download_expiry']);
1428 1428
 				}
1429 1429
 			}
1430 1430
 
1431 1431
 			// Shipping data.
1432
-			$variation = $this->save_product_shipping_data( $variation, $data );
1432
+			$variation = $this->save_product_shipping_data($variation, $data);
1433 1433
 
1434 1434
 			// Stock handling.
1435
-			if ( isset( $data['manage_stock'] ) ) {
1436
-				$variation->set_manage_stock( $data['manage_stock'] );
1435
+			if (isset($data['manage_stock'])) {
1436
+				$variation->set_manage_stock($data['manage_stock']);
1437 1437
 			}
1438 1438
 
1439
-			if ( isset( $data['in_stock'] ) ) {
1440
-				$variation->set_stock_status( true === $data['in_stock'] ? 'instock' : 'outofstock' );
1439
+			if (isset($data['in_stock'])) {
1440
+				$variation->set_stock_status(true === $data['in_stock'] ? 'instock' : 'outofstock');
1441 1441
 			}
1442 1442
 
1443
-			if ( isset( $data['backorders'] ) ) {
1444
-				$variation->set_backorders( $data['backorders'] );
1443
+			if (isset($data['backorders'])) {
1444
+				$variation->set_backorders($data['backorders']);
1445 1445
 			}
1446 1446
 
1447
-			if ( $variation->get_manage_stock() ) {
1448
-				if ( isset( $data['stock_quantity'] ) ) {
1449
-					$variation->set_stock_quantity( $data['stock_quantity'] );
1450
-				} elseif ( isset( $data['inventory_delta'] ) ) {
1451
-					$stock_quantity  = wc_stock_amount( $variation->get_stock_quantity() );
1452
-					$stock_quantity += wc_stock_amount( $data['inventory_delta'] );
1453
-					$variation->set_stock_quantity( $stock_quantity );
1447
+			if ($variation->get_manage_stock()) {
1448
+				if (isset($data['stock_quantity'])) {
1449
+					$variation->set_stock_quantity($data['stock_quantity']);
1450
+				} elseif (isset($data['inventory_delta'])) {
1451
+					$stock_quantity  = wc_stock_amount($variation->get_stock_quantity());
1452
+					$stock_quantity += wc_stock_amount($data['inventory_delta']);
1453
+					$variation->set_stock_quantity($stock_quantity);
1454 1454
 				}
1455 1455
 			} else {
1456
-				$variation->set_backorders( 'no' );
1457
-				$variation->set_stock_quantity( '' );
1456
+				$variation->set_backorders('no');
1457
+				$variation->set_stock_quantity('');
1458 1458
 			}
1459 1459
 
1460 1460
 			// Regular Price.
1461
-			if ( isset( $data['regular_price'] ) ) {
1462
-				$variation->set_regular_price( $data['regular_price'] );
1461
+			if (isset($data['regular_price'])) {
1462
+				$variation->set_regular_price($data['regular_price']);
1463 1463
 			}
1464 1464
 
1465 1465
 			// Sale Price.
1466
-			if ( isset( $data['sale_price'] ) ) {
1467
-				$variation->set_sale_price( $data['sale_price'] );
1466
+			if (isset($data['sale_price'])) {
1467
+				$variation->set_sale_price($data['sale_price']);
1468 1468
 			}
1469 1469
 
1470
-			if ( isset( $data['date_on_sale_from'] ) ) {
1471
-				$variation->set_date_on_sale_from( $data['date_on_sale_from'] );
1470
+			if (isset($data['date_on_sale_from'])) {
1471
+				$variation->set_date_on_sale_from($data['date_on_sale_from']);
1472 1472
 			}
1473 1473
 
1474
-			if ( isset( $data['date_on_sale_to'] ) ) {
1475
-				$variation->set_date_on_sale_to( $data['date_on_sale_to'] );
1474
+			if (isset($data['date_on_sale_to'])) {
1475
+				$variation->set_date_on_sale_to($data['date_on_sale_to']);
1476 1476
 			}
1477 1477
 
1478 1478
 			// Tax class.
1479
-			if ( isset( $data['tax_class'] ) ) {
1480
-				$variation->set_tax_class( $data['tax_class'] );
1479
+			if (isset($data['tax_class'])) {
1480
+				$variation->set_tax_class($data['tax_class']);
1481 1481
 			}
1482 1482
 
1483 1483
 			// Description.
1484
-			if ( isset( $data['description'] ) ) {
1485
-				$variation->set_description( wp_kses_post( $data['description'] ) );
1484
+			if (isset($data['description'])) {
1485
+				$variation->set_description(wp_kses_post($data['description']));
1486 1486
 			}
1487 1487
 
1488 1488
 			// Update taxonomies.
1489
-			if ( isset( $data['attributes'] ) ) {
1489
+			if (isset($data['attributes'])) {
1490 1490
 				$attributes = array();
1491 1491
 				$parent_attributes = $product->get_attributes();
1492 1492
 
1493
-				foreach ( $data['attributes'] as $attribute ) {
1493
+				foreach ($data['attributes'] as $attribute) {
1494 1494
 					$attribute_id   = 0;
1495 1495
 					$attribute_name = '';
1496 1496
 
1497 1497
 					// Check ID for global attributes or name for product attributes.
1498
-					if ( ! empty( $attribute['id'] ) ) {
1499
-						$attribute_id   = absint( $attribute['id'] );
1500
-						$attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id );
1501
-					} elseif ( ! empty( $attribute['name'] ) ) {
1502
-						$attribute_name = sanitize_title( $attribute['name'] );
1498
+					if ( ! empty($attribute['id'])) {
1499
+						$attribute_id   = absint($attribute['id']);
1500
+						$attribute_name = wc_attribute_taxonomy_name_by_id($attribute_id);
1501
+					} elseif ( ! empty($attribute['name'])) {
1502
+						$attribute_name = sanitize_title($attribute['name']);
1503 1503
 					}
1504 1504
 
1505
-					if ( ! $attribute_id && ! $attribute_name ) {
1505
+					if ( ! $attribute_id && ! $attribute_name) {
1506 1506
 						continue;
1507 1507
 					}
1508 1508
 
1509
-					if ( ! isset( $parent_attributes[ $attribute_name ] ) || ! $parent_attributes[ $attribute_name ]->get_variation() ) {
1509
+					if ( ! isset($parent_attributes[$attribute_name]) || ! $parent_attributes[$attribute_name]->get_variation()) {
1510 1510
 						continue;
1511 1511
 					}
1512 1512
 
1513
-					$attribute_key   = sanitize_title( $parent_attributes[ $attribute_name ]->get_name() );
1514
-					$attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : '';
1513
+					$attribute_key   = sanitize_title($parent_attributes[$attribute_name]->get_name());
1514
+					$attribute_value = isset($attribute['option']) ? wc_clean(stripslashes($attribute['option'])) : '';
1515 1515
 
1516
-					if ( $parent_attributes[ $attribute_name ]->is_taxonomy() ) {
1516
+					if ($parent_attributes[$attribute_name]->is_taxonomy()) {
1517 1517
 						// If dealing with a taxonomy, we need to get the slug from the name posted to the API.
1518
-						$term = get_term_by( 'name', $attribute_value, $attribute_name );
1518
+						$term = get_term_by('name', $attribute_value, $attribute_name);
1519 1519
 
1520
-						if ( $term && ! is_wp_error( $term ) ) {
1520
+						if ($term && ! is_wp_error($term)) {
1521 1521
 							$attribute_value = $term->slug;
1522 1522
 						} else {
1523
-							$attribute_value = sanitize_title( $attribute_value );
1523
+							$attribute_value = sanitize_title($attribute_value);
1524 1524
 						}
1525 1525
 					}
1526 1526
 
1527
-					$attributes[ $attribute_key ] = $attribute_value;
1527
+					$attributes[$attribute_key] = $attribute_value;
1528 1528
 				}
1529 1529
 
1530
-				$variation->set_attributes( $attributes );
1530
+				$variation->set_attributes($attributes);
1531 1531
 			}
1532 1532
 
1533 1533
 			$variation->save();
1534 1534
 
1535
-			do_action( 'woocommerce_rest_save_product_variation', $variation->get_id(), $menu_order, $data );
1535
+			do_action('woocommerce_rest_save_product_variation', $variation->get_id(), $menu_order, $data);
1536 1536
 		}
1537 1537
 
1538 1538
 		return true;
@@ -1545,8 +1545,8 @@  discard block
 block discarded – undo
1545 1545
 	 * @param WP_REST_Request $request Request data.
1546 1546
 	 * @return bool|WP_Error
1547 1547
 	 */
1548
-	protected function add_post_meta_fields( $post, $request ) {
1549
-		return $this->update_post_meta_fields( $post, $request );
1548
+	protected function add_post_meta_fields($post, $request) {
1549
+		return $this->update_post_meta_fields($post, $request);
1550 1550
 	}
1551 1551
 
1552 1552
 	/**
@@ -1556,30 +1556,30 @@  discard block
 block discarded – undo
1556 1556
 	 * @param WP_REST_Request $request Request data.
1557 1557
 	 * @return bool|WP_Error
1558 1558
 	 */
1559
-	protected function update_post_meta_fields( $post, $request ) {
1560
-		$product = wc_get_product( $post );
1559
+	protected function update_post_meta_fields($post, $request) {
1560
+		$product = wc_get_product($post);
1561 1561
 
1562 1562
 		// Check for featured/gallery images, upload it and set it.
1563
-		if ( isset( $request['images'] ) ) {
1564
-			$product = $this->set_product_images( $product, $request['images'] );
1563
+		if (isset($request['images'])) {
1564
+			$product = $this->set_product_images($product, $request['images']);
1565 1565
 		}
1566 1566
 
1567 1567
 		// Save product meta fields.
1568
-		$product = $this->set_product_meta( $product, $request );
1568
+		$product = $this->set_product_meta($product, $request);
1569 1569
 
1570 1570
 		// Save the product data.
1571 1571
 		$product->save();
1572 1572
 
1573 1573
 		// Save variations.
1574
-		if ( $product->is_type( 'variable' ) ) {
1575
-			if ( isset( $request['variations'] ) && is_array( $request['variations'] ) ) {
1576
-				$this->save_variations_data( $product, $request );
1574
+		if ($product->is_type('variable')) {
1575
+			if (isset($request['variations']) && is_array($request['variations'])) {
1576
+				$this->save_variations_data($product, $request);
1577 1577
 			}
1578 1578
 		}
1579 1579
 
1580 1580
 		// Clear caches here so in sync with any new variations/children.
1581
-		wc_delete_product_transients( $product->get_id() );
1582
-		wp_cache_delete( 'product-' . $product->get_id(), 'products' );
1581
+		wc_delete_product_transients($product->get_id());
1582
+		wp_cache_delete('product-' . $product->get_id(), 'products');
1583 1583
 
1584 1584
 		return true;
1585 1585
 	}
@@ -1589,8 +1589,8 @@  discard block
 block discarded – undo
1589 1589
 	 *
1590 1590
 	 * @param WP_Post $post Post data.
1591 1591
 	 */
1592
-	public function clear_transients( $post ) {
1593
-		wc_delete_product_transients( $post->ID );
1592
+	public function clear_transients($post) {
1593
+		wc_delete_product_transients($post->ID);
1594 1594
 	}
1595 1595
 
1596 1596
 	/**
@@ -1598,27 +1598,27 @@  discard block
 block discarded – undo
1598 1598
 	 *
1599 1599
 	 * @param int|WP_Post $id Post ID or WP_Post instance.
1600 1600
 	 */
1601
-	protected function delete_post( $id ) {
1602
-		if ( ! empty( $id->ID ) ) {
1601
+	protected function delete_post($id) {
1602
+		if ( ! empty($id->ID)) {
1603 1603
 			$id = $id->ID;
1604
-		} elseif ( ! is_numeric( $id ) || 0 >= $id ) {
1604
+		} elseif ( ! is_numeric($id) || 0 >= $id) {
1605 1605
 			return;
1606 1606
 		}
1607 1607
 
1608 1608
 		// Delete product attachments.
1609
-		$attachments = get_posts( array(
1609
+		$attachments = get_posts(array(
1610 1610
 			'post_parent' => $id,
1611 1611
 			'post_status' => 'any',
1612 1612
 			'post_type'   => 'attachment',
1613
-		) );
1613
+		));
1614 1614
 
1615
-		foreach ( (array) $attachments as $attachment ) {
1616
-			wp_delete_attachment( $attachment->ID, true );
1615
+		foreach ((array) $attachments as $attachment) {
1616
+			wp_delete_attachment($attachment->ID, true);
1617 1617
 		}
1618 1618
 
1619 1619
 		// Delete product.
1620
-		$product = wc_get_product( $id );
1621
-		$product->delete( true );
1620
+		$product = wc_get_product($id);
1621
+		$product->delete(true);
1622 1622
 	}
1623 1623
 
1624 1624
 	/**
@@ -1627,16 +1627,16 @@  discard block
 block discarded – undo
1627 1627
 	 * @param WP_REST_Request $request Full details about the request.
1628 1628
 	 * @return WP_REST_Response|WP_Error
1629 1629
 	 */
1630
-	public function delete_item( $request ) {
1630
+	public function delete_item($request) {
1631 1631
 		$id      = (int) $request['id'];
1632 1632
 		$force   = (bool) $request['force'];
1633
-		$post    = get_post( $id );
1634
-		$product = wc_get_product( $id );
1633
+		$post    = get_post($id);
1634
+		$product = wc_get_product($id);
1635 1635
 
1636
-		if ( ! empty( $post->post_type ) && 'product_variation' === $post->post_type && 'product' === $this->post_type ) {
1637
-			return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/&lt;product_id&gt;/variations/&lt;id&gt; endpoint.', 'woocommerce' ), array( 'status' => 404 ) );
1638
-		} elseif ( empty( $id ) || empty( $post->ID ) || $post->post_type !== $this->post_type ) {
1639
-			return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid post ID.', 'woocommerce' ), array( 'status' => 404 ) );
1636
+		if ( ! empty($post->post_type) && 'product_variation' === $post->post_type && 'product' === $this->post_type) {
1637
+			return new WP_Error("woocommerce_rest_invalid_{$this->post_type}_id", __('To manipulate product variations you should use the /products/&lt;product_id&gt;/variations/&lt;id&gt; endpoint.', 'woocommerce'), array('status' => 404));
1638
+		} elseif (empty($id) || empty($post->ID) || $post->post_type !== $this->post_type) {
1639
+			return new WP_Error("woocommerce_rest_{$this->post_type}_invalid_id", __('Invalid post ID.', 'woocommerce'), array('status' => 404));
1640 1640
 		}
1641 1641
 
1642 1642
 		$supports_trash = EMPTY_TRASH_DAYS > 0;
@@ -1649,49 +1649,49 @@  discard block
 block discarded – undo
1649 1649
 		 * @param boolean $supports_trash Whether the item type support trashing.
1650 1650
 		 * @param WP_Post $post           The Post object being considered for trashing support.
1651 1651
 		 */
1652
-		$supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_trashable", $supports_trash, $post );
1652
+		$supports_trash = apply_filters("woocommerce_rest_{$this->post_type}_trashable", $supports_trash, $post);
1653 1653
 
1654
-		if ( ! wc_rest_check_post_permissions( $this->post_type, 'delete', $post->ID ) ) {
1654
+		if ( ! wc_rest_check_post_permissions($this->post_type, 'delete', $post->ID)) {
1655 1655
 			/* translators: %s: post type */
1656
-			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() ) );
1656
+			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()));
1657 1657
 		}
1658 1658
 
1659
-		$request->set_param( 'context', 'edit' );
1660
-		$response = $this->prepare_item_for_response( $post, $request );
1659
+		$request->set_param('context', 'edit');
1660
+		$response = $this->prepare_item_for_response($post, $request);
1661 1661
 
1662 1662
 		// If we're forcing, then delete permanently.
1663
-		if ( $force ) {
1664
-			if ( $product->is_type( 'variable' ) ) {
1665
-				foreach ( $product->get_children() as $child_id ) {
1666
-					$child = wc_get_product( $child_id );
1667
-					if ( ! empty( $child ) ) {
1668
-						$child->delete( true );
1663
+		if ($force) {
1664
+			if ($product->is_type('variable')) {
1665
+				foreach ($product->get_children() as $child_id) {
1666
+					$child = wc_get_product($child_id);
1667
+					if ( ! empty($child)) {
1668
+						$child->delete(true);
1669 1669
 					}
1670 1670
 				}
1671 1671
 			} else {
1672 1672
 				// For other product types, if the product has children, remove the relationship.
1673
-				foreach ( $product->get_children() as $child_id ) {
1674
-					$child = wc_get_product( $child_id );
1675
-					if ( ! empty( $child ) ) {
1676
-						$child->set_parent_id( 0 );
1673
+				foreach ($product->get_children() as $child_id) {
1674
+					$child = wc_get_product($child_id);
1675
+					if ( ! empty($child)) {
1676
+						$child->set_parent_id(0);
1677 1677
 						$child->save();
1678 1678
 					}
1679 1679
 				}
1680 1680
 			}
1681 1681
 
1682
-			$product->delete( true );
1683
-			$result = ! ( $product->get_id() > 0 );
1682
+			$product->delete(true);
1683
+			$result = ! ($product->get_id() > 0);
1684 1684
 		} else {
1685 1685
 			// If we don't support trashing for this type, error out.
1686
-			if ( ! $supports_trash ) {
1686
+			if ( ! $supports_trash) {
1687 1687
 				/* translators: %s: post type */
1688
-				return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array( 'status' => 501 ) );
1688
+				return new WP_Error('woocommerce_rest_trash_not_supported', sprintf(__('The %s does not support trashing.', 'woocommerce'), $this->post_type), array('status' => 501));
1689 1689
 			}
1690 1690
 
1691 1691
 			// Otherwise, only trash if we haven't already.
1692
-			if ( 'trash' === $post->post_status ) {
1692
+			if ('trash' === $post->post_status) {
1693 1693
 				/* translators: %s: post type */
1694
-				return new WP_Error( 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 410 ) );
1694
+				return new WP_Error('woocommerce_rest_already_trashed', sprintf(__('The %s has already been deleted.', 'woocommerce'), $this->post_type), array('status' => 410));
1695 1695
 			}
1696 1696
 
1697 1697
 			// (Note that internally this falls through to `wp_delete_post` if
@@ -1700,14 +1700,14 @@  discard block
 block discarded – undo
1700 1700
 			$result = 'trash' === $product->get_status();
1701 1701
 		}
1702 1702
 
1703
-		if ( ! $result ) {
1703
+		if ( ! $result) {
1704 1704
 			/* translators: %s: post type */
1705
-			return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 500 ) );
1705
+			return new WP_Error('woocommerce_rest_cannot_delete', sprintf(__('The %s cannot be deleted.', 'woocommerce'), $this->post_type), array('status' => 500));
1706 1706
 		}
1707 1707
 
1708 1708
 		// Delete parent product transients.
1709
-		if ( $parent_id = wp_get_post_parent_id( $id ) ) {
1710
-			wc_delete_product_transients( $parent_id );
1709
+		if ($parent_id = wp_get_post_parent_id($id)) {
1710
+			wc_delete_product_transients($parent_id);
1711 1711
 		}
1712 1712
 
1713 1713
 		/**
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 		 * @param WP_REST_Response $response The response data.
1718 1718
 		 * @param WP_REST_Request  $request  The request sent to the API.
1719 1719
 		 */
1720
-		do_action( "woocommerce_rest_delete_{$this->post_type}", $post, $response, $request );
1720
+		do_action("woocommerce_rest_delete_{$this->post_type}", $post, $response, $request);
1721 1721
 
1722 1722
 		return $response;
1723 1723
 	}
@@ -1728,822 +1728,822 @@  discard block
 block discarded – undo
1728 1728
 	 * @return array
1729 1729
 	 */
1730 1730
 	public function get_item_schema() {
1731
-		$weight_unit    = get_option( 'woocommerce_weight_unit' );
1732
-		$dimension_unit = get_option( 'woocommerce_dimension_unit' );
1731
+		$weight_unit    = get_option('woocommerce_weight_unit');
1732
+		$dimension_unit = get_option('woocommerce_dimension_unit');
1733 1733
 		$schema         = array(
1734 1734
 			'$schema'    => 'http://json-schema.org/draft-04/schema#',
1735 1735
 			'title'      => $this->post_type,
1736 1736
 			'type'       => 'object',
1737 1737
 			'properties' => array(
1738 1738
 				'id' => array(
1739
-					'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
1739
+					'description' => __('Unique identifier for the resource.', 'woocommerce'),
1740 1740
 					'type'        => 'integer',
1741
-					'context'     => array( 'view', 'edit' ),
1741
+					'context'     => array('view', 'edit'),
1742 1742
 					'readonly'    => true,
1743 1743
 				),
1744 1744
 				'name' => array(
1745
-					'description' => __( 'Product name.', 'woocommerce' ),
1745
+					'description' => __('Product name.', 'woocommerce'),
1746 1746
 					'type'        => 'string',
1747
-					'context'     => array( 'view', 'edit' ),
1747
+					'context'     => array('view', 'edit'),
1748 1748
 				),
1749 1749
 				'slug' => array(
1750
-					'description' => __( 'Product slug.', 'woocommerce' ),
1750
+					'description' => __('Product slug.', 'woocommerce'),
1751 1751
 					'type'        => 'string',
1752
-					'context'     => array( 'view', 'edit' ),
1752
+					'context'     => array('view', 'edit'),
1753 1753
 				),
1754 1754
 				'permalink' => array(
1755
-					'description' => __( 'Product URL.', 'woocommerce' ),
1755
+					'description' => __('Product URL.', 'woocommerce'),
1756 1756
 					'type'        => 'string',
1757 1757
 					'format'      => 'uri',
1758
-					'context'     => array( 'view', 'edit' ),
1758
+					'context'     => array('view', 'edit'),
1759 1759
 					'readonly'    => true,
1760 1760
 				),
1761 1761
 				'date_created' => array(
1762
-					'description' => __( "The date the product was created, in the site's timezone.", 'woocommerce' ),
1762
+					'description' => __("The date the product was created, in the site's timezone.", 'woocommerce'),
1763 1763
 					'type'        => 'date-time',
1764
-					'context'     => array( 'view', 'edit' ),
1764
+					'context'     => array('view', 'edit'),
1765 1765
 					'readonly'    => true,
1766 1766
 				),
1767 1767
 				'date_modified' => array(
1768
-					'description' => __( "The date the product was last modified, in the site's timezone.", 'woocommerce' ),
1768
+					'description' => __("The date the product was last modified, in the site's timezone.", 'woocommerce'),
1769 1769
 					'type'        => 'date-time',
1770
-					'context'     => array( 'view', 'edit' ),
1770
+					'context'     => array('view', 'edit'),
1771 1771
 					'readonly'    => true,
1772 1772
 				),
1773 1773
 				'type' => array(
1774
-					'description' => __( 'Product type.', 'woocommerce' ),
1774
+					'description' => __('Product type.', 'woocommerce'),
1775 1775
 					'type'        => 'string',
1776 1776
 					'default'     => 'simple',
1777
-					'enum'        => array_keys( wc_get_product_types() ),
1778
-					'context'     => array( 'view', 'edit' ),
1777
+					'enum'        => array_keys(wc_get_product_types()),
1778
+					'context'     => array('view', 'edit'),
1779 1779
 				),
1780 1780
 				'status' => array(
1781
-					'description' => __( 'Product status (post status).', 'woocommerce' ),
1781
+					'description' => __('Product status (post status).', 'woocommerce'),
1782 1782
 					'type'        => 'string',
1783 1783
 					'default'     => 'publish',
1784
-					'enum'        => array_merge( array_keys( get_post_statuses() ), array( 'future' ) ),
1785
-					'context'     => array( 'view', 'edit' ),
1784
+					'enum'        => array_merge(array_keys(get_post_statuses()), array('future')),
1785
+					'context'     => array('view', 'edit'),
1786 1786
 				),
1787 1787
 				'featured' => array(
1788
-					'description' => __( 'Featured product.', 'woocommerce' ),
1788
+					'description' => __('Featured product.', 'woocommerce'),
1789 1789
 					'type'        => 'boolean',
1790 1790
 					'default'     => false,
1791
-					'context'     => array( 'view', 'edit' ),
1791
+					'context'     => array('view', 'edit'),
1792 1792
 				),
1793 1793
 				'catalog_visibility' => array(
1794
-					'description' => __( 'Catalog visibility.', 'woocommerce' ),
1794
+					'description' => __('Catalog visibility.', 'woocommerce'),
1795 1795
 					'type'        => 'string',
1796 1796
 					'default'     => 'visible',
1797
-					'enum'        => array( 'visible', 'catalog', 'search', 'hidden' ),
1798
-					'context'     => array( 'view', 'edit' ),
1797
+					'enum'        => array('visible', 'catalog', 'search', 'hidden'),
1798
+					'context'     => array('view', 'edit'),
1799 1799
 				),
1800 1800
 				'description' => array(
1801
-					'description' => __( 'Product description.', 'woocommerce' ),
1801
+					'description' => __('Product description.', 'woocommerce'),
1802 1802
 					'type'        => 'string',
1803
-					'context'     => array( 'view', 'edit' ),
1803
+					'context'     => array('view', 'edit'),
1804 1804
 				),
1805 1805
 				'short_description' => array(
1806
-					'description' => __( 'Product short description.', 'woocommerce' ),
1806
+					'description' => __('Product short description.', 'woocommerce'),
1807 1807
 					'type'        => 'string',
1808
-					'context'     => array( 'view', 'edit' ),
1808
+					'context'     => array('view', 'edit'),
1809 1809
 				),
1810 1810
 				'sku' => array(
1811
-					'description' => __( 'Unique identifier.', 'woocommerce' ),
1811
+					'description' => __('Unique identifier.', 'woocommerce'),
1812 1812
 					'type'        => 'string',
1813
-					'context'     => array( 'view', 'edit' ),
1813
+					'context'     => array('view', 'edit'),
1814 1814
 				),
1815 1815
 				'price' => array(
1816
-					'description' => __( 'Current product price.', 'woocommerce' ),
1816
+					'description' => __('Current product price.', 'woocommerce'),
1817 1817
 					'type'        => 'string',
1818
-					'context'     => array( 'view', 'edit' ),
1818
+					'context'     => array('view', 'edit'),
1819 1819
 					'readonly'    => true,
1820 1820
 				),
1821 1821
 				'regular_price' => array(
1822
-					'description' => __( 'Product regular price.', 'woocommerce' ),
1822
+					'description' => __('Product regular price.', 'woocommerce'),
1823 1823
 					'type'        => 'string',
1824
-					'context'     => array( 'view', 'edit' ),
1824
+					'context'     => array('view', 'edit'),
1825 1825
 				),
1826 1826
 				'sale_price' => array(
1827
-					'description' => __( 'Product sale price.', 'woocommerce' ),
1827
+					'description' => __('Product sale price.', 'woocommerce'),
1828 1828
 					'type'        => 'string',
1829
-					'context'     => array( 'view', 'edit' ),
1829
+					'context'     => array('view', 'edit'),
1830 1830
 				),
1831 1831
 				'date_on_sale_from' => array(
1832
-					'description' => __( 'Start date of sale price.', 'woocommerce' ),
1832
+					'description' => __('Start date of sale price.', 'woocommerce'),
1833 1833
 					'type'        => 'string',
1834
-					'context'     => array( 'view', 'edit' ),
1834
+					'context'     => array('view', 'edit'),
1835 1835
 				),
1836 1836
 				'date_on_sale_to' => array(
1837
-					'description' => __( 'End date of sale price.', 'woocommerce' ),
1837
+					'description' => __('End date of sale price.', 'woocommerce'),
1838 1838
 					'type'        => 'string',
1839
-					'context'     => array( 'view', 'edit' ),
1839
+					'context'     => array('view', 'edit'),
1840 1840
 				),
1841 1841
 				'price_html' => array(
1842
-					'description' => __( 'Price formatted in HTML.', 'woocommerce' ),
1842
+					'description' => __('Price formatted in HTML.', 'woocommerce'),
1843 1843
 					'type'        => 'string',
1844
-					'context'     => array( 'view', 'edit' ),
1844
+					'context'     => array('view', 'edit'),
1845 1845
 					'readonly'    => true,
1846 1846
 				),
1847 1847
 				'on_sale' => array(
1848
-					'description' => __( 'Shows if the product is on sale.', 'woocommerce' ),
1848
+					'description' => __('Shows if the product is on sale.', 'woocommerce'),
1849 1849
 					'type'        => 'boolean',
1850
-					'context'     => array( 'view', 'edit' ),
1850
+					'context'     => array('view', 'edit'),
1851 1851
 					'readonly'    => true,
1852 1852
 				),
1853 1853
 				'purchasable' => array(
1854
-					'description' => __( 'Shows if the product can be bought.', 'woocommerce' ),
1854
+					'description' => __('Shows if the product can be bought.', 'woocommerce'),
1855 1855
 					'type'        => 'boolean',
1856
-					'context'     => array( 'view', 'edit' ),
1856
+					'context'     => array('view', 'edit'),
1857 1857
 					'readonly'    => true,
1858 1858
 				),
1859 1859
 				'total_sales' => array(
1860
-					'description' => __( 'Amount of sales.', 'woocommerce' ),
1860
+					'description' => __('Amount of sales.', 'woocommerce'),
1861 1861
 					'type'        => 'integer',
1862
-					'context'     => array( 'view', 'edit' ),
1862
+					'context'     => array('view', 'edit'),
1863 1863
 					'readonly'    => true,
1864 1864
 				),
1865 1865
 				'virtual' => array(
1866
-					'description' => __( 'If the product is virtual.', 'woocommerce' ),
1866
+					'description' => __('If the product is virtual.', 'woocommerce'),
1867 1867
 					'type'        => 'boolean',
1868 1868
 					'default'     => false,
1869
-					'context'     => array( 'view', 'edit' ),
1869
+					'context'     => array('view', 'edit'),
1870 1870
 				),
1871 1871
 				'downloadable' => array(
1872
-					'description' => __( 'If the product is downloadable.', 'woocommerce' ),
1872
+					'description' => __('If the product is downloadable.', 'woocommerce'),
1873 1873
 					'type'        => 'boolean',
1874 1874
 					'default'     => false,
1875
-					'context'     => array( 'view', 'edit' ),
1875
+					'context'     => array('view', 'edit'),
1876 1876
 				),
1877 1877
 				'downloads' => array(
1878
-					'description' => __( 'List of downloadable files.', 'woocommerce' ),
1878
+					'description' => __('List of downloadable files.', 'woocommerce'),
1879 1879
 					'type'        => 'array',
1880
-					'context'     => array( 'view', 'edit' ),
1880
+					'context'     => array('view', 'edit'),
1881 1881
 					'items'       => array(
1882 1882
 						'type'       => 'object',
1883 1883
 						'properties' => array(
1884 1884
 							'id' => array(
1885
-								'description' => __( 'File ID.', 'woocommerce' ),
1885
+								'description' => __('File ID.', 'woocommerce'),
1886 1886
 								'type'        => 'string',
1887
-								'context'     => array( 'view', 'edit' ),
1887
+								'context'     => array('view', 'edit'),
1888 1888
 							),
1889 1889
 							'name' => array(
1890
-								'description' => __( 'File name.', 'woocommerce' ),
1890
+								'description' => __('File name.', 'woocommerce'),
1891 1891
 								'type'        => 'string',
1892
-								'context'     => array( 'view', 'edit' ),
1892
+								'context'     => array('view', 'edit'),
1893 1893
 							),
1894 1894
 							'file' => array(
1895
-								'description' => __( 'File URL.', 'woocommerce' ),
1895
+								'description' => __('File URL.', 'woocommerce'),
1896 1896
 								'type'        => 'string',
1897
-								'context'     => array( 'view', 'edit' ),
1897
+								'context'     => array('view', 'edit'),
1898 1898
 							),
1899 1899
 						),
1900 1900
 					),
1901 1901
 				),
1902 1902
 				'download_limit' => array(
1903
-					'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce' ),
1903
+					'description' => __('Number of times downloadable files can be downloaded after purchase.', 'woocommerce'),
1904 1904
 					'type'        => 'integer',
1905 1905
 					'default'     => -1,
1906
-					'context'     => array( 'view', 'edit' ),
1906
+					'context'     => array('view', 'edit'),
1907 1907
 				),
1908 1908
 				'download_expiry' => array(
1909
-					'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce' ),
1909
+					'description' => __('Number of days until access to downloadable files expires.', 'woocommerce'),
1910 1910
 					'type'        => 'integer',
1911 1911
 					'default'     => -1,
1912
-					'context'     => array( 'view', 'edit' ),
1912
+					'context'     => array('view', 'edit'),
1913 1913
 				),
1914 1914
 				'download_type' => array(
1915
-					'description' => __( 'Download type, this controls the schema on the front-end.', 'woocommerce' ),
1915
+					'description' => __('Download type, this controls the schema on the front-end.', 'woocommerce'),
1916 1916
 					'type'        => 'string',
1917 1917
 					'default'     => 'standard',
1918
-					'enum'        => array( 'standard' ),
1919
-					'context'     => array( 'view', 'edit' ),
1918
+					'enum'        => array('standard'),
1919
+					'context'     => array('view', 'edit'),
1920 1920
 				),
1921 1921
 				'external_url' => array(
1922
-					'description' => __( 'Product external URL. Only for external products.', 'woocommerce' ),
1922
+					'description' => __('Product external URL. Only for external products.', 'woocommerce'),
1923 1923
 					'type'        => 'string',
1924 1924
 					'format'      => 'uri',
1925
-					'context'     => array( 'view', 'edit' ),
1925
+					'context'     => array('view', 'edit'),
1926 1926
 				),
1927 1927
 				'button_text' => array(
1928
-					'description' => __( 'Product external button text. Only for external products.', 'woocommerce' ),
1928
+					'description' => __('Product external button text. Only for external products.', 'woocommerce'),
1929 1929
 					'type'        => 'string',
1930
-					'context'     => array( 'view', 'edit' ),
1930
+					'context'     => array('view', 'edit'),
1931 1931
 				),
1932 1932
 				'tax_status' => array(
1933
-					'description' => __( 'Tax status.', 'woocommerce' ),
1933
+					'description' => __('Tax status.', 'woocommerce'),
1934 1934
 					'type'        => 'string',
1935 1935
 					'default'     => 'taxable',
1936
-					'enum'        => array( 'taxable', 'shipping', 'none' ),
1937
-					'context'     => array( 'view', 'edit' ),
1936
+					'enum'        => array('taxable', 'shipping', 'none'),
1937
+					'context'     => array('view', 'edit'),
1938 1938
 				),
1939 1939
 				'tax_class' => array(
1940
-					'description' => __( 'Tax class.', 'woocommerce' ),
1940
+					'description' => __('Tax class.', 'woocommerce'),
1941 1941
 					'type'        => 'string',
1942
-					'context'     => array( 'view', 'edit' ),
1942
+					'context'     => array('view', 'edit'),
1943 1943
 				),
1944 1944
 				'manage_stock' => array(
1945
-					'description' => __( 'Stock management at product level.', 'woocommerce' ),
1945
+					'description' => __('Stock management at product level.', 'woocommerce'),
1946 1946
 					'type'        => 'boolean',
1947 1947
 					'default'     => false,
1948
-					'context'     => array( 'view', 'edit' ),
1948
+					'context'     => array('view', 'edit'),
1949 1949
 				),
1950 1950
 				'stock_quantity' => array(
1951
-					'description' => __( 'Stock quantity.', 'woocommerce' ),
1951
+					'description' => __('Stock quantity.', 'woocommerce'),
1952 1952
 					'type'        => 'integer',
1953
-					'context'     => array( 'view', 'edit' ),
1953
+					'context'     => array('view', 'edit'),
1954 1954
 				),
1955 1955
 				'in_stock' => array(
1956
-					'description' => __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ),
1956
+					'description' => __('Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce'),
1957 1957
 					'type'        => 'boolean',
1958 1958
 					'default'     => true,
1959
-					'context'     => array( 'view', 'edit' ),
1959
+					'context'     => array('view', 'edit'),
1960 1960
 				),
1961 1961
 				'backorders' => array(
1962
-					'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce' ),
1962
+					'description' => __('If managing stock, this controls if backorders are allowed.', 'woocommerce'),
1963 1963
 					'type'        => 'string',
1964 1964
 					'default'     => 'no',
1965
-					'enum'        => array( 'no', 'notify', 'yes' ),
1966
-					'context'     => array( 'view', 'edit' ),
1965
+					'enum'        => array('no', 'notify', 'yes'),
1966
+					'context'     => array('view', 'edit'),
1967 1967
 				),
1968 1968
 				'backorders_allowed' => array(
1969
-					'description' => __( 'Shows if backorders are allowed.', 'woocommerce' ),
1969
+					'description' => __('Shows if backorders are allowed.', 'woocommerce'),
1970 1970
 					'type'        => 'boolean',
1971
-					'context'     => array( 'view', 'edit' ),
1971
+					'context'     => array('view', 'edit'),
1972 1972
 					'readonly'    => true,
1973 1973
 				),
1974 1974
 				'backordered' => array(
1975
-					'description' => __( 'Shows if the product is on backordered.', 'woocommerce' ),
1975
+					'description' => __('Shows if the product is on backordered.', 'woocommerce'),
1976 1976
 					'type'        => 'boolean',
1977
-					'context'     => array( 'view', 'edit' ),
1977
+					'context'     => array('view', 'edit'),
1978 1978
 					'readonly'    => true,
1979 1979
 				),
1980 1980
 				'sold_individually' => array(
1981
-					'description' => __( 'Allow one item to be bought in a single order.', 'woocommerce' ),
1981
+					'description' => __('Allow one item to be bought in a single order.', 'woocommerce'),
1982 1982
 					'type'        => 'boolean',
1983 1983
 					'default'     => false,
1984
-					'context'     => array( 'view', 'edit' ),
1984
+					'context'     => array('view', 'edit'),
1985 1985
 				),
1986 1986
 				'weight' => array(
1987 1987
 					/* translators: %s: weight unit */
1988
-					'description' => sprintf( __( 'Product weight (%s).', 'woocommerce' ), $weight_unit ),
1988
+					'description' => sprintf(__('Product weight (%s).', 'woocommerce'), $weight_unit),
1989 1989
 					'type'        => 'string',
1990
-					'context'     => array( 'view', 'edit' ),
1990
+					'context'     => array('view', 'edit'),
1991 1991
 				),
1992 1992
 				'dimensions' => array(
1993
-					'description' => __( 'Product dimensions.', 'woocommerce' ),
1993
+					'description' => __('Product dimensions.', 'woocommerce'),
1994 1994
 					'type'        => 'object',
1995
-					'context'     => array( 'view', 'edit' ),
1995
+					'context'     => array('view', 'edit'),
1996 1996
 					'properties'  => array(
1997 1997
 						'length' => array(
1998 1998
 							/* translators: %s: dimension unit */
1999
-							'description' => sprintf( __( 'Product length (%s).', 'woocommerce' ), $dimension_unit ),
1999
+							'description' => sprintf(__('Product length (%s).', 'woocommerce'), $dimension_unit),
2000 2000
 							'type'        => 'string',
2001
-							'context'     => array( 'view', 'edit' ),
2001
+							'context'     => array('view', 'edit'),
2002 2002
 						),
2003 2003
 						'width' => array(
2004 2004
 							/* translators: %s: dimension unit */
2005
-							'description' => sprintf( __( 'Product width (%s).', 'woocommerce' ), $dimension_unit ),
2005
+							'description' => sprintf(__('Product width (%s).', 'woocommerce'), $dimension_unit),
2006 2006
 							'type'        => 'string',
2007
-							'context'     => array( 'view', 'edit' ),
2007
+							'context'     => array('view', 'edit'),
2008 2008
 						),
2009 2009
 						'height' => array(
2010 2010
 							/* translators: %s: dimension unit */
2011
-							'description' => sprintf( __( 'Product height (%s).', 'woocommerce' ), $dimension_unit ),
2011
+							'description' => sprintf(__('Product height (%s).', 'woocommerce'), $dimension_unit),
2012 2012
 							'type'        => 'string',
2013
-							'context'     => array( 'view', 'edit' ),
2013
+							'context'     => array('view', 'edit'),
2014 2014
 						),
2015 2015
 					),
2016 2016
 				),
2017 2017
 				'shipping_required' => array(
2018
-					'description' => __( 'Shows if the product need to be shipped.', 'woocommerce' ),
2018
+					'description' => __('Shows if the product need to be shipped.', 'woocommerce'),
2019 2019
 					'type'        => 'boolean',
2020
-					'context'     => array( 'view', 'edit' ),
2020
+					'context'     => array('view', 'edit'),
2021 2021
 					'readonly'    => true,
2022 2022
 				),
2023 2023
 				'shipping_taxable' => array(
2024
-					'description' => __( 'Shows whether or not the product shipping is taxable.', 'woocommerce' ),
2024
+					'description' => __('Shows whether or not the product shipping is taxable.', 'woocommerce'),
2025 2025
 					'type'        => 'boolean',
2026
-					'context'     => array( 'view', 'edit' ),
2026
+					'context'     => array('view', 'edit'),
2027 2027
 					'readonly'    => true,
2028 2028
 				),
2029 2029
 				'shipping_class' => array(
2030
-					'description' => __( 'Shipping class slug.', 'woocommerce' ),
2030
+					'description' => __('Shipping class slug.', 'woocommerce'),
2031 2031
 					'type'        => 'string',
2032
-					'context'     => array( 'view', 'edit' ),
2032
+					'context'     => array('view', 'edit'),
2033 2033
 				),
2034 2034
 				'shipping_class_id' => array(
2035
-					'description' => __( 'Shipping class ID.', 'woocommerce' ),
2035
+					'description' => __('Shipping class ID.', 'woocommerce'),
2036 2036
 					'type'        => 'integer',
2037
-					'context'     => array( 'view', 'edit' ),
2037
+					'context'     => array('view', 'edit'),
2038 2038
 					'readonly'    => true,
2039 2039
 				),
2040 2040
 				'reviews_allowed' => array(
2041
-					'description' => __( 'Allow reviews.', 'woocommerce' ),
2041
+					'description' => __('Allow reviews.', 'woocommerce'),
2042 2042
 					'type'        => 'boolean',
2043 2043
 					'default'     => true,
2044
-					'context'     => array( 'view', 'edit' ),
2044
+					'context'     => array('view', 'edit'),
2045 2045
 				),
2046 2046
 				'average_rating' => array(
2047
-					'description' => __( 'Reviews average rating.', 'woocommerce' ),
2047
+					'description' => __('Reviews average rating.', 'woocommerce'),
2048 2048
 					'type'        => 'string',
2049
-					'context'     => array( 'view', 'edit' ),
2049
+					'context'     => array('view', 'edit'),
2050 2050
 					'readonly'    => true,
2051 2051
 				),
2052 2052
 				'rating_count' => array(
2053
-					'description' => __( 'Amount of reviews that the product have.', 'woocommerce' ),
2053
+					'description' => __('Amount of reviews that the product have.', 'woocommerce'),
2054 2054
 					'type'        => 'integer',
2055
-					'context'     => array( 'view', 'edit' ),
2055
+					'context'     => array('view', 'edit'),
2056 2056
 					'readonly'    => true,
2057 2057
 				),
2058 2058
 				'related_ids' => array(
2059
-					'description' => __( 'List of related products IDs.', 'woocommerce' ),
2059
+					'description' => __('List of related products IDs.', 'woocommerce'),
2060 2060
 					'type'        => 'array',
2061 2061
 					'items'       => array(
2062 2062
 						'type'    => 'integer',
2063 2063
 					),
2064
-					'context'     => array( 'view', 'edit' ),
2064
+					'context'     => array('view', 'edit'),
2065 2065
 					'readonly'    => true,
2066 2066
 				),
2067 2067
 				'upsell_ids' => array(
2068
-					'description' => __( 'List of upsell products IDs.', 'woocommerce' ),
2068
+					'description' => __('List of upsell products IDs.', 'woocommerce'),
2069 2069
 					'type'        => 'array',
2070 2070
 					'items'       => array(
2071 2071
 						'type'    => 'integer',
2072 2072
 					),
2073
-					'context'     => array( 'view', 'edit' ),
2073
+					'context'     => array('view', 'edit'),
2074 2074
 				),
2075 2075
 				'cross_sell_ids' => array(
2076
-					'description' => __( 'List of cross-sell products IDs.', 'woocommerce' ),
2076
+					'description' => __('List of cross-sell products IDs.', 'woocommerce'),
2077 2077
 					'type'        => 'array',
2078 2078
 					'items'       => array(
2079 2079
 						'type'    => 'integer',
2080 2080
 					),
2081
-					'context'     => array( 'view', 'edit' ),
2081
+					'context'     => array('view', 'edit'),
2082 2082
 				),
2083 2083
 				'parent_id' => array(
2084
-					'description' => __( 'Product parent ID.', 'woocommerce' ),
2084
+					'description' => __('Product parent ID.', 'woocommerce'),
2085 2085
 					'type'        => 'integer',
2086
-					'context'     => array( 'view', 'edit' ),
2086
+					'context'     => array('view', 'edit'),
2087 2087
 				),
2088 2088
 				'purchase_note' => array(
2089
-					'description' => __( 'Optional note to send the customer after purchase.', 'woocommerce' ),
2089
+					'description' => __('Optional note to send the customer after purchase.', 'woocommerce'),
2090 2090
 					'type'        => 'string',
2091
-					'context'     => array( 'view', 'edit' ),
2091
+					'context'     => array('view', 'edit'),
2092 2092
 				),
2093 2093
 				'categories' => array(
2094
-					'description' => __( 'List of categories.', 'woocommerce' ),
2094
+					'description' => __('List of categories.', 'woocommerce'),
2095 2095
 					'type'        => 'array',
2096
-					'context'     => array( 'view', 'edit' ),
2096
+					'context'     => array('view', 'edit'),
2097 2097
 					'items'       => array(
2098 2098
 						'type'       => 'object',
2099 2099
 						'properties' => array(
2100 2100
 							'id' => array(
2101
-								'description' => __( 'Category ID.', 'woocommerce' ),
2101
+								'description' => __('Category ID.', 'woocommerce'),
2102 2102
 								'type'        => 'integer',
2103
-								'context'     => array( 'view', 'edit' ),
2103
+								'context'     => array('view', 'edit'),
2104 2104
 							),
2105 2105
 							'name' => array(
2106
-								'description' => __( 'Category name.', 'woocommerce' ),
2106
+								'description' => __('Category name.', 'woocommerce'),
2107 2107
 								'type'        => 'string',
2108
-								'context'     => array( 'view', 'edit' ),
2108
+								'context'     => array('view', 'edit'),
2109 2109
 								'readonly'    => true,
2110 2110
 							),
2111 2111
 							'slug' => array(
2112
-								'description' => __( 'Category slug.', 'woocommerce' ),
2112
+								'description' => __('Category slug.', 'woocommerce'),
2113 2113
 								'type'        => 'string',
2114
-								'context'     => array( 'view', 'edit' ),
2114
+								'context'     => array('view', 'edit'),
2115 2115
 								'readonly'    => true,
2116 2116
 							),
2117 2117
 						),
2118 2118
 					),
2119 2119
 				),
2120 2120
 				'tags' => array(
2121
-					'description' => __( 'List of tags.', 'woocommerce' ),
2121
+					'description' => __('List of tags.', 'woocommerce'),
2122 2122
 					'type'        => 'array',
2123
-					'context'     => array( 'view', 'edit' ),
2123
+					'context'     => array('view', 'edit'),
2124 2124
 					'items'       => array(
2125 2125
 						'type'       => 'object',
2126 2126
 						'properties' => array(
2127 2127
 							'id' => array(
2128
-								'description' => __( 'Tag ID.', 'woocommerce' ),
2128
+								'description' => __('Tag ID.', 'woocommerce'),
2129 2129
 								'type'        => 'integer',
2130
-								'context'     => array( 'view', 'edit' ),
2130
+								'context'     => array('view', 'edit'),
2131 2131
 							),
2132 2132
 							'name' => array(
2133
-								'description' => __( 'Tag name.', 'woocommerce' ),
2133
+								'description' => __('Tag name.', 'woocommerce'),
2134 2134
 								'type'        => 'string',
2135
-								'context'     => array( 'view', 'edit' ),
2135
+								'context'     => array('view', 'edit'),
2136 2136
 								'readonly'    => true,
2137 2137
 							),
2138 2138
 							'slug' => array(
2139
-								'description' => __( 'Tag slug.', 'woocommerce' ),
2139
+								'description' => __('Tag slug.', 'woocommerce'),
2140 2140
 								'type'        => 'string',
2141
-								'context'     => array( 'view', 'edit' ),
2141
+								'context'     => array('view', 'edit'),
2142 2142
 								'readonly'    => true,
2143 2143
 							),
2144 2144
 						),
2145 2145
 					),
2146 2146
 				),
2147 2147
 				'images' => array(
2148
-					'description' => __( 'List of images.', 'woocommerce' ),
2148
+					'description' => __('List of images.', 'woocommerce'),
2149 2149
 					'type'        => 'object',
2150
-					'context'     => array( 'view', 'edit' ),
2150
+					'context'     => array('view', 'edit'),
2151 2151
 					'items'       => array(
2152 2152
 						'type'       => 'object',
2153 2153
 						'properties' => array(
2154 2154
 							'id' => array(
2155
-								'description' => __( 'Image ID.', 'woocommerce' ),
2155
+								'description' => __('Image ID.', 'woocommerce'),
2156 2156
 								'type'        => 'integer',
2157
-								'context'     => array( 'view', 'edit' ),
2157
+								'context'     => array('view', 'edit'),
2158 2158
 							),
2159 2159
 							'date_created' => array(
2160
-								'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ),
2160
+								'description' => __("The date the image was created, in the site's timezone.", 'woocommerce'),
2161 2161
 								'type'        => 'date-time',
2162
-								'context'     => array( 'view', 'edit' ),
2162
+								'context'     => array('view', 'edit'),
2163 2163
 								'readonly'    => true,
2164 2164
 							),
2165 2165
 							'date_modified' => array(
2166
-								'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ),
2166
+								'description' => __("The date the image was last modified, in the site's timezone.", 'woocommerce'),
2167 2167
 								'type'        => 'date-time',
2168
-								'context'     => array( 'view', 'edit' ),
2168
+								'context'     => array('view', 'edit'),
2169 2169
 								'readonly'    => true,
2170 2170
 							),
2171 2171
 							'src' => array(
2172
-								'description' => __( 'Image URL.', 'woocommerce' ),
2172
+								'description' => __('Image URL.', 'woocommerce'),
2173 2173
 								'type'        => 'string',
2174 2174
 								'format'      => 'uri',
2175
-								'context'     => array( 'view', 'edit' ),
2175
+								'context'     => array('view', 'edit'),
2176 2176
 							),
2177 2177
 							'name' => array(
2178
-								'description' => __( 'Image name.', 'woocommerce' ),
2178
+								'description' => __('Image name.', 'woocommerce'),
2179 2179
 								'type'        => 'string',
2180
-								'context'     => array( 'view', 'edit' ),
2180
+								'context'     => array('view', 'edit'),
2181 2181
 							),
2182 2182
 							'alt' => array(
2183
-								'description' => __( 'Image alternative text.', 'woocommerce' ),
2183
+								'description' => __('Image alternative text.', 'woocommerce'),
2184 2184
 								'type'        => 'string',
2185
-								'context'     => array( 'view', 'edit' ),
2185
+								'context'     => array('view', 'edit'),
2186 2186
 							),
2187 2187
 							'position' => array(
2188
-								'description' => __( 'Image position. 0 means that the image is featured.', 'woocommerce' ),
2188
+								'description' => __('Image position. 0 means that the image is featured.', 'woocommerce'),
2189 2189
 								'type'        => 'integer',
2190
-								'context'     => array( 'view', 'edit' ),
2190
+								'context'     => array('view', 'edit'),
2191 2191
 							),
2192 2192
 						),
2193 2193
 					),
2194 2194
 				),
2195 2195
 				'attributes' => array(
2196
-					'description' => __( 'List of attributes.', 'woocommerce' ),
2196
+					'description' => __('List of attributes.', 'woocommerce'),
2197 2197
 					'type'        => 'array',
2198
-					'context'     => array( 'view', 'edit' ),
2198
+					'context'     => array('view', 'edit'),
2199 2199
 					'items'       => array(
2200 2200
 						'type'       => 'object',
2201 2201
 						'properties' => array(
2202 2202
 							'id' => array(
2203
-								'description' => __( 'Attribute ID.', 'woocommerce' ),
2203
+								'description' => __('Attribute ID.', 'woocommerce'),
2204 2204
 								'type'        => 'integer',
2205
-								'context'     => array( 'view', 'edit' ),
2205
+								'context'     => array('view', 'edit'),
2206 2206
 							),
2207 2207
 							'name' => array(
2208
-								'description' => __( 'Attribute name.', 'woocommerce' ),
2208
+								'description' => __('Attribute name.', 'woocommerce'),
2209 2209
 								'type'        => 'string',
2210
-								'context'     => array( 'view', 'edit' ),
2210
+								'context'     => array('view', 'edit'),
2211 2211
 							),
2212 2212
 							'position' => array(
2213
-								'description' => __( 'Attribute position.', 'woocommerce' ),
2213
+								'description' => __('Attribute position.', 'woocommerce'),
2214 2214
 								'type'        => 'integer',
2215
-								'context'     => array( 'view', 'edit' ),
2215
+								'context'     => array('view', 'edit'),
2216 2216
 							),
2217 2217
 							'visible' => array(
2218
-								'description' => __( "Define if the attribute is visible on the \"Additional information\" tab in the product's page.", 'woocommerce' ),
2218
+								'description' => __("Define if the attribute is visible on the \"Additional information\" tab in the product's page.", 'woocommerce'),
2219 2219
 								'type'        => 'boolean',
2220 2220
 								'default'     => false,
2221
-								'context'     => array( 'view', 'edit' ),
2221
+								'context'     => array('view', 'edit'),
2222 2222
 							),
2223 2223
 							'variation' => array(
2224
-								'description' => __( 'Define if the attribute can be used as variation.', 'woocommerce' ),
2224
+								'description' => __('Define if the attribute can be used as variation.', 'woocommerce'),
2225 2225
 								'type'        => 'boolean',
2226 2226
 								'default'     => false,
2227
-								'context'     => array( 'view', 'edit' ),
2227
+								'context'     => array('view', 'edit'),
2228 2228
 							),
2229 2229
 							'options' => array(
2230
-								'description' => __( 'List of available term names of the attribute.', 'woocommerce' ),
2230
+								'description' => __('List of available term names of the attribute.', 'woocommerce'),
2231 2231
 								'type'        => 'array',
2232
-								'context'     => array( 'view', 'edit' ),
2232
+								'context'     => array('view', 'edit'),
2233 2233
 							),
2234 2234
 						),
2235 2235
 					),
2236 2236
 				),
2237 2237
 				'default_attributes' => array(
2238
-					'description' => __( 'Defaults variation attributes.', 'woocommerce' ),
2238
+					'description' => __('Defaults variation attributes.', 'woocommerce'),
2239 2239
 					'type'        => 'array',
2240
-					'context'     => array( 'view', 'edit' ),
2240
+					'context'     => array('view', 'edit'),
2241 2241
 					'items'       => array(
2242 2242
 						'type'       => 'object',
2243 2243
 						'properties' => array(
2244 2244
 							'id' => array(
2245
-								'description' => __( 'Attribute ID.', 'woocommerce' ),
2245
+								'description' => __('Attribute ID.', 'woocommerce'),
2246 2246
 								'type'        => 'integer',
2247
-								'context'     => array( 'view', 'edit' ),
2247
+								'context'     => array('view', 'edit'),
2248 2248
 							),
2249 2249
 							'name' => array(
2250
-								'description' => __( 'Attribute name.', 'woocommerce' ),
2250
+								'description' => __('Attribute name.', 'woocommerce'),
2251 2251
 								'type'        => 'string',
2252
-								'context'     => array( 'view', 'edit' ),
2252
+								'context'     => array('view', 'edit'),
2253 2253
 							),
2254 2254
 							'option' => array(
2255
-								'description' => __( 'Selected attribute term name.', 'woocommerce' ),
2255
+								'description' => __('Selected attribute term name.', 'woocommerce'),
2256 2256
 								'type'        => 'string',
2257
-								'context'     => array( 'view', 'edit' ),
2257
+								'context'     => array('view', 'edit'),
2258 2258
 							),
2259 2259
 						),
2260 2260
 					),
2261 2261
 				),
2262 2262
 				'variations' => array(
2263
-					'description' => __( 'List of variations.', 'woocommerce' ),
2263
+					'description' => __('List of variations.', 'woocommerce'),
2264 2264
 					'type'        => 'array',
2265
-					'context'     => array( 'view', 'edit' ),
2265
+					'context'     => array('view', 'edit'),
2266 2266
 					'items'       => array(
2267 2267
 						'type'       => 'object',
2268 2268
 						'properties' => array(
2269 2269
 							'id' => array(
2270
-								'description' => __( 'Variation ID.', 'woocommerce' ),
2270
+								'description' => __('Variation ID.', 'woocommerce'),
2271 2271
 								'type'        => 'integer',
2272
-								'context'     => array( 'view', 'edit' ),
2272
+								'context'     => array('view', 'edit'),
2273 2273
 								'readonly'    => true,
2274 2274
 							),
2275 2275
 							'date_created' => array(
2276
-								'description' => __( "The date the variation was created, in the site's timezone.", 'woocommerce' ),
2276
+								'description' => __("The date the variation was created, in the site's timezone.", 'woocommerce'),
2277 2277
 								'type'        => 'date-time',
2278
-								'context'     => array( 'view', 'edit' ),
2278
+								'context'     => array('view', 'edit'),
2279 2279
 								'readonly'    => true,
2280 2280
 							),
2281 2281
 							'date_modified' => array(
2282
-								'description' => __( "The date the variation was last modified, in the site's timezone.", 'woocommerce' ),
2282
+								'description' => __("The date the variation was last modified, in the site's timezone.", 'woocommerce'),
2283 2283
 								'type'        => 'date-time',
2284
-								'context'     => array( 'view', 'edit' ),
2284
+								'context'     => array('view', 'edit'),
2285 2285
 								'readonly'    => true,
2286 2286
 							),
2287 2287
 							'permalink' => array(
2288
-								'description' => __( 'Variation URL.', 'woocommerce' ),
2288
+								'description' => __('Variation URL.', 'woocommerce'),
2289 2289
 								'type'        => 'string',
2290 2290
 								'format'      => 'uri',
2291
-								'context'     => array( 'view', 'edit' ),
2291
+								'context'     => array('view', 'edit'),
2292 2292
 								'readonly'    => true,
2293 2293
 							),
2294 2294
 							'sku' => array(
2295
-								'description' => __( 'Unique identifier.', 'woocommerce' ),
2295
+								'description' => __('Unique identifier.', 'woocommerce'),
2296 2296
 								'type'        => 'string',
2297
-								'context'     => array( 'view', 'edit' ),
2297
+								'context'     => array('view', 'edit'),
2298 2298
 							),
2299 2299
 							'price' => array(
2300
-								'description' => __( 'Current variation price.', 'woocommerce' ),
2300
+								'description' => __('Current variation price.', 'woocommerce'),
2301 2301
 								'type'        => 'string',
2302
-								'context'     => array( 'view', 'edit' ),
2302
+								'context'     => array('view', 'edit'),
2303 2303
 								'readonly'    => true,
2304 2304
 							),
2305 2305
 							'regular_price' => array(
2306
-								'description' => __( 'Variation regular price.', 'woocommerce' ),
2306
+								'description' => __('Variation regular price.', 'woocommerce'),
2307 2307
 								'type'        => 'string',
2308
-								'context'     => array( 'view', 'edit' ),
2308
+								'context'     => array('view', 'edit'),
2309 2309
 							),
2310 2310
 							'sale_price' => array(
2311
-								'description' => __( 'Variation sale price.', 'woocommerce' ),
2311
+								'description' => __('Variation sale price.', 'woocommerce'),
2312 2312
 								'type'        => 'string',
2313
-								'context'     => array( 'view', 'edit' ),
2313
+								'context'     => array('view', 'edit'),
2314 2314
 							),
2315 2315
 							'date_on_sale_from' => array(
2316
-								'description' => __( 'Start date of sale price.', 'woocommerce' ),
2316
+								'description' => __('Start date of sale price.', 'woocommerce'),
2317 2317
 								'type'        => 'string',
2318
-								'context'     => array( 'view', 'edit' ),
2318
+								'context'     => array('view', 'edit'),
2319 2319
 							),
2320 2320
 							'date_on_sale_to' => array(
2321
-								'description' => __( 'End date of sale price.', 'woocommerce' ),
2321
+								'description' => __('End date of sale price.', 'woocommerce'),
2322 2322
 								'type'        => 'string',
2323
-								'context'     => array( 'view', 'edit' ),
2323
+								'context'     => array('view', 'edit'),
2324 2324
 							),
2325 2325
 							'on_sale' => array(
2326
-								'description' => __( 'Shows if the variation is on sale.', 'woocommerce' ),
2326
+								'description' => __('Shows if the variation is on sale.', 'woocommerce'),
2327 2327
 								'type'        => 'boolean',
2328
-								'context'     => array( 'view', 'edit' ),
2328
+								'context'     => array('view', 'edit'),
2329 2329
 								'readonly'    => true,
2330 2330
 							),
2331 2331
 							'purchasable' => array(
2332
-								'description' => __( 'Shows if the variation can be bought.', 'woocommerce' ),
2332
+								'description' => __('Shows if the variation can be bought.', 'woocommerce'),
2333 2333
 								'type'        => 'boolean',
2334
-								'context'     => array( 'view', 'edit' ),
2334
+								'context'     => array('view', 'edit'),
2335 2335
 								'readonly'    => true,
2336 2336
 							),
2337 2337
 							'visible' => array(
2338
-								'description' => __( 'If the variation is visible.', 'woocommerce' ),
2338
+								'description' => __('If the variation is visible.', 'woocommerce'),
2339 2339
 								'type'        => 'boolean',
2340
-								'context'     => array( 'view', 'edit' ),
2340
+								'context'     => array('view', 'edit'),
2341 2341
 							),
2342 2342
 							'virtual' => array(
2343
-								'description' => __( 'If the variation is virtual.', 'woocommerce' ),
2343
+								'description' => __('If the variation is virtual.', 'woocommerce'),
2344 2344
 								'type'        => 'boolean',
2345 2345
 								'default'     => false,
2346
-								'context'     => array( 'view', 'edit' ),
2346
+								'context'     => array('view', 'edit'),
2347 2347
 							),
2348 2348
 							'downloadable' => array(
2349
-								'description' => __( 'If the variation is downloadable.', 'woocommerce' ),
2349
+								'description' => __('If the variation is downloadable.', 'woocommerce'),
2350 2350
 								'type'        => 'boolean',
2351 2351
 								'default'     => false,
2352
-								'context'     => array( 'view', 'edit' ),
2352
+								'context'     => array('view', 'edit'),
2353 2353
 							),
2354 2354
 							'downloads' => array(
2355
-								'description' => __( 'List of downloadable files.', 'woocommerce' ),
2355
+								'description' => __('List of downloadable files.', 'woocommerce'),
2356 2356
 								'type'        => 'array',
2357
-								'context'     => array( 'view', 'edit' ),
2357
+								'context'     => array('view', 'edit'),
2358 2358
 								'items'       => array(
2359 2359
 									'type'       => 'object',
2360 2360
 									'properties' => array(
2361 2361
 										'id' => array(
2362
-											'description' => __( 'File ID.', 'woocommerce' ),
2362
+											'description' => __('File ID.', 'woocommerce'),
2363 2363
 											'type'        => 'string',
2364
-											'context'     => array( 'view', 'edit' ),
2364
+											'context'     => array('view', 'edit'),
2365 2365
 										),
2366 2366
 										'name' => array(
2367
-											'description' => __( 'File name.', 'woocommerce' ),
2367
+											'description' => __('File name.', 'woocommerce'),
2368 2368
 											'type'        => 'string',
2369
-											'context'     => array( 'view', 'edit' ),
2369
+											'context'     => array('view', 'edit'),
2370 2370
 										),
2371 2371
 										'file' => array(
2372
-											'description' => __( 'File URL.', 'woocommerce' ),
2372
+											'description' => __('File URL.', 'woocommerce'),
2373 2373
 											'type'        => 'string',
2374
-											'context'     => array( 'view', 'edit' ),
2374
+											'context'     => array('view', 'edit'),
2375 2375
 										),
2376 2376
 									),
2377 2377
 								),
2378 2378
 							),
2379 2379
 							'download_limit' => array(
2380
-								'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce' ),
2380
+								'description' => __('Number of times downloadable files can be downloaded after purchase.', 'woocommerce'),
2381 2381
 								'type'        => 'integer',
2382 2382
 								'default'     => null,
2383
-								'context'     => array( 'view', 'edit' ),
2383
+								'context'     => array('view', 'edit'),
2384 2384
 							),
2385 2385
 							'download_expiry' => array(
2386
-								'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce' ),
2386
+								'description' => __('Number of days until access to downloadable files expires.', 'woocommerce'),
2387 2387
 								'type'        => 'integer',
2388 2388
 								'default'     => null,
2389
-								'context'     => array( 'view', 'edit' ),
2389
+								'context'     => array('view', 'edit'),
2390 2390
 							),
2391 2391
 							'tax_status' => array(
2392
-								'description' => __( 'Tax status.', 'woocommerce' ),
2392
+								'description' => __('Tax status.', 'woocommerce'),
2393 2393
 								'type'        => 'string',
2394 2394
 								'default'     => 'taxable',
2395
-								'enum'        => array( 'taxable', 'shipping', 'none' ),
2396
-								'context'     => array( 'view', 'edit' ),
2395
+								'enum'        => array('taxable', 'shipping', 'none'),
2396
+								'context'     => array('view', 'edit'),
2397 2397
 							),
2398 2398
 							'tax_class' => array(
2399
-								'description' => __( 'Tax class.', 'woocommerce' ),
2399
+								'description' => __('Tax class.', 'woocommerce'),
2400 2400
 								'type'        => 'string',
2401
-								'context'     => array( 'view', 'edit' ),
2401
+								'context'     => array('view', 'edit'),
2402 2402
 							),
2403 2403
 							'manage_stock' => array(
2404
-								'description' => __( 'Stock management at variation level.', 'woocommerce' ),
2404
+								'description' => __('Stock management at variation level.', 'woocommerce'),
2405 2405
 								'type'        => 'boolean',
2406 2406
 								'default'     => false,
2407
-								'context'     => array( 'view', 'edit' ),
2407
+								'context'     => array('view', 'edit'),
2408 2408
 							),
2409 2409
 							'stock_quantity' => array(
2410
-								'description' => __( 'Stock quantity.', 'woocommerce' ),
2410
+								'description' => __('Stock quantity.', 'woocommerce'),
2411 2411
 								'type'        => 'integer',
2412
-								'context'     => array( 'view', 'edit' ),
2412
+								'context'     => array('view', 'edit'),
2413 2413
 							),
2414 2414
 							'in_stock' => array(
2415
-								'description' => __( 'Controls whether or not the variation is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ),
2415
+								'description' => __('Controls whether or not the variation is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce'),
2416 2416
 								'type'        => 'boolean',
2417 2417
 								'default'     => true,
2418
-								'context'     => array( 'view', 'edit' ),
2418
+								'context'     => array('view', 'edit'),
2419 2419
 							),
2420 2420
 							'backorders' => array(
2421
-								'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce' ),
2421
+								'description' => __('If managing stock, this controls if backorders are allowed.', 'woocommerce'),
2422 2422
 								'type'        => 'string',
2423 2423
 								'default'     => 'no',
2424
-								'enum'        => array( 'no', 'notify', 'yes' ),
2425
-								'context'     => array( 'view', 'edit' ),
2424
+								'enum'        => array('no', 'notify', 'yes'),
2425
+								'context'     => array('view', 'edit'),
2426 2426
 							),
2427 2427
 							'backorders_allowed' => array(
2428
-								'description' => __( 'Shows if backorders are allowed.', 'woocommerce' ),
2428
+								'description' => __('Shows if backorders are allowed.', 'woocommerce'),
2429 2429
 								'type'        => 'boolean',
2430
-								'context'     => array( 'view', 'edit' ),
2430
+								'context'     => array('view', 'edit'),
2431 2431
 								'readonly'    => true,
2432 2432
 							),
2433 2433
 							'backordered' => array(
2434
-								'description' => __( 'Shows if the variation is on backordered.', 'woocommerce' ),
2434
+								'description' => __('Shows if the variation is on backordered.', 'woocommerce'),
2435 2435
 								'type'        => 'boolean',
2436
-								'context'     => array( 'view', 'edit' ),
2436
+								'context'     => array('view', 'edit'),
2437 2437
 								'readonly'    => true,
2438 2438
 							),
2439 2439
 							'weight' => array(
2440 2440
 								/* translators: %s: weight unit */
2441
-								'description' => sprintf( __( 'Variation weight (%s).', 'woocommerce' ), $weight_unit ),
2441
+								'description' => sprintf(__('Variation weight (%s).', 'woocommerce'), $weight_unit),
2442 2442
 								'type'        => 'string',
2443
-								'context'     => array( 'view', 'edit' ),
2443
+								'context'     => array('view', 'edit'),
2444 2444
 							),
2445 2445
 							'dimensions' => array(
2446
-								'description' => __( 'Variation dimensions.', 'woocommerce' ),
2446
+								'description' => __('Variation dimensions.', 'woocommerce'),
2447 2447
 								'type'        => 'object',
2448
-								'context'     => array( 'view', 'edit' ),
2448
+								'context'     => array('view', 'edit'),
2449 2449
 								'properties'  => array(
2450 2450
 									'length' => array(
2451 2451
 										/* translators: %s: dimension unit */
2452
-										'description' => sprintf( __( 'Variation length (%s).', 'woocommerce' ), $dimension_unit ),
2452
+										'description' => sprintf(__('Variation length (%s).', 'woocommerce'), $dimension_unit),
2453 2453
 										'type'        => 'string',
2454
-										'context'     => array( 'view', 'edit' ),
2454
+										'context'     => array('view', 'edit'),
2455 2455
 									),
2456 2456
 									'width' => array(
2457 2457
 										/* translators: %s: dimension unit */
2458
-										'description' => sprintf( __( 'Variation width (%s).', 'woocommerce' ), $dimension_unit ),
2458
+										'description' => sprintf(__('Variation width (%s).', 'woocommerce'), $dimension_unit),
2459 2459
 										'type'        => 'string',
2460
-										'context'     => array( 'view', 'edit' ),
2460
+										'context'     => array('view', 'edit'),
2461 2461
 									),
2462 2462
 									'height' => array(
2463 2463
 										/* translators: %s: dimension unit */
2464
-										'description' => sprintf( __( 'Variation height (%s).', 'woocommerce' ), $dimension_unit ),
2464
+										'description' => sprintf(__('Variation height (%s).', 'woocommerce'), $dimension_unit),
2465 2465
 										'type'        => 'string',
2466
-										'context'     => array( 'view', 'edit' ),
2466
+										'context'     => array('view', 'edit'),
2467 2467
 									),
2468 2468
 								),
2469 2469
 							),
2470 2470
 							'shipping_class' => array(
2471
-								'description' => __( 'Shipping class slug.', 'woocommerce' ),
2471
+								'description' => __('Shipping class slug.', 'woocommerce'),
2472 2472
 								'type'        => 'string',
2473
-								'context'     => array( 'view', 'edit' ),
2473
+								'context'     => array('view', 'edit'),
2474 2474
 							),
2475 2475
 							'shipping_class_id' => array(
2476
-								'description' => __( 'Shipping class ID.', 'woocommerce' ),
2476
+								'description' => __('Shipping class ID.', 'woocommerce'),
2477 2477
 								'type'        => 'integer',
2478
-								'context'     => array( 'view', 'edit' ),
2478
+								'context'     => array('view', 'edit'),
2479 2479
 								'readonly'    => true,
2480 2480
 							),
2481 2481
 							'image' => array(
2482
-								'description' => __( 'Variation image data.', 'woocommerce' ),
2482
+								'description' => __('Variation image data.', 'woocommerce'),
2483 2483
 								'type'        => 'object',
2484
-								'context'     => array( 'view', 'edit' ),
2484
+								'context'     => array('view', 'edit'),
2485 2485
 								'properties'  => array(
2486 2486
 									'id' => array(
2487
-										'description' => __( 'Image ID.', 'woocommerce' ),
2487
+										'description' => __('Image ID.', 'woocommerce'),
2488 2488
 										'type'        => 'integer',
2489
-										'context'     => array( 'view', 'edit' ),
2489
+										'context'     => array('view', 'edit'),
2490 2490
 									),
2491 2491
 									'date_created' => array(
2492
-										'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ),
2492
+										'description' => __("The date the image was created, in the site's timezone.", 'woocommerce'),
2493 2493
 										'type'        => 'date-time',
2494
-										'context'     => array( 'view', 'edit' ),
2494
+										'context'     => array('view', 'edit'),
2495 2495
 										'readonly'    => true,
2496 2496
 									),
2497 2497
 									'date_modified' => array(
2498
-										'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ),
2498
+										'description' => __("The date the image was last modified, in the site's timezone.", 'woocommerce'),
2499 2499
 										'type'        => 'date-time',
2500
-										'context'     => array( 'view', 'edit' ),
2500
+										'context'     => array('view', 'edit'),
2501 2501
 										'readonly'    => true,
2502 2502
 									),
2503 2503
 									'src' => array(
2504
-										'description' => __( 'Image URL.', 'woocommerce' ),
2504
+										'description' => __('Image URL.', 'woocommerce'),
2505 2505
 										'type'        => 'string',
2506 2506
 										'format'      => 'uri',
2507
-										'context'     => array( 'view', 'edit' ),
2507
+										'context'     => array('view', 'edit'),
2508 2508
 									),
2509 2509
 									'name' => array(
2510
-										'description' => __( 'Image name.', 'woocommerce' ),
2510
+										'description' => __('Image name.', 'woocommerce'),
2511 2511
 										'type'        => 'string',
2512
-										'context'     => array( 'view', 'edit' ),
2512
+										'context'     => array('view', 'edit'),
2513 2513
 									),
2514 2514
 									'alt' => array(
2515
-										'description' => __( 'Image alternative text.', 'woocommerce' ),
2515
+										'description' => __('Image alternative text.', 'woocommerce'),
2516 2516
 										'type'        => 'string',
2517
-										'context'     => array( 'view', 'edit' ),
2517
+										'context'     => array('view', 'edit'),
2518 2518
 									),
2519 2519
 									'position' => array(
2520
-										'description' => __( 'Image position. 0 means that the image is featured.', 'woocommerce' ),
2520
+										'description' => __('Image position. 0 means that the image is featured.', 'woocommerce'),
2521 2521
 										'type'        => 'integer',
2522
-										'context'     => array( 'view', 'edit' ),
2522
+										'context'     => array('view', 'edit'),
2523 2523
 									),
2524 2524
 								),
2525 2525
 							),
2526 2526
 							'attributes' => array(
2527
-								'description' => __( 'List of attributes.', 'woocommerce' ),
2527
+								'description' => __('List of attributes.', 'woocommerce'),
2528 2528
 								'type'        => 'array',
2529
-								'context'     => array( 'view', 'edit' ),
2529
+								'context'     => array('view', 'edit'),
2530 2530
 								'items'       => array(
2531 2531
 									'type'       => 'object',
2532 2532
 									'properties' => array(
2533 2533
 										'id' => array(
2534
-											'description' => __( 'Attribute ID.', 'woocommerce' ),
2534
+											'description' => __('Attribute ID.', 'woocommerce'),
2535 2535
 											'type'        => 'integer',
2536
-											'context'     => array( 'view', 'edit' ),
2536
+											'context'     => array('view', 'edit'),
2537 2537
 										),
2538 2538
 										'name' => array(
2539
-											'description' => __( 'Attribute name.', 'woocommerce' ),
2539
+											'description' => __('Attribute name.', 'woocommerce'),
2540 2540
 											'type'        => 'string',
2541
-											'context'     => array( 'view', 'edit' ),
2541
+											'context'     => array('view', 'edit'),
2542 2542
 										),
2543 2543
 										'option' => array(
2544
-											'description' => __( 'Selected attribute term name.', 'woocommerce' ),
2544
+											'description' => __('Selected attribute term name.', 'woocommerce'),
2545 2545
 											'type'        => 'string',
2546
-											'context'     => array( 'view', 'edit' ),
2546
+											'context'     => array('view', 'edit'),
2547 2547
 										),
2548 2548
 									),
2549 2549
 								),
@@ -2552,23 +2552,23 @@  discard block
 block discarded – undo
2552 2552
 					),
2553 2553
 				),
2554 2554
 				'grouped_products' => array(
2555
-					'description' => __( 'List of grouped products ID.', 'woocommerce' ),
2555
+					'description' => __('List of grouped products ID.', 'woocommerce'),
2556 2556
 					'type'        => 'array',
2557 2557
 					'items'       => array(
2558 2558
 						'type'    => 'integer',
2559 2559
 					),
2560
-					'context'     => array( 'view', 'edit' ),
2560
+					'context'     => array('view', 'edit'),
2561 2561
 					'readonly'    => true,
2562 2562
 				),
2563 2563
 				'menu_order' => array(
2564
-					'description' => __( 'Menu order, used to custom sort products.', 'woocommerce' ),
2564
+					'description' => __('Menu order, used to custom sort products.', 'woocommerce'),
2565 2565
 					'type'        => 'integer',
2566
-					'context'     => array( 'view', 'edit' ),
2566
+					'context'     => array('view', 'edit'),
2567 2567
 				),
2568 2568
 			),
2569 2569
 		);
2570 2570
 
2571
-		return $this->add_additional_fields_schema( $schema );
2571
+		return $this->add_additional_fields_schema($schema);
2572 2572
 	}
2573 2573
 
2574 2574
 	/**
@@ -2580,57 +2580,57 @@  discard block
 block discarded – undo
2580 2580
 		$params = parent::get_collection_params();
2581 2581
 
2582 2582
 		$params['slug'] = array(
2583
-			'description'       => __( 'Limit result set to products with a specific slug.', 'woocommerce' ),
2583
+			'description'       => __('Limit result set to products with a specific slug.', 'woocommerce'),
2584 2584
 			'type'              => 'string',
2585 2585
 			'validate_callback' => 'rest_validate_request_arg',
2586 2586
 		);
2587 2587
 		$params['status'] = array(
2588 2588
 			'default'           => 'any',
2589
-			'description'       => __( 'Limit result set to products assigned a specific status.', 'woocommerce' ),
2589
+			'description'       => __('Limit result set to products assigned a specific status.', 'woocommerce'),
2590 2590
 			'type'              => 'string',
2591
-			'enum'              => array_merge( array( 'any', 'future' ), array_keys( get_post_statuses() ) ),
2591
+			'enum'              => array_merge(array('any', 'future'), array_keys(get_post_statuses())),
2592 2592
 			'sanitize_callback' => 'sanitize_key',
2593 2593
 			'validate_callback' => 'rest_validate_request_arg',
2594 2594
 		);
2595 2595
 		$params['type'] = array(
2596
-			'description'       => __( 'Limit result set to products assigned a specific type.', 'woocommerce' ),
2596
+			'description'       => __('Limit result set to products assigned a specific type.', 'woocommerce'),
2597 2597
 			'type'              => 'string',
2598
-			'enum'              => array_keys( wc_get_product_types() ),
2598
+			'enum'              => array_keys(wc_get_product_types()),
2599 2599
 			'sanitize_callback' => 'sanitize_key',
2600 2600
 			'validate_callback' => 'rest_validate_request_arg',
2601 2601
 		);
2602 2602
 		$params['category'] = array(
2603
-			'description'       => __( 'Limit result set to products assigned a specific category ID.', 'woocommerce' ),
2603
+			'description'       => __('Limit result set to products assigned a specific category ID.', 'woocommerce'),
2604 2604
 			'type'              => 'string',
2605 2605
 			'sanitize_callback' => 'wp_parse_id_list',
2606 2606
 			'validate_callback' => 'rest_validate_request_arg',
2607 2607
 		);
2608 2608
 		$params['tag'] = array(
2609
-			'description'       => __( 'Limit result set to products assigned a specific tag ID.', 'woocommerce' ),
2609
+			'description'       => __('Limit result set to products assigned a specific tag ID.', 'woocommerce'),
2610 2610
 			'type'              => 'string',
2611 2611
 			'sanitize_callback' => 'wp_parse_id_list',
2612 2612
 			'validate_callback' => 'rest_validate_request_arg',
2613 2613
 		);
2614 2614
 		$params['shipping_class'] = array(
2615
-			'description'       => __( 'Limit result set to products assigned a specific shipping class ID.', 'woocommerce' ),
2615
+			'description'       => __('Limit result set to products assigned a specific shipping class ID.', 'woocommerce'),
2616 2616
 			'type'              => 'string',
2617 2617
 			'sanitize_callback' => 'wp_parse_id_list',
2618 2618
 			'validate_callback' => 'rest_validate_request_arg',
2619 2619
 		);
2620 2620
 		$params['attribute'] = array(
2621
-			'description'       => __( 'Limit result set to products with a specific attribute.', 'woocommerce' ),
2621
+			'description'       => __('Limit result set to products with a specific attribute.', 'woocommerce'),
2622 2622
 			'type'              => 'string',
2623 2623
 			'sanitize_callback' => 'sanitize_text_field',
2624 2624
 			'validate_callback' => 'rest_validate_request_arg',
2625 2625
 		);
2626 2626
 		$params['attribute_term'] = array(
2627
-			'description'       => __( 'Limit result set to products with a specific attribute term ID (required an assigned attribute).', 'woocommerce' ),
2627
+			'description'       => __('Limit result set to products with a specific attribute term ID (required an assigned attribute).', 'woocommerce'),
2628 2628
 			'type'              => 'string',
2629 2629
 			'sanitize_callback' => 'wp_parse_id_list',
2630 2630
 			'validate_callback' => 'rest_validate_request_arg',
2631 2631
 		);
2632 2632
 		$params['sku'] = array(
2633
-			'description'       => __( 'Limit result set to products with a specific SKU.', 'woocommerce' ),
2633
+			'description'       => __('Limit result set to products with a specific SKU.', 'woocommerce'),
2634 2634
 			'type'              => 'string',
2635 2635
 			'sanitize_callback' => 'sanitize_text_field',
2636 2636
 			'validate_callback' => 'rest_validate_request_arg',
Please login to merge, or discard this patch.