Skip to content

Instantly share code, notes, and snippets.

@dboutote
Created July 26, 2015 15:26
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 dboutote/4a76b3ad34b448d2afb6 to your computer and use it in GitHub Desktop.
Save dboutote/4a76b3ad34b448d2afb6 to your computer and use it in GitHub Desktop.
Hide email from Spam Bots using a shortcode. (WordPress theme)
<?php
/**
* Hide email from Spam Bots using a shortcode.
*
* @param array $atts Shortcode attributes. Not used.
* @param string $content The shortcode content. Should be an email address.
*
* @return string The obfuscated email address.
*/
function _ss_hide_email_shortcode( $atts , $content = null ) {
if ( ! is_email( $content ) ) {
return;
}
return antispambot( $content );
}
add_shortcode( 'email', '_ss_hide_email_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment