Welcome. You’ve reached the middle of this series. I plan to complete the rest shortly. Please leave a comment if you have anything you’d like me to cover.
The following will disable all update notification-related emails:
// Disable core update emails. We'll be sending our own.
add_filter( 'auto_core_update_send_email', '__return_false', 10 );
add_filter( 'send_core_update_notification_email', '__return_false', 10 );
add_filter( 'automatic_updates_send_debug_email', '__return_false', 10 );
add_filter( 'auto_theme_update_send_email', '__return_false', 10 );
add_filter( 'auto_plugin_update_send_email', '__return_false', 10 );
Code language: PHP (php)
Do you want to hide the automatic updates column on the plugins and themes area? This one will do the trick, albeit a bit hacky.
/**
* Remove the auto-update columns on the appropriate screens.
*/
class Remove_Auto_Update_Columns {
/**
* Class runner.
*/
public function __construct() {
add_action( 'current_screen', array( $this, 'maybe_remove_update_columns' ), 100 );
}
/**
* Force remove the auto-updates interface on certain screens.
*/
public function maybe_remove_update_columns() {
// Double-checking we're in the admin.
if ( ! is_admin() ) {
return;
}
// Skip on Ajax and Cron requests.
if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
return;
}
// Try to get the current screen.
$screen = get_current_screen();
if ( ! isset( $screen->id ) ) {
return;
}
// Force remove the auto-updates interface on certain screens.
// todo - get all the multisite screens.
switch ( $screen->id ) {
case 'site-themes-network':
case 'plugins':
case 'themes':
case 'site-health':
add_filter( 'plugins_auto_update_enabled', '__return_false' );
add_filter( 'themes_auto_update_enabled', '__return_false' );
break;
}
}
}
new Remove_Auto_Update_Columns();
Code language: PHP (php)
This one is currently only targetable via CSS.
.auto-update-status {
display: none;
}
Code language: CSS (css)
This one is just in case your host has disabled wp_version_check and you can latch the actions onto another cron process.
<?php
/* Enable auto-updates of plugins/themes with cron */
add_action(
'wp_update_plugins',
function() {
if ( wp_doing_cron() && ! doing_action( 'wp_maybe_auto_update' ) ) {
do_action( 'wp_maybe_auto_update' );
}
},
20
);
Code language: PHP (php)
The following will disable auto updates period.
add_filter( 'automatic_updater_disabled', '__return_true' );
add_filter( 'auto_update_core', '__return_false' );
add_filter( 'auto_update_plugin', '__return_false' );
add_filter( 'auto_update_theme', '__return_false' );
add_filter( 'auto_update_theme', '__return_false' );
add_filter( 'auto_update_translation', '__return_false' );
Code language: JavaScript (javascript)
If you have your own tips, please add them below in a comment. Please leave a gist. I’ll update this lesson periodically. Cheers.