Using Transients to Deploy WordPress Plugins with GitHub

Software developers who choose to delve into the world of WordPress plugins are introduced, by default, to the Subversion (SVN) repository for maintaining the distribution of their work to WordPress users. SVN works well enough, but it has some inherent weaknesses that many developers do not want to deal with. As an alternative, developers can make the most out of WordPress with GitHub and transients.

Before we discuss using transients to deploy your WordPress plugins, let us talk SVN versus GitHub. Why would anyone want to use an alternate repository system rather than stick with the default? There are quite a few reasons, but the two most important are:

  • Speed – SVN is notoriously slow. Execute even a basic command in SVN and you should plan on getting lunch while it runs. By comparison, GitHub is lightning-fast. GitHub lets developers do everything offline first – things such as file annotations and commits – before transferring from the local disk to the server. GitHub is also markedly faster when it comes to the cloning process.
  • Data Protection – The SVN platform utilises a single server along with a single version of the software that all developers are working with. The GitHub platform provides every developer with a copy of the package, essentially creating as many backup copies as there are team members. This offers instant data protection benefits.

With the preliminaries out of the way, we can now move on to deploying plugins via GitHub and transients.

Build Your PHP Class

You have worked long and hard to develop the next killer plugin; now you are ready to deploy it via GitHub. The key to making this work are transients. A transient, by definition, is a short line of code stored on a server with a clearly defined expiration date. WordPress uses them to collect and store data on all available plugins. The expiration of a transient forces WordPress to check on the plugin in question, thereby staying up-to-date with the latest version.

The first thing to do is write some PHP code. This essentially builds a class that includes information about the properties of the plugin. Your eventual code will include a class name that can be anything you want though it is helpful to simply use some variation of the base name for simplicity’s sake. As for plugin properties, it is best to use the admin_init function to make sure everything is hooked correctly. If you don’t know how to do any of this, the WordPress plugin API has all the information you need.

Setting Up GitHub and WordPress

With your PHP class in hand, it is time to move on to GitHub. Assuming you are already an active member with a working account, establish a repository for your new plugin. The most important thing here is to set your root directory to be the same directory on your local drive that contains the contents of your plugin folder. Do not make the plugin folder the root directory or no one will ever find your great plugin!

From here, the rest of the process is relatively straightforward. You will need to:

  1. Create a new release (be sure to use semantic versioning)
  2. Publish your new release
  3. Connect your plugin to GitHub
  4. Connect into the WordPress transient

Again, instructions for doing all of this are found within the WordPress plugin API. If you follow the instructions closely, you will be able to make the most of WordPress with GitHub rather than labouring over SVN. You will be more productive and much happier as a result.

About Amit Shaw

Amit Shaw, Administrator of iTechCode.He is a 26 Year Ordinary Simple guy from West Bengal,India. He writes about Blogging, Technology, Gadgets, Programming etc. Connect with him on Facebook, Add him on Google+ and Follow him on Twitter.