Skip to content

Instantly share code, notes, and snippets.

@tahirtaous
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tahirtaous/cf0eb4357e2007eae436 to your computer and use it in GitHub Desktop.
Save tahirtaous/cf0eb4357e2007eae436 to your computer and use it in GitHub Desktop.
This is probably one of the most well-hidden functions in the WordPress codebase. This function aims to convert an email into HTML entities in order to mask email addresses from evil scrapers.
// Reference : https://www.cms2cms.com/blog/6-useful-yet-relatively-unknown-wordpress-functions/
// add this code to sidebar.php or anywhere you want to display email addess
// remove <?php and ?> if you are going to paste this in functions.php
// Tested WordPress 4.1 Jan 25 2015
<?php
$email = 'mymail@mail.com';
echo 'You can contact me at ' . antispambot( $email ) . ' any time';
?>
// above code will genereta following HTML
// You can contact me at mymail@mail.com any time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment