solutionweb

WordPress Common Errors and Solutions

Three methods to solve the problem of slow upgrading and updating WordPress

Method 1: WP-CLI
WP-CLI is an official WordPress command line tool. Without a browser, you can quickly install, update the theme, configure the site, search and replace almost all conceivable functions.

How to install WP-CLI is not explained here, please go to the official installation guide.

If you have installed WP-CLI, first get the address of the new installation package through the wp core check-update command, and then download it through your own way and put it on the server.

$ wp core check-update
+———+————-+—————————————————————–+
| version | update_type | package_url |
+———+————-+—————————————————————–+
| 4.9 | major | https://downloads.wordpress.org/release/zh_CN/wordpress-4.9.zip |
+———+————-+—————————————————————–+
Finally, execute the wp core update path/to/zip/file command to upgrade WordPress, and the output is similar to that you upgrade through a web page.

$ wp core update path/to/zip/file
Starting update …
Unzip the upgrade file. …

Cleaning up files …
No files found that need cleaned up.
Success: WordPress updated successfully.
During the installation process, the language pack may be downloaded automatically, but the language pack is small and has no impact. So you successfully upgraded WordPress~ ~

Method 2: Modify WordPress upgrade code.
Or we can modify the WordPress upgrade code logic, and if the downloaded file is an update package, point directly to the local file instead of downloading it remotely.

Edit the file/WP-admin/includes/class-WP-upgrader.php and search for $ download _ file = download _ URL ($ package); , make the following changes:

public function download_package( $package ) {

//If you want to know the original download address, you can uncomment the following line, and then update it in the background of the webpage.
// exit($package);

if ($package == ‘https://downloads.wordpress.org/release/zh_CN/wordpress-4.9.zip’) {
$download_file = ‘path/to/zip/file’;
} else {
$download_file = download_url($package);
}


}
Method 3: Use proxy server.
Open the wp-config.php file and add the following code at the bottom:

define(‘WP_PROXY_HOST’, ‘us.centos.bz’);
define(‘WP_PROXY_PORT’, ‘31281’);
* The sample proxy server comes from the network.

Back to top