This is a plugin for Kirby that prevents email address to be scanned by bots.
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.
Put the safemail.php
in /site/plugins
.
(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>@example<span style="display:none">YVVWY</span>.com
</a>
Please make sure that you are not using html() function on kirbytext(), otherwise the ASCII characters won't be displayed!
<?php echo $page->my_email()->safemail() ?>
<?php echo safemail('hello@example.com'); ?>
(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') ?>
- text (optional, default: email): Displayed text
- title (optional): Link title
- class (optional): Extra classes
David Vigvari