Still having to add tweeks to functions.php after upgrade
-
After every update to my WordPress Install, I have to add code to my functions.php so that the Site Health works. This includes the auto-update being broken. This code fixes the problem, obviously related to cURL errors. These have been persistent for years and years. Isn’t it time this was fixed. It’s such a small tweak.
This actually fixes it. Just add it all to the end of the functions.php file in wp-content.// Setting a custom timeout value for cURL. Using a high value for priority to ensure the function runs after any other added to the same action hook.
add_action(‘http_api_curl’, ‘sar_custom_curl_timeout’, 9999, 1);
function sar_custom_curl_timeout( $handle ){
curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 30 ); // 30 seconds. Too much for production, only for testing.
curl_setopt( $handle, CURLOPT_TIMEOUT, 30 ); // 30 seconds. Too much for production, only for testing.
}// Setting custom timeout for the HTTP request
add_filter( ‘http_request_timeout’, ‘sar_custom_http_request_timeout’, 9999 );
function sar_custom_http_request_timeout( $timeout_value ) {
return 30; // 30 seconds. Too much for production, only for testing.
}// Setting custom timeout in HTTP request args
add_filter(‘http_request_args’, ‘sar_custom_http_request_args’, 9999, 1);
function sar_custom_http_request_args( $r ){
$r[‘timeout’] = 30; // 30 seconds. Too much for production, only for testing.
return $r;
}`
- The topic ‘Still having to add tweeks to functions.php after upgrade’ is closed to new replies.