Skip to content

Instantly share code, notes, and snippets.

@mymizan
Last active November 23, 2020 07:54
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 mymizan/a5646991ebdeccd850593386adc6d554 to your computer and use it in GitHub Desktop.
Save mymizan/a5646991ebdeccd850593386adc6d554 to your computer and use it in GitHub Desktop.
Increase WordPress cURL timeout
<?php
/**
* Add in your functions.php or through a plugin like Code Snippet.
**/
add_filter('https_local_ssl_verify', '__return_true');
add_filter('https_ssl_verify', '__return_true');
add_action('http_api_curl', 'woonet_custom_curl_timeout', PHP_INT_MAX, 1);
function woonet_custom_curl_timeout( $handle ){
curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 120 );
curl_setopt( $handle, CURLOPT_TIMEOUT, 120 );
}
add_filter( 'http_request_timeout', 'woonet_custom_http_request_timeout', PHP_INT_MAX );
function woonet_custom_http_request_timeout( $timeout_value ) {
return 120;
}
add_filter('http_request_args', 'woonet_custom_http_request_args', PHP_INT_MAX, 1);
function woonet_custom_http_request_args( $r ){
$r['timeout'] = 120;
return $r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment