$api_url_part =
substr( $url,
strlen( untrailingslashit( $api_root ) ) );
$route =
parse_url( $api_url_part, PHP_URL_PATH
);
} elseif ( !
empty( $query_params['rest_route'
] ) ) { // ?rest_route=... set directly.
$route =
$query_params['rest_route'
];
unset( $query_params['rest_route'
] );
} $request = false;
if ( !
empty( $route ) ) { $request =
new WP_REST_Request( 'GET',
$route );
$request->
set_query_params( $query_params );
} /**
* Filters the REST API request generated from a URL.
*
* @since 4.5.0
*
* @param WP_REST_Request|false $request Generated request object, or false if URL
* could not be parsed.
* @param string $url URL the request was generated from.
*/