PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 All 254 releases
give / src / Subscriptions / Endpoints / Endpoint.php

Endpoint.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.8.1, at src/Subscriptions/Endpoints/Endpoint.php

61 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Subscriptions\Endpoints;
4
5 use Give\API\RestRoute;
6 use WP_Error;
7
8 abstract class Endpoint implements RestRoute
9 {
10 /**
11 * @var string
12 */
13 protected $endpoint;
14
15 /**
16 * @param string $value
17 * @since 2.20.0
18 *
19 * @return bool
20 */
21 public function validateInt($value)
22 {
23 return filter_var($value, FILTER_VALIDATE_INT);
24 }
25
26 /**
27 * Check user permissions
28 * @since 4.3.1 updates permissions
29 * @since 2.20.0
30 *
31 * @return bool|WP_Error
32 */
33 public function permissionsCheck()
34 {
35 if (current_user_can('manage_options') || current_user_can('edit_give_payments')) {
36 return true;
37 }
38
39 return new WP_Error(
40 'rest_forbidden',
41 __("You don't have permission to view Subscriptions", 'give'),
42 ['status' => is_user_logged_in() ? 403 : 401]
43 );
44 }
45
46 /**
47 * Sets up the proper HTTP status code for authorization.
48 * @since 2.20.0
49 *
50 * @return int
51 */
52 public function authorizationStatusCode()
53 {
54 if (is_user_logged_in()) {
55 return 403;
56 }
57
58 return 401;
59 }
60 }
61