Email Encoder Bundle – Protect Email Address - Version 0.71

Version Description

(latest) = * Option to make own menu item (in admin panel) for this plugin * Option for showing "successfully encoded" check * Fixed bug showing errors for calling wrong translate function * Fixed bug always showing encoded check on site (for html encode method) * Added workaround for saving disabled checkboxes in options table * Fixed bug where encoded check was also applied on output of encoding form

Download this release

Release Info

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

Code changes from version 0.70 to 0.71

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 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,7 +20,7 @@ class WP_Email_Encoder_Bundle {
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)
@@ -54,6 +54,8 @@ class WP_Email_Encoder_Bundle {
54
  'filter_rss' => 1,
55
  'protection_text' => '*protected email*',
56
  'widget_logic_filter' => 0,
 
 
57
  'powered_by' => 1,
58
  );
59
 
@@ -103,20 +105,20 @@ class WP_Email_Encoder_Bundle {
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
 
@@ -146,7 +148,7 @@ class WP_Email_Encoder_Bundle {
146
  */
147
  function wp() {
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'));
@@ -281,8 +283,14 @@ class WP_Email_Encoder_Bundle {
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);
@@ -397,17 +405,17 @@ SIDEBAR;
397
  * @param string $hook_suffix
398
  */
399
  function admin_enqueue_scripts($hook_suffix) {
400
- if($hook_suffix == 'settings_page_email-encoder-bundle/email-encoder-bundle') {
401
  // set dashboard postbox
402
  wp_enqueue_script('dashboard');
403
  // set dashboard style for wp < 3.2.0
404
- if (isset($wp_version ) AND version_compare( preg_replace('/-.*$/', '', $wp_version ), '3.2.0', '<')) {
405
  wp_admin_css('dashboard');
406
  }
407
 
408
  // add style and script for ajax encoder
409
- wp_enqueue_script('email_encoder', plugins_url('js/email-encoder-bundle.js', __FILE__ ), array('jquery'), $this->version);
410
- wp_enqueue_script('email_encoder_admin', plugins_url('js/email-encoder-bundle-admin.js', __FILE__ ), array('jquery'), $this->version);
411
  }
412
  }
413
 
@@ -425,7 +433,7 @@ SIDEBAR;
425
  function options_page() {
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">
@@ -433,17 +441,17 @@ SIDEBAR;
433
  </script>
434
  <div class="postbox-container metabox-holder meta-box-sortables" style="width: 68%">
435
  <div style="margin:0 2%;">
 
 
 
 
 
 
436
  <div class="postbox">
437
  <div class="handlediv" title="<?php _e('Click to toggle') ?>"><br/></div>
438
  <h3 class="hndle"><?php _e('General Settings') ?></h3>
439
  <div class="inside">
440
- <form method="post" action="options.php">
441
- <?php
442
- settings_fields($this->domain);
443
- $this->set_options();
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">
@@ -451,8 +459,8 @@ SIDEBAR;
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 />
@@ -460,32 +468,30 @@ SIDEBAR;
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>
@@ -504,9 +510,26 @@ SIDEBAR;
504
  </tr>
505
  </table>
506
  </fieldset>
 
 
 
 
 
507
 
 
 
 
 
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>
@@ -514,11 +537,11 @@ SIDEBAR;
514
  </table>
515
  </fieldset>
516
  <p class="submit">
517
- <input class="button-primary" type="submit" value="<?php _e('Save Changes') ?>" />
518
  </p>
519
- </form>
520
  </div>
521
  </div>
 
522
 
523
  <div class="postbox">
524
  <div class="handlediv" title="<?php _e('Click to toggle') ?>"><br/></div>
@@ -536,27 +559,31 @@ SIDEBAR;
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>
@@ -582,7 +609,7 @@ SIDEBAR;
582
  <fieldset>
583
  <div class="input">
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>
@@ -598,27 +625,27 @@ SIDEBAR;
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>
609
  </table>
610
  </div>
611
  <div class="output nodis">
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>
@@ -639,34 +666,14 @@ SIDEBAR;
639
  $saved_options = get_option($this->options_name);
640
 
641
  // backwards compatible (old values)
642
- if (empty($saved_options )) {
643
- $saved_options = get_option($this->domain . 'options');
644
- }
645
-
646
  if (empty($saved_options)) {
647
- foreach ($this->options AS $key => $option) {
648
- $saved_options[$key] = $this->options[$key];
649
- }
650
- }
651
-
652
- // upgrade to 0.40
653
- if (! isset($saved_options['class_name'])) {
654
- // set default
655
- $saved_options['class_name'] = $this->options['class_name'];
656
- $saved_options['filter_posts'] = $this->options['filter_posts'];
657
- }
658
-
659
- // upgrade to 0.50
660
- if (!isset($saved_options['protection_text'])) {
661
- // set default
662
- $saved_options['protection_text'] = $this->options['protection_text'];
663
- $saved_options['skip_posts'] = $this->options['skip_posts'];
664
  }
665
 
666
  // set all options
667
  if (!empty($saved_options)) {
668
- foreach ($this->options AS $key => $option) {
669
- $this->options[$key] = (empty($saved_options[$key])) ? '' : $saved_options[$key];
670
  }
671
  }
672
 
@@ -675,7 +682,7 @@ SIDEBAR;
675
 
676
  // set widget_content filter of Widget Logic plugin
677
  $widget_logic_opts = get_option('widget_logic');
678
- if (is_array($widget_logic_opts ) AND key_exists('widget_logic-options-filter', $widget_logic_opts )) {
679
  $this->options['widget_logic_filter'] = ($widget_logic_opts['widget_logic-options-filter'] == 'checked') ? 1 : 0;
680
  }
681
  }
@@ -744,25 +751,31 @@ SIDEBAR;
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
758
  * @param string $method Optional, else the default setted method will; be used
 
759
  * @return string
760
  */
761
- function encode($content, $method = NULL) {
762
  // get encode method
763
  $method = $this->get_method($method, $this->method);
764
 
765
- if ($this->logged_in) {
 
766
  $content = $this->get_html_checked($content);
767
  }
768
 
@@ -778,7 +791,7 @@ SIDEBAR;
778
  * @param string $extra_attrs Optional
779
  * @return string
780
  */
781
- function encode_email($email, $display = NULL, $method = NULL, $extra_attrs = '') {
782
  // decode entities
783
  $email = html_entity_decode($email);
784
 
@@ -802,9 +815,12 @@ SIDEBAR;
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
@@ -904,7 +920,7 @@ SIDEBAR;
904
  srand((float) microtime() * 1000000);
905
 
906
  for ($i = 0; $i < strlen($value); $i = $i + 1) {
907
- $j = floor(rand( 0, 1 ));
908
 
909
  if ($j == 0) {
910
  $enc_value .= '&#' . ord(substr($value, $i, 1)) . ';';
@@ -938,7 +954,7 @@ if (!empty($_GET['ajaxEncodeEmail'])):
938
  $email = $_GET['email'];
939
  $display = (empty($_GET['display'])) ? $email : $_GET['display'];
940
 
941
- echo $WP_Email_Encoder_Bundle->encode_email($email, $display, $method);
942
  exit;
943
  endif;
944
 
@@ -982,7 +998,7 @@ endif;
982
  * @return string
983
  */
984
  if (!function_exists('encode_email_filter')):
985
- function encode_email_filter($content, $enc_tags = TRUE, $enc_mailtos = TRUE, $enc_plain_emails = TRUE ) {
986
  global $WP_Email_Encoder_Bundle;
987
  return $WP_Email_Encoder_Bundle->filter($content, $enc_tags, $enc_mailtos, $enc_plain_emails);
988
  }
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.71
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.71';
24
 
25
  /**
26
  * Used as prefix for options entry and could be used as text domain (for translations)
54
  'filter_rss' => 1,
55
  'protection_text' => '*protected email*',
56
  'widget_logic_filter' => 0,
57
+ 'show_encoded_check' => 0,
58
+ 'own_admin_menu' => 1,
59
  'powered_by' => 1,
60
  );
61
 
105
  // set methods
106
  $this->methods = array(
107
  'enc_ascii' => array(
108
+ 'name' => __('JavaScript ASCII (recommended)', $this->domain),
109
+ 'description' => __('This encoding method uses javascript (<a href="http://rumkin.com/tools/mailto_encoder/" target="_blank">original source</a>). <br />Recommended, the savest method.', $this->domain),
110
  ),
111
  'enc_escape' => array(
112
+ 'name' => __('JavaScript Escape', $this->domain),
113
+ '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.', $this->domain),
114
  ),
115
  'enc_html' => array(
116
+ 'name' => __('Html Encode', $this->domain),
117
+ '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]).', $this->domain),
118
  ),
119
  'random' => array(
120
+ 'name' => __('Random', $this->domain),
121
+ 'description' => __('Pick each time a random encoding method. <br />Not recommended, especially when using the shortcode [encode_content]).', $this->domain),
122
  ),
123
  );
124
 
148
  */
149
  function wp() {
150
  global $user_ID;
151
+ $this->logged_in = (bool) ($user_ID && current_user_can('manage_options'));
152
 
153
  // shortcodes
154
  add_shortcode('email_encoder_form', array($this, 'shortcode_email_encoder_form'));
283
  function admin_menu() {
284
  if (function_exists('add_options_page') AND current_user_can('manage_options')) {
285
  // add options page
286
+ if ($this->options['own_admin_menu']) {
287
+ $this->page_hook = add_menu_page('Email Encoder Bundle', 'Email Encoder Bundle',
288
+ 'manage_options', __FILE__, array($this, 'options_page'),
289
+ plugins_url('images/icon-email-encoder-bundle-16.png', __FILE__));
290
+ } else {
291
+ $this->page_hook = add_options_page('Email Encoder Bundle', 'Email Encoder Bundle',
292
+ 'manage_options', __FILE__, array($this, 'options_page'));
293
+ }
294
 
295
  add_action('load-' . $this->page_hook, array($this, 'help_tabs'));
296
  add_filter('contextual_help', array($this, 'contextual_help'), 10, 3);
405
  * @param string $hook_suffix
406
  */
407
  function admin_enqueue_scripts($hook_suffix) {
408
+ if ($hook_suffix == 'settings_page_email-encoder-bundle/email-encoder-bundle' || $hook_suffix == 'toplevel_page_email-encoder-bundle/email-encoder-bundle') {
409
  // set dashboard postbox
410
  wp_enqueue_script('dashboard');
411
  // set dashboard style for wp < 3.2.0
412
+ if (isset($wp_version) AND version_compare(preg_replace('/-.*$/', '', $wp_version), '3.2.0', '<')) {
413
  wp_admin_css('dashboard');
414
  }
415
 
416
  // add style and script for ajax encoder
417
+ wp_enqueue_script('email_encoder', plugins_url('js/email-encoder-bundle.js', __FILE__), array('jquery'), $this->version);
418
+ wp_enqueue_script('email_encoder_admin', plugins_url('js/email-encoder-bundle-admin.js', __FILE__), array('jquery'), $this->version);
419
  }
420
  }
421
 
433
  function options_page() {
434
  ?>
435
  <div class="wrap">
436
+ <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>
437
  <h2>Email Encoder Bundle - <em><small><?php _e('Protecting Email Addresses', $this->domain) ?></small></em></h2>
438
 
439
  <script type="text/javascript">
441
  </script>
442
  <div class="postbox-container metabox-holder meta-box-sortables" style="width: 68%">
443
  <div style="margin:0 2%;">
444
+ <form method="post" action="options.php">
445
+ <?php
446
+ settings_fields($this->domain);
447
+ $this->set_options();
448
+ $options = $this->options;
449
+ ?>
450
  <div class="postbox">
451
  <div class="handlediv" title="<?php _e('Click to toggle') ?>"><br/></div>
452
  <h3 class="hndle"><?php _e('General Settings') ?></h3>
453
  <div class="inside">
454
+ <?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php')): ?>
 
 
 
 
 
 
455
  <p class="description"><?php _e('Warning: "WP Mailto Links"-plugin is also activated, which could cause conflicts.', $this->domain) ?></p>
456
  <?php endif; ?>
457
  <fieldset class="options">
459
  <tr>
460
  <th><?php _e('Encoding Method for Protection', $this->domain) ?></th>
461
  <td><select id="<?php echo $this->options_name ?>[method]" name="<?php echo $this->options_name ?>[method]" class="method-info-select postform">
462
+ <?php foreach ($this->methods AS $method => $info): ?>
463
+ <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>
464
  <?php endforeach; ?>
465
  </select>
466
  <br />
468
  </td>
469
  </tr>
470
  <tr>
471
+ <th><?php _e('Auto-Protect Emails', $this->domain) ?></th>
472
  <td>
 
 
 
 
473
  <label><input type="checkbox" id="encode_mailtos" name="<?php echo $this->options_name ?>[encode_mailtos]" value="1" <?php checked('1', (int) $options['encode_mailtos']); ?> />
474
+ <span><?php _e('Protect mailto links', $this->domain) ?></span> <span class="description"><?php _e('(example: &lt;a href="info@myemail.com"&gt;My Email&lt;/a&gt;)', $this->domain) ?></span>
475
  </label>
476
  <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']); ?> />
477
  <span><?php _e('Replace plain email addresses to protected mailto links', $this->domain) ?></span> <span class="description"><?php _e('(not recommended)', $this->domain) ?></span>
478
  </label>
479
  <br/>
480
  <br/>
481
+ Apply on:
482
+ <br/>
483
  <label><input type="checkbox" name="<?php echo $this->options_name ?>[filter_posts]" value="1" <?php checked('1', (int) $options['filter_posts']); ?> />
484
+ <span><?php _e('All posts', $this->domain) ?></span>
485
  </label>
486
  <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']); ?> />
487
+ <span><?php _e('All comments', $this->domain) ?></span></label>
488
  <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']); ?> />
489
+ <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>
490
  <br/>
491
  <br/>
492
  <label>
493
+ <span><?php _e('Do <strong>not</strong> apply Auto-Protect on posts with ID:', $this->domain) ?></span>
494
+ <br/><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']; ?>" />
495
  <span class="description"><?php _e('(comma seperated, f.e.: 2, 7, 13, 32)', $this->domain) ?></span>
496
  </label>
497
  </td>
510
  </tr>
511
  </table>
512
  </fieldset>
513
+ <p class="submit">
514
+ <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
515
+ </p>
516
+ </div>
517
+ </div>
518
 
519
+ <div class="postbox">
520
+ <div class="handlediv" title="<?php _e('Click to toggle') ?>"><br/></div>
521
+ <h3 class="hndle"><?php _e('Other Settings') ?></h3>
522
+ <div class="inside">
523
  <fieldset class="options">
524
  <table class="form-table">
525
+ <tr>
526
+ <th><?php _e('Check encoded content', $this->domain) ?></th>
527
+ <td><label><input type="checkbox" id="<?php echo $this->options_name ?>[show_encoded_check]" name="<?php echo $this->options_name ?>[show_encoded_check]" value="1" <?php checked('1', (int) $options['show_encoded_check']); ?> /> <span><?php _e('Show "sucessfully encoded" text for all encoded content, only when logged in as admin user', $this->domain) ?></span> <br /><span class="description">(this way you can check if emails are really encoded on your site)</span></label></td>
528
+ </tr>
529
+ <tr>
530
+ <th><?php _e('Admin menu position', $this->domain) ?></th>
531
+ <td><label><input type="checkbox" id="<?php echo $this->options_name ?>[own_admin_menu]" name="<?php echo $this->options_name ?>[own_admin_menu]" value="1" <?php checked('1', (int) $options['own_admin_menu']); ?> /> <span><?php _e('Show as main menu item', $this->domain) ?></span> <span class="description">(when disabled item will be shown under "General settings")</span></label></td>
532
+ </tr>
533
  <tr>
534
  <th><?php _e('Email Encoder Form Settings', $this->domain) ?></th>
535
  <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>
537
  </table>
538
  </fieldset>
539
  <p class="submit">
540
+ <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
541
  </p>
 
542
  </div>
543
  </div>
544
+ </form>
545
 
546
  <div class="postbox">
547
  <div class="handlediv" title="<?php _e('Click to toggle') ?>"><br/></div>
559
  <div class="handlediv" title="<?php _e('Click to toggle') ?>"><br/></div>
560
  <h3 class="hndle"><?php _e('Other Plugins', $this->domain) ?></h3>
561
  <div class="inside">
562
+ <h4><img src="<?php echo plugins_url('images/icon-wp-external-links.png', __FILE__) ?>" width="16" height="16" /> WP External Links -
563
+ <em>
564
+ <?php if (is_plugin_active('wp-external-links/wp-external-links.php')): ?>
565
+ <?php _e('Activated, see', $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>
566
+ <?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-external-links/wp-external-links.php')): ?>
567
  <a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate this plugin.', $this->domain) ?></a>
568
  <?php else: ?>
569
  <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>
570
  <?php endif; ?>
571
+ </em>
572
  </h4>
573
  <p><?php _e('Manage external links on your site: open in new window/tab, set icon, add "external", add "nofollow" and more.', $this->domain) ?>
574
  <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>
575
  </p>
576
 
577
+ <h4><img src="<?php echo plugins_url('images/icon-wp-mailto-links.png', __FILE__) ?>" width="16" height="16" /> WP Mailto Links -
578
+ <em>
579
+ <?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php')): ?>
580
+ <?php _e('Activated, see', $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>
581
+ <?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-mailto-links/wp-mailto-links.php')): ?>
582
  <a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate this plugin.', $this->domain) ?></a>
583
  <?php else: ?>
584
  <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>
585
  <?php endif; ?>
586
+ </em>
587
  </h4>
588
  <p><?php _e('Manage mailto links on your site and protect emails from spambots, set mail icon and more.', $this->domain) ?>
589
  <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>
609
  <fieldset>
610
  <div class="input">
611
  <table>
612
+ <tbody>
613
  <tr>
614
  <th><label for="email"><?php _e('Email Address:', $this->domain) ?></label></th>
615
  <td><input type="text" class="regular-text" id="email" name="email" /></td>
625
  <tr>
626
  <th><label for="encode_method"><?php _e('Encoding Method:', $this->domain) ?></label></th>
627
  <td><select id="encode_method" name="encode_method" class="postform">
628
+ <?php foreach ($this->methods AS $method => $info): ?>
629
  <option value="<?php echo $method ?>" <?php if ($this->method == $method) echo 'selected="selected"' ?>><?php echo $info['name'] ?></option>
630
  <?php endforeach; ?>
631
  </select>
632
  <input type="button" id="ajax_encode" value="<?php _e('Create Protected Mail Link', $this->domain) ?> &gt;&gt;" />
633
  </td>
634
  </tr>
635
+ </tbody>
636
  </table>
637
  </div>
638
  <div class="output nodis">
639
  <table>
640
+ <tbody>
641
  <tr>
642
  <th><label for="encoded_output"><?php _e('Protected Mail Link (code):', $this->domain) ?></label></th>
643
  <td><textarea class="large-text node" id="encoded_output" name="encoded_output" cols="50" rows="4"></textarea></td>
644
  </tr>
645
+ </tbody>
646
  </table>
647
  </div>
648
+ <?php if ($this->options['powered_by']): ?>
649
  <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>
650
  <?php endif; ?>
651
  </fieldset>
666
  $saved_options = get_option($this->options_name);
667
 
668
  // backwards compatible (old values)
 
 
 
 
669
  if (empty($saved_options)) {
670
+ $saved_options = get_option($this->domain . 'options');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
671
  }
672
 
673
  // set all options
674
  if (!empty($saved_options)) {
675
+ foreach ($saved_options AS $key => $value) {
676
+ $this->options[$key] = $value;
677
  }
678
  }
679
 
682
 
683
  // set widget_content filter of Widget Logic plugin
684
  $widget_logic_opts = get_option('widget_logic');
685
+ if (is_array($widget_logic_opts) AND key_exists('widget_logic-options-filter', $widget_logic_opts)) {
686
  $this->options['widget_logic_filter'] = ($widget_logic_opts['widget_logic-options-filter'] == 'checked') ? 1 : 0;
687
  }
688
  }
751
  * @return string
752
  */
753
  function get_html_checked($content) {
754
+ if (!$this->logged_in || !$this->options['show_encoded_check']) {
755
+ return $content;
756
+ }
757
+
758
  return $content
759
  . '<a href="javascript:;" class="encoded-check"'
760
+ . ' title="' . __('Successfully Encoded (this is a check and only visible when logged in as admin)', $this->domain) . '">'
761
  . '<img class="encoded-check-icon" src="' . plugins_url('images/icon-email-encoder-bundle.png', __FILE__)
762
+ . '" alt="' . __('Encoded', $this->domain) . '" />'
763
+ . __('Successfully Encoded', $this->domain) . '</a>';
764
  }
765
 
766
  /**
767
  * Encode the given email into an encoded HTML link
768
  * @param string $content
769
  * @param string $method Optional, else the default setted method will; be used
770
+ * @param boolean $no_html_checked
771
  * @return string
772
  */
773
+ function encode($content, $method = NULL, $no_html_checked = FALSE) {
774
  // get encode method
775
  $method = $this->get_method($method, $this->method);
776
 
777
+ // add visual check
778
+ if ($no_html_checked !== TRUE) {
779
  $content = $this->get_html_checked($content);
780
  }
781
 
791
  * @param string $extra_attrs Optional
792
  * @return string
793
  */
794
+ function encode_email($email, $display = NULL, $method = NULL, $extra_attrs = '', $no_html_checked = FALSE) {
795
  // decode entities
796
  $email = html_entity_decode($email);
797
 
815
  $mailto = '<a class="'. $class .'" href="mailto:' . $email . '"'. $extra_attrs . '>' . $display . '</a>';
816
 
817
  if ($method === 'enc_html') {
818
+ // add visual check
819
+ if ($no_html_checked !== TRUE) {
820
+ $mailto = $this->get_html_checked($mailto);
821
+ }
822
  } else {
823
+ $mailto = $this->encode($mailto, $method, $no_html_checked);
824
  }
825
 
826
  // get encoded email code
920
  srand((float) microtime() * 1000000);
921
 
922
  for ($i = 0; $i < strlen($value); $i = $i + 1) {
923
+ $j = floor(rand( 0, 1));
924
 
925
  if ($j == 0) {
926
  $enc_value .= '&#' . ord(substr($value, $i, 1)) . ';';
954
  $email = $_GET['email'];
955
  $display = (empty($_GET['display'])) ? $email : $_GET['display'];
956
 
957
+ echo $WP_Email_Encoder_Bundle->encode_email($email, $display, $method, '', TRUE);
958
  exit;
959
  endif;
960
 
998
  * @return string
999
  */
1000
  if (!function_exists('encode_email_filter')):
1001
+ function encode_email_filter($content, $enc_tags = TRUE, $enc_mailtos = TRUE, $enc_plain_emails = TRUE) {
1002
  global $WP_Email_Encoder_Bundle;
1003
  return $WP_Email_Encoder_Bundle->filter($content, $enc_tags, $enc_mailtos, $enc_plain_emails);
1004
  }
images/icon-email-encoder-bundle-16.png ADDED
Binary file
js/email-encoder-bundle-admin.js CHANGED
@@ -5,13 +5,6 @@ jQuery(function ($) {
5
 
6
  var methodInfo = window.methodInfo;
7
 
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 () {
@@ -54,14 +47,36 @@ jQuery(function ($) {
54
  // add form-table class to Encoder Form tables
55
  $('.email-encoder-form table').addClass('form-table');
56
 
 
 
 
 
 
 
 
57
  // slide postbox
58
- $('.postbox').find('.handlediv, .hndle').click(function () {
59
  var $inside = $(this).parent().find('.inside');
60
 
61
  if ($inside.css('display') === 'block') {
62
- $inside.css({ display:'block' }).slideUp();
63
  } else {
64
- $inside.css({ display:'none' }).slideDown();
65
  }
66
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  });
5
 
6
  var methodInfo = window.methodInfo;
7
 
 
 
 
 
 
 
 
8
  // set info text for selected encoding method
9
  $('.method-info-select')
10
  .bind('change', function () {
47
  // add form-table class to Encoder Form tables
48
  $('.email-encoder-form table').addClass('form-table');
49
 
50
+ // remove message
51
+ $('.settings-error:first')
52
+ .hide()
53
+ .fadeIn(600)
54
+ .delay(3000)
55
+ .fadeOut(600);
56
+
57
  // slide postbox
58
+ $('.postbox').find('.handlediv, .hndle').click(function(){
59
  var $inside = $(this).parent().find('.inside');
60
 
61
  if ($inside.css('display') === 'block') {
62
+ $inside.css({ display:'block' }).fadeOut();
63
  } else {
64
+ $inside.css({ display:'none' }).fadeIn();
65
  }
66
  });
67
+
68
+ // prepare checkboxes before submit
69
+ $('.wrap form').submit(function () {
70
+ // force value 0 being saved in options
71
+ $('*[type="checkbox"]:not(:checked)')
72
+ .css({ 'visibility': 'hidden' })
73
+ .attr({
74
+ 'value': '0',
75
+ 'checked': 'checked'
76
+ });
77
+ });
78
+
79
+ // enable
80
+ $('*[type="submit"]').attr('disabled', false);
81
+
82
  });
readme.txt CHANGED
@@ -3,13 +3,13 @@ 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
@@ -86,7 +86,15 @@ It's possible to filter all widgets by using the Widget Logic plugin and activat
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
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.71
7
 
8
+ Encode mailto links and (plain) email addresses on your site and hide them from spambots. Easy to use, plugin works directly when activated.
9
 
10
  == Description ==
11
 
12
+ Encode mailto links and (plain) email addresses on your site and hide them from spambots. Easy to use, plugin works directly when activated.
13
 
14
  = Features =
15
  * Protect all emails and mailto links
86
 
87
  == Changelog ==
88
 
89
+ = 0.71 (latest) =
90
+ * Option to make own menu item (in admin panel) for this plugin
91
+ * Option for showing "successfully encoded" check
92
+ * Fixed bug showing errors for calling wrong translate function
93
+ * Fixed bug always showing encoded check on site (for html encode method)
94
+ * Added workaround for saving disabled checkboxes in options table
95
+ * Fixed bug where encoded check was also applied on output of encoding form
96
+
97
+ = 0.70 =
98
  * Fixed bug with extra params
99
  * Changed texts and added help tabs on admin options page
100
  * Changed visual check for encoded mails/content by showing icon and success message