Spam is annoying, so here’s a way to automatically block robots from collecting email addresses from your website.
Copy code The code is as follows:
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 );
Put this Put it in the functions.php file, and if a robot comes to collect email addresses, it will be automatically blocked.
http://www.bkjia.com/PHPjc/326297.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326297.htmlTechArticleSpam emails are very annoying. Here is a method to automatically block robots from collecting email addresses from your website. Copy the code The code is as follows: function security_remove_emails($content) {...