A WordPress-centric search engine for devs and theme authors



rest_ensure_request ›

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

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



Source

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

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