rest_validate_request_arg() - WordPress 函数参考中文文档

返回介绍

rest_validate_request_arg()

发布于 2017-09-11 字数1835 浏览 894 评论 0

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

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


描述


参数

$value

(mixed)
(Required)

$request

(WP_REST_Request)
(Required)

$param

(string)
(Required)


返回值

(WP_Error|boolean)


源代码

File: wp-includes/rest-api.php

function rest_validate_request_arg( $value, $request, $param ) {
	$attributes = $request->get_attributes();
	if ( ! isset( $attributes['args'][ $param ] ) || ! is_array( $attributes['args'][ $param ] ) ) {
		return true;
	}
	$args = $attributes['args'][ $param ];

	return rest_validate_value_from_schema( $value, $args, $param );
}

更新日志

Version 描述
4.7.0 Introduced.

相关函数

Uses

  • wp-includes/rest-api.php:
    rest_validate_value_from_schema()

Used By

  • wp-includes/rest-api.php:
    rest_parse_request_arg()
  • wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:
    WP_REST_Posts_Controller::sanitize_post_statuses()
  • wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:
    WP_REST_Comments_Controller::check_comment_author_email()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!