Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 312
Darren Cooney Avatar asked Jun 12 '14 15:06

Darren Cooney


People also ask

What is the use of Post_updated hook?

Use this hook whenever you need to compare values before and after the post update. This hook runs after the database update.

What is hook plugin?

Hooks are a way for one piece of code to interact/modify another piece of code at specific, pre-defined spots. They make up the foundation for how plugins and themes interact with WordPress Core, but they're also used extensively by Core itself. There are two types of hooks: Actions and Filters.

How do I filter a hook in WordPress?

WordPress offers filter hooks to allow plugins to modify various types of internal data at runtime. A plugin can modify data by binding a callback to a filter hook. When the filter is later applied, each bound callback is run in order of priority, and given the opportunity to modify a value by returning a new value.


1 Answers

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 );
like image 84
brasofilo Avatar answered Oct 25 '22 14:10

brasofilo