rest_sanitize_request_arg()WP 4.7.0

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

No Hooks.

Return

Mixed.

Usage

rest_sanitize_request_arg( $value, $request, $param );
$value(mixed) (required)
-
$request(WP_REST_Request) (required)
-
$param(string) (required)
-

Changelog

Since 4.7.0 Introduced.

rest_sanitize_request_arg() code WP 6.6.2

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