根据注册到路径的详细信息清理请求参数。

原型

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

参数

$value (mixed) (Required)

$request (WP_REST_Request) (Required)

$param (string) (Required)

返回值

(mixed)  

源文件

路径:wp-includes/rest-api.php

<?php
...
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 );
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/rest_sanitize_request_arg/