wordpresspluginshookactivation

Plugin Update Hook


My plugin needs to fire an init/build/checker function when the plugin is updated via auto updates in the WP dashboard.

Is there a WordPress hook that is fired after a plugin has been updated from the wordpress.org repository?

I'm not looking for register_activation_hook or register_deactivation_hook as those only execute on manual activation/deactivation.


Solution

  • Yes, upgrader_process_complete [see also: core reference] does that. Inspect the second parameter to know if it is a core, plugin or theme update; and if it is bulk or not.

    add_action( 'upgrader_process_complete', function( $upgrader_object, $options ) {
        // inspect $options
    }, 10, 2 );