plugin-update-checker icon indicating copy to clipboard operation
plugin-update-checker copied to clipboard

Set Plugin Hostname in `Update URI`

Open jeffpaul opened this issue 3 years ago • 5 comments

Hi there!

Alongside the WordPress 5.8 release, plugins can now set the URL for their update method. For the various integrations with the plugin-update-checker, is there a recommendation for what to put in the new Update URI field? Seems like putting something there besides https://wordpress.org/plugins/{$slug}/ or w.org/plugin/{$slug} would be ideal so WP.org naming conflicts don't overwrite plugins updated via the plugin-update-checker. I wasn't sure if there was a good reference to put there besides false, so hoping you might have some guidance?

Thanks! Jeff.

jeffpaul avatar Jun 23 '21 21:06 jeffpaul

I haven't put very much thought into this, but my recommendation would be to use something that's unique to your plugin, like your own domain name.

Since the patch also introduces a new filter that makes it more convenient to provide custom updates, there will probably be some new plugins that will try to update other plugins based on the Update URI field (e.g. a plugin for GitHub updates). So I would be wary of using any value that might have special meaning to any other developers. Even something seemingly innocuous like false could become an issue if, for example, some developer decides that false means a plugin should never get any updates and uses the filter to disable/remove updates. Setting the Update URI to something unique seems safer.

YahnisElsts avatar Jun 24 '21 18:06 YahnisElsts

Even more details on the Update URI field: Introducing “Update URI” plugin header in WordPress 5.8

jeffpaul avatar Jun 29 '21 16:06 jeffpaul

I think I should probably mention this new header in the readme, but there's currently no good place to put it. Maybe I'll add a "FAQ" section later.

  • [ ] Add a note about Update URI to README.md

YahnisElsts avatar Jul 02 '21 10:07 YahnisElsts

If I understand it, this new header would eliminate the need for including this plugin-update-checker code in our plugins, if we were using our own WP Update Server.

Wouldn't a plugin author simply set the Update URI header field, and point it at our own wp-update-server? Or does someone else have a better understanding of how this new field is meant to work?

jakeparis avatar Jul 06 '21 12:07 jakeparis

No, I don't think that would work. Quoting from the make.wordpress.org post that was mentioned above:

If the value of this new field matches any URI other than https://wordpress.org/plugins/{$slug}/ or w.org/plugin/{$slug}, WordPress will not attempt to update it. [emphasis mine]

It sounds like WordPress will not check the provided URI for updates. By default, the only thing that the Update URI header does is prevent WordPress from trying to find plugin updates on wordpress.org. Anything more - like retrieving updates from the URI - would still require custom code.

YahnisElsts avatar Jul 06 '21 14:07 YahnisElsts