Skip to content

Instantly share code, notes, and snippets.

@mrwweb
Last active June 19, 2017 22:38
Show Gist options
  • Save mrwweb/0a1928b073edc9ec2eae to your computer and use it in GitHub Desktop.
Save mrwweb/0a1928b073edc9ec2eae to your computer and use it in GitHub Desktop.
Obfustcate Emails from Bots with WordPress Shortcode
<?php
// Hide Email from Spam Bots using a short code
// Place this in your functions.php file
//
// See: codex.wordpress.org/Function_Reference/antispambot
//
// Ex: [email]you@example.org[/email]
function mrw_hide_email( $atts , $content = null ) {
if ( ! is_email( $content ) ) {
return;
}
return '<a href="mailto:' . antispambot( $content ) . '">' . antispambot( $content ) . '</a>';
}
add_shortcode( 'email', 'mrw_hide_email' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment