@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 2.6.0 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * REST API Coupons controller class. |
@@ -47,25 +47,25 @@ discard block |
||
47 | 47 | $this->namespace, '/' . $this->rest_base, array( |
48 | 48 | array( |
49 | 49 | 'methods' => WP_REST_Server::READABLE, |
50 | - 'callback' => array( $this, 'get_items' ), |
|
51 | - 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
50 | + 'callback' => array($this, 'get_items'), |
|
51 | + 'permission_callback' => array($this, 'get_items_permissions_check'), |
|
52 | 52 | 'args' => $this->get_collection_params(), |
53 | 53 | ), |
54 | 54 | array( |
55 | 55 | 'methods' => WP_REST_Server::CREATABLE, |
56 | - 'callback' => array( $this, 'create_item' ), |
|
57 | - 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
|
56 | + 'callback' => array($this, 'create_item'), |
|
57 | + 'permission_callback' => array($this, 'create_item_permissions_check'), |
|
58 | 58 | 'args' => array_merge( |
59 | - $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( |
|
59 | + $this->get_endpoint_args_for_item_schema(WP_REST_Server::CREATABLE), array( |
|
60 | 60 | 'code' => array( |
61 | - 'description' => __( 'Coupon code.', 'woocommerce' ), |
|
61 | + 'description' => __('Coupon code.', 'woocommerce'), |
|
62 | 62 | 'required' => true, |
63 | 63 | 'type' => 'string', |
64 | 64 | ), |
65 | 65 | ) |
66 | 66 | ), |
67 | 67 | ), |
68 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
68 | + 'schema' => array($this, 'get_public_item_schema'), |
|
69 | 69 | ) |
70 | 70 | ); |
71 | 71 | |
@@ -73,37 +73,37 @@ discard block |
||
73 | 73 | $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' ), |
|
106 | + 'schema' => array($this, 'get_public_item_schema'), |
|
107 | 107 | ) |
108 | 108 | ); |
109 | 109 | |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | $this->namespace, '/' . $this->rest_base . '/batch', array( |
112 | 112 | array( |
113 | 113 | 'methods' => WP_REST_Server::EDITABLE, |
114 | - 'callback' => array( $this, 'batch_items' ), |
|
115 | - 'permission_callback' => array( $this, 'batch_items_permissions_check' ), |
|
116 | - 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
114 | + 'callback' => array($this, 'batch_items'), |
|
115 | + 'permission_callback' => array($this, 'batch_items_permissions_check'), |
|
116 | + 'args' => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE), |
|
117 | 117 | ), |
118 | - 'schema' => array( $this, 'get_public_batch_schema' ), |
|
118 | + 'schema' => array($this, 'get_public_batch_schema'), |
|
119 | 119 | ) |
120 | 120 | ); |
121 | 121 | } |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | * @param int $id Object ID. |
128 | 128 | * @return WC_Data |
129 | 129 | */ |
130 | - protected function get_object( $id ) { |
|
131 | - return new WC_Coupon( $id ); |
|
130 | + protected function get_object($id) { |
|
131 | + return new WC_Coupon($id); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -138,28 +138,28 @@ discard block |
||
138 | 138 | * @param WC_Data $object WC_Data instance. |
139 | 139 | * @return array |
140 | 140 | */ |
141 | - protected function get_formatted_item_data( $object ) { |
|
141 | + protected function get_formatted_item_data($object) { |
|
142 | 142 | $data = $object->get_data(); |
143 | 143 | |
144 | - $format_decimal = array( 'amount', 'minimum_amount', 'maximum_amount' ); |
|
145 | - $format_date = array( 'date_created', 'date_modified', 'date_expires' ); |
|
146 | - $format_null = array( 'usage_limit', 'usage_limit_per_user', 'limit_usage_to_x_items' ); |
|
144 | + $format_decimal = array('amount', 'minimum_amount', 'maximum_amount'); |
|
145 | + $format_date = array('date_created', 'date_modified', 'date_expires'); |
|
146 | + $format_null = array('usage_limit', 'usage_limit_per_user', 'limit_usage_to_x_items'); |
|
147 | 147 | |
148 | 148 | // Format decimal values. |
149 | - foreach ( $format_decimal as $key ) { |
|
150 | - $data[ $key ] = wc_format_decimal( $data[ $key ], 2 ); |
|
149 | + foreach ($format_decimal as $key) { |
|
150 | + $data[$key] = wc_format_decimal($data[$key], 2); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Format date values. |
154 | - foreach ( $format_date as $key ) { |
|
155 | - $datetime = $data[ $key ]; |
|
156 | - $data[ $key ] = wc_rest_prepare_date_response( $datetime, false ); |
|
157 | - $data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime ); |
|
154 | + foreach ($format_date as $key) { |
|
155 | + $datetime = $data[$key]; |
|
156 | + $data[$key] = wc_rest_prepare_date_response($datetime, false); |
|
157 | + $data[$key . '_gmt'] = wc_rest_prepare_date_response($datetime); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | // Format null values. |
161 | - foreach ( $format_null as $key ) { |
|
162 | - $data[ $key ] = $data[ $key ] ? $data[ $key ] : null; |
|
161 | + foreach ($format_null as $key) { |
|
162 | + $data[$key] = $data[$key] ? $data[$key] : null; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | return array( |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | * @param WP_REST_Request $request Request object. |
202 | 202 | * @return WP_REST_Response |
203 | 203 | */ |
204 | - public function prepare_object_for_response( $object, $request ) { |
|
205 | - $data = $this->get_formatted_item_data( $object ); |
|
206 | - $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
207 | - $data = $this->add_additional_fields_to_object( $data, $request ); |
|
208 | - $data = $this->filter_response_by_context( $data, $context ); |
|
209 | - $response = rest_ensure_response( $data ); |
|
210 | - $response->add_links( $this->prepare_links( $object, $request ) ); |
|
204 | + public function prepare_object_for_response($object, $request) { |
|
205 | + $data = $this->get_formatted_item_data($object); |
|
206 | + $context = ! empty($request['context']) ? $request['context'] : 'view'; |
|
207 | + $data = $this->add_additional_fields_to_object($data, $request); |
|
208 | + $data = $this->filter_response_by_context($data, $context); |
|
209 | + $response = rest_ensure_response($data); |
|
210 | + $response->add_links($this->prepare_links($object, $request)); |
|
211 | 211 | |
212 | 212 | /** |
213 | 213 | * Filter the data for a response. |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @param WC_Data $object Object data. |
220 | 220 | * @param WP_REST_Request $request Request object. |
221 | 221 | */ |
222 | - return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request ); |
|
222 | + return apply_filters("woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -229,12 +229,12 @@ discard block |
||
229 | 229 | * @param WP_REST_Request $request Full details about the request. |
230 | 230 | * @return array |
231 | 231 | */ |
232 | - protected function prepare_objects_query( $request ) { |
|
233 | - $args = parent::prepare_objects_query( $request ); |
|
232 | + protected function prepare_objects_query($request) { |
|
233 | + $args = parent::prepare_objects_query($request); |
|
234 | 234 | |
235 | - if ( ! empty( $request['code'] ) ) { |
|
236 | - $id = wc_get_coupon_id_by_code( $request['code'] ); |
|
237 | - $args['post__in'] = array( $id ); |
|
235 | + if ( ! empty($request['code'])) { |
|
236 | + $id = wc_get_coupon_id_by_code($request['code']); |
|
237 | + $args['post__in'] = array($id); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | // Get only ids. |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | * @param array $schema Schema. |
250 | 250 | * @return bool |
251 | 251 | */ |
252 | - protected function filter_writable_props( $schema ) { |
|
253 | - return empty( $schema['readonly'] ); |
|
252 | + protected function filter_writable_props($schema) { |
|
253 | + return empty($schema['readonly']); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -260,47 +260,47 @@ discard block |
||
260 | 260 | * @param bool $creating If is creating a new object. |
261 | 261 | * @return WP_Error|WC_Data |
262 | 262 | */ |
263 | - protected function prepare_object_for_database( $request, $creating = false ) { |
|
264 | - $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; |
|
265 | - $coupon = new WC_Coupon( $id ); |
|
263 | + protected function prepare_object_for_database($request, $creating = false) { |
|
264 | + $id = isset($request['id']) ? absint($request['id']) : 0; |
|
265 | + $coupon = new WC_Coupon($id); |
|
266 | 266 | $schema = $this->get_item_schema(); |
267 | - $data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) ); |
|
267 | + $data_keys = array_keys(array_filter($schema['properties'], array($this, 'filter_writable_props'))); |
|
268 | 268 | |
269 | 269 | // Validate required POST fields. |
270 | - if ( $creating && empty( $request['code'] ) ) { |
|
271 | - return new WP_Error( 'woocommerce_rest_empty_coupon_code', sprintf( __( 'The coupon code cannot be empty.', 'woocommerce' ), 'code' ), array( 'status' => 400 ) ); |
|
270 | + if ($creating && empty($request['code'])) { |
|
271 | + return new WP_Error('woocommerce_rest_empty_coupon_code', sprintf(__('The coupon code cannot be empty.', 'woocommerce'), 'code'), array('status' => 400)); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | // Handle all writable props. |
275 | - foreach ( $data_keys as $key ) { |
|
276 | - $value = $request[ $key ]; |
|
275 | + foreach ($data_keys as $key) { |
|
276 | + $value = $request[$key]; |
|
277 | 277 | |
278 | - if ( ! is_null( $value ) ) { |
|
279 | - switch ( $key ) { |
|
278 | + if ( ! is_null($value)) { |
|
279 | + switch ($key) { |
|
280 | 280 | case 'code': |
281 | - $coupon_code = wc_format_coupon_code( $value ); |
|
281 | + $coupon_code = wc_format_coupon_code($value); |
|
282 | 282 | $id = $coupon->get_id() ? $coupon->get_id() : 0; |
283 | - $id_from_code = wc_get_coupon_id_by_code( $coupon_code, $id ); |
|
283 | + $id_from_code = wc_get_coupon_id_by_code($coupon_code, $id); |
|
284 | 284 | |
285 | - if ( $id_from_code ) { |
|
286 | - return new WP_Error( 'woocommerce_rest_coupon_code_already_exists', __( 'The coupon code already exists', 'woocommerce' ), array( 'status' => 400 ) ); |
|
285 | + if ($id_from_code) { |
|
286 | + return new WP_Error('woocommerce_rest_coupon_code_already_exists', __('The coupon code already exists', 'woocommerce'), array('status' => 400)); |
|
287 | 287 | } |
288 | 288 | |
289 | - $coupon->set_code( $coupon_code ); |
|
289 | + $coupon->set_code($coupon_code); |
|
290 | 290 | break; |
291 | 291 | case 'meta_data': |
292 | - if ( is_array( $value ) ) { |
|
293 | - foreach ( $value as $meta ) { |
|
294 | - $coupon->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); |
|
292 | + if (is_array($value)) { |
|
293 | + foreach ($value as $meta) { |
|
294 | + $coupon->update_meta_data($meta['key'], $meta['value'], isset($meta['id']) ? $meta['id'] : ''); |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | break; |
298 | 298 | case 'description': |
299 | - $coupon->set_description( wp_filter_post_kses( $value ) ); |
|
299 | + $coupon->set_description(wp_filter_post_kses($value)); |
|
300 | 300 | break; |
301 | 301 | default: |
302 | - if ( is_callable( array( $coupon, "set_{$key}" ) ) ) { |
|
303 | - $coupon->{"set_{$key}"}( $value ); |
|
302 | + if (is_callable(array($coupon, "set_{$key}"))) { |
|
303 | + $coupon->{"set_{$key}"}($value); |
|
304 | 304 | } |
305 | 305 | break; |
306 | 306 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @param WP_REST_Request $request Request object. |
318 | 318 | * @param bool $creating If is creating a new object. |
319 | 319 | */ |
320 | - return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $coupon, $request, $creating ); |
|
320 | + return apply_filters("woocommerce_rest_pre_insert_{$this->post_type}_object", $coupon, $request, $creating); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -332,194 +332,194 @@ discard block |
||
332 | 332 | 'type' => 'object', |
333 | 333 | 'properties' => array( |
334 | 334 | 'id' => array( |
335 | - 'description' => __( 'Unique identifier for the object.', 'woocommerce' ), |
|
335 | + 'description' => __('Unique identifier for the object.', 'woocommerce'), |
|
336 | 336 | 'type' => 'integer', |
337 | - 'context' => array( 'view', 'edit' ), |
|
337 | + 'context' => array('view', 'edit'), |
|
338 | 338 | 'readonly' => true, |
339 | 339 | ), |
340 | 340 | 'code' => array( |
341 | - 'description' => __( 'Coupon code.', 'woocommerce' ), |
|
341 | + 'description' => __('Coupon code.', 'woocommerce'), |
|
342 | 342 | 'type' => 'string', |
343 | - 'context' => array( 'view', 'edit' ), |
|
343 | + 'context' => array('view', 'edit'), |
|
344 | 344 | ), |
345 | 345 | 'amount' => array( |
346 | - 'description' => __( 'The amount of discount. Should always be numeric, even if setting a percentage.', 'woocommerce' ), |
|
346 | + 'description' => __('The amount of discount. Should always be numeric, even if setting a percentage.', 'woocommerce'), |
|
347 | 347 | 'type' => 'string', |
348 | - 'context' => array( 'view', 'edit' ), |
|
348 | + 'context' => array('view', 'edit'), |
|
349 | 349 | ), |
350 | 350 | 'date_created' => array( |
351 | - 'description' => __( "The date the coupon was created, in the site's timezone.", 'woocommerce' ), |
|
351 | + 'description' => __("The date the coupon was created, in the site's timezone.", 'woocommerce'), |
|
352 | 352 | 'type' => 'date-time', |
353 | - 'context' => array( 'view', 'edit' ), |
|
353 | + 'context' => array('view', 'edit'), |
|
354 | 354 | 'readonly' => true, |
355 | 355 | ), |
356 | 356 | 'date_created_gmt' => array( |
357 | - 'description' => __( 'The date the coupon was created, as GMT.', 'woocommerce' ), |
|
357 | + 'description' => __('The date the coupon was created, as GMT.', 'woocommerce'), |
|
358 | 358 | 'type' => 'date-time', |
359 | - 'context' => array( 'view', 'edit' ), |
|
359 | + 'context' => array('view', 'edit'), |
|
360 | 360 | 'readonly' => true, |
361 | 361 | ), |
362 | 362 | 'date_modified' => array( |
363 | - 'description' => __( "The date the coupon was last modified, in the site's timezone.", 'woocommerce' ), |
|
363 | + 'description' => __("The date the coupon was last modified, in the site's timezone.", 'woocommerce'), |
|
364 | 364 | 'type' => 'date-time', |
365 | - 'context' => array( 'view', 'edit' ), |
|
365 | + 'context' => array('view', 'edit'), |
|
366 | 366 | 'readonly' => true, |
367 | 367 | ), |
368 | 368 | 'date_modified_gmt' => array( |
369 | - 'description' => __( 'The date the coupon was last modified, as GMT.', 'woocommerce' ), |
|
369 | + 'description' => __('The date the coupon was last modified, as GMT.', 'woocommerce'), |
|
370 | 370 | 'type' => 'date-time', |
371 | - 'context' => array( 'view', 'edit' ), |
|
371 | + 'context' => array('view', 'edit'), |
|
372 | 372 | 'readonly' => true, |
373 | 373 | ), |
374 | 374 | 'discount_type' => array( |
375 | - 'description' => __( 'Determines the type of discount that will be applied.', 'woocommerce' ), |
|
375 | + 'description' => __('Determines the type of discount that will be applied.', 'woocommerce'), |
|
376 | 376 | 'type' => 'string', |
377 | 377 | 'default' => 'fixed_cart', |
378 | - 'enum' => array_keys( wc_get_coupon_types() ), |
|
379 | - 'context' => array( 'view', 'edit' ), |
|
378 | + 'enum' => array_keys(wc_get_coupon_types()), |
|
379 | + 'context' => array('view', 'edit'), |
|
380 | 380 | ), |
381 | 381 | 'description' => array( |
382 | - 'description' => __( 'Coupon description.', 'woocommerce' ), |
|
382 | + 'description' => __('Coupon description.', 'woocommerce'), |
|
383 | 383 | 'type' => 'string', |
384 | - 'context' => array( 'view', 'edit' ), |
|
384 | + 'context' => array('view', 'edit'), |
|
385 | 385 | ), |
386 | 386 | 'date_expires' => array( |
387 | - 'description' => __( "The date the coupon expires, in the site's timezone.", 'woocommerce' ), |
|
387 | + 'description' => __("The date the coupon expires, in the site's timezone.", 'woocommerce'), |
|
388 | 388 | 'type' => 'string', |
389 | - 'context' => array( 'view', 'edit' ), |
|
389 | + 'context' => array('view', 'edit'), |
|
390 | 390 | ), |
391 | 391 | 'date_expires_gmt' => array( |
392 | - 'description' => __( 'The date the coupon expires, as GMT.', 'woocommerce' ), |
|
392 | + 'description' => __('The date the coupon expires, as GMT.', 'woocommerce'), |
|
393 | 393 | 'type' => 'string', |
394 | - 'context' => array( 'view', 'edit' ), |
|
394 | + 'context' => array('view', 'edit'), |
|
395 | 395 | ), |
396 | 396 | 'usage_count' => array( |
397 | - 'description' => __( 'Number of times the coupon has been used already.', 'woocommerce' ), |
|
397 | + 'description' => __('Number of times the coupon has been used already.', 'woocommerce'), |
|
398 | 398 | 'type' => 'integer', |
399 | - 'context' => array( 'view', 'edit' ), |
|
399 | + 'context' => array('view', 'edit'), |
|
400 | 400 | 'readonly' => true, |
401 | 401 | ), |
402 | 402 | 'individual_use' => array( |
403 | - 'description' => __( 'If true, the coupon can only be used individually. Other applied coupons will be removed from the cart.', 'woocommerce' ), |
|
403 | + 'description' => __('If true, the coupon can only be used individually. Other applied coupons will be removed from the cart.', 'woocommerce'), |
|
404 | 404 | 'type' => 'boolean', |
405 | 405 | 'default' => false, |
406 | - 'context' => array( 'view', 'edit' ), |
|
406 | + 'context' => array('view', 'edit'), |
|
407 | 407 | ), |
408 | 408 | 'product_ids' => array( |
409 | - 'description' => __( 'List of product IDs the coupon can be used on.', 'woocommerce' ), |
|
409 | + 'description' => __('List of product IDs the coupon can be used on.', 'woocommerce'), |
|
410 | 410 | 'type' => 'array', |
411 | 411 | 'items' => array( |
412 | 412 | 'type' => 'integer', |
413 | 413 | ), |
414 | - 'context' => array( 'view', 'edit' ), |
|
414 | + 'context' => array('view', 'edit'), |
|
415 | 415 | ), |
416 | 416 | 'excluded_product_ids' => array( |
417 | - 'description' => __( 'List of product IDs the coupon cannot be used on.', 'woocommerce' ), |
|
417 | + 'description' => __('List of product IDs the coupon cannot be used on.', 'woocommerce'), |
|
418 | 418 | 'type' => 'array', |
419 | 419 | 'items' => array( |
420 | 420 | 'type' => 'integer', |
421 | 421 | ), |
422 | - 'context' => array( 'view', 'edit' ), |
|
422 | + 'context' => array('view', 'edit'), |
|
423 | 423 | ), |
424 | 424 | 'usage_limit' => array( |
425 | - 'description' => __( 'How many times the coupon can be used in total.', 'woocommerce' ), |
|
425 | + 'description' => __('How many times the coupon can be used in total.', 'woocommerce'), |
|
426 | 426 | 'type' => 'integer', |
427 | - 'context' => array( 'view', 'edit' ), |
|
427 | + 'context' => array('view', 'edit'), |
|
428 | 428 | ), |
429 | 429 | 'usage_limit_per_user' => array( |
430 | - 'description' => __( 'How many times the coupon can be used per customer.', 'woocommerce' ), |
|
430 | + 'description' => __('How many times the coupon can be used per customer.', 'woocommerce'), |
|
431 | 431 | 'type' => 'integer', |
432 | - 'context' => array( 'view', 'edit' ), |
|
432 | + 'context' => array('view', 'edit'), |
|
433 | 433 | ), |
434 | 434 | 'limit_usage_to_x_items' => array( |
435 | - 'description' => __( 'Max number of items in the cart the coupon can be applied to.', 'woocommerce' ), |
|
435 | + 'description' => __('Max number of items in the cart the coupon can be applied to.', 'woocommerce'), |
|
436 | 436 | 'type' => 'integer', |
437 | - 'context' => array( 'view', 'edit' ), |
|
437 | + 'context' => array('view', 'edit'), |
|
438 | 438 | ), |
439 | 439 | 'free_shipping' => array( |
440 | - 'description' => __( 'If true and if the free shipping method requires a coupon, this coupon will enable free shipping.', 'woocommerce' ), |
|
440 | + 'description' => __('If true and if the free shipping method requires a coupon, this coupon will enable free shipping.', 'woocommerce'), |
|
441 | 441 | 'type' => 'boolean', |
442 | 442 | 'default' => false, |
443 | - 'context' => array( 'view', 'edit' ), |
|
443 | + 'context' => array('view', 'edit'), |
|
444 | 444 | ), |
445 | 445 | 'product_categories' => array( |
446 | - 'description' => __( 'List of category IDs the coupon applies to.', 'woocommerce' ), |
|
446 | + 'description' => __('List of category IDs the coupon applies to.', 'woocommerce'), |
|
447 | 447 | 'type' => 'array', |
448 | 448 | 'items' => array( |
449 | 449 | 'type' => 'integer', |
450 | 450 | ), |
451 | - 'context' => array( 'view', 'edit' ), |
|
451 | + 'context' => array('view', 'edit'), |
|
452 | 452 | ), |
453 | 453 | 'excluded_product_categories' => array( |
454 | - 'description' => __( 'List of category IDs the coupon does not apply to.', 'woocommerce' ), |
|
454 | + 'description' => __('List of category IDs the coupon does not apply to.', 'woocommerce'), |
|
455 | 455 | 'type' => 'array', |
456 | 456 | 'items' => array( |
457 | 457 | 'type' => 'integer', |
458 | 458 | ), |
459 | - 'context' => array( 'view', 'edit' ), |
|
459 | + 'context' => array('view', 'edit'), |
|
460 | 460 | ), |
461 | 461 | 'exclude_sale_items' => array( |
462 | - 'description' => __( 'If true, this coupon will not be applied to items that have sale prices.', 'woocommerce' ), |
|
462 | + 'description' => __('If true, this coupon will not be applied to items that have sale prices.', 'woocommerce'), |
|
463 | 463 | 'type' => 'boolean', |
464 | 464 | 'default' => false, |
465 | - 'context' => array( 'view', 'edit' ), |
|
465 | + 'context' => array('view', 'edit'), |
|
466 | 466 | ), |
467 | 467 | 'minimum_amount' => array( |
468 | - 'description' => __( 'Minimum order amount that needs to be in the cart before coupon applies.', 'woocommerce' ), |
|
468 | + 'description' => __('Minimum order amount that needs to be in the cart before coupon applies.', 'woocommerce'), |
|
469 | 469 | 'type' => 'string', |
470 | - 'context' => array( 'view', 'edit' ), |
|
470 | + 'context' => array('view', 'edit'), |
|
471 | 471 | ), |
472 | 472 | 'maximum_amount' => array( |
473 | - 'description' => __( 'Maximum order amount allowed when using the coupon.', 'woocommerce' ), |
|
473 | + 'description' => __('Maximum order amount allowed when using the coupon.', 'woocommerce'), |
|
474 | 474 | 'type' => 'string', |
475 | - 'context' => array( 'view', 'edit' ), |
|
475 | + 'context' => array('view', 'edit'), |
|
476 | 476 | ), |
477 | 477 | 'email_restrictions' => array( |
478 | - 'description' => __( 'List of email addresses that can use this coupon.', 'woocommerce' ), |
|
478 | + 'description' => __('List of email addresses that can use this coupon.', 'woocommerce'), |
|
479 | 479 | 'type' => 'array', |
480 | 480 | 'items' => array( |
481 | 481 | 'type' => 'string', |
482 | 482 | ), |
483 | - 'context' => array( 'view', 'edit' ), |
|
483 | + 'context' => array('view', 'edit'), |
|
484 | 484 | ), |
485 | 485 | 'used_by' => array( |
486 | - 'description' => __( 'List of user IDs (or guest email addresses) that have used the coupon.', 'woocommerce' ), |
|
486 | + 'description' => __('List of user IDs (or guest email addresses) that have used the coupon.', 'woocommerce'), |
|
487 | 487 | 'type' => 'array', |
488 | 488 | 'items' => array( |
489 | 489 | 'type' => 'integer', |
490 | 490 | ), |
491 | - 'context' => array( 'view', 'edit' ), |
|
491 | + 'context' => array('view', 'edit'), |
|
492 | 492 | 'readonly' => true, |
493 | 493 | ), |
494 | 494 | 'meta_data' => array( |
495 | - 'description' => __( 'Meta data.', 'woocommerce' ), |
|
495 | + 'description' => __('Meta data.', 'woocommerce'), |
|
496 | 496 | 'type' => 'array', |
497 | - 'context' => array( 'view', 'edit' ), |
|
497 | + 'context' => array('view', 'edit'), |
|
498 | 498 | 'items' => array( |
499 | 499 | 'type' => 'object', |
500 | 500 | 'properties' => array( |
501 | 501 | 'id' => array( |
502 | - 'description' => __( 'Meta ID.', 'woocommerce' ), |
|
502 | + 'description' => __('Meta ID.', 'woocommerce'), |
|
503 | 503 | 'type' => 'integer', |
504 | - 'context' => array( 'view', 'edit' ), |
|
504 | + 'context' => array('view', 'edit'), |
|
505 | 505 | 'readonly' => true, |
506 | 506 | ), |
507 | 507 | 'key' => array( |
508 | - 'description' => __( 'Meta key.', 'woocommerce' ), |
|
508 | + 'description' => __('Meta key.', 'woocommerce'), |
|
509 | 509 | 'type' => 'string', |
510 | - 'context' => array( 'view', 'edit' ), |
|
510 | + 'context' => array('view', 'edit'), |
|
511 | 511 | ), |
512 | 512 | 'value' => array( |
513 | - 'description' => __( 'Meta value.', 'woocommerce' ), |
|
513 | + 'description' => __('Meta value.', 'woocommerce'), |
|
514 | 514 | 'type' => 'mixed', |
515 | - 'context' => array( 'view', 'edit' ), |
|
515 | + 'context' => array('view', 'edit'), |
|
516 | 516 | ), |
517 | 517 | ), |
518 | 518 | ), |
519 | 519 | ), |
520 | 520 | ), |
521 | 521 | ); |
522 | - return $this->add_additional_fields_schema( $schema ); |
|
522 | + return $this->add_additional_fields_schema($schema); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | /** |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | $params = parent::get_collection_params(); |
532 | 532 | |
533 | 533 | $params['code'] = array( |
534 | - 'description' => __( 'Limit result set to resources with a specific code.', 'woocommerce' ), |
|
534 | + 'description' => __('Limit result set to resources with a specific code.', 'woocommerce'), |
|
535 | 535 | 'type' => 'string', |
536 | 536 | 'sanitize_callback' => 'sanitize_text_field', |
537 | 537 | 'validate_callback' => 'rest_validate_request_arg', |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 3.4.0 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * REST API Network Orders controller class. |
@@ -29,18 +29,18 @@ discard block |
||
29 | 29 | * Register the routes for network orders. |
30 | 30 | */ |
31 | 31 | public function register_routes() { |
32 | - if ( is_multisite() ) { |
|
32 | + if (is_multisite()) { |
|
33 | 33 | register_rest_route( |
34 | 34 | $this->namespace, |
35 | 35 | '/' . $this->rest_base . '/network', |
36 | 36 | array( |
37 | 37 | array( |
38 | 38 | 'methods' => WP_REST_Server::READABLE, |
39 | - 'callback' => array( $this, 'network_orders' ), |
|
40 | - 'permission_callback' => array( $this, 'network_orders_permissions_check' ), |
|
39 | + 'callback' => array($this, 'network_orders'), |
|
40 | + 'permission_callback' => array($this, 'network_orders_permissions_check'), |
|
41 | 41 | 'args' => $this->get_collection_params(), |
42 | 42 | ), |
43 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
43 | + 'schema' => array($this, 'get_public_item_schema'), |
|
44 | 44 | ) |
45 | 45 | ); |
46 | 46 | } |
@@ -54,34 +54,34 @@ discard block |
||
54 | 54 | public function get_public_item_schema() { |
55 | 55 | $schema = parent::get_public_item_schema(); |
56 | 56 | |
57 | - $schema['properties']['blog'] = array( |
|
58 | - 'description' => __( 'Blog id of the record on the multisite.', 'woocommerce' ), |
|
57 | + $schema['properties']['blog'] = array( |
|
58 | + 'description' => __('Blog id of the record on the multisite.', 'woocommerce'), |
|
59 | 59 | 'type' => 'integer', |
60 | - 'context' => array( 'view' ), |
|
60 | + 'context' => array('view'), |
|
61 | 61 | 'readonly' => true, |
62 | 62 | ); |
63 | - $schema['properties']['edit_url'] = array( |
|
64 | - 'description' => __( 'URL to edit the order', 'woocommerce' ), |
|
63 | + $schema['properties']['edit_url'] = array( |
|
64 | + 'description' => __('URL to edit the order', 'woocommerce'), |
|
65 | 65 | 'type' => 'string', |
66 | - 'context' => array( 'view' ), |
|
66 | + 'context' => array('view'), |
|
67 | 67 | 'readonly' => true, |
68 | 68 | ); |
69 | - $schema['properties']['customer'][] = array( |
|
70 | - 'description' => __( 'Name of the customer for the order', 'woocommerce' ), |
|
69 | + $schema['properties']['customer'][] = array( |
|
70 | + 'description' => __('Name of the customer for the order', 'woocommerce'), |
|
71 | 71 | 'type' => 'string', |
72 | - 'context' => array( 'view' ), |
|
72 | + 'context' => array('view'), |
|
73 | 73 | 'readonly' => true, |
74 | 74 | ); |
75 | - $schema['properties']['status_name'][] = array( |
|
76 | - 'description' => __( 'Order Status', 'woocommerce' ), |
|
75 | + $schema['properties']['status_name'][] = array( |
|
76 | + 'description' => __('Order Status', 'woocommerce'), |
|
77 | 77 | 'type' => 'string', |
78 | - 'context' => array( 'view' ), |
|
78 | + 'context' => array('view'), |
|
79 | 79 | 'readonly' => true, |
80 | 80 | ); |
81 | 81 | $schema['properties']['formatted_total'][] = array( |
82 | - 'description' => __( 'Order total formatted for locale', 'woocommerce' ), |
|
82 | + 'description' => __('Order total formatted for locale', 'woocommerce'), |
|
83 | 83 | 'type' => 'string', |
84 | - 'context' => array( 'view' ), |
|
84 | + 'context' => array('view'), |
|
85 | 85 | 'readonly' => true, |
86 | 86 | ); |
87 | 87 | |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return bool $permission |
97 | 97 | */ |
98 | - public function network_orders_permissions_check( $request ) { |
|
99 | - $blog_id = $request->get_param( 'blog_id' ); |
|
100 | - $blog_id = ! empty( $blog_id ) ? $blog_id : get_current_blog_id(); |
|
98 | + public function network_orders_permissions_check($request) { |
|
99 | + $blog_id = $request->get_param('blog_id'); |
|
100 | + $blog_id = ! empty($blog_id) ? $blog_id : get_current_blog_id(); |
|
101 | 101 | |
102 | - switch_to_blog( $blog_id ); |
|
102 | + switch_to_blog($blog_id); |
|
103 | 103 | |
104 | - $permission = $this->get_items_permissions_check( $request ); |
|
104 | + $permission = $this->get_items_permissions_check($request); |
|
105 | 105 | |
106 | 106 | restore_current_blog(); |
107 | 107 | |
@@ -115,39 +115,39 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return WP_REST_Response |
117 | 117 | */ |
118 | - public function network_orders( $request ) { |
|
119 | - $blog_id = $request->get_param( 'blog_id' ); |
|
120 | - $blog_id = ! empty( $blog_id ) ? $blog_id : get_current_blog_id(); |
|
121 | - $active_plugins = get_blog_option( $blog_id, 'active_plugins', array() ); |
|
122 | - $network_active_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
118 | + public function network_orders($request) { |
|
119 | + $blog_id = $request->get_param('blog_id'); |
|
120 | + $blog_id = ! empty($blog_id) ? $blog_id : get_current_blog_id(); |
|
121 | + $active_plugins = get_blog_option($blog_id, 'active_plugins', array()); |
|
122 | + $network_active_plugins = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
123 | 123 | |
124 | - $plugins = array_merge( $active_plugins, $network_active_plugins ); |
|
124 | + $plugins = array_merge($active_plugins, $network_active_plugins); |
|
125 | 125 | $wc_active = false; |
126 | - foreach ( $plugins as $plugin ) { |
|
127 | - if ( substr_compare( $plugin, '/woocommerce.php', strlen( $plugin ) - strlen( '/woocommerce.php' ), strlen( '/woocommerce.php' ) ) === 0 ) { |
|
126 | + foreach ($plugins as $plugin) { |
|
127 | + if (substr_compare($plugin, '/woocommerce.php', strlen($plugin) - strlen('/woocommerce.php'), strlen('/woocommerce.php')) === 0) { |
|
128 | 128 | $wc_active = true; |
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | 132 | // If WooCommerce not active for site, return an empty response. |
133 | - if ( ! $wc_active ) { |
|
134 | - $response = rest_ensure_response( array() ); |
|
133 | + if ( ! $wc_active) { |
|
134 | + $response = rest_ensure_response(array()); |
|
135 | 135 | return $response; |
136 | 136 | } |
137 | 137 | |
138 | - switch_to_blog( $blog_id ); |
|
139 | - add_filter( 'woocommerce_rest_orders_prepare_object_query', array( $this, 'network_orders_filter_args' ) ); |
|
140 | - $items = $this->get_items( $request ); |
|
141 | - remove_filter( 'woocommerce_rest_orders_prepare_object_query', array( $this, 'network_orders_filter_args' ) ); |
|
138 | + switch_to_blog($blog_id); |
|
139 | + add_filter('woocommerce_rest_orders_prepare_object_query', array($this, 'network_orders_filter_args')); |
|
140 | + $items = $this->get_items($request); |
|
141 | + remove_filter('woocommerce_rest_orders_prepare_object_query', array($this, 'network_orders_filter_args')); |
|
142 | 142 | |
143 | - foreach ( $items->data as &$current_order ) { |
|
144 | - $order = wc_get_order( $current_order['id'] ); |
|
143 | + foreach ($items->data as &$current_order) { |
|
144 | + $order = wc_get_order($current_order['id']); |
|
145 | 145 | |
146 | - $current_order['blog'] = get_blog_details( get_current_blog_id() ); |
|
147 | - $current_order['edit_url'] = get_admin_url( $blog_id, 'post.php?post=' . absint( $order->get_id() ) . '&action=edit' ); |
|
146 | + $current_order['blog'] = get_blog_details(get_current_blog_id()); |
|
147 | + $current_order['edit_url'] = get_admin_url($blog_id, 'post.php?post=' . absint($order->get_id()) . '&action=edit'); |
|
148 | 148 | /* translators: 1: first name 2: last name */ |
149 | - $current_order['customer'] = trim( sprintf( _x( '%1$s %2$s', 'full name', 'woocommerce' ), $order->get_billing_first_name(), $order->get_billing_last_name() ) ); |
|
150 | - $current_order['status_name'] = wc_get_order_status_name( $order->get_status() ); |
|
149 | + $current_order['customer'] = trim(sprintf(_x('%1$s %2$s', 'full name', 'woocommerce'), $order->get_billing_first_name(), $order->get_billing_last_name())); |
|
150 | + $current_order['status_name'] = wc_get_order_status_name($order->get_status()); |
|
151 | 151 | $current_order['formatted_total'] = $order->get_formatted_order_total(); |
152 | 152 | } |
153 | 153 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array |
165 | 165 | */ |
166 | - public function network_orders_filter_args( $args ) { |
|
166 | + public function network_orders_filter_args($args) { |
|
167 | 167 | $args['post_status'] = array( |
168 | 168 | 'wc-on-hold', |
169 | 169 | 'wc-processing', |
@@ -8,7 +8,7 @@ |
||
8 | 8 | * @since 2.6.0 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * REST API Taxes controller class. |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 2.6.0 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * REST API Webhooks controller class. |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | * @param WP_REST_Request $request Request object. |
33 | 33 | * @return WP_REST_Response $response |
34 | 34 | */ |
35 | - public function prepare_item_for_response( $id, $request ) { |
|
36 | - $webhook = wc_get_webhook( $id ); |
|
35 | + public function prepare_item_for_response($id, $request) { |
|
36 | + $webhook = wc_get_webhook($id); |
|
37 | 37 | |
38 | - if ( empty( $webhook ) || is_null( $webhook ) ) { |
|
39 | - return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) ); |
|
38 | + if (empty($webhook) || is_null($webhook)) { |
|
39 | + return new WP_Error("woocommerce_rest_{$this->post_type}_invalid_id", __('ID is invalid.', 'woocommerce'), array('status' => 400)); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $data = array( |
@@ -48,20 +48,20 @@ discard block |
||
48 | 48 | 'event' => $webhook->get_event(), |
49 | 49 | 'hooks' => $webhook->get_hooks(), |
50 | 50 | 'delivery_url' => $webhook->get_delivery_url(), |
51 | - 'date_created' => wc_rest_prepare_date_response( $webhook->get_date_created(), false ), |
|
52 | - 'date_created_gmt' => wc_rest_prepare_date_response( $webhook->get_date_created() ), |
|
53 | - 'date_modified' => wc_rest_prepare_date_response( $webhook->get_date_modified(), false ), |
|
54 | - 'date_modified_gmt' => wc_rest_prepare_date_response( $webhook->get_date_modified() ), |
|
51 | + 'date_created' => wc_rest_prepare_date_response($webhook->get_date_created(), false), |
|
52 | + 'date_created_gmt' => wc_rest_prepare_date_response($webhook->get_date_created()), |
|
53 | + 'date_modified' => wc_rest_prepare_date_response($webhook->get_date_modified(), false), |
|
54 | + 'date_modified_gmt' => wc_rest_prepare_date_response($webhook->get_date_modified()), |
|
55 | 55 | ); |
56 | 56 | |
57 | - $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
58 | - $data = $this->add_additional_fields_to_object( $data, $request ); |
|
59 | - $data = $this->filter_response_by_context( $data, $context ); |
|
57 | + $context = ! empty($request['context']) ? $request['context'] : 'view'; |
|
58 | + $data = $this->add_additional_fields_to_object($data, $request); |
|
59 | + $data = $this->filter_response_by_context($data, $context); |
|
60 | 60 | |
61 | 61 | // Wrap the data in a response object. |
62 | - $response = rest_ensure_response( $data ); |
|
62 | + $response = rest_ensure_response($data); |
|
63 | 63 | |
64 | - $response->add_links( $this->prepare_links( $webhook->get_id(), $request ) ); |
|
64 | + $response->add_links($this->prepare_links($webhook->get_id(), $request)); |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Filter webhook object returned from the REST API. |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param WC_Webhook $webhook Webhook object used to create response. |
71 | 71 | * @param WP_REST_Request $request Request object. |
72 | 72 | */ |
73 | - return apply_filters( "woocommerce_rest_prepare_{$this->post_type}", $response, $webhook, $request ); |
|
73 | + return apply_filters("woocommerce_rest_prepare_{$this->post_type}", $response, $webhook, $request); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -95,88 +95,88 @@ discard block |
||
95 | 95 | 'type' => 'object', |
96 | 96 | 'properties' => array( |
97 | 97 | 'id' => array( |
98 | - 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), |
|
98 | + 'description' => __('Unique identifier for the resource.', 'woocommerce'), |
|
99 | 99 | 'type' => 'integer', |
100 | - 'context' => array( 'view', 'edit' ), |
|
100 | + 'context' => array('view', 'edit'), |
|
101 | 101 | 'readonly' => true, |
102 | 102 | ), |
103 | 103 | 'name' => array( |
104 | - 'description' => __( 'A friendly name for the webhook.', 'woocommerce' ), |
|
104 | + 'description' => __('A friendly name for the webhook.', 'woocommerce'), |
|
105 | 105 | 'type' => 'string', |
106 | - 'context' => array( 'view', 'edit' ), |
|
106 | + 'context' => array('view', 'edit'), |
|
107 | 107 | ), |
108 | 108 | 'status' => array( |
109 | - 'description' => __( 'Webhook status.', 'woocommerce' ), |
|
109 | + 'description' => __('Webhook status.', 'woocommerce'), |
|
110 | 110 | 'type' => 'string', |
111 | 111 | 'default' => 'active', |
112 | - 'enum' => array_keys( wc_get_webhook_statuses() ), |
|
113 | - 'context' => array( 'view', 'edit' ), |
|
112 | + 'enum' => array_keys(wc_get_webhook_statuses()), |
|
113 | + 'context' => array('view', 'edit'), |
|
114 | 114 | ), |
115 | 115 | 'topic' => array( |
116 | - 'description' => __( 'Webhook topic.', 'woocommerce' ), |
|
116 | + 'description' => __('Webhook topic.', 'woocommerce'), |
|
117 | 117 | 'type' => 'string', |
118 | - 'context' => array( 'view', 'edit' ), |
|
118 | + 'context' => array('view', 'edit'), |
|
119 | 119 | ), |
120 | 120 | 'resource' => array( |
121 | - 'description' => __( 'Webhook resource.', 'woocommerce' ), |
|
121 | + 'description' => __('Webhook resource.', 'woocommerce'), |
|
122 | 122 | 'type' => 'string', |
123 | - 'context' => array( 'view', 'edit' ), |
|
123 | + 'context' => array('view', 'edit'), |
|
124 | 124 | 'readonly' => true, |
125 | 125 | ), |
126 | 126 | 'event' => array( |
127 | - 'description' => __( 'Webhook event.', 'woocommerce' ), |
|
127 | + 'description' => __('Webhook event.', 'woocommerce'), |
|
128 | 128 | 'type' => 'string', |
129 | - 'context' => array( 'view', 'edit' ), |
|
129 | + 'context' => array('view', 'edit'), |
|
130 | 130 | 'readonly' => true, |
131 | 131 | ), |
132 | 132 | 'hooks' => array( |
133 | - 'description' => __( 'WooCommerce action names associated with the webhook.', 'woocommerce' ), |
|
133 | + 'description' => __('WooCommerce action names associated with the webhook.', 'woocommerce'), |
|
134 | 134 | 'type' => 'array', |
135 | - 'context' => array( 'view', 'edit' ), |
|
135 | + 'context' => array('view', 'edit'), |
|
136 | 136 | 'readonly' => true, |
137 | 137 | 'items' => array( |
138 | 138 | 'type' => 'string', |
139 | 139 | ), |
140 | 140 | ), |
141 | 141 | 'delivery_url' => array( |
142 | - 'description' => __( 'The URL where the webhook payload is delivered.', 'woocommerce' ), |
|
142 | + 'description' => __('The URL where the webhook payload is delivered.', 'woocommerce'), |
|
143 | 143 | 'type' => 'string', |
144 | 144 | 'format' => 'uri', |
145 | - 'context' => array( 'view', 'edit' ), |
|
145 | + 'context' => array('view', 'edit'), |
|
146 | 146 | 'readonly' => true, |
147 | 147 | ), |
148 | 148 | 'secret' => array( |
149 | - 'description' => __( "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default to a MD5 hash from the current user's ID|username if not provided.", 'woocommerce' ), |
|
149 | + 'description' => __("Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default to a MD5 hash from the current user's ID|username if not provided.", 'woocommerce'), |
|
150 | 150 | 'type' => 'string', |
151 | - 'context' => array( 'edit' ), |
|
151 | + 'context' => array('edit'), |
|
152 | 152 | ), |
153 | 153 | 'date_created' => array( |
154 | - 'description' => __( "The date the webhook was created, in the site's timezone.", 'woocommerce' ), |
|
154 | + 'description' => __("The date the webhook was created, in the site's timezone.", 'woocommerce'), |
|
155 | 155 | 'type' => 'date-time', |
156 | - 'context' => array( 'view', 'edit' ), |
|
156 | + 'context' => array('view', 'edit'), |
|
157 | 157 | 'readonly' => true, |
158 | 158 | ), |
159 | 159 | 'date_created_gmt' => array( |
160 | - 'description' => __( 'The date the webhook was created, as GMT.', 'woocommerce' ), |
|
160 | + 'description' => __('The date the webhook was created, as GMT.', 'woocommerce'), |
|
161 | 161 | 'type' => 'date-time', |
162 | - 'context' => array( 'view', 'edit' ), |
|
162 | + 'context' => array('view', 'edit'), |
|
163 | 163 | 'readonly' => true, |
164 | 164 | ), |
165 | 165 | 'date_modified' => array( |
166 | - 'description' => __( "The date the webhook was last modified, in the site's timezone.", 'woocommerce' ), |
|
166 | + 'description' => __("The date the webhook was last modified, in the site's timezone.", 'woocommerce'), |
|
167 | 167 | 'type' => 'date-time', |
168 | - 'context' => array( 'view', 'edit' ), |
|
168 | + 'context' => array('view', 'edit'), |
|
169 | 169 | 'readonly' => true, |
170 | 170 | ), |
171 | 171 | 'date_modified_gmt' => array( |
172 | - 'description' => __( 'The date the webhook was last modified, as GMT.', 'woocommerce' ), |
|
172 | + 'description' => __('The date the webhook was last modified, as GMT.', 'woocommerce'), |
|
173 | 173 | 'type' => 'date-time', |
174 | - 'context' => array( 'view', 'edit' ), |
|
174 | + 'context' => array('view', 'edit'), |
|
175 | 175 | 'readonly' => true, |
176 | 176 | ), |
177 | 177 | ), |
178 | 178 | ); |
179 | 179 | |
180 | - return $this->add_additional_fields_schema( $schema ); |
|
180 | + return $this->add_additional_fields_schema($schema); |
|
181 | 181 | } |
182 | 182 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 2.6.0 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * REST API Order Notes controller class. |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return array|WP_Error |
34 | 34 | */ |
35 | - public function get_items( $request ) { |
|
36 | - $order = wc_get_order( (int) $request['order_id'] ); |
|
35 | + public function get_items($request) { |
|
36 | + $order = wc_get_order((int) $request['order_id']); |
|
37 | 37 | |
38 | - if ( ! $order || $this->post_type !== $order->get_type() ) { |
|
39 | - return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
38 | + if ( ! $order || $this->post_type !== $order->get_type()) { |
|
39 | + return new WP_Error("woocommerce_rest_{$this->post_type}_invalid_id", __('Invalid order ID.', 'woocommerce'), array('status' => 404)); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $args = array( |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | ); |
47 | 47 | |
48 | 48 | // Allow filter by order note type. |
49 | - if ( 'customer' === $request['type'] ) { |
|
49 | + if ('customer' === $request['type']) { |
|
50 | 50 | $args['meta_query'] = array( // WPCS: slow query ok. |
51 | 51 | array( |
52 | 52 | 'key' => 'is_customer_note', |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'compare' => '=', |
55 | 55 | ), |
56 | 56 | ); |
57 | - } elseif ( 'internal' === $request['type'] ) { |
|
57 | + } elseif ('internal' === $request['type']) { |
|
58 | 58 | $args['meta_query'] = array( // WPCS: slow query ok. |
59 | 59 | array( |
60 | 60 | 'key' => 'is_customer_note', |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | ); |
64 | 64 | } |
65 | 65 | |
66 | - remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); |
|
66 | + remove_filter('comments_clauses', array('WC_Comments', 'exclude_order_comments'), 10, 1); |
|
67 | 67 | |
68 | - $notes = get_comments( $args ); |
|
68 | + $notes = get_comments($args); |
|
69 | 69 | |
70 | - add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); |
|
70 | + add_filter('comments_clauses', array('WC_Comments', 'exclude_order_comments'), 10, 1); |
|
71 | 71 | |
72 | 72 | $data = array(); |
73 | - foreach ( $notes as $note ) { |
|
74 | - $order_note = $this->prepare_item_for_response( $note, $request ); |
|
75 | - $order_note = $this->prepare_response_for_collection( $order_note ); |
|
73 | + foreach ($notes as $note) { |
|
74 | + $order_note = $this->prepare_item_for_response($note, $request); |
|
75 | + $order_note = $this->prepare_response_for_collection($order_note); |
|
76 | 76 | $data[] = $order_note; |
77 | 77 | } |
78 | 78 | |
79 | - return rest_ensure_response( $data ); |
|
79 | + return rest_ensure_response($data); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -86,23 +86,23 @@ discard block |
||
86 | 86 | * @param WP_REST_Request $request Request object. |
87 | 87 | * @return WP_REST_Response $response Response data. |
88 | 88 | */ |
89 | - public function prepare_item_for_response( $note, $request ) { |
|
89 | + public function prepare_item_for_response($note, $request) { |
|
90 | 90 | $data = array( |
91 | 91 | 'id' => (int) $note->comment_ID, |
92 | - 'date_created' => wc_rest_prepare_date_response( $note->comment_date ), |
|
93 | - 'date_created_gmt' => wc_rest_prepare_date_response( $note->comment_date_gmt ), |
|
92 | + 'date_created' => wc_rest_prepare_date_response($note->comment_date), |
|
93 | + 'date_created_gmt' => wc_rest_prepare_date_response($note->comment_date_gmt), |
|
94 | 94 | 'note' => $note->comment_content, |
95 | - 'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ), |
|
95 | + 'customer_note' => (bool) get_comment_meta($note->comment_ID, 'is_customer_note', true), |
|
96 | 96 | ); |
97 | 97 | |
98 | - $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
99 | - $data = $this->add_additional_fields_to_object( $data, $request ); |
|
100 | - $data = $this->filter_response_by_context( $data, $context ); |
|
98 | + $context = ! empty($request['context']) ? $request['context'] : 'view'; |
|
99 | + $data = $this->add_additional_fields_to_object($data, $request); |
|
100 | + $data = $this->filter_response_by_context($data, $context); |
|
101 | 101 | |
102 | 102 | // Wrap the data in a response object. |
103 | - $response = rest_ensure_response( $data ); |
|
103 | + $response = rest_ensure_response($data); |
|
104 | 104 | |
105 | - $response->add_links( $this->prepare_links( $note ) ); |
|
105 | + $response->add_links($this->prepare_links($note)); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Filter order note object returned from the REST API. |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param WP_Comment $note Order note object used to create response. |
112 | 112 | * @param WP_REST_Request $request Request object. |
113 | 113 | */ |
114 | - return apply_filters( 'woocommerce_rest_prepare_order_note', $response, $note, $request ); |
|
114 | + return apply_filters('woocommerce_rest_prepare_order_note', $response, $note, $request); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -126,38 +126,38 @@ discard block |
||
126 | 126 | 'type' => 'object', |
127 | 127 | 'properties' => array( |
128 | 128 | 'id' => array( |
129 | - 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), |
|
129 | + 'description' => __('Unique identifier for the resource.', 'woocommerce'), |
|
130 | 130 | 'type' => 'integer', |
131 | - 'context' => array( 'view', 'edit' ), |
|
131 | + 'context' => array('view', 'edit'), |
|
132 | 132 | 'readonly' => true, |
133 | 133 | ), |
134 | 134 | 'date_created' => array( |
135 | - 'description' => __( "The date the order note was created, in the site's timezone.", 'woocommerce' ), |
|
135 | + 'description' => __("The date the order note was created, in the site's timezone.", 'woocommerce'), |
|
136 | 136 | 'type' => 'date-time', |
137 | - 'context' => array( 'view', 'edit' ), |
|
137 | + 'context' => array('view', 'edit'), |
|
138 | 138 | 'readonly' => true, |
139 | 139 | ), |
140 | 140 | 'date_created_gmt' => array( |
141 | - 'description' => __( 'The date the order note was created, as GMT.', 'woocommerce' ), |
|
141 | + 'description' => __('The date the order note was created, as GMT.', 'woocommerce'), |
|
142 | 142 | 'type' => 'date-time', |
143 | - 'context' => array( 'view', 'edit' ), |
|
143 | + 'context' => array('view', 'edit'), |
|
144 | 144 | 'readonly' => true, |
145 | 145 | ), |
146 | 146 | 'note' => array( |
147 | - 'description' => __( 'Order note content.', 'woocommerce' ), |
|
147 | + 'description' => __('Order note content.', 'woocommerce'), |
|
148 | 148 | 'type' => 'string', |
149 | - 'context' => array( 'view', 'edit' ), |
|
149 | + 'context' => array('view', 'edit'), |
|
150 | 150 | ), |
151 | 151 | 'customer_note' => array( |
152 | - 'description' => __( 'If true, the note will be shown to customers and they will be notified. If false, the note will be for admin reference only.', 'woocommerce' ), |
|
152 | + 'description' => __('If true, the note will be shown to customers and they will be notified. If false, the note will be for admin reference only.', 'woocommerce'), |
|
153 | 153 | 'type' => 'boolean', |
154 | 154 | 'default' => false, |
155 | - 'context' => array( 'view', 'edit' ), |
|
155 | + 'context' => array('view', 'edit'), |
|
156 | 156 | ), |
157 | 157 | ), |
158 | 158 | ); |
159 | 159 | |
160 | - return $this->add_additional_fields_schema( $schema ); |
|
160 | + return $this->add_additional_fields_schema($schema); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -167,12 +167,12 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function get_collection_params() { |
169 | 169 | $params = array(); |
170 | - $params['context'] = $this->get_context_param( array( 'default' => 'view' ) ); |
|
170 | + $params['context'] = $this->get_context_param(array('default' => 'view')); |
|
171 | 171 | $params['type'] = array( |
172 | 172 | 'default' => 'any', |
173 | - 'description' => __( 'Limit result to customers or internal notes.', 'woocommerce' ), |
|
173 | + 'description' => __('Limit result to customers or internal notes.', 'woocommerce'), |
|
174 | 174 | 'type' => 'string', |
175 | - 'enum' => array( 'any', 'customer', 'internal' ), |
|
175 | + 'enum' => array('any', 'customer', 'internal'), |
|
176 | 176 | 'sanitize_callback' => 'sanitize_key', |
177 | 177 | 'validate_callback' => 'rest_validate_request_arg', |
178 | 178 | ); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 3.0.0 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Paymenga gateways controller class. |
@@ -40,36 +40,36 @@ discard block |
||
40 | 40 | $this->namespace, '/' . $this->rest_base, array( |
41 | 41 | array( |
42 | 42 | 'methods' => WP_REST_Server::READABLE, |
43 | - 'callback' => array( $this, 'get_items' ), |
|
44 | - 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
43 | + 'callback' => array($this, 'get_items'), |
|
44 | + 'permission_callback' => array($this, 'get_items_permissions_check'), |
|
45 | 45 | 'args' => $this->get_collection_params(), |
46 | 46 | ), |
47 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
47 | + 'schema' => array($this, 'get_public_item_schema'), |
|
48 | 48 | ) |
49 | 49 | ); |
50 | 50 | register_rest_route( |
51 | 51 | $this->namespace, '/' . $this->rest_base . '/(?P<id>[\w-]+)', array( |
52 | 52 | 'args' => array( |
53 | 53 | 'id' => array( |
54 | - 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), |
|
54 | + 'description' => __('Unique identifier for the resource.', 'woocommerce'), |
|
55 | 55 | 'type' => 'string', |
56 | 56 | ), |
57 | 57 | ), |
58 | 58 | array( |
59 | 59 | 'methods' => WP_REST_Server::READABLE, |
60 | - 'callback' => array( $this, 'get_item' ), |
|
61 | - 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
60 | + 'callback' => array($this, 'get_item'), |
|
61 | + 'permission_callback' => array($this, 'get_item_permissions_check'), |
|
62 | 62 | 'args' => array( |
63 | - 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
63 | + 'context' => $this->get_context_param(array('default' => 'view')), |
|
64 | 64 | ), |
65 | 65 | ), |
66 | 66 | array( |
67 | 67 | 'methods' => WP_REST_Server::EDITABLE, |
68 | - 'callback' => array( $this, 'update_item' ), |
|
69 | - 'permission_callback' => array( $this, 'update_items_permissions_check' ), |
|
70 | - 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
68 | + 'callback' => array($this, 'update_item'), |
|
69 | + 'permission_callback' => array($this, 'update_items_permissions_check'), |
|
70 | + 'args' => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE), |
|
71 | 71 | ), |
72 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
72 | + 'schema' => array($this, 'get_public_item_schema'), |
|
73 | 73 | ) |
74 | 74 | ); |
75 | 75 | } |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * @param WP_REST_Request $request Full details about the request. |
81 | 81 | * @return WP_Error|boolean |
82 | 82 | */ |
83 | - public function get_items_permissions_check( $request ) { |
|
84 | - if ( ! wc_rest_check_manager_permissions( 'payment_gateways', 'read' ) ) { |
|
85 | - return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
83 | + public function get_items_permissions_check($request) { |
|
84 | + if ( ! wc_rest_check_manager_permissions('payment_gateways', 'read')) { |
|
85 | + return new WP_Error('woocommerce_rest_cannot_view', __('Sorry, you cannot list resources.', 'woocommerce'), array('status' => rest_authorization_required_code())); |
|
86 | 86 | } |
87 | 87 | return true; |
88 | 88 | } |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | * @param WP_REST_Request $request Full details about the request. |
94 | 94 | * @return WP_Error|boolean |
95 | 95 | */ |
96 | - public function get_item_permissions_check( $request ) { |
|
97 | - if ( ! wc_rest_check_manager_permissions( 'payment_gateways', 'read' ) ) { |
|
98 | - return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
96 | + public function get_item_permissions_check($request) { |
|
97 | + if ( ! wc_rest_check_manager_permissions('payment_gateways', 'read')) { |
|
98 | + return new WP_Error('woocommerce_rest_cannot_view', __('Sorry, you cannot view this resource.', 'woocommerce'), array('status' => rest_authorization_required_code())); |
|
99 | 99 | } |
100 | 100 | return true; |
101 | 101 | } |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | * @param WP_REST_Request $request Full details about the request. |
107 | 107 | * @return WP_Error|boolean |
108 | 108 | */ |
109 | - public function update_items_permissions_check( $request ) { |
|
110 | - if ( ! wc_rest_check_manager_permissions( 'payment_gateways', 'edit' ) ) { |
|
111 | - return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
109 | + public function update_items_permissions_check($request) { |
|
110 | + if ( ! wc_rest_check_manager_permissions('payment_gateways', 'edit')) { |
|
111 | + return new WP_Error('woocommerce_rest_cannot_edit', __('Sorry, you are not allowed to edit this resource.', 'woocommerce'), array('status' => rest_authorization_required_code())); |
|
112 | 112 | } |
113 | 113 | return true; |
114 | 114 | } |
@@ -119,16 +119,16 @@ discard block |
||
119 | 119 | * @param WP_REST_Request $request Full details about the request. |
120 | 120 | * @return WP_Error|WP_REST_Response |
121 | 121 | */ |
122 | - public function get_items( $request ) { |
|
122 | + public function get_items($request) { |
|
123 | 123 | $payment_gateways = WC()->payment_gateways->payment_gateways(); |
124 | 124 | $response = array(); |
125 | - foreach ( $payment_gateways as $payment_gateway_id => $payment_gateway ) { |
|
125 | + foreach ($payment_gateways as $payment_gateway_id => $payment_gateway) { |
|
126 | 126 | $payment_gateway->id = $payment_gateway_id; |
127 | - $gateway = $this->prepare_item_for_response( $payment_gateway, $request ); |
|
128 | - $gateway = $this->prepare_response_for_collection( $gateway ); |
|
127 | + $gateway = $this->prepare_item_for_response($payment_gateway, $request); |
|
128 | + $gateway = $this->prepare_response_for_collection($gateway); |
|
129 | 129 | $response[] = $gateway; |
130 | 130 | } |
131 | - return rest_ensure_response( $response ); |
|
131 | + return rest_ensure_response($response); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -137,15 +137,15 @@ discard block |
||
137 | 137 | * @param WP_REST_Request $request Request data. |
138 | 138 | * @return WP_REST_Response|WP_Error |
139 | 139 | */ |
140 | - public function get_item( $request ) { |
|
141 | - $gateway = $this->get_gateway( $request ); |
|
140 | + public function get_item($request) { |
|
141 | + $gateway = $this->get_gateway($request); |
|
142 | 142 | |
143 | - if ( is_null( $gateway ) ) { |
|
144 | - return new WP_Error( 'woocommerce_rest_payment_gateway_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
143 | + if (is_null($gateway)) { |
|
144 | + return new WP_Error('woocommerce_rest_payment_gateway_invalid', __('Resource does not exist.', 'woocommerce'), array('status' => 404)); |
|
145 | 145 | } |
146 | 146 | |
147 | - $gateway = $this->prepare_item_for_response( $gateway, $request ); |
|
148 | - return rest_ensure_response( $gateway ); |
|
147 | + $gateway = $this->prepare_item_for_response($gateway, $request); |
|
148 | + return rest_ensure_response($gateway); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | * @param WP_REST_Request $request Request data. |
155 | 155 | * @return WP_REST_Response|WP_Error |
156 | 156 | */ |
157 | - public function update_item( $request ) { |
|
158 | - $gateway = $this->get_gateway( $request ); |
|
157 | + public function update_item($request) { |
|
158 | + $gateway = $this->get_gateway($request); |
|
159 | 159 | |
160 | - if ( is_null( $gateway ) ) { |
|
161 | - return new WP_Error( 'woocommerce_rest_payment_gateway_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
160 | + if (is_null($gateway)) { |
|
161 | + return new WP_Error('woocommerce_rest_payment_gateway_invalid', __('Resource does not exist.', 'woocommerce'), array('status' => 404)); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Get settings. |
@@ -166,60 +166,60 @@ discard block |
||
166 | 166 | $settings = $gateway->settings; |
167 | 167 | |
168 | 168 | // Update settings. |
169 | - if ( isset( $request['settings'] ) ) { |
|
169 | + if (isset($request['settings'])) { |
|
170 | 170 | $errors_found = false; |
171 | - foreach ( $gateway->form_fields as $key => $field ) { |
|
172 | - if ( isset( $request['settings'][ $key ] ) ) { |
|
173 | - if ( is_callable( array( $this, 'validate_setting_' . $field['type'] . '_field' ) ) ) { |
|
174 | - $value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][ $key ], $field ); |
|
171 | + foreach ($gateway->form_fields as $key => $field) { |
|
172 | + if (isset($request['settings'][$key])) { |
|
173 | + if (is_callable(array($this, 'validate_setting_' . $field['type'] . '_field'))) { |
|
174 | + $value = $this->{'validate_setting_' . $field['type'] . '_field'}($request['settings'][$key], $field); |
|
175 | 175 | } else { |
176 | - $value = $this->validate_setting_text_field( $request['settings'][ $key ], $field ); |
|
176 | + $value = $this->validate_setting_text_field($request['settings'][$key], $field); |
|
177 | 177 | } |
178 | - if ( is_wp_error( $value ) ) { |
|
178 | + if (is_wp_error($value)) { |
|
179 | 179 | $errors_found = true; |
180 | 180 | break; |
181 | 181 | } |
182 | - $settings[ $key ] = $value; |
|
182 | + $settings[$key] = $value; |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - if ( $errors_found ) { |
|
187 | - return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) ); |
|
186 | + if ($errors_found) { |
|
187 | + return new WP_Error('rest_setting_value_invalid', __('An invalid setting value was passed.', 'woocommerce'), array('status' => 400)); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | 191 | // Update if this method is enabled or not. |
192 | - if ( isset( $request['enabled'] ) ) { |
|
193 | - $settings['enabled'] = wc_bool_to_string( $request['enabled'] ); |
|
192 | + if (isset($request['enabled'])) { |
|
193 | + $settings['enabled'] = wc_bool_to_string($request['enabled']); |
|
194 | 194 | $gateway->enabled = $settings['enabled']; |
195 | 195 | } |
196 | 196 | |
197 | 197 | // Update title. |
198 | - if ( isset( $request['title'] ) ) { |
|
198 | + if (isset($request['title'])) { |
|
199 | 199 | $settings['title'] = $request['title']; |
200 | 200 | $gateway->title = $settings['title']; |
201 | 201 | } |
202 | 202 | |
203 | 203 | // Update description. |
204 | - if ( isset( $request['description'] ) ) { |
|
204 | + if (isset($request['description'])) { |
|
205 | 205 | $settings['description'] = $request['description']; |
206 | 206 | $gateway->description = $settings['description']; |
207 | 207 | } |
208 | 208 | |
209 | 209 | // Update options. |
210 | 210 | $gateway->settings = $settings; |
211 | - update_option( $gateway->get_option_key(), apply_filters( 'woocommerce_gateway_' . $gateway->id . '_settings_values', $settings, $gateway ) ); |
|
211 | + update_option($gateway->get_option_key(), apply_filters('woocommerce_gateway_' . $gateway->id . '_settings_values', $settings, $gateway)); |
|
212 | 212 | |
213 | 213 | // Update order. |
214 | - if ( isset( $request['order'] ) ) { |
|
215 | - $order = (array) get_option( 'woocommerce_gateway_order' ); |
|
216 | - $order[ $gateway->id ] = $request['order']; |
|
217 | - update_option( 'woocommerce_gateway_order', $order ); |
|
218 | - $gateway->order = absint( $request['order'] ); |
|
214 | + if (isset($request['order'])) { |
|
215 | + $order = (array) get_option('woocommerce_gateway_order'); |
|
216 | + $order[$gateway->id] = $request['order']; |
|
217 | + update_option('woocommerce_gateway_order', $order); |
|
218 | + $gateway->order = absint($request['order']); |
|
219 | 219 | } |
220 | 220 | |
221 | - $gateway = $this->prepare_item_for_response( $gateway, $request ); |
|
222 | - return rest_ensure_response( $gateway ); |
|
221 | + $gateway = $this->prepare_item_for_response($gateway, $request); |
|
222 | + return rest_ensure_response($gateway); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -228,11 +228,11 @@ discard block |
||
228 | 228 | * @param WP_REST_Request $request Request data. |
229 | 229 | * @return WP_REST_Response|null |
230 | 230 | */ |
231 | - public function get_gateway( $request ) { |
|
231 | + public function get_gateway($request) { |
|
232 | 232 | $gateway = null; |
233 | 233 | $payment_gateways = WC()->payment_gateways->payment_gateways(); |
234 | - foreach ( $payment_gateways as $payment_gateway_id => $payment_gateway ) { |
|
235 | - if ( $request['id'] !== $payment_gateway_id ) { |
|
234 | + foreach ($payment_gateways as $payment_gateway_id => $payment_gateway) { |
|
235 | + if ($request['id'] !== $payment_gateway_id) { |
|
236 | 236 | continue; |
237 | 237 | } |
238 | 238 | $payment_gateway->id = $payment_gateway_id; |
@@ -248,25 +248,25 @@ discard block |
||
248 | 248 | * @param WP_REST_Request $request Request object. |
249 | 249 | * @return WP_REST_Response $response Response data. |
250 | 250 | */ |
251 | - public function prepare_item_for_response( $gateway, $request ) { |
|
252 | - $order = (array) get_option( 'woocommerce_gateway_order' ); |
|
251 | + public function prepare_item_for_response($gateway, $request) { |
|
252 | + $order = (array) get_option('woocommerce_gateway_order'); |
|
253 | 253 | $item = array( |
254 | 254 | 'id' => $gateway->id, |
255 | 255 | 'title' => $gateway->title, |
256 | 256 | 'description' => $gateway->description, |
257 | - 'order' => isset( $order[ $gateway->id ] ) ? $order[ $gateway->id ] : '', |
|
258 | - 'enabled' => ( 'yes' === $gateway->enabled ), |
|
257 | + 'order' => isset($order[$gateway->id]) ? $order[$gateway->id] : '', |
|
258 | + 'enabled' => ('yes' === $gateway->enabled), |
|
259 | 259 | 'method_title' => $gateway->get_method_title(), |
260 | 260 | 'method_description' => $gateway->get_method_description(), |
261 | - 'settings' => $this->get_settings( $gateway ), |
|
261 | + 'settings' => $this->get_settings($gateway), |
|
262 | 262 | ); |
263 | 263 | |
264 | - $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
265 | - $data = $this->add_additional_fields_to_object( $item, $request ); |
|
266 | - $data = $this->filter_response_by_context( $data, $context ); |
|
264 | + $context = ! empty($request['context']) ? $request['context'] : 'view'; |
|
265 | + $data = $this->add_additional_fields_to_object($item, $request); |
|
266 | + $data = $this->filter_response_by_context($data, $context); |
|
267 | 267 | |
268 | - $response = rest_ensure_response( $data ); |
|
269 | - $response->add_links( $this->prepare_links( $gateway, $request ) ); |
|
268 | + $response = rest_ensure_response($data); |
|
269 | + $response->add_links($this->prepare_links($gateway, $request)); |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Filter payment gateway objects returned from the REST API. |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * @param WC_Payment_Gateway $gateway Payment gateway object. |
276 | 276 | * @param WP_REST_Request $request Request object. |
277 | 277 | */ |
278 | - return apply_filters( 'woocommerce_rest_prepare_payment_gateway', $response, $gateway, $request ); |
|
278 | + return apply_filters('woocommerce_rest_prepare_payment_gateway', $response, $gateway, $request); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -285,36 +285,36 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @return array |
287 | 287 | */ |
288 | - public function get_settings( $gateway ) { |
|
288 | + public function get_settings($gateway) { |
|
289 | 289 | $settings = array(); |
290 | 290 | $gateway->init_form_fields(); |
291 | - foreach ( $gateway->form_fields as $id => $field ) { |
|
291 | + foreach ($gateway->form_fields as $id => $field) { |
|
292 | 292 | // Make sure we at least have a title and type. |
293 | - if ( empty( $field['title'] ) || empty( $field['type'] ) ) { |
|
293 | + if (empty($field['title']) || empty($field['type'])) { |
|
294 | 294 | continue; |
295 | 295 | } |
296 | 296 | // Ignore 'title' settings/fields -- they are UI only. |
297 | - if ( 'title' === $field['type'] ) { |
|
297 | + if ('title' === $field['type']) { |
|
298 | 298 | continue; |
299 | 299 | } |
300 | 300 | // Ignore 'enabled' and 'description' which get included elsewhere. |
301 | - if ( in_array( $id, array( 'enabled', 'description' ), true ) ) { |
|
301 | + if (in_array($id, array('enabled', 'description'), true)) { |
|
302 | 302 | continue; |
303 | 303 | } |
304 | 304 | $data = array( |
305 | 305 | 'id' => $id, |
306 | - 'label' => empty( $field['label'] ) ? $field['title'] : $field['label'], |
|
307 | - 'description' => empty( $field['description'] ) ? '' : $field['description'], |
|
306 | + 'label' => empty($field['label']) ? $field['title'] : $field['label'], |
|
307 | + 'description' => empty($field['description']) ? '' : $field['description'], |
|
308 | 308 | 'type' => $field['type'], |
309 | - 'value' => empty( $gateway->settings[ $id ] ) ? '' : $gateway->settings[ $id ], |
|
310 | - 'default' => empty( $field['default'] ) ? '' : $field['default'], |
|
311 | - 'tip' => empty( $field['description'] ) ? '' : $field['description'], |
|
312 | - 'placeholder' => empty( $field['placeholder'] ) ? '' : $field['placeholder'], |
|
309 | + 'value' => empty($gateway->settings[$id]) ? '' : $gateway->settings[$id], |
|
310 | + 'default' => empty($field['default']) ? '' : $field['default'], |
|
311 | + 'tip' => empty($field['description']) ? '' : $field['description'], |
|
312 | + 'placeholder' => empty($field['placeholder']) ? '' : $field['placeholder'], |
|
313 | 313 | ); |
314 | - if ( ! empty( $field['options'] ) ) { |
|
314 | + if ( ! empty($field['options'])) { |
|
315 | 315 | $data['options'] = $field['options']; |
316 | 316 | } |
317 | - $settings[ $id ] = $data; |
|
317 | + $settings[$id] = $data; |
|
318 | 318 | } |
319 | 319 | return $settings; |
320 | 320 | } |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | * @param WP_REST_Request $request Request object. |
327 | 327 | * @return array |
328 | 328 | */ |
329 | - protected function prepare_links( $gateway, $request ) { |
|
329 | + protected function prepare_links($gateway, $request) { |
|
330 | 330 | $links = array( |
331 | 331 | 'self' => array( |
332 | - 'href' => rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->rest_base, $gateway->id ) ), |
|
332 | + 'href' => rest_url(sprintf('/%s/%s/%s', $this->namespace, $this->rest_base, $gateway->id)), |
|
333 | 333 | ), |
334 | 334 | 'collection' => array( |
335 | - 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), |
|
335 | + 'href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)), |
|
336 | 336 | ), |
337 | 337 | ); |
338 | 338 | |
@@ -351,97 +351,97 @@ discard block |
||
351 | 351 | 'type' => 'object', |
352 | 352 | 'properties' => array( |
353 | 353 | 'id' => array( |
354 | - 'description' => __( 'Payment gateway ID.', 'woocommerce' ), |
|
354 | + 'description' => __('Payment gateway ID.', 'woocommerce'), |
|
355 | 355 | 'type' => 'string', |
356 | - 'context' => array( 'view', 'edit' ), |
|
356 | + 'context' => array('view', 'edit'), |
|
357 | 357 | 'readonly' => true, |
358 | 358 | ), |
359 | 359 | 'title' => array( |
360 | - 'description' => __( 'Payment gateway title on checkout.', 'woocommerce' ), |
|
360 | + 'description' => __('Payment gateway title on checkout.', 'woocommerce'), |
|
361 | 361 | 'type' => 'string', |
362 | - 'context' => array( 'view', 'edit' ), |
|
362 | + 'context' => array('view', 'edit'), |
|
363 | 363 | ), |
364 | 364 | 'description' => array( |
365 | - 'description' => __( 'Payment gateway description on checkout.', 'woocommerce' ), |
|
365 | + 'description' => __('Payment gateway description on checkout.', 'woocommerce'), |
|
366 | 366 | 'type' => 'string', |
367 | - 'context' => array( 'view', 'edit' ), |
|
367 | + 'context' => array('view', 'edit'), |
|
368 | 368 | ), |
369 | 369 | 'order' => array( |
370 | - 'description' => __( 'Payment gateway sort order.', 'woocommerce' ), |
|
370 | + 'description' => __('Payment gateway sort order.', 'woocommerce'), |
|
371 | 371 | 'type' => 'integer', |
372 | - 'context' => array( 'view', 'edit' ), |
|
372 | + 'context' => array('view', 'edit'), |
|
373 | 373 | 'arg_options' => array( |
374 | 374 | 'sanitize_callback' => 'absint', |
375 | 375 | ), |
376 | 376 | ), |
377 | 377 | 'enabled' => array( |
378 | - 'description' => __( 'Payment gateway enabled status.', 'woocommerce' ), |
|
378 | + 'description' => __('Payment gateway enabled status.', 'woocommerce'), |
|
379 | 379 | 'type' => 'boolean', |
380 | - 'context' => array( 'view', 'edit' ), |
|
380 | + 'context' => array('view', 'edit'), |
|
381 | 381 | ), |
382 | 382 | 'method_title' => array( |
383 | - 'description' => __( 'Payment gateway method title.', 'woocommerce' ), |
|
383 | + 'description' => __('Payment gateway method title.', 'woocommerce'), |
|
384 | 384 | 'type' => 'string', |
385 | - 'context' => array( 'view', 'edit' ), |
|
385 | + 'context' => array('view', 'edit'), |
|
386 | 386 | 'readonly' => true, |
387 | 387 | ), |
388 | 388 | 'method_description' => array( |
389 | - 'description' => __( 'Payment gateway method description.', 'woocommerce' ), |
|
389 | + 'description' => __('Payment gateway method description.', 'woocommerce'), |
|
390 | 390 | 'type' => 'string', |
391 | - 'context' => array( 'view', 'edit' ), |
|
391 | + 'context' => array('view', 'edit'), |
|
392 | 392 | 'readonly' => true, |
393 | 393 | ), |
394 | 394 | 'settings' => array( |
395 | - 'description' => __( 'Payment gateway settings.', 'woocommerce' ), |
|
395 | + 'description' => __('Payment gateway settings.', 'woocommerce'), |
|
396 | 396 | 'type' => 'object', |
397 | - 'context' => array( 'view', 'edit' ), |
|
397 | + 'context' => array('view', 'edit'), |
|
398 | 398 | 'properties' => array( |
399 | 399 | 'id' => array( |
400 | - 'description' => __( 'A unique identifier for the setting.', 'woocommerce' ), |
|
400 | + 'description' => __('A unique identifier for the setting.', 'woocommerce'), |
|
401 | 401 | 'type' => 'string', |
402 | - 'context' => array( 'view', 'edit' ), |
|
402 | + 'context' => array('view', 'edit'), |
|
403 | 403 | 'readonly' => true, |
404 | 404 | ), |
405 | 405 | 'label' => array( |
406 | - 'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ), |
|
406 | + 'description' => __('A human readable label for the setting used in interfaces.', 'woocommerce'), |
|
407 | 407 | 'type' => 'string', |
408 | - 'context' => array( 'view', 'edit' ), |
|
408 | + 'context' => array('view', 'edit'), |
|
409 | 409 | 'readonly' => true, |
410 | 410 | ), |
411 | 411 | 'description' => array( |
412 | - 'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ), |
|
412 | + 'description' => __('A human readable description for the setting used in interfaces.', 'woocommerce'), |
|
413 | 413 | 'type' => 'string', |
414 | - 'context' => array( 'view', 'edit' ), |
|
414 | + 'context' => array('view', 'edit'), |
|
415 | 415 | 'readonly' => true, |
416 | 416 | ), |
417 | 417 | 'type' => array( |
418 | - 'description' => __( 'Type of setting.', 'woocommerce' ), |
|
418 | + 'description' => __('Type of setting.', 'woocommerce'), |
|
419 | 419 | 'type' => 'string', |
420 | - 'context' => array( 'view', 'edit' ), |
|
421 | - 'enum' => array( 'text', 'email', 'number', 'color', 'password', 'textarea', 'select', 'multiselect', 'radio', 'image_width', 'checkbox' ), |
|
420 | + 'context' => array('view', 'edit'), |
|
421 | + 'enum' => array('text', 'email', 'number', 'color', 'password', 'textarea', 'select', 'multiselect', 'radio', 'image_width', 'checkbox'), |
|
422 | 422 | 'readonly' => true, |
423 | 423 | ), |
424 | 424 | 'value' => array( |
425 | - 'description' => __( 'Setting value.', 'woocommerce' ), |
|
425 | + 'description' => __('Setting value.', 'woocommerce'), |
|
426 | 426 | 'type' => 'string', |
427 | - 'context' => array( 'view', 'edit' ), |
|
427 | + 'context' => array('view', 'edit'), |
|
428 | 428 | ), |
429 | 429 | 'default' => array( |
430 | - 'description' => __( 'Default value for the setting.', 'woocommerce' ), |
|
430 | + 'description' => __('Default value for the setting.', 'woocommerce'), |
|
431 | 431 | 'type' => 'string', |
432 | - 'context' => array( 'view', 'edit' ), |
|
432 | + 'context' => array('view', 'edit'), |
|
433 | 433 | 'readonly' => true, |
434 | 434 | ), |
435 | 435 | 'tip' => array( |
436 | - 'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce' ), |
|
436 | + 'description' => __('Additional help text shown to the user about the setting.', 'woocommerce'), |
|
437 | 437 | 'type' => 'string', |
438 | - 'context' => array( 'view', 'edit' ), |
|
438 | + 'context' => array('view', 'edit'), |
|
439 | 439 | 'readonly' => true, |
440 | 440 | ), |
441 | 441 | 'placeholder' => array( |
442 | - 'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce' ), |
|
442 | + 'description' => __('Placeholder text to be displayed in text inputs.', 'woocommerce'), |
|
443 | 443 | 'type' => 'string', |
444 | - 'context' => array( 'view', 'edit' ), |
|
444 | + 'context' => array('view', 'edit'), |
|
445 | 445 | 'readonly' => true, |
446 | 446 | ), |
447 | 447 | ), |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | ), |
450 | 450 | ); |
451 | 451 | |
452 | - return $this->add_additional_fields_schema( $schema ); |
|
452 | + return $this->add_additional_fields_schema($schema); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | */ |
460 | 460 | public function get_collection_params() { |
461 | 461 | return array( |
462 | - 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
462 | + 'context' => $this->get_context_param(array('default' => 'view')), |
|
463 | 463 | ); |
464 | 464 | } |
465 | 465 |
@@ -8,7 +8,7 @@ discard block |
||
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. |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | 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 | 'args' => $this->get_collection_params(), |
48 | 48 | ), |
49 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
49 | + 'schema' => array($this, 'get_public_item_schema'), |
|
50 | 50 | ) |
51 | 51 | ); |
52 | 52 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * @param WP_REST_Request $request Full details about the request. |
58 | 58 | * @return WP_Error|boolean |
59 | 59 | */ |
60 | - public function get_items_permissions_check( $request ) { |
|
61 | - if ( ! wc_rest_check_manager_permissions( 'system_status', 'read' ) ) { |
|
62 | - return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
60 | + public function get_items_permissions_check($request) { |
|
61 | + if ( ! wc_rest_check_manager_permissions('system_status', 'read')) { |
|
62 | + return new WP_Error('woocommerce_rest_cannot_view', __('Sorry, you cannot list resources.', 'woocommerce'), array('status' => rest_authorization_required_code())); |
|
63 | 63 | } |
64 | 64 | return true; |
65 | 65 | } |
@@ -70,24 +70,24 @@ discard block |
||
70 | 70 | * @param WP_REST_Request $request Full details about the request. |
71 | 71 | * @return WP_Error|WP_REST_Response |
72 | 72 | */ |
73 | - public function get_items( $request ) { |
|
73 | + public function get_items($request) { |
|
74 | 74 | $schema = $this->get_item_schema(); |
75 | 75 | $mappings = $this->get_item_mappings(); |
76 | 76 | $response = array(); |
77 | 77 | |
78 | - foreach ( $mappings as $section => $values ) { |
|
79 | - foreach ( $values as $key => $value ) { |
|
80 | - if ( isset( $schema['properties'][ $section ]['properties'][ $key ]['type'] ) ) { |
|
81 | - settype( $values[ $key ], $schema['properties'][ $section ]['properties'][ $key ]['type'] ); |
|
78 | + foreach ($mappings as $section => $values) { |
|
79 | + foreach ($values as $key => $value) { |
|
80 | + if (isset($schema['properties'][$section]['properties'][$key]['type'])) { |
|
81 | + settype($values[$key], $schema['properties'][$section]['properties'][$key]['type']); |
|
82 | 82 | } |
83 | 83 | } |
84 | - settype( $values, $schema['properties'][ $section ]['type'] ); |
|
85 | - $response[ $section ] = $values; |
|
84 | + settype($values, $schema['properties'][$section]['type']); |
|
85 | + $response[$section] = $values; |
|
86 | 86 | } |
87 | 87 | |
88 | - $response = $this->prepare_item_for_response( $response, $request ); |
|
88 | + $response = $this->prepare_item_for_response($response, $request); |
|
89 | 89 | |
90 | - return rest_ensure_response( $response ); |
|
90 | + return rest_ensure_response($response); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -102,229 +102,229 @@ discard block |
||
102 | 102 | 'type' => 'object', |
103 | 103 | 'properties' => array( |
104 | 104 | 'environment' => array( |
105 | - 'description' => __( 'Environment.', 'woocommerce' ), |
|
105 | + 'description' => __('Environment.', 'woocommerce'), |
|
106 | 106 | 'type' => 'object', |
107 | - 'context' => array( 'view' ), |
|
107 | + 'context' => array('view'), |
|
108 | 108 | 'readonly' => true, |
109 | 109 | 'properties' => array( |
110 | 110 | 'home_url' => array( |
111 | - 'description' => __( 'Home URL.', 'woocommerce' ), |
|
111 | + 'description' => __('Home URL.', 'woocommerce'), |
|
112 | 112 | 'type' => 'string', |
113 | 113 | 'format' => 'uri', |
114 | - 'context' => array( 'view' ), |
|
114 | + 'context' => array('view'), |
|
115 | 115 | 'readonly' => true, |
116 | 116 | ), |
117 | 117 | 'site_url' => array( |
118 | - 'description' => __( 'Site URL.', 'woocommerce' ), |
|
118 | + 'description' => __('Site URL.', 'woocommerce'), |
|
119 | 119 | 'type' => 'string', |
120 | 120 | 'format' => 'uri', |
121 | - 'context' => array( 'view' ), |
|
121 | + 'context' => array('view'), |
|
122 | 122 | 'readonly' => true, |
123 | 123 | ), |
124 | 124 | 'wc_version' => array( |
125 | - 'description' => __( 'WooCommerce version.', 'woocommerce' ), |
|
125 | + 'description' => __('WooCommerce version.', 'woocommerce'), |
|
126 | 126 | 'type' => 'string', |
127 | - 'context' => array( 'view' ), |
|
127 | + 'context' => array('view'), |
|
128 | 128 | 'readonly' => true, |
129 | 129 | ), |
130 | 130 | 'log_directory' => array( |
131 | - 'description' => __( 'Log directory.', 'woocommerce' ), |
|
131 | + 'description' => __('Log directory.', 'woocommerce'), |
|
132 | 132 | 'type' => 'string', |
133 | - 'context' => array( 'view' ), |
|
133 | + 'context' => array('view'), |
|
134 | 134 | 'readonly' => true, |
135 | 135 | ), |
136 | 136 | 'log_directory_writable' => array( |
137 | - 'description' => __( 'Is log directory writable?', 'woocommerce' ), |
|
137 | + 'description' => __('Is log directory writable?', 'woocommerce'), |
|
138 | 138 | 'type' => 'boolean', |
139 | - 'context' => array( 'view' ), |
|
139 | + 'context' => array('view'), |
|
140 | 140 | 'readonly' => true, |
141 | 141 | ), |
142 | 142 | 'wp_version' => array( |
143 | - 'description' => __( 'WordPress version.', 'woocommerce' ), |
|
143 | + 'description' => __('WordPress version.', 'woocommerce'), |
|
144 | 144 | 'type' => 'string', |
145 | - 'context' => array( 'view' ), |
|
145 | + 'context' => array('view'), |
|
146 | 146 | 'readonly' => true, |
147 | 147 | ), |
148 | 148 | 'wp_multisite' => array( |
149 | - 'description' => __( 'Is WordPress multisite?', 'woocommerce' ), |
|
149 | + 'description' => __('Is WordPress multisite?', 'woocommerce'), |
|
150 | 150 | 'type' => 'boolean', |
151 | - 'context' => array( 'view' ), |
|
151 | + 'context' => array('view'), |
|
152 | 152 | 'readonly' => true, |
153 | 153 | ), |
154 | 154 | 'wp_memory_limit' => array( |
155 | - 'description' => __( 'WordPress memory limit.', 'woocommerce' ), |
|
155 | + 'description' => __('WordPress memory limit.', 'woocommerce'), |
|
156 | 156 | 'type' => 'integer', |
157 | - 'context' => array( 'view' ), |
|
157 | + 'context' => array('view'), |
|
158 | 158 | 'readonly' => true, |
159 | 159 | ), |
160 | 160 | 'wp_debug_mode' => array( |
161 | - 'description' => __( 'Is WordPress debug mode active?', 'woocommerce' ), |
|
161 | + 'description' => __('Is WordPress debug mode active?', 'woocommerce'), |
|
162 | 162 | 'type' => 'boolean', |
163 | - 'context' => array( 'view' ), |
|
163 | + 'context' => array('view'), |
|
164 | 164 | 'readonly' => true, |
165 | 165 | ), |
166 | 166 | 'wp_cron' => array( |
167 | - 'description' => __( 'Are WordPress cron jobs enabled?', 'woocommerce' ), |
|
167 | + 'description' => __('Are WordPress cron jobs enabled?', 'woocommerce'), |
|
168 | 168 | 'type' => 'boolean', |
169 | - 'context' => array( 'view' ), |
|
169 | + 'context' => array('view'), |
|
170 | 170 | 'readonly' => true, |
171 | 171 | ), |
172 | 172 | 'language' => array( |
173 | - 'description' => __( 'WordPress language.', 'woocommerce' ), |
|
173 | + 'description' => __('WordPress language.', 'woocommerce'), |
|
174 | 174 | 'type' => 'string', |
175 | - 'context' => array( 'view' ), |
|
175 | + 'context' => array('view'), |
|
176 | 176 | 'readonly' => true, |
177 | 177 | ), |
178 | 178 | 'server_info' => array( |
179 | - 'description' => __( 'Server info.', 'woocommerce' ), |
|
179 | + 'description' => __('Server info.', 'woocommerce'), |
|
180 | 180 | 'type' => 'string', |
181 | - 'context' => array( 'view' ), |
|
181 | + 'context' => array('view'), |
|
182 | 182 | 'readonly' => true, |
183 | 183 | ), |
184 | 184 | 'php_version' => array( |
185 | - 'description' => __( 'PHP version.', 'woocommerce' ), |
|
185 | + 'description' => __('PHP version.', 'woocommerce'), |
|
186 | 186 | 'type' => 'string', |
187 | - 'context' => array( 'view' ), |
|
187 | + 'context' => array('view'), |
|
188 | 188 | 'readonly' => true, |
189 | 189 | ), |
190 | 190 | 'php_post_max_size' => array( |
191 | - 'description' => __( 'PHP post max size.', 'woocommerce' ), |
|
191 | + 'description' => __('PHP post max size.', 'woocommerce'), |
|
192 | 192 | 'type' => 'integer', |
193 | - 'context' => array( 'view' ), |
|
193 | + 'context' => array('view'), |
|
194 | 194 | 'readonly' => true, |
195 | 195 | ), |
196 | 196 | 'php_max_execution_time' => array( |
197 | - 'description' => __( 'PHP max execution time.', 'woocommerce' ), |
|
197 | + 'description' => __('PHP max execution time.', 'woocommerce'), |
|
198 | 198 | 'type' => 'integer', |
199 | - 'context' => array( 'view' ), |
|
199 | + 'context' => array('view'), |
|
200 | 200 | 'readonly' => true, |
201 | 201 | ), |
202 | 202 | 'php_max_input_vars' => array( |
203 | - 'description' => __( 'PHP max input vars.', 'woocommerce' ), |
|
203 | + 'description' => __('PHP max input vars.', 'woocommerce'), |
|
204 | 204 | 'type' => 'integer', |
205 | - 'context' => array( 'view' ), |
|
205 | + 'context' => array('view'), |
|
206 | 206 | 'readonly' => true, |
207 | 207 | ), |
208 | 208 | 'curl_version' => array( |
209 | - 'description' => __( 'cURL version.', 'woocommerce' ), |
|
209 | + 'description' => __('cURL version.', 'woocommerce'), |
|
210 | 210 | 'type' => 'string', |
211 | - 'context' => array( 'view' ), |
|
211 | + 'context' => array('view'), |
|
212 | 212 | 'readonly' => true, |
213 | 213 | ), |
214 | 214 | 'suhosin_installed' => array( |
215 | - 'description' => __( 'Is SUHOSIN installed?', 'woocommerce' ), |
|
215 | + 'description' => __('Is SUHOSIN installed?', 'woocommerce'), |
|
216 | 216 | 'type' => 'boolean', |
217 | - 'context' => array( 'view' ), |
|
217 | + 'context' => array('view'), |
|
218 | 218 | 'readonly' => true, |
219 | 219 | ), |
220 | 220 | 'max_upload_size' => array( |
221 | - 'description' => __( 'Max upload size.', 'woocommerce' ), |
|
221 | + 'description' => __('Max upload size.', 'woocommerce'), |
|
222 | 222 | 'type' => 'integer', |
223 | - 'context' => array( 'view' ), |
|
223 | + 'context' => array('view'), |
|
224 | 224 | 'readonly' => true, |
225 | 225 | ), |
226 | 226 | 'mysql_version' => array( |
227 | - 'description' => __( 'MySQL version.', 'woocommerce' ), |
|
227 | + 'description' => __('MySQL version.', 'woocommerce'), |
|
228 | 228 | 'type' => 'string', |
229 | - 'context' => array( 'view' ), |
|
229 | + 'context' => array('view'), |
|
230 | 230 | 'readonly' => true, |
231 | 231 | ), |
232 | 232 | 'mysql_version_string' => array( |
233 | - 'description' => __( 'MySQL version string.', 'woocommerce' ), |
|
233 | + 'description' => __('MySQL version string.', 'woocommerce'), |
|
234 | 234 | 'type' => 'string', |
235 | - 'context' => array( 'view' ), |
|
235 | + 'context' => array('view'), |
|
236 | 236 | 'readonly' => true, |
237 | 237 | ), |
238 | 238 | 'default_timezone' => array( |
239 | - 'description' => __( 'Default timezone.', 'woocommerce' ), |
|
239 | + 'description' => __('Default timezone.', 'woocommerce'), |
|
240 | 240 | 'type' => 'string', |
241 | - 'context' => array( 'view' ), |
|
241 | + 'context' => array('view'), |
|
242 | 242 | 'readonly' => true, |
243 | 243 | ), |
244 | 244 | 'fsockopen_or_curl_enabled' => array( |
245 | - 'description' => __( 'Is fsockopen/cURL enabled?', 'woocommerce' ), |
|
245 | + 'description' => __('Is fsockopen/cURL enabled?', 'woocommerce'), |
|
246 | 246 | 'type' => 'boolean', |
247 | - 'context' => array( 'view' ), |
|
247 | + 'context' => array('view'), |
|
248 | 248 | 'readonly' => true, |
249 | 249 | ), |
250 | 250 | 'soapclient_enabled' => array( |
251 | - 'description' => __( 'Is SoapClient class enabled?', 'woocommerce' ), |
|
251 | + 'description' => __('Is SoapClient class enabled?', 'woocommerce'), |
|
252 | 252 | 'type' => 'boolean', |
253 | - 'context' => array( 'view' ), |
|
253 | + 'context' => array('view'), |
|
254 | 254 | 'readonly' => true, |
255 | 255 | ), |
256 | 256 | 'domdocument_enabled' => array( |
257 | - 'description' => __( 'Is DomDocument class enabled?', 'woocommerce' ), |
|
257 | + 'description' => __('Is DomDocument class enabled?', 'woocommerce'), |
|
258 | 258 | 'type' => 'boolean', |
259 | - 'context' => array( 'view' ), |
|
259 | + 'context' => array('view'), |
|
260 | 260 | 'readonly' => true, |
261 | 261 | ), |
262 | 262 | 'gzip_enabled' => array( |
263 | - 'description' => __( 'Is GZip enabled?', 'woocommerce' ), |
|
263 | + 'description' => __('Is GZip enabled?', 'woocommerce'), |
|
264 | 264 | 'type' => 'boolean', |
265 | - 'context' => array( 'view' ), |
|
265 | + 'context' => array('view'), |
|
266 | 266 | 'readonly' => true, |
267 | 267 | ), |
268 | 268 | 'mbstring_enabled' => array( |
269 | - 'description' => __( 'Is mbstring enabled?', 'woocommerce' ), |
|
269 | + 'description' => __('Is mbstring enabled?', 'woocommerce'), |
|
270 | 270 | 'type' => 'boolean', |
271 | - 'context' => array( 'view' ), |
|
271 | + 'context' => array('view'), |
|
272 | 272 | 'readonly' => true, |
273 | 273 | ), |
274 | 274 | 'remote_post_successful' => array( |
275 | - 'description' => __( 'Remote POST successful?', 'woocommerce' ), |
|
275 | + 'description' => __('Remote POST successful?', 'woocommerce'), |
|
276 | 276 | 'type' => 'boolean', |
277 | - 'context' => array( 'view' ), |
|
277 | + 'context' => array('view'), |
|
278 | 278 | 'readonly' => true, |
279 | 279 | ), |
280 | 280 | 'remote_post_response' => array( |
281 | - 'description' => __( 'Remote POST response.', 'woocommerce' ), |
|
281 | + 'description' => __('Remote POST response.', 'woocommerce'), |
|
282 | 282 | 'type' => 'string', |
283 | - 'context' => array( 'view' ), |
|
283 | + 'context' => array('view'), |
|
284 | 284 | 'readonly' => true, |
285 | 285 | ), |
286 | 286 | 'remote_get_successful' => array( |
287 | - 'description' => __( 'Remote GET successful?', 'woocommerce' ), |
|
287 | + 'description' => __('Remote GET successful?', 'woocommerce'), |
|
288 | 288 | 'type' => 'boolean', |
289 | - 'context' => array( 'view' ), |
|
289 | + 'context' => array('view'), |
|
290 | 290 | 'readonly' => true, |
291 | 291 | ), |
292 | 292 | 'remote_get_response' => array( |
293 | - 'description' => __( 'Remote GET response.', 'woocommerce' ), |
|
293 | + 'description' => __('Remote GET response.', 'woocommerce'), |
|
294 | 294 | 'type' => 'string', |
295 | - 'context' => array( 'view' ), |
|
295 | + 'context' => array('view'), |
|
296 | 296 | 'readonly' => true, |
297 | 297 | ), |
298 | 298 | ), |
299 | 299 | ), |
300 | 300 | 'database' => array( |
301 | - 'description' => __( 'Database.', 'woocommerce' ), |
|
301 | + 'description' => __('Database.', 'woocommerce'), |
|
302 | 302 | 'type' => 'object', |
303 | - 'context' => array( 'view' ), |
|
303 | + 'context' => array('view'), |
|
304 | 304 | 'readonly' => true, |
305 | 305 | 'properties' => array( |
306 | 306 | 'wc_database_version' => array( |
307 | - 'description' => __( 'WC database version.', 'woocommerce' ), |
|
307 | + 'description' => __('WC database version.', 'woocommerce'), |
|
308 | 308 | 'type' => 'string', |
309 | - 'context' => array( 'view' ), |
|
309 | + 'context' => array('view'), |
|
310 | 310 | 'readonly' => true, |
311 | 311 | ), |
312 | 312 | 'database_prefix' => array( |
313 | - 'description' => __( 'Database prefix.', 'woocommerce' ), |
|
313 | + 'description' => __('Database prefix.', 'woocommerce'), |
|
314 | 314 | 'type' => 'string', |
315 | - 'context' => array( 'view' ), |
|
315 | + 'context' => array('view'), |
|
316 | 316 | 'readonly' => true, |
317 | 317 | ), |
318 | 318 | 'maxmind_geoip_database' => array( |
319 | - 'description' => __( 'MaxMind GeoIP database.', 'woocommerce' ), |
|
319 | + 'description' => __('MaxMind GeoIP database.', 'woocommerce'), |
|
320 | 320 | 'type' => 'string', |
321 | - 'context' => array( 'view' ), |
|
321 | + 'context' => array('view'), |
|
322 | 322 | 'readonly' => true, |
323 | 323 | ), |
324 | 324 | 'database_tables' => array( |
325 | - 'description' => __( 'Database tables.', 'woocommerce' ), |
|
325 | + 'description' => __('Database tables.', 'woocommerce'), |
|
326 | 326 | 'type' => 'array', |
327 | - 'context' => array( 'view' ), |
|
327 | + 'context' => array('view'), |
|
328 | 328 | 'readonly' => true, |
329 | 329 | 'items' => array( |
330 | 330 | 'type' => 'string', |
@@ -333,190 +333,190 @@ discard block |
||
333 | 333 | ), |
334 | 334 | ), |
335 | 335 | 'active_plugins' => array( |
336 | - 'description' => __( 'Active plugins.', 'woocommerce' ), |
|
336 | + 'description' => __('Active plugins.', 'woocommerce'), |
|
337 | 337 | 'type' => 'array', |
338 | - 'context' => array( 'view' ), |
|
338 | + 'context' => array('view'), |
|
339 | 339 | 'readonly' => true, |
340 | 340 | 'items' => array( |
341 | 341 | 'type' => 'string', |
342 | 342 | ), |
343 | 343 | ), |
344 | 344 | 'inactive_plugins' => array( |
345 | - 'description' => __( 'Inactive plugins.', 'woocommerce' ), |
|
345 | + 'description' => __('Inactive plugins.', 'woocommerce'), |
|
346 | 346 | 'type' => 'array', |
347 | - 'context' => array( 'view' ), |
|
347 | + 'context' => array('view'), |
|
348 | 348 | 'readonly' => true, |
349 | 349 | 'items' => array( |
350 | 350 | 'type' => 'string', |
351 | 351 | ), |
352 | 352 | ), |
353 | 353 | 'dropins_mu_plugins' => array( |
354 | - 'description' => __( 'Dropins & MU plugins.', 'woocommerce' ), |
|
354 | + 'description' => __('Dropins & MU plugins.', 'woocommerce'), |
|
355 | 355 | 'type' => 'array', |
356 | - 'context' => array( 'view' ), |
|
356 | + 'context' => array('view'), |
|
357 | 357 | 'readonly' => true, |
358 | 358 | 'items' => array( |
359 | 359 | 'type' => 'string', |
360 | 360 | ), |
361 | 361 | ), |
362 | 362 | 'theme' => array( |
363 | - 'description' => __( 'Theme.', 'woocommerce' ), |
|
363 | + 'description' => __('Theme.', 'woocommerce'), |
|
364 | 364 | 'type' => 'object', |
365 | - 'context' => array( 'view' ), |
|
365 | + 'context' => array('view'), |
|
366 | 366 | 'readonly' => true, |
367 | 367 | 'properties' => array( |
368 | 368 | 'name' => array( |
369 | - 'description' => __( 'Theme name.', 'woocommerce' ), |
|
369 | + 'description' => __('Theme name.', 'woocommerce'), |
|
370 | 370 | 'type' => 'string', |
371 | - 'context' => array( 'view' ), |
|
371 | + 'context' => array('view'), |
|
372 | 372 | 'readonly' => true, |
373 | 373 | ), |
374 | 374 | 'version' => array( |
375 | - 'description' => __( 'Theme version.', 'woocommerce' ), |
|
375 | + 'description' => __('Theme version.', 'woocommerce'), |
|
376 | 376 | 'type' => 'string', |
377 | - 'context' => array( 'view' ), |
|
377 | + 'context' => array('view'), |
|
378 | 378 | 'readonly' => true, |
379 | 379 | ), |
380 | 380 | 'version_latest' => array( |
381 | - 'description' => __( 'Latest version of theme.', 'woocommerce' ), |
|
381 | + 'description' => __('Latest version of theme.', 'woocommerce'), |
|
382 | 382 | 'type' => 'string', |
383 | - 'context' => array( 'view' ), |
|
383 | + 'context' => array('view'), |
|
384 | 384 | 'readonly' => true, |
385 | 385 | ), |
386 | 386 | 'author_url' => array( |
387 | - 'description' => __( 'Theme author URL.', 'woocommerce' ), |
|
387 | + 'description' => __('Theme author URL.', 'woocommerce'), |
|
388 | 388 | 'type' => 'string', |
389 | 389 | 'format' => 'uri', |
390 | - 'context' => array( 'view' ), |
|
390 | + 'context' => array('view'), |
|
391 | 391 | 'readonly' => true, |
392 | 392 | ), |
393 | 393 | 'is_child_theme' => array( |
394 | - 'description' => __( 'Is this theme a child theme?', 'woocommerce' ), |
|
394 | + 'description' => __('Is this theme a child theme?', 'woocommerce'), |
|
395 | 395 | 'type' => 'boolean', |
396 | - 'context' => array( 'view' ), |
|
396 | + 'context' => array('view'), |
|
397 | 397 | 'readonly' => true, |
398 | 398 | ), |
399 | 399 | 'has_woocommerce_support' => array( |
400 | - 'description' => __( 'Does the theme declare WooCommerce support?', 'woocommerce' ), |
|
400 | + 'description' => __('Does the theme declare WooCommerce support?', 'woocommerce'), |
|
401 | 401 | 'type' => 'boolean', |
402 | - 'context' => array( 'view' ), |
|
402 | + 'context' => array('view'), |
|
403 | 403 | 'readonly' => true, |
404 | 404 | ), |
405 | 405 | 'has_woocommerce_file' => array( |
406 | - 'description' => __( 'Does the theme have a woocommerce.php file?', 'woocommerce' ), |
|
406 | + 'description' => __('Does the theme have a woocommerce.php file?', 'woocommerce'), |
|
407 | 407 | 'type' => 'boolean', |
408 | - 'context' => array( 'view' ), |
|
408 | + 'context' => array('view'), |
|
409 | 409 | 'readonly' => true, |
410 | 410 | ), |
411 | 411 | 'has_outdated_templates' => array( |
412 | - 'description' => __( 'Does this theme have outdated templates?', 'woocommerce' ), |
|
412 | + 'description' => __('Does this theme have outdated templates?', 'woocommerce'), |
|
413 | 413 | 'type' => 'boolean', |
414 | - 'context' => array( 'view' ), |
|
414 | + 'context' => array('view'), |
|
415 | 415 | 'readonly' => true, |
416 | 416 | ), |
417 | 417 | 'overrides' => array( |
418 | - 'description' => __( 'Template overrides.', 'woocommerce' ), |
|
418 | + 'description' => __('Template overrides.', 'woocommerce'), |
|
419 | 419 | 'type' => 'array', |
420 | - 'context' => array( 'view' ), |
|
420 | + 'context' => array('view'), |
|
421 | 421 | 'readonly' => true, |
422 | 422 | 'items' => array( |
423 | 423 | 'type' => 'string', |
424 | 424 | ), |
425 | 425 | ), |
426 | 426 | 'parent_name' => array( |
427 | - 'description' => __( 'Parent theme name.', 'woocommerce' ), |
|
427 | + 'description' => __('Parent theme name.', 'woocommerce'), |
|
428 | 428 | 'type' => 'string', |
429 | - 'context' => array( 'view' ), |
|
429 | + 'context' => array('view'), |
|
430 | 430 | 'readonly' => true, |
431 | 431 | ), |
432 | 432 | 'parent_version' => array( |
433 | - 'description' => __( 'Parent theme version.', 'woocommerce' ), |
|
433 | + 'description' => __('Parent theme version.', 'woocommerce'), |
|
434 | 434 | 'type' => 'string', |
435 | - 'context' => array( 'view' ), |
|
435 | + 'context' => array('view'), |
|
436 | 436 | 'readonly' => true, |
437 | 437 | ), |
438 | 438 | 'parent_author_url' => array( |
439 | - 'description' => __( 'Parent theme author URL.', 'woocommerce' ), |
|
439 | + 'description' => __('Parent theme author URL.', 'woocommerce'), |
|
440 | 440 | 'type' => 'string', |
441 | 441 | 'format' => 'uri', |
442 | - 'context' => array( 'view' ), |
|
442 | + 'context' => array('view'), |
|
443 | 443 | 'readonly' => true, |
444 | 444 | ), |
445 | 445 | ), |
446 | 446 | ), |
447 | 447 | 'settings' => array( |
448 | - 'description' => __( 'Settings.', 'woocommerce' ), |
|
448 | + 'description' => __('Settings.', 'woocommerce'), |
|
449 | 449 | 'type' => 'object', |
450 | - 'context' => array( 'view' ), |
|
450 | + 'context' => array('view'), |
|
451 | 451 | 'readonly' => true, |
452 | 452 | 'properties' => array( |
453 | 453 | 'api_enabled' => array( |
454 | - 'description' => __( 'REST API enabled?', 'woocommerce' ), |
|
454 | + 'description' => __('REST API enabled?', 'woocommerce'), |
|
455 | 455 | 'type' => 'boolean', |
456 | - 'context' => array( 'view' ), |
|
456 | + 'context' => array('view'), |
|
457 | 457 | 'readonly' => true, |
458 | 458 | ), |
459 | 459 | 'force_ssl' => array( |
460 | - 'description' => __( 'SSL forced?', 'woocommerce' ), |
|
460 | + 'description' => __('SSL forced?', 'woocommerce'), |
|
461 | 461 | 'type' => 'boolean', |
462 | - 'context' => array( 'view' ), |
|
462 | + 'context' => array('view'), |
|
463 | 463 | 'readonly' => true, |
464 | 464 | ), |
465 | 465 | 'currency' => array( |
466 | - 'description' => __( 'Currency.', 'woocommerce' ), |
|
466 | + 'description' => __('Currency.', 'woocommerce'), |
|
467 | 467 | 'type' => 'string', |
468 | - 'context' => array( 'view' ), |
|
468 | + 'context' => array('view'), |
|
469 | 469 | 'readonly' => true, |
470 | 470 | ), |
471 | 471 | 'currency_symbol' => array( |
472 | - 'description' => __( 'Currency symbol.', 'woocommerce' ), |
|
472 | + 'description' => __('Currency symbol.', 'woocommerce'), |
|
473 | 473 | 'type' => 'string', |
474 | - 'context' => array( 'view' ), |
|
474 | + 'context' => array('view'), |
|
475 | 475 | 'readonly' => true, |
476 | 476 | ), |
477 | 477 | 'currency_position' => array( |
478 | - 'description' => __( 'Currency position.', 'woocommerce' ), |
|
478 | + 'description' => __('Currency position.', 'woocommerce'), |
|
479 | 479 | 'type' => 'string', |
480 | - 'context' => array( 'view' ), |
|
480 | + 'context' => array('view'), |
|
481 | 481 | 'readonly' => true, |
482 | 482 | ), |
483 | 483 | 'thousand_separator' => array( |
484 | - 'description' => __( 'Thousand separator.', 'woocommerce' ), |
|
484 | + 'description' => __('Thousand separator.', 'woocommerce'), |
|
485 | 485 | 'type' => 'string', |
486 | - 'context' => array( 'view' ), |
|
486 | + 'context' => array('view'), |
|
487 | 487 | 'readonly' => true, |
488 | 488 | ), |
489 | 489 | 'decimal_separator' => array( |
490 | - 'description' => __( 'Decimal separator.', 'woocommerce' ), |
|
490 | + 'description' => __('Decimal separator.', 'woocommerce'), |
|
491 | 491 | 'type' => 'string', |
492 | - 'context' => array( 'view' ), |
|
492 | + 'context' => array('view'), |
|
493 | 493 | 'readonly' => true, |
494 | 494 | ), |
495 | 495 | 'number_of_decimals' => array( |
496 | - 'description' => __( 'Number of decimals.', 'woocommerce' ), |
|
496 | + 'description' => __('Number of decimals.', 'woocommerce'), |
|
497 | 497 | 'type' => 'integer', |
498 | - 'context' => array( 'view' ), |
|
498 | + 'context' => array('view'), |
|
499 | 499 | 'readonly' => true, |
500 | 500 | ), |
501 | 501 | 'geolocation_enabled' => array( |
502 | - 'description' => __( 'Geolocation enabled?', 'woocommerce' ), |
|
502 | + 'description' => __('Geolocation enabled?', 'woocommerce'), |
|
503 | 503 | 'type' => 'boolean', |
504 | - 'context' => array( 'view' ), |
|
504 | + 'context' => array('view'), |
|
505 | 505 | 'readonly' => true, |
506 | 506 | ), |
507 | 507 | 'taxonomies' => array( |
508 | - 'description' => __( 'Taxonomy terms for product/order statuses.', 'woocommerce' ), |
|
508 | + 'description' => __('Taxonomy terms for product/order statuses.', 'woocommerce'), |
|
509 | 509 | 'type' => 'array', |
510 | - 'context' => array( 'view' ), |
|
510 | + 'context' => array('view'), |
|
511 | 511 | 'readonly' => true, |
512 | 512 | 'items' => array( |
513 | 513 | 'type' => 'string', |
514 | 514 | ), |
515 | 515 | ), |
516 | 516 | 'product_visibility_terms' => array( |
517 | - 'description' => __( 'Terms in the product visibility taxonomy.', 'woocommerce' ), |
|
517 | + 'description' => __('Terms in the product visibility taxonomy.', 'woocommerce'), |
|
518 | 518 | 'type' => 'array', |
519 | - 'context' => array( 'view' ), |
|
519 | + 'context' => array('view'), |
|
520 | 520 | 'readonly' => true, |
521 | 521 | 'items' => array( |
522 | 522 | 'type' => 'string', |
@@ -525,29 +525,29 @@ discard block |
||
525 | 525 | ), |
526 | 526 | ), |
527 | 527 | 'security' => array( |
528 | - 'description' => __( 'Security.', 'woocommerce' ), |
|
528 | + 'description' => __('Security.', 'woocommerce'), |
|
529 | 529 | 'type' => 'object', |
530 | - 'context' => array( 'view' ), |
|
530 | + 'context' => array('view'), |
|
531 | 531 | 'readonly' => true, |
532 | 532 | 'properties' => array( |
533 | 533 | 'secure_connection' => array( |
534 | - 'description' => __( 'Is the connection to your store secure?', 'woocommerce' ), |
|
534 | + 'description' => __('Is the connection to your store secure?', 'woocommerce'), |
|
535 | 535 | 'type' => 'boolean', |
536 | - 'context' => array( 'view' ), |
|
536 | + 'context' => array('view'), |
|
537 | 537 | 'readonly' => true, |
538 | 538 | ), |
539 | 539 | 'hide_errors' => array( |
540 | - 'description' => __( 'Hide errors from visitors?', 'woocommerce' ), |
|
540 | + 'description' => __('Hide errors from visitors?', 'woocommerce'), |
|
541 | 541 | 'type' => 'boolean', |
542 | - 'context' => array( 'view' ), |
|
542 | + 'context' => array('view'), |
|
543 | 543 | 'readonly' => true, |
544 | 544 | ), |
545 | 545 | ), |
546 | 546 | ), |
547 | 547 | 'pages' => array( |
548 | - 'description' => __( 'WooCommerce pages.', 'woocommerce' ), |
|
548 | + 'description' => __('WooCommerce pages.', 'woocommerce'), |
|
549 | 549 | 'type' => 'array', |
550 | - 'context' => array( 'view' ), |
|
550 | + 'context' => array('view'), |
|
551 | 551 | 'readonly' => true, |
552 | 552 | 'items' => array( |
553 | 553 | 'type' => 'string', |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | ), |
557 | 557 | ); |
558 | 558 | |
559 | - return $this->add_additional_fields_schema( $schema ); |
|
559 | + return $this->add_additional_fields_schema($schema); |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | /** |
@@ -589,23 +589,23 @@ discard block |
||
589 | 589 | |
590 | 590 | // Figure out cURL version, if installed. |
591 | 591 | $curl_version = ''; |
592 | - if ( function_exists( 'curl_version' ) ) { |
|
592 | + if (function_exists('curl_version')) { |
|
593 | 593 | $curl_version = curl_version(); |
594 | 594 | $curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version']; |
595 | - } elseif ( extension_loaded( 'curl' ) ) { |
|
596 | - $curl_version = __( 'cURL installed but unable to retrieve version.', 'woocommerce' ); |
|
595 | + } elseif (extension_loaded('curl')) { |
|
596 | + $curl_version = __('cURL installed but unable to retrieve version.', 'woocommerce'); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | // WP memory limit. |
600 | - $wp_memory_limit = wc_let_to_num( WP_MEMORY_LIMIT ); |
|
601 | - if ( function_exists( 'memory_get_usage' ) ) { |
|
602 | - $wp_memory_limit = max( $wp_memory_limit, wc_let_to_num( @ini_get( 'memory_limit' ) ) ); |
|
600 | + $wp_memory_limit = wc_let_to_num(WP_MEMORY_LIMIT); |
|
601 | + if (function_exists('memory_get_usage')) { |
|
602 | + $wp_memory_limit = max($wp_memory_limit, wc_let_to_num(@ini_get('memory_limit'))); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | // Test POST requests. |
606 | - $post_response_code = get_transient( 'woocommerce_test_remote_post' ); |
|
606 | + $post_response_code = get_transient('woocommerce_test_remote_post'); |
|
607 | 607 | |
608 | - if ( false === $post_response_code || is_wp_error( $post_response_code ) ) { |
|
608 | + if (false === $post_response_code || is_wp_error($post_response_code)) { |
|
609 | 609 | $response = wp_safe_remote_post( |
610 | 610 | 'https://www.paypal.com/cgi-bin/webscr', |
611 | 611 | array( |
@@ -617,63 +617,63 @@ discard block |
||
617 | 617 | ), |
618 | 618 | ) |
619 | 619 | ); |
620 | - if ( ! is_wp_error( $response ) ) { |
|
620 | + if ( ! is_wp_error($response)) { |
|
621 | 621 | $post_response_code = $response['response']['code']; |
622 | 622 | } |
623 | - set_transient( 'woocommerce_test_remote_post', $post_response_code, HOUR_IN_SECONDS ); |
|
623 | + set_transient('woocommerce_test_remote_post', $post_response_code, HOUR_IN_SECONDS); |
|
624 | 624 | } |
625 | 625 | |
626 | - $post_response_successful = ! is_wp_error( $post_response_code ) && $post_response_code >= 200 && $post_response_code < 300; |
|
626 | + $post_response_successful = ! is_wp_error($post_response_code) && $post_response_code >= 200 && $post_response_code < 300; |
|
627 | 627 | |
628 | 628 | // Test GET requests. |
629 | - $get_response_code = get_transient( 'woocommerce_test_remote_get' ); |
|
629 | + $get_response_code = get_transient('woocommerce_test_remote_get'); |
|
630 | 630 | |
631 | - if ( false === $get_response_code || is_wp_error( $get_response_code ) ) { |
|
632 | - $response = wp_safe_remote_get( 'https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ) ); |
|
633 | - if ( ! is_wp_error( $response ) ) { |
|
631 | + if (false === $get_response_code || is_wp_error($get_response_code)) { |
|
632 | + $response = wp_safe_remote_get('https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . (is_multisite() ? '1' : '0')); |
|
633 | + if ( ! is_wp_error($response)) { |
|
634 | 634 | $get_response_code = $response['response']['code']; |
635 | 635 | } |
636 | - set_transient( 'woocommerce_test_remote_get', $get_response_code, HOUR_IN_SECONDS ); |
|
636 | + set_transient('woocommerce_test_remote_get', $get_response_code, HOUR_IN_SECONDS); |
|
637 | 637 | } |
638 | 638 | |
639 | - $get_response_successful = ! is_wp_error( $get_response_code ) && $get_response_code >= 200 && $get_response_code < 300; |
|
639 | + $get_response_successful = ! is_wp_error($get_response_code) && $get_response_code >= 200 && $get_response_code < 300; |
|
640 | 640 | |
641 | 641 | $database_version = wc_get_server_database_version(); |
642 | 642 | |
643 | 643 | // Return all environment info. Described by JSON Schema. |
644 | 644 | return array( |
645 | - 'home_url' => get_option( 'home' ), |
|
646 | - 'site_url' => get_option( 'siteurl' ), |
|
645 | + 'home_url' => get_option('home'), |
|
646 | + 'site_url' => get_option('siteurl'), |
|
647 | 647 | 'version' => WC()->version, |
648 | 648 | 'log_directory' => WC_LOG_DIR, |
649 | - 'log_directory_writable' => (bool) @fopen( WC_LOG_DIR . 'test-log.log', 'a' ), |
|
650 | - 'wp_version' => get_bloginfo( 'version' ), |
|
649 | + 'log_directory_writable' => (bool) @fopen(WC_LOG_DIR . 'test-log.log', 'a'), |
|
650 | + 'wp_version' => get_bloginfo('version'), |
|
651 | 651 | 'wp_multisite' => is_multisite(), |
652 | 652 | 'wp_memory_limit' => $wp_memory_limit, |
653 | - 'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ), |
|
654 | - 'wp_cron' => ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ), |
|
653 | + 'wp_debug_mode' => (defined('WP_DEBUG') && WP_DEBUG), |
|
654 | + 'wp_cron' => ! (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON), |
|
655 | 655 | 'language' => get_locale(), |
656 | 656 | 'external_object_cache' => wp_using_ext_object_cache(), |
657 | - 'server_info' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? wc_clean( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '', |
|
657 | + 'server_info' => isset($_SERVER['SERVER_SOFTWARE']) ? wc_clean(wp_unslash($_SERVER['SERVER_SOFTWARE'])) : '', |
|
658 | 658 | 'php_version' => phpversion(), |
659 | - 'php_post_max_size' => wc_let_to_num( ini_get( 'post_max_size' ) ), |
|
660 | - 'php_max_execution_time' => ini_get( 'max_execution_time' ), |
|
661 | - 'php_max_input_vars' => ini_get( 'max_input_vars' ), |
|
659 | + 'php_post_max_size' => wc_let_to_num(ini_get('post_max_size')), |
|
660 | + 'php_max_execution_time' => ini_get('max_execution_time'), |
|
661 | + 'php_max_input_vars' => ini_get('max_input_vars'), |
|
662 | 662 | 'curl_version' => $curl_version, |
663 | - 'suhosin_installed' => extension_loaded( 'suhosin' ), |
|
663 | + 'suhosin_installed' => extension_loaded('suhosin'), |
|
664 | 664 | 'max_upload_size' => wp_max_upload_size(), |
665 | 665 | 'mysql_version' => $database_version['number'], |
666 | 666 | 'mysql_version_string' => $database_version['string'], |
667 | 667 | 'default_timezone' => date_default_timezone_get(), |
668 | - 'fsockopen_or_curl_enabled' => ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ), |
|
669 | - 'soapclient_enabled' => class_exists( 'SoapClient' ), |
|
670 | - 'domdocument_enabled' => class_exists( 'DOMDocument' ), |
|
671 | - 'gzip_enabled' => is_callable( 'gzopen' ), |
|
672 | - 'mbstring_enabled' => extension_loaded( 'mbstring' ), |
|
668 | + 'fsockopen_or_curl_enabled' => (function_exists('fsockopen') || function_exists('curl_init')), |
|
669 | + 'soapclient_enabled' => class_exists('SoapClient'), |
|
670 | + 'domdocument_enabled' => class_exists('DOMDocument'), |
|
671 | + 'gzip_enabled' => is_callable('gzopen'), |
|
672 | + 'mbstring_enabled' => extension_loaded('mbstring'), |
|
673 | 673 | 'remote_post_successful' => $post_response_successful, |
674 | - 'remote_post_response' => is_wp_error( $post_response_code ) ? $post_response_code->get_error_message() : $post_response_code, |
|
674 | + 'remote_post_response' => is_wp_error($post_response_code) ? $post_response_code->get_error_message() : $post_response_code, |
|
675 | 675 | 'remote_get_successful' => $get_response_successful, |
676 | - 'remote_get_response' => is_wp_error( $get_response_code ) ? $get_response_code->get_error_message() : $get_response_code, |
|
676 | + 'remote_get_response' => is_wp_error($get_response_code) ? $get_response_code->get_error_message() : $get_response_code, |
|
677 | 677 | ); |
678 | 678 | } |
679 | 679 | |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | * @param string $table Table name. |
684 | 684 | * @return stromg |
685 | 685 | */ |
686 | - protected function add_db_table_prefix( $table ) { |
|
686 | + protected function add_db_table_prefix($table) { |
|
687 | 687 | global $wpdb; |
688 | 688 | return $wpdb->prefix . $table; |
689 | 689 | } |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | * |
737 | 737 | * If we changed the tables above to include the prefix, then any filters against that table could break. |
738 | 738 | */ |
739 | - $core_tables = array_map( array( $this, 'add_db_table_prefix' ), $core_tables ); |
|
739 | + $core_tables = array_map(array($this, 'add_db_table_prefix'), $core_tables); |
|
740 | 740 | |
741 | 741 | /** |
742 | 742 | * Organize WooCommerce and non-WooCommerce tables separately for display purposes later. |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | * To ensure we include all WC tables, even if they do not exist, pre-populate the WC array with all the tables. |
745 | 745 | */ |
746 | 746 | $tables = array( |
747 | - 'woocommerce' => array_fill_keys( $core_tables, false ), |
|
747 | + 'woocommerce' => array_fill_keys($core_tables, false), |
|
748 | 748 | 'other' => array(), |
749 | 749 | ); |
750 | 750 | |
@@ -753,16 +753,16 @@ discard block |
||
753 | 753 | 'index' => 0, |
754 | 754 | ); |
755 | 755 | |
756 | - $site_tables_prefix = $wpdb->get_blog_prefix( get_current_blog_id() ); |
|
757 | - $global_tables = $wpdb->tables( 'global', true ); |
|
758 | - foreach ( $database_table_information as $table ) { |
|
756 | + $site_tables_prefix = $wpdb->get_blog_prefix(get_current_blog_id()); |
|
757 | + $global_tables = $wpdb->tables('global', true); |
|
758 | + foreach ($database_table_information as $table) { |
|
759 | 759 | // Only include tables matching the prefix of the current site, this is to prevent displaying all tables on a MS install not relating to the current. |
760 | - if ( is_multisite() && 0 !== strpos( $table->name, $site_tables_prefix ) && ! in_array( $table->name, $global_tables, true ) ) { |
|
760 | + if (is_multisite() && 0 !== strpos($table->name, $site_tables_prefix) && ! in_array($table->name, $global_tables, true)) { |
|
761 | 761 | continue; |
762 | 762 | } |
763 | - $table_type = in_array( $table->name, $core_tables ) ? 'woocommerce' : 'other'; |
|
763 | + $table_type = in_array($table->name, $core_tables) ? 'woocommerce' : 'other'; |
|
764 | 764 | |
765 | - $tables[ $table_type ][ $table->name ] = array( |
|
765 | + $tables[$table_type][$table->name] = array( |
|
766 | 766 | 'data' => $table->data, |
767 | 767 | 'index' => $table->index, |
768 | 768 | 'engine' => $table->engine, |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | |
775 | 775 | // Return all database info. Described by JSON Schema. |
776 | 776 | return array( |
777 | - 'wc_database_version' => get_option( 'woocommerce_db_version' ), |
|
777 | + 'wc_database_version' => get_option('woocommerce_db_version'), |
|
778 | 778 | 'database_prefix' => $wpdb->prefix, |
779 | 779 | 'maxmind_geoip_database' => WC_Geolocation::get_local_database_path(), |
780 | 780 | 'database_tables' => $tables, |
@@ -790,9 +790,9 @@ discard block |
||
790 | 790 | public function get_post_type_counts() { |
791 | 791 | global $wpdb; |
792 | 792 | |
793 | - $post_type_counts = $wpdb->get_results( "SELECT post_type AS 'type', count(1) AS 'count' FROM {$wpdb->posts} GROUP BY post_type;" ); |
|
793 | + $post_type_counts = $wpdb->get_results("SELECT post_type AS 'type', count(1) AS 'count' FROM {$wpdb->posts} GROUP BY post_type;"); |
|
794 | 794 | |
795 | - return is_array( $post_type_counts ) ? $post_type_counts : array(); |
|
795 | + return is_array($post_type_counts) ? $post_type_counts : array(); |
|
796 | 796 | } |
797 | 797 | |
798 | 798 | /** |
@@ -803,21 +803,21 @@ discard block |
||
803 | 803 | public function get_active_plugins() { |
804 | 804 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
805 | 805 | |
806 | - if ( ! function_exists( 'get_plugin_data' ) ) { |
|
806 | + if ( ! function_exists('get_plugin_data')) { |
|
807 | 807 | return array(); |
808 | 808 | } |
809 | 809 | |
810 | - $active_plugins = (array) get_option( 'active_plugins', array() ); |
|
811 | - if ( is_multisite() ) { |
|
812 | - $network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
813 | - $active_plugins = array_merge( $active_plugins, $network_activated_plugins ); |
|
810 | + $active_plugins = (array) get_option('active_plugins', array()); |
|
811 | + if (is_multisite()) { |
|
812 | + $network_activated_plugins = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
813 | + $active_plugins = array_merge($active_plugins, $network_activated_plugins); |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | $active_plugins_data = array(); |
817 | 817 | |
818 | - foreach ( $active_plugins as $plugin ) { |
|
819 | - $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
|
820 | - $active_plugins_data[] = $this->format_plugin_data( $plugin, $data ); |
|
818 | + foreach ($active_plugins as $plugin) { |
|
819 | + $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin); |
|
820 | + $active_plugins_data[] = $this->format_plugin_data($plugin, $data); |
|
821 | 821 | } |
822 | 822 | |
823 | 823 | return $active_plugins_data; |
@@ -831,25 +831,25 @@ discard block |
||
831 | 831 | public function get_inactive_plugins() { |
832 | 832 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
833 | 833 | |
834 | - if ( ! function_exists( 'get_plugins' ) ) { |
|
834 | + if ( ! function_exists('get_plugins')) { |
|
835 | 835 | return array(); |
836 | 836 | } |
837 | 837 | |
838 | 838 | $plugins = get_plugins(); |
839 | - $active_plugins = (array) get_option( 'active_plugins', array() ); |
|
839 | + $active_plugins = (array) get_option('active_plugins', array()); |
|
840 | 840 | |
841 | - if ( is_multisite() ) { |
|
842 | - $network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
843 | - $active_plugins = array_merge( $active_plugins, $network_activated_plugins ); |
|
841 | + if (is_multisite()) { |
|
842 | + $network_activated_plugins = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
843 | + $active_plugins = array_merge($active_plugins, $network_activated_plugins); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | $plugins_data = array(); |
847 | 847 | |
848 | - foreach ( $plugins as $plugin => $data ) { |
|
849 | - if ( in_array( $plugin, $active_plugins, true ) ) { |
|
848 | + foreach ($plugins as $plugin => $data) { |
|
849 | + if (in_array($plugin, $active_plugins, true)) { |
|
850 | 850 | continue; |
851 | 851 | } |
852 | - $plugins_data[] = $this->format_plugin_data( $plugin, $data ); |
|
852 | + $plugins_data[] = $this->format_plugin_data($plugin, $data); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | return $plugins_data; |
@@ -863,23 +863,23 @@ discard block |
||
863 | 863 | * @param array $data Plugin data from WP. |
864 | 864 | * @return array Formatted data. |
865 | 865 | */ |
866 | - protected function format_plugin_data( $plugin, $data ) { |
|
866 | + protected function format_plugin_data($plugin, $data) { |
|
867 | 867 | require_once ABSPATH . 'wp-admin/includes/update.php'; |
868 | 868 | |
869 | - if ( ! function_exists( 'get_plugin_updates' ) ) { |
|
869 | + if ( ! function_exists('get_plugin_updates')) { |
|
870 | 870 | return array(); |
871 | 871 | } |
872 | 872 | |
873 | 873 | // Use WP API to lookup latest updates for plugins. WC_Helper injects updates for premium plugins. |
874 | - if ( empty( $this->available_updates ) ) { |
|
874 | + if (empty($this->available_updates)) { |
|
875 | 875 | $this->available_updates = get_plugin_updates(); |
876 | 876 | } |
877 | 877 | |
878 | 878 | $version_latest = $data['Version']; |
879 | 879 | |
880 | 880 | // Find latest version. |
881 | - if ( isset( $this->available_updates[ $plugin ]->update->new_version ) ) { |
|
882 | - $version_latest = $this->available_updates[ $plugin ]->update->new_version; |
|
881 | + if (isset($this->available_updates[$plugin]->update->new_version)) { |
|
882 | + $version_latest = $this->available_updates[$plugin]->update->new_version; |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | return array( |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | 'version_latest' => $version_latest, |
890 | 890 | 'url' => $data['PluginURI'], |
891 | 891 | 'author_name' => $data['AuthorName'], |
892 | - 'author_url' => esc_url_raw( $data['AuthorURI'] ), |
|
892 | + 'author_url' => esc_url_raw($data['AuthorURI']), |
|
893 | 893 | 'network_activated' => $data['Network'], |
894 | 894 | ); |
895 | 895 | } |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | 'dropins' => array(), |
907 | 907 | 'mu_plugins' => array(), |
908 | 908 | ); |
909 | - foreach ( $dropins as $key => $dropin ) { |
|
909 | + foreach ($dropins as $key => $dropin) { |
|
910 | 910 | $plugins['dropins'][] = array( |
911 | 911 | 'plugin' => $key, |
912 | 912 | 'name' => $dropin['Name'], |
@@ -914,14 +914,14 @@ discard block |
||
914 | 914 | } |
915 | 915 | |
916 | 916 | $mu_plugins = get_mu_plugins(); |
917 | - foreach ( $mu_plugins as $plugin => $mu_plugin ) { |
|
917 | + foreach ($mu_plugins as $plugin => $mu_plugin) { |
|
918 | 918 | $plugins['mu_plugins'][] = array( |
919 | 919 | 'plugin' => $plugin, |
920 | 920 | 'name' => $mu_plugin['Name'], |
921 | 921 | 'version' => $mu_plugin['Version'], |
922 | 922 | 'url' => $mu_plugin['PluginURI'], |
923 | 923 | 'author_name' => $mu_plugin['AuthorName'], |
924 | - 'author_url' => esc_url_raw( $mu_plugin['AuthorURI'] ), |
|
924 | + 'author_url' => esc_url_raw($mu_plugin['AuthorURI']), |
|
925 | 925 | ); |
926 | 926 | } |
927 | 927 | return $plugins; |
@@ -938,12 +938,12 @@ discard block |
||
938 | 938 | |
939 | 939 | // Get parent theme info if this theme is a child theme, otherwise |
940 | 940 | // pass empty info in the response. |
941 | - if ( is_child_theme() ) { |
|
942 | - $parent_theme = wp_get_theme( $active_theme->template ); |
|
941 | + if (is_child_theme()) { |
|
942 | + $parent_theme = wp_get_theme($active_theme->template); |
|
943 | 943 | $parent_theme_info = array( |
944 | 944 | 'parent_name' => $parent_theme->name, |
945 | 945 | 'parent_version' => $parent_theme->version, |
946 | - 'parent_version_latest' => WC_Admin_Status::get_latest_theme_version( $parent_theme ), |
|
946 | + 'parent_version_latest' => WC_Admin_Status::get_latest_theme_version($parent_theme), |
|
947 | 947 | 'parent_author_url' => $parent_theme->{'Author URI'}, |
948 | 948 | ); |
949 | 949 | } else { |
@@ -961,34 +961,34 @@ discard block |
||
961 | 961 | */ |
962 | 962 | $override_files = array(); |
963 | 963 | $outdated_templates = false; |
964 | - $scan_files = WC_Admin_Status::scan_template_files( WC()->plugin_path() . '/templates/' ); |
|
965 | - foreach ( $scan_files as $file ) { |
|
966 | - $located = apply_filters( 'wc_get_template', $file, $file, array(), WC()->template_path(), WC()->plugin_path() . '/templates/' ); |
|
964 | + $scan_files = WC_Admin_Status::scan_template_files(WC()->plugin_path() . '/templates/'); |
|
965 | + foreach ($scan_files as $file) { |
|
966 | + $located = apply_filters('wc_get_template', $file, $file, array(), WC()->template_path(), WC()->plugin_path() . '/templates/'); |
|
967 | 967 | |
968 | - if ( file_exists( $located ) ) { |
|
968 | + if (file_exists($located)) { |
|
969 | 969 | $theme_file = $located; |
970 | - } elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) { |
|
970 | + } elseif (file_exists(get_stylesheet_directory() . '/' . $file)) { |
|
971 | 971 | $theme_file = get_stylesheet_directory() . '/' . $file; |
972 | - } elseif ( file_exists( get_stylesheet_directory() . '/' . WC()->template_path() . $file ) ) { |
|
972 | + } elseif (file_exists(get_stylesheet_directory() . '/' . WC()->template_path() . $file)) { |
|
973 | 973 | $theme_file = get_stylesheet_directory() . '/' . WC()->template_path() . $file; |
974 | - } elseif ( file_exists( get_template_directory() . '/' . $file ) ) { |
|
974 | + } elseif (file_exists(get_template_directory() . '/' . $file)) { |
|
975 | 975 | $theme_file = get_template_directory() . '/' . $file; |
976 | - } elseif ( file_exists( get_template_directory() . '/' . WC()->template_path() . $file ) ) { |
|
976 | + } elseif (file_exists(get_template_directory() . '/' . WC()->template_path() . $file)) { |
|
977 | 977 | $theme_file = get_template_directory() . '/' . WC()->template_path() . $file; |
978 | 978 | } else { |
979 | 979 | $theme_file = false; |
980 | 980 | } |
981 | 981 | |
982 | - if ( ! empty( $theme_file ) ) { |
|
983 | - $core_version = WC_Admin_Status::get_file_version( WC()->plugin_path() . '/templates/' . $file ); |
|
984 | - $theme_version = WC_Admin_Status::get_file_version( $theme_file ); |
|
985 | - if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) { |
|
986 | - if ( ! $outdated_templates ) { |
|
982 | + if ( ! empty($theme_file)) { |
|
983 | + $core_version = WC_Admin_Status::get_file_version(WC()->plugin_path() . '/templates/' . $file); |
|
984 | + $theme_version = WC_Admin_Status::get_file_version($theme_file); |
|
985 | + if ($core_version && (empty($theme_version) || version_compare($theme_version, $core_version, '<'))) { |
|
986 | + if ( ! $outdated_templates) { |
|
987 | 987 | $outdated_templates = true; |
988 | 988 | } |
989 | 989 | } |
990 | 990 | $override_files[] = array( |
991 | - 'file' => str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ), |
|
991 | + 'file' => str_replace(WP_CONTENT_DIR . '/themes/', '', $theme_file), |
|
992 | 992 | 'version' => $theme_version, |
993 | 993 | 'core_version' => $core_version, |
994 | 994 | ); |
@@ -998,16 +998,16 @@ discard block |
||
998 | 998 | $active_theme_info = array( |
999 | 999 | 'name' => $active_theme->name, |
1000 | 1000 | 'version' => $active_theme->version, |
1001 | - 'version_latest' => WC_Admin_Status::get_latest_theme_version( $active_theme ), |
|
1002 | - 'author_url' => esc_url_raw( $active_theme->{'Author URI'} ), |
|
1001 | + 'version_latest' => WC_Admin_Status::get_latest_theme_version($active_theme), |
|
1002 | + 'author_url' => esc_url_raw($active_theme->{'Author URI'} ), |
|
1003 | 1003 | 'is_child_theme' => is_child_theme(), |
1004 | - 'has_woocommerce_support' => current_theme_supports( 'woocommerce' ), |
|
1005 | - 'has_woocommerce_file' => ( file_exists( get_stylesheet_directory() . '/woocommerce.php' ) || file_exists( get_template_directory() . '/woocommerce.php' ) ), |
|
1004 | + 'has_woocommerce_support' => current_theme_supports('woocommerce'), |
|
1005 | + 'has_woocommerce_file' => (file_exists(get_stylesheet_directory() . '/woocommerce.php') || file_exists(get_template_directory() . '/woocommerce.php')), |
|
1006 | 1006 | 'has_outdated_templates' => $outdated_templates, |
1007 | 1007 | 'overrides' => $override_files, |
1008 | 1008 | ); |
1009 | 1009 | |
1010 | - return array_merge( $active_theme_info, $parent_theme_info ); |
|
1010 | + return array_merge($active_theme_info, $parent_theme_info); |
|
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | /** |
@@ -1019,36 +1019,36 @@ discard block |
||
1019 | 1019 | public function get_settings() { |
1020 | 1020 | // Get a list of terms used for product/order taxonomies. |
1021 | 1021 | $term_response = array(); |
1022 | - $terms = get_terms( 'product_type', array( 'hide_empty' => 0 ) ); |
|
1023 | - foreach ( $terms as $term ) { |
|
1024 | - $term_response[ $term->slug ] = strtolower( $term->name ); |
|
1022 | + $terms = get_terms('product_type', array('hide_empty' => 0)); |
|
1023 | + foreach ($terms as $term) { |
|
1024 | + $term_response[$term->slug] = strtolower($term->name); |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | // Get a list of terms used for product visibility. |
1028 | 1028 | $product_visibility_terms = array(); |
1029 | - $terms = get_terms( 'product_visibility', array( 'hide_empty' => 0 ) ); |
|
1030 | - foreach ( $terms as $term ) { |
|
1031 | - $product_visibility_terms[ $term->slug ] = strtolower( $term->name ); |
|
1029 | + $terms = get_terms('product_visibility', array('hide_empty' => 0)); |
|
1030 | + foreach ($terms as $term) { |
|
1031 | + $product_visibility_terms[$term->slug] = strtolower($term->name); |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | // Check if WooCommerce.com account is connected. |
1035 | 1035 | $woo_com_connected = 'no'; |
1036 | - $helper_options = get_option( 'woocommerce_helper_data', array() ); |
|
1037 | - if ( array_key_exists( 'auth', $helper_options ) && ! empty( $helper_options['auth'] ) ) { |
|
1036 | + $helper_options = get_option('woocommerce_helper_data', array()); |
|
1037 | + if (array_key_exists('auth', $helper_options) && ! empty($helper_options['auth'])) { |
|
1038 | 1038 | $woo_com_connected = 'yes'; |
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | // Return array of useful settings for debugging. |
1042 | 1042 | return array( |
1043 | - 'api_enabled' => 'yes' === get_option( 'woocommerce_api_enabled' ), |
|
1044 | - 'force_ssl' => 'yes' === get_option( 'woocommerce_force_ssl_checkout' ), |
|
1043 | + 'api_enabled' => 'yes' === get_option('woocommerce_api_enabled'), |
|
1044 | + 'force_ssl' => 'yes' === get_option('woocommerce_force_ssl_checkout'), |
|
1045 | 1045 | 'currency' => get_woocommerce_currency(), |
1046 | 1046 | 'currency_symbol' => get_woocommerce_currency_symbol(), |
1047 | - 'currency_position' => get_option( 'woocommerce_currency_pos' ), |
|
1047 | + 'currency_position' => get_option('woocommerce_currency_pos'), |
|
1048 | 1048 | 'thousand_separator' => wc_get_price_thousand_separator(), |
1049 | 1049 | 'decimal_separator' => wc_get_price_decimal_separator(), |
1050 | 1050 | 'number_of_decimals' => wc_get_price_decimals(), |
1051 | - 'geolocation_enabled' => in_array( get_option( 'woocommerce_default_customer_address' ), array( 'geolocation_ajax', 'geolocation' ) ), |
|
1051 | + 'geolocation_enabled' => in_array(get_option('woocommerce_default_customer_address'), array('geolocation_ajax', 'geolocation')), |
|
1052 | 1052 | 'taxonomies' => $term_response, |
1053 | 1053 | 'product_visibility_terms' => $product_visibility_terms, |
1054 | 1054 | 'woocommerce_com_connected' => $woo_com_connected, |
@@ -1061,10 +1061,10 @@ discard block |
||
1061 | 1061 | * @return array |
1062 | 1062 | */ |
1063 | 1063 | public function get_security_info() { |
1064 | - $check_page = wc_get_page_permalink( 'shop' ); |
|
1064 | + $check_page = wc_get_page_permalink('shop'); |
|
1065 | 1065 | return array( |
1066 | - 'secure_connection' => 'https' === substr( $check_page, 0, 5 ), |
|
1067 | - 'hide_errors' => ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), |
|
1066 | + 'secure_connection' => 'https' === substr($check_page, 0, 5), |
|
1067 | + 'hide_errors' => ! (defined('WP_DEBUG') && defined('WP_DEBUG_DISPLAY') && WP_DEBUG && WP_DEBUG_DISPLAY) || 0 === intval(ini_get('display_errors')), |
|
1068 | 1068 | ); |
1069 | 1069 | } |
1070 | 1070 | |
@@ -1077,31 +1077,31 @@ discard block |
||
1077 | 1077 | public function get_pages() { |
1078 | 1078 | // WC pages to check against. |
1079 | 1079 | $check_pages = array( |
1080 | - _x( 'Shop base', 'Page setting', 'woocommerce' ) => array( |
|
1080 | + _x('Shop base', 'Page setting', 'woocommerce') => array( |
|
1081 | 1081 | 'option' => 'woocommerce_shop_page_id', |
1082 | 1082 | 'shortcode' => '', |
1083 | 1083 | ), |
1084 | - _x( 'Cart', 'Page setting', 'woocommerce' ) => array( |
|
1084 | + _x('Cart', 'Page setting', 'woocommerce') => array( |
|
1085 | 1085 | 'option' => 'woocommerce_cart_page_id', |
1086 | - 'shortcode' => '[' . apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) . ']', |
|
1086 | + 'shortcode' => '[' . apply_filters('woocommerce_cart_shortcode_tag', 'woocommerce_cart') . ']', |
|
1087 | 1087 | ), |
1088 | - _x( 'Checkout', 'Page setting', 'woocommerce' ) => array( |
|
1088 | + _x('Checkout', 'Page setting', 'woocommerce') => array( |
|
1089 | 1089 | 'option' => 'woocommerce_checkout_page_id', |
1090 | - 'shortcode' => '[' . apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) . ']', |
|
1090 | + 'shortcode' => '[' . apply_filters('woocommerce_checkout_shortcode_tag', 'woocommerce_checkout') . ']', |
|
1091 | 1091 | ), |
1092 | - _x( 'My account', 'Page setting', 'woocommerce' ) => array( |
|
1092 | + _x('My account', 'Page setting', 'woocommerce') => array( |
|
1093 | 1093 | 'option' => 'woocommerce_myaccount_page_id', |
1094 | - 'shortcode' => '[' . apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' ) . ']', |
|
1094 | + 'shortcode' => '[' . apply_filters('woocommerce_my_account_shortcode_tag', 'woocommerce_my_account') . ']', |
|
1095 | 1095 | ), |
1096 | - _x( 'Terms and conditions', 'Page setting', 'woocommerce' ) => array( |
|
1096 | + _x('Terms and conditions', 'Page setting', 'woocommerce') => array( |
|
1097 | 1097 | 'option' => 'woocommerce_terms_page_id', |
1098 | 1098 | 'shortcode' => '', |
1099 | 1099 | ), |
1100 | 1100 | ); |
1101 | 1101 | |
1102 | 1102 | $pages_output = array(); |
1103 | - foreach ( $check_pages as $page_name => $values ) { |
|
1104 | - $page_id = get_option( $values['option'] ); |
|
1103 | + foreach ($check_pages as $page_name => $values) { |
|
1104 | + $page_id = get_option($values['option']); |
|
1105 | 1105 | $page_set = false; |
1106 | 1106 | $page_exists = false; |
1107 | 1107 | $page_visible = false; |
@@ -1109,21 +1109,21 @@ discard block |
||
1109 | 1109 | $shortcode_required = false; |
1110 | 1110 | |
1111 | 1111 | // Page checks. |
1112 | - if ( $page_id ) { |
|
1112 | + if ($page_id) { |
|
1113 | 1113 | $page_set = true; |
1114 | 1114 | } |
1115 | - if ( get_post( $page_id ) ) { |
|
1115 | + if (get_post($page_id)) { |
|
1116 | 1116 | $page_exists = true; |
1117 | 1117 | } |
1118 | - if ( 'publish' === get_post_status( $page_id ) ) { |
|
1118 | + if ('publish' === get_post_status($page_id)) { |
|
1119 | 1119 | $page_visible = true; |
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | // Shortcode checks. |
1123 | - if ( $values['shortcode'] && get_post( $page_id ) ) { |
|
1123 | + if ($values['shortcode'] && get_post($page_id)) { |
|
1124 | 1124 | $shortcode_required = true; |
1125 | - $page = get_post( $page_id ); |
|
1126 | - if ( strstr( $page->post_content, $values['shortcode'] ) ) { |
|
1125 | + $page = get_post($page_id); |
|
1126 | + if (strstr($page->post_content, $values['shortcode'])) { |
|
1127 | 1127 | $shortcode_present = true; |
1128 | 1128 | } |
1129 | 1129 | } |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | */ |
1152 | 1152 | public function get_collection_params() { |
1153 | 1153 | return array( |
1154 | - 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
1154 | + 'context' => $this->get_context_param(array('default' => 'view')), |
|
1155 | 1155 | ); |
1156 | 1156 | } |
1157 | 1157 | |
@@ -1162,11 +1162,11 @@ discard block |
||
1162 | 1162 | * @param WP_REST_Request $request Request object. |
1163 | 1163 | * @return WP_REST_Response |
1164 | 1164 | */ |
1165 | - public function prepare_item_for_response( $system_status, $request ) { |
|
1166 | - $data = $this->add_additional_fields_to_object( $system_status, $request ); |
|
1167 | - $data = $this->filter_response_by_context( $data, 'view' ); |
|
1165 | + public function prepare_item_for_response($system_status, $request) { |
|
1166 | + $data = $this->add_additional_fields_to_object($system_status, $request); |
|
1167 | + $data = $this->filter_response_by_context($data, 'view'); |
|
1168 | 1168 | |
1169 | - $response = rest_ensure_response( $data ); |
|
1169 | + $response = rest_ensure_response($data); |
|
1170 | 1170 | |
1171 | 1171 | /** |
1172 | 1172 | * Filter the system status returned from the REST API. |
@@ -1175,6 +1175,6 @@ discard block |
||
1175 | 1175 | * @param mixed $system_status System status |
1176 | 1176 | * @param WP_REST_Request $request Request object. |
1177 | 1177 | */ |
1178 | - return apply_filters( 'woocommerce_rest_prepare_system_status', $response, $system_status, $request ); |
|
1178 | + return apply_filters('woocommerce_rest_prepare_system_status', $response, $system_status, $request); |
|
1179 | 1179 | } |
1180 | 1180 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | * @since 2.6.0 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * REST API Product Attributes controller class. |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | namespace WooCommerce\RestApi\Controllers\Version4; |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * REST API System Status Tools controller class. |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | array( |
34 | 34 | array( |
35 | 35 | 'methods' => \WP_REST_Server::READABLE, |
36 | - 'callback' => array( $this, 'get_items' ), |
|
37 | - 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
36 | + 'callback' => array($this, 'get_items'), |
|
37 | + 'permission_callback' => array($this, 'get_items_permissions_check'), |
|
38 | 38 | 'args' => $this->get_collection_params(), |
39 | 39 | ), |
40 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
40 | + 'schema' => array($this, 'get_public_item_schema'), |
|
41 | 41 | ), |
42 | 42 | true |
43 | 43 | ); |
@@ -48,22 +48,22 @@ discard block |
||
48 | 48 | array( |
49 | 49 | 'args' => array( |
50 | 50 | 'id' => array( |
51 | - 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), |
|
51 | + 'description' => __('Unique identifier for the resource.', 'woocommerce'), |
|
52 | 52 | 'type' => 'string', |
53 | 53 | ), |
54 | 54 | ), |
55 | 55 | array( |
56 | 56 | 'methods' => \WP_REST_Server::READABLE, |
57 | - 'callback' => array( $this, 'get_item' ), |
|
58 | - 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
57 | + 'callback' => array($this, 'get_item'), |
|
58 | + 'permission_callback' => array($this, 'get_item_permissions_check'), |
|
59 | 59 | ), |
60 | 60 | array( |
61 | 61 | 'methods' => \WP_REST_Server::EDITABLE, |
62 | - 'callback' => array( $this, 'update_item' ), |
|
63 | - 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
|
64 | - 'args' => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::EDITABLE ), |
|
62 | + 'callback' => array($this, 'update_item'), |
|
63 | + 'permission_callback' => array($this, 'update_item_permissions_check'), |
|
64 | + 'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE), |
|
65 | 65 | ), |
66 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
66 | + 'schema' => array($this, 'get_public_item_schema'), |
|
67 | 67 | ), |
68 | 68 | true |
69 | 69 | ); |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | * @param \WP_REST_Request $request Full details about the request. |
76 | 76 | * @return \WP_Error|boolean |
77 | 77 | */ |
78 | - public function get_items_permissions_check( $request ) { |
|
79 | - if ( ! wc_rest_check_manager_permissions( 'system_status', 'read' ) ) { |
|
80 | - return new \WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
78 | + public function get_items_permissions_check($request) { |
|
79 | + if ( ! wc_rest_check_manager_permissions('system_status', 'read')) { |
|
80 | + return new \WP_Error('woocommerce_rest_cannot_view', __('Sorry, you cannot list resources.', 'woocommerce'), array('status' => rest_authorization_required_code())); |
|
81 | 81 | } |
82 | 82 | return true; |
83 | 83 | } |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | * @param \WP_REST_Request $request Full details about the request. |
89 | 89 | * @return \WP_Error|boolean |
90 | 90 | */ |
91 | - public function get_item_permissions_check( $request ) { |
|
92 | - if ( ! wc_rest_check_manager_permissions( 'system_status', 'read' ) ) { |
|
93 | - return new \WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
91 | + public function get_item_permissions_check($request) { |
|
92 | + if ( ! wc_rest_check_manager_permissions('system_status', 'read')) { |
|
93 | + return new \WP_Error('woocommerce_rest_cannot_view', __('Sorry, you cannot view this resource.', 'woocommerce'), array('status' => rest_authorization_required_code())); |
|
94 | 94 | } |
95 | 95 | return true; |
96 | 96 | } |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * @param \WP_REST_Request $request Full details about the request. |
102 | 102 | * @return \WP_Error|boolean |
103 | 103 | */ |
104 | - public function update_item_permissions_check( $request ) { |
|
105 | - if ( ! wc_rest_check_manager_permissions( 'system_status', 'edit' ) ) { |
|
106 | - return new \WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
104 | + public function update_item_permissions_check($request) { |
|
105 | + if ( ! wc_rest_check_manager_permissions('system_status', 'edit')) { |
|
106 | + return new \WP_Error('woocommerce_rest_cannot_update', __('Sorry, you cannot update resource.', 'woocommerce'), array('status' => rest_authorization_required_code())); |
|
107 | 107 | } |
108 | 108 | return true; |
109 | 109 | } |
@@ -117,89 +117,89 @@ discard block |
||
117 | 117 | public function get_tools() { |
118 | 118 | $tools = array( |
119 | 119 | 'clear_transients' => array( |
120 | - 'name' => __( 'WooCommerce transients', 'woocommerce' ), |
|
121 | - 'button' => __( 'Clear transients', 'woocommerce' ), |
|
122 | - 'desc' => __( 'This tool will clear the product/shop transients cache.', 'woocommerce' ), |
|
120 | + 'name' => __('WooCommerce transients', 'woocommerce'), |
|
121 | + 'button' => __('Clear transients', 'woocommerce'), |
|
122 | + 'desc' => __('This tool will clear the product/shop transients cache.', 'woocommerce'), |
|
123 | 123 | ), |
124 | 124 | 'clear_expired_transients' => array( |
125 | - 'name' => __( 'Expired transients', 'woocommerce' ), |
|
126 | - 'button' => __( 'Clear transients', 'woocommerce' ), |
|
127 | - 'desc' => __( 'This tool will clear ALL expired transients from WordPress.', 'woocommerce' ), |
|
125 | + 'name' => __('Expired transients', 'woocommerce'), |
|
126 | + 'button' => __('Clear transients', 'woocommerce'), |
|
127 | + 'desc' => __('This tool will clear ALL expired transients from WordPress.', 'woocommerce'), |
|
128 | 128 | ), |
129 | 129 | 'delete_orphaned_variations' => array( |
130 | - 'name' => __( 'Orphaned variations', 'woocommerce' ), |
|
131 | - 'button' => __( 'Delete orphaned variations', 'woocommerce' ), |
|
132 | - 'desc' => __( 'This tool will delete all variations which have no parent.', 'woocommerce' ), |
|
130 | + 'name' => __('Orphaned variations', 'woocommerce'), |
|
131 | + 'button' => __('Delete orphaned variations', 'woocommerce'), |
|
132 | + 'desc' => __('This tool will delete all variations which have no parent.', 'woocommerce'), |
|
133 | 133 | ), |
134 | 134 | 'clear_expired_download_permissions' => array( |
135 | - 'name' => __( 'Used-up download permissions', 'woocommerce' ), |
|
136 | - 'button' => __( 'Clean up download permissions', 'woocommerce' ), |
|
137 | - 'desc' => __( 'This tool will delete expired download permissions and permissions with 0 remaining downloads.', 'woocommerce' ), |
|
135 | + 'name' => __('Used-up download permissions', 'woocommerce'), |
|
136 | + 'button' => __('Clean up download permissions', 'woocommerce'), |
|
137 | + 'desc' => __('This tool will delete expired download permissions and permissions with 0 remaining downloads.', 'woocommerce'), |
|
138 | 138 | ), |
139 | 139 | 'regenerate_product_lookup_tables' => array( |
140 | - 'name' => __( 'Product lookup tables', 'woocommerce' ), |
|
141 | - 'button' => __( 'Regenerate', 'woocommerce' ), |
|
142 | - 'desc' => __( 'This tool will regenerate product lookup table data. This process may take a while.', 'woocommerce' ), |
|
140 | + 'name' => __('Product lookup tables', 'woocommerce'), |
|
141 | + 'button' => __('Regenerate', 'woocommerce'), |
|
142 | + 'desc' => __('This tool will regenerate product lookup table data. This process may take a while.', 'woocommerce'), |
|
143 | 143 | ), |
144 | 144 | 'recount_terms' => array( |
145 | - 'name' => __( 'Term counts', 'woocommerce' ), |
|
146 | - 'button' => __( 'Recount terms', 'woocommerce' ), |
|
147 | - 'desc' => __( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', 'woocommerce' ), |
|
145 | + 'name' => __('Term counts', 'woocommerce'), |
|
146 | + 'button' => __('Recount terms', 'woocommerce'), |
|
147 | + 'desc' => __('This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', 'woocommerce'), |
|
148 | 148 | ), |
149 | 149 | 'reset_roles' => array( |
150 | - 'name' => __( 'Capabilities', 'woocommerce' ), |
|
151 | - 'button' => __( 'Reset capabilities', 'woocommerce' ), |
|
152 | - 'desc' => __( 'This tool will reset the admin, customer and shop_manager roles to default. Use this if your users cannot access all of the WooCommerce admin pages.', 'woocommerce' ), |
|
150 | + 'name' => __('Capabilities', 'woocommerce'), |
|
151 | + 'button' => __('Reset capabilities', 'woocommerce'), |
|
152 | + 'desc' => __('This tool will reset the admin, customer and shop_manager roles to default. Use this if your users cannot access all of the WooCommerce admin pages.', 'woocommerce'), |
|
153 | 153 | ), |
154 | 154 | 'clear_sessions' => array( |
155 | - 'name' => __( 'Clear customer sessions', 'woocommerce' ), |
|
156 | - 'button' => __( 'Clear', 'woocommerce' ), |
|
155 | + 'name' => __('Clear customer sessions', 'woocommerce'), |
|
156 | + 'button' => __('Clear', 'woocommerce'), |
|
157 | 157 | 'desc' => sprintf( |
158 | 158 | '<strong class="red">%1$s</strong> %2$s', |
159 | - __( 'Note:', 'woocommerce' ), |
|
160 | - __( 'This tool will delete all customer session data from the database, including current carts and saved carts in the database.', 'woocommerce' ) |
|
159 | + __('Note:', 'woocommerce'), |
|
160 | + __('This tool will delete all customer session data from the database, including current carts and saved carts in the database.', 'woocommerce') |
|
161 | 161 | ), |
162 | 162 | ), |
163 | 163 | 'install_pages' => array( |
164 | - 'name' => __( 'Create default WooCommerce pages', 'woocommerce' ), |
|
165 | - 'button' => __( 'Create pages', 'woocommerce' ), |
|
164 | + 'name' => __('Create default WooCommerce pages', 'woocommerce'), |
|
165 | + 'button' => __('Create pages', 'woocommerce'), |
|
166 | 166 | 'desc' => sprintf( |
167 | 167 | '<strong class="red">%1$s</strong> %2$s', |
168 | - __( 'Note:', 'woocommerce' ), |
|
169 | - __( 'This tool will install all the missing WooCommerce pages. Pages already defined and set up will not be replaced.', 'woocommerce' ) |
|
168 | + __('Note:', 'woocommerce'), |
|
169 | + __('This tool will install all the missing WooCommerce pages. Pages already defined and set up will not be replaced.', 'woocommerce') |
|
170 | 170 | ), |
171 | 171 | ), |
172 | 172 | 'delete_taxes' => array( |
173 | - 'name' => __( 'Delete WooCommerce tax rates', 'woocommerce' ), |
|
174 | - 'button' => __( 'Delete tax rates', 'woocommerce' ), |
|
173 | + 'name' => __('Delete WooCommerce tax rates', 'woocommerce'), |
|
174 | + 'button' => __('Delete tax rates', 'woocommerce'), |
|
175 | 175 | 'desc' => sprintf( |
176 | 176 | '<strong class="red">%1$s</strong> %2$s', |
177 | - __( 'Note:', 'woocommerce' ), |
|
178 | - __( 'This option will delete ALL of your tax rates, use with caution. This action cannot be reversed.', 'woocommerce' ) |
|
177 | + __('Note:', 'woocommerce'), |
|
178 | + __('This option will delete ALL of your tax rates, use with caution. This action cannot be reversed.', 'woocommerce') |
|
179 | 179 | ), |
180 | 180 | ), |
181 | 181 | 'regenerate_thumbnails' => array( |
182 | - 'name' => __( 'Regenerate shop thumbnails', 'woocommerce' ), |
|
183 | - 'button' => __( 'Regenerate', 'woocommerce' ), |
|
184 | - 'desc' => __( 'This will regenerate all shop thumbnails to match your theme and/or image settings.', 'woocommerce' ), |
|
182 | + 'name' => __('Regenerate shop thumbnails', 'woocommerce'), |
|
183 | + 'button' => __('Regenerate', 'woocommerce'), |
|
184 | + 'desc' => __('This will regenerate all shop thumbnails to match your theme and/or image settings.', 'woocommerce'), |
|
185 | 185 | ), |
186 | 186 | 'db_update_routine' => array( |
187 | - 'name' => __( 'Update database', 'woocommerce' ), |
|
188 | - 'button' => __( 'Update database', 'woocommerce' ), |
|
187 | + 'name' => __('Update database', 'woocommerce'), |
|
188 | + 'button' => __('Update database', 'woocommerce'), |
|
189 | 189 | 'desc' => sprintf( |
190 | 190 | '<strong class="red">%1$s</strong> %2$s', |
191 | - __( 'Note:', 'woocommerce' ), |
|
192 | - __( 'This tool will update your WooCommerce database to the latest version. Please ensure you make sufficient backups before proceeding.', 'woocommerce' ) |
|
191 | + __('Note:', 'woocommerce'), |
|
192 | + __('This tool will update your WooCommerce database to the latest version. Please ensure you make sufficient backups before proceeding.', 'woocommerce') |
|
193 | 193 | ), |
194 | 194 | ), |
195 | 195 | ); |
196 | 196 | |
197 | 197 | // Jetpack does the image resizing heavy lifting so you don't have to. |
198 | - if ( ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) || ! apply_filters( 'woocommerce_background_image_regeneration', true ) ) { |
|
199 | - unset( $tools['regenerate_thumbnails'] ); |
|
198 | + if ((class_exists('Jetpack') && Jetpack::is_module_active('photon')) || ! apply_filters('woocommerce_background_image_regeneration', true)) { |
|
199 | + unset($tools['regenerate_thumbnails']); |
|
200 | 200 | } |
201 | 201 | |
202 | - return apply_filters( 'woocommerce_debug_tools', $tools ); |
|
202 | + return apply_filters('woocommerce_debug_tools', $tools); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | * @param \WP_REST_Request $request Full details about the request. |
209 | 209 | * @return \WP_Error\WP_REST_Response |
210 | 210 | */ |
211 | - public function get_items( $request ) { |
|
211 | + public function get_items($request) { |
|
212 | 212 | $tools = array(); |
213 | - foreach ( $this->get_tools() as $id => $tool ) { |
|
213 | + foreach ($this->get_tools() as $id => $tool) { |
|
214 | 214 | $tools[] = $this->prepare_response_for_collection( |
215 | 215 | $this->prepare_item_for_response( |
216 | 216 | array( |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | ); |
225 | 225 | } |
226 | 226 | |
227 | - $response = rest_ensure_response( $tools ); |
|
227 | + $response = rest_ensure_response($tools); |
|
228 | 228 | return $response; |
229 | 229 | } |
230 | 230 | |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | * @param \WP_REST_Request $request Request data. |
235 | 235 | * @return \WP_Error\WP_REST_Response |
236 | 236 | */ |
237 | - public function get_item( $request ) { |
|
237 | + public function get_item($request) { |
|
238 | 238 | $tools = $this->get_tools(); |
239 | - if ( empty( $tools[ $request['id'] ] ) ) { |
|
240 | - return new \WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
239 | + if (empty($tools[$request['id']])) { |
|
240 | + return new \WP_Error('woocommerce_rest_system_status_tool_invalid_id', __('Invalid tool ID.', 'woocommerce'), array('status' => 404)); |
|
241 | 241 | } |
242 | - $tool = $tools[ $request['id'] ]; |
|
242 | + $tool = $tools[$request['id']]; |
|
243 | 243 | return rest_ensure_response( |
244 | 244 | $this->prepare_item_for_response( |
245 | 245 | array( |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | * @param \WP_REST_Request $request Request data. |
260 | 260 | * @return \WP_Error\WP_REST_Response |
261 | 261 | */ |
262 | - public function update_item( $request ) { |
|
262 | + public function update_item($request) { |
|
263 | 263 | $tools = $this->get_tools(); |
264 | - if ( empty( $tools[ $request['id'] ] ) ) { |
|
265 | - return new \WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
264 | + if (empty($tools[$request['id']])) { |
|
265 | + return new \WP_Error('woocommerce_rest_system_status_tool_invalid_id', __('Invalid tool ID.', 'woocommerce'), array('status' => 404)); |
|
266 | 266 | } |
267 | 267 | |
268 | - $tool = $tools[ $request['id'] ]; |
|
268 | + $tool = $tools[$request['id']]; |
|
269 | 269 | $tool = array( |
270 | 270 | 'id' => $request['id'], |
271 | 271 | 'name' => $tool['name'], |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | 'description' => $tool['desc'], |
274 | 274 | ); |
275 | 275 | |
276 | - $execute_return = $this->execute_tool( $request['id'] ); |
|
277 | - $tool = array_merge( $tool, $execute_return ); |
|
276 | + $execute_return = $this->execute_tool($request['id']); |
|
277 | + $tool = array_merge($tool, $execute_return); |
|
278 | 278 | |
279 | 279 | /** |
280 | 280 | * Fires after a WooCommerce REST system status tool has been executed. |
@@ -282,11 +282,11 @@ discard block |
||
282 | 282 | * @param array $tool Details about the tool that has been executed. |
283 | 283 | * @param \WP_REST_Request $request The current \WP_REST_Request object. |
284 | 284 | */ |
285 | - do_action( 'woocommerce_rest_insert_system_status_tool', $tool, $request ); |
|
285 | + do_action('woocommerce_rest_insert_system_status_tool', $tool, $request); |
|
286 | 286 | |
287 | - $request->set_param( 'context', 'edit' ); |
|
288 | - $response = $this->prepare_item_for_response( $tool, $request ); |
|
289 | - return rest_ensure_response( $response ); |
|
287 | + $request->set_param('context', 'edit'); |
|
288 | + $response = $this->prepare_item_for_response($tool, $request); |
|
289 | + return rest_ensure_response($response); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -296,14 +296,14 @@ discard block |
||
296 | 296 | * @param \WP_REST_Request $request Request object. |
297 | 297 | * @return \WP_REST_Response $response Response data. |
298 | 298 | */ |
299 | - public function prepare_item_for_response( $item, $request ) { |
|
300 | - $context = empty( $request['context'] ) ? 'view' : $request['context']; |
|
301 | - $data = $this->add_additional_fields_to_object( $item, $request ); |
|
302 | - $data = $this->filter_response_by_context( $data, $context ); |
|
299 | + public function prepare_item_for_response($item, $request) { |
|
300 | + $context = empty($request['context']) ? 'view' : $request['context']; |
|
301 | + $data = $this->add_additional_fields_to_object($item, $request); |
|
302 | + $data = $this->filter_response_by_context($data, $context); |
|
303 | 303 | |
304 | - $response = rest_ensure_response( $data ); |
|
304 | + $response = rest_ensure_response($data); |
|
305 | 305 | |
306 | - $response->add_links( $this->prepare_links( $item['id'] ) ); |
|
306 | + $response->add_links($this->prepare_links($item['id'])); |
|
307 | 307 | |
308 | 308 | return $response; |
309 | 309 | } |
@@ -320,46 +320,46 @@ discard block |
||
320 | 320 | 'type' => 'object', |
321 | 321 | 'properties' => array( |
322 | 322 | 'id' => array( |
323 | - 'description' => __( 'A unique identifier for the tool.', 'woocommerce' ), |
|
323 | + 'description' => __('A unique identifier for the tool.', 'woocommerce'), |
|
324 | 324 | 'type' => 'string', |
325 | - 'context' => array( 'view', 'edit' ), |
|
325 | + 'context' => array('view', 'edit'), |
|
326 | 326 | 'arg_options' => array( |
327 | 327 | 'sanitize_callback' => 'sanitize_title', |
328 | 328 | ), |
329 | 329 | ), |
330 | 330 | 'name' => array( |
331 | - 'description' => __( 'Tool name.', 'woocommerce' ), |
|
331 | + 'description' => __('Tool name.', 'woocommerce'), |
|
332 | 332 | 'type' => 'string', |
333 | - 'context' => array( 'view', 'edit' ), |
|
333 | + 'context' => array('view', 'edit'), |
|
334 | 334 | 'arg_options' => array( |
335 | 335 | 'sanitize_callback' => 'sanitize_text_field', |
336 | 336 | ), |
337 | 337 | ), |
338 | 338 | 'action' => array( |
339 | - 'description' => __( 'What running the tool will do.', 'woocommerce' ), |
|
339 | + 'description' => __('What running the tool will do.', 'woocommerce'), |
|
340 | 340 | 'type' => 'string', |
341 | - 'context' => array( 'view', 'edit' ), |
|
341 | + 'context' => array('view', 'edit'), |
|
342 | 342 | 'arg_options' => array( |
343 | 343 | 'sanitize_callback' => 'sanitize_text_field', |
344 | 344 | ), |
345 | 345 | ), |
346 | 346 | 'description' => array( |
347 | - 'description' => __( 'Tool description.', 'woocommerce' ), |
|
347 | + 'description' => __('Tool description.', 'woocommerce'), |
|
348 | 348 | 'type' => 'string', |
349 | - 'context' => array( 'view', 'edit' ), |
|
349 | + 'context' => array('view', 'edit'), |
|
350 | 350 | 'arg_options' => array( |
351 | 351 | 'sanitize_callback' => 'sanitize_text_field', |
352 | 352 | ), |
353 | 353 | ), |
354 | 354 | 'success' => array( |
355 | - 'description' => __( 'Did the tool run successfully?', 'woocommerce' ), |
|
355 | + 'description' => __('Did the tool run successfully?', 'woocommerce'), |
|
356 | 356 | 'type' => 'boolean', |
357 | - 'context' => array( 'edit' ), |
|
357 | + 'context' => array('edit'), |
|
358 | 358 | ), |
359 | 359 | 'message' => array( |
360 | - 'description' => __( 'Tool return message.', 'woocommerce' ), |
|
360 | + 'description' => __('Tool return message.', 'woocommerce'), |
|
361 | 361 | 'type' => 'string', |
362 | - 'context' => array( 'edit' ), |
|
362 | + 'context' => array('edit'), |
|
363 | 363 | 'arg_options' => array( |
364 | 364 | 'sanitize_callback' => 'sanitize_text_field', |
365 | 365 | ), |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | ), |
368 | 368 | ); |
369 | 369 | |
370 | - return $this->add_additional_fields_schema( $schema ); |
|
370 | + return $this->add_additional_fields_schema($schema); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
@@ -376,11 +376,11 @@ discard block |
||
376 | 376 | * @param string $id ID. |
377 | 377 | * @return array |
378 | 378 | */ |
379 | - protected function prepare_links( $id ) { |
|
379 | + protected function prepare_links($id) { |
|
380 | 380 | $base = '/' . $this->namespace . '/' . $this->rest_base; |
381 | 381 | $links = array( |
382 | 382 | 'item' => array( |
383 | - 'href' => rest_url( trailingslashit( $base ) . $id ), |
|
383 | + 'href' => rest_url(trailingslashit($base) . $id), |
|
384 | 384 | 'embeddable' => true, |
385 | 385 | ), |
386 | 386 | ); |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | */ |
396 | 396 | public function get_collection_params() { |
397 | 397 | return array( |
398 | - 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
398 | + 'context' => $this->get_context_param(array('default' => 'view')), |
|
399 | 399 | ); |
400 | 400 | } |
401 | 401 | |
@@ -405,30 +405,30 @@ discard block |
||
405 | 405 | * @param string $tool Tool. |
406 | 406 | * @return array |
407 | 407 | */ |
408 | - public function execute_tool( $tool ) { |
|
408 | + public function execute_tool($tool) { |
|
409 | 409 | global $wpdb; |
410 | 410 | $ran = true; |
411 | - switch ( $tool ) { |
|
411 | + switch ($tool) { |
|
412 | 412 | case 'clear_transients': |
413 | 413 | wc_delete_product_transients(); |
414 | 414 | wc_delete_shop_order_transients(); |
415 | - delete_transient( 'wc_count_comments' ); |
|
415 | + delete_transient('wc_count_comments'); |
|
416 | 416 | |
417 | 417 | $attribute_taxonomies = wc_get_attribute_taxonomies(); |
418 | 418 | |
419 | - if ( $attribute_taxonomies ) { |
|
420 | - foreach ( $attribute_taxonomies as $attribute ) { |
|
421 | - delete_transient( 'wc_layered_nav_counts_pa_' . $attribute->attribute_name ); |
|
419 | + if ($attribute_taxonomies) { |
|
420 | + foreach ($attribute_taxonomies as $attribute) { |
|
421 | + delete_transient('wc_layered_nav_counts_pa_' . $attribute->attribute_name); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | - \WC_Cache_Helper::get_transient_version( 'shipping', true ); |
|
426 | - $message = __( 'Product transients cleared', 'woocommerce' ); |
|
425 | + \WC_Cache_Helper::get_transient_version('shipping', true); |
|
426 | + $message = __('Product transients cleared', 'woocommerce'); |
|
427 | 427 | break; |
428 | 428 | |
429 | 429 | case 'clear_expired_transients': |
430 | 430 | /* translators: %d: amount of expired transients */ |
431 | - $message = sprintf( __( '%d transients rows cleared', 'woocommerce' ), wc_delete_expired_transients() ); |
|
431 | + $message = sprintf(__('%d transients rows cleared', 'woocommerce'), wc_delete_expired_transients()); |
|
432 | 432 | break; |
433 | 433 | |
434 | 434 | case 'delete_orphaned_variations': |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | ) |
443 | 443 | ); |
444 | 444 | /* translators: %d: amount of orphaned variations */ |
445 | - $message = sprintf( __( '%d orphaned variations deleted', 'woocommerce' ), $result ); |
|
445 | + $message = sprintf(__('%d orphaned variations deleted', 'woocommerce'), $result); |
|
446 | 446 | break; |
447 | 447 | |
448 | 448 | case 'clear_expired_download_permissions': |
@@ -452,25 +452,25 @@ discard block |
||
452 | 452 | $wpdb->prepare( |
453 | 453 | "DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions |
454 | 454 | WHERE ( downloads_remaining != '' AND downloads_remaining = 0 ) OR ( access_expires IS NOT NULL AND access_expires < %s )", |
455 | - date( 'Y-m-d', current_time( 'timestamp' ) ) |
|
455 | + date('Y-m-d', current_time('timestamp')) |
|
456 | 456 | ) |
457 | 457 | ) |
458 | 458 | ); |
459 | 459 | /* translators: %d: amount of permissions */ |
460 | - $message = sprintf( __( '%d permissions deleted', 'woocommerce' ), $result ); |
|
460 | + $message = sprintf(__('%d permissions deleted', 'woocommerce'), $result); |
|
461 | 461 | break; |
462 | 462 | |
463 | 463 | case 'regenerate_product_lookup_tables': |
464 | - if ( ! wc_update_product_lookup_tables_is_running() ) { |
|
464 | + if ( ! wc_update_product_lookup_tables_is_running()) { |
|
465 | 465 | wc_update_product_lookup_tables(); |
466 | 466 | } |
467 | - $message = __( 'Lookup tables are regenerating', 'woocommerce' ); |
|
467 | + $message = __('Lookup tables are regenerating', 'woocommerce'); |
|
468 | 468 | break; |
469 | 469 | case 'reset_roles': |
470 | 470 | // Remove then re-add caps and roles. |
471 | 471 | \WC_Install::remove_roles(); |
472 | 472 | \WC_Install::create_roles(); |
473 | - $message = __( 'Roles successfully reset', 'woocommerce' ); |
|
473 | + $message = __('Roles successfully reset', 'woocommerce'); |
|
474 | 474 | break; |
475 | 475 | |
476 | 476 | case 'recount_terms': |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | 'fields' => 'id=>parent', |
482 | 482 | ) |
483 | 483 | ); |
484 | - _wc_term_recount( $product_cats, get_taxonomy( 'product_cat' ), true, false ); |
|
484 | + _wc_term_recount($product_cats, get_taxonomy('product_cat'), true, false); |
|
485 | 485 | $product_tags = get_terms( |
486 | 486 | 'product_tag', |
487 | 487 | array( |
@@ -489,61 +489,61 @@ discard block |
||
489 | 489 | 'fields' => 'id=>parent', |
490 | 490 | ) |
491 | 491 | ); |
492 | - _wc_term_recount( $product_tags, get_taxonomy( 'product_tag' ), true, false ); |
|
493 | - $message = __( 'Terms successfully recounted', 'woocommerce' ); |
|
492 | + _wc_term_recount($product_tags, get_taxonomy('product_tag'), true, false); |
|
493 | + $message = __('Terms successfully recounted', 'woocommerce'); |
|
494 | 494 | break; |
495 | 495 | |
496 | 496 | case 'clear_sessions': |
497 | - $wpdb->query( "TRUNCATE {$wpdb->prefix}woocommerce_sessions" ); |
|
498 | - $result = absint( $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key='_woocommerce_persistent_cart_" . get_current_blog_id() . "';" ) ); // WPCS: unprepared SQL ok. |
|
497 | + $wpdb->query("TRUNCATE {$wpdb->prefix}woocommerce_sessions"); |
|
498 | + $result = absint($wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key='_woocommerce_persistent_cart_" . get_current_blog_id() . "';")); // WPCS: unprepared SQL ok. |
|
499 | 499 | wp_cache_flush(); |
500 | 500 | /* translators: %d: amount of sessions */ |
501 | - $message = sprintf( __( 'Deleted all active sessions, and %d saved carts.', 'woocommerce' ), absint( $result ) ); |
|
501 | + $message = sprintf(__('Deleted all active sessions, and %d saved carts.', 'woocommerce'), absint($result)); |
|
502 | 502 | break; |
503 | 503 | |
504 | 504 | case 'install_pages': |
505 | 505 | \WC_Install::create_pages(); |
506 | - $message = __( 'All missing WooCommerce pages successfully installed', 'woocommerce' ); |
|
506 | + $message = __('All missing WooCommerce pages successfully installed', 'woocommerce'); |
|
507 | 507 | break; |
508 | 508 | |
509 | 509 | case 'delete_taxes': |
510 | - $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rates;" ); |
|
511 | - $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rate_locations;" ); |
|
512 | - \WC_Cache_Helper::incr_cache_prefix( 'taxes' ); |
|
513 | - $message = __( 'Tax rates successfully deleted', 'woocommerce' ); |
|
510 | + $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rates;"); |
|
511 | + $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rate_locations;"); |
|
512 | + \WC_Cache_Helper::incr_cache_prefix('taxes'); |
|
513 | + $message = __('Tax rates successfully deleted', 'woocommerce'); |
|
514 | 514 | break; |
515 | 515 | |
516 | 516 | case 'regenerate_thumbnails': |
517 | 517 | \WC_Regenerate_Images::queue_image_regeneration(); |
518 | - $message = __( 'Thumbnail regeneration has been scheduled to run in the background.', 'woocommerce' ); |
|
518 | + $message = __('Thumbnail regeneration has been scheduled to run in the background.', 'woocommerce'); |
|
519 | 519 | break; |
520 | 520 | |
521 | 521 | case 'db_update_routine': |
522 | 522 | $blog_id = get_current_blog_id(); |
523 | 523 | // Used to fire an action added in WP_Background_Process::_construct() that calls WP_Background_Process::handle_cron_healthcheck(). |
524 | 524 | // This method will make sure the database updates are executed even if cron is disabled. Nothing will happen if the updates are already running. |
525 | - do_action( 'wp_' . $blog_id . '_wc_updater_cron' ); |
|
526 | - $message = __( 'Database upgrade routine has been scheduled to run in the background.', 'woocommerce' ); |
|
525 | + do_action('wp_' . $blog_id . '_wc_updater_cron'); |
|
526 | + $message = __('Database upgrade routine has been scheduled to run in the background.', 'woocommerce'); |
|
527 | 527 | break; |
528 | 528 | |
529 | 529 | default: |
530 | 530 | $tools = $this->get_tools(); |
531 | - if ( isset( $tools[ $tool ]['callback'] ) ) { |
|
532 | - $callback = $tools[ $tool ]['callback']; |
|
533 | - $return = call_user_func( $callback ); |
|
534 | - if ( is_string( $return ) ) { |
|
531 | + if (isset($tools[$tool]['callback'])) { |
|
532 | + $callback = $tools[$tool]['callback']; |
|
533 | + $return = call_user_func($callback); |
|
534 | + if (is_string($return)) { |
|
535 | 535 | $message = $return; |
536 | - } elseif ( false === $return ) { |
|
537 | - $callback_string = is_array( $callback ) ? get_class( $callback[0] ) . '::' . $callback[1] : $callback; |
|
536 | + } elseif (false === $return) { |
|
537 | + $callback_string = is_array($callback) ? get_class($callback[0]) . '::' . $callback[1] : $callback; |
|
538 | 538 | $ran = false; |
539 | 539 | /* translators: %s: callback string */ |
540 | - $message = sprintf( __( 'There was an error calling %s', 'woocommerce' ), $callback_string ); |
|
540 | + $message = sprintf(__('There was an error calling %s', 'woocommerce'), $callback_string); |
|
541 | 541 | } else { |
542 | - $message = __( 'Tool ran.', 'woocommerce' ); |
|
542 | + $message = __('Tool ran.', 'woocommerce'); |
|
543 | 543 | } |
544 | 544 | } else { |
545 | 545 | $ran = false; |
546 | - $message = __( 'There was an error calling this tool. There is no callback present.', 'woocommerce' ); |
|
546 | + $message = __('There was an error calling this tool. There is no callback present.', 'woocommerce'); |
|
547 | 547 | } |
548 | 548 | break; |
549 | 549 | } |