Last active
January 16, 2016 15:06
-
-
Save katlove/09187be6c39c78c0211f to your computer and use it in GitHub Desktop.
Encode Mailto Shortcode for WordPress
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 | |
| /** | |
| * Add a shortcode for mailto link | |
| * Use: [mailto][email protected][/mailto] | |
| */ | |
| function make_cool_mailto_shortcode( $atts , $content = null ) { | |
| for ($i = 0; $i < strlen($content); $i++) $encodedmail .= "&#" . ord($content[$i]) . ';'; | |
| return '<a href="mailto:'.$encodedmail.'">'.$encodedmail.'</a>'; | |
| } | |
| add_shortcode('mailto', 'make_cool_mailto_shortcode'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment