-
-
Save dannygsmith/b5d79fb4e722eb80b9aaca9c5465b5b9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Creates a link for email and then hide email address from Spam Bots in HTML using a shortcode. | |
* [email][email protected][/email] | |
* | |
* @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 jdd_hide_email_shortcode( $atts, $content = null ) { | |
if ( ! is_email( $content ) ) { | |
return; | |
} | |
return '<a href="mailto:' . antispambot( $content ) . '">' . antispambot( $content ) . '</a>'; | |
} | |
add_shortcode( 'email', 'jdd_hide_email_shortcode' ); | |
// Enable shortcodes in text widgets | |
add_filter( 'widget_text','do_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment