vip_safe_wp_remote_get

This is a sophisticated extended version of wp_remote_get().

It is designed to more gracefully handle failure than wpcom_vip_file_get_contents() does.

Note that like wp_remote_get(), this function does not cache.

Parameters

Name Type Description
$url string URL to fetch
$fallback_value string Optional. Set a fallback value to be returned if the external request fails.
$threshold int Optional. The number of fails required before subsequent requests automatically return the fallback value. Defaults to 3, with a maximum of 10.
$timeout int Optional. Number of seconds before the request times out. Valid values 1-3; defaults to 1.
$retry int Optional. Number of seconds before resetting the fail counter and the number of seconds to delay making new requests after the fail threshold is reached. Defaults to 20, with a minimum of 10.
Optional. array Set other arguments to be passed to wp_remote_get().

Return Value

string|WP_Error|array: Array of results. If fail counter is met, returns the $fallback_value, otherwise return WP_Error.

Ready to get started?

Drop us a note.

No matter where you are in the planning process, we’re happy to help, and we’re actual humans here on the other side of the form. 👋 We’re here to discuss your challenges and plans, evaluate your existing resources or a potential partner, or even make some initial recommendations. And, of course, we’re here to help any time you’re in the market for some robust WordPress awesomeness.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.