wpseek.com
A WordPress-centric search engine for devs and theme authors



rest_ensure_request › WordPress Function

Since4.4.0
Deprecatedn/a
rest_ensure_request ( $request )
Parameters:
  • (array|string|WP_REST_Request) $request Request to check.
    Required: Yes
Returns:
  • (WP_REST_Request) REST request instance.
Defined at:
Codex:
Change Log:
  • 5.3.0

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



Source

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 );
}