Completely turn off WordPress automatic update and update check functions, improve background running speed, and optimize wordpress performance

One year ago (2023-11-27) Chief Editor
6 minutes
three hundred and three
zero

WordPress supports the automatic checking of WordPress core code, plug-ins and theme versions in the background, and supports automatic updating. This is a great function, which enables WordPress sites to keep the latest version, especially when there are security vulnerabilities.

Problems with WordPress automatic update

However, this has also caused some other problems:

1. The update server of WordPress is abroad, and the acceleration service has not been started in China, so when WordPress checks for updates in the background, it may not be connected smoothly for various reasons, and then it is stuck all the time, causing the WordPress background to be very slow sometimes.

2. Automatic update is a good thing, but some plug-ins or themes change too much, causing background crash, which is not a good thing, especially if the production environment collapses, which is not a good thing. Therefore, for some sensitive systems, it is better to upgrade on the test server and test them before upgrading on the official production server.

To sum up, it is better to turn off the automatic update function of WordPress on the official server, and then update to the official server after upgrading and updating on the test server Ensure stable service , can also Make WordPress run faster in the background

Turn off automatic update and update check

How to turn off WordPress automatic update and background update check?

First, WordPress provides a constant: AUTOMATIC_UPDATER_DISABLED , on wp-config.php If this value is set to false in the file, the custom update function can be turned off.

If you don't want to change wp-config.php WordPress also provides a automatic_updater_disabled Interface, through which you can also turn off automatic updates:

add_filter ( automatic_updater_disabled , __return_true );

However, if you have access to the background, WordPress will regularly detect whether the WordPress core, plug-ins and themes have been updated. This function is achieved through timed jobs, which include three timed jobs:

wp_version_check : Check whether the WordPress core code is the latest version. wp_update_plugins : Check whether the WordPress plug-in is the latest version. wp_update_themes : Check whether the WordPress theme is the latest version.

These three scheduled jobs are run every two days. No matter whether you visit the background or not, they will run to check whether your site needs to be updated. We can close the regular update check job through the following code:

remove_action ( init , wp_schedule_update_checks );
wp_clear_scheduled_hook ( wp_version_check );
wp_clear_scheduled_hook ( wp_update_plugins );
wp_clear_scheduled_hook ( wp_update_themes );

In addition to regular jobs, if you visit the WordPress background, WordPress will check whether the WordPress core, plug-ins and themes are updated every 12 hours. This is the reason why WordPress is sometimes very slow. Many people think that WordPress is very slow because they have not visited the background of WordPress for a long time. As soon as they visit WordPress, they first check for updates, so it seems very slow. It is obvious that because you visit it, they will check every 12 hours.

Therefore, the function of detecting updates every 12 hours should be turned off, which is the key to speed up in the background:

remove_action ( admin_init , _maybe_update_core );
remove_action ( admin_init , _maybe_update_plugins );
remove_action ( admin_init , _maybe_update_themes );

After we block it like this, will WordPress updates not be available in the background? No, when we enter the WordPress background plug-in management page, theme management interface, and the update sub page under the dashboard, whenever we enter these three interfaces, WordPress will detect whether there is a new version.

Of course, you can also remove the function of detecting updates when you enter these pages, but I don't think it is necessary to enter specific pages to do specific corresponding things. I think it is completely OK, so there is no relevant code here.

These codes can be added to the functions.php File can also be directly checked in the WPJAM Basic plug-in to block the automatic update function.

After this process, if there is an update, it needs to be updated manually. It is recommended to use SSH to install, upgrade and migrate the WordPress blog.

The function of blocking WordPress automatic update and update check has been integrated into the WPJAM Basic plug-in, and has been provided for free download. Click to read the original text.

This article is written by: Chief Editor Published on Software Development of Little Turkey , please indicate the source for reprinting: //hongchengtech.cn/blog/749.html
Kuke_WP editor
author

Related recommendations

One year ago (2023-11-27)

12 WordPress enterprise theme templates are recommended! WordPress can be built without writing code!, Wordpress setup

When many companies choose WordPress to build their websites, they often don't know which theme is easy to use. There are too many WordPress corporate themes in the market for everyone to choose, but they always hesitate to make a decision. Here we have carefully sorted out 12 WordPress corporate themes, covering all walks of life
four hundred and forty-eight
zero
One year ago (2023-11-27)

Inventory of WordPress themes on online course website (updated in 2020), free WordPress themes

To build an online education platform using the WordPress website building program, it is not only necessary to choose a better virtual host provider, but also the most important thing is to use a core online course plug-in, and a powerful WordPress theme can also improve students' learning experience. Learn more about WordPre
four hundred and forty-eight
zero
One year ago (2023-11-27)

Count the domestic excellent WordPress themes and wordpress excellent themes

WordPress originates from abroad, is easy to use, and is very popular, making more and more websites in China start to use WordPress website building programs. There are also many powerful experts or teams in China who have developed WordPress Chinese themes. This article details the outstanding WordPress themes in China. I Begin Theme
six hundred and thirty-eight
zero
One year ago (2023-11-27)

Best WordPress theme list in 2022 (free and paid), Wordpress resource network theme

When building a WordPress website, should you use a free theme or an advanced theme? What types of functions do you need, and how advanced do you want your website to be? These are all good questions. You need to explain before you spend money on WordPress topics. This is why we need to know all the details of the selected theme, and cover the topics from several
three hundred and ninety-five
zero

comment

0 people have participated in the review

Scan code to add WeChat

contact us

WeChat: Kuzhuti
Online consultation: