WordPress开发者和主题制作者的搜索引擎



rest_ensure_request ›

Since4.4.0
已弃用n/a
rest_ensure_request ( $request )
参数:
  • (array|string|WP_REST_Request) $request Request to check.
    Required: Yes
返回:
  • (WP_REST_Request) REST request instance.
定义在:
文档:
Change Log:
  • 5.3.0

Ensures request arguments are a request object (for consistency).



源码

function rest_ensure_request( $request ) {
	if ( $request instanceof WP_REST_Request ) {
		return $request;
	}

	if ( is_string( $request ) ) {
		return new WP_REST_Request( 'GET', $request );
	}

	return new WP_REST_Request( 'GET', '', $request );
}