-
-
Save jkudish/4235056 to your computer and use it in GitHub Desktop.
Email Short Code
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 | |
function cwc_mail_shortcode( $atts , $content = null ) { | |
if ( ! is_email( $content ) ) | |
return; | |
for ( $i = 0; $i < strlen( $content ); $i++ ) | |
$encodedmail .= "&#" . ord( $content[$i] ) . ';'; | |
return '<a href="' . esc_url( 'mailto:' . $encodedmail ) . '">Email</a>'; | |
} | |
add_shortcode( 'email', 'cwc_mail_shortcode' ); |
Sorry I forgot to remove the image links when I uploaded it last night :-) That's what I get for multi-tasking and copy and pasting at the meetup…
you can use the http://codex.wordpress.org/Function_Reference/antispambot function as well
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Improved @robertdall's shortcode by:
$content
is an email address, and if not, just return out of the function, avoiding potential issues if it wasn't an email address