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 / API / Endpoints / Migrations / Endpoint.php

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

51 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\API\Endpoints\Migrations;
4
5 use Give\API\RestRoute;
6 use Give\Framework\Permissions\Facades\UserPermissions;
7 use WP_Error;
8
9 /**
10 * Class Endpoint
11 * @package Give\API\Endpoints\Migrations
12 *
13 * @since 4.14.0 update permission capability to use facade
14 * @since 2.10.0
15 */
16 abstract class Endpoint implements RestRoute
17 {
18
19 /**
20 * @var string
21 */
22 protected $endpoint;
23
24 /**
25 * Check user permissions
26 * @return bool|WP_Error
27 */
28 public function permissionsCheck()
29 {
30 if ( ! UserPermissions::settings()->canManage()) {
31 return new WP_Error(
32 'rest_forbidden',
33 __('You don\'t have the right permissions to view Migrations', 'give'),
34 ['status' => $this->authorizationStatusCode()]
35 );
36 }
37
38 return true;
39 }
40
41 // Sets up the proper HTTP status code for authorization.
42 public function authorizationStatusCode()
43 {
44 if (is_user_logged_in()) {
45 return 403;
46 }
47
48 return 401;
49 }
50 }
51