Last active
June 19, 2017 22:38
-
-
Save mrwweb/0a1928b073edc9ec2eae to your computer and use it in GitHub Desktop.
Obfustcate Emails from Bots with WordPress Shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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