Skip to content

Instantly share code, notes, and snippets.

@G3ronim0
Forked from sudar/wp-increase-timeout.php
Created February 9, 2016 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save G3ronim0/d480d42fa8d4e3038c45 to your computer and use it in GitHub Desktop.
Save G3ronim0/d480d42fa8d4e3038c45 to your computer and use it in GitHub Desktop.
Increase the curl timeout in WordPress
<?php
Copied from http://fatlabmusic.com/blog/2009/08/12/how-to-fix-wp-http-error-name-lookup-timed-out/
//adjustments to wp-includes/http.php timeout values to workaround slow server responses
add_filter('http_request_args', 'bal_http_request_args', 100, 1);
function bal_http_request_args($r) //called on line 237
{
$r['timeout'] = 15;
return $r;
}
add_action('http_api_curl', 'bal_http_api_curl', 100, 1);
function bal_http_api_curl($handle) //called on line 1315
{
curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 15 );
curl_setopt( $handle, CURLOPT_TIMEOUT, 15 );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment