Customized WordPress: SVN Externals


Let’s say you have a WordPress repository (because you previously set one up) and you have a firm understanding of the basics of Subversion. You’re almost to the point where you can begin customizing WordPress for your own use. Being an employee of a blog network, I’d prefer if this was used for your own personal benefit, however I recognize that one of the main benefactors of such a scheme are blog networks or folks providing commercialized instances of WordPress – generally hosted as this makes good business sense under GPL and commercialization (you don’t have to give away any code and commercial modifications then), but I digress. :-)

Now assume for a minute that you actually want to customize WordPress. The defacto way of accomplishing this is through plugins. WordPress is very extensible and allows for most any default behaviour to be modified via plugin hooks. Thousands of plugins already exist at the WordPress plugin repository. Even better, all of these plugins are also available as SVN repositories. So why not use them as such?

Subversion gives us the benefit of using

1
svn:externals

, a property of each folder in a repository, to define external repositories (i.e. plugin repositories) to include files and folders that are not controlled by the repository, but are still included.

Ok, so it’s a little difficult to explian, but a good example of this is how Automattic has bundled the Akismet plugin as an external. If you were to checkout the WordPress code, you would find that Akismet is bundled as an external entity – it is not controlled by the WordPress repository itself.

We can do the same thing with our WordPress repository.

Adding SVN Externals

You can add any external SVN repository to your custom WordPress but the most likely candidate for this tool is to bundle plugins. Assume you wanted to bundle my Embargo Press Release plugin. You would use the

1
svn propedit

command to get this done.

1
macbrain:~/svn/wpwc aaron$ svn propedit svn:externals wp-content/plugins

This generally brings up vi for editing. If you’re not familiar with vi, go get familiar. It’s your best friend on the unix commandline.

The syntax for the svn:externals property is like this:

1
embargo  http://svn.wp-plugins.org/embargo-press-release/trunk/

The first portion is the directory name that the contents of the repository will be downloaded into. At this time, there is no way in subversion to grab individual files – only directories. You can designate specific revision numbers, a practice that is encouraged to ensure no accidental breakage. To do so, you might formulate the property as such:

1
embargo -r 12438 http://svn.wp-plugins.org/embargo-press-release/trunk/

Place additional repositories on subsequent lines and remember when you’re done to commit your changes!

1
macbrain:~/svn/wpwc aaron$ svn ci -m "svn:externals modifications"

Though SVN is great and the svn:externals properites gives us alot of flexibility, sometimes we actually have to modify core files. I’ll show you how to do that next time,