禁用 WordPress 核心版本 禁用所有主題 更新檢查與提示
// 1. 禁用 WordPress 核心版本更新檢查與提示
add_filter( 'pre_site_transient_update_core', '__return_null' );
remove_action( 'admin_notices', 'update_nag', 3 );
// 2. 禁用所有主題更新檢查
add_filter( 'pre_site_transient_update_themes', '__return_null' );
// 3. 禁用插件更新檢查 (如果也需要的話,可視情況保留)
// add_filter( 'pre_site_transient_update_plugins', '__return_null' );
在 WPCode(或 WPCode Lite)中添加這些代碼非常方便,因為你不需要手動修改 functions.php 文件,且更換主題時代碼依然有效。
請按照以下步驟操作:
步驟 1:新建代碼片段
進入 WordPress 後台,點擊左側選單的 Code Snippets -> + Add Snippet。
選擇 Add Your Custom Code (New Snippet)。
步驟 2:輸入禁用代碼
將 Code Type 下拉選單切換為 PHP Snippet,然後貼入以下代碼(這會同時禁用核心與主題更新提示):
php
// 1. 禁用 WordPress 核心版本更新檢查與提示
add_filter( 'pre_site_transient_update_core', '__return_null' );
remove_action( 'admin_notices', 'update_nag', 3 );
// 2. 禁用所有主題更新檢查
add_filter( 'pre_site_transient_update_themes', '__return_null' );
// 3. 禁用插件更新檢查 (如果也需要的話,可視情況保留)
// add_filter( 'pre_site_transient_update_plugins', '__return_null' );
請謹慎使用程式碼。
步驟 3:設置與啟用
Insertion (插入方式):保持默認的 Run Everywhere (全域運行)。
效果確認:將右上角的開關切換為 Active (啟用),然後點擊 Save Snippet。
⚠️ 特別注意
wp-config.php 代碼無法在這裡使用:WPCode 只能運行 PHP 邏輯,無法修改 wp-config.php 中的 define 常量。如果你之前想用 define( 'AUTOMATIC_UPDATER_DISABLED', true );,這必須透過 FTP 或主機文件管理器手動修改文件。
緩存延遲:儲存後,建議到「儀表板」->「更新」點擊一下「重新檢查」,原本的更新提示就會消失。
你需要我也提供禁用特定某個插件更新的代碼嗎?
Warning: Attempt to read property "current" on bool in /Users/mac/Local Sites/site/app/public/wp-admin/update-core.php on line 41
Warning: Attempt to read property "locale" on bool in /Users/mac/Local Sites/site/app/public/wp-admin/update-core.php on line 43
Warning: Attempt to read property "locale" on bool in /Users/mac/Local Sites/site/app/public/wp-admin/update-core.php on line 45
Warning: Attempt to read property "locale" on bool in /Users/mac/Local Sites/site/app/public/wp-admin/update-core.php on line 51
Warning: Attempt to read property "current" on bool in /Users/mac/Local Sites/site/app/public/wp-admin/update-core.php on line 67
Warning: Attempt to read property "response" on bool in /Users/mac/Local Sites/site/app/public/wp-admin/update-core.php on line 77