On this page
rest_parse_request_arg( mixed $value, WP_REST_Request $request, string $param ): mixed
Parse a request argument based on details registered to the route.
Description
Runs a validation check and sanitizes the value, primarily to be used via the sanitize_callback arguments in the endpoint args registration.
Parameters
$valuemixed Required$requestWP_REST_Request Required$paramstring Required
Return
mixed
Source
File: wp-includes/rest-api.php. View all references
function rest_parse_request_arg( $value, $request, $param ) {
$is_valid = rest_validate_request_arg( $value, $request, $param );
if ( is_wp_error( $is_valid ) ) {
return $is_valid;
}
$value = rest_sanitize_request_arg( $value, $request, $param );
return $value;
}
Related
Uses
| Uses | Description |
|---|---|
| rest_validate_request_arg() wp-includes/rest-api.php | Validate a request argument based on details registered to the route. |
| rest_sanitize_request_arg() wp-includes/rest-api.php | Sanitize a request argument based on details registered to the route. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Used By
| Used By | Description |
|---|---|
| WP_REST_Search_Controller::sanitize_subtypes() wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php | Sanitizes the list of subtypes, to ensure only subtypes of the passed type are included. |
| WP_REST_Settings_Controller::sanitize_callback() wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php | Custom sanitize callback used for all options to allow the use of ‘null’. |
Changelog
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/rest_parse_request_arg