The WordPress Email Spambot Short Code encodes email address when placed inside the short code.
Usage Example:
[email]myemail@mydomain.com[/email]
Code to hide email addresses from spambots:
/** HIDE EMAIL FROM SPAM BOTS USING A SHORTCODE. */
function wpcodex_hide_email_shortcode( $atts , $content = null ) {
if ( ! is_email( $content ) ) {
return;
}
return '<a href="mailto:' . antispambot( $content ) . '">' . antispambot( $content ) . '</a>';
}
add_shortcode( 'email', 'wpcodex_hide_email_shortcode' );
add_filter( 'widget_text', 'shortcode_unautop' );
add_filter( 'widget_text', 'do_shortcode' );
Share Your Two Cents