rest_parse_request_arg

Parse a request argument based on details registered to the route.

Description

rest_parse_request_arg( (mixed) $value, (WP_REST_Request) $request, (string) $param ); 

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

  1. if ( !function_exists( 'rest_parse_request_arg' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/vendor/wp-rest-functions.php'; 
  3.  
  4. // The value. 
  5. $value = null; 
  6.  
  7. // The request. 
  8. $request = null; 
  9.  
  10. // The param. 
  11. $param = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = rest_parse_request_arg($value, $request, $param); 
  15.  

Defined (1)

The function is defined in the following location(s).

/includes/vendor/wp-rest-functions.php  
  1. function rest_parse_request_arg( $value, $request, $param ) { 
  2.  
  3. $is_valid = rest_validate_request_arg( $value, $request, $param ); 
  4.  
  5. if ( is_wp_error( $is_valid ) ) { 
  6. return $is_valid; 
  7.  
  8. $value = rest_sanitize_request_arg( $value, $request, $param ); 
  9.  
  10. return $value;