Skip to content

Instantly share code, notes, and snippets.

@jkudish
Forked from robertdall/emailshortcode.php
Created December 7, 2012 17:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jkudish/4235056 to your computer and use it in GitHub Desktop.
Save jkudish/4235056 to your computer and use it in GitHub Desktop.
Email Short Code
<?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' );
@robertdall
Copy link

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… 

@chrismccoy
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment