I maintain and develop several plugins in the WP repo and have been wanting to deploy some update that display notices/setups new settings for installations that are upgrading to the new version of the plugin. However, it is not possible to manually update a plugin on one's localhost (there is a feature request for this to be included in WP core). I found this post on reddit with some interesting suggestions, namely
I guess one of the above should do the trick. However, has anyone else come across this problem? What solution have you used?
[EDIT] Option 4 does not trigger the update hook, it simply deactivates/removes the old plugin and installs the new one.
I maintain and develop several plugins in the WP repo and have been wanting to deploy some update that display notices/setups new settings for installations that are upgrading to the new version of the plugin. However, it is not possible to manually update a plugin on one's localhost (there is a feature request for this to be included in WP core). I found this post on reddit with some interesting suggestions, namely
I guess one of the above should do the trick. However, has anyone else come across this problem? What solution have you used?
[EDIT] Option 4 does not trigger the update hook, it simply deactivates/removes the old plugin and installs the new one.
OK, so you want to do something after update (let's say add some DB table, change its structure or something like that).
The feature request you mention is very old and I don't believe it would be solved - because there is no need for that feature.
There are many scenarios, when your plugin won't be notified that its version changed:
So what? All of these cases should cause update notification? No, I don't believe so.
The update notification is an event that is meant to notify you, that plugin updater ended its job. You can log it, you can send some notification emails, and so on.
But you shouldn't rely on it to perform any actions for newer version of a plugin. And these cases above show you why.
On the other hand - if your plugin won't work, then it's its fault, not WP. And when you go to Codex page for that hook, you'll see:
The upgrader_process_complete action hook is run when the download process for a plugin install or update finishes.
It is passed two arguments: an instance of the WP_Upgrader() class and the $hook_extra array.
Use with caution: When you use the upgrader_process_complete action hook in your plugin and your plugin is the one which under upgrade, then this action will run the old version of your plugin.
So I don't believe you should use this action in your case at all...
One of the common practice is versioning the DB. (WP also does it). You can put an option and store your plugin version in there. Your plugin may check that version and if it sees, that this option is different than its version, then DB update (or any other operations) has to be done.