Skip to content

Instantly share code, notes, and snippets.

@Pleiades
Created November 15, 2012 23:10
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 Pleiades/4082216 to your computer and use it in GitHub Desktop.
Save Pleiades/4082216 to your computer and use it in GitHub Desktop.
Obfuscate an Email Address
function munge_mail_shortcode( $atts , $content=null ) {
for ($i = 0; $i < strlen($content); $i++) $encodedmail .= "&#" . ord($content[$i]) . ';';
return '<a href="mailto:'.$encodedmail.'">'.$encodedmail.'</a>';
}
add_shortcode('mailto', 'munge_mail_shortcode');
[mailto]myemail@example.com[/mailto]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment