自动将WordPress内容Email邮箱地址加密防止被收集

有些项目和用户会利用软件对网络上的邮件地址进行收集,然后有针对的群发邮件。如果我们网站采用的是WordPress程序,我们可以采用Antispambot插件自动将网站中邮件Email地址进行加密,在源代码中是看不到邮箱信息的。我们也可以通过无代码实现。

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 );

我们在当前主题的functions.php文件中加上代码,同样可以实现用插件的效果。

推荐站内搜索:域名注册商外贸空间、国内ip代理、服务器租赁、香港云服务器、美国欧洲云服务器、icp备案查询网、已备案域名查询、备案 查询、wordpress主机、