1

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

  1. update the code in the WP repo but keep the same current version number, install a lower version number on a localhost and trigger the update via the dashboard.
  2. use the Github-Updater plugin to update the plugin from a github repo, however not sure if this works. Going to try and come back to post the results here.
  3. can trigger updates by using the WP Rollback plugin to rollback your plugin version. This sounds a little convoluted, one would have to code the reverse logic to test it.
  4. Use the Updater plugin which claims it can update from a zip file. (going to test this)

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.

2
  • And what is your problem exactly with manual update? Jan 22, 2019 at 7:19
  • it does not trigger the update hook
    – Aurovrata
    Jan 22, 2019 at 7:23

1 Answer 1

-1

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:

  1. User manually uploads newer version and performs update.
  2. User goes to FTP and overwrites plugin directory with newer version.
  3. User deletes the plugin and uploads newer version.
  4. User used your plugin in old version some time ago and now uploads it again using FTP.

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...

So how other plugins take care of that?

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.

4
  • The 'upgrader_process_complete' hook is used by plugin developers to notify users of changes in a new update so that may take appropriate action. It is part of the codex so although your answer makes some valid points, it does not answer the question.
    – Aurovrata
    Jan 22, 2019 at 10:36
  • @Aurovrata it is in codex and the Codex clearly says: "The upgrader_process_complete action hook is run when the download process for a plugin install or update finishes." You want to use this hook in other conditions, so... Jan 22, 2019 at 10:40
  • Which plugins use this hook to "to notify users of changes in a new update" - because it really makes no sense. This hook is meant for entirely different purposes and Codex clearly shows that there will be many problems with such usage... Jan 22, 2019 at 10:45
  • thanks for your answer, I appreciate your offer to help, but regardless of the how a developer may want to use this hook, my question is how can one actually test it in a local development environment, which you answer does not address.
    – Aurovrata
    Dec 9, 2019 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.