Email Encoder Bundle – Protect Email Address - Version 0.70

Version Description

(latest) = * Fixed bug with extra params * Changed texts and added help tabs on admin options page * Changed visual check for encoded mails/content by showing icon and success message * Solved that all attributes of mailto links remain when encoding

Download this release

Release Info

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

Code changes from version 0.60 to 0.70

email-encoder-bundle.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  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.60
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.60';
24
 
25
  /**
26
  * Used as prefix for options entry and could be used as text domain (for translations)
@@ -34,6 +34,11 @@ class WP_Email_Encoder_Bundle {
34
  */
35
  var $options_name = 'WP_Email_Encoder_Bundle_options';
36
 
 
 
 
 
 
37
  /**
38
  * @var array
39
  */
@@ -70,28 +75,14 @@ class WP_Email_Encoder_Bundle {
70
  /**
71
  * @var array
72
  */
73
- var $methods = array(
74
- 'enc_ascii' => array(
75
- 'name' => 'JavaScript ASCII',
76
- 'description' => 'Uses javascript (<a href="http://rumkin.com/tools/mailto_encoder/" target="_blank">original source</a>).',
77
- ),
78
- 'enc_escape' => array(
79
- 'name' => 'JavaScript Escape',
80
- 'description' => 'Uses javascript eval() function (<a href="http://blueberryware.net/2008/09/14/email-spam-protection/" target="_blank">original source</a>).',
81
- ),
82
- 'enc_html' => array(
83
- 'name' => 'Html Encode',
84
- 'description' => 'Email encode method using antispambot() built-in WordPress (<a href="http://codex.wordpress.org/Function_Reference/antispambot" target="_blank">more info</a>).',
85
- ),
86
- );
87
 
88
  /**
89
  * Regexp
90
  * @var array
91
  */
92
  var $regexp_patterns = array(
93
- 'mailto' => '/<a[^<>]*?href=["\']mailto:(.*?)["\'].*?>(.*?)<\/a[\s+]*>/is',
94
- 'tag' => '/\[encode_email\s+(.*?)\]/is',
95
  'email' => '/([A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6})/is',
96
  );
97
 
@@ -109,6 +100,26 @@ class WP_Email_Encoder_Bundle {
109
  // load text domain for translations
110
  load_plugin_textdomain($this->domain, FALSE, dirname(plugin_basename(__FILE__)) . '/lang/');
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  // set option values
113
  $this->set_options();
114
 
@@ -137,8 +148,6 @@ class WP_Email_Encoder_Bundle {
137
  global $user_ID;
138
  $this->logged_in = (bool) ($user_ID && current_user_can('level_10'));
139
 
140
- $priority = 100;
141
-
142
  // shortcodes
143
  add_shortcode('email_encoder_form', array($this, 'shortcode_email_encoder_form'));
144
  add_shortcode('encode_email', array($this, 'shortcode_encode_email'));
@@ -147,60 +156,47 @@ class WP_Email_Encoder_Bundle {
147
  if (is_feed()) {
148
  // rss feed
149
  if ($this->options['filter_rss']) {
150
- add_filter('the_title', array($this, 'filter_rss_callback'), $priority);
151
- add_filter('the_content', array($this, 'filter_rss_callback'), $priority);
152
- add_filter('the_excerpt', array($this, 'filter_rss_callback'), $priority);
153
- add_filter('the_title_rss', array($this, 'filter_rss_callback'), $priority);
154
- add_filter('the_content_rss', array($this, 'filter_rss_callback'), $priority);
155
- add_filter('the_excerpt_rss', array($this, 'filter_rss_callback'), $priority);
156
- add_filter('comment_text_rss', array($this, 'filter_rss_callback'), $priority);
157
- add_filter('comment_author_rss ', array($this, 'filter_rss_callback'), $priority);
158
- add_filter('the_category_rss ', array($this, 'filter_rss_callback'), $priority);
159
- add_filter('the_content_feed', array($this, 'filter_rss_callback'), $priority);
160
- add_filter('author feed link', array($this, 'filter_rss_callback'), $priority);
161
- add_filter('feed_link', array($this, 'filter_rss_callback'), $priority);
162
  }
163
  } else {
164
  // add style when logged in
165
  if ($this->logged_in) {
166
- add_action('wp_head', array($this, 'add_style'));
167
  }
168
 
 
 
169
  // post content
170
  if ($this->options['filter_posts']) {
171
- add_filter('the_title', array($this, 'filter_callback'), $priority);
172
- add_filter('the_content', array($this, 'filter_callback'), $priority);
173
- add_filter('the_excerpt', array($this, 'filter_callback'), $priority);
174
- add_filter('get_the_excerpt', array($this, 'filter_callback'), $priority);
175
  }
176
 
177
  // comments
178
  if ($this->options['filter_comments']) {
179
- add_filter('comment_text', array($this, 'filter_callback'), $priority);
180
- add_filter('comment_excerpt', array($this, 'filter_callback'), $priority);
181
- add_filter('comment_url', array($this, 'filter_callback'), $priority);
182
- add_filter('get_comment_author_url', array($this, 'filter_callback'), $priority);
183
- add_filter('get_comment_author_link', array($this, 'filter_callback'), $priority);
184
- add_filter('get_comment_author_url_link', array($this, 'filter_callback'), $priority);
185
  }
186
 
187
  // widgets
188
  if ($this->options['filter_widgets']) {
189
- // Only text widgets
190
- add_filter('widget_title', array($this, 'filter_callback'), $priority);
191
- add_filter('widget_text', array($this, 'filter_callback'), $priority);
192
- // also replace shortcodes
193
- add_filter('widget_text', 'do_shortcode', $priority);
194
 
195
- // Only if Widget Logic plugin is installed and 'widget_content' option is activated
196
- add_filter('widget_content', array($this, 'filter_callback'), $priority);
197
  // also replace shortcodes
198
- add_filter('widget_content', 'do_shortcode', $priority);
 
 
 
 
 
199
  }
200
  }
201
 
202
  // action hook
203
- do_action('init_email_encoder_bundle', array($this, 'filter_callback'));
204
  }
205
 
206
  /**
@@ -220,7 +216,7 @@ class WP_Email_Encoder_Bundle {
220
  * @return string
221
  */
222
  function shortcode_encode_email($attrs) {
223
- if (!key_exists('email', $attrs)) {
224
  return '';
225
  }
226
 
@@ -239,17 +235,19 @@ class WP_Email_Encoder_Bundle {
239
  * @return string
240
  */
241
  function shortcode_encode_content($attrs, $content = '') {
242
- $method = (key_exists('method', $attrs)) ? $attrs['method'] : NULL;
243
 
244
  return $this->encode($content, $method);
245
  }
246
 
247
  /**
248
- * Add style for encoded mails when logged in
249
  */
250
- function add_style() {
251
  echo '<style type="text/css">' . "\n";
252
- echo '.' . $this->domain . ' { background: #f00 !important; display: inline !important; }' . "\n";
 
 
253
  echo '</style>' . "\n";
254
  }
255
 
@@ -283,11 +281,106 @@ class WP_Email_Encoder_Bundle {
283
  function admin_menu() {
284
  if (function_exists('add_options_page') AND current_user_can('manage_options')) {
285
  // add options page
286
- $page = add_options_page('Email Encoder Bundle', 'Email Encoder Bundle',
287
  'manage_options', __FILE__, array($this, 'options_page'));
 
 
 
288
  }
289
  }
290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
  /**
292
  * admin_init action
293
  */
@@ -333,7 +426,7 @@ class WP_Email_Encoder_Bundle {
333
  ?>
334
  <div class="wrap">
335
  <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>
336
- <h2>Email Encoder Bundle</h2>
337
 
338
  <script type="text/javascript">
339
  var methodInfo = <?php echo json_encode($this->methods) ?>;
@@ -351,58 +444,61 @@ class WP_Email_Encoder_Bundle {
351
  $options = $this->options;
352
  ?>
353
  <?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php') ): ?>
354
- <p class="description"><?php _e('Warning: "WP Mailto Links"-plugin is also activated, which could cause conflicts.', $this->domain ) ?></p>
355
  <?php endif; ?>
356
  <fieldset class="options">
357
  <table class="form-table">
358
  <tr>
359
- <th><?php _e('Choose encoding method', $this->domain ) ?></th>
360
- <td><label><select id="<?php echo $this->options_name ?>[method]" name="<?php echo $this->options_name ?>[method]" class="method-info-select postform">
361
  <?php foreach ($this->methods AS $method => $info ): ?>
362
  <option value="<?php echo $method ?>" <?php if ($this->method == $method ) echo 'selected="selected"' ?>><?php echo $info['name']; if ($method == 'lim_email_ascii'){ echo ' (recommended)'; } ?></option>
363
  <?php endforeach; ?>
364
- <option value="random" <?php if ($this->method == 'random') echo 'selected="selected"' ?>><?php echo __('Random', $this->domain ) ?></option>
365
  </select>
366
- <span class="description"></span></label>
 
367
  </td>
368
  </tr>
369
  <tr>
370
- <th><?php _e('Automatically encode emails', $this->domain ) ?></th>
371
  <td>
 
 
 
 
372
  <label><input type="checkbox" id="encode_mailtos" name="<?php echo $this->options_name ?>[encode_mailtos]" value="1" <?php checked('1', (int) $options['encode_mailtos']); ?> />
373
- <span><?php _e('Encode mailto-links', $this->domain ) ?></span>
374
  </label>
375
  <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']); ?> />
376
- <span><?php _e('Replace plain emailaddresses to encoded mailto-links', $this->domain ) ?></span> <span class="description"><?php _e('(NOT recommended)', $this->domain ) ?></span>
377
  </label>
 
 
 
 
 
 
 
 
 
 
378
  <br/>
379
  <label>
380
- <span><?php _e('Skip posts with ID:', $this->domain ) ?></span>
381
  <input type="text" id="<?php echo $this->options_name ?>[skip_posts]" name="<?php echo $this->options_name ?>[skip_posts]" value="<?php echo $options['skip_posts']; ?>" />
382
- <span class="description"><?php _e('(comma seperated, f.e.: 2, 7, 13, 32)', $this->domain ) ?></span>
383
  </label>
384
  </td>
385
  </tr>
386
  <tr>
387
- <th><?php _e('Set class for mailto-links', $this->domain ) ?></th>
388
  <td><label><input type="text" id="<?php echo $this->options_name ?>[class_name]" name="<?php echo $this->options_name ?>[class_name]" value="<?php echo $options['class_name']; ?>" />
389
- <span class="description"><?php _e('Set class-attribute for encoded mailto links <em>(optional)</em>', $this->domain ) ?></span></label></td>
390
  </tr>
391
  <tr>
392
- <th><?php _e('Options has effect on', $this->domain ) ?></th>
393
- <td><label><input type="checkbox" name="<?php echo $this->options_name ?>[filter_posts]" value="1" <?php checked('1', (int) $options['filter_posts']); ?> />
394
- <span><?php _e('All posts', $this->domain ) ?></span>
395
- </label>
396
- <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']); ?> />
397
- <span><?php _e('All comments', $this->domain ) ?></span></label>
398
- <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']); ?> />
399
- <span><?php if ($this->options['widget_logic_filter']) { _e('All widgets (uses the <code>widget_content</code> filter of the Widget Logic plugin)', $this->domain); } else { _e('All text widgets', $this->domain); } ?></span></label>
400
- </td>
401
- </tr>
402
- <tr>
403
- <th><?php _e('Protect RSS feed', $this->domain ) ?></th>
404
  <td><label><input type="checkbox" id="filter_rss" name="<?php echo $this->options_name ?>[filter_rss]" value="1" <?php checked('1', (int) $options['filter_rss']); ?> />
405
- <span><?php _e('Replace emails in RSS feed by ', $this->domain ) ?></span></label>
406
  <label><input type="text" id="protection_text" name="<?php echo $this->options_name ?>[protection_text]" value="<?php echo $options['protection_text']; ?>" />
407
  </td>
408
  </tr>
@@ -412,8 +508,8 @@ class WP_Email_Encoder_Bundle {
412
  <fieldset class="options">
413
  <table class="form-table">
414
  <tr>
415
- <th><?php _e('"Email Encoder Form" settings', $this->domain ) ?></th>
416
- <td><label><input type="checkbox" id="<?php echo $this->options_name ?>[powered_by]" name="<?php echo $this->options_name ?>[powered_by]" value="1" <?php checked('1', (int) $options['powered_by']); ?> /> <span><?php _e('Show the "powered by"-link on bottom of the encode form', $this->domain ) ?></span></label></td>
417
  </tr>
418
  </table>
419
  </fieldset>
@@ -426,7 +522,7 @@ class WP_Email_Encoder_Bundle {
426
 
427
  <div class="postbox">
428
  <div class="handlediv" title="<?php _e('Click to toggle') ?>"><br/></div>
429
- <h3 class="hndle"><?php _e('Email Encoder Form', $this->domain ) ?></h3>
430
  <div class="inside">
431
  <?php echo $this->get_encoder_form(); ?>
432
  </div>
@@ -438,48 +534,33 @@ class WP_Email_Encoder_Bundle {
438
  <div style="margin:0 2%;">
439
  <div class="postbox">
440
  <div class="handlediv" title="<?php _e('Click to toggle') ?>"><br/></div>
441
- <h3 class="hndle"><?php _e('About') ?>...</h3>
442
  <div class="inside">
443
- <h4><img src="<?php echo plugins_url('images/icon-email-encoder-bundle.png', __FILE__ ) ?>" width="16" height="16" /> Email Encoder Bundle (v<?php echo $this->version ?>)</h4>
444
- <p><?php _e('Protect email addresses on your site from spambots and being used for spamming by using one of the encoding methods.', $this->domain ) ?></p>
445
- <ul>
446
- <li><a href="http://wordpress.org/extend/plugins/email-encoder-bundle/faq/" target="_blank"><?php _e('Get Started - FAQ', $this->domain ) ?></a></li>
447
- <li><a href="http://www.freelancephp.net/contact/" target="_blank"><?php _e('Questions or suggestions?', $this->domain ) ?></a></li>
448
- <li><?php _e('If you like this plugin please send your rating at WordPress.org.') ?></li>
449
- <li><a href="http://wordpress.org/extend/plugins/email-encoder-bundle/" target="_blank">WordPress.org</a> | <a href="http://www.freelancephp.net/email-encoder-php-class-wp-plugin/" target="_blank">FreelancePHP.net</a></li>
450
- </ul>
451
- </div>
452
- </div>
453
-
454
- <div class="postbox">
455
- <div class="handlediv" title="<?php _e('Click to toggle') ?>"><br/></div>
456
- <h3 class="hndle"><?php _e('Other Plugins', $this->domain ) ?></h3>
457
- <div class="inside">
458
- <h4><img src="<?php echo plugins_url('images/icon-wp-external-links.png', __FILE__ ) ?>" width="16" height="16" /> WP External Links</h4>
459
- <p><?php _e('Manage external links on your site: open in new window/tab, set icon, add "external", add "nofollow" and more.', $this->domain ) ?></p>
460
- <ul>
461
  <?php if (is_plugin_active('wp-external-links/wp-external-links.php') ): ?>
462
- <li><?php _e('This plugin is already activated.', $this->domain ) ?> <a href="<?php echo get_bloginfo('url') ?>/wp-admin/options-general.php?page=wp-external-links/wp-external-links.php"><?php _e('Settings') ?></a></li>
463
  <?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-external-links/wp-external-links.php') ): ?>
464
- <li><a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate this plugin.', $this->domain ) ?></a></li>
465
  <?php else: ?>
466
- <li><a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugin-install.php?tab=search&type=term&s=WP+External+Links+freelancephp&plugin-search-input=Search+Plugins"><?php _e('Get this plugin now', $this->domain ) ?></a></li>
467
  <?php endif; ?>
468
- <li><a href="http://wordpress.org/extend/plugins/wp-external-links/" target="_blank">WordPress.org</a> | <a href="http://www.freelancephp.net/wp-external-links-plugin/" target="_blank">FreelancePHP.net</a></li>
469
- </ul>
 
 
470
 
471
- <h4><img src="<?php echo plugins_url('images/icon-wp-mailto-links.png', __FILE__ ) ?>" width="16" height="16" /> WP Mailto Links</h4>
472
- <p><?php _e('Manage mailto links on your site and protect emails from spambots, set mail icon and more.', $this->domain ) ?></p>
473
- <ul>
474
  <?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php') ): ?>
475
- <li><?php _e('This plugin is already activated.', $this->domain ) ?> <a href="<?php echo get_bloginfo('url') ?>/wp-admin/options-general.php?page=wp-mailto-links/wp-mailto-links.php"><?php _e('Settings') ?></a></li>
476
  <?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-mailto-links/wp-mailto-links.php') ): ?>
477
- <li><a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate this plugin.', $this->domain ) ?></a></li>
478
  <?php else: ?>
479
- <li><a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugin-install.php?tab=search&type=term&s=WP+Mailto+Links+freelancephp&plugin-search-input=Search+Plugins"><?php _e('Get this plugin now', $this->domain ) ?></a></li>
480
  <?php endif; ?>
481
- <li><a href="http://wordpress.org/extend/plugins/wp-mailto-links/" target="_blank">WordPress.org</a> | <a href="http://www.freelancephp.net/wp-mailto-links-plugin/" target="_blank">FreelancePHP.net</a></li>
482
- </ul>
 
 
483
  </div>
484
  </div>
485
  </div>
@@ -503,26 +584,25 @@ class WP_Email_Encoder_Bundle {
503
  <table>
504
  <tr>
505
  <tr>
506
- <th><label for="email"><?php _e('Email address', $this->domain ) ?></label></th>
507
  <td><input type="text" class="regular-text" id="email" name="email" /></td>
508
  </tr>
509
  <tr>
510
- <th><label for="display"><?php _e('Display', $this->domain ) ?></label></th>
511
  <td><input type="text" class="regular-text" id="display" name="display" /></td>
512
  </tr>
513
  <tr>
514
- <th><?php _e('Example', $this->domain ) ?></th>
515
  <td><span id="example"></span></td>
516
  </tr>
517
  <tr>
518
- <th><label for="encode_method"><?php _e('Encode method', $this->domain ) ?></label></th>
519
  <td><select id="encode_method" name="encode_method" class="postform">
520
  <?php foreach ($this->methods AS $method => $info ): ?>
521
- <option value="<?php echo $method ?>" <?php if ($this->method == $method ) echo 'selected="selected"' ?>><?php echo $info['name'] ?></option>
522
  <?php endforeach; ?>
523
- <option value="random" <?php if ($this->method == 'random') echo 'selected="selected"' ?>><?php _e('Random', $this->domain ) ?></option>
524
  </select>
525
- <input type="button" id="ajax_encode" value="<?php _e('Encode', $this->domain ) ?> &gt;&gt;" />
526
  </td>
527
  </tr>
528
  </tr>
@@ -532,14 +612,14 @@ class WP_Email_Encoder_Bundle {
532
  <table>
533
  <tr>
534
  <tr>
535
- <th><label for="encoded_output"><?php _e('Code', $this->domain ) ?></label></th>
536
- <td><textarea class="large-text node" id="encoded_output" name="encoded_output"></textarea></td>
537
  </tr>
538
  </tr>
539
  </table>
540
  </div>
541
  <?php if ($this->options['powered_by'] ): ?>
542
- <p class="powered-by"><?php _e('Powered by', $this->domain ) ?> <a rel="external" href="http://www.freelancephp.net/email-encoder-php-class-wp-plugin/">Email Encoder Bundle</a></p>
543
  <?php endif; ?>
544
  </fieldset>
545
  </form>
@@ -628,11 +708,13 @@ class WP_Email_Encoder_Bundle {
628
  * @return string
629
  */
630
  function callback_encode_email($match) {
631
- if (count($match ) == 2) {
632
  return $this->encode_email($match[1]);
 
 
633
  }
634
 
635
- return $this->encode_email($match[1], $match[2]);
636
  }
637
 
638
  /**
@@ -656,6 +738,20 @@ class WP_Email_Encoder_Bundle {
656
  return $method;
657
  }
658
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
659
  /**
660
  * Encode the given email into an encoded HTML link
661
  * @param string $content
@@ -667,7 +763,7 @@ class WP_Email_Encoder_Bundle {
667
  $method = $this->get_method($method, $this->method);
668
 
669
  if ($this->logged_in) {
670
- $content = '<div class="' . $this->domain . '">' . $content . '</div>';
671
  }
672
 
673
  // get encoded email code
@@ -702,12 +798,17 @@ class WP_Email_Encoder_Bundle {
702
  }
703
 
704
  $class = $this->options['class_name'];
705
- $extra_attrs = ' ' . trim($extra_attrs) . ' title="' . $display . '"';
 
706
 
707
- $html = '<a class="'. $class .'" href="mailto:' . $email . '"'. $extra_attrs . '>' . $display . '</a>';
 
 
 
 
708
 
709
  // get encoded email code
710
- return ($method === 'enc_html') ? $html : $this->encode($html, $method);
711
  }
712
 
713
  /**
@@ -747,7 +848,7 @@ class WP_Email_Encoder_Bundle {
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);'
2
  /*
3
  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 and hide them from spambots by using an encoding method. Easy to use, flexible .
6
  Author: Victor Villaverde Laan
7
+ Version: 0.70
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.70';
24
 
25
  /**
26
  * Used as prefix for options entry and could be used as text domain (for translations)
34
  */
35
  var $options_name = 'WP_Email_Encoder_Bundle_options';
36
 
37
+ /**
38
+ * @var string
39
+ */
40
+ var $page_hook = null;
41
+
42
  /**
43
  * @var array
44
  */
75
  /**
76
  * @var array
77
  */
78
+ var $methods = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
  /**
81
  * Regexp
82
  * @var array
83
  */
84
  var $regexp_patterns = array(
85
+ 'mailto' => '/<a([^<>]*?)href=["\']mailto:(.*?)["\'](.*?)>(.*?)<\/a[\s+]*>/is',
 
86
  'email' => '/([A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6})/is',
87
  );
88
 
100
  // load text domain for translations
101
  load_plugin_textdomain($this->domain, FALSE, dirname(plugin_basename(__FILE__)) . '/lang/');
102
 
103
+ // set methods
104
+ $this->methods = array(
105
+ 'enc_ascii' => array(
106
+ 'name' => _('JavaScript ASCII (recommended)'),
107
+ 'description' => _('This encoding method uses javascript (<a href="http://rumkin.com/tools/mailto_encoder/" target="_blank">original source</a>). <br />Recommended, the savest method.'),
108
+ ),
109
+ 'enc_escape' => array(
110
+ 'name' => _('JavaScript Escape'),
111
+ 'description' => _('This encoding method uses the javascript eval() function (<a href="http://blueberryware.net/2008/09/14/email-spam-protection/" target="_blank">original source</a>). <br />Pretty save method.'),
112
+ ),
113
+ 'enc_html' => array(
114
+ 'name' => _('Html Encode'),
115
+ 'description' => _('This encoding method uses the antispambot() function, built-in WordPress (<a href="http://codex.wordpress.org/Function_Reference/antispambot" target="_blank">more info</a>). <br />Not recommended, especially when using the shortcode [encode_content]).'),
116
+ ),
117
+ 'random' => array(
118
+ 'name' => _('Random'),
119
+ 'description' => 'Pick each time a random encoding method. <br />Not recommended, especially when using the shortcode [encode_content]).',
120
+ ),
121
+ );
122
+
123
  // set option values
124
  $this->set_options();
125
 
148
  global $user_ID;
149
  $this->logged_in = (bool) ($user_ID && current_user_can('level_10'));
150
 
 
 
151
  // shortcodes
152
  add_shortcode('email_encoder_form', array($this, 'shortcode_email_encoder_form'));
153
  add_shortcode('encode_email', array($this, 'shortcode_encode_email'));
156
  if (is_feed()) {
157
  // rss feed
158
  if ($this->options['filter_rss']) {
159
+ $rss_filters = array('the_title', 'the_content', 'the_excerpt', 'the_title_rss', 'the_content_rss', 'the_excerpt_rss',
160
+ 'comment_text_rss', 'comment_author_rss', 'the_category_rss', 'the_content_feed', 'author_feed_link', 'feed_link');
161
+
162
+ foreach($rss_filters as $filter) {
163
+ add_filter($filter, array($this, 'filter_rss_callback'), 100);
164
+ }
 
 
 
 
 
 
165
  }
166
  } else {
167
  // add style when logged in
168
  if ($this->logged_in) {
169
+ add_action('wp_head', array($this, 'wp_head'));
170
  }
171
 
172
+ $filters = array();
173
+
174
  // post content
175
  if ($this->options['filter_posts']) {
176
+ array_push($filters, 'the_title', 'the_content', 'the_excerpt', 'get_the_excerpt');
 
 
 
177
  }
178
 
179
  // comments
180
  if ($this->options['filter_comments']) {
181
+ array_push($filters, 'comment_text', 'comment_excerpt', 'comment_url', 'get_comment_author_url', 'get_comment_author_link', 'get_comment_author_url_link');
 
 
 
 
 
182
  }
183
 
184
  // widgets
185
  if ($this->options['filter_widgets']) {
186
+ array_push($filters, 'widget_title', 'widget_text', 'widget_content');
 
 
 
 
187
 
 
 
188
  // also replace shortcodes
189
+ add_filter('widget_text', 'do_shortcode', 100);
190
+ add_filter('widget_content', 'do_shortcode', 100); // filter of Widget Logic plugin
191
+ }
192
+
193
+ foreach($filters as $filter) {
194
+ add_filter($filter, array($this, 'filter_callback'), 100);
195
  }
196
  }
197
 
198
  // action hook
199
+ do_action('init_email_encoder_bundle', array($this, 'filter_callback'), $this);
200
  }
201
 
202
  /**
216
  * @return string
217
  */
218
  function shortcode_encode_email($attrs) {
219
+ if (!is_array($attrs) || !key_exists('email', $attrs)) {
220
  return '';
221
  }
222
 
235
  * @return string
236
  */
237
  function shortcode_encode_content($attrs, $content = '') {
238
+ $method = (is_array($attrs) && key_exists('method', $attrs)) ? $attrs['method'] : NULL;
239
 
240
  return $this->encode($content, $method);
241
  }
242
 
243
  /**
244
+ * Add style/script for encoded mails when logged in
245
  */
246
+ function wp_head() {
247
  echo '<style type="text/css">' . "\n";
248
+ echo 'a.encoded-check { opacity:0.5; position:absolute; text-decoration:none !important; font:10px Arial !important; margin-top:-3px; color:#629632; font-weight:bold; }' . "\n";
249
+ echo 'a.encoded-check:hover { opacity:1; cursor:help; }' . "\n";
250
+ echo 'a.encoded-check img { width:10px; height:10px; }' . "\n";
251
  echo '</style>' . "\n";
252
  }
253
 
281
  function admin_menu() {
282
  if (function_exists('add_options_page') AND current_user_can('manage_options')) {
283
  // add options page
284
+ $this->page_hook = add_options_page('Email Encoder Bundle', 'Email Encoder Bundle',
285
  'manage_options', __FILE__, array($this, 'options_page'));
286
+
287
+ add_action('load-' . $this->page_hook, array($this, 'help_tabs'));
288
+ add_filter('contextual_help', array($this, 'contextual_help'), 10, 3);
289
  }
290
  }
291
 
292
+ /**
293
+ * Remove default contextual help text
294
+ * @param string $contextual_help
295
+ * @param integer $screen_id
296
+ * @param object $screen
297
+ * @return string
298
+ */
299
+ function contextual_help($contextual_help, $screen_id, $screen) {
300
+ if ($screen_id == $this->page_hook) {
301
+ $contextual_help = '';
302
+ }
303
+
304
+ return $contextual_help;
305
+ }
306
+
307
+ /**
308
+ * Create help tabs
309
+ */
310
+ function help_tabs() {
311
+ if (!function_exists('get_current_screen')) {
312
+ return;
313
+ }
314
+
315
+ $screen = get_current_screen();
316
+
317
+ $about = <<<ABOUT
318
+ <p><strong>Email Encoder Bundle - version {$this->version}</strong></p>
319
+ <p>Encode mailto links and (plain) email addresses and hide them from spambots. Easy to use, plugin works directly when activated. Save way to protect email addresses on your site.</p>
320
+ ABOUT;
321
+ $screen->add_help_tab(array(
322
+ 'id' => 'about',
323
+ 'title' => __('About'),
324
+ 'content' => __($about),
325
+ ));
326
+
327
+ $shortcodes = <<<SHORTCODES
328
+ <p>Encode an email address:
329
+ <br/><code>[encode_email email="..." display="..."]</code> ("display" is optional)
330
+ </p>
331
+ <p>Encode some content:
332
+ <br/><code>[encode_content method="..."]...[/encode_content]</code> ("method" is optional)
333
+ </p>
334
+ <p>Puts an encoder form in your post:
335
+ <br/><code>[email_encoder_form]</code>
336
+ </p>
337
+ SHORTCODES;
338
+ $screen->add_help_tab(array(
339
+ 'id' => 'shortcodes',
340
+ 'title' => __('Shortcodes'),
341
+ 'content' => __($shortcodes),
342
+ ));
343
+
344
+ $templatefunctions = <<<TEMPLATEFUNCTIONS
345
+ <p>Encode the given email (other params are optional):
346
+ <br/><code><&#63;php echo encode_email(\$email, [\$display], [\$method], [\$extra_attrs]); &#63;></code>
347
+ </p>
348
+ <p>Encode the given content for emails to encode (other param is optional):
349
+ <br/><code><&#63;php echo encode_content(\$content, [\$method]); &#63;></code>
350
+ </p>
351
+ <p>Filter the given content for emails to encode (other params are optional):
352
+ <br/><code><&#63;php echo encode_email_filter(\$content, [\$enc_tags], [\$enc_mailtos], [\$enc_plain_emails]); &#63;></code>
353
+ </p>
354
+ TEMPLATEFUNCTIONS;
355
+ $screen->add_help_tab(array(
356
+ 'id' => 'templatefunctions',
357
+ 'title' => __('Template functions'),
358
+ 'content' => __($templatefunctions),
359
+ ));
360
+
361
+ $hooks = <<<HOOKS
362
+ <p>Add extra code on initializing this plugin, like extra filters for encoding.</p>
363
+ <pre>
364
+ function extra_encode_filters(\$filter_callback, \$object) {
365
+ add_filter('some_filter', \$filter_callback);
366
+ }
367
+ add_action('init_email_encoder_bundle', 'extra_encode_filters');
368
+ </pre>
369
+ HOOKS;
370
+ $screen->add_help_tab(array(
371
+ 'id' => 'hooks',
372
+ 'title' => __('Hooks'),
373
+ 'content' => __($hooks),
374
+ ));
375
+
376
+ $sidebar = <<<SIDEBAR
377
+ <p>See <a href="http://wordpress.org/extend/plugins/email-encoder-bundle/faq/" target="_blank">FAQ</a> at WordPress.org</p>
378
+ <p>Send your <a href="http://www.freelancephp.net/contact/" target="_blank">question</a></p>
379
+ <p><strong>Please <a href="http://wordpress.org/extend/plugins/email-encoder-bundle/" target="_blank">rate this plugin</a> and vote if the plugin works.</strong></p>
380
+ SIDEBAR;
381
+ $screen->set_help_sidebar(__($sidebar));
382
+ }
383
+
384
  /**
385
  * admin_init action
386
  */
426
  ?>
427
  <div class="wrap">
428
  <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>
429
+ <h2>Email Encoder Bundle - <em><small><?php _e('Protecting Email Addresses', $this->domain) ?></small></em></h2>
430
 
431
  <script type="text/javascript">
432
  var methodInfo = <?php echo json_encode($this->methods) ?>;
444
  $options = $this->options;
445
  ?>
446
  <?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php') ): ?>
447
+ <p class="description"><?php _e('Warning: "WP Mailto Links"-plugin is also activated, which could cause conflicts.', $this->domain) ?></p>
448
  <?php endif; ?>
449
  <fieldset class="options">
450
  <table class="form-table">
451
  <tr>
452
+ <th><?php _e('Encoding Method for Protection', $this->domain) ?></th>
453
+ <td><select id="<?php echo $this->options_name ?>[method]" name="<?php echo $this->options_name ?>[method]" class="method-info-select postform">
454
  <?php foreach ($this->methods AS $method => $info ): ?>
455
  <option value="<?php echo $method ?>" <?php if ($this->method == $method ) echo 'selected="selected"' ?>><?php echo $info['name']; if ($method == 'lim_email_ascii'){ echo ' (recommended)'; } ?></option>
456
  <?php endforeach; ?>
 
457
  </select>
458
+ <br />
459
+ <label><span class="description"></span></label>
460
  </td>
461
  </tr>
462
  <tr>
463
+ <th><?php _e('Protect Emails', $this->domain) ?></th>
464
  <td>
465
+ <label><input type="checkbox" name="<?php echo $this->options_name ?>[encode_tags]" value="1" checked="checked" disabled="disabled" />
466
+ <span><?php _e( 'Create protected links for <code>[encode_email]</code> shortcodes', $this->domain) ?></span>
467
+ </label>
468
+ <br/>
469
  <label><input type="checkbox" id="encode_mailtos" name="<?php echo $this->options_name ?>[encode_mailtos]" value="1" <?php checked('1', (int) $options['encode_mailtos']); ?> />
470
+ <span><?php _e('Protect mailto links', $this->domain) ?></span>
471
  </label>
472
  <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']); ?> />
473
+ <span><?php _e('Replace plain email addresses to protected mailto links', $this->domain) ?></span> <span class="description"><?php _e('(not recommended)', $this->domain) ?></span>
474
  </label>
475
+ <br/>
476
+ <br/>
477
+ <label><input type="checkbox" name="<?php echo $this->options_name ?>[filter_posts]" value="1" <?php checked('1', (int) $options['filter_posts']); ?> />
478
+ <span><?php _e('Protect emails in all posts', $this->domain) ?></span>
479
+ </label>
480
+ <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']); ?> />
481
+ <span><?php _e('Protect emails in all comments', $this->domain) ?></span></label>
482
+ <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']); ?> />
483
+ <span><?php if ($this->options['widget_logic_filter']) { _e('Protect emails in all widgets (uses the <code>widget_content</code> filter of the Widget Logic plugin)', $this->domain); } else { _e('Protect emails in all text widgets', $this->domain); } ?></span></label>
484
+ <br/>
485
  <br/>
486
  <label>
487
+ <span><?php _e('Skip posts with ID:', $this->domain) ?></span>
488
  <input type="text" id="<?php echo $this->options_name ?>[skip_posts]" name="<?php echo $this->options_name ?>[skip_posts]" value="<?php echo $options['skip_posts']; ?>" />
489
+ <span class="description"><?php _e('(comma seperated, f.e.: 2, 7, 13, 32)', $this->domain) ?></span>
490
  </label>
491
  </td>
492
  </tr>
493
  <tr>
494
+ <th><?php _e('Class for Protected Links', $this->domain) ?></th>
495
  <td><label><input type="text" id="<?php echo $this->options_name ?>[class_name]" name="<?php echo $this->options_name ?>[class_name]" value="<?php echo $options['class_name']; ?>" />
496
+ <span class="description"><?php _e('All protected mailto links will get these class(es) <em>(optional, else keep blank)</em>', $this->domain) ?></span></label></td>
497
  </tr>
498
  <tr>
499
+ <th><?php _e('Protect Emails in RSS Feeds', $this->domain) ?></th>
 
 
 
 
 
 
 
 
 
 
 
500
  <td><label><input type="checkbox" id="filter_rss" name="<?php echo $this->options_name ?>[filter_rss]" value="1" <?php checked('1', (int) $options['filter_rss']); ?> />
501
+ <span><?php _e('Replace emails in RSS feeds with the following text:', $this->domain) ?></span></label>
502
  <label><input type="text" id="protection_text" name="<?php echo $this->options_name ?>[protection_text]" value="<?php echo $options['protection_text']; ?>" />
503
  </td>
504
  </tr>
508
  <fieldset class="options">
509
  <table class="form-table">
510
  <tr>
511
+ <th><?php _e('Email Encoder Form Settings', $this->domain) ?></th>
512
+ <td><label><input type="checkbox" id="<?php echo $this->options_name ?>[powered_by]" name="<?php echo $this->options_name ?>[powered_by]" value="1" <?php checked('1', (int) $options['powered_by']); ?> /> <span><?php _e('Show the "powered by"-link on bottom of the encoder form', $this->domain) ?></span></label></td>
513
  </tr>
514
  </table>
515
  </fieldset>
522
 
523
  <div class="postbox">
524
  <div class="handlediv" title="<?php _e('Click to toggle') ?>"><br/></div>
525
+ <h3 class="hndle"><?php _e('Email Encoder Form', $this->domain) ?></h3>
526
  <div class="inside">
527
  <?php echo $this->get_encoder_form(); ?>
528
  </div>
534
  <div style="margin:0 2%;">
535
  <div class="postbox">
536
  <div class="handlediv" title="<?php _e('Click to toggle') ?>"><br/></div>
537
+ <h3 class="hndle"><?php _e('Other Plugins', $this->domain) ?></h3>
538
  <div class="inside">
539
+ <h4><img src="<?php echo plugins_url('images/icon-wp-external-links.png', __FILE__ ) ?>" width="16" height="16" /> WP External Links -
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
540
  <?php if (is_plugin_active('wp-external-links/wp-external-links.php') ): ?>
541
+ <?php _e('This plugin is already activated.', $this->domain) ?> <a href="<?php echo get_bloginfo('url') ?>/wp-admin/options-general.php?page=wp-external-links/wp-external-links.php"><?php _e('Settings') ?></a>
542
  <?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-external-links/wp-external-links.php') ): ?>
543
+ <a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate this plugin.', $this->domain) ?></a>
544
  <?php else: ?>
545
+ <a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugin-install.php?tab=search&type=term&s=WP+External+Links+freelancephp&plugin-search-input=Search+Plugins"><?php _e('Get this plugin now', $this->domain) ?></a>
546
  <?php endif; ?>
547
+ </h4>
548
+ <p><?php _e('Manage external links on your site: open in new window/tab, set icon, add "external", add "nofollow" and more.', $this->domain) ?>
549
+ <br /><a href="http://wordpress.org/extend/plugins/wp-external-links/" target="_blank">WordPress.org</a> | <a href="http://www.freelancephp.net/wp-external-links-plugin/" target="_blank">FreelancePHP.net</a>
550
+ </p>
551
 
552
+ <h4><img src="<?php echo plugins_url('images/icon-wp-mailto-links.png', __FILE__ ) ?>" width="16" height="16" /> WP Mailto Links -
 
 
553
  <?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php') ): ?>
554
+ <?php _e('This plugin is already activated.', $this->domain) ?> <a href="<?php echo get_bloginfo('url') ?>/wp-admin/options-general.php?page=wp-mailto-links/wp-mailto-links.php"><?php _e('Settings') ?></a>
555
  <?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-mailto-links/wp-mailto-links.php') ): ?>
556
+ <a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate this plugin.', $this->domain) ?></a>
557
  <?php else: ?>
558
+ <a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugin-install.php?tab=search&type=term&s=WP+Mailto+Links+freelancephp&plugin-search-input=Search+Plugins"><?php _e('Get this plugin now', $this->domain) ?></a>
559
  <?php endif; ?>
560
+ </h4>
561
+ <p><?php _e('Manage mailto links on your site and protect emails from spambots, set mail icon and more.', $this->domain) ?>
562
+ <br /><a href="http://wordpress.org/extend/plugins/wp-mailto-links/" target="_blank">WordPress.org</a> | <a href="http://www.freelancephp.net/wp-mailto-links-plugin/" target="_blank">FreelancePHP.net</a>
563
+ </p>
564
  </div>
565
  </div>
566
  </div>
584
  <table>
585
  <tr>
586
  <tr>
587
+ <th><label for="email"><?php _e('Email Address:', $this->domain) ?></label></th>
588
  <td><input type="text" class="regular-text" id="email" name="email" /></td>
589
  </tr>
590
  <tr>
591
+ <th><label for="display"><?php _e('Display Text:', $this->domain) ?></label></th>
592
  <td><input type="text" class="regular-text" id="display" name="display" /></td>
593
  </tr>
594
  <tr>
595
+ <th><?php _e('Mailto Link', $this->domain) ?></th>
596
  <td><span id="example"></span></td>
597
  </tr>
598
  <tr>
599
+ <th><label for="encode_method"><?php _e('Encoding Method:', $this->domain) ?></label></th>
600
  <td><select id="encode_method" name="encode_method" class="postform">
601
  <?php foreach ($this->methods AS $method => $info ): ?>
602
+ <option value="<?php echo $method ?>" <?php if ($this->method == $method) echo 'selected="selected"' ?>><?php echo $info['name'] ?></option>
603
  <?php endforeach; ?>
 
604
  </select>
605
+ <input type="button" id="ajax_encode" value="<?php _e('Create Protected Mail Link', $this->domain) ?> &gt;&gt;" />
606
  </td>
607
  </tr>
608
  </tr>
612
  <table>
613
  <tr>
614
  <tr>
615
+ <th><label for="encoded_output"><?php _e('Protected Mail Link (code):', $this->domain) ?></label></th>
616
+ <td><textarea class="large-text node" id="encoded_output" name="encoded_output" cols="50" rows="4"></textarea></td>
617
  </tr>
618
  </tr>
619
  </table>
620
  </div>
621
  <?php if ($this->options['powered_by'] ): ?>
622
+ <p class="powered-by"><?php _e('Powered by', $this->domain) ?> <a rel="external" href="http://www.freelancephp.net/email-encoder-php-class-wp-plugin/">Email Encoder Bundle</a></p>
623
  <?php endif; ?>
624
  </fieldset>
625
  </form>
708
  * @return string
709
  */
710
  function callback_encode_email($match) {
711
+ if (count($match) < 3) {
712
  return $this->encode_email($match[1]);
713
+ } else if (count($match) == 3) {
714
+ return $this->encode_email($match[2]);
715
  }
716
 
717
+ return $this->encode_email($match[2], $match[4], null, $match[1] . ' ' . $match[3]);
718
  }
719
 
720
  /**
738
  return $method;
739
  }
740
 
741
+ /**
742
+ * Add html to encoded content to show check icon and text
743
+ * @param string $content
744
+ * @return string
745
+ */
746
+ function get_html_checked($content) {
747
+ return $content
748
+ . '<a href="javascript:;" class="encoded-check"'
749
+ . ' title="' . _('Succesfully Encoded (this is a check and only visible when logged in as admin)', $this->domain) . '">'
750
+ . '<img class="encoded-check-icon" src="' . plugins_url('images/icon-email-encoder-bundle.png', __FILE__)
751
+ . '" alt="' . _('Encoded', $this->domain) . '" />'
752
+ . _('Succesfully Encoded', $this->domain) . '</a>';
753
+ }
754
+
755
  /**
756
  * Encode the given email into an encoded HTML link
757
  * @param string $content
763
  $method = $this->get_method($method, $this->method);
764
 
765
  if ($this->logged_in) {
766
+ $content = $this->get_html_checked($content);
767
  }
768
 
769
  // get encoded email code
798
  }
799
 
800
  $class = $this->options['class_name'];
801
+ $extra_attrs = ' ' . trim($extra_attrs);
802
+ $mailto = '<a class="'. $class .'" href="mailto:' . $email . '"'. $extra_attrs . '>' . $display . '</a>';
803
 
804
+ if ($method === 'enc_html') {
805
+ $mailto = $this->get_html_checked($mailto);
806
+ } else {
807
+ $mailto = $this->encode($mailto, $method);
808
+ }
809
 
810
  // get encoded email code
811
+ return $mailto;
812
  }
813
 
814
  /**
848
 
849
  return '<script type="text/javascript">/*<![CDATA[*/'
850
  . '(function(){'
851
+ . 'var ML="'. $mail_letters_enc .'",MI="'. $mail_indices .'",OT="";'
852
  . 'for(var j=0;j<MI.length;j++){'
853
  . 'OT+=ML.charAt(MI.charCodeAt(j)-48);'
854
  . '}document.write(OT);'
js/email-encoder-bundle-admin.js CHANGED
@@ -8,23 +8,25 @@ jQuery(function ($) {
8
  // remove message
9
  $('.settings-error')
10
  .hide()
11
- .slideDown(600)
12
  .delay(3000)
13
- .slideUp(600);
14
 
15
  // set info text for selected encoding method
16
  $('.method-info-select')
17
- .bind('change blur keyup', function () {
18
  var method = $(this).val(),
19
  $desc = $(this).parent().find('span.description');
20
 
21
  if (methodInfo && methodInfo[method]) {
 
22
  $desc.html(methodInfo[method].description || '');
 
23
  } else {
24
  $desc.html('');
25
  }
26
  })
27
- .blur();
28
 
29
  // "has effect on"
30
  $('input#encode_emails')
8
  // remove message
9
  $('.settings-error')
10
  .hide()
11
+ .fadeIn(600)
12
  .delay(3000)
13
+ .fadeOut(600);
14
 
15
  // set info text for selected encoding method
16
  $('.method-info-select')
17
+ .bind('change', function () {
18
  var method = $(this).val(),
19
  $desc = $(this).parent().find('span.description');
20
 
21
  if (methodInfo && methodInfo[method]) {
22
+ $desc.hide();
23
  $desc.html(methodInfo[method].description || '');
24
+ $desc.fadeIn();
25
  } else {
26
  $desc.html('');
27
  }
28
  })
29
+ .change();
30
 
31
  // "has effect on"
32
  $('input#encode_emails')
js/email-encoder-bundle.js CHANGED
@@ -26,7 +26,7 @@ jQuery(function($){
26
  method: $wrap.find('#encode_method').val()
27
  }, function (data) {
28
  $wrap.find('#encoded_output').val(data);
29
- $wrap.find('.output').slideDown();
30
  });
31
  };
32
 
@@ -48,11 +48,17 @@ jQuery(function($){
48
  // get encoded link on these events
49
  $wrap.find('#email, #display')
50
  .keyup(function () {
51
- // show example how it will appear on the page
52
- $wrap.find('#example').html('<a href="mailto:' + $email.val() + '">' + $display.val() + '</a>');
 
 
 
 
 
 
53
 
54
  // clear code field
55
- $wrap.find('.output').slideUp();
56
  $wrap.find('#encoded_output').val('');
57
  })
58
  .keyup();
26
  method: $wrap.find('#encode_method').val()
27
  }, function (data) {
28
  $wrap.find('#encoded_output').val(data);
29
+ $wrap.find('.output').fadeIn();
30
  });
31
  };
32
 
48
  // get encoded link on these events
49
  $wrap.find('#email, #display')
50
  .keyup(function () {
51
+ if ($display.val().length > 0) {
52
+ // show example how it will appear on the page
53
+ $wrap.find('#example')
54
+ .html('<a href="mailto:' + $email.val() + '">' + $display.val() + '</a>')
55
+ .parents('tr').fadeIn();
56
+ } else {
57
+ $wrap.find('#example').parents('tr').fadeOut();
58
+ }
59
 
60
  // clear code field
61
+ $wrap.find('.output').fadeOut();
62
  $wrap.find('#encoded_output').val('');
63
  })
64
  .keyup();
readme.txt CHANGED
@@ -1,57 +1,32 @@
1
  === Email Encoder Bundle ===
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.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
 
10
  == Description ==
11
 
12
- Protect email addresses on your site from spambots and being used for spamming. This plugin encodes all email adresses so spambots cannot read them.
13
 
14
  = Features =
15
- * Protect plain emails and mailto links
 
16
  * Encode all kind of content (text and html)
17
- * Scanning posts, widgets, comments and RSS feeds
18
- * Choose one of the high-quality encoding methods
19
- * Supports querystrings like 'info@myemail.com?subject=Plugin'
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
 
@@ -67,7 +42,7 @@ Supports PHP4.3+ and up to latest WP version.
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:
@@ -75,16 +50,15 @@ The default method is `JavaScript ASCII` the following output will be created in
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:
@@ -92,11 +66,12 @@ For Example:
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.
@@ -106,10 +81,17 @@ It's possible to filter all widgets by using the Widget Logic plugin and activat
106
  == Screenshots ==
107
 
108
  1. Admin Options Page
 
109
  1. Email Encoder Form on the Site
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
1
  === Email Encoder Bundle ===
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.0.0
5
+ Tested up to: 3.5.1
6
+ Stable tag: 0.70
7
 
8
+ Encode mailto links and (plain) email addresses and hide them from spambots. Easy to use, plugin works directly when activated. Save way to protect email addresses on your site.
9
 
10
  == Description ==
11
 
12
+ Encode mailto links and (plain) email addresses and hide them from spambots. Easy to use, plugin works directly when activated. Save way to protect email addresses on your site.
13
 
14
  = Features =
15
+ * Protect all emails and mailto links
16
+ * Check posts, widgets, comments and RSS feeds
17
  * Encode all kind of content (text and html)
18
+ * Email Encoder Form (in admin and also for your site)
19
+ * Use params in mailto links, like: cc, bcc, subject, body
20
+ * And more...
 
21
 
22
+ = Documentation =
23
+ See help tab on the plugin page in the WP Admin Panel.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  = Support =
26
+ Supports PHP 4.3+ and WP 3.0+.
27
 
28
  = Contact =
29
+ [Send your comment](http://www.freelancephp.net/email-encoder-php-class-wp-plugin/)[ or question](http://www.freelancephp.net/contact/)
30
 
31
  == Installation ==
32
 
42
  In the posts you can use this shortcode:
43
  `[email_encode email="myname@test.nl" display="My Email"]`
44
 
45
+ By default mailto links like this will also be encoded:
46
  `<a href="mailto:myname@test.nl">My Email</a>`
47
 
48
  The default method is `JavaScript ASCII` the following output will be created in the source code of the page:
50
 
51
  This code is not readable by spambots and protects your emailaddress.
52
 
 
 
 
 
53
  = How to create mailto links that opens in a new window? =
54
 
55
  You could add extra params to the mailto link and add `target='_blank'` for opening them in a new window, like:
56
  `[encode_email email="yourmail@test.nl" display="My Mail" extra_attrs="target='_blank'"]`
57
 
58
+ In html this will look like:
59
+ `<a href="mailto:yourmail@test.nl" target="_blank">My Mail</a>`
60
+
61
+ = How can I encode content of BBPress, WP e-Commerce or other plugins? =
62
 
63
  If you use other plugins that needs to be encoded you can add a callback to the action "init_email_encoder_bundle".
64
  For Example:
66
  `add_action('init_email_encoder_bundle', 'extra_encode_filters');
67
 
68
  function extra_encode_filters($filter_callback) {
69
+ // add filters for BBPress
70
  add_filter('bbp_get_reply_content', $filter_callback);
71
  add_filter('bbp_get_topic_content', $filter_callback);
72
  }`
73
 
74
+ = How to encode emails in all widgets (and not only text widgets)? =
75
 
76
  If the option 'All text widgets' is activated, only text widgets will be filtered for encoding.
77
  It's possible to filter all widgets by using the Widget Logic plugin and activate the 'widget_content' filter.
81
  == Screenshots ==
82
 
83
  1. Admin Options Page
84
+ 1. Check encoded email/content when logged in as admin
85
  1. Email Encoder Form on the Site
86
 
87
  == Changelog ==
88
 
89
+ = 0.70 (latest) =
90
+ * Fixed bug with extra params
91
+ * Changed texts and added help tabs on admin options page
92
+ * Changed visual check for encoded mails/content by showing icon and success message
93
+ * Solved that all attributes of mailto links remain when encoding
94
+
95
  = 0.60 =
96
  * Added hook "init_email_encoder_form" to add custom filters (of other plugins)
97
  * Added JavaScript code encapsulation for ASCII method
screenshot-2.png CHANGED
Binary file
screenshot-3.png ADDED
Binary file