I would wish to add a filter to _e() and __() functions. The filter is FilterTextOfEmail(). This will basically detect any emails and add anti-spam method to it.

I assume, the function for filtering should look like:

function my_wp_text_email_filtering ($content) {
    return FilterTextOfEmail($content)
}

But how to call it?

link|improve this question

Could you provide more context on what is you're trying to archieve? Is FilterTextOfEmail an example function name, or does that function literally exist? More details and clarification of the question please.. – t31os Dec 21 '11 at 21:54
feedback

2 Answers

up vote 7 down vote accepted

The filter name is gettext, and you would add it like this:

add_filter( 'gettext', 'my_wp_text_email_filtering', 10, 3 );

function my_wp_text_email_filtering( $translated, $text, $domain ) {
    return FilterTextOfEmail( $translated );
}

The $text argument is there also in case you want to access the pre-translated text.

link|improve this answer
Thank you for answering, works great. However, what would be the filter for the the_content() as it appears, __() and _e() don't automatically apply for that. – Kalle H. Väravas Dec 22 '11 at 11:23
Not sure what you're asking here? You just want to apply the same filter to the_content? Wouldn't add_filter( 'the_content', 'FilterTextOfEmail' ); work for that? – goldenapples Dec 22 '11 at 19:37
Yes, your are correct! Thank you! – Kalle H. Väravas Dec 22 '11 at 21:00
feedback

You have to filter 'gettext'. See this answer for an example.

Always check the textdomain parameter to avoid conflicts with plugins and themes.

link|improve this answer
Thank you for answering – Kalle H. Väravas Dec 22 '11 at 11:22
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.