A community library of hooks for Pure Blog.

Email Obfuscation

Author: Kev Quirk |  Hook: on_filter_content

Encodes the email address set in your Pure Blog site settings as HTML entities throughout your post content, making it harder for scrapers to harvest.

Requires site_email to be set in your Pure Blog settings — if it's blank, the hook does nothing.

function on_filter_content(string $content): string
{
    $config = load_config();
    $email  = trim((string) ($config['site_email'] ?? ''));
    if ($email === '') {
        return $content;
    }

    $encoded = implode('', array_map(fn($c) => '&#x' . dechex(ord($c)) . ';', str_split($email)));
    return str_replace($email, $encoded, $content);
}

← Back to all hooks