hooks - Is there any way to allow a plugin to write over a previous version?

admin2025-06-03  4

When installing a plugin, it will not install if the directory to which it is attempting to install already exists. This means that users of our plugin must first manually deactivate and delete the plugin.

Is there any way to forcibly overwrite the directory or to deactivate the plugin and delete the directory at installation?

The only solution I can come up with is to deactivate and delete the previous version on activation, but not only would this require versioning the plugin directory, it would also apparently require versioning all of the plugin's functions.

When installing a plugin, it will not install if the directory to which it is attempting to install already exists. This means that users of our plugin must first manually deactivate and delete the plugin.

Is there any way to forcibly overwrite the directory or to deactivate the plugin and delete the directory at installation?

The only solution I can come up with is to deactivate and delete the previous version on activation, but not only would this require versioning the plugin directory, it would also apparently require versioning all of the plugin's functions.

Share Improve this question edited Feb 9, 2019 at 0:03 fuxia 107k39 gold badges255 silver badges461 bronze badges asked May 3, 2012 at 22:39 joshjosh 1133 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

If you're manually installing a plugin, you need to disable and delete the old version. However, WordPress does allow you to update your plugin programatically.

If your plugin is hosted on the WordPress repository, it will prompt the users to install updates for you. You've likely seen this with Akismet and other plugins already.

If your plugin isn't hosted on the WordPress repository, there are a few other things you can do. Many premium theme/plugin shops are including their own update scripts in their releases. It allows them to push out updates to their customers that use the standard WordPress update mechanisms to download the new package, install it, and remove old files.

Here are just a few examples:

  • WordPress Upgrade Class for Commercial or Client Plugins
  • WordPress GitHub Plugin Updater - useful if you host your plugin on GitHub rather than in the WP repo
  • The "Making Your Own Plugin Repository" section in Chapter 9 of Professional WordPress Plugin Development Note, this is an affiliate link
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748926724a314882.html

最新回复(0)