class-wcs-auth.php
1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* WooCommerce Auth
*
* Handles wc-auth endpoint requests
*
* @author Prospress
* @category API
* @since 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class WCS_Auth {
/**
* Setup class
*
* @since 2.0.0
*/
public function __construct() {
add_filter( 'woocommerce_api_permissions_in_scope', array( $this, 'get_permissions_in_scope' ), 10, 2 );
}
/**
* Return a list of permissions a scope allows
*
* @param array $permissions
* @param string $scope
* @since 2.0.0
* @return array
*/
public function get_permissions_in_scope( $permissions, $scope ) {
switch ( $scope ) {
case 'read' :
$permissions[] = __( 'View subscriptions', 'woocommerce-subscriptions' );
break;
case 'write' :
$permissions[] = __( 'Create subscriptions', 'woocommerce-subscriptions' );
break;
case 'read_write' :
$permissions[] = __( 'View and manage subscriptions', 'woocommerce-subscriptions' );
break;
}
return $permissions;
}
}
return new WCS_Auth();