rest_parse_request_arg
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 (3)
- 0. $value (mixed)
- The value.
- 1. $request (WP_REST_Request)
- The request.
- 2. $param (string)
- The param.
Usage
if ( !function_exists( 'rest_parse_request_arg' ) ) { require_once ABSPATH . WPINC . '/rest-api.php'; } // The value. $value = null; // The request. $request = null; // The param. $param = ''; // NOTICE! Understand what this does before running. $result = rest_parse_request_arg($value, $request, $param);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/rest-api.php
- 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;
- }