Last active
November 23, 2020 07:54
-
-
Save mymizan/a5646991ebdeccd850593386adc6d554 to your computer and use it in GitHub Desktop.
Increase WordPress cURL timeout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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