Paste the following code into your functions.php file. Once you saved the file, the code will filter content and widget content to hide all e-mails from spambots.
function security_remove_emails($content) { $pattern = '/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})/i'; $fix = preg_replace_callback($pattern,"security_remove_emails_logic", $content); return $fix; } function security_remove_emails_logic($result) { return antispambot($result[1]); } add_filter( 'the_content', 'security_remove_emails', 20 ); add_filter( 'widget_text', 'security_remove_emails', 20 );
Thanks to Stian Jacobsen for submitting this tip!