2026年5月20日
2026年5月20日
WordPressで特定プラグインだけ自動更新を無効にする方法
はじめに
WordPressのプラグイン自動更新は便利ですが、カスタマイズしたプラグインや互換性を慎重に確認したいプラグインは自動更新を無効にしたい場合があります。特定プラグインだけ自動更新を制御する方法を解説します。
症状・原因
- 自動更新でカスタマイズが上書きされたくない
- WooCommerceなど重要プラグインは手動で確認してから更新したい
- 一部プラグインだけ自動更新を有効にして他は無効にしたい
- 自動更新の設定をコードで管理したい
解決手順
ステップ1:管理画面から自動更新を制御する
プラグイン → インストール済みプラグイン:
→ 各プラグインの「自動更新を有効化」リンクをクリック
→ または「自動更新を無効化」でOFF
一括設定:
→ プラグインをチェックボックスで複数選択
→「一括操作」→「自動更新を有効化/無効化」
→「適用」
ステップ2:フィルターで特定プラグインの自動更新を無効化する
// functions.php — 特定プラグインの自動更新を無効化
add_filter('auto_update_plugin', function(bool $update, object $item): bool {
// 自動更新を無効にしたいプラグインのスラッグ
$disabled = [
'woocommerce/woocommerce.php',
'elementor/elementor.php',
'advanced-custom-fields/acf.php',
];
if (in_array($item->plugin, $disabled, true)) {
return false; // 自動更新を無効化
}
return $update; // その他は元の設定に従う
}, 10, 2);
ステップ3:全プラグインの自動更新を無効化する
// functions.php — 全プラグインの自動更新を完全無効化
add_filter('auto_update_plugin', '__return_false');
// または wp-config.php で定数を定義
define('AUTOMATIC_UPDATER_DISABLED', true); // コア・プラグイン・テーマ全て無効
// プラグインのみ無効化(コアは自動更新を維持)
add_filter('auto_update_plugin', '__return_false');
add_filter('auto_update_theme', '__return_false');
// コアのセキュリティアップデートは維持
add_filter('allow_minor_auto_core_updates', '__return_true');
ステップ4:WP-CLIで自動更新を管理する
# プラグインの自動更新状態を確認
wp plugin auto-updates status --all
# 特定プラグインの自動更新を無効化
wp plugin auto-updates disable woocommerce
wp plugin auto-updates disable elementor
# 特定プラグインの自動更新を有効化
wp plugin auto-updates enable wordfence
# 全プラグインの自動更新を無効化
wp plugin auto-updates disable --all
# 全プラグインの自動更新を有効化
wp plugin auto-updates enable --all
# 現在の自動更新設定をJSONで確認
wp option get auto_update_plugins --format=json
ステップ5:自動更新メール通知を設定する
// functions.php — 自動更新の完了メールを無効化
add_filter('auto_plugin_update_send_email', '__return_false');
// 自動更新メールの宛先を変更
add_filter('auto_plugin_update_send_email', '__return_true');
add_filter('update_email_addresses', function(array $emails): array {
return ['admin@example.com', 'dev@example.com'];
});
// 自動更新後にSlack通知を送る
add_action('automatic_updates_complete', function(array $results) {
if (empty($results['plugin'])) {
return;
}
$updated = array_column($results['plugin'], 'name');
$message = '自動更新完了: ' . implode(', ', $updated);
wp_remote_post('https://hooks.slack.com/services/YOUR/WEBHOOK', [
'body' => json_encode(['text' => $message]),
'headers' => ['Content-Type' => 'application/json'],
]);
});
ステップ6:更新前後のバックアップと確認
# 自動更新が実行される前にバックアップ
# wp-config.php に追加してバックアップ後に更新
add_filter('upgrader_pre_install', function($response, $hook_extra) {
// バックアップ処理(UpdraftPlusやManageWPと連携)
return $response;
}, 10, 2);
# 手動で安全に全プラグインを更新
wp plugin update --all --dry-run # 何が更新されるか事前確認
wp plugin update --all # 本番更新
wp cache flush # キャッシュクリア
注意事項
AUTOMATIC_UPDATER_DISABLEDをtrueにするとセキュリティアップデートも止まります。コアのセキュリティ更新はallow_minor_auto_core_updatesで維持することを推奨します- 自動更新を無効にしたプラグインは定期的に手動で更新してください
- WP-CLIの
wp plugin auto-updates disableで設定した内容はwp_auto_update_pluginsオプションに保存されます
まとめ
特定プラグインだけ自動更新を無効にするには auto_update_plugin フィルターで対象スラッグを除外します。WP-CLIでは wp plugin auto-updates disable woocommerce で即座に設定でき、wp option get auto_update_plugins で現在の設定を確認できます。