Skip to content

Instantly share code, notes, and snippets.

@Steven-Rose
Created March 13, 2012 07:07
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 Steven-Rose/2027368 to your computer and use it in GitHub Desktop.
Save Steven-Rose/2027368 to your computer and use it in GitHub Desktop.
WP: Obfuscate email addresses
[mailto]email@yourdomain.com[/mailto]
function 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', 'mail_shortcode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment