A WordPress-centric search engine for devs and theme authors



rest_sanitize_request_arg ›

Since4.7.0
Deprecatedn/a
rest_sanitize_request_arg ( $value, $request, $param )
Parameters: (3)
  • (mixed) $value
    Required: Yes
  • (WP_REST_Request) $request
    Required: Yes
  • (string) $param
    Required: Yes
Returns:
  • (mixed)
Defined at:
Codex:

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



Source

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 );
}