I would like to run several actions on a website once WP core or any of the plugins have been updated using the built-in update process. Is there a way to do it?
I would prefer if I could run commands on 3 different cases:
- WP core update is finished
- A single plugin update has been
finished - A bulk update for plugins has been finished (so that I
run the command only
after all of them have been finished)
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Hooks
The hooks you’re searching for are
'pre_set_site_transient_update_plugins'
and
'upgrader_post_install'
The later takes three arguments. Example:
function upgrader_post_install_cb( $true, $hook_extra, $result )
and should be used for: Move & activate the plugin, echo the update message.
Moving plugins
Moving works like this:
$wp_filesystem->move(
$result['destination']
,'your_destination_path'
);
Then use activate_plugin( 'path/file' ); after moving.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0