Plugin Update Hook

Darren Cooney picture Darren Cooney · Jun 12, 2014 · Viewed 7.4k times · Source

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.

Answer

brasofilo picture brasofilo · Jun 13, 2014

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 );