wp_safe_remote_request()
Retrieve the raw response from a safe HTTP request.
This function is ideal when the HTTP request is being made to an arbitrary URL. The URL is validated to avoid redirection and request forgery attacks.
Uses: _wp_http_get_object()
No Hooks.
Return
Array|WP_Error
. The response or WP_Error on failure.
Usage
wp_safe_remote_request( $url, $args );
- $url(string) (required)
- URL to retrieve.
- $args(array)
- Request arguments.
Default: empty array
Notes
- See: wp_remote_request() For more information on the response array format.
- See: WP_Http::request() For default arguments information.
Changelog
Since 3.6.0 | Introduced. |
Code of wp_safe_remote_request() wp safe remote request WP 5.9.3
function wp_safe_remote_request( $url, $args = array() ) { $args['reject_unsafe_urls'] = true; $http = _wp_http_get_object(); return $http->request( $url, $args ); }