PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.19.6
GiveWP – Donation Plugin and Fundraising Platform v2.19.6
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 2.31.1 All 253 releases
give / src / DonationForms / Endpoints / Endpoint.php
Endpoint.php
56 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\DonationForms\Endpoints;
4
5 use Give\API\RestRoute;
6 use WP_Error;
7
8 /**
9 * @since 2.19.0
10 */
11 abstract class Endpoint implements RestRoute
12 {
13
14 /**
15 * @var string
16 */
17 protected $endpoint;
18
19 /**
20 * @param string $value
21 *
22 * @return bool
23 */
24 public function validateInt($value)
25 {
26 return filter_var($value, FILTER_VALIDATE_INT);
27 }
28
29 /**
30 * Check user permissions
31 * @return bool|WP_Error
32 */
33 public function permissionsCheck()
34 {
35 if ( ! current_user_can('edit_posts')) {
36 return new WP_Error(
37 'rest_forbidden',
38 esc_html__('You dont have the right permissions to view Donation Forms', 'give'),
39 ['status' => $this->authorizationStatusCode()]
40 );
41 }
42
43 return true;
44 }
45
46 // Sets up the proper HTTP status code for authorization.
47 public function authorizationStatusCode()
48 {
49 if (is_user_logged_in()) {
50 return 403;
51 }
52
53 return 401;
54 }
55 }
56