Skip to content

Instantly share code, notes, and snippets.

@nathaningram
Created November 13, 2015 20:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathaningram/e4223705b0efb5fb86da to your computer and use it in GitHub Desktop.
Save nathaningram/e4223705b0efb5fb86da to your computer and use it in GitHub Desktop.
Design to Builder Shortcodes for functions.php
//Anti-Spam Email Shortcode
//Use this shortcode [emailme]nathan@brilliantly.net[/emailme]
function protect_email_address( $atts , $content=null ) {
for ($i = 0; $i < strlen($content); $i++) $encodedmail .= "&#" . ord($content[$i]) . ';';
return '<a href="mailto:'.$encodedmail.'">'.$encodedmail.'</a>';
}
add_shortcode('emailme', 'protect_email_address');
//Current Year Shortcode
function year_shortcode() {
$year = date('Y');
return $year;
}
add_shortcode('year', 'year_shortcode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment