Themergency

How To Contribute Code To WordPress

There are a number of ways you can contribute back to WordPress. Tom McFarlin also blogged about it recently, and in summary you can:

  • Contribute to the Codex documentation.
  • Submit a translation.
  • Chime in on the support forums.
  • Participate in the IRC chats.
  • Submit code.

Obviously, the last one interests me the most, as I write code. I mentioned in a previous post that I wanted to contribute some code back to WordPress, to enhance the gallery shortcode. And today, my fellow readers, I finally did what I have been wanting to do for ages - I contributed a patch back to WordPress core!

Steps To Follow

If you want to contribute a new feature, enhancement or bug fix, you can follow these steps that I took:

  1. Create a login for WordPress.org - if you have plugins on WordPress.org or have ever used the support forums then you already have a login.
  2. Install a SVN client - I use Tortoise SVN (Windows) but there are Mac equivalents: SmartSVN or Versions or many others.
  3. Install and Run WordPress locally - using the source from step 3, get a local instance of WordPress running.
  4. Make your core changes! - make the necessary additions or changes to the core files and test everything is working as expected.
  5. Create a patch - using Tortoise to make a patch is as simple as right clicking the modified file or folder and choosing TortoiseSVN -> Create Patch.
  6. Submit a Trac ticket - read up on submitting bugs, and then create a new ticket. Be as descriptive as possible.
  7. Upload your patch - immediately after submitting your ticket, add your patch file as an attachment.
  8. Hold on to your pants - now wait to see how your ticket will be received.

My Contribution

I submitted ticket #26623: Make gallery_shortcode more customizable. It’s a small enhancement to the gallery_shortcode function which outputs the HTML for the built-in galleries. I included some code to make it easier to style and also makes it much easier to override from plugins and themes. I went a bit overboard with my ticket and gave a huge explanation including code samples. I also pointed to a Github repo where I have committed a demo plugin which used the newly proposed changes.

Support My Ticket

If you have worked with the gallery at all, then you will understand why I submitted this ticket. It is simply too hard to customize the default gallery at this point in time. Making any changes means you have to override the entire function, including all of it’s logic. My goal with this patch, is to keep this logic in place and hidden, while still allowing for complete customization of the HTML code. Plugin and theme authors should love this change!