Email Encoder Bundle – Protect Email Address - Version 1.4.1

Version Description

  • Fixed preserving classes on mailto links
Download this release

Release Info

Developer freelancephp
Plugin Icon 128x128 Email Encoder Bundle – Protect Email Address
Version 1.4.1
Comparing to
See all releases

Code changes from version 1.4.0 to 1.4.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.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,17 +12,20 @@ Domain Path: /languages
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'); }
19
  if (!defined('EMAIL_ENCODER_BUNDLE_OPTIONS_NAME')) { define('EMAIL_ENCODER_BUNDLE_OPTIONS_NAME', 'WP_Email_Encoder_Bundle_options'); }
20
  if (!defined('EMAIL_ENCODER_BUNDLE_ADMIN_PAGE')) { define('EMAIL_ENCODER_BUNDLE_ADMIN_PAGE', 'email-encoder-bundle-settings'); }
21
 
 
 
 
 
 
22
  // check plugin compatibility
23
- if (isset($wp_version)
24
- && version_compare(preg_replace('/-.*$/', '', $wp_version), '3.4', '>=')
25
- && version_compare(phpversion(), '5.2.4', '>=')) {
26
 
27
  // include classes
28
  require_once('includes/class-eeb-admin.php');
@@ -51,7 +54,7 @@ if (isset($wp_version)
51
  $plugin_title = get_admin_page_title();
52
 
53
  echo '<div class="error">'
54
- . sprintf(__('<p>Warning - The plugin <strong>%s</strong> requires PHP 5.2.4+ and WP 3.4+. Please upgrade your PHP and/or WordPress.'
55
  . '<br/>Disable the plugin to remove this message.</p>'
56
  , EMAIL_ENCODER_BUNDLE_DOMAIN), $plugin_title)
57
  . '</div>';
@@ -61,5 +64,3 @@ if (isset($wp_version)
61
  endif;
62
 
63
  }
64
-
65
- /* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
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.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
  */
13
 
14
  // constants
15
+ if (!defined('EMAIL_ENCODER_BUNDLE_VERSION')) { define('EMAIL_ENCODER_BUNDLE_VERSION', '1.4.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'); }
19
  if (!defined('EMAIL_ENCODER_BUNDLE_OPTIONS_NAME')) { define('EMAIL_ENCODER_BUNDLE_OPTIONS_NAME', 'WP_Email_Encoder_Bundle_options'); }
20
  if (!defined('EMAIL_ENCODER_BUNDLE_ADMIN_PAGE')) { define('EMAIL_ENCODER_BUNDLE_ADMIN_PAGE', 'email-encoder-bundle-settings'); }
21
 
22
+ // wp_version var was used by older WP versions
23
+ if (!isset($wp_version)) {
24
+ $wp_version = get_bloginfo('version');
25
+ }
26
+
27
  // check plugin compatibility
28
+ if (version_compare($wp_version, '3.6', '>=') && version_compare(phpversion(), '5.2.4', '>=')) {
 
 
29
 
30
  // include classes
31
  require_once('includes/class-eeb-admin.php');
54
  $plugin_title = get_admin_page_title();
55
 
56
  echo '<div class="error">'
57
+ . sprintf(__('<p>Warning - The plugin <strong>%s</strong> requires PHP 5.2.4+ and WP 3.6+. Please upgrade your PHP and/or WordPress.'
58
  . '<br/>Disable the plugin to remove this message.</p>'
59
  , EMAIL_ENCODER_BUNDLE_DOMAIN), $plugin_title)
60
  . '</div>';
64
  endif;
65
 
66
  }
 
 
includes/class-eeb-site.php CHANGED
@@ -32,6 +32,7 @@ final class Eeb_Site extends Eeb_Admin {
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
  /**
@@ -145,16 +146,20 @@ final class Eeb_Site extends Eeb_Admin {
145
  * WP head
146
  */
147
  public function wp_head() {
148
- // add styling for encoding check message + icon
149
- if ($this->is_admin_user && $this->options['show_encoded_check']) {
150
- echo <<<CSS
151
- <style type="text/css">
152
- a.encoded-check { opacity:0.5; position:absolute; text-decoration:none !important; font:10px Arial !important; margin-top:-3px; color:#629632; font-weight:bold; }
153
- a.encoded-check:hover { opacity:1; cursor:help; }
154
- a.encoded-check img { width:10px; height:10px; }
155
- </style>
156
- CSS;
157
- }
 
 
 
 
158
  }
159
 
160
  /* -------------------------------------------------------------------------
@@ -383,9 +388,18 @@ CSS;
383
  $email = $this->enc_html($email);
384
  }
385
 
386
- $class = $this->options['class_name'];
387
  $extra_attrs = ' ' . trim($extra_attrs);
388
- $mailto = '<a class="'. $class .'" href="mailto:' . $email . '"'. $extra_attrs . '>' . $display . '</a>';
 
 
 
 
 
 
 
 
 
 
389
 
390
  if ($method === 'enc_html') {
391
  // add visual check
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
+ 'class' => '/class=["\'](.*?)["\']/i',
36
  );
37
 
38
  /**
146
  * WP head
147
  */
148
  public function wp_head() {
149
+ $css = '';
150
+ $css .= '<style type="text/css" media="screen">';
151
+
152
+ // add styling for encoding check message + icon
153
+ if ($this->is_admin_user && $this->options['show_encoded_check']) {
154
+ $css .= 'a.encoded-check { opacity:0.5; position:absolute; text-decoration:none !important; font:10px Arial !important; margin-top:-3px; color:#629632; font-weight:bold; }';
155
+ $css .= 'a.encoded-check:hover { opacity:1; cursor:help; }';
156
+ $css .= 'a.encoded-check img { width:10px; height:10px; }';
157
+ }
158
+
159
+ // $css .= 'a[href^="mailto:"] .fa { margin-right:0.4em; }';
160
+ $css .= '</style>';
161
+
162
+ echo $css;
163
  }
164
 
165
  /* -------------------------------------------------------------------------
388
  $email = $this->enc_html($email);
389
  }
390
 
 
391
  $extra_attrs = ' ' . trim($extra_attrs);
392
+
393
+ // add class
394
+ if (preg_match($this->regexp_patterns['class'], $extra_attrs, $matches)) {
395
+ // class attribute set
396
+ $extra_attrs = str_replace($matches[0], sprintf('class="%s"', $matches[1] . ' ' . $this->options['class_name']), $extra_attrs);
397
+ } else {
398
+ // class attribute not set
399
+ $extra_attrs .= ' class="' . $this->options['class_name'] . '"';
400
+ }
401
+
402
+ $mailto = '<a href="mailto:' . $email . '"'. $extra_attrs . '>' . $display . '</a>';
403
 
404
  if ($method === 'enc_html') {
405
  // add visual check
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Email Encoder Bundle - Protect Email Address ===
2
  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.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,6 +125,9 @@ It's possible to filter all widgets by using the [Widget Logic Plugin](https://w
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)
1
  === Email Encoder Bundle - Protect Email Address ===
2
  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.6.0
5
+ Tested up to: 4.2.2
6
+ Stable tag: 1.4.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
 
126
  == Changelog ==
127
 
128
+ = 1.4.1 =
129
+ * Fixed [preserving classes on mailto links](https://wordpress.org/support/topic/preserve-link-classes)
130
+
131
  = 1.4.0 =
132
  * Fixed bug prefilled email address in input fields
133
  * Added option protection text for encoded content (other than email addresses)