WP_REST_View_Config_Controller::get_items_permissions_check
Checks if a given request has access to read view config.
Method of the class: WP_REST_View_Config_Controller{}
No Hooks.
Returns
true|WP_Error. True if the request has read access, WP_Error object otherwise.
Usage
$WP_REST_View_Config_Controller = new WP_REST_View_Config_Controller(); $WP_REST_View_Config_Controller->get_items_permissions_check( $request );
- $request(WP_REST_Request) (required)
- Full details about the request.
Changelog
| Since 7.1.0 | Introduced. |
WP_REST_View_Config_Controller::get_items_permissions_check() WP REST View Config Controller::get items permissions check code WP 7.1
public function get_items_permissions_check( $request ) {
$kind = $request->get_param( 'kind' );
$name = $request->get_param( 'name' );
$capability = $this->get_required_capability( $kind, $name );
if ( null === $capability ) {
return new WP_Error(
'rest_view_config_invalid_entity',
__( 'Invalid entity kind or name.' ),
array( 'status' => 404 )
);
}
if ( ! current_user_can( $capability ) ) {
return new WP_Error(
'rest_cannot_read',
__( 'Sorry, you are not allowed to read view config.' ),
array( 'status' => rest_authorization_required_code() )
);
}
return true;
}