在自动升级WordPress核心以及WordPress插件或主题的时候,比如avada,the7,betheme等国外主题。
往往会因为网络原因导致下载核心或插件的时候超时,从而导致升级失败,此时WordPress会给出如下提示:
cURL error 28: Operation timed out after 300005 milliseconds with 48782 out of 5279786 bytes received.
Operation timed out after 30 seconds with ......
从提示中我们可以看到WordPress默认给出的超时时限是30秒,我们可以将这个值修改的大一些,使得即使在网速不佳的情况下也可以完成下载。
打开 wp-admin\includes\file.php
查找如下语句
1 | $response = wp_remote_get($url, array('timeout' => 30)); |
将其中的30改大,如改成300:
1 | $response = wp_remote_get($url, array('timeout' => 300)); |
保存即可。
新版(4.9以上)
//Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default.
if ( ! defined('FS_CONNECT_TIMEOUT') )
define('FS_CONNECT_TIMEOUT', 30);
if ( ! defined('FS_TIMEOUT') )
define('FS_TIMEOUT', 30);