Quick and dirty Wordpress deployment plugin

I recently had to work on a Wordpress site for a client in order to make some updates and was frustrated to find little in Wordpress' API to help you to script updates in a reproducible manner. Coming from a Drupal background I am used to being able to use hook_update_N() to script any database changes I need to make so that when I deploy to the staging environment and ultimately to production, the changes can be made automatically by running the update script.

To get round this, I have hacked together a little plugin for Wordpress that operates in a similar manner as shown below. Essentially, when viewing the admin area of Wordpress, the plugin checks to see whether a version number in the database is older than the version number defined in the plugin. If it is, then it iterates through all the intermediate numbers and attempts to run functions named in the form deployment_update_N(). It's rudimentary, but it works and it did the job for me to deploy changes to the site in a sane manner!

Tags