Email Encoder Bundle – Protect Email Address - Version 0.60

Version Description

  • Added hook "init_email_encoder_form" to add custom filters (of other plugins)
  • Added JavaScript code encapsulation for ASCII method
  • Solved reinstalling bug for setting right encoding method
  • Solved bug shortcodes encoded with HTML method
Download this release

Release Info

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

Code changes from version 0.50 to 0.60

Files changed (2) hide show
  1. email-encoder-bundle.php +18 -12
  2. readme.txt +56 -27
email-encoder-bundle.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Email Encoder Bundle
4
  Plugin URI: http://www.freelancephp.net/email-encoder-php-class-wp-plugin/
5
  Description: Protect email addresses on your site from spambots and being used for spamming by using one of the encoding methods.
6
  Author: Victor Villaverde Laan
7
- Version: 0.50
8
  Author URI: http://www.freelancephp.net
9
  License: Dual licensed under the MIT and GPL licenses
10
  */
@@ -20,7 +20,7 @@ class WP_Email_Encoder_Bundle {
20
  * Current version
21
  * @var string
22
  */
23
- var $version = '0.50';
24
 
25
  /**
26
  * Used as prefix for options entry and could be used as text domain (for translations)
@@ -38,7 +38,7 @@ class WP_Email_Encoder_Bundle {
38
  * @var array
39
  */
40
  var $options = array(
41
- 'method' => 'lim_email_ascii',
42
  'encode_mailtos' => 1,
43
  'encode_emails' => 0,
44
  'skip_posts' => '',
@@ -199,6 +199,8 @@ class WP_Email_Encoder_Bundle {
199
  }
200
  }
201
 
 
 
202
  }
203
 
204
  /**
@@ -687,6 +689,8 @@ class WP_Email_Encoder_Bundle {
687
  // set email as display
688
  if ($display === NULL) {
689
  $display = $email;
 
 
690
  }
691
 
692
  // get encode method
@@ -742,12 +746,14 @@ class WP_Email_Encoder_Bundle {
742
  $mail_indices = str_replace("\"", "\\\"", $mail_indices);
743
 
744
  return '<script type="text/javascript">/*<![CDATA[*/'
745
- . 'ML="'. $mail_letters_enc .'";'
746
- . 'MI="'. $mail_indices .'";'
747
- . 'OT="";'
748
- . 'for(j=0;j<MI.length;j++){'
749
  . 'OT+=ML.charAt(MI.charCodeAt(j)-48);'
750
- . '}document.write(OT);/*]]>*/</script><noscript>'
 
 
 
751
  . $this->options['protection_text']
752
  . '</noscript>';
753
  }
@@ -789,18 +795,18 @@ class WP_Email_Encoder_Bundle {
789
  * @return string
790
  */
791
  function enc_html($value) {
792
- // check if antispambot WordPress function exists
793
  if (function_exists('antispambot')) {
794
  $enc_value = antispambot($value);
795
  } else {
796
  $enc_value = '';
797
- srand( (float) microtime() * 1000000);
798
 
799
  for ($i = 0; $i < strlen($value); $i = $i + 1) {
800
- $j = floor( rand( 0, 1 ));
801
 
802
  if ($j == 0) {
803
- $enc_value .= '&#' . ord( substr($value, $i, 1 ) ).';';
804
  } elseif ($j == 1) {
805
  $enc_value .= substr($value, $i, 1);
806
  }
4
  Plugin URI: http://www.freelancephp.net/email-encoder-php-class-wp-plugin/
5
  Description: Protect email addresses on your site from spambots and being used for spamming by using one of the encoding methods.
6
  Author: Victor Villaverde Laan
7
+ Version: 0.60
8
  Author URI: http://www.freelancephp.net
9
  License: Dual licensed under the MIT and GPL licenses
10
  */
20
  * Current version
21
  * @var string
22
  */
23
+ var $version = '0.60';
24
 
25
  /**
26
  * Used as prefix for options entry and could be used as text domain (for translations)
38
  * @var array
39
  */
40
  var $options = array(
41
+ 'method' => 'enc_ascii',
42
  'encode_mailtos' => 1,
43
  'encode_emails' => 0,
44
  'skip_posts' => '',
199
  }
200
  }
201
 
202
+ // action hook
203
+ do_action('init_email_encoder_bundle', array($this, 'filter_callback'));
204
  }
205
 
206
  /**
689
  // set email as display
690
  if ($display === NULL) {
691
  $display = $email;
692
+ } else {
693
+ $display = html_entity_decode($display);
694
  }
695
 
696
  // get encode method
746
  $mail_indices = str_replace("\"", "\\\"", $mail_indices);
747
 
748
  return '<script type="text/javascript">/*<![CDATA[*/'
749
+ . '(function(){'
750
+ . 'var ML="'. $mail_letters_enc .'", MI="'. $mail_indices .'", OT="";'
751
+ . 'for(var j=0;j<MI.length;j++){'
 
752
  . 'OT+=ML.charAt(MI.charCodeAt(j)-48);'
753
+ . '}document.write(OT);'
754
+ . '}());'
755
+ . '/*]]>*/'
756
+ . '</script><noscript>'
757
  . $this->options['protection_text']
758
  . '</noscript>';
759
  }
795
  * @return string
796
  */
797
  function enc_html($value) {
798
+ // check for built-in WP function
799
  if (function_exists('antispambot')) {
800
  $enc_value = antispambot($value);
801
  } else {
802
  $enc_value = '';
803
+ srand((float) microtime() * 1000000);
804
 
805
  for ($i = 0; $i < strlen($value); $i = $i + 1) {
806
+ $j = floor(rand( 0, 1 ));
807
 
808
  if ($j == 0) {
809
+ $enc_value .= '&#' . ord(substr($value, $i, 1)) . ';';
810
  } elseif ($j == 1) {
811
  $enc_value .= substr($value, $i, 1);
812
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: freelancephp
3
  Tags: email, hide, mailto, spam, protection, spambots, encoder, encrypt, encode, obfuscate, antispam, spamming
4
  Requires at least: 2.7.0
5
  Tested up to: 3.5.0
6
- Stable tag: 0.50
7
 
8
  Protect email addresses on your site from spambots and being used for spamming. This plugin encodes all email adresses so spambots cannot read them.
9
 
@@ -20,18 +20,39 @@ Protect email addresses on your site from spambots and being used for spamming.
20
  * Put an Email Encoder Form on your site
21
 
22
  = Tags =
23
- * `[encode_email email="..." display="..." method="..."]` Encode the given email, "display" is optional otherwise the email wil be used as display
24
- * `[encode_content method="..."]...[/encode_content]` Encode content, "method" is optional otherwise the method set in the admin options page
25
- * `[email_encoder_form]` Puts an encoder form in your post (check if the option is activated on this page)
 
 
 
 
 
26
 
27
  = Template functions =
28
- * `<?php echo encode_email( $email, [ $display ], [ $method ], [ $extra_attrs ] ); ?>` Encode the given email, the other params are optional
29
- * `<?php echo encode_content( $content, [ $method ] ); ?>` Encode the given content for emails to encode
30
- * `<?php echo encode_email_filter( $content, [ $enc_tags ], [ $enc_mailtos ], [ $enc_plain_emails ] ); ?>` Filter the given content for emails to encode, the other params are optional
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  = Support =
33
  Supports PHP4.3+ and up to latest WP version.
34
 
 
 
 
35
  == Installation ==
36
 
37
  1. Go to `Plugins` in the Admin menu
@@ -43,31 +64,42 @@ Supports PHP4.3+ and up to latest WP version.
43
 
44
  = How do I encode my emailaddress(es)? =
45
 
46
- By default the option `Encode mailto links` is enabled and the default method is `JavaScript ASCII`. This means the following html snippet:
 
 
 
47
  `<a href="mailto:myname@test.nl">My Email</a>`
48
 
49
- Will be encoded, which creates the following output in the source code of your page:
50
  `<script type="text/javascript">/*<![CDATA[*/ML="mo@k<insc:r.y=-Ehe a\">f/lMt";MI="4CB8HC77=D0C5HJ1>H563DB@:AF=D0C5HJ190<6C0A2JA7J;6HDBBJ5JHA=DI<B?0C5HDEI<B?0C5H4GCE";OT="";for(j=0;j<MI.length;j++){OT+=ML.charAt(MI.charCodeAt(j)-48);}document.write(OT);/*]]>*/</script><noscript>*protected email*</noscript>`
51
 
52
- Therefore spambots are not able to scan this emailaddress from the site.
53
-
54
- Within your posts, you can use the shortcode `[email_encode]`, f.e.:
55
- `[email_encode email="myname@test.nl" display="My Email"]`
56
 
57
  = Which encoding method should I use? =
58
 
59
- The `Html Encode` method uses the built-in function of WordPress and does not use any javascript.
60
- Although JavaScript methods (like `JavaScript ASCII`) are probably better protection against spambots.
61
 
62
  = How to create mailto links that opens in a new window? =
63
 
64
- You could use add extra params to the mailto link and add `target='_blank'`, f.e.:
65
  `[encode_email email="yourmail@test.nl" display="My Mail" extra_attrs="target='_blank'"]`
66
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  = How to encode emails in ALL widgets? =
68
 
69
- If the option 'All text widgets' is activated, only all widgets will be filtered for encoding.
70
- It's possible to encode emails in all widgets by using the Widget Logic plugin and activate the 'widget_content' filter.
71
 
72
  [Do you have another question? Please ask me](http://www.freelancephp.net/contact/)
73
 
@@ -78,6 +110,12 @@ It's possible to encode emails in all widgets by using the Widget Logic plugin a
78
 
79
  == Changelog ==
80
 
 
 
 
 
 
 
81
  = 0.50 =
82
  * Added encode method for all kind of contents (template function and shortcode "encode_content")
83
  * Added extra param for additional html attributes (f.e. target="_blank")
@@ -155,12 +193,3 @@ It's possible to encode emails in all widgets by using the Widget Logic plugin a
155
  * [Adam Hunter](http://blueberryware.net) for the encode method 'JavaScript Escape' which is taken from his plugin [Email Spam Protection](http://blueberryware.net/2008/09/14/email-spam-protection/)
156
  * [Tyler Akins](http://rumkin.com) for the encode method 'JavaScript ASCII Mixer'
157
  * Title icon on Admin Options Page was made by [Jack Cai](http://www.doublejdesign.co.uk/)
158
-
159
- == Upgrade Notice ==
160
-
161
- = 0.50 =
162
- * Added encode method for all kind of contents
163
- * Added extra param for additional html attributes
164
- * Added option to skip certain posts from being automatically encoded
165
- * Added option custom protection text
166
- * Notice: not possible to add your own methods anymore.
3
  Tags: email, hide, mailto, spam, protection, spambots, encoder, encrypt, encode, obfuscate, antispam, spamming
4
  Requires at least: 2.7.0
5
  Tested up to: 3.5.0
6
+ Stable tag: 0.60
7
 
8
  Protect email addresses on your site from spambots and being used for spamming. This plugin encodes all email adresses so spambots cannot read them.
9
 
20
  * Put an Email Encoder Form on your site
21
 
22
  = Tags =
23
+ Encode the given email, "display" is optional:
24
+ `[encode_email email="..." display="..."]`
25
+
26
+ Encode content, "method" is optional:
27
+ `[encode_content method="..."]...[/encode_content]`
28
+
29
+ Puts an encoder form in your post:
30
+ `[email_encoder_form]`
31
 
32
  = Template functions =
33
+ Encode the given email (other params are optional):
34
+ `<?php echo encode_email($email, [$display], [$method], [$extra_attrs]); ?>`
35
+
36
+ Encode the given content for emails to encode (other param is optional):
37
+ `<?php echo encode_content($content, [$method]); ?>`
38
+
39
+ Filter the given content for emails to encode (other params are optional):
40
+ `<?php echo encode_email_filter($content, [$enc_tags], [$enc_mailtos], [$enc_plain_emails]); ?>`
41
+
42
+ = Hooks =
43
+ Add extra code on initialize the Email Encoder Bundle (f.e. add extra filters for encoding):
44
+ `add_action('init_email_encoder_bundle', 'extra_encode_filters');
45
+
46
+ function extra_encode_filters($filter_callback) {
47
+ add_filter('some_filter', $filter_callback);
48
+ }`
49
 
50
  = Support =
51
  Supports PHP4.3+ and up to latest WP version.
52
 
53
+ = Contact =
54
+ [Send our comment](http://www.freelancephp.net/email-encoder-php-class-wp-plugin/)[ or question](http://www.freelancephp.net/contact/)
55
+
56
  == Installation ==
57
 
58
  1. Go to `Plugins` in the Admin menu
64
 
65
  = How do I encode my emailaddress(es)? =
66
 
67
+ In the posts you can use this shortcode:
68
+ `[email_encode email="myname@test.nl" display="My Email"]`
69
+
70
+ By default the option `Encode mailto links` and that means this of html snippet will also be encoded:
71
  `<a href="mailto:myname@test.nl">My Email</a>`
72
 
73
+ The default method is `JavaScript ASCII` the following output will be created in the source code of the page:
74
  `<script type="text/javascript">/*<![CDATA[*/ML="mo@k<insc:r.y=-Ehe a\">f/lMt";MI="4CB8HC77=D0C5HJ1>H563DB@:AF=D0C5HJ190<6C0A2JA7J;6HDBBJ5JHA=DI<B?0C5HDEI<B?0C5H4GCE";OT="";for(j=0;j<MI.length;j++){OT+=ML.charAt(MI.charCodeAt(j)-48);}document.write(OT);/*]]>*/</script><noscript>*protected email*</noscript>`
75
 
76
+ This code is not readable by spambots and protects your emailaddress.
 
 
 
77
 
78
  = Which encoding method should I use? =
79
 
80
+ The `Html Encode` method is a simple method. Probably JavaScript methods like JavaScript ASCII` would be a better protection against spambots.
 
81
 
82
  = How to create mailto links that opens in a new window? =
83
 
84
+ You could add extra params to the mailto link and add `target='_blank'` for opening them in a new window, like:
85
  `[encode_email email="yourmail@test.nl" display="My Mail" extra_attrs="target='_blank'"]`
86
 
87
+ = How can I encode content of BBPress plugin? =
88
+
89
+ If you use other plugins that needs to be encoded you can add a callback to the action "init_email_encoder_bundle".
90
+ For Example:
91
+
92
+ `add_action('init_email_encoder_bundle', 'extra_encode_filters');
93
+
94
+ function extra_encode_filters($filter_callback) {
95
+ add_filter('bbp_get_reply_content', $filter_callback);
96
+ add_filter('bbp_get_topic_content', $filter_callback);
97
+ }`
98
+
99
  = How to encode emails in ALL widgets? =
100
 
101
+ If the option 'All text widgets' is activated, only text widgets will be filtered for encoding.
102
+ It's possible to filter all widgets by using the Widget Logic plugin and activate the 'widget_content' filter.
103
 
104
  [Do you have another question? Please ask me](http://www.freelancephp.net/contact/)
105
 
110
 
111
  == Changelog ==
112
 
113
+ = 0.60 =
114
+ * Added hook "init_email_encoder_form" to add custom filters (of other plugins)
115
+ * Added JavaScript code encapsulation for ASCII method
116
+ * Solved reinstalling bug for setting right encoding method
117
+ * Solved bug shortcodes encoded with HTML method
118
+
119
  = 0.50 =
120
  * Added encode method for all kind of contents (template function and shortcode "encode_content")
121
  * Added extra param for additional html attributes (f.e. target="_blank")
193
  * [Adam Hunter](http://blueberryware.net) for the encode method 'JavaScript Escape' which is taken from his plugin [Email Spam Protection](http://blueberryware.net/2008/09/14/email-spam-protection/)
194
  * [Tyler Akins](http://rumkin.com) for the encode method 'JavaScript ASCII Mixer'
195
  * Title icon on Admin Options Page was made by [Jack Cai](http://www.doublejdesign.co.uk/)