Email Obfuscator

<?php
/*
Plugin Name: Email Obfuscator
Plugin URI: https://kimmo.no/email-obfuscator/
Description: This plugin obfuscates email addresses to protect them from spam-bots while still displaying them to human visitors.
Version: 1.0
Author: Kimmono
Author URI: https://kimmo.no
License: GPLv2 or later
Text Domain: email-obfuscator
*/

// Prevent direct access to the plugin file
if (!defined('ABSPATH')) {
    exit;
}

function eo_obfuscate_email($email) {
    $obfuscated_email = '';
    $length = strlen($email);

    for ($i = 0; $i < $length; $i++) {
        $obfuscated_email .= '&#' . ord($email[$i]) . ';';
    }

    return $obfuscated_email;
}

function eo_email_shortcode($atts, $content = null) {
    if (!is_email($content)) {
        return '';
    }

    $obfuscated_email = eo_obfuscate_email($content);

    return '<a href="mailto:' . $obfuscated_email . '">' . $obfuscated_email . '</a>';
}

add_shortcode('email', 'eo_email_shortcode');