WordPress Plugin Update Class

30Aug07

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

5 Responses to “WordPress Plugin Update Class”


  1. Gravatar Icon 1 milemann Posted August 30th, 2007 - 20:14

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

  2. Gravatar Icon 2 Chris Posted August 31st, 2007 - 21:55

    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).

  3. Gravatar Icon 3 alakhnor Posted September 2nd, 2007 - 15:20

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

    Next step is to retrieve version directly from WP.org. ;)

  4. Gravatar Icon 4 Chris Posted September 9th, 2007 - 09:34

    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!

Who's linking?

  1. 1 links for 2007-08-31 at orioa Pingback on Aug 31st, 2007
    "[...] WordPress Plugin Update Class at alex.rabe (tags: wordpress plugin) [...] "

Leave a Reply


Comment guidelines: No spamming, no profanity, and no flaming. Inappropriate comments will be deleted outright.