You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{"generator":"Code Snippets v2.13.2","date_created":"2019-02-01 18:45","snippets":[{"name":"Custom timeout values for HTTP requests in WordPress","desc":"https:\/\/www.samuelaguilera.com\/post\/curl-error-28-wordpress","tags":["custom","timeout","HTTPS","requests","curl","wordpress"],"scope":"admin","code":"\/\/ 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.\r\nadd_action('http_api_curl', 'sar_custom_curl_timeout', 9999, 1);\r\nfunction sar_custom_curl_timeout( $handle ){\r\n\tcurl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 15 );\r\n\tcurl_setopt( $handle, CURLOPT_TIMEOUT, 15 );\r\n}\r\n\/\/ Setting custom timeout for the HTTP request\r\nadd_filter( 'http_request_timeout', 'sar_custom_http_request_timeout', 9999 );\r\nfunction sar_custom_http_request_timeout( $timeout_value ) {\r\n\treturn 15;\r\n}\r\n\/\/ Setting custom timeout in HTTP request args\r\nadd_filter('http_request_args', 'sar_custom_http_request_args', 9999, 1);\r\nfunction sar_custom_http_request_args( $r ){\r\n\t$r['timeout'] = 15;\r\n\treturn $r;\r\n}"}]}