{"id":7635062,"date":"2016-08-04T18:38:56","date_gmt":"2016-08-04T18:38:56","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/email-antispambot\/"},"modified":"2016-09-01T17:30:14","modified_gmt":"2016-09-01T17:30:14","slug":"email-antispambot","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/email-antispambot\/","title":{"rendered":"Email Antispambot"},"content":{"rendered":"<p>I am trying to use antispambot to encode my email address in widget text using a short code as per <a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/antispambot\">Function_Reference\/antispambot<br \/>\n<\/a><br \/>\nMy website is <a href=\"http:\/\/legalmarketingplus.com\">legalmarketingplus.com<\/a> <\/p>\n<p>It is still under development. I tried to put my email in the header as &#8220;info AT legalmarketingplus.com&#8221;. This is in my functions.php<\/p>\n<pre><code>\/**\n * Hide email from Spam Bots using a shortcode.\n *\n * @param array  $atts    Shortcode attributes. Not used.\n * @param string $content The shortcode content. Should be an email address.\n *\n * @return string The obfuscated email address.\n *\/\nfunction wpcodex_hide_email_shortcode( $atts , $content = null ) {\n\tif ( ! is_email( $content ) ) {\n\t\treturn;\n\t}\n\n        \/\/ Test to see what antispambot returns. This works.\n        \/\/ I am getting encoded email.\n       \t$fh = fopen(&#039;\/home3\/digitalwiz\/tmp\/testlog.txt&#039;,&quot;a+&quot;);\n\tfwrite($fh,antispambot( $content ));\n\tfclose($fh);\n\n\treturn &#039;&lt;a href=&quot;mailto:&#039; . antispambot( $content ) . &#039;&quot;&gt;&#039; . antispambot( $content ) . &#039;&lt;\/a&gt;&#039;;\n}\n\nadd_shortcode( &#039;email&#039;, &#039;wpcodex_hide_email_shortcode&#039; );\n\n\/\/ You can also use this in a plain text widget if you add this filter to your function file as well.\n\nadd_filter( &#039;widget_text&#039;, &#039;shortcode_unautop&#039;);\nadd_filter( &#039;widget_text&#039;, &#039;do_shortcode&#039;);\n\n\/*\nTo use this in your WordPress Content area all you have to do it wrap it in a short code.\n\n[email]john.doe@mysite.com[\/email]\n\n*\/<\/code><\/pre>\n<p>I put a test in to write antispambot( $content ) to a text file. It is writing the encoded email address to the text file but the source code has the regular email address. I am using the shortcode [email]. This is in widget text.<\/p>\n<p>I checked using &#8220;Debug Bar Actions and Filters Addon&#8221; and the only callbacks on widget_text are:<\/p>\n<ul>\n<li>balanceTags<\/li>\n<li>shortcode_unautop<\/li>\n<li>do_shortcode<\/li>\n<\/ul>\n<p>Thank you in advance for all of your help.<\/p>\n","protected":false},"template":"","class_list":["post-7635062","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/7635062","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/7635062\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=7635062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}