PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.18
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.18
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
← All changes | includes/API/V2/Proxy/Coupons_Proxy_Behavior.php +6 -9 1.10.131.10.18 View file →
@@ -10,8 +10,14 @@
10 10 /**
11 11 * Relaxes WooCommerce coupon read permission only during the forward.
12 12 */
13 13 final class Coupons_Proxy_Behavior extends Scoped_Proxy_Behavior {
14 + /** POS read grant for this collection only.
15 + *
16 + * @var string
17 + */
18 + protected $permission_collection = 'coupons';
19 +
14 20 /**
15 21 * Install this resource's hooks and return their removal tuples.
16 22 *
17 23 * @return array<int, array{0: string, 1: callable, 2: int}>
@@ -16,17 +22,9 @@
16 22 *
17 23 * @return array<int, array{0: string, 1: callable, 2: int}>
18 24 */
19 25 protected function install(): array {
20 - $filter = static function ( $permission, $context, $object_id, $post_type ) {
21 - if ( ! $permission && 'shop_coupon' === $post_type && 'read' === $context ) {
22 - $permission = current_user_can( 'access_woocommerce_pos' );
23 - }
24 26
25 - return $permission;
26 - };
27 - add_filter( 'woocommerce_rest_check_permissions', $filter, 10, 4 );
28 -
29 27 // Coupon date/modified sorts tie routinely (imports share timestamps);
30 28 // pin the id tiebreak so multi-page walks stay stable (see Stable_Sort).
31 29 $stable_sort = static function ( $args ) {
32 30 return Stable_Sort::with_post_id_tiebreak( (array) $args );
@@ -33,9 +31,8 @@
33 31 };
34 32 add_filter( 'woocommerce_rest_shop_coupon_object_query', $stable_sort );
35 33
36 34 return array(
37 - array( 'woocommerce_rest_check_permissions', $filter, 10 ),
38 35 array( 'woocommerce_rest_shop_coupon_object_query', $stable_sort, 10 ),
39 36 );
40 37 }
41 38 }