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/Scoped_Proxy_Behavior.php +13 -0 1.10.31.10.18 View file →
@@ -6,8 +6,9 @@
6 6 */
7 7
8 8 namespace WCPOS\WooCommercePOS\API\V2\Proxy;
9 9
10 +use WCPOS\WooCommercePOS\Services\Permission_Rules;
10 11 use WP_REST_Request;
11 12
12 13 /**
13 14 * Gives every resource the same install/run/finally/unwind discipline.
@@ -12,8 +13,14 @@
12 13 /**
13 14 * Gives every resource the same install/run/finally/unwind discipline.
14 15 */
15 16 abstract class Scoped_Proxy_Behavior implements Proxy_Behavior {
17 + /** Permission collection, when this resource has a POS-tier read grant.
18 + *
19 + * @var string|null
20 + */
21 + protected $permission_collection;
22 +
16 23 /**
17 24 * Forward every param untouched.
18 25 *
19 26 * @param array $params Query parameters to forward.
@@ -33,12 +40,18 @@
33 40 * @return mixed
34 41 */
35 42 public function around( callable $forward ) {
36 43 $bindings = $this->install();
44 + if ( $this->permission_collection ) {
45 + Permission_Rules::install_wc_filter( $this->permission_collection );
46 + }
37 47
38 48 try {
39 49 return $this->run( $forward );
40 50 } finally {
51 + if ( $this->permission_collection ) {
52 + Permission_Rules::uninstall_wc_filter();
53 + }
41 54 foreach ( array_reverse( $bindings ) as $binding ) {
42 55 remove_filter( $binding[0], $binding[1], $binding[2] );
43 56 }
44 57 }