YahnisElsts / wp-update-server

A custom update API for WordPress plugins and themes. Intended to be used in conjunction with my plugin-update-checker library.
MIT License
824 stars 176 forks source link

Handling alpha and beta plugin versions #104

Closed wiwimaster closed 1 year ago

wiwimaster commented 1 year ago

Hi Yahnis,

first of all, you've created an awesome plugin, thanks a lot for that!

Now I'm trying to offer plugin users access to the beta version of our plugin (e.g. by setting "I want to use the beta version" in the plugin's settings). Based on that setting I could load a different plugin updater URL, or use some other settings to load a different version of the plugin (that has the same slug of course).

I struggle a bit on how to do this using the wp-update-server as I think I cannot alter either folder, slug, or query vars of the request URL. Do you have an idea how I could provide access to different plugin versions using the WP Update server?

Thanks a lot Jan

YahnisElsts commented 1 year ago

Using a different URL sounds like it might be the easiest option. You could name the beta version something like plugin-name-beta. Use that as the folder name, name the ZIP file plugin-name-beta.zip, and put it in the packages directory as if it was a separate plugin. Then you can change the slug in the update URL to plugin-name-beta.

Even though the folder name and ZIP filename will be different from the base plugin, the update checker should automatically rename the plugin folder from plugin-name-beta to just plugin-name when installing an update. This is a feature: the update checker tries to ensure that the plugin folder name stays the same after an update. This was originally introduced to make PUC work with GitHub's auto-generated ZIP archives that automatically add the branch, tag, or commit hash to the folder name.

wiwimaster commented 1 year ago

That works perfectly, thanks for your help!