Skip to content

Instantly share code, notes, and snippets.

@Steven-Rose
Created March 13, 2012 07:07
Show Gist options
  • 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 protected][/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