W3cubDocs

/WordPress

rest_ensure_request( array|WP_REST_Request $request )

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

Description

Parameters

$request

(array|WP_REST_Request) (Required) Request to check.

Return

(WP_REST_Request) REST request instance.

Source

File: wp-includes/rest-api.php

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

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

Changelog

Version Description
4.4.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/rest_ensure_request