[email]...[/email] shortcode syntax using built-in Wordpress Codex functionality.
Author: Robert Peake
Author URI: http://www.peakepro.com/
Plugin URI: https://wordpress.org/plugins/antispambot
Text Domain: antispambot
Domain Path: /languages
*/
/**
* 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 wpcodex_hide_email_shortcode( $atts , $content = null ) {
if ( ! is_email( $content ) ) {
return $content;
}
extract( shortcode_atts( array(
'hex_encoding' => 0,
), $atts, 'antispambot' ) );
return '' . antispambot( $content, $hex_encoding ) . '';
}
add_shortcode( 'email', 'wpcodex_hide_email_shortcode' );