6

I'm trying to create a WordPress update automation plugin. here I got two option to make enable and disable the updates.

  1. Via define

ex :defined( 'AUTOMATIC_UPDATER_DISABLED',true )

2.via add_filter

ex:add_filter( 'allow_major_auto_core_updates', '__return_true', 1 );

my problem is if I have disabled the updates via define and also have enabled it via add_filter which one will work ? does add_filter override 'define'? or define override 'add_filter'?

0

1 Answer 1

5

Skimming through the Core_Upgrader::should_update_to_version() method, it looks like we can override the

 defined( 'WP_AUTO_UPDATE_CORE' )    // true (all), false, minor

check, used to setup the local boolean variables$upgrade_dev, $upgrade_minor and $upgrade_major, with the following filters:

...
apply_filters( 'allow_dev_auto_core_updates',   $upgrade_dev   ) 
...
apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor )
...
apply_filters( 'allow_major_auto_core_updates', $upgrade_major )
...

So these filters have the last word over the WP_AUTO_UPDATE_CORE constant check.

Similarly, the automatic_updater_disabled filter can override the AUTOMATIC_UPDATER_DISABLED constant check.

But note that we can't override the constant itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.