Version Description
- Fixed bug prefilled email address in input fields
- Added option protection text for encoded content (other than email addresses)
Download this release
Release Info
| Developer | freelancephp |
| Plugin | |
| Version | 1.4.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.3.0 to 1.4.0
- email-encoder-bundle.php +2 -2
- includes/.htaccess +1 -0
- includes/class-eeb-admin.php +19 -4
- includes/class-eeb-site.php +53 -52
- includes/template-functions.php +73 -72
- js/src/.htaccess +1 -0
- readme.txt +5 -1
email-encoder-bundle.php
CHANGED
|
@@ -4,7 +4,7 @@ Plugin Name: Email Encoder Bundle - Protect Email Address
|
|
| 4 |
Plugin URI: http://www.freelancephp.net/email-encoder-php-class-wp-plugin/
|
| 5 |
Description: Protect email addresses on your site and hide them from spambots by using an encoding method. Easy to use, flexible .
|
| 6 |
Author: Victor Villaverde Laan
|
| 7 |
-
Version: 1.
|
| 8 |
Author URI: http://www.freelancephp.net
|
| 9 |
License: Dual licensed under the MIT and GPL licenses
|
| 10 |
Text Domain: email-encoder-bundle
|
|
@@ -12,7 +12,7 @@ Domain Path: /languages
|
|
| 12 |
*/
|
| 13 |
|
| 14 |
// constants
|
| 15 |
-
if (!defined('EMAIL_ENCODER_BUNDLE_VERSION')) { define('EMAIL_ENCODER_BUNDLE_VERSION', '1.
|
| 16 |
if (!defined('EMAIL_ENCODER_BUNDLE_FILE')) { define('EMAIL_ENCODER_BUNDLE_FILE', __FILE__); }
|
| 17 |
if (!defined('EMAIL_ENCODER_BUNDLE_KEY')) { define('EMAIL_ENCODER_BUNDLE_KEY', 'WP_Email_Encoder_Bundle'); }
|
| 18 |
if (!defined('EMAIL_ENCODER_BUNDLE_DOMAIN')) { define('EMAIL_ENCODER_BUNDLE_DOMAIN', 'email-encoder-bundle'); }
|
| 4 |
Plugin URI: http://www.freelancephp.net/email-encoder-php-class-wp-plugin/
|
| 5 |
Description: Protect email addresses on your site and hide them from spambots by using an encoding method. Easy to use, flexible .
|
| 6 |
Author: Victor Villaverde Laan
|
| 7 |
+
Version: 1.4.0
|
| 8 |
Author URI: http://www.freelancephp.net
|
| 9 |
License: Dual licensed under the MIT and GPL licenses
|
| 10 |
Text Domain: email-encoder-bundle
|
| 12 |
*/
|
| 13 |
|
| 14 |
// constants
|
| 15 |
+
if (!defined('EMAIL_ENCODER_BUNDLE_VERSION')) { define('EMAIL_ENCODER_BUNDLE_VERSION', '1.4.0'); }
|
| 16 |
if (!defined('EMAIL_ENCODER_BUNDLE_FILE')) { define('EMAIL_ENCODER_BUNDLE_FILE', __FILE__); }
|
| 17 |
if (!defined('EMAIL_ENCODER_BUNDLE_KEY')) { define('EMAIL_ENCODER_BUNDLE_KEY', 'WP_Email_Encoder_Bundle'); }
|
| 18 |
if (!defined('EMAIL_ENCODER_BUNDLE_DOMAIN')) { define('EMAIL_ENCODER_BUNDLE_DOMAIN', 'email-encoder-bundle'); }
|
includes/.htaccess
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
| 1 |
+
deny from all
|
includes/class-eeb-admin.php
CHANGED
|
@@ -21,11 +21,13 @@ abstract class Eeb_Admin {
|
|
| 21 |
'method' => 'enc_ascii',
|
| 22 |
'encode_mailtos' => 1,
|
| 23 |
'encode_emails' => 0,
|
|
|
|
| 24 |
'filter_posts' => 1,
|
| 25 |
'filter_widgets' => 1,
|
| 26 |
'filter_comments' => 1,
|
| 27 |
'skip_posts' => '',
|
| 28 |
'protection_text' => '*protected email*',
|
|
|
|
| 29 |
'class_name' => 'mailto-link',
|
| 30 |
'filter_rss' => 1,
|
| 31 |
'remove_shortcodes_rss' => 1,
|
|
@@ -324,7 +326,11 @@ abstract class Eeb_Admin {
|
|
| 324 |
<span><?php _e('Protect mailto links, like f.e. <code><a href="info@myemail.com">My Email</a></code>', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 325 |
<br/><label><input type="checkbox" id="encode_emails" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[encode_emails]" value="1" <?php checked('1', (int) $options['encode_emails']); ?> disabled="disabled" />
|
| 326 |
<span><?php _e('Replace plain email addresses to protected mailto links.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 327 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
</label>
|
| 329 |
<br/>
|
| 330 |
</td>
|
|
@@ -405,9 +411,18 @@ abstract class Eeb_Admin {
|
|
| 405 |
</tr>
|
| 406 |
<tr>
|
| 407 |
<th><?php _e('Set <code><noscript></code> text', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 408 |
-
<td><label
|
| 409 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 410 |
</label>
|
|
|
|
|
|
|
| 411 |
</td>
|
| 412 |
</tr>
|
| 413 |
<tr>
|
|
@@ -653,7 +668,7 @@ abstract class Eeb_Admin {
|
|
| 653 |
. ' echo eeb_email_filter(\'Some content with email like info@somedomein.com or a mailto link\');' . "\n"
|
| 654 |
. '}' . "\n"
|
| 655 |
. '?></code></pre>'
|
| 656 |
-
. '<p>You can pass a few extra optional params (in this order): <code>enc_tags</code>, <code>enc_mailtos</code>, <code>enc_plain_emails</code></p>'
|
| 657 |
. '<h4>eeb_form()</h4>'
|
| 658 |
. '<p>Create an encoder form:</p>'
|
| 659 |
. '<pre><code><?php' . "\n"
|
| 21 |
'method' => 'enc_ascii',
|
| 22 |
'encode_mailtos' => 1,
|
| 23 |
'encode_emails' => 0,
|
| 24 |
+
'encode_fields' => 1,
|
| 25 |
'filter_posts' => 1,
|
| 26 |
'filter_widgets' => 1,
|
| 27 |
'filter_comments' => 1,
|
| 28 |
'skip_posts' => '',
|
| 29 |
'protection_text' => '*protected email*',
|
| 30 |
+
'protection_text_content' => '*protected content*',
|
| 31 |
'class_name' => 'mailto-link',
|
| 32 |
'filter_rss' => 1,
|
| 33 |
'remove_shortcodes_rss' => 1,
|
| 326 |
<span><?php _e('Protect mailto links, like f.e. <code><a href="info@myemail.com">My Email</a></code>', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 327 |
<br/><label><input type="checkbox" id="encode_emails" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[encode_emails]" value="1" <?php checked('1', (int) $options['encode_emails']); ?> disabled="disabled" />
|
| 328 |
<span><?php _e('Replace plain email addresses to protected mailto links.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 329 |
+
<!--<span class="description notice-form-field-bug"><br/><?php _e('Notice: be carefull with this option when using email addresses on form fields, please <a href="http://wordpress.org/extend/plugins/email-encoder-bundle/faq/" target="_blank">check the FAQ</a> for more info.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>-->
|
| 330 |
+
</label>
|
| 331 |
+
<br/><label><input type="checkbox" id="encode_fields" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[encode_fields]" value="1" <?php checked('1', (int) $options['encode_fields']); ?> />
|
| 332 |
+
<span><?php _e('Replace prefilled email addresses in input fields.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 333 |
+
<span class="description"><?php _e(' - Recommended!', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 334 |
</label>
|
| 335 |
<br/>
|
| 336 |
</td>
|
| 411 |
</tr>
|
| 412 |
<tr>
|
| 413 |
<th><?php _e('Set <code><noscript></code> text', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 414 |
+
<td><label>
|
| 415 |
+
<span><?php _e('For encoded emails:', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 416 |
+
<br/><input type="text" id="protection_text" class="regular-text" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[protection_text]" value="<?php echo $options['protection_text']; ?>" />
|
| 417 |
+
</label>
|
| 418 |
+
<br/>
|
| 419 |
+
<br/>
|
| 420 |
+
<label>
|
| 421 |
+
<span><?php _e('For other encoded content:', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 422 |
+
<br/><input type="text" id="protection_text_content" class="regular-text" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[protection_text_content]" value="<?php echo $options['protection_text_content']; ?>" />
|
| 423 |
</label>
|
| 424 |
+
<br/>
|
| 425 |
+
<br/><span class="description"><?php _e('Used as <code><noscript></code> fallback for JavaScrip methods.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 426 |
</td>
|
| 427 |
</tr>
|
| 428 |
<tr>
|
| 668 |
. ' echo eeb_email_filter(\'Some content with email like info@somedomein.com or a mailto link\');' . "\n"
|
| 669 |
. '}' . "\n"
|
| 670 |
. '?></code></pre>'
|
| 671 |
+
. '<p>You can pass a few extra optional params (in this order): <code>enc_tags</code>, <code>enc_mailtos</code>, <code>enc_plain_emails</code>, <code>enc_input_fields</code></p>'
|
| 672 |
. '<h4>eeb_form()</h4>'
|
| 673 |
. '<p>Create an encoder form:</p>'
|
| 674 |
. '<pre><code><?php' . "\n"
|
includes/class-eeb-site.php
CHANGED
|
@@ -31,6 +31,7 @@ final class Eeb_Site extends Eeb_Admin {
|
|
| 31 |
private $regexp_patterns = array(
|
| 32 |
'mailto' => '/<a([^<>]*?)href=["\']mailto:(.*?)["\'](.*?)>(.*?)<\/a[\s+]*>/is',
|
| 33 |
'email' => '/([A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6})/is',
|
|
|
|
| 34 |
);
|
| 35 |
|
| 36 |
/**
|
|
@@ -172,7 +173,7 @@ CSS;
|
|
| 172 |
return $content;
|
| 173 |
}
|
| 174 |
|
| 175 |
-
return $this->encode_email_filter($content, true, $this->options['encode_mailtos'], $this->options['encode_emails']);
|
| 176 |
}
|
| 177 |
|
| 178 |
/**
|
|
@@ -204,9 +205,15 @@ CSS;
|
|
| 204 |
* @param boolean $enc_tags Optional, default true
|
| 205 |
* @param boolean $enc_mailtos Optional, default true
|
| 206 |
* @param boolean $enc_plain_emails Optional, default true
|
|
|
|
| 207 |
* @return string
|
| 208 |
*/
|
| 209 |
-
public function encode_email_filter($content, $enc_tags = true, $enc_mailtos = true, $enc_plain_emails = true) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
// encode mailto links
|
| 211 |
if ($enc_mailtos) {
|
| 212 |
$content = preg_replace_callback($this->regexp_patterns['mailto'], array($this, 'callback_encode_email'), $content);
|
|
@@ -218,10 +225,7 @@ CSS;
|
|
| 218 |
}
|
| 219 |
|
| 220 |
// workaround for double encoding bug when auto-protect mailto is enabled and method is enc_html
|
| 221 |
-
|
| 222 |
-
// change back to html tag
|
| 223 |
-
$content = str_replace('[a-replacement]', '<a', $content);
|
| 224 |
-
}
|
| 225 |
|
| 226 |
return $content;
|
| 227 |
}
|
|
@@ -233,12 +237,37 @@ CSS;
|
|
| 233 |
*/
|
| 234 |
public function callback_encode_email($match) {
|
| 235 |
if (count($match) < 3) {
|
| 236 |
-
|
| 237 |
} else if (count($match) == 3) {
|
| 238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
}
|
| 240 |
|
| 241 |
-
return $
|
| 242 |
}
|
| 243 |
|
| 244 |
/* -------------------------------------------------------------------------
|
|
@@ -275,10 +304,7 @@ CSS;
|
|
| 275 |
$encoded = $this->encode_email($email, $display, $extra_attrs, $method);
|
| 276 |
|
| 277 |
// workaround for double encoding bug when auto-protect mailto is enabled and method is enc_html
|
| 278 |
-
|
| 279 |
-
// change html tag to entity
|
| 280 |
-
$encoded = str_replace('<a', '[a-replacement]', $encoded);
|
| 281 |
-
}
|
| 282 |
|
| 283 |
return $encoded;
|
| 284 |
}
|
|
@@ -299,46 +325,24 @@ CSS;
|
|
| 299 |
* Encode Functions
|
| 300 |
* -------------------------------------------------------------------------/
|
| 301 |
|
| 302 |
-
|
| 303 |
-
/**
|
| 304 |
-
* Encode the link text to support UTF8 caracter
|
| 305 |
-
* Solution found @ http://php.net/manual/en/function.utf8-decode.php#85034
|
| 306 |
-
* @param string $string
|
| 307 |
-
* @return string
|
| 308 |
-
*/
|
| 309 |
-
|
| 310 |
-
function charset_decode_utf_8 ($string) {
|
| 311 |
-
/* Only do the slow convert if there are 8-bit characters */
|
| 312 |
-
/* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
|
| 313 |
-
if (! preg_match("[\200-\237]", $string) and ! preg_match("[\241-\377]", $string))
|
| 314 |
-
return $string;
|
| 315 |
-
|
| 316 |
-
// decode three byte unicode characters
|
| 317 |
-
$string = preg_replace("/([\340-\357])([\200-\277])([\200-\277])/e", "'&#'.((ord('\\1')-224)*4096 + (ord('\\2')-128)*64 + (ord('\\3')-128)).';'", $string);
|
| 318 |
-
|
| 319 |
-
// decode two byte unicode characters
|
| 320 |
-
$string = preg_replace("/([\300-\337])([\200-\277])/e", "'&#'.((ord('\\1')-192)*64+(ord('\\2')-128)).';'", $string);
|
| 321 |
-
|
| 322 |
-
return $string;
|
| 323 |
-
}
|
| 324 |
-
|
| 325 |
/**
|
| 326 |
* Encode the given email into an encoded HTML link
|
| 327 |
* @param string $content
|
| 328 |
* @param string $method Optional, else the default setted method will; be used
|
| 329 |
-
* @param boolean $no_html_checked
|
|
|
|
| 330 |
* @return string
|
| 331 |
*/
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
|
| 337 |
// get encode method
|
| 338 |
$method = $this->get_method($method, $this->method);
|
| 339 |
|
| 340 |
// get encoded email code
|
| 341 |
-
$content = $this->{$method}($content);
|
| 342 |
|
| 343 |
// add visual check
|
| 344 |
if ($no_html_checked !== true) {
|
|
@@ -389,7 +393,7 @@ CSS;
|
|
| 389 |
$mailto = $this->get_success_check($mailto);
|
| 390 |
}
|
| 391 |
} else {
|
| 392 |
-
$mailto = $this->encode_content($mailto, $method, $no_html_checked);
|
| 393 |
}
|
| 394 |
|
| 395 |
// get encoded email code
|
|
@@ -418,19 +422,15 @@ CSS;
|
|
| 418 |
* Different Encoding Methods
|
| 419 |
* ------------------------------------------------------------------------*/
|
| 420 |
|
| 421 |
-
//public function encodeURIComponent($str) {
|
| 422 |
-
// $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')');
|
| 423 |
-
// return strtr(rawurlencode($str), $revert);
|
| 424 |
-
//}
|
| 425 |
-
|
| 426 |
/**
|
| 427 |
* ASCII method
|
| 428 |
* Based on function from Tyler Akins (http://rumkin.com/tools/mailto_encoder/)
|
| 429 |
*
|
| 430 |
* @param string $value
|
|
|
|
| 431 |
* @return string
|
| 432 |
*/
|
| 433 |
-
private function enc_ascii($value) {
|
| 434 |
$mail_link = $value;
|
| 435 |
|
| 436 |
// first encode, so special chars can be supported
|
|
@@ -469,7 +469,7 @@ CSS;
|
|
| 469 |
. '}document.write(decodeURIComponent(o));' // decode at the end, this way special chars can be supported
|
| 470 |
. '}());'
|
| 471 |
. '</script><noscript>'
|
| 472 |
-
. $
|
| 473 |
. '</noscript>';
|
| 474 |
}
|
| 475 |
|
|
@@ -489,9 +489,10 @@ CSS;
|
|
| 489 |
* Taken from the plugin "Email Spam Protection" by Adam Hunter (http://blueberryware.net/2008/09/14/email-spam-protection/)
|
| 490 |
*
|
| 491 |
* @param string $value
|
|
|
|
| 492 |
* @return string
|
| 493 |
*/
|
| 494 |
-
private function enc_escape($value) {
|
| 495 |
$string = 'document.write(\'' . $value . '\')';
|
| 496 |
|
| 497 |
// break string into array of characters, we can't use string_split because its php5 only
|
|
@@ -506,7 +507,7 @@ CSS;
|
|
| 506 |
}
|
| 507 |
|
| 508 |
$out .= "'))" . '</script><noscript>'
|
| 509 |
-
. $
|
| 510 |
. '</noscript>';
|
| 511 |
|
| 512 |
return $out;
|
| 31 |
private $regexp_patterns = array(
|
| 32 |
'mailto' => '/<a([^<>]*?)href=["\']mailto:(.*?)["\'](.*?)>(.*?)<\/a[\s+]*>/is',
|
| 33 |
'email' => '/([A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6})/is',
|
| 34 |
+
'input' => '/<input([^>]*)value=["\'][\s+]*([A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6})[\s+]*["\']([^>]*)>/is',
|
| 35 |
);
|
| 36 |
|
| 37 |
/**
|
| 173 |
return $content;
|
| 174 |
}
|
| 175 |
|
| 176 |
+
return $this->encode_email_filter($content, true, $this->options['encode_mailtos'], $this->options['encode_emails'], $this->options['encode_fields']);
|
| 177 |
}
|
| 178 |
|
| 179 |
/**
|
| 205 |
* @param boolean $enc_tags Optional, default true
|
| 206 |
* @param boolean $enc_mailtos Optional, default true
|
| 207 |
* @param boolean $enc_plain_emails Optional, default true
|
| 208 |
+
* @param boolean $enc_input_fields Optional, default true
|
| 209 |
* @return string
|
| 210 |
*/
|
| 211 |
+
public function encode_email_filter($content, $enc_tags = true, $enc_mailtos = true, $enc_plain_emails = true, $enc_input_fields = true) {
|
| 212 |
+
// encode input fields with prefilled email address
|
| 213 |
+
if ($enc_input_fields) {
|
| 214 |
+
$content = preg_replace_callback($this->regexp_patterns['input'], array($this, 'callback_encode_input_field'), $content);
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
// encode mailto links
|
| 218 |
if ($enc_mailtos) {
|
| 219 |
$content = preg_replace_callback($this->regexp_patterns['mailto'], array($this, 'callback_encode_email'), $content);
|
| 225 |
}
|
| 226 |
|
| 227 |
// workaround for double encoding bug when auto-protect mailto is enabled and method is enc_html
|
| 228 |
+
$content = str_replace('[a-replacement]', '<a', $content);
|
|
|
|
|
|
|
|
|
|
| 229 |
|
| 230 |
return $content;
|
| 231 |
}
|
| 237 |
*/
|
| 238 |
public function callback_encode_email($match) {
|
| 239 |
if (count($match) < 3) {
|
| 240 |
+
$encoded = $this->encode_email($match[1]);
|
| 241 |
} else if (count($match) == 3) {
|
| 242 |
+
$encoded = $this->encode_email($match[2]);
|
| 243 |
+
} else {
|
| 244 |
+
$encoded = $this->encode_email($match[2], $match[4], $match[1] . ' ' . $match[3]);
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
// workaround for double encoding bug when auto-protect mailto is enabled and method is enc_html
|
| 248 |
+
$encoded = str_replace('<a', '[a-replacement]', $encoded);
|
| 249 |
+
|
| 250 |
+
return $encoded;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
/**
|
| 254 |
+
* Callback for encoding input field with email address
|
| 255 |
+
* @param array $match
|
| 256 |
+
* @return string
|
| 257 |
+
*/
|
| 258 |
+
public function callback_encode_input_field($match) {
|
| 259 |
+
if ($this->method === 'enc_html') {
|
| 260 |
+
// enc_html method
|
| 261 |
+
$email = $match[2];
|
| 262 |
+
$encoded_email = $this->enc_html($email);
|
| 263 |
+
|
| 264 |
+
$encoded = str_replace($email , $encoded_email, $match[0]);
|
| 265 |
+
$encoded = $this->get_success_check($encoded);
|
| 266 |
+
} else {
|
| 267 |
+
$encoded = $this->encode_content($match[0]);
|
| 268 |
}
|
| 269 |
|
| 270 |
+
return $encoded;
|
| 271 |
}
|
| 272 |
|
| 273 |
/* -------------------------------------------------------------------------
|
| 304 |
$encoded = $this->encode_email($email, $display, $extra_attrs, $method);
|
| 305 |
|
| 306 |
// workaround for double encoding bug when auto-protect mailto is enabled and method is enc_html
|
| 307 |
+
$encoded = str_replace('<a', '[a-replacement]', $encoded);
|
|
|
|
|
|
|
|
|
|
| 308 |
|
| 309 |
return $encoded;
|
| 310 |
}
|
| 325 |
* Encode Functions
|
| 326 |
* -------------------------------------------------------------------------/
|
| 327 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
/**
|
| 329 |
* Encode the given email into an encoded HTML link
|
| 330 |
* @param string $content
|
| 331 |
* @param string $method Optional, else the default setted method will; be used
|
| 332 |
+
* @param boolean $no_html_checked Optional
|
| 333 |
+
* @param string $protection_text Optional
|
| 334 |
* @return string
|
| 335 |
*/
|
| 336 |
+
public function encode_content($content, $method = null, $no_html_checked = false, $protection_text = null) {
|
| 337 |
+
if ($protection_text === null) {
|
| 338 |
+
$protection_text = $this->options['protection_text_content'];
|
| 339 |
+
}
|
| 340 |
|
| 341 |
// get encode method
|
| 342 |
$method = $this->get_method($method, $this->method);
|
| 343 |
|
| 344 |
// get encoded email code
|
| 345 |
+
$content = $this->{$method}($content, $protection_text);
|
| 346 |
|
| 347 |
// add visual check
|
| 348 |
if ($no_html_checked !== true) {
|
| 393 |
$mailto = $this->get_success_check($mailto);
|
| 394 |
}
|
| 395 |
} else {
|
| 396 |
+
$mailto = $this->encode_content($mailto, $method, $no_html_checked, $this->options['protection_text']);
|
| 397 |
}
|
| 398 |
|
| 399 |
// get encoded email code
|
| 422 |
* Different Encoding Methods
|
| 423 |
* ------------------------------------------------------------------------*/
|
| 424 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 425 |
/**
|
| 426 |
* ASCII method
|
| 427 |
* Based on function from Tyler Akins (http://rumkin.com/tools/mailto_encoder/)
|
| 428 |
*
|
| 429 |
* @param string $value
|
| 430 |
+
* @param string $protection_text
|
| 431 |
* @return string
|
| 432 |
*/
|
| 433 |
+
private function enc_ascii($value, $protection_text) {
|
| 434 |
$mail_link = $value;
|
| 435 |
|
| 436 |
// first encode, so special chars can be supported
|
| 469 |
. '}document.write(decodeURIComponent(o));' // decode at the end, this way special chars can be supported
|
| 470 |
. '}());'
|
| 471 |
. '</script><noscript>'
|
| 472 |
+
. $protection_text
|
| 473 |
. '</noscript>';
|
| 474 |
}
|
| 475 |
|
| 489 |
* Taken from the plugin "Email Spam Protection" by Adam Hunter (http://blueberryware.net/2008/09/14/email-spam-protection/)
|
| 490 |
*
|
| 491 |
* @param string $value
|
| 492 |
+
* @param string $protection_text
|
| 493 |
* @return string
|
| 494 |
*/
|
| 495 |
+
private function enc_escape($value, $protection_text) {
|
| 496 |
$string = 'document.write(\'' . $value . '\')';
|
| 497 |
|
| 498 |
// break string into array of characters, we can't use string_split because its php5 only
|
| 507 |
}
|
| 508 |
|
| 509 |
$out .= "'))" . '</script><noscript>'
|
| 510 |
+
. $protection_text
|
| 511 |
. '</noscript>';
|
| 512 |
|
| 513 |
return $out;
|
includes/template-functions.php
CHANGED
|
@@ -1,72 +1,73 @@
|
|
| 1 |
-
<?php defined('ABSPATH') OR die('No direct access.');
|
| 2 |
-
|
| 3 |
-
/**
|
| 4 |
-
* Template Functions
|
| 5 |
-
*
|
| 6 |
-
* @package Email_Encoder_Bundle
|
| 7 |
-
* @category WordPress Plugins
|
| 8 |
-
*/
|
| 9 |
-
if (!is_admin()):
|
| 10 |
-
|
| 11 |
-
/**
|
| 12 |
-
* Template function for encoding email
|
| 13 |
-
* @global Eeb_Site $Eeb_Site
|
| 14 |
-
* @param string $email
|
| 15 |
-
* @param string $display if non given will be same as email
|
| 16 |
-
* @param string $extra_attrs Optional
|
| 17 |
-
* @param string $method Optional, else the default setted method will; be used
|
| 18 |
-
* @return string
|
| 19 |
-
*/
|
| 20 |
-
if (!function_exists('eeb_email')):
|
| 21 |
-
function eeb_email($email, $display = null, $extra_attrs = '', $method = null) {
|
| 22 |
-
global $Eeb_Site;
|
| 23 |
-
return $Eeb_Site->encode_email($email, $display, $extra_attrs, $method);
|
| 24 |
-
}
|
| 25 |
-
endif;
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
/**
|
| 29 |
-
* Template function for encoding content
|
| 30 |
-
* @global Eeb_Site $Eeb_Site
|
| 31 |
-
* @param string $content
|
| 32 |
-
* @param string $method Optional, default null
|
| 33 |
-
* @return string
|
| 34 |
-
*/
|
| 35 |
-
if (!function_exists('eeb_content')):
|
| 36 |
-
function eeb_content($content, $method = null) {
|
| 37 |
-
global $Eeb_Site;
|
| 38 |
-
return $Eeb_Site->encode_content($content, $method);
|
| 39 |
-
}
|
| 40 |
-
endif;
|
| 41 |
-
|
| 42 |
-
/**
|
| 43 |
-
* Template function for encoding emails in the given content
|
| 44 |
-
* @global Eeb_Site $Eeb_Site
|
| 45 |
-
* @param string $content
|
| 46 |
-
* @param boolean $enc_tags Optional, default true
|
| 47 |
-
* @param boolean $enc_mailtos Optional, default true
|
| 48 |
-
* @param boolean $enc_plain_emails Optional, default true
|
| 49 |
-
* @
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
*
|
| 61 |
-
* @
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
| 1 |
+
<?php defined('ABSPATH') OR die('No direct access.');
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Template Functions
|
| 5 |
+
*
|
| 6 |
+
* @package Email_Encoder_Bundle
|
| 7 |
+
* @category WordPress Plugins
|
| 8 |
+
*/
|
| 9 |
+
if (!is_admin()):
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Template function for encoding email
|
| 13 |
+
* @global Eeb_Site $Eeb_Site
|
| 14 |
+
* @param string $email
|
| 15 |
+
* @param string $display if non given will be same as email
|
| 16 |
+
* @param string $extra_attrs Optional
|
| 17 |
+
* @param string $method Optional, else the default setted method will; be used
|
| 18 |
+
* @return string
|
| 19 |
+
*/
|
| 20 |
+
if (!function_exists('eeb_email')):
|
| 21 |
+
function eeb_email($email, $display = null, $extra_attrs = '', $method = null) {
|
| 22 |
+
global $Eeb_Site;
|
| 23 |
+
return $Eeb_Site->encode_email($email, $display, $extra_attrs, $method);
|
| 24 |
+
}
|
| 25 |
+
endif;
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Template function for encoding content
|
| 30 |
+
* @global Eeb_Site $Eeb_Site
|
| 31 |
+
* @param string $content
|
| 32 |
+
* @param string $method Optional, default null
|
| 33 |
+
* @return string
|
| 34 |
+
*/
|
| 35 |
+
if (!function_exists('eeb_content')):
|
| 36 |
+
function eeb_content($content, $method = null) {
|
| 37 |
+
global $Eeb_Site;
|
| 38 |
+
return $Eeb_Site->encode_content($content, $method);
|
| 39 |
+
}
|
| 40 |
+
endif;
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Template function for encoding emails in the given content
|
| 44 |
+
* @global Eeb_Site $Eeb_Site
|
| 45 |
+
* @param string $content
|
| 46 |
+
* @param boolean $enc_tags Optional, default true
|
| 47 |
+
* @param boolean $enc_mailtos Optional, default true
|
| 48 |
+
* @param boolean $enc_plain_emails Optional, default true
|
| 49 |
+
* @param boolean $enc_input_fields Optional, default true
|
| 50 |
+
* @return string
|
| 51 |
+
*/
|
| 52 |
+
if (!function_exists('eeb_email_filter')):
|
| 53 |
+
function eeb_email_filter($content, $enc_tags = true, $enc_mailtos = true, $enc_plain_emails = true, $enc_input_fields = true) {
|
| 54 |
+
global $Eeb_Site;
|
| 55 |
+
return $Eeb_Site->encode_email_filter($content, $enc_tags, $enc_mailtos, $enc_plain_emails, $enc_input_fields);
|
| 56 |
+
}
|
| 57 |
+
endif;
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Template function for getting HTML of the encoder form (to put it on the site)
|
| 61 |
+
* @global Eeb_Site $Eeb_Site
|
| 62 |
+
* @return string
|
| 63 |
+
*/
|
| 64 |
+
if (!function_exists('eeb_form')):
|
| 65 |
+
function eeb_form() {
|
| 66 |
+
global $Eeb_Site;
|
| 67 |
+
return $Eeb_Site->get_encoder_form();
|
| 68 |
+
}
|
| 69 |
+
endif;
|
| 70 |
+
|
| 71 |
+
endif;
|
| 72 |
+
|
| 73 |
+
/* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
|
js/src/.htaccess
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
| 1 |
+
deny from all
|
readme.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: freelancephp
|
|
| 3 |
Tags: email address, protect, antispam, mailto, spambot, secure, e-mail, email, mail, obfuscate, encode, encoder, encrypt, hide, bot, crawl, spider, robots, spam, protection, harvest, harvesting, security
|
| 4 |
Requires at least: 3.4.0
|
| 5 |
Tested up to: 4.1.1
|
| 6 |
-
Stable tag: 1.
|
| 7 |
|
| 8 |
Encode mailto links, email addresses, phone numbers and any text to hide them from (spam)bots. Mailto links will be protected automatically.
|
| 9 |
|
|
@@ -125,6 +125,10 @@ It's possible to filter all widgets by using the [Widget Logic Plugin](https://w
|
|
| 125 |
|
| 126 |
== Changelog ==
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
= 1.3.0 =
|
| 129 |
* Also support special chars for the javascript methods, like é, â, ö, Chinese chars etcetera
|
| 130 |
* Fixed bug unchecking options "use shortcode" and "use deprecated"
|
| 3 |
Tags: email address, protect, antispam, mailto, spambot, secure, e-mail, email, mail, obfuscate, encode, encoder, encrypt, hide, bot, crawl, spider, robots, spam, protection, harvest, harvesting, security
|
| 4 |
Requires at least: 3.4.0
|
| 5 |
Tested up to: 4.1.1
|
| 6 |
+
Stable tag: 1.4.0
|
| 7 |
|
| 8 |
Encode mailto links, email addresses, phone numbers and any text to hide them from (spam)bots. Mailto links will be protected automatically.
|
| 9 |
|
| 125 |
|
| 126 |
== Changelog ==
|
| 127 |
|
| 128 |
+
= 1.4.0 =
|
| 129 |
+
* Fixed bug prefilled email address in input fields
|
| 130 |
+
* Added option protection text for encoded content (other than email addresses)
|
| 131 |
+
|
| 132 |
= 1.3.0 =
|
| 133 |
* Also support special chars for the javascript methods, like é, â, ö, Chinese chars etcetera
|
| 134 |
* Fixed bug unchecking options "use shortcode" and "use deprecated"
|
