Spam-safe email address shortcode
Type [email]you@example.com[/email] to show a clickable email address that’s scrambled in the page code, so address-harvesting bots can’t read it.
<?php
// [email]you@example.com[/email]
$email = sanitize_email( (string) $content );
if ( ! is_email( $email ) ) {
return '';
}
return '<a href="' . esc_attr( 'mailto:' . antispambot( $email ) ) . '">' . esc_html( antispambot( $email ) ) . '</a>';
How to use it
Type [email] in a post, a page or a Shortcode block.
In these packs
- Shortcodes: Handy shortcodes for dates, breadcrumbs, buttons, share links, members-only content and more.