Connect with us

WordPress development: Managing plugins through Subversion

coding

WordPress development: Managing plugins through Subversion

UPDATE: For a complete guide on how to create a WordPress plugin (that sells), please check out our newly released tutorial on Teachable: https://coderevolution.teachable.com/p/wordpress-plugin-development-tutorial.

WordPress has included the functionality to allow you to update plugins automatically since version 2.7. This works well for most setups, but what if you want a little more control over the upgrade process. Maybe you want to see the code changes between your version and the new version and merge any code changes you have made?

The answer is to install and upgrade your plugins with SVN, through the command line. Every plugin hosted in the official WordPress Plugin Repository has a Subversion repository which stores the plugin’s files. We can use these repositories to “check out” the files into our wp-content/plugins folder. Once the files have been downloaded to your plugin directory, you can then activate it in your WordPress administration panel.

Once you have found a plugin that you would like to install in the plugin repository, take note of its URL slug. We’ll need this for determining the URL of the Subversion repository. For example, the WP Super Cache plugin (http://wordpress.org/extend/plugins/wp-super-cache/) has a URL slug of wp-super-cache (the last part of the URL). The root of the plugin’s SVN repositories is located at: http://plugins.svn.wordpress.org/. You simply append a plugin’s URL slug to the end of this URL, and you will have the location of its repository.

Now that we have the Subversion repository, we need to figure out where the latest version of the plugin is stored. A Subversion repository typically has three directories in its root: branchestags and trunk. Normally, active plugin development is done under trunk, while tags contain directories of stable releases. Branches may contain directories that encase older-than-trunk development releases. Typically, under this system, you could check out the highest number under tags to download the most recent version. However, not all developers follow this “standard”. Some may only have their plugin under trunk, and only “check in” release ready code. To find out which system the developer is using, open the readme.txt file under trunk. Under the first section in that file, look for a line that starts with “Stable tag”. If you find this line, you can get the latest stable release by “checking out” that number from the tags directory. If this line doesn’t exist, you can assume that the trunk directory contains the stable version of the plugin, and that you should “check out” trunk.

As for actually “checking out” these plugins, you’ll first need to SSH into your server and `cd` into your wp-content/plugins file. You can then run a command such as the following:

svn co http://plugins.svn.wordpress.org/wp-super-cache/tags/0.9.8/ wp-super-cache

Which would load the WP Super Cache plugin files into a directory named “wp-super-cache”. You can then head to your WordPress administration panel and activate the plugins.

When it comes time to upgrade a plugin, it’s a similar process. If you previously checked out a tag (run `svn info` if you don’t remember), just find the latest version number to determine the new Subversion URL. For example, if WP Super Cache 0.9.9 were to be released, I could upgrade to it by `cd`ing into its directory and running:

svn sw http://plugins.svn.wordpress.org/wp-super-cache/tags/0.9.9/

Which will switch the working repository to the new version of the plugin, merging the changes into your current files.

If you checked out from trunk before, you can just run the following to update:

svn up

If you plan on making custom modifications to plugins you install, managing them via Subversion is the best route to take. You’ll be able to view the differences (run `svn help diff` for details on this) and have Subversion merge them together automatically. Not to mention, you’ll also enjoy faster installs and upgrades.

Continue Reading
You may also like...
Click to comment

Leave a Reply

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

More in coding

To Top
Grab the largest plugin bundle from CodeCanyon!