Last active
March 22, 2016 23:26
-
-
Save FriendlyWP/7164049 to your computer and use it in GitHub Desktop.
Mailto email obfuscation shortcode. For anti-spam (spam-bots, spam fix, email mailto).
This file contains hidden or 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
/* SHORTCODE FOR EMAIL OBFUSCATION | |
* usage: [email][email protected][/email] | |
* OR: [email address="[email protected]"]Contact Us[/email] | |
*/ | |
add_shortcode('email', 'emailbot_ssc'); | |
function emailbot_ssc($atts, $content = null) { | |
extract( shortcode_atts( array( | |
'address' => '', | |
), $atts ) ); | |
ob_start(); | |
if ( !isset($atts['address']) ) { | |
$address = $content; | |
} else { | |
$address = $atts['address']; | |
} | |
$email = '<a class="email_link" href="mailto:'.antispambot($address).'" target="_blank">'; | |
$email .= antispambot($content); | |
$email .= '</a>'; | |
$output = ob_get_clean(); | |
return $email . $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment