PluginProbe
Passster – Password Protect Pages and Content / 4.3.14
Passster – Password Protect Pages and Content v4.3.14
4.3.16 4.3.15 4.3.14 4.3.12 4.3.13 4.3.11 4.3.10 4.3.9 4.3.8 4.3.7 4.3.6 4.3.5 trunk 3.5.4 3.5.5.2 3.5.5.8 3.5.5.9 4.0 4.1.4 4.2.10 4.2.11 4.2.12 4.2.13 4.2.14 4.2.15 All 48 releases
content-protector / inc / class-ps-protected-areas-rest-controller.php

class-ps-protected-areas-rest-controller.php in Passster – Password Protect Pages and Content 4.3.14, at inc/class-ps-protected-areas-rest-controller.php

40 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace passster;
4
5 /**
6 * REST controller for the "protected_areas" post type.
7 *
8 * WordPress' default WP_REST_Posts_Controller ignores a post type's
9 * public/publicly_queryable flags when deciding read access — it only
10 * checks show_in_rest and post status — so with the default controller
11 * anyone could read every area's protected content via /wp/v2/protected_areas.
12 * These routes exist only so the block editor (logged-in admins) can
13 * read/write areas; visitors unlock areas exclusively through the
14 * password-gated passster/v1 routes.
15 */
16 class PS_Protected_Areas_Rest_Controller extends \WP_REST_Posts_Controller {
17
18 /**
19 * Checks if a given request has access to read protected areas.
20 *
21 * @param \WP_REST_Request $request Full details about the request.
22 *
23 * @return bool
24 */
25 public function get_items_permissions_check( $request ) {
26 return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
27 }
28
29 /**
30 * Checks if a given request has access to read a single protected area.
31 *
32 * @param \WP_REST_Request $request Full details about the request.
33 *
34 * @return bool
35 */
36 public function get_item_permissions_check( $request ) {
37 return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
38 }
39 }
40