Chặn cập nhật WordPress

Để ngăn WordPress cập nhật tự động hoàn toàn (bao gồm cả core, plugin và theme), bạn cần thực hiện các bước sau:

1. Chặn cập nhật WordPress Core

Thay đổi dòng sau trong wp-config.php:

define( 'WP_AUTO_UPDATE_CORE', false );

Nếu dòng đó đang là true, hãy sửa thành false.

2. Chặn cập nhật tự động plugin và theme

Thêm vào wp-config.php:

define( 'AUTOMATIC_UPDATER_DISABLED', true );
define( 'DISALLOW_FILE_MODS', true );

Lưu ý: DISALLOW_FILE_MODS cũng sẽ vô hiệu hóa trình cập nhật trong giao diện admin, nên bạn sẽ không thể cập nhật thủ công qua WP Admin.

3. Chặn cập nhật qua functions.php (Ưu tiên dùng)

Nếu bạn chỉ muốn chặn cập nhật tự động nhưng vẫn có thể cập nhật thủ công, thêm đoạn này vào functions.php của theme:

add_filter( 'automatic_updater_disabled', '__return_true' );
add_filter( 'auto_update_plugin', '__return_false' );
add_filter( 'auto_update_theme', '__return_false' );
add_filter( 'auto_update_translation', '__return_false' );

4. Chặn kiểm tra cập nhật từ WordPress.org (Ưu tiên dùng)

Thêm vào functions.php:

remove_action( 'wp_version_check', 'wp_version_check' );
remove_action( 'admin_init', '_maybe_update_core' );
remove_action( 'admin_init', '_maybe_update_plugins' );
remove_action( 'admin_init', '_maybe_update_themes' );
add_filter( 'pre_site_transient_update_core', '__return_null' );
add_filter( 'pre_site_transient_update_plugins', '__return_null' );
add_filter( 'pre_site_transient_update_themes', '__return_null' );

Sau khi thực hiện các bước trên, WordPress sẽ hoàn toàn ngừng cập nhật tự động. 🚀