Email Encoder Bundle – Protect Email Address - Version 1.2.0

Version Description

  • Added filter for Encoder Form content (eeb_form_content)
Download this release

Release Info

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

Code changes from version 1.1.0 to 1.2.0

LICENSE ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Victor Villaverde Laan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
README.md ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ Email Encoder Bundle
2
+ ====================
3
+
4
+ Sharing the code of this WordPress plugin. Now everybody can contribute their improvements, bug fixes and new features.
5
+
6
+ See http://wordpress.org/plugins/email-encoder-bundle/
email-encoder-bundle.php CHANGED
@@ -1,71 +1,65 @@
1
- <?php defined('ABSPATH') OR die('No direct access.');
2
- /*
3
- Plugin Name: Email Encoder Bundle - Protect Email Address
4
- Plugin URI: http://www.freelancephp.net/email-encoder-php-class-wp-plugin/
5
- Description: Protect email addresses on your site and hide them from spambots by using an encoding method. Easy to use, flexible .
6
- Author: Victor Villaverde Laan
7
- Version: 1.1.0
8
- Author URI: http://www.freelancephp.net
9
- License: Dual licensed under the MIT and GPL licenses
10
- Text Domain: email-encoder-bundle
11
- Domain Path: /languages
12
- */
13
-
14
- // constants
15
- if (!defined('EMAIL_ENCODER_BUNDLE_VERSION')) { define('EMAIL_ENCODER_BUNDLE_VERSION', '1.1.0'); }
16
- if (!defined('EMAIL_ENCODER_BUNDLE_FILE')) { define('EMAIL_ENCODER_BUNDLE_FILE', __FILE__); }
17
- if (!defined('EMAIL_ENCODER_BUNDLE_KEY')) { define('EMAIL_ENCODER_BUNDLE_KEY', 'WP_Email_Encoder_Bundle'); }
18
- if (!defined('EMAIL_ENCODER_BUNDLE_DOMAIN')) { define('EMAIL_ENCODER_BUNDLE_DOMAIN', 'email-encoder-bundle'); }
19
- if (!defined('EMAIL_ENCODER_BUNDLE_OPTIONS_NAME')) { define('EMAIL_ENCODER_BUNDLE_OPTIONS_NAME', 'WP_Email_Encoder_Bundle_options'); }
20
- if (!defined('EMAIL_ENCODER_BUNDLE_ADMIN_PAGE')) { define('EMAIL_ENCODER_BUNDLE_ADMIN_PAGE', 'email-encoder-bundle-settings'); }
21
-
22
- // check plugin compatibility
23
- if (isset($wp_version)
24
- && version_compare(preg_replace('/-.*$/', '', $wp_version), '3.4', '>=')
25
- && version_compare(phpversion(), '5.2.4', '>=')) {
26
-
27
- // include classes
28
- require_once('includes/class-eeb-admin.php');
29
- require_once('includes/class-eeb-site.php');
30
- require_once('includes/template-functions.php');
31
-
32
- // create instance
33
- $Eeb_Site = Eeb_Site::getInstance();
34
-
35
- // handle AJAX request
36
- if (!empty($_GET['ajaxEncodeEmail'])):
37
- // input vars
38
- $method = $_GET['method'];
39
- $email = $_GET['email'];
40
- $display = (empty($_GET['display'])) ? $email : $_GET['display'];
41
-
42
- echo $Eeb_Site->encode_email($email, $display, '', $method, true);
43
- exit;
44
- endif;
45
-
46
- // for testing purposes
47
- if (file_exists($_SERVER['DOCUMENT_ROOT'] . 'wp/plugins/wp-plugin-tester/tests/test-email-encoder-bundle.php')) {
48
- require_once($_SERVER['DOCUMENT_ROOT'] . 'wp/plugins/wp-plugin-tester/wp-plugin-tester.php');
49
- require_once($_SERVER['DOCUMENT_ROOT'] . 'wp/plugins/wp-plugin-tester/tests/test-email-encoder-bundle.php');
50
- }
51
-
52
- } else {
53
-
54
- // set error message
55
- if (!function_exists('eeb_error_notice')):
56
- function eeb_error_notice() {
57
- $plugin_title = get_admin_page_title();
58
-
59
- echo '<div class="error">'
60
- . sprintf(__('<p>Warning - The plugin <strong>%s</strong> requires PHP 5.2.4+ and WP 3.4+. Please upgrade your PHP and/or WordPress.'
61
- . '<br/>Disable the plugin to remove this message.</p>'
62
- , EMAIL_ENCODER_BUNDLE_DOMAIN), $plugin_title)
63
- . '</div>';
64
- }
65
-
66
- add_action('admin_notices', 'eeb_error_notice');
67
- endif;
68
-
69
- }
70
-
71
  /* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
1
+ <?php defined('ABSPATH') OR die('No direct access.');
2
+ /*
3
+ Plugin Name: Email Encoder Bundle - Protect Email Address
4
+ Plugin URI: http://www.freelancephp.net/email-encoder-php-class-wp-plugin/
5
+ Description: Protect email addresses on your site and hide them from spambots by using an encoding method. Easy to use, flexible .
6
+ Author: Victor Villaverde Laan
7
+ Version: 1.2.0
8
+ Author URI: http://www.freelancephp.net
9
+ License: Dual licensed under the MIT and GPL licenses
10
+ Text Domain: email-encoder-bundle
11
+ Domain Path: /languages
12
+ */
13
+
14
+ // constants
15
+ if (!defined('EMAIL_ENCODER_BUNDLE_VERSION')) { define('EMAIL_ENCODER_BUNDLE_VERSION', '1.2.0'); }
16
+ if (!defined('EMAIL_ENCODER_BUNDLE_FILE')) { define('EMAIL_ENCODER_BUNDLE_FILE', __FILE__); }
17
+ if (!defined('EMAIL_ENCODER_BUNDLE_KEY')) { define('EMAIL_ENCODER_BUNDLE_KEY', 'WP_Email_Encoder_Bundle'); }
18
+ if (!defined('EMAIL_ENCODER_BUNDLE_DOMAIN')) { define('EMAIL_ENCODER_BUNDLE_DOMAIN', 'email-encoder-bundle'); }
19
+ if (!defined('EMAIL_ENCODER_BUNDLE_OPTIONS_NAME')) { define('EMAIL_ENCODER_BUNDLE_OPTIONS_NAME', 'WP_Email_Encoder_Bundle_options'); }
20
+ if (!defined('EMAIL_ENCODER_BUNDLE_ADMIN_PAGE')) { define('EMAIL_ENCODER_BUNDLE_ADMIN_PAGE', 'email-encoder-bundle-settings'); }
21
+
22
+ // check plugin compatibility
23
+ if (isset($wp_version)
24
+ && version_compare(preg_replace('/-.*$/', '', $wp_version), '3.4', '>=')
25
+ && version_compare(phpversion(), '5.2.4', '>=')) {
26
+
27
+ // include classes
28
+ require_once('includes/class-eeb-admin.php');
29
+ require_once('includes/class-eeb-site.php');
30
+ require_once('includes/template-functions.php');
31
+
32
+ // create instance
33
+ $Eeb_Site = Eeb_Site::getInstance();
34
+
35
+ // handle AJAX request
36
+ if (!empty($_GET['ajaxEncodeEmail'])):
37
+ // input vars
38
+ $method = $_GET['method'];
39
+ $email = $_GET['email'];
40
+ $display = (empty($_GET['display'])) ? $email : $_GET['display'];
41
+
42
+ echo $Eeb_Site->encode_email($email, $display, '', $method, true);
43
+ exit;
44
+ endif;
45
+
46
+ } else {
47
+
48
+ // set error message
49
+ if (!function_exists('eeb_error_notice')):
50
+ function eeb_error_notice() {
51
+ $plugin_title = get_admin_page_title();
52
+
53
+ echo '<div class="error">'
54
+ . sprintf(__('<p>Warning - The plugin <strong>%s</strong> requires PHP 5.2.4+ and WP 3.4+. Please upgrade your PHP and/or WordPress.'
55
+ . '<br/>Disable the plugin to remove this message.</p>'
56
+ , EMAIL_ENCODER_BUNDLE_DOMAIN), $plugin_title)
57
+ . '</div>';
58
+ }
59
+
60
+ add_action('admin_notices', 'eeb_error_notice');
61
+ endif;
62
+
63
+ }
64
+
 
 
 
 
 
 
65
  /* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
includes/class-eeb-admin.php CHANGED
@@ -1,816 +1,837 @@
1
- <?php defined('ABSPATH') OR die('No direct access.');
2
-
3
- /**
4
- * Class Eeb_Admin
5
- *
6
- * Contains all code nescessary for the Admin part
7
- *
8
- * @abstract
9
- *
10
- * @package Email_Encoder_Bundle
11
- * @category WordPress Plugins
12
- */
13
- if (!class_exists('Eeb_Admin')):
14
-
15
- abstract class Eeb_Admin {
16
-
17
- /**
18
- * @var array
19
- */
20
- private $default_options = array(
21
- 'version' => null,
22
- 'method' => 'enc_ascii',
23
- 'encode_mailtos' => 1,
24
- 'encode_emails' => 0,
25
- 'filter_posts' => 1,
26
- 'filter_widgets' => 1,
27
- 'filter_comments' => 1,
28
- 'skip_posts' => '',
29
- 'protection_text' => '*protected email*',
30
- 'class_name' => 'mailto-link',
31
- 'filter_rss' => 1,
32
- 'remove_shortcodes_rss' => 1,
33
- 'protection_text_rss' => '*protected email*',
34
- 'widget_logic_filter' => 0,
35
- 'show_encoded_check' => 0,
36
- 'shortcodes_in_widgets' => 0,
37
- 'support_deprecated_names' => 0,
38
- 'own_admin_menu' => 1,
39
- 'powered_by' => 1,
40
- );
41
-
42
- /**
43
- * @var array
44
- */
45
- protected $options = array();
46
-
47
- /**
48
- * @var array
49
- */
50
- protected $skip_posts = array();
51
-
52
- /**
53
- * @var string
54
- */
55
- protected $method = 'enc_ascii';
56
-
57
- /**
58
- * @var array
59
- */
60
- private $methods = array();
61
-
62
- /**
63
- * @var boolean
64
- */
65
- private $initial_metabox_settings = false;
66
-
67
- /**
68
- * Constructor
69
- */
70
- protected function __construct() {
71
- // load text domain for translations
72
- load_plugin_textdomain(EMAIL_ENCODER_BUNDLE_DOMAIN, false, dirname(plugin_basename(EMAIL_ENCODER_BUNDLE_FILE)) . '/languages/');
73
-
74
- // set methods
75
- $this->methods = array(
76
- 'enc_ascii' => array(
77
- 'name' => __('JS Rot13', EMAIL_ENCODER_BUNDLE_DOMAIN),
78
- 'description' => __('Recommended, the savest method using a rot13 method in JavaScript.', EMAIL_ENCODER_BUNDLE_DOMAIN),
79
- ),
80
- 'enc_escape' => array(
81
- 'name' => __('JS Escape', EMAIL_ENCODER_BUNDLE_DOMAIN),
82
- 'description' => __('Pretty save method using JavaScipt\'s escape function.', EMAIL_ENCODER_BUNDLE_DOMAIN),
83
- ),
84
- 'enc_html' => array(
85
- 'name' => __('Html Encode', EMAIL_ENCODER_BUNDLE_DOMAIN),
86
- 'description' => __('Not recommended, equal to <a href="http://codex.wordpress.org/Function_Reference/antispambot" target="_blank"><code>antispambot()</code></a> function of WordPress.', EMAIL_ENCODER_BUNDLE_DOMAIN),
87
- ),
88
- );
89
-
90
- // set option values
91
- $this->set_options();
92
-
93
- // prepare vars
94
- $skip_posts = $this->options['skip_posts'];
95
- $skip_posts = str_replace(' ', '', $skip_posts);
96
- $skip_posts = explode(',', $skip_posts);
97
- $this->skip_posts = $skip_posts;
98
-
99
- // set uninstall hook
100
- register_uninstall_hook(EMAIL_ENCODER_BUNDLE_FILE, array('Eeb_Admin', 'uninstall'));
101
-
102
- // add actions
103
- add_action('wp', array($this, 'wp'));
104
- add_action('admin_init', array($this, 'admin_init'));
105
- add_action('admin_menu', array($this, 'admin_menu'));
106
- }
107
-
108
- /**
109
- * Set options from save values or defaults
110
- */
111
- private function set_options() {
112
- $upgrade = false;
113
-
114
- // first set defaults
115
- $this->options = $this->default_options;
116
-
117
- // get saved options
118
- $saved_options = get_option(EMAIL_ENCODER_BUNDLE_OPTIONS_NAME);
119
-
120
- // backwards compatible (old values)
121
- if (empty($saved_options)) {
122
- $saved_options = get_option(EMAIL_ENCODER_BUNDLE_KEY . 'options');
123
-
124
- // cleanup old values
125
- delete_option(EMAIL_ENCODER_BUNDLE_KEY . 'options');
126
- }
127
-
128
- $version = get_option('eeb_version');
129
- if ($version !== false) {
130
- $saved_options['version'] = $version;
131
-
132
- // cleanup old value
133
- delete_option('eeb_version');
134
- }
135
-
136
- // set all options
137
- if (!empty($saved_options)) {
138
- $upgrade = true;
139
-
140
- foreach ($saved_options AS $key => $value) {
141
- $this->options[$key] = $value;
142
- }
143
- }
144
-
145
- if ($saved_options['version'] != EMAIL_ENCODER_BUNDLE_VERSION) {
146
- if (empty($saved_options['version'])) {
147
- if ($upgrade) {
148
- // upgrade from version < 1.0.0
149
- $this->options['support_deprecated_names'] = 1;
150
- $this->options['shortcodes_in_widgets'] = 1;
151
-
152
- //update_option(EMAIL_ENCODER_BUNDLE_OPTIONS_NAME, $this->options);
153
- } else {
154
- // first time
155
- $this->initial_metabox_settings = true;
156
- }
157
- } else {
158
- // upgrading from version >= 1.0.0
159
-
160
- }
161
-
162
- // update version
163
- update_option(EMAIL_ENCODER_BUNDLE_OPTIONS_NAME, $this->options);
164
- }
165
-
166
- // set encode method
167
- $this->method = $this->get_method($this->options['method'], 'enc_ascii');
168
-
169
- // set widget_content filter of Widget Logic plugin
170
- $widget_logic_opts = get_option('widget_logic');
171
- if (is_array($widget_logic_opts) && key_exists('widget_logic-options-filter', $widget_logic_opts)) {
172
- $this->options['widget_logic_filter'] = ($widget_logic_opts['widget_logic-options-filter'] == 'checked') ? 1 : 0;
173
- }
174
- }
175
-
176
- /**
177
- * Get method name
178
- * @param string $method
179
- * @param string $defaultMethod Optional, default 'enc_html'
180
- * @return string
181
- */
182
- protected function get_method($method, $defaultMethod = 'enc_html') {
183
- $method = strtolower($method);
184
-
185
- if (!method_exists($this, $method)) {
186
- $method = $defaultMethod; // set default method
187
- }
188
-
189
- return $method;
190
- }
191
-
192
- /**
193
- * Callback Uninstall
194
- */
195
- static public function uninstall() {
196
- delete_option(EMAIL_ENCODER_BUNDLE_OPTIONS_NAME);
197
- unregister_setting(EMAIL_ENCODER_BUNDLE_KEY, EMAIL_ENCODER_BUNDLE_OPTIONS_NAME);
198
- }
199
-
200
- /**
201
- * Callbacka admin_init
202
- */
203
- public function admin_init() {
204
- // register settings
205
- register_setting(EMAIL_ENCODER_BUNDLE_KEY, EMAIL_ENCODER_BUNDLE_OPTIONS_NAME);
206
-
207
- // actions and filters
208
- add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2);
209
- }
210
-
211
- /**
212
- * Callback add links on plugin page
213
- * @param array $links
214
- * @param string $file
215
- * @return array
216
- */
217
- public function plugin_action_links($links, $file) {
218
- if ($file == plugin_basename(EMAIL_ENCODER_BUNDLE_FILE)) {
219
- $page = ($this->options['own_admin_menu']) ? 'admin.php' : 'options-general.php';
220
- $settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/' . $page . '?page=' . EMAIL_ENCODER_BUNDLE_ADMIN_PAGE . '">' . __('Settings', EMAIL_ENCODER_BUNDLE_DOMAIN) . '</a>';
221
- array_unshift($links, $settings_link);
222
- }
223
-
224
- return $links;
225
- }
226
-
227
- /**
228
- * Callback admin_menu
229
- */
230
- public function admin_menu() {
231
- // add page and menu item
232
- if ($this->options['own_admin_menu']) {
233
- // create main menu item
234
- $page_hook = add_menu_page(__('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN), __('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN),
235
- 'manage_options', EMAIL_ENCODER_BUNDLE_ADMIN_PAGE, array($this, 'show_options_page'),
236
- plugins_url('images/icon-email-encoder-bundle-16.png', EMAIL_ENCODER_BUNDLE_FILE));
237
- } else {
238
- // create submenu item under "Settings"
239
- $page_hook = add_submenu_page('options-general.php', __('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN), __('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN),
240
- 'manage_options', EMAIL_ENCODER_BUNDLE_ADMIN_PAGE, array($this, 'show_options_page'));
241
- }
242
-
243
- // load plugin page
244
- add_action('load-' . $page_hook, array($this, 'load_options_page'));
245
- }
246
-
247
- /* -------------------------------------------------------------------------
248
- * Admin Options Page
249
- * ------------------------------------------------------------------------*/
250
-
251
- /**
252
- * Load admin options page
253
- */
254
- public function load_options_page() {
255
- // set dashboard postbox
256
- wp_enqueue_script('dashboard');
257
-
258
- // add script for ajax encoder
259
- //wp_enqueue_script('email_encoder', plugins_url('js/src/email-encoder-bundle.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
260
- //wp_enqueue_script('email_encoder_admin', plugins_url('js/src/email-encoder-bundle-admin.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
261
- wp_enqueue_script('email_encoder', plugins_url('js/email-encoder-bundle.min.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
262
-
263
- // add help tabs
264
- $this->add_help_tabs();
265
-
266
- // screen settings
267
- if (function_exists('add_screen_option')) {
268
- add_screen_option('layout_columns', array(
269
- 'max' => 2,
270
- 'default' => 2
271
- ));
272
- }
273
-
274
- // add meta boxes
275
- add_meta_box('main_settings', __('Main Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('main_settings'));
276
- add_meta_box('additional_settings', __('Additional Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('additional_settings'));
277
- add_meta_box('rss_settings', __('RSS Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('rss_settings'));
278
- add_meta_box('admin_settings', __('Admin Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('admin_settings'));
279
- add_meta_box('encode_form', __('Email Encoder Form', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('encode_form'));
280
- add_meta_box('this_plugin', __('Support', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'side', 'core', array('this_plugin'));
281
- add_meta_box('other_plugins', __('Other Plugins', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'side', 'core', array('other_plugins'));
282
- }
283
-
284
- /**
285
- * Show admin options page
286
- */
287
- public function show_options_page() {
288
- $this->set_options();
289
- ?>
290
- <div class="wrap">
291
- <div class="icon32" id="icon-options-custom" style="background:url(<?php echo plugins_url('images/icon-email-encoder-bundle.png', EMAIL_ENCODER_BUNDLE_FILE) ?>) no-repeat 50% 50%"><br></div>
292
- <h2><?php echo get_admin_page_title() ?> - <em><small><?php _e('Protect Email Addresses', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></small></em></h2>
293
-
294
- <?php if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' && $this->options['own_admin_menu']): ?>
295
- <div class="updated settings-error" id="setting-error-settings_updated">
296
- <p><strong><?php _e('Settings saved.' ) ?></strong></p>
297
- </div>
298
- <?php endif; ?>
299
-
300
- <?php if ($this->initial_metabox_settings): ?>
301
- <script type="text/javascript">jQuery(function($){ $('#additional_settings, #rss_settings, #admin_settings, #encode_form').addClass('closed'); });</script>
302
- <?php endif; ?>
303
-
304
- <form method="post" action="options.php">
305
- <?php settings_fields(EMAIL_ENCODER_BUNDLE_KEY); ?>
306
-
307
- <input type="hidden" name="<?php echo EMAIL_ENCODER_BUNDLE_KEY ?>_nonce" value="<?php echo wp_create_nonce(EMAIL_ENCODER_BUNDLE_KEY) ?>" />
308
- <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
309
- <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
310
-
311
- <div id="poststuff">
312
- <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
313
- <!--<div id="post-body-content"></div>-->
314
-
315
- <div id="postbox-container-1" class="postbox-container">
316
- <?php do_meta_boxes('', 'side', ''); ?>
317
- </div>
318
-
319
- <div id="postbox-container-2" class="postbox-container">
320
- <?php do_meta_boxes('', 'normal', ''); ?>
321
- <?php do_meta_boxes('', 'advanced', ''); ?>
322
- </div>
323
- </div> <!-- #post-body -->
324
- </div> <!-- #poststuff -->
325
- </form>
326
- </div>
327
- <?php
328
- }
329
-
330
- /**
331
- * Show content of metabox (callback)
332
- * @param array $post
333
- * @param array $meta_box
334
- */
335
- public function show_meta_box_content($post, $meta_box) {
336
- $key = $meta_box['args'][0];
337
- $options = $this->options;
338
-
339
- if ($key === 'main_settings') {
340
- ?>
341
- <?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php')): ?>
342
- <p class="description"><?php _e('Warning: "WP Mailto Links"-plugin is also activated, which could cause conflicts.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></p>
343
- <?php endif; ?>
344
- <fieldset class="options">
345
- <table class="form-table">
346
- <tr>
347
- <th><?php _e('Choose what to protect', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
348
- <td>
349
- <label><input type="checkbox" id="encode_mailtos" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[encode_mailtos]" value="1" <?php checked('1', (int) $options['encode_mailtos']); ?> />
350
- <span><?php _e('Protect mailto links, like f.e. <code>&lt;a href="info@myemail.com"&gt;My Email&lt;/a&gt;</code>', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
351
- <br/><label><input type="checkbox" id="encode_emails" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[encode_emails]" value="1" <?php checked('1', (int) $options['encode_emails']); ?> disabled="disabled" />
352
- <span><?php _e('Replace plain email addresses to protected mailto links.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
353
- <span class="description notice-form-field-bug"><br/><?php _e('Notice: be carefull with this option when using email addresses on form fields, please <a href="http://wordpress.org/extend/plugins/email-encoder-bundle/faq/" target="_blank">check the FAQ</a> for more info.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
354
- </label>
355
- <br/>
356
- </td>
357
- </tr>
358
- <tr>
359
- <th><?php _e('Apply on...', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
360
- <td>
361
- <label><input type="checkbox" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_posts]" value="1" <?php checked('1', (int) $options['filter_posts']); ?> />
362
- <span><?php _e('All posts and pages', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
363
- </label>
364
- <br/><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_comments]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_comments]" value="1" <?php checked('1', (int) $options['filter_comments']); ?> />
365
- <span><?php _e('All comments', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
366
- <br/><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_widgets]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_widgets]" value="1" <?php checked('1', (int) $options['filter_widgets']); ?> />
367
- <span><?php if ($this->options['widget_logic_filter']) { _e('All widgets (uses the <code>widget_content</code> filter of the Widget Logic plugin)', EMAIL_ENCODER_BUNDLE_DOMAIN); } else { _e('All text widgets', EMAIL_ENCODER_BUNDLE_DOMAIN); } ?></span></label>
368
- </td>
369
- </tr>
370
- <tr>
371
- <th><?php _e('Add class to protected mailto links', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
372
- <td><label><input type="text" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[class_name]" class="regular-text" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[class_name]" value="<?php echo $options['class_name']; ?>" />
373
- <br/><span class="description"><?php _e('All protected mailto links will get these class(es). Optional, else keep blank.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label></td>
374
- </tr>
375
- </table>
376
- </fieldset>
377
-
378
- <p class="submit">
379
- <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
380
- </p>
381
- <br class="clear" />
382
-
383
- <?php
384
- } else if ($key === 'rss_settings') {
385
- ?>
386
- <fieldset class="options">
387
- <table class="form-table">
388
- <tr>
389
- <th><?php _e('Protect emails in RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
390
- <td><label><input type="checkbox" id="filter_rss" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_rss]" value="1" <?php checked('1', (int) $options['filter_rss']); ?> />
391
- <span><?php _e('Replace emails in RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
392
- </td>
393
- </tr>
394
- <tr>
395
- <th><?php _e('Remove shortcodes from RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
396
- <td><label><input type="checkbox" id="remove_shortcodes_rss" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[remove_shortcodes_rss]" value="1" <?php checked('1', (int) $options['remove_shortcodes_rss']); ?> />
397
- <span><?php _e('Remove all shortcodes from the RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
398
- </td>
399
- </tr>
400
- <tr>
401
- <th><?php _e('Set protection text in RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
402
- <td><label><input type="text" id="protection_text" class="regular-text" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[protection_text_rss]" value="<?php echo $options['protection_text_rss']; ?>" />
403
- <br/><span class="description"><?php _e('Used as replacement for email addresses in RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
404
- </label>
405
- </td>
406
- </tr>
407
- </table>
408
- </fieldset>
409
-
410
- <p class="submit">
411
- <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
412
- </p>
413
- <br class="clear" />
414
- <?php
415
- } else if ($key === 'additional_settings') {
416
- ?>
417
- <fieldset class="options">
418
- <table class="form-table">
419
- <tr>
420
- <th><?php _e('Choose protection method', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
421
- <td>
422
- <?php foreach ($this->methods AS $method => $info): ?>
423
- <label>
424
- <input type="radio" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[method]" class="protection-method" value="<?php echo $method ?>" <?php if ($this->method == $method) echo 'checked="checked"' ?> />
425
- <span><?php echo $info['name'] ?></span>
426
- - <span class="description"><?php echo $info['description'] ?></span>
427
- </label>
428
- <br/>
429
- <?php endforeach; ?>
430
- </td>
431
- </tr>
432
- <tr>
433
- <th><?php _e('Set <code>&lt;noscript&gt;</code> text', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
434
- <td><label><input type="text" id="protection_text" class="regular-text" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[protection_text]" value="<?php echo $options['protection_text']; ?>" />
435
- <br/><span class="description"><?php _e('Used for the <code>&lt;noscript&gt;</code> fallback for JavaScrip methods.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
436
- </label>
437
- </td>
438
- </tr>
439
- <tr>
440
- <th><?php _e('Exclude posts', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
441
- <td>
442
- <label>
443
- <span><?php _e('Do <strong>not</strong> apply protection on posts or pages with the folllowing ID:', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
444
- <br/><input type="text" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[skip_posts]" class="regular-text" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[skip_posts]" value="<?php echo $options['skip_posts']; ?>" />
445
- <br/><span class="description"><?php _e('Seperate Id\'s by comma, f.e.: 2, 7, 13, 32.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
446
- <br/><span class="description"><?php _e('Notice: shortcodes still work on these posts.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
447
- </label>
448
- </td>
449
- </tr>
450
- <tr>
451
- <th><?php _e('Use shortcodes in widgets', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
452
- <td>
453
- <label><input type="checkbox" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[shortcodes_in_widgets]" value="1" <?php checked('1', (int) $options['shortcodes_in_widgets']); ?> />
454
- <span><?php _e('Also use shortcodes in widgets.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
455
- <br/><span class="description"><?php if (!$this->options['widget_logic_filter']) { _e('Notice: only works for text widgets!', EMAIL_ENCODER_BUNDLE_DOMAIN); } else { _e('All text widgets', EMAIL_ENCODER_BUNDLE_DOMAIN); } ?></span></label>
456
- </label>
457
- </td>
458
- </tr>
459
- <tr>
460
- <th><?php _e('Use deprecated names', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
461
- <td><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[support_deprecated_names]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[support_deprecated_names]" value="1" <?php checked('1', (int) $options['support_deprecated_names']); ?> />
462
- <span><?php _e('Keep supporting the old names for action, shortcodes and template functions.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
463
- <br /><span class="description">These deprecated will still be available: <code>init_email_encoder_bundle</code>, <code>[encode_email]</code>, <code>[encode_content]</code>, <code>[email_encoder_form]</code>, <code>encode_email()</code>, <code>encode_content()</code>, <code>encode_email_filter()</code></span></label></td>
464
- </tr>
465
- </table>
466
- </fieldset>
467
-
468
- <p class="submit">
469
- <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
470
- </p>
471
- <br class="clear" />
472
- <?php
473
- } else if ($key === 'admin_settings') {
474
- ?>
475
- <fieldset class="options">
476
- <table class="form-table">
477
- <tr>
478
- <th><?php _e('Check "succesfully encoded"', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
479
- <td><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[show_encoded_check]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[show_encoded_check]" value="1" <?php checked('1', (int) $options['show_encoded_check']); ?> />
480
- <span><?php _e('Show "successfully encoded" text for all encoded content, only when logged in as admin user.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
481
- <br/><span class="description"><?php _e('This way you can check if emails are really encoded on your site.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
482
- </label>
483
- </td>
484
- </tr>
485
- <tr>
486
- <th><?php _e('Choose admin menu position', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
487
- <td><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[own_admin_menu]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[own_admin_menu]" value="1" <?php checked('1', (int) $options['own_admin_menu']); ?> />
488
- <span><?php _e('Show as main menu item.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
489
- <br /><span class="description">When disabled this page will be available under "General settings".</span>
490
- </label>
491
- </td>
492
- </tr>
493
- </table>
494
- </fieldset>
495
-
496
- <p class="submit">
497
- <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
498
- </p>
499
-
500
- <br class="clear" />
501
- <?php
502
- } else if ($key === 'encode_form') {
503
- ?>
504
- <p><?php _e('If you like you can also create you own secure mailto links manually with this form. Just copy the generated code and put it on your post, page or template.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></p>
505
-
506
- <hr style="border:1px solid #FFF; border-top:1px solid #EEE;" />
507
-
508
- <?php echo $this->get_encoder_form(); ?>
509
-
510
- <hr style="border:1px solid #FFF; border-top:1px solid #EEE;"/>
511
-
512
- <p class="description"><?php _e('You can also put the encoder form on your site by using the shortcode <code>[eeb_form]</code> or the template function <code>eeb_form()</code>.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></p>
513
-
514
- <fieldset class="options">
515
- <table class="form-table">
516
- <tr>
517
- <th><?php _e('Show "powered by"', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
518
- <td><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[powered_by]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[powered_by]" value="1" <?php checked('1', (int) $options['powered_by']); ?> />
519
- <span><?php _e('Show the "powered by"-link on bottom of the encoder form', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
520
- </label>
521
- </td>
522
- </tr>
523
- </table>
524
- </fieldset>
525
-
526
- <p class="submit">
527
- <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
528
- </p>
529
- <br class="clear" />
530
-
531
- <?php
532
- } else if ($key === 'this_plugin') {
533
- ?>
534
- <ul>
535
- <li><a href="#" class="eeb-help-link"><?php _e('Documentation', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a></li>
536
- <li><a href="http://wordpress.org/support/plugin/email-encoder-bundle#postform" target="_blank"><?php _e('Report a problem', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a></li>
537
- </ul>
538
-
539
- <p><strong><a href="http://wordpress.org/support/view/plugin-reviews/email-encoder-bundle" target="_blank"><?php _e('Please rate this plugin!', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a></strong></p>
540
- <?php
541
- } else if ($key === 'other_plugins') {
542
- ?>
543
- <h4><img src="<?php echo plugins_url('images/icon-wp-external-links.png', EMAIL_ENCODER_BUNDLE_FILE) ?>" width="16" height="16" /> WP External Links -
544
- <?php if (is_plugin_active('wp-external-links/wp-external-links.php')): ?>
545
- <a href="<?php echo get_bloginfo('url') ?>/wp-admin/options-general.php?page=wp-external-links/wp-external-links.php"><?php _e('Settings') ?></a>
546
- <?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-external-links/wp-external-links.php')): ?>
547
- <a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a>
548
- <?php else: ?>
549
- <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', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a>
550
- <?php endif; ?>
551
- </h4>
552
- <p><?php _e('Manage external links on your site: open in new window/tab, set icon, add "external", add "nofollow" and more.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?>
553
- <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>
554
- </p>
555
-
556
- <h4><img src="<?php echo plugins_url('images/icon-wp-mailto-links.png', EMAIL_ENCODER_BUNDLE_FILE) ?>" width="16" height="16" /> WP Mailto Links -
557
- <?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php')): ?>
558
- <a href="<?php echo get_bloginfo('url') ?>/wp-admin/options-general.php?page=wp-mailto-links/wp-mailto-links.php"><?php _e('Settings') ?></a>
559
- <?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-mailto-links/wp-mailto-links.php')): ?>
560
- <a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a>
561
- <?php else: ?>
562
- <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', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a>
563
- <?php endif; ?>
564
- </h4>
565
- <p><?php _e('Manage mailto links on your site and protect emails from spambots, set mail icon and more.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?>
566
- <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>
567
- </p>
568
- <?php
569
- }
570
- }
571
-
572
- /* -------------------------------------------------------------------------
573
- * Help Tabs
574
- * ------------------------------------------------------------------------*/
575
-
576
- /**
577
- * Add help tabs
578
- */
579
- public function add_help_tabs() {
580
- if (!function_exists('get_current_screen')) {
581
- return;
582
- }
583
-
584
- $screen = get_current_screen();
585
-
586
- $screen->set_help_sidebar($this->get_help_text('sidebar'));
587
-
588
- $screen->add_help_tab(array(
589
- 'id' => 'quickstart',
590
- 'title' => __('Quick Start', EMAIL_ENCODER_BUNDLE_DOMAIN),
591
- 'content' => $this->get_help_text('quickstart'),
592
- ));
593
- $screen->add_help_tab(array(
594
- 'id' => 'shortcodes',
595
- 'title' => __('Shortcodes', EMAIL_ENCODER_BUNDLE_DOMAIN),
596
- 'content' => $this->get_help_text('shortcodes'),
597
- ));
598
- $screen->add_help_tab(array(
599
- 'id' => 'templatefunctions',
600
- 'title' => __('Template Functions', EMAIL_ENCODER_BUNDLE_DOMAIN),
601
- 'content' => $this->get_help_text('templatefunctions'),
602
- ));
603
- $screen->add_help_tab(array(
604
- 'id' => 'actions',
605
- 'title' => __('Action Hook', EMAIL_ENCODER_BUNDLE_DOMAIN),
606
- 'content' => $this->get_help_text('actions'),
607
- ));
608
- $screen->add_help_tab(array(
609
- 'id' => 'filters',
610
- 'title' => __('Filter Hooks', EMAIL_ENCODER_BUNDLE_DOMAIN),
611
- 'content' => $this->get_help_text('filters'),
612
- ));
613
- $screen->add_help_tab(array(
614
- 'id' => 'faq',
615
- 'title' => __('FAQ', EMAIL_ENCODER_BUNDLE_DOMAIN),
616
- 'content' => $this->get_help_text('faq'),
617
- ));
618
- }
619
-
620
- /**
621
- * Get text for given help tab
622
- * @param string $key
623
- * @return string
624
- */
625
- private function get_help_text($key) {
626
- if ($key === 'quickstart') {
627
- $plugin_title = get_admin_page_title();
628
- $icon_url = plugins_url('images/icon-email-encoder-bundle.png', EMAIL_ENCODER_BUNDLE_FILE);
629
- $quick_start_url = plugins_url('images/quick-start.png', EMAIL_ENCODER_BUNDLE_FILE);
630
- $version = EMAIL_ENCODER_BUNDLE_VERSION;
631
-
632
- $content = sprintf(__('<h3><img src="%s" width="16" height="16" /> %s - version %s</h3>'
633
- . '<p>The plugin works out-of-the-box. All mailto links in your posts, pages, comments and (text) widgets will be encoded (by default). <br/>If you also want to encode plain email address as well, you have to check the option.</p>'
634
- . '<img src="%s" width="600" height="273" />'
635
- , EMAIL_ENCODER_BUNDLE_DOMAIN), $icon_url, $plugin_title, $version, $quick_start_url);
636
- } else if ($key === 'shortcodes') {
637
- $content = __('<h3>Shortcodes</h3>'
638
- . '<p>You can use these shortcodes within your post or page.</p>'
639
- . '<h4>eeb_email</h4>'
640
- . '<p>Create an encoded mailto link:</p>'
641
- . '<p><code>[eeb_email email="..." display="..."]</code></p>'
642
- . '<ul>'
643
- . '<li>"display" is optional or the email wil be shown as display (also protected)</li>'
644
- . '<li>"extra_attrs" is optional, example: <code>extra_attrs="target=\'_blank\'"</code></li>'
645
- . '<li>"method" is optional, else the method option will be used.</li>'
646
- . '</ul>'
647
- . '<h4>eeb_content</h4>'
648
- . '<p>Encode some text:</p>'
649
- . '<p><code>[eeb_content method="..."]...[/encode_content]</code></p>'
650
- . '<ul>'
651
- . '<li>"method" is optional, else the method option will be used.</li>'
652
- . '</ul>'
653
- . '<h4>eeb_form</h4>'
654
- . '<p>Create an encoder form:</p>'
655
- . '<p><code>[eeb_form]</code></p>'
656
- , EMAIL_ENCODER_BUNDLE_DOMAIN);
657
- } else if ($key === 'templatefunctions') {
658
- $content = __('<h3>Template Functions</h3>'
659
- . '<h4>eeb_email()</h4>'
660
- . '<p>Create an encoded mailto link:</p>'
661
- . '<pre><code><&#63;php' . "\n"
662
- . 'if (function_exists(\'eeb_email\')) {' . "\n"
663
- . ' echo eeb_email(\'info@somedomain.com\');' . "\n"
664
- . '}' . "\n"
665
- . '&#63;></code></pre>'
666
- . '<p>You can pass a few extra optional params (in this order): <code>display</code>, <code>extra_attrs</code>, <code>method</code></p>'
667
- . '<h4>eeb_content()</h4>'
668
- . '<p>Encode some text:</p>'
669
- . '<pre><code><&#63;php' . "\n"
670
- . 'if (function_exists(\'eeb_content\')) {' . "\n"
671
- . ' echo eeb_content(\'Encode this text\');' . "\n"
672
- . '}' . "\n"
673
- . '&#63;></code></pre>'
674
- . '<p>You can pas an extra optional param: <code>method</code></p>'
675
- . '<h4>eeb_email_filter()</h4>'
676
- . '<p>Filter given content and encode all email addresses or mailto links:</p>'
677
- . '<pre><code><&#63;php' . "\n"
678
- . 'if (function_exists(\'eeb_email_filter\')) {' . "\n"
679
- . ' echo eeb_email_filter(\'Some content with email like info@somedomein.com or a mailto link\');' . "\n"
680
- . '}' . "\n"
681
- . '&#63;></code></pre>'
682
- . '<p>You can pass a few extra optional params (in this order): <code>enc_tags</code>, <code>enc_mailtos</code>, <code>enc_plain_emails</code></p>'
683
- . '<h4>eeb_form()</h4>'
684
- . '<p>Create an encoder form:</p>'
685
- . '<pre><code><&#63;php' . "\n"
686
- . 'if (function_exists(\'eeb_form\')) {' . "\n"
687
- . ' echo eeb_form();' . "\n"
688
- . '}' . "\n"
689
- . '&#63;></code></pre>'
690
- , EMAIL_ENCODER_BUNDLE_DOMAIN);
691
- } else if ($key === 'actions') {
692
- $content = __('<h3>Action Hooks</h3>'
693
- . '<h4>eeb_ready</h4>'
694
- . '<p>Add extra code on initializing this plugin, like extra filters for encoding.</p>'
695
- . '<pre><code><&#63;php' . "\n"
696
- . 'add_action(\'eeb_ready\', \'extra_encode_filters\');' . "\n\n"
697
- . 'function extra_encode_filters($eeb_object) {' . "\n"
698
- . ' add_filter(\'some_filter\', array($eeb_object, \'callback_filter\'));' . "\n"
699
- . '}' . "\n"
700
- . '&#63;></code></pre>'
701
- , EMAIL_ENCODER_BUNDLE_DOMAIN);
702
- } else if ($key === 'filters') {
703
- $content = __('<h3>Filter Hooks</h3>'
704
- . '<h4>eeb_mailto_regexp</h4>'
705
- . '<p>You can change the regular expression used for searching mailto links.</p>'
706
- . '<pre><code><&#63;php' . "\n"
707
- . 'add_filter(\'eeb_mailto_regexp\', \'change_mailto_regexp\');' . "\n\n"
708
- . 'function change_mailto_regexp($regexp) {' . "\n"
709
- . ' return \'-your regular expression-\';' . "\n"
710
- . '}' . "\n"
711
- . '&#63;></code></pre>'
712
- . '<h4>eeb_email_regexp</h4>'
713
- . '<p>You can change the regular expression used for searching mailto links.</p>'
714
- . '<pre><code><&#63;php' . "\n"
715
- . 'add_filter(\'eeb_email_regexp\', \'change_email_regexp\');' . "\n\n"
716
- . 'function change_email_regexp($regexp) {' . "\n"
717
- . ' return \'-your regular expression-\';' . "\n"
718
- . '}' . "\n"
719
- . '&#63;></code></pre>'
720
- , EMAIL_ENCODER_BUNDLE_DOMAIN);
721
- } else if ($key === 'faq') {
722
- $content = __('<h3>FAQ</h3>'
723
- . '<p>Please check the <a href="http://wordpress.org/extend/plugins/email-encoder-bundle/faq/" target="_blank">FAQ on the Plugin site</a>.'
724
- , EMAIL_ENCODER_BUNDLE_DOMAIN);
725
- } else if ($key === 'sidebar') {
726
- $content = __('<h4>About the author</h4>'
727
- . '<ul>'
728
- . '<li><a href="http://www.freelancephp.net/" target="_blank">FreelancePHP.net</a></li>'
729
- . '<li><a href="http://www.freelancephp.net/contact/" target="_blank">Contact</a></li>'
730
- . '</ul>'
731
- , EMAIL_ENCODER_BUNDLE_DOMAIN);
732
- } else {
733
- $content = '';
734
- }
735
-
736
- return $content;
737
- }
738
-
739
- /* -------------------------------------------------------------------------
740
- * Encoder Form
741
- * -------------------------------------------------------------------------/
742
-
743
- /**
744
- * Get the encoder form (to use as a demo, like on the options page)
745
- * @return string
746
- */
747
- public function get_encoder_form() {
748
- $lang_email = __('Email Address:', EMAIL_ENCODER_BUNDLE_DOMAIN);
749
- $lang_display = __('Display Text:', EMAIL_ENCODER_BUNDLE_DOMAIN);
750
- $lang_mailto = __('Mailto Link:', EMAIL_ENCODER_BUNDLE_DOMAIN);
751
- $lang_method = __('Encoding Method:', EMAIL_ENCODER_BUNDLE_DOMAIN);
752
- $lang_create = __('Create Protected Mail Link &gt;&gt;', EMAIL_ENCODER_BUNDLE_DOMAIN);
753
- $lang_output = __('Protected Mail Link (code):', EMAIL_ENCODER_BUNDLE_DOMAIN);
754
-
755
- $method_options = '';
756
- foreach ($this->methods as $method => $info) {
757
- $method_options .= '<option value="' . $method . '"' . (($this->method == $method) ? ' selected="selected"' : '') . '>' . $info['name'] . '</option>';
758
- }
759
-
760
- $powered_by = '';
761
- if ($this->options['powered_by']) {
762
- $powered_by .= '<p class="powered-by">' . __('Powered by', EMAIL_ENCODER_BUNDLE_DOMAIN) . ' <a rel="external" href="http://www.freelancephp.net/email-encoder-php-class-wp-plugin/">Email Encoder Bundle</a></p>';
763
- }
764
-
765
- return <<<FORM
766
- <div class="eeb-form">
767
- <form>
768
- <fieldset>
769
- <div class="input">
770
- <table>
771
- <tbody>
772
- <tr>
773
- <th><label for="eeb-email">{$lang_email}</label></th>
774
- <td><input type="text" class="regular-text" id="eeb-email" name="eeb-email" /></td>
775
- </tr>
776
- <tr>
777
- <th><label for="eeb-display">{$lang_display}</label></th>
778
- <td><input type="text" class="regular-text" id="eeb-display" name="eeb-display" /></td>
779
- </tr>
780
- <tr>
781
- <th>{$lang_mailto}</th>
782
- <td><span class="eeb-example"></span></td>
783
- </tr>
784
- <tr>
785
- <th><label for="eeb-encode-method">{$lang_method}</label></th>
786
- <td><select id="eeb-encode-method" name="eeb-encode-method" class="postform">
787
- {$method_options}
788
- </select>
789
- <input type="button" id="eeb-ajax-encode" name="eeb-ajax-encode" value="{$lang_create}" />
790
- </td>
791
- </tr>
792
- </tbody>
793
- </table>
794
- </div>
795
- <div class="eeb-output">
796
- <table>
797
- <tbody>
798
- <tr>
799
- <th><label for="eeb-encoded-output">{$lang_output}</label></th>
800
- <td><textarea class="large-text node" id="eeb-encoded-output" name="eeb-encoded-output" cols="50" rows="4"></textarea></td>
801
- </tr>
802
- </tbody>
803
- </table>
804
- </div>
805
- {$powered_by}
806
- </fieldset>
807
- </form>
808
- </div>
809
- FORM;
810
- }
811
-
812
- } // end class Eeb_Admin
813
-
814
- endif;
815
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
816
  /* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
1
+ <?php defined('ABSPATH') OR die('No direct access.');
2
+
3
+ /**
4
+ * Class Eeb_Admin
5
+ *
6
+ * Contains all code nescessary for the Admin part
7
+ *
8
+ * @abstract
9
+ *
10
+ * @package Email_Encoder_Bundle
11
+ * @category WordPress Plugins
12
+ */
13
+ if (!class_exists('Eeb_Admin')):
14
+
15
+ abstract class Eeb_Admin {
16
+
17
+ /**
18
+ * @var array
19
+ */
20
+ private $default_options = array(
21
+ 'version' => null,
22
+ 'method' => 'enc_ascii',
23
+ 'encode_mailtos' => 1,
24
+ 'encode_emails' => 0,
25
+ 'filter_posts' => 1,
26
+ 'filter_widgets' => 1,
27
+ 'filter_comments' => 1,
28
+ 'skip_posts' => '',
29
+ 'protection_text' => '*protected email*',
30
+ 'class_name' => 'mailto-link',
31
+ 'filter_rss' => 1,
32
+ 'remove_shortcodes_rss' => 1,
33
+ 'protection_text_rss' => '*protected email*',
34
+ 'widget_logic_filter' => 0,
35
+ 'show_encoded_check' => 0,
36
+ 'shortcodes_in_widgets' => 0,
37
+ 'support_deprecated_names' => 0,
38
+ 'own_admin_menu' => 1,
39
+ 'powered_by' => 1,
40
+ );
41
+
42
+ /**
43
+ * @var array
44
+ */
45
+ protected $options = array();
46
+
47
+ /**
48
+ * @var array
49
+ */
50
+ protected $skip_posts = array();
51
+
52
+ /**
53
+ * @var string
54
+ */
55
+ protected $method = 'enc_ascii';
56
+
57
+ /**
58
+ * @var array
59
+ */
60
+ private $methods = array();
61
+
62
+ /**
63
+ * @var boolean
64
+ */
65
+ private $initial_metabox_settings = false;
66
+
67
+ /**
68
+ * Constructor
69
+ */
70
+ protected function __construct() {
71
+ // load text domain for translations
72
+ load_plugin_textdomain(EMAIL_ENCODER_BUNDLE_DOMAIN, false, dirname(plugin_basename(EMAIL_ENCODER_BUNDLE_FILE)) . '/languages/');
73
+
74
+ // set methods
75
+ $this->methods = array(
76
+ 'enc_ascii' => array(
77
+ 'name' => __('JS Rot13', EMAIL_ENCODER_BUNDLE_DOMAIN),
78
+ 'description' => __('Recommended, the savest method using a rot13 method in JavaScript.', EMAIL_ENCODER_BUNDLE_DOMAIN),
79
+ ),
80
+ 'enc_escape' => array(
81
+ 'name' => __('JS Escape', EMAIL_ENCODER_BUNDLE_DOMAIN),
82
+ 'description' => __('Pretty save method using JavaScipt\'s escape function.', EMAIL_ENCODER_BUNDLE_DOMAIN),
83
+ ),
84
+ 'enc_html' => array(
85
+ 'name' => __('Html Encode', EMAIL_ENCODER_BUNDLE_DOMAIN),
86
+ 'description' => __('Not recommended, equal to <a href="http://codex.wordpress.org/Function_Reference/antispambot" target="_blank"><code>antispambot()</code></a> function of WordPress.', EMAIL_ENCODER_BUNDLE_DOMAIN),
87
+ ),
88
+ );
89
+
90
+ // set option values
91
+ $this->set_options();
92
+
93
+ // prepare vars
94
+ $skip_posts = $this->options['skip_posts'];
95
+ $skip_posts = str_replace(' ', '', $skip_posts);
96
+ $skip_posts = explode(',', $skip_posts);
97
+ $this->skip_posts = $skip_posts;
98
+
99
+ // set uninstall hook
100
+ register_uninstall_hook(EMAIL_ENCODER_BUNDLE_FILE, array('Eeb_Admin', 'uninstall'));
101
+
102
+ // add actions
103
+ add_action('wp', array($this, 'wp'));
104
+ add_action('admin_init', array($this, 'admin_init'));
105
+ add_action('admin_menu', array($this, 'admin_menu'));
106
+ }
107
+
108
+ /**
109
+ * Set options from save values or defaults
110
+ */
111
+ private function set_options() {
112
+ $upgrade = false;
113
+
114
+ // first set defaults
115
+ $this->options = $this->default_options;
116
+
117
+ // get saved options
118
+ $saved_options = get_option(EMAIL_ENCODER_BUNDLE_OPTIONS_NAME);
119
+
120
+ // backwards compatible (old values)
121
+ if (empty($saved_options)) {
122
+ $saved_options = get_option(EMAIL_ENCODER_BUNDLE_KEY . 'options');
123
+
124
+ // cleanup old values
125
+ delete_option(EMAIL_ENCODER_BUNDLE_KEY . 'options');
126
+ }
127
+
128
+ $version = get_option('eeb_version');
129
+ if ($version !== false) {
130
+ $saved_options['version'] = $version;
131
+
132
+ // cleanup old value
133
+ delete_option('eeb_version');
134
+ }
135
+
136
+ // set all options
137
+ if (!empty($saved_options)) {
138
+ $upgrade = true;
139
+
140
+ foreach ($saved_options AS $key => $value) {
141
+ $this->options[$key] = $value;
142
+ }
143
+ }
144
+
145
+ if ($saved_options['version'] != EMAIL_ENCODER_BUNDLE_VERSION) {
146
+ if (empty($saved_options['version'])) {
147
+ if ($upgrade) {
148
+ // upgrade from version < 1.0.0
149
+ $this->options['support_deprecated_names'] = 1;
150
+ $this->options['shortcodes_in_widgets'] = 1;
151
+
152
+ //update_option(EMAIL_ENCODER_BUNDLE_OPTIONS_NAME, $this->options);
153
+ } else {
154
+ // first time
155
+ $this->initial_metabox_settings = true;
156
+ }
157
+ } else {
158
+ // upgrading from version >= 1.0.0
159
+
160
+ }
161
+
162
+ // update version
163
+ update_option(EMAIL_ENCODER_BUNDLE_OPTIONS_NAME, $this->options);
164
+ }
165
+
166
+ // set encode method
167
+ $this->method = $this->get_method($this->options['method'], 'enc_ascii');
168
+
169
+ // set widget_content filter of Widget Logic plugin
170
+ $widget_logic_opts = get_option('widget_logic');
171
+ if (is_array($widget_logic_opts) && key_exists('widget_logic-options-filter', $widget_logic_opts)) {
172
+ $this->options['widget_logic_filter'] = ($widget_logic_opts['widget_logic-options-filter'] == 'checked') ? 1 : 0;
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Get method name
178
+ * @param string $method
179
+ * @param string $defaultMethod Optional, default 'enc_html'
180
+ * @return string
181
+ */
182
+ protected function get_method($method, $defaultMethod = 'enc_html') {
183
+ $method = strtolower($method);
184
+
185
+ if (!method_exists($this, $method)) {
186
+ $method = $defaultMethod; // set default method
187
+ }
188
+
189
+ return $method;
190
+ }
191
+
192
+ /**
193
+ * Callback Uninstall
194
+ */
195
+ static public function uninstall() {
196
+ delete_option(EMAIL_ENCODER_BUNDLE_OPTIONS_NAME);
197
+ unregister_setting(EMAIL_ENCODER_BUNDLE_KEY, EMAIL_ENCODER_BUNDLE_OPTIONS_NAME);
198
+ }
199
+
200
+ /**
201
+ * Callbacka admin_init
202
+ */
203
+ public function admin_init() {
204
+ // register settings
205
+ register_setting(EMAIL_ENCODER_BUNDLE_KEY, EMAIL_ENCODER_BUNDLE_OPTIONS_NAME);
206
+
207
+ // actions and filters
208
+ add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2);
209
+ }
210
+
211
+ /**
212
+ * Callback add links on plugin page
213
+ * @param array $links
214
+ * @param string $file
215
+ * @return array
216
+ */
217
+ public function plugin_action_links($links, $file) {
218
+ if ($file == plugin_basename(EMAIL_ENCODER_BUNDLE_FILE)) {
219
+ $page = ($this->options['own_admin_menu']) ? 'admin.php' : 'options-general.php';
220
+ $settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/' . $page . '?page=' . EMAIL_ENCODER_BUNDLE_ADMIN_PAGE . '">' . __('Settings', EMAIL_ENCODER_BUNDLE_DOMAIN) . '</a>';
221
+ array_unshift($links, $settings_link);
222
+ }
223
+
224
+ return $links;
225
+ }
226
+
227
+ /**
228
+ * Callback admin_menu
229
+ */
230
+ public function admin_menu() {
231
+ // add page and menu item
232
+ if ($this->options['own_admin_menu']) {
233
+ // create main menu item
234
+ $page_hook = add_menu_page(__('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN), __('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN),
235
+ 'manage_options', EMAIL_ENCODER_BUNDLE_ADMIN_PAGE, array($this, 'show_options_page'),
236
+ plugins_url('images/icon-email-encoder-bundle-16.png', EMAIL_ENCODER_BUNDLE_FILE));
237
+ } else {
238
+ // create submenu item under "Settings"
239
+ $page_hook = add_submenu_page('options-general.php', __('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN), __('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN),
240
+ 'manage_options', EMAIL_ENCODER_BUNDLE_ADMIN_PAGE, array($this, 'show_options_page'));
241
+ }
242
+
243
+ // load plugin page
244
+ add_action('load-' . $page_hook, array($this, 'load_options_page'));
245
+ }
246
+
247
+ /* -------------------------------------------------------------------------
248
+ * Admin Options Page
249
+ * ------------------------------------------------------------------------*/
250
+
251
+ /**
252
+ * Load admin options page
253
+ */
254
+ public function load_options_page() {
255
+ // set dashboard postbox
256
+ wp_enqueue_script('dashboard');
257
+
258
+ // add script for ajax encoder
259
+ //wp_enqueue_script('email_encoder', plugins_url('js/src/email-encoder-bundle.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
260
+ //wp_enqueue_script('email_encoder_admin', plugins_url('js/src/email-encoder-bundle-admin.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
261
+ wp_enqueue_script('email_encoder', plugins_url('js/email-encoder-bundle.min.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
262
+
263
+ // add help tabs
264
+ $this->add_help_tabs();
265
+
266
+ // screen settings
267
+ if (function_exists('add_screen_option')) {
268
+ add_screen_option('layout_columns', array(
269
+ 'max' => 2,
270
+ 'default' => 2
271
+ ));
272
+ }
273
+
274
+ // add meta boxes
275
+ add_meta_box('main_settings', __('Main Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('main_settings'));
276
+ add_meta_box('additional_settings', __('Additional Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('additional_settings'));
277
+ add_meta_box('rss_settings', __('RSS Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('rss_settings'));
278
+ add_meta_box('admin_settings', __('Admin Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('admin_settings'));
279
+ add_meta_box('encode_form', __('Email Encoder Form', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('encode_form'));
280
+ add_meta_box('this_plugin', __('Support', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'side', 'core', array('this_plugin'));
281
+ add_meta_box('other_plugins', __('Other Plugins', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'side', 'core', array('other_plugins'));
282
+ }
283
+
284
+ /**
285
+ * Show admin options page
286
+ */
287
+ public function show_options_page() {
288
+ $this->set_options();
289
+ ?>
290
+ <div class="wrap">
291
+ <div class="icon32" id="icon-options-custom" style="background:url(<?php echo plugins_url('images/icon-email-encoder-bundle.png', EMAIL_ENCODER_BUNDLE_FILE) ?>) no-repeat 50% 50%"><br></div>
292
+ <h2><?php echo get_admin_page_title() ?> - <em><small><?php _e('Protect Email Addresses', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></small></em></h2>
293
+
294
+ <?php if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' && $this->options['own_admin_menu']): ?>
295
+ <div class="updated settings-error" id="setting-error-settings_updated">
296
+ <p><strong><?php _e('Settings saved.' ) ?></strong></p>
297
+ </div>
298
+ <?php endif; ?>
299
+
300
+ <?php if ($this->initial_metabox_settings): ?>
301
+ <script type="text/javascript">jQuery(function($){ $('#additional_settings, #rss_settings, #admin_settings, #encode_form').addClass('closed'); });</script>
302
+ <?php endif; ?>
303
+
304
+ <form method="post" action="options.php">
305
+ <?php settings_fields(EMAIL_ENCODER_BUNDLE_KEY); ?>
306
+
307
+ <input type="hidden" name="<?php echo EMAIL_ENCODER_BUNDLE_KEY ?>_nonce" value="<?php echo wp_create_nonce(EMAIL_ENCODER_BUNDLE_KEY) ?>" />
308
+ <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
309
+ <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
310
+
311
+ <div id="poststuff">
312
+ <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
313
+ <!--<div id="post-body-content"></div>-->
314
+
315
+ <div id="postbox-container-1" class="postbox-container">
316
+ <?php do_meta_boxes('', 'side', ''); ?>
317
+ </div>
318
+
319
+ <div id="postbox-container-2" class="postbox-container">
320
+ <?php do_meta_boxes('', 'normal', ''); ?>
321
+ <?php do_meta_boxes('', 'advanced', ''); ?>
322
+ </div>
323
+ </div> <!-- #post-body -->
324
+ </div> <!-- #poststuff -->
325
+ </form>
326
+ </div>
327
+ <?php
328
+ }
329
+
330
+ /**
331
+ * Show content of metabox (callback)
332
+ * @param array $post
333
+ * @param array $meta_box
334
+ */
335
+ public function show_meta_box_content($post, $meta_box) {
336
+ $key = $meta_box['args'][0];
337
+ $options = $this->options;
338
+
339
+ if ($key === 'main_settings') {
340
+ ?>
341
+ <?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php')): ?>
342
+ <p class="description"><?php _e('Warning: "WP Mailto Links"-plugin is also activated, which could cause conflicts.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></p>
343
+ <?php endif; ?>
344
+ <fieldset class="options">
345
+ <table class="form-table">
346
+ <tr>
347
+ <th><?php _e('Choose what to protect', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
348
+ <td>
349
+ <label><input type="checkbox" id="encode_mailtos" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[encode_mailtos]" value="1" <?php checked('1', (int) $options['encode_mailtos']); ?> />
350
+ <span><?php _e('Protect mailto links, like f.e. <code>&lt;a href="info@myemail.com"&gt;My Email&lt;/a&gt;</code>', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
351
+ <br/><label><input type="checkbox" id="encode_emails" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[encode_emails]" value="1" <?php checked('1', (int) $options['encode_emails']); ?> disabled="disabled" />
352
+ <span><?php _e('Replace plain email addresses to protected mailto links.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
353
+ <span class="description notice-form-field-bug"><br/><?php _e('Notice: be carefull with this option when using email addresses on form fields, please <a href="http://wordpress.org/extend/plugins/email-encoder-bundle/faq/" target="_blank">check the FAQ</a> for more info.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
354
+ </label>
355
+ <br/>
356
+ </td>
357
+ </tr>
358
+ <tr>
359
+ <th><?php _e('Apply on...', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
360
+ <td>
361
+ <label><input type="checkbox" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_posts]" value="1" <?php checked('1', (int) $options['filter_posts']); ?> />
362
+ <span><?php _e('All posts and pages', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
363
+ </label>
364
+ <br/><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_comments]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_comments]" value="1" <?php checked('1', (int) $options['filter_comments']); ?> />
365
+ <span><?php _e('All comments', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
366
+ <br/><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_widgets]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_widgets]" value="1" <?php checked('1', (int) $options['filter_widgets']); ?> />
367
+ <span><?php if ($this->options['widget_logic_filter']) { _e('All widgets (uses the <code>widget_content</code> filter of the Widget Logic plugin)', EMAIL_ENCODER_BUNDLE_DOMAIN); } else { _e('All text widgets', EMAIL_ENCODER_BUNDLE_DOMAIN); } ?></span></label>
368
+ </td>
369
+ </tr>
370
+ <tr>
371
+ <th><?php _e('Add class to protected mailto links', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
372
+ <td><label><input type="text" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[class_name]" class="regular-text" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[class_name]" value="<?php echo $options['class_name']; ?>" />
373
+ <br/><span class="description"><?php _e('All protected mailto links will get these class(es). Optional, else keep blank.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label></td>
374
+ </tr>
375
+ </table>
376
+ </fieldset>
377
+
378
+ <p class="submit">
379
+ <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
380
+ </p>
381
+ <br class="clear" />
382
+
383
+ <?php
384
+ } else if ($key === 'rss_settings') {
385
+ ?>
386
+ <fieldset class="options">
387
+ <table class="form-table">
388
+ <tr>
389
+ <th><?php _e('Protect emails in RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
390
+ <td><label><input type="checkbox" id="filter_rss" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_rss]" value="1" <?php checked('1', (int) $options['filter_rss']); ?> />
391
+ <span><?php _e('Replace emails in RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
392
+ </td>
393
+ </tr>
394
+ <tr>
395
+ <th><?php _e('Remove shortcodes from RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
396
+ <td><label><input type="checkbox" id="remove_shortcodes_rss" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[remove_shortcodes_rss]" value="1" <?php checked('1', (int) $options['remove_shortcodes_rss']); ?> />
397
+ <span><?php _e('Remove all shortcodes from the RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
398
+ </td>
399
+ </tr>
400
+ <tr>
401
+ <th><?php _e('Set protection text in RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
402
+ <td><label><input type="text" id="protection_text" class="regular-text" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[protection_text_rss]" value="<?php echo $options['protection_text_rss']; ?>" />
403
+ <br/><span class="description"><?php _e('Used as replacement for email addresses in RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
404
+ </label>
405
+ </td>
406
+ </tr>
407
+ </table>
408
+ </fieldset>
409
+
410
+ <p class="submit">
411
+ <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
412
+ </p>
413
+ <br class="clear" />
414
+ <?php
415
+ } else if ($key === 'additional_settings') {
416
+ ?>
417
+ <fieldset class="options">
418
+ <table class="form-table">
419
+ <tr>
420
+ <th><?php _e('Choose protection method', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
421
+ <td>
422
+ <?php foreach ($this->methods AS $method => $info): ?>
423
+ <label>
424
+ <input type="radio" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[method]" class="protection-method" value="<?php echo $method ?>" <?php if ($this->method == $method) echo 'checked="checked"' ?> />
425
+ <span><?php echo $info['name'] ?></span>
426
+ - <span class="description"><?php echo $info['description'] ?></span>
427
+ </label>
428
+ <br/>
429
+ <?php endforeach; ?>
430
+ </td>
431
+ </tr>
432
+ <tr>
433
+ <th><?php _e('Set <code>&lt;noscript&gt;</code> text', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
434
+ <td><label><input type="text" id="protection_text" class="regular-text" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[protection_text]" value="<?php echo $options['protection_text']; ?>" />
435
+ <br/><span class="description"><?php _e('Used for the <code>&lt;noscript&gt;</code> fallback for JavaScrip methods.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
436
+ </label>
437
+ </td>
438
+ </tr>
439
+ <tr>
440
+ <th><?php _e('Exclude posts', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
441
+ <td>
442
+ <label>
443
+ <span><?php _e('Do <strong>not</strong> apply protection on posts or pages with the folllowing ID:', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
444
+ <br/><input type="text" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[skip_posts]" class="regular-text" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[skip_posts]" value="<?php echo $options['skip_posts']; ?>" />
445
+ <br/><span class="description"><?php _e('Seperate Id\'s by comma, f.e.: 2, 7, 13, 32.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
446
+ <br/><span class="description"><?php _e('Notice: shortcodes still work on these posts.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
447
+ </label>
448
+ </td>
449
+ </tr>
450
+ <tr>
451
+ <th><?php _e('Use shortcodes in widgets', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
452
+ <td>
453
+ <label><input type="checkbox" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[shortcodes_in_widgets]" value="1" <?php checked('1', (int) $options['shortcodes_in_widgets']); ?> />
454
+ <span><?php _e('Also use shortcodes in widgets.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
455
+ <br/><span class="description"><?php if (!$this->options['widget_logic_filter']) { _e('Notice: only works for text widgets!', EMAIL_ENCODER_BUNDLE_DOMAIN); } else { _e('All text widgets', EMAIL_ENCODER_BUNDLE_DOMAIN); } ?></span></label>
456
+ </label>
457
+ </td>
458
+ </tr>
459
+ <tr>
460
+ <th><?php _e('Use deprecated names', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
461
+ <td><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[support_deprecated_names]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[support_deprecated_names]" value="1" <?php checked('1', (int) $options['support_deprecated_names']); ?> />
462
+ <span><?php _e('Keep supporting the old names for action, shortcodes and template functions.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
463
+ <br /><span class="description">These deprecated will still be available: <code>init_email_encoder_bundle</code>, <code>[encode_email]</code>, <code>[encode_content]</code>, <code>[email_encoder_form]</code>, <code>encode_email()</code>, <code>encode_content()</code>, <code>encode_email_filter()</code></span></label></td>
464
+ </tr>
465
+ </table>
466
+ </fieldset>
467
+
468
+ <p class="submit">
469
+ <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
470
+ </p>
471
+ <br class="clear" />
472
+ <?php
473
+ } else if ($key === 'admin_settings') {
474
+ ?>
475
+ <fieldset class="options">
476
+ <table class="form-table">
477
+ <tr>
478
+ <th><?php _e('Check "succesfully encoded"', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
479
+ <td><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[show_encoded_check]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[show_encoded_check]" value="1" <?php checked('1', (int) $options['show_encoded_check']); ?> />
480
+ <span><?php _e('Show "successfully encoded" text for all encoded content, only when logged in as admin user.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
481
+ <br/><span class="description"><?php _e('This way you can check if emails are really encoded on your site.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
482
+ </label>
483
+ </td>
484
+ </tr>
485
+ <tr>
486
+ <th><?php _e('Choose admin menu position', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
487
+ <td><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[own_admin_menu]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[own_admin_menu]" value="1" <?php checked('1', (int) $options['own_admin_menu']); ?> />
488
+ <span><?php _e('Show as main menu item.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
489
+ <br /><span class="description">When disabled this page will be available under "General settings".</span>
490
+ </label>
491
+ </td>
492
+ </tr>
493
+ </table>
494
+ </fieldset>
495
+
496
+ <p class="submit">
497
+ <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
498
+ </p>
499
+
500
+ <br class="clear" />
501
+ <?php
502
+ } else if ($key === 'encode_form') {
503
+ ?>
504
+ <p><?php _e('If you like you can also create you own secure mailto links manually with this form. Just copy the generated code and put it on your post, page or template.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></p>
505
+
506
+ <hr style="border:1px solid #FFF; border-top:1px solid #EEE;" />
507
+
508
+ <?php echo $this->get_encoder_form(); ?>
509
+
510
+ <hr style="border:1px solid #FFF; border-top:1px solid #EEE;"/>
511
+
512
+ <p class="description"><?php _e('You can also put the encoder form on your site by using the shortcode <code>[eeb_form]</code> or the template function <code>eeb_form()</code>.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></p>
513
+
514
+ <fieldset class="options">
515
+ <table class="form-table">
516
+ <tr>
517
+ <th><?php _e('Show "powered by"', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
518
+ <td><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[powered_by]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[powered_by]" value="1" <?php checked('1', (int) $options['powered_by']); ?> />
519
+ <span><?php _e('Show the "powered by"-link on bottom of the encoder form', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
520
+ </label>
521
+ </td>
522
+ </tr>
523
+ </table>
524
+ </fieldset>
525
+
526
+ <p class="submit">
527
+ <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
528
+ </p>
529
+ <br class="clear" />
530
+
531
+ <?php
532
+ } else if ($key === 'this_plugin') {
533
+ ?>
534
+ <ul>
535
+ <li><a href="#" class="eeb-help-link"><?php _e('Documentation', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a></li>
536
+ <li><a href="http://wordpress.org/support/plugin/email-encoder-bundle#postform" target="_blank"><?php _e('Report a problem', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a></li>
537
+ </ul>
538
+
539
+ <p><strong><a href="http://wordpress.org/support/view/plugin-reviews/email-encoder-bundle" target="_blank"><?php _e('Please rate this plugin!', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a></strong></p>
540
+ <?php
541
+ } else if ($key === 'other_plugins') {
542
+ ?>
543
+ <h4><img src="<?php echo plugins_url('images/icon-wp-external-links.png', EMAIL_ENCODER_BUNDLE_FILE) ?>" width="16" height="16" /> WP External Links -
544
+ <?php if (is_plugin_active('wp-external-links/wp-external-links.php')): ?>
545
+ <a href="<?php echo get_bloginfo('url') ?>/wp-admin/options-general.php?page=wp-external-links/wp-external-links.php"><?php _e('Settings') ?></a>
546
+ <?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-external-links/wp-external-links.php')): ?>
547
+ <a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a>
548
+ <?php else: ?>
549
+ <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', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a>
550
+ <?php endif; ?>
551
+ </h4>
552
+ <p><?php _e('Manage external links on your site: open in new window/tab, set icon, add "external", add "nofollow" and more.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?>
553
+ <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>
554
+ </p>
555
+
556
+ <h4><img src="<?php echo plugins_url('images/icon-wp-mailto-links.png', EMAIL_ENCODER_BUNDLE_FILE) ?>" width="16" height="16" /> WP Mailto Links -
557
+ <?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php')): ?>
558
+ <a href="<?php echo get_bloginfo('url') ?>/wp-admin/options-general.php?page=wp-mailto-links/wp-mailto-links.php"><?php _e('Settings') ?></a>
559
+ <?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-mailto-links/wp-mailto-links.php')): ?>
560
+ <a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a>
561
+ <?php else: ?>
562
+ <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', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a>
563
+ <?php endif; ?>
564
+ </h4>
565
+ <p><?php _e('Manage mailto links on your site and protect emails from spambots, set mail icon and more.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?>
566
+ <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>
567
+ </p>
568
+ <?php
569
+ }
570
+ }
571
+
572
+ /* -------------------------------------------------------------------------
573
+ * Help Tabs
574
+ * ------------------------------------------------------------------------*/
575
+
576
+ /**
577
+ * Add help tabs
578
+ */
579
+ public function add_help_tabs() {
580
+ if (!function_exists('get_current_screen')) {
581
+ return;
582
+ }
583
+
584
+ $screen = get_current_screen();
585
+
586
+ $screen->set_help_sidebar($this->get_help_text('sidebar'));
587
+
588
+ $screen->add_help_tab(array(
589
+ 'id' => 'quickstart',
590
+ 'title' => __('Quick Start', EMAIL_ENCODER_BUNDLE_DOMAIN),
591
+ 'content' => $this->get_help_text('quickstart'),
592
+ ));
593
+ $screen->add_help_tab(array(
594
+ 'id' => 'shortcodes',
595
+ 'title' => __('Shortcodes', EMAIL_ENCODER_BUNDLE_DOMAIN),
596
+ 'content' => $this->get_help_text('shortcodes'),
597
+ ));
598
+ $screen->add_help_tab(array(
599
+ 'id' => 'templatefunctions',
600
+ 'title' => __('Template Functions', EMAIL_ENCODER_BUNDLE_DOMAIN),
601
+ 'content' => $this->get_help_text('templatefunctions'),
602
+ ));
603
+ $screen->add_help_tab(array(
604
+ 'id' => 'actions',
605
+ 'title' => __('Action Hook', EMAIL_ENCODER_BUNDLE_DOMAIN),
606
+ 'content' => $this->get_help_text('actions'),
607
+ ));
608
+ $screen->add_help_tab(array(
609
+ 'id' => 'filters',
610
+ 'title' => __('Filter Hooks', EMAIL_ENCODER_BUNDLE_DOMAIN),
611
+ 'content' => $this->get_help_text('filters'),
612
+ ));
613
+ $screen->add_help_tab(array(
614
+ 'id' => 'faq',
615
+ 'title' => __('FAQ', EMAIL_ENCODER_BUNDLE_DOMAIN),
616
+ 'content' => $this->get_help_text('faq'),
617
+ ));
618
+ }
619
+
620
+ /**
621
+ * Get text for given help tab
622
+ * @param string $key
623
+ * @return string
624
+ */
625
+ private function get_help_text($key) {
626
+ if ($key === 'quickstart') {
627
+ $plugin_title = get_admin_page_title();
628
+ $icon_url = plugins_url('images/icon-email-encoder-bundle.png', EMAIL_ENCODER_BUNDLE_FILE);
629
+ $quick_start_url = plugins_url('images/quick-start.png', EMAIL_ENCODER_BUNDLE_FILE);
630
+ $version = EMAIL_ENCODER_BUNDLE_VERSION;
631
+
632
+ $content = sprintf(__('<h3><img src="%s" width="16" height="16" /> %s - version %s</h3>'
633
+ . '<p>The plugin works out-of-the-box. All mailto links in your posts, pages, comments and (text) widgets will be encoded (by default). <br/>If you also want to encode plain email address as well, you have to check the option.</p>'
634
+ . '<img src="%s" width="600" height="273" />'
635
+ , EMAIL_ENCODER_BUNDLE_DOMAIN), $icon_url, $plugin_title, $version, $quick_start_url);
636
+ } else if ($key === 'shortcodes') {
637
+ $content = __('<h3>Shortcodes</h3>'
638
+ . '<p>You can use these shortcodes within your post or page.</p>'
639
+ . '<h4>eeb_email</h4>'
640
+ . '<p>Create an encoded mailto link:</p>'
641
+ . '<p><code>[eeb_email email="..." display="..."]</code></p>'
642
+ . '<ul>'
643
+ . '<li>"display" is optional or the email wil be shown as display (also protected)</li>'
644
+ . '<li>"extra_attrs" is optional, example: <code>extra_attrs="target=\'_blank\'"</code></li>'
645
+ . '<li>"method" is optional, else the method option will be used.</li>'
646
+ . '</ul>'
647
+ . '<h4>eeb_content</h4>'
648
+ . '<p>Encode some text:</p>'
649
+ . '<p><code>[eeb_content method="..."]...[/eeb_content]</code></p>'
650
+ . '<ul>'
651
+ . '<li>"method" is optional, else the method option will be used.</li>'
652
+ . '</ul>'
653
+ . '<h4>eeb_form</h4>'
654
+ . '<p>Create an encoder form:</p>'
655
+ . '<p><code>[eeb_form]</code></p>'
656
+ , EMAIL_ENCODER_BUNDLE_DOMAIN);
657
+ } else if ($key === 'templatefunctions') {
658
+ $content = __('<h3>Template Functions</h3>'
659
+ . '<h4>eeb_email()</h4>'
660
+ . '<p>Create an encoded mailto link:</p>'
661
+ . '<pre><code><&#63;php' . "\n"
662
+ . 'if (function_exists(\'eeb_email\')) {' . "\n"
663
+ . ' echo eeb_email(\'info@somedomain.com\');' . "\n"
664
+ . '}' . "\n"
665
+ . '&#63;></code></pre>'
666
+ . '<p>You can pass a few extra optional params (in this order): <code>display</code>, <code>extra_attrs</code>, <code>method</code></p>'
667
+ . '<h4>eeb_content()</h4>'
668
+ . '<p>Encode some text:</p>'
669
+ . '<pre><code><&#63;php' . "\n"
670
+ . 'if (function_exists(\'eeb_content\')) {' . "\n"
671
+ . ' echo eeb_content(\'Encode this text\');' . "\n"
672
+ . '}' . "\n"
673
+ . '&#63;></code></pre>'
674
+ . '<p>You can pas an extra optional param: <code>method</code></p>'
675
+ . '<h4>eeb_email_filter()</h4>'
676
+ . '<p>Filter given content and encode all email addresses or mailto links:</p>'
677
+ . '<pre><code><&#63;php' . "\n"
678
+ . 'if (function_exists(\'eeb_email_filter\')) {' . "\n"
679
+ . ' echo eeb_email_filter(\'Some content with email like info@somedomein.com or a mailto link\');' . "\n"
680
+ . '}' . "\n"
681
+ . '&#63;></code></pre>'
682
+ . '<p>You can pass a few extra optional params (in this order): <code>enc_tags</code>, <code>enc_mailtos</code>, <code>enc_plain_emails</code></p>'
683
+ . '<h4>eeb_form()</h4>'
684
+ . '<p>Create an encoder form:</p>'
685
+ . '<pre><code><&#63;php' . "\n"
686
+ . 'if (function_exists(\'eeb_form\')) {' . "\n"
687
+ . ' echo eeb_form();' . "\n"
688
+ . '}' . "\n"
689
+ . '&#63;></code></pre>'
690
+ , EMAIL_ENCODER_BUNDLE_DOMAIN);
691
+ } else if ($key === 'actions') {
692
+ $content = __('<h3>Action Hooks</h3>'
693
+ . '<h4>eeb_ready</h4>'
694
+ . '<p>Add extra code on initializing this plugin, like extra filters for encoding.</p>'
695
+ . '<pre><code><&#63;php' . "\n"
696
+ . 'add_action(\'eeb_ready\', \'extra_encode_filters\');' . "\n\n"
697
+ . 'function extra_encode_filters($eeb_object) {' . "\n"
698
+ . ' add_filter(\'some_filter\', array($eeb_object, \'callback_filter\'));' . "\n"
699
+ . '}' . "\n"
700
+ . '&#63;></code></pre>'
701
+ , EMAIL_ENCODER_BUNDLE_DOMAIN);
702
+ } else if ($key === 'filters') {
703
+ $content = __('<h3>Filter Hooks</h3>'
704
+ . '<h4>eeb_mailto_regexp</h4>'
705
+ . '<p>You can change the regular expression used for searching mailto links.</p>'
706
+ . '<pre><code><&#63;php' . "\n"
707
+ . 'add_filter(\'eeb_mailto_regexp\', \'change_mailto_regexp\');' . "\n\n"
708
+ . 'function change_mailto_regexp($regexp) {' . "\n"
709
+ . ' return \'-your regular expression-\';' . "\n"
710
+ . '}' . "\n"
711
+ . '&#63;></code></pre>'
712
+ . '<h4>eeb_email_regexp</h4>'
713
+ . '<p>You can change the regular expression used for searching mailto links.</p>'
714
+ . '<pre><code><&#63;php' . "\n"
715
+ . 'add_filter(\'eeb_email_regexp\', \'change_email_regexp\');' . "\n\n"
716
+ . 'function change_email_regexp($regexp) {' . "\n"
717
+ . ' return \'-your regular expression-\';' . "\n"
718
+ . '}' . "\n"
719
+ . '&#63;></code></pre>'
720
+ . '<h4>eeb_form_content</h4>'
721
+ . '<p>Filter for changing the form layout.</p>'
722
+ . '<pre><code><&#63;php' . "\n"
723
+ . 'add_filter(\'eeb_form_content\', \'eeb_form_content\', 10, 4);' . "\n\n"
724
+ . 'function eeb_form_content($content, $labels, $show_powered_by, $methods) {' . "\n"
725
+ . ' // add a &lt;div&gt;-wrapper' . "\n"
726
+ . ' return \'&lt;div class="form-wrapper"&gt;\' . $content . \'&lt;/div&gt;\';' . "\n"
727
+ . '}' . "\n"
728
+ . '&#63;></code></pre>'
729
+ , EMAIL_ENCODER_BUNDLE_DOMAIN);
730
+ } else if ($key === 'faq') {
731
+ $content = __('<h3>FAQ</h3>'
732
+ . '<p>Please check the <a href="http://wordpress.org/extend/plugins/email-encoder-bundle/faq/" target="_blank">FAQ on the Plugin site</a>.'
733
+ , EMAIL_ENCODER_BUNDLE_DOMAIN);
734
+ } else if ($key === 'sidebar') {
735
+ $content = __('<h4>About the author</h4>'
736
+ . '<ul>'
737
+ . '<li><a href="http://www.freelancephp.net/" target="_blank">FreelancePHP.net</a></li>'
738
+ . '<li><a href="http://www.freelancephp.net/contact/" target="_blank">Contact</a></li>'
739
+ . '</ul>'
740
+ , EMAIL_ENCODER_BUNDLE_DOMAIN);
741
+ } else {
742
+ $content = '';
743
+ }
744
+
745
+ return $content;
746
+ }
747
+
748
+ /* -------------------------------------------------------------------------
749
+ * Encoder Form
750
+ * -------------------------------------------------------------------------/
751
+
752
+ /**
753
+ * Get the encoder form (to use as a demo, like on the options page)
754
+ * @return string
755
+ */
756
+ public function get_encoder_form() {
757
+ $method_options = '';
758
+ foreach ($this->methods as $method_name => $info) {
759
+ $method_options .= '<option value="' . $method_name . '"' . (($this->method == $method_name) ? ' selected="selected"' : '') . '>' . $info['name'] . '</option>';
760
+ }
761
+
762
+ $show_powered_by = (bool) $this->options['powered_by'];
763
+ $powered_by = '';
764
+ if ($show_powered_by) {
765
+ $powered_by .= '<p class="powered-by">' . __('Powered by', EMAIL_ENCODER_BUNDLE_DOMAIN) . ' <a rel="external" href="http://www.freelancephp.net/email-encoder-php-class-wp-plugin/">Email Encoder Bundle</a></p>';
766
+ }
767
+
768
+ $labels = array(
769
+ 'email' => __('Email Address:', EMAIL_ENCODER_BUNDLE_DOMAIN),
770
+ 'display' => __('Display Text:', EMAIL_ENCODER_BUNDLE_DOMAIN),
771
+ 'mailto' => __('Mailto Link:', EMAIL_ENCODER_BUNDLE_DOMAIN),
772
+ 'method' => __('Encoding Method:', EMAIL_ENCODER_BUNDLE_DOMAIN),
773
+ 'create_link' => __('Create Protected Mail Link &gt;&gt;', EMAIL_ENCODER_BUNDLE_DOMAIN),
774
+ 'output' => __('Protected Mail Link (code):', EMAIL_ENCODER_BUNDLE_DOMAIN),
775
+ 'method_options' => $method_options,
776
+ 'powered_by' => $powered_by,
777
+ );
778
+
779
+ extract($labels);
780
+
781
+ $form = <<<FORM
782
+ <div class="eeb-form">
783
+ <form>
784
+ <fieldset>
785
+ <div class="input">
786
+ <table>
787
+ <tbody>
788
+ <tr>
789
+ <th><label for="eeb-email">{$email}</label></th>
790
+ <td><input type="text" class="regular-text" id="eeb-email" name="eeb-email" /></td>
791
+ </tr>
792
+ <tr>
793
+ <th><label for="eeb-display">{$display}</label></th>
794
+ <td><input type="text" class="regular-text" id="eeb-display" name="eeb-display" /></td>
795
+ </tr>
796
+ <tr>
797
+ <th>{$mailto}</th>
798
+ <td><span class="eeb-example"></span></td>
799
+ </tr>
800
+ <tr>
801
+ <th><label for="eeb-encode-method">{$method}</label></th>
802
+ <td><select id="eeb-encode-method" name="eeb-encode-method" class="postform">
803
+ {$method_options}
804
+ </select>
805
+ <input type="button" id="eeb-ajax-encode" name="eeb-ajax-encode" value="{$create_link}" />
806
+ </td>
807
+ </tr>
808
+ </tbody>
809
+ </table>
810
+ </div>
811
+ <div class="eeb-output">
812
+ <table>
813
+ <tbody>
814
+ <tr>
815
+ <th><label for="eeb-encoded-output">{$output}</label></th>
816
+ <td><textarea class="large-text node" id="eeb-encoded-output" name="eeb-encoded-output" cols="50" rows="4"></textarea></td>
817
+ </tr>
818
+ </tbody>
819
+ </table>
820
+ </div>
821
+ {$powered_by}
822
+ </fieldset>
823
+ </form>
824
+ </div>
825
+ FORM;
826
+
827
+ // apply filters
828
+ $form = apply_filters('eeb_form_content', $form, $labels, $show_powered_by, $this->methods);
829
+
830
+ return $form;
831
+ }
832
+
833
+ } // end class Eeb_Admin
834
+
835
+ endif;
836
+
837
  /* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
includes/class-eeb-site.php CHANGED
@@ -1,516 +1,516 @@
1
- <?php defined('ABSPATH') OR die('No direct access.');
2
-
3
- /**
4
- * Class Eeb_Site (singleton)
5
- *
6
- * Contains all nescessary code for the site part
7
- *
8
- * @extends Eeb_Admin
9
- * @final
10
- *
11
- * @package Email_Encoder_Bundle
12
- * @category WordPress Plugins
13
- */
14
- if (!class_exists('Eeb_Site') && class_exists('Eeb_Admin')):
15
-
16
- final class Eeb_Site extends Eeb_Admin {
17
-
18
- /**
19
- * @var Eeb_Site Singleton instance
20
- */
21
- static private $instance = null;
22
-
23
- /**
24
- * @var boolean
25
- */
26
- private $is_admin_user = false;
27
-
28
- /**
29
- * @var array Regular expresssions
30
- */
31
- private $regexp_patterns = array(
32
- 'mailto' => '/<a([^<>]*?)href=["\']mailto:(.*?)["\'](.*?)>(.*?)<\/a[\s+]*>/is',
33
- 'email' => '/([A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6})/is',
34
- );
35
-
36
- /**
37
- * Constructor
38
- */
39
- protected function __construct() {
40
- parent::__construct();
41
- }
42
-
43
- /**
44
- * Make private to prevent multiple objects
45
- */
46
- private function __clone() {}
47
-
48
- /**
49
- * Get singleton instance
50
- */
51
- static public function getInstance() {
52
- if (self::$instance === null) {
53
- self::$instance = new Eeb_Site();
54
- }
55
-
56
- return self::$instance;
57
- }
58
-
59
- /**
60
- * wp action
61
- */
62
- public function wp() {
63
- $this->is_admin_user = current_user_can('manage_options');
64
-
65
- if (is_admin()) {
66
- return;
67
- }
68
-
69
- // apply filters
70
- $this->regexp_patterns['mailto'] = apply_filters('eeb_mailto_regexp', $this->regexp_patterns['mailto']);
71
- $this->regexp_patterns['email'] = apply_filters('eeb_email_regexp', $this->regexp_patterns['email']);
72
-
73
- if (is_feed()) {
74
- // rss feed
75
- $rss_filters = array('the_title', 'the_content', 'the_excerpt', 'the_title_rss', 'the_content_rss', 'the_excerpt_rss',
76
- 'comment_text_rss', 'comment_author_rss', 'the_category_rss', 'the_content_feed', 'author_feed_link', 'feed_link');
77
-
78
- foreach($rss_filters as $filter) {
79
- if ($this->options['remove_shortcodes_rss']) {
80
- add_filter($filter, array($this, 'callback_rss_remove_shortcodes'), 9);
81
- }
82
-
83
- if ($this->options['filter_rss']) {
84
- add_filter($filter, array($this, 'callback_filter_rss'), 100);
85
- }
86
- }
87
- } else {
88
- // site
89
- $filters = array();
90
-
91
- // post content
92
- if ($this->options['filter_posts']) {
93
- array_push($filters, 'the_title', 'the_content', 'the_excerpt', 'get_the_excerpt');
94
- }
95
-
96
- // comments
97
- if ($this->options['filter_comments']) {
98
- array_push($filters, 'comment_text', 'comment_excerpt', 'comment_url', 'get_comment_author_url', 'get_comment_author_link', 'get_comment_author_url_link');
99
- }
100
-
101
- // widgets
102
- if ($this->options['filter_widgets']) {
103
- array_push($filters, 'widget_title', 'widget_text', 'widget_content');
104
-
105
- // also replace shortcodes
106
- if ($this->options['shortcodes_in_widgets']) {
107
- add_filter('widget_text', 'do_shortcode', 100);
108
- add_filter('widget_content', 'do_shortcode', 100); // widget_content id filter of Widget Logic plugin
109
- }
110
- }
111
-
112
- foreach($filters as $filter) {
113
- add_filter($filter, array($this, 'callback_filter'), 100);
114
- }
115
- }
116
-
117
- // actions
118
- add_action('wp_head', array($this, 'wp_head'));
119
-
120
- // shortcodes
121
- add_shortcode('eeb_form', array($this, 'shortcode_email_encoder_form'));
122
- add_shortcode('eeb_email', array($this, 'shortcode_encode_email'));
123
- add_shortcode('eeb_content', array($this, 'shortcode_encode_content'));
124
-
125
- // hook
126
- do_action('eeb_ready', array($this, 'callback_filter'), $this);
127
-
128
- // support for deprecated action and shortcodes
129
- if ($this->options['support_deprecated_names'] == 1) {
130
- // deprecated template functions
131
- require_once('deprecated.php');
132
-
133
- // deprecated shortcodes
134
- add_shortcode('email_encoder_form', array($this, 'shortcode_email_encoder_form'));
135
- add_shortcode('encode_email', array($this, 'shortcode_encode_email'));
136
- add_shortcode('encode_content', array($this, 'shortcode_encode_content'));
137
-
138
- // deprecated hooks
139
- do_action('init_email_encoder_bundle', array($this, 'callback_filter'), $this);
140
- }
141
- }
142
-
143
- /**
144
- * WP head
145
- */
146
- public function wp_head() {
147
- // add styling for encoding check message + icon
148
- if ($this->is_admin_user && $this->options['show_encoded_check']) {
149
- echo <<<CSS
150
- <style type="text/css">
151
- a.encoded-check { opacity:0.5; position:absolute; text-decoration:none !important; font:10px Arial !important; margin-top:-3px; color:#629632; font-weight:bold; }
152
- a.encoded-check:hover { opacity:1; cursor:help; }
153
- a.encoded-check img { width:10px; height:10px; }
154
- </style>
155
- CSS;
156
- }
157
- }
158
-
159
- /* -------------------------------------------------------------------------
160
- * Filter Callbacks
161
- * ------------------------------------------------------------------------*/
162
-
163
- /**
164
- * WP filter callback
165
- * @param string $content
166
- * @return string
167
- */
168
- public function callback_filter($content) {
169
- global $post;
170
-
171
- if (isset($post) && in_array($post->ID, $this->skip_posts)) {
172
- return $content;
173
- }
174
-
175
- return $this->encode_email_filter($content, true, $this->options['encode_mailtos'], $this->options['encode_emails']);
176
- }
177
-
178
- /**
179
- * RSS Filter callback
180
- * @param string $content
181
- * @return string
182
- */
183
- public function callback_filter_rss($content) {
184
- $content = preg_replace($this->regexp_patterns, $this->options['protection_text_rss'], $content);
185
-
186
- return $content;
187
- }
188
-
189
- /**
190
- * RSS Callback Remove shortcodes
191
- * @param string $content
192
- * @return string
193
- */
194
- public function callback_rss_remove_shortcodes($content) {
195
- // strip shortcodes like [eeb_content], [eeb_form]
196
- $content = strip_shortcodes($content);
197
-
198
- return $content;
199
- }
200
-
201
- /**
202
- * Filter content for encoding
203
- * @param string $content
204
- * @param boolean $enc_tags Optional, default true
205
- * @param boolean $enc_mailtos Optional, default true
206
- * @param boolean $enc_plain_emails Optional, default true
207
- * @return string
208
- */
209
- public function encode_email_filter($content, $enc_tags = true, $enc_mailtos = true, $enc_plain_emails = true) {
210
- // encode mailto links
211
- if ($enc_mailtos) {
212
- $content = preg_replace_callback($this->regexp_patterns['mailto'], array($this, 'callback_encode_email'), $content);
213
- }
214
-
215
- // replace plain emails
216
- if ($enc_plain_emails) {
217
- $content = preg_replace_callback($this->regexp_patterns['email'], array($this, 'callback_encode_email'), $content);
218
- }
219
-
220
- // workaround for double encoding bug when auto-protect mailto is enabled and method is enc_html
221
- if ($this->options['encode_mailtos'] == 1) {
222
- // change back to html tag
223
- $content = str_replace('[a-replacement]', '<a', $content);
224
- }
225
-
226
- return $content;
227
- }
228
-
229
- /**
230
- * Callback for encoding email
231
- * @param array $match
232
- * @return string
233
- */
234
- public function callback_encode_email($match) {
235
- if (count($match) < 3) {
236
- return $this->encode_email($match[1]);
237
- } else if (count($match) == 3) {
238
- return $this->encode_email($match[2]);
239
- }
240
-
241
- return $this->encode_email($match[2], $match[4], $match[1] . ' ' . $match[3]);
242
- }
243
-
244
- /* -------------------------------------------------------------------------
245
- * Shortcode Functions
246
- * ------------------------------------------------------------------------*/
247
-
248
- /**
249
- * Shortcode showing encoder form
250
- * @return string
251
- */
252
- public function shortcode_email_encoder_form() {
253
- // add style and script for ajax encoder
254
- wp_enqueue_script('email_encoder', plugins_url('js/email-encoder-bundle.min.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
255
-
256
- return $this->get_encoder_form();
257
- }
258
-
259
- /**
260
- * Shortcode encoding email
261
- * @param array $attrs
262
- * @return string
263
- */
264
- public function shortcode_encode_email($attrs) {
265
- if (!is_array($attrs) || !key_exists('email', $attrs)) {
266
- return '';
267
- }
268
-
269
- $email = $attrs['email'];
270
- $display = (key_exists('display', $attrs)) ? $attrs['display'] : $attrs['email'];
271
- $method = (key_exists('method', $attrs)) ? $attrs['method'] : null;
272
- $extra_attrs = (key_exists('extra_attrs', $attrs)) ? $attrs['extra_attrs'] : null;
273
-
274
- $encoded = $this->encode_email($email, $display, $extra_attrs, $method);
275
-
276
- // workaround for double encoding bug when auto-protect mailto is enabled and method is enc_html
277
- if ($this->options['encode_mailtos'] == 1 && $method === 'enc_html') {
278
- // change html tag to entity
279
- $encoded = str_replace('<a', '[a-replacement]', $encoded);
280
- }
281
-
282
- return $encoded;
283
- }
284
-
285
- /**
286
- * Shortcode encoding content
287
- * @param array $attrs
288
- * @param string $content Optional
289
- * @return string
290
- */
291
- public function shortcode_encode_content($attrs, $content = '') {
292
- $method = (is_array($attrs) && key_exists('method', $attrs)) ? $attrs['method'] : null;
293
-
294
- return $this->encode_content($content, $method);
295
- }
296
-
297
- /* -------------------------------------------------------------------------
298
- * Encode Functions
299
- * -------------------------------------------------------------------------/
300
-
301
- /**
302
- * Encode the given email into an encoded HTML link
303
- * @param string $content
304
- * @param string $method Optional, else the default setted method will; be used
305
- * @param boolean $no_html_checked
306
- * @return string
307
- */
308
- public function encode_content($content, $method = null, $no_html_checked = false) {
309
- // get encode method
310
- $method = $this->get_method($method, $this->method);
311
-
312
- // get encoded email code
313
- $content = $this->{$method}($content);
314
-
315
- // add visual check
316
- if ($no_html_checked !== true) {
317
- $content = $this->get_success_check($content);
318
- }
319
-
320
- return $content;
321
- }
322
-
323
- /**
324
- * Encode the given email into an encoded HTML link
325
- * @param string $email
326
- * @param string $display Optional, if not set display will be the email
327
- * @param string $extra_attrs Optional
328
- * @param string $method Optional, else the default setted method will; be used
329
- * @param boolean $no_html_checked
330
- * @return string
331
- */
332
- public function encode_email($email, $display = null, $extra_attrs = '', $method = null, $no_html_checked = false) {
333
- // get encode method
334
- $method = $this->get_method($method, $this->method);
335
-
336
- // decode entities
337
- $email = html_entity_decode($email);
338
-
339
- // set email as display
340
- if ($display === null) {
341
- $display = $email;
342
-
343
- if ($method === 'enc_html') {
344
- $display = $this->enc_html($display);
345
- }
346
- } else {
347
- $display = html_entity_decode($display);
348
- }
349
-
350
- if ($method === 'enc_html') {
351
- $email = $this->enc_html($email);
352
- }
353
-
354
- $class = $this->options['class_name'];
355
- $extra_attrs = ' ' . trim($extra_attrs);
356
- $mailto = '<a class="'. $class .'" href="mailto:' . $email . '"'. $extra_attrs . '>' . $display . '</a>';
357
-
358
- if ($method === 'enc_html') {
359
- // add visual check
360
- if ($no_html_checked !== true) {
361
- $mailto = $this->get_success_check($mailto);
362
- }
363
- } else {
364
- $mailto = $this->encode_content($mailto, $method, $no_html_checked);
365
- }
366
-
367
- // get encoded email code
368
- return $mailto;
369
- }
370
-
371
- /**
372
- * Add html to encoded content to show check icon and text
373
- * @param string $content
374
- * @return string
375
- */
376
- private function get_success_check($content) {
377
- if (!$this->is_admin_user || !$this->options['show_encoded_check']) {
378
- return $content;
379
- }
380
-
381
- return $content
382
- . '<a href="javascript:;" class="encoded-check"'
383
- . ' title="' . __('Successfully Encoded (this is a check and only visible when logged in as admin)', EMAIL_ENCODER_BUNDLE_DOMAIN) . '">'
384
- . '<img class="encoded-check-icon" src="' . plugins_url('images/icon-email-encoder-bundle.png', EMAIL_ENCODER_BUNDLE_FILE)
385
- . '" alt="' . __('Encoded', EMAIL_ENCODER_BUNDLE_DOMAIN) . '" />'
386
- . __('Successfully Encoded', EMAIL_ENCODER_BUNDLE_DOMAIN) . '</a>';
387
- }
388
-
389
- /* -------------------------------------------------------------------------
390
- * Different Encoding Methods
391
- * ------------------------------------------------------------------------*/
392
-
393
- //public function encodeURIComponent($str) {
394
- // $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')');
395
- // return strtr(rawurlencode($str), $revert);
396
- //}
397
-
398
- /**
399
- * ASCII method
400
- * Based on function from Tyler Akins (http://rumkin.com/tools/mailto_encoder/)
401
- *
402
- * @param string $value
403
- * @return string
404
- */
405
- private function enc_ascii($value) {
406
- $mail_link = $value;
407
-
408
- $mail_letters = '';
409
-
410
- for ($i = 0; $i < strlen($mail_link); $i ++) {
411
- $l = substr($mail_link, $i, 1);
412
-
413
- if (strpos($mail_letters, $l) === false) {
414
- $p = rand(0, strlen($mail_letters));
415
- $mail_letters = substr($mail_letters, 0, $p) .
416
- $l . substr($mail_letters, $p, strlen($mail_letters));
417
- }
418
- }
419
-
420
- $mail_letters_enc = str_replace("\\", "\\\\", $mail_letters);
421
- $mail_letters_enc = str_replace("\"", "\\\"", $mail_letters_enc);
422
-
423
- $mail_indices = '';
424
- for ($i = 0; $i < strlen($mail_link); $i ++) {
425
- $index = strpos($mail_letters, substr($mail_link, $i, 1));
426
- $index += 48;
427
- $mail_indices .= chr($index);
428
- }
429
-
430
- $mail_indices = str_replace("\\", "\\\\", $mail_indices);
431
- $mail_indices = str_replace("\"", "\\\"", $mail_indices);
432
-
433
- return '<script type="text/javascript">'
434
- . '(function(){'
435
- . 'var ml="'. $mail_letters_enc .'",mi="'. $mail_indices .'",o="";'
436
- // . 'console.log("-----");'
437
- // . 'console.log("' . $mail_letters_enc . '");'
438
- // . 'console.log("' . $this->encodeURIComponent($mail_letters_enc) . '");'
439
- // . 'var test = decodeURIComponent(\'' . $this->encodeURIComponent($mail_letters_enc) . '\');'
440
- // . 'test = test.replace("\", "");'
441
- // . 'console.log(test);'
442
- . 'for(var j=0,l=mi.length;j<l;j++){'
443
- . 'o+=ml.charAt(mi.charCodeAt(j)-48);'
444
- . '}document.write(o);'
445
- . '}());'
446
- . '</script><noscript>'
447
- . $this->options['protection_text']
448
- . '</noscript>';
449
- }
450
-
451
- /**
452
- * Escape method
453
- * Taken from the plugin "Email Spam Protection" by Adam Hunter (http://blueberryware.net/2008/09/14/email-spam-protection/)
454
- *
455
- * @param string $value
456
- * @return string
457
- */
458
- private function enc_escape($value) {
459
- $string = 'document.write(\'' . $value . '\')';
460
-
461
- // break string into array of characters, we can't use string_split because its php5 only
462
- $split = preg_split('||', $string);
463
- $out = '<script type="text/javascript">' . "eval(unescape('";
464
-
465
- foreach ($split as $c) {
466
- // preg split will return empty first and last characters, check for them and ignore
467
- if (!empty($c)) {
468
- $out .= '%' . dechex(ord($c));
469
- }
470
- }
471
-
472
- $out .= "'))" . '</script><noscript>'
473
- . $this->options['protection_text']
474
- . '</noscript>';
475
-
476
- return $out;
477
- }
478
-
479
- /**
480
- * Convert randomly chars to htmlentities
481
- * This method is partly taken from WordPress
482
- * @link http://codex.wordpress.org/Function_Reference/antispambot
483
- *
484
- * @param string $value
485
- * @return string
486
- */
487
- private function enc_html($value) {
488
- // check for built-in WP function
489
- if (function_exists('antispambot')) {
490
- $emailNOSPAMaddy = antispambot($value);
491
- } else {
492
- $emailNOSPAMaddy = '';
493
- srand ((float) microtime() * 1000000);
494
- for ($i = 0; $i < strlen($emailaddy); $i = $i + 1) {
495
- $j = floor(rand(0, 1+$mailto));
496
- if ($j==0) {
497
- $emailNOSPAMaddy .= '&#'.ord(substr($emailaddy,$i,1)).';';
498
- } elseif ($j==1) {
499
- $emailNOSPAMaddy .= substr($emailaddy,$i,1);
500
- } elseif ($j==2) {
501
- $emailNOSPAMaddy .= '%'.zeroise(dechex(ord(substr($emailaddy, $i, 1))), 2);
502
- }
503
- }
504
- $emailNOSPAMaddy = str_replace('@','&#64;',$emailNOSPAMaddy);
505
- }
506
-
507
- $emailNOSPAMaddy = str_replace('@', '&#64;', $emailNOSPAMaddy);
508
-
509
- return $emailNOSPAMaddy;
510
- }
511
-
512
- } // end class Eeb_Site
513
-
514
- endif;
515
-
516
  /* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
1
+ <?php defined('ABSPATH') OR die('No direct access.');
2
+
3
+ /**
4
+ * Class Eeb_Site (singleton)
5
+ *
6
+ * Contains all nescessary code for the site part
7
+ *
8
+ * @extends Eeb_Admin
9
+ * @final
10
+ *
11
+ * @package Email_Encoder_Bundle
12
+ * @category WordPress Plugins
13
+ */
14
+ if (!class_exists('Eeb_Site') && class_exists('Eeb_Admin')):
15
+
16
+ final class Eeb_Site extends Eeb_Admin {
17
+
18
+ /**
19
+ * @var Eeb_Site Singleton instance
20
+ */
21
+ static private $instance = null;
22
+
23
+ /**
24
+ * @var boolean
25
+ */
26
+ private $is_admin_user = false;
27
+
28
+ /**
29
+ * @var array Regular expresssions
30
+ */
31
+ private $regexp_patterns = array(
32
+ 'mailto' => '/<a([^<>]*?)href=["\']mailto:(.*?)["\'](.*?)>(.*?)<\/a[\s+]*>/is',
33
+ 'email' => '/([A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6})/is',
34
+ );
35
+
36
+ /**
37
+ * Constructor
38
+ */
39
+ protected function __construct() {
40
+ parent::__construct();
41
+ }
42
+
43
+ /**
44
+ * Make private to prevent multiple objects
45
+ */
46
+ private function __clone() {}
47
+
48
+ /**
49
+ * Get singleton instance
50
+ */
51
+ static public function getInstance() {
52
+ if (self::$instance === null) {
53
+ self::$instance = new Eeb_Site();
54
+ }
55
+
56
+ return self::$instance;
57
+ }
58
+
59
+ /**
60
+ * wp action
61
+ */
62
+ public function wp() {
63
+ $this->is_admin_user = current_user_can('manage_options');
64
+
65
+ if (is_admin()) {
66
+ return;
67
+ }
68
+
69
+ // apply filters
70
+ $this->regexp_patterns['mailto'] = apply_filters('eeb_mailto_regexp', $this->regexp_patterns['mailto']);
71
+ $this->regexp_patterns['email'] = apply_filters('eeb_email_regexp', $this->regexp_patterns['email']);
72
+
73
+ if (is_feed()) {
74
+ // rss feed
75
+ $rss_filters = array('the_title', 'the_content', 'the_excerpt', 'the_title_rss', 'the_content_rss', 'the_excerpt_rss',
76
+ 'comment_text_rss', 'comment_author_rss', 'the_category_rss', 'the_content_feed', 'author_feed_link', 'feed_link');
77
+
78
+ foreach($rss_filters as $filter) {
79
+ if ($this->options['remove_shortcodes_rss']) {
80
+ add_filter($filter, array($this, 'callback_rss_remove_shortcodes'), 9);
81
+ }
82
+
83
+ if ($this->options['filter_rss']) {
84
+ add_filter($filter, array($this, 'callback_filter_rss'), 100);
85
+ }
86
+ }
87
+ } else {
88
+ // site
89
+ $filters = array();
90
+
91
+ // post content
92
+ if ($this->options['filter_posts']) {
93
+ array_push($filters, 'the_title', 'the_content', 'the_excerpt', 'get_the_excerpt');
94
+ }
95
+
96
+ // comments
97
+ if ($this->options['filter_comments']) {
98
+ array_push($filters, 'comment_text', 'comment_excerpt', 'comment_url', 'get_comment_author_url', 'get_comment_author_link', 'get_comment_author_url_link');
99
+ }
100
+
101
+ // widgets
102
+ if ($this->options['filter_widgets']) {
103
+ array_push($filters, 'widget_title', 'widget_text', 'widget_content');
104
+
105
+ // also replace shortcodes
106
+ if ($this->options['shortcodes_in_widgets']) {
107
+ add_filter('widget_text', 'do_shortcode', 100);
108
+ add_filter('widget_content', 'do_shortcode', 100); // widget_content id filter of Widget Logic plugin
109
+ }
110
+ }
111
+
112
+ foreach($filters as $filter) {
113
+ add_filter($filter, array($this, 'callback_filter'), 100);
114
+ }
115
+ }
116
+
117
+ // actions
118
+ add_action('wp_head', array($this, 'wp_head'));
119
+
120
+ // shortcodes
121
+ add_shortcode('eeb_form', array($this, 'shortcode_email_encoder_form'));
122
+ add_shortcode('eeb_email', array($this, 'shortcode_encode_email'));
123
+ add_shortcode('eeb_content', array($this, 'shortcode_encode_content'));
124
+
125
+ // hook
126
+ do_action('eeb_ready', array($this, 'callback_filter'), $this);
127
+
128
+ // support for deprecated action and shortcodes
129
+ if ($this->options['support_deprecated_names'] == 1) {
130
+ // deprecated template functions
131
+ require_once('deprecated.php');
132
+
133
+ // deprecated shortcodes
134
+ add_shortcode('email_encoder_form', array($this, 'shortcode_email_encoder_form'));
135
+ add_shortcode('encode_email', array($this, 'shortcode_encode_email'));
136
+ add_shortcode('encode_content', array($this, 'shortcode_encode_content'));
137
+
138
+ // deprecated hooks
139
+ do_action('init_email_encoder_bundle', array($this, 'callback_filter'), $this);
140
+ }
141
+ }
142
+
143
+ /**
144
+ * WP head
145
+ */
146
+ public function wp_head() {
147
+ // add styling for encoding check message + icon
148
+ if ($this->is_admin_user && $this->options['show_encoded_check']) {
149
+ echo <<<CSS
150
+ <style type="text/css">
151
+ a.encoded-check { opacity:0.5; position:absolute; text-decoration:none !important; font:10px Arial !important; margin-top:-3px; color:#629632; font-weight:bold; }
152
+ a.encoded-check:hover { opacity:1; cursor:help; }
153
+ a.encoded-check img { width:10px; height:10px; }
154
+ </style>
155
+ CSS;
156
+ }
157
+ }
158
+
159
+ /* -------------------------------------------------------------------------
160
+ * Filter Callbacks
161
+ * ------------------------------------------------------------------------*/
162
+
163
+ /**
164
+ * WP filter callback
165
+ * @param string $content
166
+ * @return string
167
+ */
168
+ public function callback_filter($content) {
169
+ global $post;
170
+
171
+ if (isset($post) && in_array($post->ID, $this->skip_posts)) {
172
+ return $content;
173
+ }
174
+
175
+ return $this->encode_email_filter($content, true, $this->options['encode_mailtos'], $this->options['encode_emails']);
176
+ }
177
+
178
+ /**
179
+ * RSS Filter callback
180
+ * @param string $content
181
+ * @return string
182
+ */
183
+ public function callback_filter_rss($content) {
184
+ $content = preg_replace($this->regexp_patterns, $this->options['protection_text_rss'], $content);
185
+
186
+ return $content;
187
+ }
188
+
189
+ /**
190
+ * RSS Callback Remove shortcodes
191
+ * @param string $content
192
+ * @return string
193
+ */
194
+ public function callback_rss_remove_shortcodes($content) {
195
+ // strip shortcodes like [eeb_content], [eeb_form]
196
+ $content = strip_shortcodes($content);
197
+
198
+ return $content;
199
+ }
200
+
201
+ /**
202
+ * Filter content for encoding
203
+ * @param string $content
204
+ * @param boolean $enc_tags Optional, default true
205
+ * @param boolean $enc_mailtos Optional, default true
206
+ * @param boolean $enc_plain_emails Optional, default true
207
+ * @return string
208
+ */
209
+ public function encode_email_filter($content, $enc_tags = true, $enc_mailtos = true, $enc_plain_emails = true) {
210
+ // encode mailto links
211
+ if ($enc_mailtos) {
212
+ $content = preg_replace_callback($this->regexp_patterns['mailto'], array($this, 'callback_encode_email'), $content);
213
+ }
214
+
215
+ // replace plain emails
216
+ if ($enc_plain_emails) {
217
+ $content = preg_replace_callback($this->regexp_patterns['email'], array($this, 'callback_encode_email'), $content);
218
+ }
219
+
220
+ // workaround for double encoding bug when auto-protect mailto is enabled and method is enc_html
221
+ if ($this->options['encode_mailtos'] == 1) {
222
+ // change back to html tag
223
+ $content = str_replace('[a-replacement]', '<a', $content);
224
+ }
225
+
226
+ return $content;
227
+ }
228
+
229
+ /**
230
+ * Callback for encoding email
231
+ * @param array $match
232
+ * @return string
233
+ */
234
+ public function callback_encode_email($match) {
235
+ if (count($match) < 3) {
236
+ return $this->encode_email($match[1]);
237
+ } else if (count($match) == 3) {
238
+ return $this->encode_email($match[2]);
239
+ }
240
+
241
+ return $this->encode_email($match[2], $match[4], $match[1] . ' ' . $match[3]);
242
+ }
243
+
244
+ /* -------------------------------------------------------------------------
245
+ * Shortcode Functions
246
+ * ------------------------------------------------------------------------*/
247
+
248
+ /**
249
+ * Shortcode showing encoder form
250
+ * @return string
251
+ */
252
+ public function shortcode_email_encoder_form() {
253
+ // add style and script for ajax encoder
254
+ wp_enqueue_script('email_encoder', plugins_url('js/email-encoder-bundle.min.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
255
+
256
+ return $this->get_encoder_form();
257
+ }
258
+
259
+ /**
260
+ * Shortcode encoding email
261
+ * @param array $attrs
262
+ * @return string
263
+ */
264
+ public function shortcode_encode_email($attrs) {
265
+ if (!is_array($attrs) || !key_exists('email', $attrs)) {
266
+ return '';
267
+ }
268
+
269
+ $email = $attrs['email'];
270
+ $display = (key_exists('display', $attrs)) ? $attrs['display'] : $attrs['email'];
271
+ $method = (key_exists('method', $attrs)) ? $attrs['method'] : null;
272
+ $extra_attrs = (key_exists('extra_attrs', $attrs)) ? $attrs['extra_attrs'] : null;
273
+
274
+ $encoded = $this->encode_email($email, $display, $extra_attrs, $method);
275
+
276
+ // workaround for double encoding bug when auto-protect mailto is enabled and method is enc_html
277
+ if ($this->options['encode_mailtos'] == 1 && $method === 'enc_html') {
278
+ // change html tag to entity
279
+ $encoded = str_replace('<a', '[a-replacement]', $encoded);
280
+ }
281
+
282
+ return $encoded;
283
+ }
284
+
285
+ /**
286
+ * Shortcode encoding content
287
+ * @param array $attrs
288
+ * @param string $content Optional
289
+ * @return string
290
+ */
291
+ public function shortcode_encode_content($attrs, $content = '') {
292
+ $method = (is_array($attrs) && key_exists('method', $attrs)) ? $attrs['method'] : null;
293
+
294
+ return $this->encode_content($content, $method);
295
+ }
296
+
297
+ /* -------------------------------------------------------------------------
298
+ * Encode Functions
299
+ * -------------------------------------------------------------------------/
300
+
301
+ /**
302
+ * Encode the given email into an encoded HTML link
303
+ * @param string $content
304
+ * @param string $method Optional, else the default setted method will; be used
305
+ * @param boolean $no_html_checked
306
+ * @return string
307
+ */
308
+ public function encode_content($content, $method = null, $no_html_checked = false) {
309
+ // get encode method
310
+ $method = $this->get_method($method, $this->method);
311
+
312
+ // get encoded email code
313
+ $content = $this->{$method}($content);
314
+
315
+ // add visual check
316
+ if ($no_html_checked !== true) {
317
+ $content = $this->get_success_check($content);
318
+ }
319
+
320
+ return $content;
321
+ }
322
+
323
+ /**
324
+ * Encode the given email into an encoded HTML link
325
+ * @param string $email
326
+ * @param string $display Optional, if not set display will be the email
327
+ * @param string $extra_attrs Optional
328
+ * @param string $method Optional, else the default setted method will; be used
329
+ * @param boolean $no_html_checked
330
+ * @return string
331
+ */
332
+ public function encode_email($email, $display = null, $extra_attrs = '', $method = null, $no_html_checked = false) {
333
+ // get encode method
334
+ $method = $this->get_method($method, $this->method);
335
+
336
+ // decode entities
337
+ $email = html_entity_decode($email);
338
+
339
+ // set email as display
340
+ if ($display === null) {
341
+ $display = $email;
342
+
343
+ if ($method === 'enc_html') {
344
+ $display = $this->enc_html($display);
345
+ }
346
+ } else {
347
+ $display = html_entity_decode($display);
348
+ }
349
+
350
+ if ($method === 'enc_html') {
351
+ $email = $this->enc_html($email);
352
+ }
353
+
354
+ $class = $this->options['class_name'];
355
+ $extra_attrs = ' ' . trim($extra_attrs);
356
+ $mailto = '<a class="'. $class .'" href="mailto:' . $email . '"'. $extra_attrs . '>' . $display . '</a>';
357
+
358
+ if ($method === 'enc_html') {
359
+ // add visual check
360
+ if ($no_html_checked !== true) {
361
+ $mailto = $this->get_success_check($mailto);
362
+ }
363
+ } else {
364
+ $mailto = $this->encode_content($mailto, $method, $no_html_checked);
365
+ }
366
+
367
+ // get encoded email code
368
+ return $mailto;
369
+ }
370
+
371
+ /**
372
+ * Add html to encoded content to show check icon and text
373
+ * @param string $content
374
+ * @return string
375
+ */
376
+ private function get_success_check($content) {
377
+ if (!$this->is_admin_user || !$this->options['show_encoded_check']) {
378
+ return $content;
379
+ }
380
+
381
+ return $content
382
+ . '<a href="javascript:;" class="encoded-check"'
383
+ . ' title="' . __('Successfully Encoded (this is a check and only visible when logged in as admin)', EMAIL_ENCODER_BUNDLE_DOMAIN) . '">'
384
+ . '<img class="encoded-check-icon" src="' . plugins_url('images/icon-email-encoder-bundle.png', EMAIL_ENCODER_BUNDLE_FILE)
385
+ . '" alt="' . __('Encoded', EMAIL_ENCODER_BUNDLE_DOMAIN) . '" />'
386
+ . __('Successfully Encoded', EMAIL_ENCODER_BUNDLE_DOMAIN) . '</a>';
387
+ }
388
+
389
+ /* -------------------------------------------------------------------------
390
+ * Different Encoding Methods
391
+ * ------------------------------------------------------------------------*/
392
+
393
+ //public function encodeURIComponent($str) {
394
+ // $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')');
395
+ // return strtr(rawurlencode($str), $revert);
396
+ //}
397
+
398
+ /**
399
+ * ASCII method
400
+ * Based on function from Tyler Akins (http://rumkin.com/tools/mailto_encoder/)
401
+ *
402
+ * @param string $value
403
+ * @return string
404
+ */
405
+ private function enc_ascii($value) {
406
+ $mail_link = $value;
407
+
408
+ $mail_letters = '';
409
+
410
+ for ($i = 0; $i < strlen($mail_link); $i ++) {
411
+ $l = substr($mail_link, $i, 1);
412
+
413
+ if (strpos($mail_letters, $l) === false) {
414
+ $p = rand(0, strlen($mail_letters));
415
+ $mail_letters = substr($mail_letters, 0, $p) .
416
+ $l . substr($mail_letters, $p, strlen($mail_letters));
417
+ }
418
+ }
419
+
420
+ $mail_letters_enc = str_replace("\\", "\\\\", $mail_letters);
421
+ $mail_letters_enc = str_replace("\"", "\\\"", $mail_letters_enc);
422
+
423
+ $mail_indices = '';
424
+ for ($i = 0; $i < strlen($mail_link); $i ++) {
425
+ $index = strpos($mail_letters, substr($mail_link, $i, 1));
426
+ $index += 48;
427
+ $mail_indices .= chr($index);
428
+ }
429
+
430
+ $mail_indices = str_replace("\\", "\\\\", $mail_indices);
431
+ $mail_indices = str_replace("\"", "\\\"", $mail_indices);
432
+
433
+ return '<script type="text/javascript">'
434
+ . '(function(){'
435
+ . 'var ml="'. $mail_letters_enc .'",mi="'. $mail_indices .'",o="";'
436
+ // . 'console.log("-----");'
437
+ // . 'console.log("' . $mail_letters_enc . '");'
438
+ // . 'console.log("' . $this->encodeURIComponent($mail_letters_enc) . '");'
439
+ // . 'var test = decodeURIComponent(\'' . $this->encodeURIComponent($mail_letters_enc) . '\');'
440
+ // . 'test = test.replace("\", "");'
441
+ // . 'console.log(test);'
442
+ . 'for(var j=0,l=mi.length;j<l;j++){'
443
+ . 'o+=ml.charAt(mi.charCodeAt(j)-48);'
444
+ . '}document.write(o);'
445
+ . '}());'
446
+ . '</script><noscript>'
447
+ . $this->options['protection_text']
448
+ . '</noscript>';
449
+ }
450
+
451
+ /**
452
+ * Escape method
453
+ * Taken from the plugin "Email Spam Protection" by Adam Hunter (http://blueberryware.net/2008/09/14/email-spam-protection/)
454
+ *
455
+ * @param string $value
456
+ * @return string
457
+ */
458
+ private function enc_escape($value) {
459
+ $string = 'document.write(\'' . $value . '\')';
460
+
461
+ // break string into array of characters, we can't use string_split because its php5 only
462
+ $split = preg_split('||', $string);
463
+ $out = '<script type="text/javascript">' . "eval(unescape('";
464
+
465
+ foreach ($split as $c) {
466
+ // preg split will return empty first and last characters, check for them and ignore
467
+ if (!empty($c)) {
468
+ $out .= '%' . dechex(ord($c));
469
+ }
470
+ }
471
+
472
+ $out .= "'))" . '</script><noscript>'
473
+ . $this->options['protection_text']
474
+ . '</noscript>';
475
+
476
+ return $out;
477
+ }
478
+
479
+ /**
480
+ * Convert randomly chars to htmlentities
481
+ * This method is partly taken from WordPress
482
+ * @link http://codex.wordpress.org/Function_Reference/antispambot
483
+ *
484
+ * @param string $value
485
+ * @return string
486
+ */
487
+ private function enc_html($value) {
488
+ // check for built-in WP function
489
+ if (function_exists('antispambot')) {
490
+ $emailNOSPAMaddy = antispambot($value);
491
+ } else {
492
+ $emailNOSPAMaddy = '';
493
+ srand ((float) microtime() * 1000000);
494
+ for ($i = 0; $i < strlen($emailaddy); $i = $i + 1) {
495
+ $j = floor(rand(0, 1+$mailto));
496
+ if ($j==0) {
497
+ $emailNOSPAMaddy .= '&#'.ord(substr($emailaddy,$i,1)).';';
498
+ } elseif ($j==1) {
499
+ $emailNOSPAMaddy .= substr($emailaddy,$i,1);
500
+ } elseif ($j==2) {
501
+ $emailNOSPAMaddy .= '%'.zeroise(dechex(ord(substr($emailaddy, $i, 1))), 2);
502
+ }
503
+ }
504
+ $emailNOSPAMaddy = str_replace('@','&#64;',$emailNOSPAMaddy);
505
+ }
506
+
507
+ $emailNOSPAMaddy = str_replace('@', '&#64;', $emailNOSPAMaddy);
508
+
509
+ return $emailNOSPAMaddy;
510
+ }
511
+
512
+ } // end class Eeb_Site
513
+
514
+ endif;
515
+
516
  /* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
js/email-encoder-bundle.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /* Email Encoder Bundle */
2
  jQuery(function(e){"use strict";var t=e(".eeb-form");var n=t.find("#eeb-email");var r=t.find("#eeb-display");var i;var s=function(){if(!n.val()){return}t.find("#eeb-encoded-output").val("");e.get("",{ajaxEncodeEmail:true,email:n.val(),display:r.val()||n.val(),method:t.find("#eeb-encode-method").val()},function(e){t.find("#eeb-encoded-output").val(e);t.find(".eeb-output").fadeIn()})};t.find(".eeb-output").hide();n.keyup(function(){var e=n.val();var t=r.val();if(!t||t===i){r.val(e)}i=e});t.find("#eeb-email, #eeb-display").keyup(function(){if(r.val().length>0){t.find(".eeb-example").html('<a href="mailto:'+n.val()+'">'+r.val()+"</a>").parents("tr").fadeIn()}else{t.find(".eeb-example").parents("tr").fadeOut()}t.find(".eeb-output").fadeOut();t.find("#eeb-encoded-output").val("")}).keyup();t.find("#eeb-encode-method").bind("change keyup",function(){s()});t.find("#eeb-ajax-encode").click(function(){s()})});jQuery(function(e){"use strict";var t=e("#encode_emails");e("#setting-error-settings_updated").click(function(){e(this).hide()});e("#encode_mailtos").change(function(){var n=e(this).prop("checked");t.attr("disabled",!n);if(!n){t.attr("checked",false)}t.change()}).change();t.change(function(){e(".notice-form-field-bug")[t.prop("checked")?"fadeIn":"fadeOut"]()});e(".eeb-form table").addClass("form-table");e(".eeb-help-link").click(function(t){e("#contextual-help-link").click();t.preventDefault()});e(".wrap form").submit(function(){e('*[type="checkbox"]:not(:checked)').css({visibility:"hidden"}).attr({value:"0",checked:"checked"})});e('*[type="submit"]').attr("disabled",false).removeClass("submit")})
1
+ /* Email Encoder Bundle */
2
  jQuery(function(e){"use strict";var t=e(".eeb-form");var n=t.find("#eeb-email");var r=t.find("#eeb-display");var i;var s=function(){if(!n.val()){return}t.find("#eeb-encoded-output").val("");e.get("",{ajaxEncodeEmail:true,email:n.val(),display:r.val()||n.val(),method:t.find("#eeb-encode-method").val()},function(e){t.find("#eeb-encoded-output").val(e);t.find(".eeb-output").fadeIn()})};t.find(".eeb-output").hide();n.keyup(function(){var e=n.val();var t=r.val();if(!t||t===i){r.val(e)}i=e});t.find("#eeb-email, #eeb-display").keyup(function(){if(r.val().length>0){t.find(".eeb-example").html('<a href="mailto:'+n.val()+'">'+r.val()+"</a>").parents("tr").fadeIn()}else{t.find(".eeb-example").parents("tr").fadeOut()}t.find(".eeb-output").fadeOut();t.find("#eeb-encoded-output").val("")}).keyup();t.find("#eeb-encode-method").bind("change keyup",function(){s()});t.find("#eeb-ajax-encode").click(function(){s()})});jQuery(function(e){"use strict";var t=e("#encode_emails");e("#setting-error-settings_updated").click(function(){e(this).hide()});e("#encode_mailtos").change(function(){var n=e(this).prop("checked");t.attr("disabled",!n);if(!n){t.attr("checked",false)}t.change()}).change();t.change(function(){e(".notice-form-field-bug")[t.prop("checked")?"fadeIn":"fadeOut"]()});e(".eeb-form table").addClass("form-table");e(".eeb-help-link").click(function(t){e("#contextual-help-link").click();t.preventDefault()});e(".wrap form").submit(function(){e('*[type="checkbox"]:not(:checked)').css({visibility:"hidden"}).attr({value:"0",checked:"checked"})});e('*[type="submit"]').attr("disabled",false).removeClass("submit")})
js/src/email-encoder-bundle-admin.js CHANGED
@@ -1,59 +1,59 @@
1
- /* Email Encoder Bundle - Admin */
2
- /*global jQuery*/
3
- jQuery(function ($) {
4
- 'use strict';
5
-
6
- var $encodeEmails = $('#encode_emails');
7
-
8
- $('#setting-error-settings_updated').click(function () {
9
- $(this).hide();
10
- });
11
-
12
- // enable/disable plain emails
13
- $('#encode_mailtos')
14
- .change(function () {
15
- var checked = $(this).prop('checked');
16
-
17
- $encodeEmails.attr('disabled', !checked);
18
-
19
- if (!checked) {
20
- $encodeEmails.attr('checked', false);
21
- }
22
-
23
- // force change trigger
24
- $encodeEmails.change();
25
- })
26
- .change();
27
-
28
- // show/hide notice
29
- $encodeEmails.change(function () {
30
- $('.notice-form-field-bug')[$encodeEmails.prop('checked') ? 'fadeIn' : 'fadeOut']();
31
- });
32
-
33
- // add form-table class to Encoder Form tables
34
- $('.eeb-form table').addClass('form-table');
35
-
36
- //
37
- $('.eeb-help-link').click(function (e) {
38
- $('#contextual-help-link').click();
39
- e.preventDefault();
40
- });
41
-
42
- // Workaround for saving disabled checkboxes in options db
43
- // prepare checkboxes before submit
44
- $('.wrap form').submit(function () {
45
- // force value 0 being saved in options
46
- $('*[type="checkbox"]:not(:checked)')
47
- .css({ 'visibility': 'hidden' })
48
- .attr({
49
- 'value': '0',
50
- 'checked': 'checked'
51
- });
52
- });
53
-
54
- // enable submit buttons
55
- $('*[type="submit"]')
56
- .attr('disabled', false)
57
- .removeClass('submit'); // remove class to fix button background
58
-
59
- });
1
+ /* Email Encoder Bundle - Admin */
2
+ /*global jQuery*/
3
+ jQuery(function ($) {
4
+ 'use strict';
5
+
6
+ var $encodeEmails = $('#encode_emails');
7
+
8
+ $('#setting-error-settings_updated').click(function () {
9
+ $(this).hide();
10
+ });
11
+
12
+ // enable/disable plain emails
13
+ $('#encode_mailtos')
14
+ .change(function () {
15
+ var checked = $(this).prop('checked');
16
+
17
+ $encodeEmails.attr('disabled', !checked);
18
+
19
+ if (!checked) {
20
+ $encodeEmails.attr('checked', false);
21
+ }
22
+
23
+ // force change trigger
24
+ $encodeEmails.change();
25
+ })
26
+ .change();
27
+
28
+ // show/hide notice
29
+ $encodeEmails.change(function () {
30
+ $('.notice-form-field-bug')[$encodeEmails.prop('checked') ? 'fadeIn' : 'fadeOut']();
31
+ });
32
+
33
+ // add form-table class to Encoder Form tables
34
+ $('.eeb-form table').addClass('form-table');
35
+
36
+ //
37
+ $('.eeb-help-link').click(function (e) {
38
+ $('#contextual-help-link').click();
39
+ e.preventDefault();
40
+ });
41
+
42
+ // Workaround for saving disabled checkboxes in options db
43
+ // prepare checkboxes before submit
44
+ $('.wrap form').submit(function () {
45
+ // force value 0 being saved in options
46
+ $('*[type="checkbox"]:not(:checked)')
47
+ .css({ 'visibility': 'hidden' })
48
+ .attr({
49
+ 'value': '0',
50
+ 'checked': 'checked'
51
+ });
52
+ });
53
+
54
+ // enable submit buttons
55
+ $('*[type="submit"]')
56
+ .attr('disabled', false)
57
+ .removeClass('submit'); // remove class to fix button background
58
+
59
+ });
js/src/email-encoder-bundle.js CHANGED
@@ -1,74 +1,74 @@
1
- /* Email Encoder Bundle - Encoder Form */
2
- /*global jQuery*/
3
- jQuery(function ($) {
4
- 'use strict';
5
-
6
- var $wrap = $('.eeb-form');
7
- var $email = $wrap.find('#eeb-email');
8
- var $display = $wrap.find('#eeb-display');
9
- var prevEmail;
10
-
11
- // get encoded email ( ajax call )
12
- var getEncoded = function () {
13
- // stop when email field is empty
14
- if (!$email.val()) {
15
- return;
16
- }
17
-
18
- // empty the output field
19
- $wrap.find('#eeb-encoded-output').val('');
20
-
21
- // get the encoded email link
22
- $.get('', {
23
- ajaxEncodeEmail: true,
24
- email: $email.val(),
25
- display: $display.val() || $email.val(),
26
- method: $wrap.find('#eeb-encode-method').val()
27
- }, function (data) {
28
- $wrap.find('#eeb-encoded-output').val(data);
29
- $wrap.find('.eeb-output').fadeIn();
30
- });
31
- };
32
-
33
- // hide output
34
- $wrap.find('.eeb-output').hide();
35
-
36
- // auto-set display field
37
- $email.keyup(function () {
38
- var email = $email.val();
39
- var display = $display.val();
40
-
41
- if (!display || display === prevEmail) {
42
- $display.val(email);
43
- }
44
-
45
- prevEmail = email;
46
- });
47
-
48
- // get encoded link on these events
49
- $wrap.find('#eeb-email, #eeb-display')
50
- .keyup(function () {
51
- if ($display.val().length > 0) {
52
- // show example how it will appear on the page
53
- $wrap.find('.eeb-example')
54
- .html('<a href="mailto:' + $email.val() + '">' + $display.val() + '</a>')
55
- .parents('tr').fadeIn();
56
- } else {
57
- $wrap.find('.eeb-example').parents('tr').fadeOut();
58
- }
59
-
60
- // clear code field
61
- $wrap.find('.eeb-output').fadeOut();
62
- $wrap.find('#eeb-encoded-output').val('');
63
- })
64
- .keyup();
65
-
66
- $wrap.find('#eeb-encode-method').bind('change keyup', function () {
67
- getEncoded();
68
- });
69
-
70
- $wrap.find('#eeb-ajax-encode').click(function () {
71
- getEncoded();
72
- });
73
-
74
- });
1
+ /* Email Encoder Bundle - Encoder Form */
2
+ /*global jQuery*/
3
+ jQuery(function ($) {
4
+ 'use strict';
5
+
6
+ var $wrap = $('.eeb-form');
7
+ var $email = $wrap.find('#eeb-email');
8
+ var $display = $wrap.find('#eeb-display');
9
+ var prevEmail;
10
+
11
+ // get encoded email ( ajax call )
12
+ var getEncoded = function () {
13
+ // stop when email field is empty
14
+ if (!$email.val()) {
15
+ return;
16
+ }
17
+
18
+ // empty the output field
19
+ $wrap.find('#eeb-encoded-output').val('');
20
+
21
+ // get the encoded email link
22
+ $.get('', {
23
+ ajaxEncodeEmail: true,
24
+ email: $email.val(),
25
+ display: $display.val() || $email.val(),
26
+ method: $wrap.find('#eeb-encode-method').val()
27
+ }, function (data) {
28
+ $wrap.find('#eeb-encoded-output').val(data);
29
+ $wrap.find('.eeb-output').fadeIn();
30
+ });
31
+ };
32
+
33
+ // hide output
34
+ $wrap.find('.eeb-output').hide();
35
+
36
+ // auto-set display field
37
+ $email.keyup(function () {
38
+ var email = $email.val();
39
+ var display = $display.val();
40
+
41
+ if (!display || display === prevEmail) {
42
+ $display.val(email);
43
+ }
44
+
45
+ prevEmail = email;
46
+ });
47
+
48
+ // get encoded link on these events
49
+ $wrap.find('#eeb-email, #eeb-display')
50
+ .keyup(function () {
51
+ if ($display.val().length > 0) {
52
+ // show example how it will appear on the page
53
+ $wrap.find('.eeb-example')
54
+ .html('<a href="mailto:' + $email.val() + '">' + $display.val() + '</a>')
55
+ .parents('tr').fadeIn();
56
+ } else {
57
+ $wrap.find('.eeb-example').parents('tr').fadeOut();
58
+ }
59
+
60
+ // clear code field
61
+ $wrap.find('.eeb-output').fadeOut();
62
+ $wrap.find('#eeb-encoded-output').val('');
63
+ })
64
+ .keyup();
65
+
66
+ $wrap.find('#eeb-encode-method').bind('change keyup', function () {
67
+ getEncoded();
68
+ });
69
+
70
+ $wrap.find('#eeb-ajax-encode').click(function () {
71
+ getEncoded();
72
+ });
73
+
74
+ });
readme.txt CHANGED
@@ -1,243 +1,248 @@
1
- === Email Encoder Bundle - Protect Email Address ===
2
- Contributors: freelancephp
3
- Tags: email address, protect, antispam, mailto, spambot, secure, e-mail, email, mail, obfuscate, encode, encoder, encrypt, hide, bot, crawl, spider, robots, spam, protection, harvest, harvesting, security
4
- Requires at least: 3.4.0
5
- Tested up to: 3.8.1
6
- Stable tag: 1.1.0
7
-
8
- Encode mailto links, email addresses or any text (like phone numbers) and hide them from spambots. All mailto links in your posts, pages, comments and (text) widgets will be protected immediatly after activation.
9
-
10
- == Description ==
11
-
12
- Encode mailto links, email addresses or any text (like phone numbers) and hide them from spambots. All mailto links in your posts, pages, comments and (text) widgets will be protected immediatly after activation.
13
-
14
- = Features =
15
- * Protect mailto links
16
- * Protect plain email addresses
17
- * Protect your RSS feeds
18
- * Encode any text (like phone numbers)
19
- * Shortcodes, template functions, action and filter hooks, Encoder Form and more...
20
-
21
- = Easy to use =
22
- The plugin works out-of-the-box. All mailto links in your posts, pages, comments and (text) widgets will be encoded (by default).
23
- If you also want to encode plain email address as well, you have to check that option.
24
-
25
- = Help =
26
- * Documentation - Check the Help tab on the plugin Admin page
27
- * [FAQ](http://wordpress.org/extend/plugins/email-encoder-bundle/faq/)
28
- * [Report a problem](http://wordpress.org/support/plugin/email-encoder-bundle#postform)
29
-
30
- = Github =
31
- I published the code on [Github](https://github.com/freelancephp/Email-Encoder-Bundle) so anybody can commit code changes.
32
-
33
- = Like this plugin? =
34
- No donation needed.
35
- If you want to support, just [rate this plugin](http://wordpress.org/support/view/plugin-reviews/email-encoder-bundle).
36
- And/or place [a comment on my blog](http://www.freelancephp.net/email-encoder-php-class-wp-plugin/).
37
-
38
- == Installation ==
39
-
40
- 1. Go to `Plugins` in the Admin menu
41
- 1. Click on the button `Add new`
42
- 1. Search for `Email Encode Bundle` and click 'Install Now' or click on the `upload` link to upload `email-encode-bundle.zip`
43
- 1. Click on `Activate plugin`
44
-
45
- == Frequently Asked Questions ==
46
-
47
- = How do I encode my email address(es)? =
48
-
49
- In the posts you can use this shortcode:
50
- `[eeb_email email="myname@test.nl" display="My Email"]`
51
-
52
- By default mailto links like this will also be encoded:
53
- `<a href="mailto:myname@test.nl">My Email</a>`
54
-
55
- The default method is `JS Rot13` the following output will be created in the source code of the page:
56
- `<script type="text/javascript">/*<![CDATA[*/ML="mo@k<insc:r.y=-Ehe a\">f/lMt";MI="4CB8HC77=D0C5HJ1>H563DB@:AF=D0C5HJ190<6C0A2JA7J;6HDBBJ5JHA=DI<B?0C5HDEI<B?0C5H4GCE";OT="";for(j=0;j<MI.length;j++){OT+=ML.charAt(MI.charCodeAt(j)-48);}document.write(OT);/*]]>*/</script><noscript>*protected email*</noscript>`
57
-
58
- This code is not readable by spambots and protects your email address.
59
-
60
- = Email address in a form field is being encoded in a strange way. What to do? =
61
-
62
- An email address in a form field will not be encoded correctly.
63
- There are 2 ways to solve this problem:
64
-
65
- 1. Turn of the option "Replace plain email addresses to protected mailto links". Keep in mind that this will be the case for the whole site.
66
- 1. Add the page ID of the form to the option "Do not apply Auto-Protect on posts with ID". The page content will be skipped by the plugin.
67
-
68
- = How to use email encodig in Custom Fields? =
69
-
70
- You will have to use the template function `eeb_email()` or `eeb_content()`.
71
- For example, if your template contains:
72
- `echo get_post_meta($post->ID, 'emailaddress', true);`
73
-
74
- Then change it to:
75
- `$emailaddress = get_post_meta($post->ID, 'emailaddress', true);
76
- echo eeb_email($emailaddress, 'Mail Me');`
77
-
78
- = How to create mailto links that opens in a new window? =
79
-
80
- You could add extra params to the mailto link and add `target='_blank'` for opening them in a new window, like:
81
- `[eeb_email email="yourmail@test.nl" display="My Mail" extra_attrs="target='_blank'"]`
82
-
83
- In html this will look like:
84
- `<a href="mailto:yourmail@test.nl" target="_blank">My Mail</a>`
85
-
86
- = How can I encode content of BBPress, WP e-Commerce or other plugins? =
87
-
88
- If you use other plugins that needs to be encoded you can add a callback to the action "init_email_encoder_bundle".
89
- For Example:
90
-
91
- `add_action('eeb_ready', 'extra_encode_filters');
92
-
93
- function extra_encode_filters($filter_callback) {
94
- // add filters for BBPress
95
- add_filter('bbp_get_reply_content', $filter_callback);
96
- add_filter('bbp_get_topic_content', $filter_callback);
97
- }`
98
-
99
- = Can I use special characters (like Chinese)? =
100
- It's only possible to use special characters for the display. And only works by using the shortcode with the HTML encode method.
101
- Example:
102
- `[eeb_email method="enc_html" email="myname@myemail.nl" display="我的郵箱"]`
103
-
104
- = How to encode emails in all widgets (and not only text widgets)? =
105
-
106
- If the option 'All text widgets' is activated, only text widgets will be filtered for encoding.
107
- It's possible to filter all widgets by using the Widget Logic plugin and activate the 'widget_content' filter.
108
-
109
- [Do you have another question? Please ask me](http://www.freelancephp.net/contact/)
110
-
111
- == Screenshots ==
112
-
113
- 1. Admin Options Page
114
- 1. Check encoded email/content when logged in as admin
115
- 1. Email Encoder Form on the Site
116
-
117
- == Other Notes
118
- = Credits =
119
- * [Adam Hunter](http://blueberryware.net) for the encode method 'JavaScript Escape' which is taken from his plugin [Email Spam Protection](http://blueberryware.net/2008/09/14/email-spam-protection/)
120
- * [Tyler Akins](http://rumkin.com) for the encode method 'JavaScript ASCII Mixer'
121
- * Title icon on Admin Options Page was made by [Jack Cai](http://www.doublejdesign.co.uk/)
122
-
123
- == Changelog ==
124
-
125
- = 1.1.0 =
126
- * Added filters for changing regular expression for mailto links and email addresses
127
- * Fixed bug don't encode when loading admin panel
128
-
129
- = 1.0.2 =
130
- * Fixed bug wrong "settings" link
131
- * Fixed bug removing shortcodes RSS feed
132
-
133
- = 1.0.1 =
134
- * Fixed PHP support (same as WordPress)
135
-
136
- = 1.0.0 =
137
- * NOW ONLY SUPPORT FOR WP 3.4.0+
138
- * Fixed bug deleting setting values when unregister (will now be deleted on uninstall)
139
- * Fixed bug also possible to set protection text when RSS disabled
140
- * Fixed bug saving metaboxes settings
141
- * Added option support shortcodes in widgets
142
- * Added option removing shortcodes for RSS feed
143
- * Removed "random" method option
144
- * Changed names for action and shortcode (prefixed with eeb_), optional the old names will still be supported
145
- * Added template function for creating the encoder form
146
- * Changed class en id names of the Encoder Form
147
-
148
- = 0.80 =
149
- * Added screen settings
150
- * Registered metaboxes
151
- * Fixed bug random method
152
- * Workaround for display with special characters (like Chinese), works only with enc_html
153
-
154
- = 0.71 =
155
- * Option to make own menu item (in admin panel) for this plugin
156
- * Option for showing "successfully encoded" check
157
- * Fixed bug showing errors for calling wrong translate function
158
- * Fixed bug always showing encoded check on site (for html encode method)
159
- * Added workaround for saving disabled checkboxes in options table
160
- * Fixed bug where encoded check was also applied on output of encoding form
161
-
162
- = 0.70 =
163
- * Fixed bug with extra params
164
- * Changed texts and added help tabs on admin options page
165
- * Changed visual check for encoded mails/content by showing icon and success message
166
- * Solved that all attributes of mailto links remain when encoding
167
-
168
- = 0.60 =
169
- * Added hook "init_email_encoder_form" to add custom filters (of other plugins)
170
- * Added JavaScript code encapsulation for ASCII method
171
- * Solved reinstalling bug for setting right encoding method
172
- * Fixed bug shortcodes encoded with HTML method
173
-
174
- = 0.50 =
175
- * Added encode method for all kind of contents (template function and shortcode "encode_content")
176
- * Added extra param for additional html attributes (f.e. target="_blank")
177
- * Added option to skip certain posts from being automatically encoded
178
- * Added option custom protection text
179
- * Removed "method" folder. Not possible to add own methods anymore.
180
- * Other small changes and some refactoring
181
-
182
- = 0.42 =
183
- * Widget Logic options bug
184
-
185
- = 0.41 =
186
- * Fixed bug by improving regular expression for mailto links
187
- * Changed script attribute `language` to `type`
188
- * Script only loaded on options page (hopefully this solves the dashboard toggle problem some people are experiencing)
189
- * Added support for widget_content filter of the Logic Widget plugin
190
-
191
- = 0.40 =
192
- * Added option for setting CSS classes
193
- * Improved RSS protection
194
- * Removed Lim_Email_Encoder class (now all handled by the main class)
195
- * Enabled setting checkbox for filtering posts
196
- * Fixed PHP / WP notices
197
- * Added param for encode methods: $obj
198
-
199
- = 0.32 =
200
- * Fix IE bug
201
- * Bug plain emails
202
- * Optional "method" param for tag and template function, f.e. [encode_email email="test@domain.com" method="ascii"]
203
- * Small adjustments
204
-
205
- = 0.31 =
206
- * Fixed tiny bug (incorrect var-name $priority on line 100 of email-encoder-bundle.php)
207
-
208
- = 0.30 =
209
- * Added protection for emails in RSS feeds
210
- * Improved filtering tags [encode_email ... ]
211
- * Improved ASCII and Escape method and added noscript message
212
- * Solved an option bug (encode mailto links VS encode plain emails)
213
- * Made some cosmetical adjustments on the options page
214
- * Code refactoring
215
-
216
- = 0.22 =
217
- * First decodes entities before encoding email
218
- * Added more wp filters for encoding
219
-
220
- = 0.21 =
221
- * Changed Encoder Form: HTML markup and JavaScript
222
- * Made some minor adjustments and fixed little bugs
223
-
224
- = 0.20 =
225
- * Implemented internalization (including translation for nl_NL)
226
- * Improved user-interface of the Admin Settings Page and the Encoder Form
227
- * Added template function: encode_email_filter()
228
- * Kept and added only high-quality encoding methods
229
- * Refactored the code and changed method- and var-names within the classes
230
- * Removed 3rd param $encode_display out of the encoding methods, display should always be encoded
231
- * Added prefix 'lim_email_' to the encoding methods
232
-
233
- = 0.12 =
234
- * Nothing changed, but 0.11 had some errors because /methods directory was missing in the repository.
235
-
236
- = 0.11 =
237
- * also possible to use encode tag in widgets by activating the "filter widget" option
238
-
239
- = 0.10 =
240
- * Works with PHP4 and PHP5
241
- * Methods: default_encode, wp_antispambot, anti_email_spam, email_escape, hide_email
242
- * Use the tags: `[email_encode email=".." display=".."]`, `[email_encoder_form]`
243
- * Template function: `email_encode()`
 
 
 
 
 
1
+ === Email Encoder Bundle - Protect Email Address ===
2
+ Contributors: freelancephp
3
+ Tags: email address, protect, antispam, mailto, spambot, secure, e-mail, email, mail, obfuscate, encode, encoder, encrypt, hide, bot, crawl, spider, robots, spam, protection, harvest, harvesting, security
4
+ Requires at least: 3.4.0
5
+ Tested up to: 3.9.1
6
+ Stable tag: 1.2.0
7
+
8
+ Encode mailto links, email addresses, phone numbers and any text to hide them from (spam)bots. Mailto links will be protected automatically after activating plugin.
9
+
10
+ == Description ==
11
+
12
+ Encode mailto links, email addresses, phone numbers and any text to hide them from (spam)bots.
13
+
14
+ = Features =
15
+ * Protect mailto links and plain email addresses
16
+ * Protect phone numbers (or any text/html)
17
+ * Also protect your RSS feeds
18
+ * Use shortcodes, template functions, action and filter hooks
19
+ * Use the Encoder Form to manually create encoded scripts
20
+
21
+ = Easy to use =
22
+ After activating the plugin all mailto links will be protected automatically.
23
+ You could use shortcodes or template functions to protect plain email addresses, phone numbers or other text.
24
+
25
+ = Support =
26
+ * Documentation - When activated check the "Help"-tab on the plugin options page
27
+ * [FAQ](http://wordpress.org/extend/plugins/email-encoder-bundle/faq/)
28
+ * [Github](https://github.com/freelancephp/Email-Encoder-Bundle)
29
+
30
+ = Like this plugin? =
31
+ [Send Your Review](http://wordpress.org/support/view/plugin-reviews/email-encoder-bundle).
32
+
33
+ == Installation ==
34
+
35
+ 1. Go to `Plugins` in the Admin menu
36
+ 1. Click on the button `Add new`
37
+ 1. Search for `Email Encode Bundle` and click 'Install Now' or click on the `upload` link to upload `email-encode-bundle.zip`
38
+ 1. Click on `Activate plugin`
39
+
40
+ == Frequently Asked Questions ==
41
+
42
+ = How do I encode my email address(es)? =
43
+
44
+ In the posts you can use this shortcode:
45
+ `[eeb_email email="myname@test.nl" display="My Email"]`
46
+
47
+ But mailto links will be encoded automatically (option is on by default):
48
+ `<a href="mailto:myname@test.nl">My Email</a>`
49
+
50
+ The source of the page will now contain encoded script, like:
51
+ `<script type="text/javascript">/*<![CDATA[*/ML="mo@k<insc:r.y=-Ehe a\">f/lMt";MI="4CB8HC77=D0C5HJ1>H563DB@:AF=D0C5HJ190<6C0A2JA7J;6HDBBJ5JHA=DI<B?0C5HDEI<B?0C5H4GCE";OT="";for(j=0;j<MI.length;j++){OT+=ML.charAt(MI.charCodeAt(j)-48);}document.write(OT);/*]]>*/</script><noscript>*protected email*</noscript>`
52
+
53
+ This code is not readable by spambots and protects your email address.
54
+
55
+ = How do I encode phone nummbers or other text? =
56
+
57
+ Just use the following shortcode within your posts:
58
+ `[eeb_content]35-01235-468113[/eeb_content]`
59
+
60
+ For other parts of your site you can use the template function `eeb_content()`.
61
+
62
+ = Email address in a form field is being encoded in a strange way. What to do? =
63
+
64
+ An email address in a form field will not be encoded correctly.
65
+ There are 2 ways to solve this problem:
66
+
67
+ 1. Turn of the option "Replace plain email addresses to protected mailto links". Keep in mind that this will be the case for the whole site.
68
+ 1. Add the page ID of the form to the option "Do not apply Auto-Protect on posts with ID". The page content will be skipped by the plugin.
69
+
70
+ = How to use email encodig in Custom Fields? =
71
+
72
+ You will have to use the template function `eeb_email()` or `eeb_content()`.
73
+ For example, if your template contains:
74
+ `echo get_post_meta($post->ID, 'emailaddress', true);`
75
+
76
+ Then change it to:
77
+ `$emailaddress = get_post_meta($post->ID, 'emailaddress', true);
78
+ echo eeb_email($emailaddress, 'Mail Me');`
79
+
80
+ = How to create mailto links that opens in a new window? =
81
+
82
+ You could add extra params to the mailto link and add `target='_blank'` for opening them in a new window, like:
83
+ `[eeb_email email="yourmail@test.nl" display="My Mail" extra_attrs="target='_blank'"]`
84
+
85
+ In html this will look like:
86
+ `<a href="mailto:yourmail@test.nl" target="_blank">My Mail</a>`
87
+
88
+ = How can I encode content of BBPress, WP e-Commerce or other plugins? =
89
+
90
+ If you use other plugins that needs to be encoded you can add a callback to the action "init_email_encoder_bundle".
91
+ For Example:
92
+
93
+ `add_action('eeb_ready', 'extra_encode_filters');
94
+
95
+ function extra_encode_filters($filter_callback) {
96
+ // add filters for BBPress
97
+ add_filter('bbp_get_reply_content', $filter_callback);
98
+ add_filter('bbp_get_topic_content', $filter_callback);
99
+ }`
100
+
101
+ = Can I use special characters (like Chinese)? =
102
+ It's only possible to use special characters for the display. And only works by using the shortcode with the HTML encode method.
103
+ Example:
104
+ `[eeb_email method="enc_html" email="myname@myemail.nl" display="我的郵箱"]`
105
+
106
+ = How to encode emails in all widgets (and not only text widgets)? =
107
+
108
+ If the option 'All text widgets' is activated, only text widgets will be filtered for encoding.
109
+ It's possible to filter all widgets by using the Widget Logic plugin and activate the 'widget_content' filter.
110
+
111
+ [Do you have another question? Please ask me](http://www.freelancephp.net/contact/)
112
+
113
+ == Screenshots ==
114
+
115
+ 1. Admin Options Page
116
+ 1. Check encoded email/content when logged in as admin
117
+ 1. Email Encoder Form on the Site
118
+
119
+ == Other Notes
120
+ = Credits =
121
+ * [Adam Hunter](http://blueberryware.net) for the encode method 'JavaScript Escape' which is taken from his plugin [Email Spam Protection](http://blueberryware.net/2008/09/14/email-spam-protection/)
122
+ * [Tyler Akins](http://rumkin.com) for the encode method 'JavaScript ASCII Mixer'
123
+ * Title icon on Admin Options Page was made by [Jack Cai](http://www.doublejdesign.co.uk/)
124
+
125
+ == Changelog ==
126
+
127
+ = 1.2.0 =
128
+ * Added filter for Encoder Form content (eeb_form_content)
129
+
130
+ = 1.1.0 =
131
+ * Added filters for changing regular expression for mailto links and email addresses
132
+ * Fixed bug don't encode when loading admin panel
133
+
134
+ = 1.0.2 =
135
+ * Fixed bug wrong "settings" link
136
+ * Fixed bug removing shortcodes RSS feed
137
+
138
+ = 1.0.1 =
139
+ * Fixed PHP support (same as WordPress)
140
+
141
+ = 1.0.0 =
142
+ * NOW ONLY SUPPORT FOR WP 3.4.0+
143
+ * Fixed bug deleting setting values when unregister (will now be deleted on uninstall)
144
+ * Fixed bug also possible to set protection text when RSS disabled
145
+ * Fixed bug saving metaboxes settings
146
+ * Added option support shortcodes in widgets
147
+ * Added option removing shortcodes for RSS feed
148
+ * Removed "random" method option
149
+ * Changed names for action and shortcode (prefixed with eeb_), optional the old names will still be supported
150
+ * Added template function for creating the encoder form
151
+ * Changed class en id names of the Encoder Form
152
+
153
+ = 0.80 =
154
+ * Added screen settings
155
+ * Registered metaboxes
156
+ * Fixed bug random method
157
+ * Workaround for display with special characters (like Chinese), works only with enc_html
158
+
159
+ = 0.71 =
160
+ * Option to make own menu item (in admin panel) for this plugin
161
+ * Option for showing "successfully encoded" check
162
+ * Fixed bug showing errors for calling wrong translate function
163
+ * Fixed bug always showing encoded check on site (for html encode method)
164
+ * Added workaround for saving disabled checkboxes in options table
165
+ * Fixed bug where encoded check was also applied on output of encoding form
166
+
167
+ = 0.70 =
168
+ * Fixed bug with extra params
169
+ * Changed texts and added help tabs on admin options page
170
+ * Changed visual check for encoded mails/content by showing icon and success message
171
+ * Solved that all attributes of mailto links remain when encoding
172
+
173
+ = 0.60 =
174
+ * Added hook "init_email_encoder_form" to add custom filters (of other plugins)
175
+ * Added JavaScript code encapsulation for ASCII method
176
+ * Solved reinstalling bug for setting right encoding method
177
+ * Fixed bug shortcodes encoded with HTML method
178
+
179
+ = 0.50 =
180
+ * Added encode method for all kind of contents (template function and shortcode "encode_content")
181
+ * Added extra param for additional html attributes (f.e. target="_blank")
182
+ * Added option to skip certain posts from being automatically encoded
183
+ * Added option custom protection text
184
+ * Removed "method" folder. Not possible to add own methods anymore.
185
+ * Other small changes and some refactoring
186
+
187
+ = 0.42 =
188
+ * Widget Logic options bug
189
+
190
+ = 0.41 =
191
+ * Fixed bug by improving regular expression for mailto links
192
+ * Changed script attribute `language` to `type`
193
+ * Script only loaded on options page (hopefully this solves the dashboard toggle problem some people are experiencing)
194
+ * Added support for widget_content filter of the Logic Widget plugin
195
+
196
+ = 0.40 =
197
+ * Added option for setting CSS classes
198
+ * Improved RSS protection
199
+ * Removed Lim_Email_Encoder class (now all handled by the main class)
200
+ * Enabled setting checkbox for filtering posts
201
+ * Fixed PHP / WP notices
202
+ * Added param for encode methods: $obj
203
+
204
+ = 0.32 =
205
+ * Fix IE bug
206
+ * Bug plain emails
207
+ * Optional "method" param for tag and template function, f.e. [encode_email email="test@domain.com" method="ascii"]
208
+ * Small adjustments
209
+
210
+ = 0.31 =
211
+ * Fixed tiny bug (incorrect var-name $priority on line 100 of email-encoder-bundle.php)
212
+
213
+ = 0.30 =
214
+ * Added protection for emails in RSS feeds
215
+ * Improved filtering tags [encode_email ... ]
216
+ * Improved ASCII and Escape method and added noscript message
217
+ * Solved an option bug (encode mailto links VS encode plain emails)
218
+ * Made some cosmetical adjustments on the options page
219
+ * Code refactoring
220
+
221
+ = 0.22 =
222
+ * First decodes entities before encoding email
223
+ * Added more wp filters for encoding
224
+
225
+ = 0.21 =
226
+ * Changed Encoder Form: HTML markup and JavaScript
227
+ * Made some minor adjustments and fixed little bugs
228
+
229
+ = 0.20 =
230
+ * Implemented internalization (including translation for nl_NL)
231
+ * Improved user-interface of the Admin Settings Page and the Encoder Form
232
+ * Added template function: encode_email_filter()
233
+ * Kept and added only high-quality encoding methods
234
+ * Refactored the code and changed method- and var-names within the classes
235
+ * Removed 3rd param $encode_display out of the encoding methods, display should always be encoded
236
+ * Added prefix 'lim_email_' to the encoding methods
237
+
238
+ = 0.12 =
239
+ * Nothing changed, but 0.11 had some errors because /methods directory was missing in the repository.
240
+
241
+ = 0.11 =
242
+ * also possible to use encode tag in widgets by activating the "filter widget" option
243
+
244
+ = 0.10 =
245
+ * Works with PHP4 and PHP5
246
+ * Methods: default_encode, wp_antispambot, anti_email_spam, email_escape, hide_email
247
+ * Use the tags: `[email_encode email=".." display=".."]`, `[email_encoder_form]`
248
+ * Template function: `email_encode()`