CreaCaptcha

EmailObfuscator
in package

Obfuscates mailto: links and plain-text email addresses in front-end output. The real address is XOR-hex encoded into a data-cce attribute and restored client-side by the decoder script. Two modes share this class: the content-filter mode (process()) and the full-page-buffer mode (process_page()). See the module-7 and module-8 design specs.

Table of Contents

Methods

process()  : string
Content-filter callback. Returns the content unchanged when the feature is off or the context is admin/feed; otherwise obfuscates addresses and enqueues the decoder script.
process_page()  : string
Full-page-buffer entry — obfuscates addresses inside the page <body>.
encode()  : string
XOR-hex encodes a string: a random key byte followed by each byte of the value XOR-ed with that key, all two-digit hex. The result contains no "@" and no recognisable email structure.
obfuscate()  : string
The shared, script-safe obfuscation pass. Tokenises the HTML once, then encodes `mailto:` hrefs in tag segments and plain-text addresses in text segments; <script> and <style> blocks are skipped in both passes.

Methods

process()

Content-filter callback. Returns the content unchanged when the feature is off or the context is admin/feed; otherwise obfuscates addresses and enqueues the decoder script.

public process(mixed $content) : string
Parameters
$content : mixed

The content passed by the WordPress filter.

Return values
string

process_page()

Full-page-buffer entry — obfuscates addresses inside the page <body>.

public process_page(string $html) : string

The and everything outside is left untouched. Returns the HTML unchanged when no is present (e.g. a non-HTML response).

Parameters
$html : string

The full buffered page HTML.

Return values
string

encode()

XOR-hex encodes a string: a random key byte followed by each byte of the value XOR-ed with that key, all two-digit hex. The result contains no "@" and no recognisable email structure.

private encode(string $value) : string
Parameters
$value : string

The value to encode.

Return values
string

obfuscate()

The shared, script-safe obfuscation pass. Tokenises the HTML once, then encodes `mailto:` hrefs in tag segments and plain-text addresses in text segments; <script> and <style> blocks are skipped in both passes.

private obfuscate(string $html) : string
Parameters
$html : string

The HTML to process.

Return values
string

        
On this page

Search results