[wp-hackers] filtering french characters in the_title

Simon Blackbourn piemanek at gmail.com
Mon Oct 19 12:37:31 UTC 2009


Hi

I'm developing a multi-lingual site that uses password-protected posts, and
my client doesn't want the word 'protected' to appear anywhere.

I'm filtering the_title like so:

add_filter( 'the_title', 'no_prot_in_title' );

function no_prot_in_title( $title ) {

    $pattern[0] = '/Protected:/';                    // english
    $pattern[1] = '/Protegido:/';                    // spanish
    $pattern[2] = '/Protégé :/';                     // french
    $replacement[0] = '';
    $replacement[1] = '';
    $replacement[2] = '';

    return preg_replace( $pattern, $replacement, $title );

}

It works perfectly for English and Spanish, but not for French, so I presume
the accented letters are the source of the problem.

I've tried using é instead of the actual letters é and tried
replacing the space with   but it still doesn't work (btw - there is
definitely a space before the colon in the french translation).

Does anyone know how I might get this to work?

Thanks!


More information about the wp-hackers mailing list