How to Integrate WordPress Plugin Update Notifications Into Your Commercial Plugin

Plugins hosted on the WordPress repository enjoy a very neat and integrated update procedure whereby as soon as you upload a new version of the plugin, the users will get a notification in their dashboard saying that there is a new version available. However if on the other hand your plugin is not hosted on the repository, you might be wondering if you can achieve the same thing. As you might have guessed, the answer is yes!
Table of Contents

Sponsored Ad

If you purchase through a link on our site, we may earn a commission.

Plugins hosted on the WordPress repository enjoy a very neat and integrated update procedure whereby as soon as you upload a new version of the plugin, the users will get a notification in their dashboard saying that there is a new version available.

However if on the other hand your plugin is not hosted on the repository, you might be wondering if you can achieve the same thing. As you might have guessed, the answer is yes!

A Github-hosted project by Jeremy Clark provides all the code you need:

https://github.com/jeremyclark13/automatic-theme-plugin-update

Here’s another free solution by W-Shadow:

http://w-shadow.com/blog/2010/09/02/automatic-updates-for-any-plugin/

And yet another one by Jason Gill:

http://www.gilluminate.com/2011/12/23/host-your-own-custom-wordpress-plugin-updater/

If you’d like to build it yourself, there is an excellent tutorial on WP.Tutsplus.com:

http://wp.tutsplus.com/tutorials/plugins/a-guide-to-the-wordpress-http-api-automatic-plugin-updates/

There is also a Codecanyon item named WordPress Plugin Update which does a similar job and might be worth checking out too.

Preventing Updates

Many developers also develop plugins for particular clients. In this case, they might want to prevent WordPress from sending out any data to WordPress.org when doing update checks. The code below, provided by Mark Jaquith, will do the trick:

[php]
function cws_hidden_plugin_12345( $r, $url ) {
if ( 0 !== strpos( $url, ‘http://api.wordpress.org/plugins/update-check’ ) )
return $r; // Not a plugin update request. Bail immediately.
$plugins = unserialize( $r[‘body’][‘plugins’] );
unset( $plugins->plugins[ plugin_basename( __FILE__ ) ] );
unset( $plugins->active[ array_search( plugin_basename( __FILE__ ), $plugins->active ) ] );
$r[‘body’][‘plugins’] = serialize( $plugins );
return $r;
}

add_filter( ‘http_request_args’, ‘cws_hidden_plugin_12345’, 5, 2 );
[/php]

If you enjoyed this post, make sure to subscribe to WPMayor’s RSS feed.

Jean Galea is an investor, entrepreneur, and blogger. He is the founder of WP Mayor, the plugins WP RSS Aggregator and Spotlight, as well as the Mastermind.fm podcast. His personal blog can be found at jeangalea.com.

Sponsored Ad

If you purchase through a link on our site, we may earn a commission.

All suggestions are anonymous.

More from our blog...

Post a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Stay updated with WP Mayor's newsletter showcase every week

Stay on top of every new WordPress innovation and latest launches. Receive all our fresh product reviews and expert guides directly in your inbox.

Hosting Survey 2024

Are you happy with your hosting provider or are you over-paying for too little? Have your say below!

"*" indicates required fields

What's the main reason you picked this host?*
How happy are you with your host?*

OPTIONAL: If you'd like to receive the results of this survey, please enter your details below.