Lowercase p, dangit!

How to remove the ‘capital_P_dangit’ filter from WordPress

The ‘capital_P_dangit’ is a small piece of code that was added to the WordPress core just before WordPress 3.0 was released. It changes all instances of “Wordpress” (notice the lowercase “p”) to “WordPress” in areas where content is shown on the site. The code, written by Matt Mullenweg himself, was committed to WordPress without a Trac ticket, so it wasn’t left open to community discussion beforehand.

The function is included as a default filter called ‘capital_P_dangit’ that is automatically applied to the title, content and comments of every page or custom post type of your site. It might not look like a big deal, but that filter is executed in every single page view.

The solution

According to Matt Mullenweg, a plugin should be built:

As I said before, you are in /complete control/ of your site. It’s a single line to remove a filter. If you don’t like the filter, vote with your feet or with a plugin. If the function cause a non-trivial number of people to avoid 3.0, leave WP, or install a plugin to deactivate I would seriously reconsider it. In the absence of that, there are a 1,001 better places to focus my attention with regards to WordPress.

That message is dated May 2010. Seven years have passed, and WordPress still automatically capitalizes Wordpress to WordPress. The time has come to take matters if our own hands.

Option 1. Do it yourself

You can remove the execution of the filter adding this code to your functions.php or custom plugin:

remove_filter( 'the_title', 'capital_P_dangit', 11 );
remove_filter( 'the_content', 'capital_P_dangit', 11 );
remove_filter( 'comment_text', 'capital_P_dangit', 31 );

Option 2. Install a plugin

This plugin by Tom Lany does an excellent work removing the ‘capital_P_dangit’ filter, although it’s a bit of overkill to install a plugin just to remove a filter.


Option 3. Use Machete

Since Machete 2.0.2, the Optimization Module includes an option to remove the ‘capital_P_dangit’ filter.

Open your dashboard, click on Machete > Optimization, check the capital_P_dangit option and save changes.

Image: Some rights reserved by Leo Reynolds