ten80snowboarder

Shortcode to Encode Email in WordPress Posts

May 4th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. /* If you code a page template directly, you can add the function like so: */
  2.  
  3. antispambot("youremail@yoursite.com");
  4.  
  5. /* A way to take advantage of the antispambot() function within posts and pages content */
  6. // EMAIL ENCODE SHORTCODE
  7. function email_encode_function( $atts, $content ){
  8.     return '<a href="'.antispambot("mailto:".$content).'">'.antispambot($content).'</a>';
  9. }
  10. add_shortcode( 'email', 'email_encode_function' );
  11.  
  12. /* Code snippet goes in function.php file.
  13.    Use the following structure to safely display an email address in your post or page content:
  14.  
  15.     [email]you@you.com[/email]
  16.  
  17.  */
Add Comment
Please, Sign In to add comment