WordPress.org

Ready to get started?Download WordPress

Forums

Plugin to scramble email links? (4 posts)

  1. jumbo
    Member
    Posted 9 years ago #

    Is there any plugin/hack that will scramble/encode email addresses to protect from spambots?
    I wouldn't even mind doing something such as this:

    Thanks.

  2. Beel
    Member
    Posted 9 years ago #

    Here is what I use:
    <?php echo encodeEmail('usernam@whatever.net?subject=From WP page', 'E-mail', 'email', '<img src="image.gif" alt="E-mail Me!" />');
    function encodeEmail($_email,$_emailText,$_emailCSS, $_emailImg)
    {
    $_encodedEmail = '';
    for($i = 0; $i < strlen($_email); $i++)
    {
    $_check = htmlentities($_email[$i],ENT_QUOTES);
    $_email[$i] == $_check ? $_encodedEmail .= '&#'. ord($_email[$i]). ';' : $_encodedEmail .= $_check;
    }
    if(trim($_emailImg != ''))
    {
    $_viewEmail = ' href="mailto:' . $_encodedEmail . '" class="' . $_emailCSS . '" title="' . $_emailText . '">' . $_emailImg . '';
    }
    elseif(trim($_emailText == ''))
    {
    $_emailText = $_encodedEmail;
    $_viewEmail = ' href="mailto:' . $_encodedEmail . '" class="' . $_emailCSS . '" title="' . $_emailText . '">' . $_emailText . '';
    }
    elseif(trim($_emailText != ''))
    {
    $_viewEmail = ' href="mailto:' . $_encodedEmail . '" class="' . $_emailCSS . '" title="' . $_emailText . '">' . $_emailText . '';
    }
    return $_viewEmail;
    }
    ?>

  3. jumbo
    Member
    Posted 9 years ago #

    Thanks Beel, but I'm talking about scrambling the address within a post. I want WP to scan over the entry and any time an email address is "detected" it will be scrambled automatically; the same way double line breaks are converted to paragraph tags.

  4. Beel
    Member
    Posted 9 years ago #

    Well, take that on as a project and make a filter out of it.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.