/safemail

Hide email address from bots with Kirby CMS

Primary LanguagePHPMIT LicenseMIT

Kirby Safemail Plugin

This is a plugin for Kirby that prevents email address to be scanned by bots.

How it works?

Safemail replaces the @ and . characters in the href part with random generated texts. And changes it back on click. It also insterts extra characters on the text part, and replaces the @ and . characters with the correct ASCII codes to make it harder to recognize.

Installation

Put the safemail.php in /site/plugins.

Example usage

1. Kirbytext.

(safemail: hello@examaple.com)

It is compatible with email kirbytext as well.

(email: hello@eaxmaple.com)

Output:

<a href="mailto:helloI0GDKexampleYVVWYcom" onclick="this.href=this.href.replace(/I0GDK/,'@').replace(/YVVWY/,'.')">
hello<span style="display:none">I0GDK</span>&#64;example<span style="display:none">YVVWY</span>&#46;com
</a>

Please make sure that you are not using html() function on kirbytext(), otherwise the ASCII characters won't be displayed!

2. Fields

<?php echo $page->my_email()->safemail() ?>

3. Anywhere else

<?php echo safemail('hello@example.com'); ?>

4. Full featured examples

(safemail: hello@examaple.com text: Contact us title: Title for contact us class: email)

(email: hello@examaple.com text: Contact us title: Title for contact us class: email)
<?php echo $page->my_email()->safemail('Contact us', ' Title for contact us', 'email') ?>
<?php echo safemail('Contact us', ' Title for contact us', 'email') ?>

Parameters

  • email
  • text (optional, default: email): Displayed text
  • title (optional): Link title
  • class (optional): Extra classes

Author

David Vigvari

Credits

Amit Agarval