Not so Judicious capital_P


So – after all the hype about the capital_P_dangit “feature” in 3.0 surfaced, the core team did decide to make a change.  They’ve implemented a “more judicious” version of the filter to help “fix” some of the technical glitches the original code caused.  Today I’ll take a quick peek at that code so we can see just how effective the changes are.  In this example, I’ll be using the very same, new and improved code.

Here we have the “new code” – I haven’t altered a single line of it nor have I disabled the capital_P_dangit() filter in this installation of WordPress (version 3.0.1 from the SVN).

function capital_P_dangit( $text ) {
// Simple replacement for titles
if ( ‘the_title’ === current_filter() )
return str_replace( ‘WordPress’, ‘WordPress’, $text );
// Still here? Use the more judicious replacement
static $dblq = false;
if ( false === $dblq )
$dblq = _x(‘“’, ‘opening curly quote’);
return str_replace(
array( ‘ WordPress’, ‘‘Wordpress’, $dblq . ‘WordPress’, ‘>Wordpress’, ‘(WordPress’ ),
array( ‘ WordPress’, ‘‘WordPress’, $dblq . ‘WordPress’, ‘>WordPress’, ‘(WordPress’ ),
$text );
}

Check out the screencast for a quick overview of the new filter — or read on.

Now, if you don’t code — you might not understand why, but if you cut and paste this code expecting it to work, it won’t. See, the code snippet I pasted into the post is not the same as the code you’re looking at here. The filter has changed some capitalization and rendered it useless. I intended to give you a working code snippet, I made sure the snippet worked, but WordPress has broken by transparently “correcting an error in my spelling”.

WordPress_my_intent() <- This is just an example of what a function could be called — but this too has been altered. So, if I were to use an incorrectly capitalized “WordPress” in my function names, perhaps in code snippets I wrote last year, I then upgraded to 3.0, none of my snippets would work for anyone.

And what about not technical articles where I was trying to make a point — for whatever reason — by spelling WordPress incorrectly?

Perhaps the next revision of this junk code, that should NOT be in the core, will include some advanced mind-reading fuzzy logic.

11 thoughts on “Not so Judicious capital_P

  1. The fact that they realize a change is needed, but are STILL sticking to their guns on this egotistical issue is actually surprising to me.

    If you admit there’s a problem, why not remove the filter & put it in a plugin? There’s just no feasible reason for this at all.

    And I love the irony that the idiotic filter breaks its own code when trying to share it’s own code lol. Well done.

    • Thanks, Ben.

      It really is pretty silly that I even need to point this type of junk out – it’s code that would have been punted if it were submitted by anyone else. At this point, I’m sure it’ll stay in the core JUST because they can’t admit being in the wrong.

  2. Why are you putting so much energy into this? It stems from Matt so it will not be reverted. Period. That’s the essence of “benevolent dictatorship”.

    • Someone has to … When things like this become the norm in a community project, there has to be someone willing to relentlessly push back.

      From a technical point of view, WordPress has become an amazing project. From a community point of view, it’s in dire need of help.

  3. Thanks for blogging about this issue. You see it in the same way I do – in fact, I really don’t understand how there is any other way to see it! I hope the WordPress team fix the “bug” soon: http://core.trac.wordpress.org/ticket/13971 . It makes me mad that the WordPress team don’t prioritise code efficiency and performance over everything else.

    • Tom,

      I think, by and far, the TEAM does prioritize good code and performance over everything else.

      Several core contributors have quietly commented about this and other similar subjects — but they find it difficult to openly speak out and I don’t blame them for keeping quiet. They’ve seen what happens to people when they speak up.

      • Oh get over it. You seem to think that Matt is the beginning and end of this issue. He has given numerous responses to this issue on the wp-hackers list about this issue. I don’t feel strongly enough about the issue at hand to comment on it, but remarks like this are completely unfounded and completely unnecessary. Put your effort into something productive.

  4. Hi Gil

    I want to say 2 things.

    First, I want to say thank you for reopening this ticket
    http://core.trac.wordpress.org/ticket/13971
    ( I don’t know how this would end but it’s good to know there are people who stand up and do the right thing. )

    Second, this is clearly not about the coding standard or else that matters.
    It’s purely to serve Matt’s egoistical part, nothing more or less.

    Look at this message from the About page of wordpress.org

    “Everything you see here, from the documentation to the code itself, was created by and for the community. WordPress is an Open Source project, which means there are hundreds of people all over the world working on it.”
    http://wordpress.org/about/

    and here below is what Matt wrote 3 years ago

    “WP has never been driven by committee, or voting, and I personally think that approach tends to create bland, soulless software.”
    Matt ( @ticket#4254 )

    and look what’s happening now in ticket#13971

    I don’t know what all the core dev are afraid of here.
    What hold you back from doing the right thing ?

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>