Last active
December 14, 2015 08:09
-
-
Save chuckreynolds/5055366 to your computer and use it in GitHub Desktop.
Automatically Spam Proof Emails on a WordPress Site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', 'flex_remove_emails', 20 ); | |
add_filter( 'widget_text', 'flex_remove_emails', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment