Blog » Automatic Updates for WordPress Plugins

Automatic Updates for WordPress Plugins

Having just completed another update to a WordPress plugin that is specific to our clients and having to push that change out the 100+ sites running them made we wistful for the luxury that plugin developers who host on WordPress.com’s directory have. They can update in one location and all their clients will automatically be notified (in their site control panel) that the plugin needs to be updated and provide a simple mechanism to do so.

I had long hoped to find a way to do this for out plugins but the complexity from most solutions that I’d found made it seem hardly worth the effort. That was until I stumbled on an old post by Janis Elsts at W-Shadow.com. His relatively clear instructions along with the requisite files made it a rather trivial issue to integrate this vital feature into my latest plugin.

There are 4 basic steps to do this:

  1. Post your the current version of your plugin’s ZIP file at a publicly-accessible, consistent URL that you’ll use in the configuration of the JSON metadata file in step 2.
  2. Create a JSON file that contains all the metadata that WordPress will require to determine the current version and present it to the end user. This file needs to be hosted at a publicly-accessible, consistent URL that you’ll use later in the configuration of your plugin’s primary file. Below is a sample minimum configuration:
     {
    "name" : "My Cool Plugin",
    "slug" : "my-cool-plugin",
    "download_url" : "http://example.com/plugins/my-cool-plugin.zip",
    "version" : "2.0",
    "author" : "John Smith",
    "sections" : {
    "description" : "Plugin description here. Basic HTML allowed."
    }
    }
  3. Add the /plugin-updates/ folder found in his Client Library to your plugin.
  4. Add the following code to the primary file of your plugin.

Things to remember are:

  • When creating your .zip file, be sure to use place all your files not in the root of your zip file but in a folder that is the same name as the slug. This is the folder that WordPress will install your plugin into.
  • If your plugin uses a class file
  • See Janis’ notes in his blog file if for some reason you need to use a specific version of the client library if other plugins are using the PucFactory::buildUpdateChecker(); class/method and it is different than yours.

Happy coding!

Michael Gibbs
Stalk Me...
Latest posts by Michael Gibbs (see all)