WP Manifestindependent plugin directory
manifest / utilities / cgit-wp-obfuscator

Castlegate IT WP Obfuscator archived

Automatically obfuscate email links in content, excerpts, and elsewhere

by Castlegate IT · github.com/castlegateit/cgit-wp-obfuscator · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/castlegateit/cgit-wp-obfuscator/archive/refs/heads/master.zip

Readme

Castlegate IT WP Obfuscator

Castlegate IT WP Obfuscator is a WordPress plugin that automatically obfuscates email addresses in the main content and excerpts of posts and pages by randomly replacing characters with HTML character entities.

The plugin provides two functions that can be used in your plugin or theme:

  • cgit_obfuscate($str) returns an obfuscated version of the string $str.
  • cgit_obfuscate_link($email, $text) returns a complete mailto: link to the email address $email. You can use $text to set the text of the link; otherwise it defaults to $email (also obfuscated).

You can also use the Obfuscator and ContentObfuscator classes directly to obfuscate individual strings and email addresses within content respectively:

$obfuscator = new \Cgit\Obfuscator\Obfuscator('example@example.com');
echo $obfuscator->obfuscate(); // obfuscated string
echo $obfuscator->obfuscateLink(); // obfuscated HTML email link
$obfuscator = new \Cgit\Obfuscator\ContentObfuscator($foo);
echo $obfuscator->obfuscate(); // HTML content with email addresses obfuscated

You can add attributes to links as associative arrays, for example:

echo cgit_obfuscate_link('example@example.com', 'email me', [
    'class' => 'email-link',
]);

License

Released under the MIT License. See LICENSE for details.

Read the full README on GitHub →