WTF?

This is an experiment on Usability by Anirudh Sanjeev. Under construction. Run along now.

February 9th, 2008 Leave a comment posted in Uncategorized

OneClick Framework

What is it?

It’s a framework to allow your plugins and themes to update themselves to the latest versions, so the users are never using the old version. It is just a port from the source code of the OneClick plugin, which featured the ability to instantly upgrade itself.

How do I use it.

Here are the steps you need to take to use the OneClick Framework:

  1. Download the zip files, and extract into the folder of your plugin/theme, as shown in these screenshots.
    Screenshot - 10_4_2007 , 4_26_59 PM
    Screenshot - 10_4_2007 , 4_28_44 PM
  2. in your php code, first set the three environment variables
    Code (php)
    1. if(!class_exists(‘ocframework’))//very important if more than one plugin is using the framework
    2.         require(‘framework.php’);
    3. //using framework for a plugin
    4. //create a new updater object
    5. $updater=new ocframework();
    6. //set the versionpath, pointing to a remote textfile containing only the latest version
    7. $updater->versionpath=‘http://10.111.10.100/myplugin.txt’;
    8. //set the current version of the plugin.
    9. $updater->version=‘0.1′;
    10. //set the path of the zip file to be downloaded
    11. $updater->downloadpath=‘http://10.111.10.100/myplugin.zip’;
    12. if($updater->checkForUpdate())//this returns a boolean value wether an update is available
    13. {
    14.         $updater->update();
    15. }

    Essentially you’re creating a new object, and setting the file where it has to look for the latest version, and the path from which it has to download the zip file.

  3. Requirements for the zip file:
    It should be uploaded on a stable remote server with a good uptime. Also the files must have a directory with *the same name* as the plugin. So, for myplugin, the screenshot would look like:
    Screenshot - 10_4_2007 , 4_39_01 PM
  4. That’s it! You still have to build your plugin or theme though.

How does it work?

It works by unzipping the contents of the remote zip file in the parent directory. so it will unzip the contents of myplugin in /wp-content/plugins/, thus effectively replacing the old version of the folder.

Suggestions:

  1. Be sure to ask the user before updating the theme. The function checkForUpdate returns a boolean value wether an update is available.
  2. Checking for an update takes up significant amount of resources and time. You might want to incorporate checking for an update everyday or something like that.
  3. Please don’t update without the user’s consent. Especially for themes. If the user has made modifications to the theme source code, it will be lost.
  4. All settings will be preserved for plugins and themes. You don’t need to reactivate the plugin after it’s updated.
  5. The next version has a feature where it can email the user that an update is available, and they can confirm and plugin/theme is updated.
  6. This framework was written in the span of two hours and hasn’t been extensively tested. It’s in beta right now. If you find a bug, email me. Check back for a stable release soon. Unfortunately the framework doesn’t update itself :)

Where can I get support for this?

If you have any question, leave a comment here and I’ll try getting back to you. In case you find a bug, have a feature suggestion, or want to help out with the code, send an email to anirudh at anirudhsanjeev dot org

Who are you?

I am Anirudh. I also happened to write the OneClick plugin for wordpress. This has been downloaded over 12000 times. This website is part of my new project, where I write articles on usability and interface design. It’s still under construction, as you can see.

Important:

I just found a minor bug that could’ve deleted your wp-admin folder(not a good thing). Now what you have to do is just add one more line to your code before checking for an update.

If you’re using it for a plugin, then add $updater->targetdir=”../wp-content/plugins/”; near the other environment variables

If you’re using it for a theme, then add $updater->targetdir=”../wp-content/themes/”; near the other environment variables

Download

Download the file: ocframework.zip (version 0.1)

October 4th, 2007 9 comments posted in Uncategorized

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

September 4th, 2007 1 comment posted in Uncategorized