Hook or function to check if performing a WP Core update?


I’m trying to find a way to detect if WP is actively performing a core update.

The use-case is a development server where I break things regularly and coded two “emergency reset” procedures that will reset the site back to a working state by either adding URL query args to the site URL (if WP isn’t totally broken), or visiting a specific ‘reset.php’ site link (WP totally broken). The URL query args method uses WP functions to make changes. The ‘reset.php’ executes sh scripts to make changes.

Part of what happens during a reset is disabling all plugins. To make sure specific plugins are active at all times (including after a reset), I’m hooking into 'plugins_loaded' and force-activating specific plugins. Kinda like MU Plugins, but forcibly activated every page load, and they can be deleted if need be.

The problem is that every page load of WP, the 'plugins_loaded' hook is acted upon, making specific plugins constantly activated, which breaks WP Core updates giving the message "An automated WordPress update has failed to complete".

I’m looking for a hook or function to detect when WP is performing a Core update so that I can selectively force-activate plugins only when a Core update is NOT actively happening.

Something like is_doing_core_update() returns true or false.

No luck finding something like this myself, so reaching out to the gurus.

If I am unable to find a suitable way to accomplish this, my alternative option is to check for updates to core & plugins and then do any available updates PRIOR to force-activating those specific plugins. Maybe this is my only real option, but I’d still like to see if there’s a hook or function to detect when an update is actively happening.

John Patrick Hayden 1 month 2022-10-17T19:02:15-05:00 0 Answers 0 views 0

Leave an answer