WordPress Plugin Update Class

During I wrote my plugin NextGEN Gallery I study the plugins ImageManager and Spam Karma. Both of them contain a routine to inform the users about news. After the Hacker attack I get a feeling how important it is, that the users keeps their plugins (and not only WordPress) up to date… therefore I write this little PHP class to avoid double work for my other plugins. Feel free to use it :

This is one way how can use it, if you wish to show a note in the dashboard :

 // Dashboard update notification example
 function myPlugin_update_dashboard() {
   $Check = new CheckPlugin(); 
   $Check->URL  = "The URL to the version.php";
   $Check->version = "1.00";
   $Check->name  = "myPlugin";
   if ($Check->startCheck()) {
      echo '<h3>Update Information</h3>';
     echo '<p>A new version is available</p>';
   }
 }
 
 add_action('activity_box_end', 'myPlugin_update_dashboard', '0');

The class CheckPlugin() will look at the URL and check for the actual version of your plugin. To fetch the information I take the idea of Per Søderlind to use the Snoopy class, which is part of WordPress. But what is inside of version.php ?
Very simple , look here :

$version = array();
$version["myPlugin"] = "1.00";
$version["otherPlugin"] = "2.50";

echo serialize($version);

A serialized array gives me the possibility to add more plugins to the version.php file. To avoid too much traffic you can set $Check->period (default 86400 sec = 1 day) to any other value…

Download Checker.zip here
Simple, free, 2kb

Advertisements
Tagged ,

5 thoughts on “WordPress Plugin Update Class

  1. milemann says:

    nice! very nice!
    you are in tune alex …
    greetz
    mil

  2. […] WordPress Plugin Update Class at alex.rabe (tags: wordpress plugin) […]

  3. Chris says:

    Hi Alex,
    that’s nice. But it would be very useful if this plugin could also actually download and unzip the upgrade.
    I use Instant Upgrade (http://www.zirona.com/software/wordpress-instant-upgrade) to upgrade several WP installations. It saves a lot of time.
    If also plugins would provide such a mechanism it would be just great. It’s a pity that WordPress does not bring these functions (e.g. by adding an update-url in the plugin-description which would allow an automatic update).

  4. alakhnor says:

    That’s what you use in NGG isn’t it?

    Next step is to retrieve version directly from WP.org. 😉

  5. Chris says:

    Hi, for upgrading plugins i’ve written a small plugin:

    http://chris.leipold.ws/2007/09/03/wp-plugin-installer/

    I’ll try to combine my plugin with yours so you could click on the notifier “update now” without downloading, unzipping and putting on the server.

    Cheers!

Comments are closed.

%d bloggers like this: