Sanitizes and validates the list of statuses.
Description
See also
Parameters
- $statuses
-
(string|array) (Required) One or more statuses.
- $request
-
(WP_REST_Request) (Required) Full details about the request.
- $parameter
-
(string) (Required) Additional parameter to pass to validation.
Return
(array|WP_Error) A list of valid statuses, otherwise WP_Error object.
Source
File: src/db-objects/forms/rest-forms-controller.php
public function sanitize_status_param( $statuses, $request, $parameter ) { $statuses = wp_parse_slug_list( $statuses ); $attributes = $request->get_attributes(); $default_status = $attributes['args']['status']['default']; foreach ( $statuses as $status ) { if ( $status === $default_status ) { continue; } $post_type_obj = get_post_type_object( $this->manager->get_prefix() . 'form' ); if ( current_user_can( $post_type_obj->cap->edit_posts ) ) { $result = rest_validate_request_arg( $status, $request, $parameter ); if ( is_wp_error( $result ) ) { return $result; } } else { return new WP_Error( 'rest_forbidden_status', __( 'Status is forbidden.', 'torro-forms' ), array( 'status' => rest_authorization_required_code() ) ); } } return $statuses; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |