Skip to content

Instantly share code, notes, and snippets.

@tahirtaous
Last active August 29, 2015 14:14
Show Gist options
  • 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 = '[email protected]';
echo 'You can contact me at ' . antispambot( $email ) . ' any time';
?>
// above code will genereta following HTML
// You can contact me at [email protected] any time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment