| Total Complexity | 3 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | class ResetSecurity implements Initializable |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * Initialize module (perform any tasks that should be done init hook). |
||
| 18 | */ |
||
| 19 | public function init() |
||
| 20 | { |
||
| 21 | // Disable REST API methods to anonymous users |
||
| 22 | add_filter('rest_authentication_errors', [$this, 'requireAuthForRestAccess']); |
||
|
|
|||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Return an authentication error if a user who is not logged in tries to query the REST API. |
||
| 27 | * |
||
| 28 | * @param mixed $access |
||
| 29 | * |
||
| 30 | * @return WP_Error |
||
| 31 | */ |
||
| 32 | public function requireAuthForRestAccess($access) |
||
| 43 | } |
||
| 44 | } |
||
| 45 |