Skip to content

Instantly share code, notes, and snippets.

@derekshirk
Last active August 29, 2015 14:03
Show Gist options
  • Save derekshirk/cb420413281e272f7b74 to your computer and use it in GitHub Desktop.
Save derekshirk/cb420413281e272f7b74 to your computer and use it in GitHub Desktop.
WordPress - email cloaking function
<?php
$my_email_address = "my.secret.email.address@gmail.com";
$my_email_address_cloaked = antispambot( $my_email_address );
echo $my_email_address_cloaked;
?>
// you can cloak email addresses anywhere in your posts wit this shortcode
<?php
function antispambot_sc( $atts ) {
extract( shortcode_atts( array(
'email' => ''
), $atts ) );
return antispambot( $email );
}
add_shortcode( 'antispambot', 'antispambot_sc' );
// Usage: [antispambot email="my.cloaked.email.address@gmail.com"]
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment