On this page
rest_sanitize_request_arg( mixed $value, WP_REST_Request $request, string $param ): mixed
Sanitize a request argument based on details registered to the route.
Parameters
$valuemixed Required$requestWP_REST_Request Required$paramstring Required
Return
mixed
Source
File: wp-includes/rest-api.php. View all references
function rest_sanitize_request_arg( $value, $request, $param ) {
$attributes = $request->get_attributes();
if ( ! isset( $attributes['args'][ $param ] ) || ! is_array( $attributes['args'][ $param ] ) ) {
return $value;
}
$args = $attributes['args'][ $param ];
return rest_sanitize_value_from_schema( $value, $args, $param );
}
Related
Uses
| Uses | Description |
|---|---|
| rest_sanitize_value_from_schema() wp-includes/rest-api.php | Sanitize a value based on a schema. |
Used By
| Used By | Description |
|---|---|
| WP_REST_Menus_Controller::get_item_schema() wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php | Retrieves the term’s schema, conforming to JSON Schema. |
| rest_parse_request_arg() wp-includes/rest-api.php | Parse a request argument based on details registered to the route. |
Changelog
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/rest_sanitize_request_arg