Plugin screenshot thumbnail 1/1

Obfuscator

This plugin adds Twig filters to help you obfuscate email addresses (or any other content) in your templates.

This helps in thwarting spam bots that might crawl your website looking for email addresses to add to their mailing lists. The encoding logic is based on Dan Benjamin’s Hivelogic Enkoder.

Usage

The following Twig snippet will produce HTML where both the plain text email, and the mailto: anchor tag are recognised as emails and obfuscated.

{% apply enkode_emails %}
    Reach us on me@example.com or
    <a href="mailto:anotherme@example.com">here</a>.
{% endapply %}

It will result in something like this (re-formatted for readability):

Reach us on

<span id="enkoder_1_2033799978">email hidden; JavaScript is required</span>
<script id="script_enkoder_1_2033799978" type="text/javascript"> /* <!-- */
function hivelogic_enkoder_1_2033799978() { … } hivelogic_enkoder_1_2033799978();
/* --> */ </script>

or

<span id="enkoder_0_1540754146">email hidden; JavaScript is required</span>
<script id="script_enkoder_0_1540754146" type="text/javascript"> /* <!-- */
function hivelogic_enkoder_0_1540754146() { … } hivelogic_enkoder_0_1540754146();
/* --> */ </script>.

More Filters

In addition to the enkode_emails filter, Obfuscator comes with a bunch of additional filters for more fine grained targeting of what to obfuscate.

{{
    'Reach us on me@example.com or <a href="mailto:anotherme@example.com">here</a>.' |
    enkode_emails
}}

{{ '<a href="mailto:me@example.com">Contact Us</a>' | enkode_mailtos }}

{{ 'Contact us at me@example.com.' | enkode_plaintext_emails }}

{{ 'I don’t want spam bots to read this.' | enkode }}

{{
    'If you don’t have JavaScript, you’ll see a helpful message.' |
    enkode('JavaScript is required to view this message.')
}}
Installation Instructions

To install this plugin, copy the command above to your terminal.

Active Installs
1,342
Version
1.1.1
License
MIT
Compatibility
Craft 3, Craft 4
Last release
July 19, 2022
Activity (30 days)
0
Closed Issues
1
Open Issues
0
Merged PRs
0
Open PRs