A Piklist update, and Piklist Updates

First, a Piklist update. It’s been over two months since our last release, which is just way too long. We promise to try harder to do more frequent releases.  The good news is that Kevin and I have been working on many new Piklist features.  The bad news, is that they are only 90% ready for prime time. Once completed, we will have a seriously major version to release.  This version should address many of the issues and feature requests you’ve been asking for.

While building this out we came across a major Piklist bug… Piklist didn’t really play nice with multisite. If you install on one site in a multisite install, all is well. But Network Activate, and bad things happen. Piklist wants to create two tables, but on Network Activation they were only created on the main site. Obviously, we needed to fix this, and also make it easy to implement for future updates. So, today we released v0.7.2, which contains the new Piklist Updates feature.

Piklist Updates

Writing update code for your WordPress plugin is not fun. Seriously, it’s just not fun. First, you need to determine if it’s an update or new install, and then you need to determine if multisite is running. If so, and the user network activated your plugin, then you need to loop through all the sites and run your update script. Yuck.

Back in October 2010, Nacin announced that plugin activation hooks will no longer fire for updates, and WordPress doesn’t have a register_update_hook(). When this was proposed in trac ticket 14912, it was declined by the core team. Further discussion led to this recommended procedure: store the plugin version in your database and verify it on each admin page load.

Well, fear not my friends, Piklist will now do all the hard work for you and make it dead simple to create update routines for your Piklist plugins.

  1. First, create an “updates” folder in your piklist/parts/ folder.
  2. Then, create a file to contain your update procedure. The file name should be the version of your plugin.
  3. And of course, make sure you have a version number in the comment block of your PIklist plugin.

That’s all folks!  Seriously, that’s it.

So, how does it work?  Let’s use v0.7.2 of Piklist as an example.

In the parts/updates/ folder lives a file named 0.7.2.php (same as the current version). This file contains the update routine for users updating from an earlier version to v0.7.2. This file is written to update ONE site by migrating some table data and deleting an old table. There is no multisite logic here…Piklist will handle that for you.

Since there is no hook that fires when a plugin is updated, Piklist will only check for updates:

  • When the logged in user can manage_options. Since Administrators are the only users who can activate plugins, they should be the only users who can trigger an update as well.
  • On the Plugins, Update and Dashboard pages.

In addition to running the update, Piklist will keep track of each Piklist plugin you install. Not just the most recent version…but, a version history. Sweet!

There are three caveats when writing your update procedure:

  1. Write for ONE site: The update procedure should be written as if you are updating a single site install. Piklist will automatically handle multisite updates for you. If you are manipulating tables, it is recommended that you use the wpdb class, and $prefix to properly handle tables in a multisite install.
  2. Only PHP: The updates file can only contain PHP code.
  3. Don’t define functions: Since an update procedure is designed to only run once per site, defining functions in your update procedure doesn’t make sense. Any functions should be defined in your main plugin code. You can call functions from your update procedure, just don’t define any.

Better Multisite Support

This is also the first step for better multisite support for Piklist. The new check_network_propagate() function (in class-piklist.php) will allow us to easily expand the multisite capabilities of Piklist and all Piklist plugins.  This has been a popular request, and you will start to see more multisite features roll out in the future.

This isn’t quite the super awesome, feature packed update you deserve after two months, but it is a necessary update for what’s coming next.

Keep sending us your Piklist success stories.  We love hearing from you!




7 thoughts on “A Piklist update, and Piklist Updates

  1. Can’t wait for multisite support!

    Are you still planning on releasing the sample CRM app?

    1. Steve says:

      Yes. Just waiting for all the pieces to be finished.

  2. ahmet says:

    there is no video on youtube about your plugin.

  3. Andy says:

    It’s been over 4 months since your last release. How are things looking?

  4. Andy says:

    sorry to be on your case, but I’m looking at implementing piklist as a project management solution. But, if you have some amjor update arriving soon I can wait. Or, should I just jump into what already exists? Advice is all I need Steve. Cheers, Andy

  5. Dave says:

    Is this project still active? Looks like a while since any updates… Was interested in this but am a little Leary with slow updates for the project. Any news?

Leave a Reply

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