I’m using the File Upload extension to upload a custom plugin file to wp-content/mu-plugins/ and this file contains a few filters to change settings like this. For disabling the auto update functionality I use these filters:
/** Disable the possibility to enable automatic updates (WP 5.5) */
add_filter( 'plugins_auto_update_enabled', '__return_false' );
add_filter( 'themes_auto_update_enabled', '__return_false' );
/** Disable the possibility to enable automatic updates for WP core (WP 5.6) */
add_filter( 'allow_major_auto_core_updates', '__return_false' );
Because if you have a lot of sites (in my case 230 at the moment) and you want to apply a code snippet to a new site, you have to select all sites, where the snippet is removed on the existing sites and re-added to all including the new site. This process takes much more time and you can’t see which sites don’t have the snippets yet.
With the must use plugin method I can check via the Plugins page which sites don’t have the plugin or have an older version and I can upload the latest version of my plugin just to the sites that need it.
Thanks Dennis. this is what I ended up doing. but I used @josklever suggestion with his plugin. I tested this on one site (using MainWP) to install it as an MU-Plugin. This worked great so I did it for the rest of my sites.
I hope you don’t mind, I changed the name of the plugin file to something more meaningful to me and commented out the section that stops core updates. But I did leave your name in the PHP header comments.
Do as you like. JKWS is the acronym of my business, and the code is just public knowledge, so I don’t have any rights to claim. It’s just meant for inspiration.
The last filter doesn’t stop core updates, just the possibility to enable automatic major core updates. Minor (security) updates will still be installed automatically. And all updates can of course be installed manually or via MainWP as soon as you think it’s ready.
Thank you for posting that! This has actually encouraged me to use my very first custom plugin on my own website to disable jQuery Migrate (as my first test). I am now wondering if it may be better to use custom plugins like that instead of code snippets, or if it’s better to just use code snippets instead. The benefit of a custom plugin I suppose is when I’m working inside their website I can see and disable certain functionality right away, versus having to use MainWP for that which is a pain to know what snippets are applied to any particular client site at any given time. Very interesting!!