PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.13.1
GiveWP – Donation Plugin and Fundraising Platform v2.13.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 2.31.1 All 253 releases
give / src / API / Endpoints / Migrations / Endpoint.php
Endpoint.php
46 lines 817 B
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 WP_Error;
7
8 /**
9 * Class Endpoint
10 * @package Give\API\Endpoints\Migrations
11 *
12 * @since 2.10.0
13 */
14 abstract class Endpoint implements RestRoute {
15
16 /**
17 * @var string
18 */
19 protected $endpoint;
20
21 /**
22 * Check user permissions
23 * @return bool|WP_Error
24 */
25 public function permissionsCheck() {
26 if ( ! current_user_can( 'manage_give_settings' ) ) {
27 return new WP_Error(
28 'rest_forbidden',
29 esc_html__( 'You dont have the right permissions to view Migrations', 'give' ),
30 [ 'status' => $this->authorizationStatusCode() ]
31 );
32 }
33
34 return true;
35 }
36
37 // Sets up the proper HTTP status code for authorization.
38 public function authorizationStatusCode() {
39 if ( is_user_logged_in() ) {
40 return 403;
41 }
42
43 return 401;
44 }
45 }
46