Customized WordPress: Applying Patches to WordPress

We’ve talked a lot already about basic subversion, creating a WordPress repository and bundling externals such as plugins. This will accomplish most of what you probably want or need to do with a Custom WordPress repository. However, there may be modifications that you’d like to integrate into the core – perhaps patches that you’ve worked up personally or patches that have been submitted to WordPress that perhaps never saw the light of day. Never fear, you can apply patches to your repository to customize the code for future use.

For this example, let’s use the patch in ticket #2177 submitted to WordPress Trac as an example. This patch, or diff as they are called, has been added to the WordPress core for WordPress 2.3 and provides hooks for all the feeds and related data elements on the WordPress dashboard. This means that you will be able to replace the feeds used with your own.

Say you didn’t want to wait until WordPress 2.3 is released later this summer. You can easily take this diff and apply it to your own WordPress repository. Simply grab the diff from Trac (Hint:

1
macbrain:~/svn aaron$ wget -O mypatch.diff http://trac.wordpress.org/changeset/5346?format=diff&new=5346

) then use the

1
patch

command:

1
macbrain:~/svn aaron$ patch -d wpwc -p0 -N < mypatch.diff

This command means “apply mypatch.diff to the files designated in the diff starting in the wpwc directory”. You could actually place all these patches in a shell script and run them consecutively if there’s a bunch.

Finally, when you’ve patched your working copy, don’t forget to commit your changes!

1
macbrain:~/svn aaron$ svn commit wpwc -m "Applied #2177 to Repository"