Question

If I write a private plugin, is there any way to use the WordPress auto-update mechanism to update it?

I want to encapsulate the functionality, but it's specific to my own 5 or so blogs, so it's not a good candidate for the public plugins resource. But I love the easy-updating mechanism.

Is there a way to do this?

Was it helpful?

Solution

Looks like the applicable code is in wp-includes/update.php, wp_update_plugins():

$to_send = (object) compact('plugins', 'active');

$options = array(
    'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3), 
    'body' => array( 'plugins' => serialize( $to_send ) ),
    'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
);  

$raw_response = wp_remote_post('http://api.wordpress.org/plugins/update-check/1.0/', $options);

It specifically checks api.wordpress.org. Technically speaking it would be possible to pass a key inside $to_send to delegate the check, but to my knowledge that is not a supported feature.

If you hook into set_site_transient_update_plugins you could add your own package details into this variable. It looks like those values will be trusted when you run the plugin updater. See wp-admin/update.php and wp-admin/includes/class-wp-upgrader.php. Given the code in these two functions, I think it would be possible to inject your own update server, you just need to look at how the package details are formatted and match that.

OTHER TIPS

This plugin does it for you:

Automatic Updates For Private And Commercial Plugins

Since time immemorial, only plugins hosted in the official WordPress.org plugin directory have supported automatic updates. Now, I’ve written a PHP library that you can use to add automatic update capabilities to any plugin. Public, private and commercial plugins alike – all can now enjoy the benefits of automatic update notifications and one-click upgrades.

GitHub repository

If you like free ... and want to use something like GitHub, GitLab, or BitBucket, this is a good quality and supported plugin for handling it (supports private and enterprise):

https://github.com/afragen/github-updater

I'm looking into the same thing. A couple of links that I've found that might be helpful:

The first is some info and pointers to the upgrades API. The second is a code snippet showing how to actually request info from the API.

You may want to check out the WordPress Development Kit plugin. I recently migrated my proprietary update system to this plugin. The plugin now serves as the back-end processor for my premium plugin updates.

This is similar in setup to the solution provided by agileapricot above. It will install as a standard plugin on a WordPress site. You host your premium .zip files and the plugins.json in production or prerelease directories on your server (specified in the settings for the plugin).

The plugin also allows you to list plugin versions and can even provide a download for the files on public, password-protected, or subscription-protected pages. You can see an example of the on-page version list here.

I have been using the plugin for months to publish the change log for my premium add-ons, the current versions list, and download lists for my Premier Subscription holders. Now, with version 0.7.01, it is working as the query destination for inline WordPress updates.

Hope some of you find it useful.

If you want a hosted solution that you don't have to manage, check out Kernl (https://kernl.us). Its a service that provides the infrastructure for updating plugins and makes it easy to integrate into your own plugins.

you can use this commercial plugin: http://autohosted.com/ no limitation and have several other feature you might need:

  • No monthly charge
  • Unlimited use
  • Easy integration with Themes and Plugins
  • Authentication by domains, keys, & roles
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top