v4.0.0 - Improved Error Handling
- Feature: Non-validation errors during execution of the handler now return a 500 json error. Detailed error information will be included if the user has the permission of the class's
$errorPermissionproperty (default 'manage_options')
Breaking Change
The BaseRestController class now enforces a function signature via an abstract class method. Ensure your extended classes match the following (note the inclusion of WP_REST_Request $request in the handler signature):
use WP_REST_Request;
use EvoWpRestRegistration\BaseRestController;
defined('ABSPATH') or exit;
class MyEndpoint extends BaseRestController
{
protected $path = 'my-section/my-endpoint';
protected $methods = 'POST';
public function authorise()
{
return current_user_can('manage_options');
}
public function handler(WP_REST_Request $request)
{
// Do things
}
}