Email Encoder Bundle – Protect Email Address - Version 0.41

Version Description

  • Solved bug by improving regular expression for mailto links
  • Changed script attribute language to type
  • Script only loaded on options page (hopefully this solves the dashboard toggle problem some people are experiencing)
  • Added support for widget_content filter of the Logic Widget plugin
Download this release

Release Info

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

Code changes from version 0.40 to 0.41

Files changed (3) hide show
  1. email-encoder-bundle.php +37 -23
  2. methods/ascii.php +1 -1
  3. readme.txt +16 -2
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.40
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.40';
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' => NULL,
42
  'encode_mailtos' => 1,
43
  'encode_emails' => 1,
44
  'class_name' => 'mailto-link',
@@ -46,6 +46,7 @@ class WP_Email_Encoder_Bundle {
46
  'filter_widgets' => 1,
47
  'filter_comments' => 1,
48
  'filter_rss' => 1,
 
49
  'powered_by' => 1,
50
  );
51
 
@@ -54,7 +55,7 @@ class WP_Email_Encoder_Bundle {
54
  * @var array
55
  */
56
  var $regexp_patterns = array(
57
- 'mailto' => '/<a.*?href=["\']mailto:(.*?)["\'].*?>(.*?)<\/a[\s+]*>/is',
58
  'tag' => '/\[encode_email\s+(.*?)\]/is',
59
  'email' => '/([A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6})/is',
60
  );
@@ -91,7 +92,7 @@ class WP_Email_Encoder_Bundle {
91
  $this->_set_options();
92
 
93
  // load text domain for translations
94
- load_plugin_textdomain( $this->domain, dirname( __FILE__ ) . '/lang/', basename( dirname(__FILE__) ) . '/lang/' );
95
 
96
  // set uninstall hook
97
  if ( function_exists( 'register_deactivation_hook' ) )
@@ -103,7 +104,7 @@ class WP_Email_Encoder_Bundle {
103
  add_action( 'the_posts', array( $this, 'the_posts' ) );
104
 
105
  // set filters
106
- add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ), $priority );
107
  }
108
 
109
  /**
@@ -156,9 +157,8 @@ class WP_Email_Encoder_Bundle {
156
  add_filter( 'widget_title', array( $this, '_filter_callback' ), $priority );
157
  add_filter( 'widget_text', array( $this, '_filter_callback' ), $priority );
158
 
159
- // Only if Widget Logic plugin is installed
160
- // @todo Doesn't work and cannot find another way to filter all widget contents
161
- //add_filter( 'widget_content', array( $this, 'filter_content' ), $priority );
162
  }
163
  }
164
 
@@ -191,7 +191,7 @@ class WP_Email_Encoder_Bundle {
191
  * Callback admin_menu
192
  */
193
  function admin_menu() {
194
- if ( function_exists('add_options_page') AND current_user_can('manage_options') ) {
195
  // add options page
196
  $page = add_options_page( 'Email Encoder Bundle', 'Email Encoder Bundle',
197
  'manage_options', __FILE__, array( $this, 'options_page' ) );
@@ -205,12 +205,19 @@ class WP_Email_Encoder_Bundle {
205
  // register settings
206
  register_setting( $this->domain, $this->options_name );
207
 
208
- // set dashboard postbox
209
- wp_admin_css( 'dashboard' );
210
- wp_enqueue_script( 'dashboard' );
 
 
 
 
 
 
211
 
212
- // add style and script for ajax encoder
213
- wp_enqueue_script( 'email_encoder', plugins_url( 'js/email-encoder-bundle.js', __FILE__ ), array( 'jquery' ), $this->version );
 
214
  }
215
 
216
  /**
@@ -218,7 +225,7 @@ class WP_Email_Encoder_Bundle {
218
  */
219
  function options_page() {
220
  ?>
221
- <script language="javascript">
222
  jQuery(function( $ ){
223
  // remove message
224
  $( '.settings-error' )
@@ -273,7 +280,7 @@ jQuery(function( $ ){
273
  <div class="icon32" id="icon-options-custom" style="background:url( <?php echo plugins_url( 'images/icon-email-encoder-bundle.png', __FILE__ ) ?> ) no-repeat 50% 50%"><br></div>
274
  <h2>Email Encoder Bundle</h2>
275
 
276
- <script language="javascript">
277
  var methodInfo = <?php echo json_encode( $this->methods ) ?>;
278
  </script>
279
  <div class="postbox-container metabox-holder meta-box-sortables" style="width: 69%">
@@ -308,13 +315,13 @@ jQuery(function( $ ){
308
  <th><?php _e( 'Encode emails', $this->domain ) ?></th>
309
  <td>
310
  <label><input type="checkbox" name="<?php echo $this->options_name ?>[encode_tags]" value="1" checked="checked" disabled="disabled" />
311
- <span><?php _e( 'Encode <code>[encode_email]</code> tags', $this->domain ) ?></span>
312
  </label>
313
  <br/><label><input type="checkbox" id="encode_mailtos" name="<?php echo $this->options_name ?>[encode_mailtos]" value="1" <?php checked('1', (int) $options['encode_mailtos']); ?> />
314
- <span><?php _e( 'Encode mailto-links', $this->domain ) ?></span>
315
  </label>
316
  <br/><label><input type="checkbox" id="encode_emails" name="<?php echo $this->options_name ?>[encode_emails]" value="1" <?php checked('1', (int) $options['encode_emails']); ?> />
317
- <span><?php _e( 'Replace plain emailaddresses to encoded mailto-links', $this->domain ) ?></span>
318
  </label>
319
  </td>
320
  </tr>
@@ -326,12 +333,12 @@ jQuery(function( $ ){
326
  <tr>
327
  <th><?php _e( 'Options has effect on', $this->domain ) ?></th>
328
  <td><label><input type="checkbox" name="<?php echo $this->options_name ?>[filter_posts]" value="1" <?php checked('1', (int) $options['filter_posts']); ?> />
329
- <span><?php _e( 'Posts', $this->domain ) ?></span>
330
  </label>
331
  <br/><label><input type="checkbox" id="<?php echo $this->options_name ?>[filter_comments]" name="<?php echo $this->options_name ?>[filter_comments]" value="1" <?php checked('1', (int) $options['filter_comments']); ?> />
332
- <span><?php _e( 'Comments', $this->domain ) ?></span></label>
333
  <br/><label><input type="checkbox" id="<?php echo $this->options_name ?>[filter_widgets]" name="<?php echo $this->options_name ?>[filter_widgets]" value="1" <?php checked('1', (int) $options['filter_widgets']); ?> />
334
- <span><?php _e( 'Text widgets', $this->domain ) ?></span></label>
335
  </td>
336
  </tr>
337
  <tr>
@@ -558,7 +565,14 @@ jQuery(function( $ ){
558
  }
559
  }
560
 
 
561
  $this->set_method( $this->options['method'] );
 
 
 
 
 
 
562
  }
563
 
564
  /**
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.41
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.41';
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' => 'lim_email_ascii',
42
  'encode_mailtos' => 1,
43
  'encode_emails' => 1,
44
  'class_name' => 'mailto-link',
46
  'filter_widgets' => 1,
47
  'filter_comments' => 1,
48
  'filter_rss' => 1,
49
+ 'widget_content_filter' => 0,
50
  'powered_by' => 1,
51
  );
52
 
55
  * @var array
56
  */
57
  var $regexp_patterns = array(
58
+ 'mailto' => '/<a[^<>]*?href=["\']mailto:(.*?)["\'].*?>(.*?)<\/a[\s+]*>/is',
59
  'tag' => '/\[encode_email\s+(.*?)\]/is',
60
  'email' => '/([A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6})/is',
61
  );
92
  $this->_set_options();
93
 
94
  // load text domain for translations
95
+ load_plugin_textdomain( $this->domain, FALSE, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
96
 
97
  // set uninstall hook
98
  if ( function_exists( 'register_deactivation_hook' ) )
104
  add_action( 'the_posts', array( $this, 'the_posts' ) );
105
 
106
  // set filters
107
+ add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ), 10 );
108
  }
109
 
110
  /**
157
  add_filter( 'widget_title', array( $this, '_filter_callback' ), $priority );
158
  add_filter( 'widget_text', array( $this, '_filter_callback' ), $priority );
159
 
160
+ // Only if Widget Logic plugin is installed and 'widget_content' option is activated
161
+ add_filter( 'widget_content', array( $this, '_filter_callback' ), $priority );
 
162
  }
163
  }
164
 
191
  * Callback admin_menu
192
  */
193
  function admin_menu() {
194
+ if ( function_exists( 'add_options_page' ) AND current_user_can( 'manage_options' ) ) {
195
  // add options page
196
  $page = add_options_page( 'Email Encoder Bundle', 'Email Encoder Bundle',
197
  'manage_options', __FILE__, array( $this, 'options_page' ) );
205
  // register settings
206
  register_setting( $this->domain, $this->options_name );
207
 
208
+ // actions
209
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_print_scripts' ) );
210
+ }
211
+
212
+ function admin_print_scripts( $hook_suffix ) {
213
+ if( $hook_suffix == 'settings_page_email-encoder-bundle/email-encoder-bundle' ) {
214
+ // set dashboard postbox
215
+ wp_admin_css( 'dashboard' );
216
+ wp_enqueue_script( 'dashboard' );
217
 
218
+ // add style and script for ajax encoder
219
+ wp_enqueue_script( 'email_encoder', plugins_url( 'js/email-encoder-bundle.js', __FILE__ ), array( 'jquery' ), $this->version );
220
+ }
221
  }
222
 
223
  /**
225
  */
226
  function options_page() {
227
  ?>
228
+ <script type="text/javascript">
229
  jQuery(function( $ ){
230
  // remove message
231
  $( '.settings-error' )
280
  <div class="icon32" id="icon-options-custom" style="background:url( <?php echo plugins_url( 'images/icon-email-encoder-bundle.png', __FILE__ ) ?> ) no-repeat 50% 50%"><br></div>
281
  <h2>Email Encoder Bundle</h2>
282
 
283
+ <script type="text/javascript">
284
  var methodInfo = <?php echo json_encode( $this->methods ) ?>;
285
  </script>
286
  <div class="postbox-container metabox-holder meta-box-sortables" style="width: 69%">
315
  <th><?php _e( 'Encode emails', $this->domain ) ?></th>
316
  <td>
317
  <label><input type="checkbox" name="<?php echo $this->options_name ?>[encode_tags]" value="1" checked="checked" disabled="disabled" />
318
+ <span><?php _e( 'Encode <code>[encode_email]</code> shortcode', $this->domain ) ?></span>
319
  </label>
320
  <br/><label><input type="checkbox" id="encode_mailtos" name="<?php echo $this->options_name ?>[encode_mailtos]" value="1" <?php checked('1', (int) $options['encode_mailtos']); ?> />
321
+ <span><?php _e( 'Automatically encode mailto-links', $this->domain ) ?></span>
322
  </label>
323
  <br/><label><input type="checkbox" id="encode_emails" name="<?php echo $this->options_name ?>[encode_emails]" value="1" <?php checked('1', (int) $options['encode_emails']); ?> />
324
+ <span><?php _e( 'Automatically replace plain emailaddresses to encoded mailto-links', $this->domain ) ?></span>
325
  </label>
326
  </td>
327
  </tr>
333
  <tr>
334
  <th><?php _e( 'Options has effect on', $this->domain ) ?></th>
335
  <td><label><input type="checkbox" name="<?php echo $this->options_name ?>[filter_posts]" value="1" <?php checked('1', (int) $options['filter_posts']); ?> />
336
+ <span><?php _e( 'All posts', $this->domain ) ?></span>
337
  </label>
338
  <br/><label><input type="checkbox" id="<?php echo $this->options_name ?>[filter_comments]" name="<?php echo $this->options_name ?>[filter_comments]" value="1" <?php checked('1', (int) $options['filter_comments']); ?> />
339
+ <span><?php _e( 'All comments', $this->domain ) ?></span></label>
340
  <br/><label><input type="checkbox" id="<?php echo $this->options_name ?>[filter_widgets]" name="<?php echo $this->options_name ?>[filter_widgets]" value="1" <?php checked('1', (int) $options['filter_widgets']); ?> />
341
+ <span><?php if ( $this->options[ 'widget_logic_filter' ] ) { _e( 'All widgets (uses the widget_content filter of the Widget Logic plugin)', $this->domain ); } else { _e( 'All text widgets', $this->domain ); } ?></span></label>
342
  </td>
343
  </tr>
344
  <tr>
565
  }
566
  }
567
 
568
+ // set encode method
569
  $this->set_method( $this->options['method'] );
570
+
571
+ // set widget_content filter of Widget Logic plugin
572
+ $widget_logic_opts = get_option( 'widget_logic' );
573
+ if ( key_exists( 'widget_logic-options-filter', $widget_logic_opts ) ) {
574
+ $this->options[ 'widget_logic_filter' ] = ( $widget_logic_opts[ 'widget_logic-options-filter' ] == 'checked' ) ? 1 : 0;
575
+ }
576
  }
577
 
578
  /**
methods/ascii.php CHANGED
@@ -46,7 +46,7 @@ function lim_email_ascii( $email, $display, $obj ) {
46
  $MailIndexes = str_replace("\\", "\\\\", $MailIndexes);
47
  $MailIndexes = str_replace("\"", "\\\"", $MailIndexes);
48
 
49
- return '<script language="javascript">/*<![CDATA[*/'
50
  . 'ML="'. $MailLettersEnc .'";'
51
  . 'MI="'. $MailIndexes .'";'
52
  . 'OT="";'
46
  $MailIndexes = str_replace("\\", "\\\\", $MailIndexes);
47
  $MailIndexes = str_replace("\"", "\\\"", $MailIndexes);
48
 
49
+ return '<script type="text/javascript">/*<![CDATA[*/'
50
  . 'ML="'. $MailLettersEnc .'";'
51
  . 'MI="'. $MailIndexes .'";'
52
  . 'OT="";'
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  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.1
6
- Stable tag: 0.40
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
 
@@ -48,6 +48,11 @@ Supports PHP4.3+ and up to latest WP version.
48
  The `Html Encode` method uses the built-in function of WordPress and does not use any javascript.
49
  Although JavaScript methods (like `JavaScript ASCII`) are probably better protection against spambots.
50
 
 
 
 
 
 
51
  = I want to make some adjustment in one of the encoding methods. What is the best way? =
52
 
53
  The best way is to make a copy of that method and make your adjustments in the copy. Give the new method a unique name.
@@ -70,6 +75,12 @@ Optionally you can add a name and description to be showed in the admin panel, l
70
 
71
  == Changelog ==
72
 
 
 
 
 
 
 
73
  = 0.40 =
74
  * Added option for setting CSS classes
75
  * Improved RSS protection
@@ -133,6 +144,9 @@ Optionally you can add a name and description to be showed in the admin panel, l
133
 
134
  == Upgrade Notice ==
135
 
 
 
 
136
  = 0.40 =
137
  * Added option for setting CSS classes
138
  * Improved RSS protection
2
  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.1.3
6
+ Stable tag: 0.41
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
 
48
  The `Html Encode` method uses the built-in function of WordPress and does not use any javascript.
49
  Although JavaScript methods (like `JavaScript ASCII`) are probably better protection against spambots.
50
 
51
+ = How to encode emails in ALL widgets? =
52
+
53
+ If the option 'All text widgets' is activated, only all widgets will be filtered for encoding.
54
+ It's possible to encode emails in all widgets by using the Widget Logic plugin and activate the 'wodget_content' filter.
55
+
56
  = I want to make some adjustment in one of the encoding methods. What is the best way? =
57
 
58
  The best way is to make a copy of that method and make your adjustments in the copy. Give the new method a unique name.
75
 
76
  == Changelog ==
77
 
78
+ = 0.41 =
79
+ * Solved bug by improving regular expression for mailto links
80
+ * Changed script attribute `language` to `type`
81
+ * Script only loaded on options page (hopefully this solves the dashboard toggle problem some people are experiencing)
82
+ * Added support for widget_content filter of the Logic Widget plugin
83
+
84
  = 0.40 =
85
  * Added option for setting CSS classes
86
  * Improved RSS protection
144
 
145
  == Upgrade Notice ==
146
 
147
+ = 0.41 =
148
+ * Solved some issues
149
+
150
  = 0.40 =
151
  * Added option for setting CSS classes
152
  * Improved RSS protection