rest_sanitize_request_arg( mixed $value, WP_REST_Request $request, string $param ): mixed

In this article

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

Parameters

$valuemixedrequired
$requestWP_REST_Requestrequired
$paramstringrequired

Return

mixed

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, $param );
}

Changelog

VersionDescription
4.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.