CP auto-updating despite filters

I have the following code in my theme class constructor (a class that is called from the functions.php file):

add_filter( ‘allow_dev_auto_core_updates’, ‘__return_false’ );
add_filter( ‘allow_minor_auto_core_updates’, ‘__return_false’ );
add_filter( ‘allow_major_auto_core_updates’, ‘__return_false’ );
add_filter( ‘auto_update_plugin’, ‘__return_false’ );
add_filter( ‘auto_update_theme’, ‘__return_false’ );
add_filter( ‘auto_update_translation’, ‘__return_false’ );
define(‘DISALLOW_FILE_EDIT’, true);

But ClassicPress auto-updated to 1.1.1 anyway. WP never used to do that.

Why isn’t CP respecting the minor update filter?

EDIT: This happens on some sites but not others, and I can’t identify any difference that might affect it.

1 Like

CP respects the same filters and constants as WP for automatic updates.

I suspect the theme is too late in the load order for the filters to take effect. I’m not sure why some sites aren’t getting automatic updates though. Maybe some of the update-related constants are defined in the wp-config.php file for these sites?

Interesting. All the advice I read (StackOverflow etc) says the functions.php in the theme is the right place to put the filters, and my class instantiates as soon as functions.php is loaded.

Some of my themes where this happens (not all) are admin-only themes (all templates redirect to wp-login.php) but functions.php still loads even so. And my wp-config files are clean.

Maybe I’ll try the “define in wp-config” method instead, where this should disable everything:

define( 'AUTOMATIC_UPDATER_DISABLED', true );
2 Likes

Is this advice specifically for the update-related filters?

This is the recommended way to disable automatic updates because it will always work.

You could also try debugging the load order for updates triggered by wp-cron, to verify whether your filters are being triggered in time, but this is more complicated.

We were very careful not to make any changes to the ways that automatic updates can be disabled, so I’m guessing the way you’ve organized this code has probably changed compared to when these sites were on WordPress.

And just a standard reminder: disabling automatic updates is fine as long as you’re willing and able to stay on top of them manually :wink:

Yes. That’s why what I’m experiencing is puzzling, especially because it’s inconsistent.

But to be honest it’s a rabbit hole that I don’t really have the time to go down at the moment :smile:

So I’ll switch to using the wp-config method.

And yes, I use MainWP to keep on top of updates - I just like to test things on localhost and staging copies before I allow production sites to update.

3 Likes