I had a situation recently when I wanted to let plugin users know of a change I’d made since the previous version. The best way, I think, is to use admin_notices and create a notice at the top of the admin page. But I wanted the message to appear only to users who had just updated the plugin, not to appear to users who had just installed the plugin. It turns that there is a hook, upgrader_process_complete, that allows you to do exactly this. It fires when WordPress runs an upgrade / update for themes or plugins and provides us with data on which plugins or themes have been updated.
This means that you can add an action that will run when WordPress has processed an update and check which plugins have been updated. If yours is one of them, you can display a notice to your users.
To test this out, I made a short plugin that will display a notice to users when it’s installed then display a different notice when it’s updated.
<?php
/*Plugin Name: Upgrader Process Example
Plugin URI: https://catapultthemes.com/wordpress-plugin-update-hook-upgrader_process_complete/
Description: Just an example of using upgrader_process_complete
Version: 1.0.0
Author: Catapult Themes
Author
Source: https://managewp.org/articles/15677/wordpress-plugin-update-hook-upgrader-process-complete
source https://williechiu40.wordpress.com/2017/07/18/wordpress-plugin-update-hook-upgrader_process_complete/
No comments:
Post a Comment