WordPress REST API Exposure Checker
Check URL
Remediation
Add the code below to your theme's function files
add_filter('rest_endpoints', function ($endpoints) {
if (!is_user_logged_in()) {
return [];
}
return $endpoints;
});
add_filter('rest_authentication_errors', function ($result) {
if (!is_user_logged_in()) {
return new WP_Error('rest_disabled', __('The REST API is restricted to logged-in users only.'), array('status' => 403));
}
return $result;
});
Or Download our plugin disable-rest-api-for-guests.zip