rest_ensure_request

函数


rest_ensure_request ( $request )
参数
  • (array|string|WP_REST_Request)
    $request
    Request to check.
    Required:
返回值
  • (WP_REST_Request) REST request instance.
定义位置
  • wp-includes/rest-api.php
    , line 592
引入
4.4.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 );
}