Version Description
- Added filters for changing regular expression for mailto links and email addresses
- Fixed bug don't encode when loading admin panel
Download this release
Release Info
Developer | freelancephp |
Plugin | Email Encoder Bundle – Protect Email Address |
Version | 1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.1.0
- email-encoder-bundle.php +24 -34
- images/quick-start.png +0 -0
- includes/class-eeb-admin.php +199 -218
- includes/class-eeb-site.php +75 -30
- includes/deprecated.php +10 -10
- includes/template-functions.php +56 -53
- js/src/email-encoder-bundle-admin.js +0 -1
- readme.txt +31 -26
- screenshot-1.png +0 -0
email-encoder-bundle.php
CHANGED
@@ -4,51 +4,33 @@ 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.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 |
-
//
|
15 |
-
if (!defined('
|
16 |
-
|
17 |
-
}
|
18 |
-
|
19 |
-
|
20 |
-
if (!defined('
|
21 |
-
define('EMAIL_ENCODER_BUNDLE_VERSION', '1.0.2');
|
22 |
-
}
|
23 |
-
|
24 |
-
// plugin key
|
25 |
-
if (!defined('EMAIL_ENCODER_BUNDLE_KEY')) {
|
26 |
-
define('EMAIL_ENCODER_BUNDLE_KEY', 'WP_Email_Encoder_Bundle');
|
27 |
-
}
|
28 |
-
|
29 |
-
// plugin domain for translation
|
30 |
-
if (!defined('EMAIL_ENCODER_BUNDLE_DOMAIN')) {
|
31 |
-
define('EMAIL_ENCODER_BUNDLE_DOMAIN', 'email-encoder-bundle');
|
32 |
-
}
|
33 |
|
34 |
// check plugin compatibility
|
35 |
if (isset($wp_version)
|
36 |
-
|
37 |
-
|
38 |
|
39 |
// include classes
|
40 |
require_once('includes/class-eeb-admin.php');
|
41 |
require_once('includes/class-eeb-site.php');
|
42 |
require_once('includes/template-functions.php');
|
43 |
|
44 |
-
// for testing purposes
|
45 |
-
if (file_exists(dirname(__FILE__) . '/../../wp-plugin-tester/tests/test-email-encoder-bundle.php')) {
|
46 |
-
require_once('/../../wp-plugin-tester/wp-plugin-tester.php');
|
47 |
-
require_once('/../../wp-plugin-tester/tests/test-email-encoder-bundle.php');
|
48 |
-
}
|
49 |
-
|
50 |
// create instance
|
51 |
-
$
|
52 |
|
53 |
// handle AJAX request
|
54 |
if (!empty($_GET['ajaxEncodeEmail'])):
|
@@ -57,19 +39,27 @@ if (isset($wp_version)
|
|
57 |
$email = $_GET['email'];
|
58 |
$display = (empty($_GET['display'])) ? $email : $_GET['display'];
|
59 |
|
60 |
-
echo $
|
61 |
exit;
|
62 |
endif;
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
} else {
|
65 |
|
66 |
// set error message
|
67 |
-
if (function_exists('eeb_error_notice')):
|
68 |
function eeb_error_notice() {
|
|
|
|
|
69 |
echo '<div class="error">'
|
70 |
-
. __('<p>Warning - The plugin <strong
|
71 |
-
|
72 |
-
|
73 |
. '</div>';
|
74 |
}
|
75 |
|
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'])):
|
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 |
|
images/quick-start.png
ADDED
Binary file
|
includes/class-eeb-admin.php
CHANGED
@@ -3,34 +3,22 @@
|
|
3 |
/**
|
4 |
* Class Eeb_Admin
|
5 |
*
|
6 |
-
*
|
|
|
|
|
7 |
*
|
8 |
* @package Email_Encoder_Bundle
|
9 |
* @category WordPress Plugins
|
10 |
*/
|
11 |
if (!class_exists('Eeb_Admin')):
|
12 |
|
13 |
-
class Eeb_Admin {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* @var string
|
17 |
-
*/
|
18 |
-
private $options_name = NULL;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* @var string
|
22 |
-
*/
|
23 |
-
private $page_hook = NULL;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @var boolean
|
27 |
-
*/
|
28 |
-
protected $is_admin_user = FALSE;
|
29 |
|
30 |
/**
|
31 |
* @var array
|
32 |
*/
|
33 |
private $default_options = array(
|
|
|
34 |
'method' => 'enc_ascii',
|
35 |
'encode_mailtos' => 1,
|
36 |
'encode_emails' => 0,
|
@@ -71,12 +59,17 @@ class Eeb_Admin {
|
|
71 |
*/
|
72 |
private $methods = array();
|
73 |
|
|
|
|
|
|
|
|
|
|
|
74 |
/**
|
75 |
* Constructor
|
76 |
*/
|
77 |
-
|
78 |
// load text domain for translations
|
79 |
-
load_plugin_textdomain(
|
80 |
|
81 |
// set methods
|
82 |
$this->methods = array(
|
@@ -94,9 +87,6 @@ class Eeb_Admin {
|
|
94 |
),
|
95 |
);
|
96 |
|
97 |
-
// set option name
|
98 |
-
$this->options_name = EMAIL_ENCODER_BUNDLE_KEY . '_options';
|
99 |
-
|
100 |
// set option values
|
101 |
$this->set_options();
|
102 |
|
@@ -113,46 +103,56 @@ class Eeb_Admin {
|
|
113 |
add_action('wp', array($this, 'wp'));
|
114 |
add_action('admin_init', array($this, 'admin_init'));
|
115 |
add_action('admin_menu', array($this, 'admin_menu'));
|
116 |
-
|
117 |
|
118 |
/**
|
119 |
* Set options from save values or defaults
|
120 |
*/
|
121 |
private function set_options() {
|
122 |
-
$
|
123 |
-
$upgrade = FALSE;
|
124 |
|
125 |
// first set defaults
|
126 |
$this->options = $this->default_options;
|
127 |
|
128 |
// get saved options
|
129 |
-
$saved_options = get_option(
|
130 |
|
131 |
// backwards compatible (old values)
|
132 |
if (empty($saved_options)) {
|
133 |
$saved_options = get_option(EMAIL_ENCODER_BUNDLE_KEY . 'options');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
|
136 |
// set all options
|
137 |
if (!empty($saved_options)) {
|
138 |
-
$upgrade =
|
139 |
|
140 |
foreach ($saved_options AS $key => $value) {
|
141 |
$this->options[$key] = $value;
|
142 |
}
|
143 |
}
|
144 |
|
145 |
-
if ($
|
146 |
-
if (empty($
|
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(
|
153 |
} else {
|
154 |
// first time
|
155 |
-
|
156 |
}
|
157 |
} else {
|
158 |
// upgrading from version >= 1.0.0
|
@@ -160,7 +160,7 @@ class Eeb_Admin {
|
|
160 |
}
|
161 |
|
162 |
// update version
|
163 |
-
update_option(
|
164 |
}
|
165 |
|
166 |
// set encode method
|
@@ -168,7 +168,7 @@ class Eeb_Admin {
|
|
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)
|
172 |
$this->options['widget_logic_filter'] = ($widget_logic_opts['widget_logic-options-filter'] == 'checked') ? 1 : 0;
|
173 |
}
|
174 |
}
|
@@ -192,17 +192,9 @@ class Eeb_Admin {
|
|
192 |
/**
|
193 |
* Callback Uninstall
|
194 |
*/
|
195 |
-
public
|
196 |
-
delete_option(
|
197 |
-
unregister_setting(EMAIL_ENCODER_BUNDLE_KEY,
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* Callback wp action
|
202 |
-
*/
|
203 |
-
public function wp() {
|
204 |
-
// check admin
|
205 |
-
$this->is_admin_user = current_user_can('manage_options');
|
206 |
}
|
207 |
|
208 |
/**
|
@@ -210,10 +202,9 @@ class Eeb_Admin {
|
|
210 |
*/
|
211 |
public function admin_init() {
|
212 |
// register settings
|
213 |
-
register_setting(EMAIL_ENCODER_BUNDLE_KEY,
|
214 |
|
215 |
-
// actions
|
216 |
-
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
217 |
add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2);
|
218 |
}
|
219 |
|
@@ -226,53 +217,31 @@ class Eeb_Admin {
|
|
226 |
public function plugin_action_links($links, $file) {
|
227 |
if ($file == plugin_basename(EMAIL_ENCODER_BUNDLE_FILE)) {
|
228 |
$page = ($this->options['own_admin_menu']) ? 'admin.php' : 'options-general.php';
|
229 |
-
$settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/' . $page . '?page=
|
230 |
array_unshift($links, $settings_link);
|
231 |
}
|
232 |
|
233 |
return $links;
|
234 |
}
|
235 |
|
236 |
-
/**
|
237 |
-
* Callback admin_enqueue_scripts
|
238 |
-
* @param string $hook_suffix
|
239 |
-
*/
|
240 |
-
public function admin_enqueue_scripts($hook_suffix) {
|
241 |
-
global $wp_version;
|
242 |
-
|
243 |
-
if ($hook_suffix == $this->page_hook || $hook_suffix == 'toplevel_page_email-encoder-bundle/email-encoder-bundle') {
|
244 |
-
// set dashboard postbox
|
245 |
-
wp_enqueue_script('dashboard');
|
246 |
-
|
247 |
-
// add script for ajax encoder
|
248 |
-
// wp_enqueue_script('email_encoder', plugins_url('js/src/email-encoder-bundle.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
|
249 |
-
// 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);
|
250 |
-
wp_enqueue_script('email_encoder', plugins_url('js/email-encoder-bundle.min.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
|
251 |
-
}
|
252 |
-
}
|
253 |
-
|
254 |
/**
|
255 |
* Callback admin_menu
|
256 |
*/
|
257 |
public function admin_menu() {
|
258 |
-
if ($this->is_admin_user) {
|
259 |
-
return;
|
260 |
-
}
|
261 |
-
|
262 |
// add page and menu item
|
263 |
if ($this->options['own_admin_menu']) {
|
264 |
// create main menu item
|
265 |
-
$
|
266 |
-
'manage_options',
|
267 |
plugins_url('images/icon-email-encoder-bundle-16.png', EMAIL_ENCODER_BUNDLE_FILE));
|
268 |
} else {
|
269 |
// create submenu item under "Settings"
|
270 |
-
$
|
271 |
-
'manage_options',
|
272 |
}
|
273 |
|
274 |
// load plugin page
|
275 |
-
add_action('load-' . $
|
276 |
}
|
277 |
|
278 |
/* -------------------------------------------------------------------------
|
@@ -283,6 +252,14 @@ class Eeb_Admin {
|
|
283 |
* Load admin options page
|
284 |
*/
|
285 |
public function load_options_page() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
// add help tabs
|
287 |
$this->add_help_tabs();
|
288 |
|
@@ -295,12 +272,13 @@ class Eeb_Admin {
|
|
295 |
}
|
296 |
|
297 |
// add meta boxes
|
298 |
-
add_meta_box('
|
299 |
-
add_meta_box('
|
300 |
-
add_meta_box('
|
301 |
-
add_meta_box('
|
302 |
-
add_meta_box('
|
303 |
-
add_meta_box('
|
|
|
304 |
}
|
305 |
|
306 |
/**
|
@@ -319,12 +297,16 @@ class Eeb_Admin {
|
|
319 |
</div>
|
320 |
<?php endif; ?>
|
321 |
|
|
|
|
|
|
|
|
|
322 |
<form method="post" action="options.php">
|
323 |
<?php settings_fields(EMAIL_ENCODER_BUNDLE_KEY); ?>
|
324 |
|
325 |
<input type="hidden" name="<?php echo EMAIL_ENCODER_BUNDLE_KEY ?>_nonce" value="<?php echo wp_create_nonce(EMAIL_ENCODER_BUNDLE_KEY) ?>" />
|
326 |
-
<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce',
|
327 |
-
<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce',
|
328 |
|
329 |
<div id="poststuff">
|
330 |
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
|
@@ -354,32 +336,19 @@ class Eeb_Admin {
|
|
354 |
$key = $meta_box['args'][0];
|
355 |
$options = $this->options;
|
356 |
|
357 |
-
if ($key === '
|
358 |
?>
|
359 |
<?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php')): ?>
|
360 |
<p class="description"><?php _e('Warning: "WP Mailto Links"-plugin is also activated, which could cause conflicts.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></p>
|
361 |
<?php endif; ?>
|
362 |
<fieldset class="options">
|
363 |
<table class="form-table">
|
364 |
-
<tr>
|
365 |
-
<th><?php _e('Choose protection method', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
366 |
-
<td>
|
367 |
-
<?php foreach ($this->methods AS $method => $info): ?>
|
368 |
-
<label>
|
369 |
-
<input type="radio" name="<?php echo $this->options_name ?>[method]" class="protection-method" value="<?php echo $method ?>" <?php if ($this->method == $method) echo 'checked="checked"' ?> />
|
370 |
-
<span><?php echo $info['name'] ?></span>
|
371 |
-
- <span class="description"><?php echo $info['description'] ?></span>
|
372 |
-
</label>
|
373 |
-
<br/>
|
374 |
-
<?php endforeach; ?>
|
375 |
-
</td>
|
376 |
-
</tr>
|
377 |
<tr>
|
378 |
<th><?php _e('Choose what to protect', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
379 |
<td>
|
380 |
-
<label><input type="checkbox" id="encode_mailtos" name="<?php echo
|
381 |
<span><?php _e('Protect mailto links, like f.e. <code><a href="info@myemail.com">My Email</a></code>', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
382 |
-
<br/><label><input type="checkbox" id="encode_emails" name="<?php echo
|
383 |
<span><?php _e('Replace plain email addresses to protected mailto links.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
384 |
<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>
|
385 |
</label>
|
@@ -389,38 +358,20 @@ class Eeb_Admin {
|
|
389 |
<tr>
|
390 |
<th><?php _e('Apply on...', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
391 |
<td>
|
392 |
-
<label><input type="checkbox" name="<?php echo
|
393 |
-
<span><?php _e('All posts', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
394 |
</label>
|
395 |
-
<br/><label><input type="checkbox" id="<?php echo
|
396 |
<span><?php _e('All comments', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
|
397 |
-
<br/><label><input type="checkbox" id="<?php echo
|
398 |
<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>
|
399 |
</td>
|
400 |
</tr>
|
401 |
-
<tr>
|
402 |
-
<th><?php _e('Set <code><noscript></code> text', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
403 |
-
<td><label><input type="text" id="protection_text" class="regular-text" name="<?php echo $this->options_name ?>[protection_text]" value="<?php echo $options['protection_text']; ?>" />
|
404 |
-
<br/><span class="description"><?php _e('Used for the <code><noscript></code> fallback for JavaScrip methods.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
405 |
-
</label>
|
406 |
-
</td>
|
407 |
-
</tr>
|
408 |
<tr>
|
409 |
<th><?php _e('Add class to protected mailto links', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
410 |
-
<td><label><input type="text" id="<?php echo
|
411 |
<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>
|
412 |
</tr>
|
413 |
-
<tr>
|
414 |
-
<th><?php _e('Exclude posts', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
415 |
-
<td>
|
416 |
-
<label>
|
417 |
-
<span><?php _e('Do <strong>not</strong> apply protection on posts or pages with the folllowing ID:', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
418 |
-
<br/><input type="text" id="<?php echo $this->options_name ?>[skip_posts]" class="regular-text" name="<?php echo $this->options_name ?>[skip_posts]" value="<?php echo $options['skip_posts']; ?>" />
|
419 |
-
<br/><span class="description"><?php _e('Seperate Id\'s by comma, f.e.: 2, 7, 13, 32.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
420 |
-
<br/><span class="description"><?php _e('Notice: shortcodes still work on these posts.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
421 |
-
</label>
|
422 |
-
</td>
|
423 |
-
</tr>
|
424 |
</table>
|
425 |
</fieldset>
|
426 |
|
@@ -430,41 +381,76 @@ class Eeb_Admin {
|
|
430 |
<br class="clear" />
|
431 |
|
432 |
<?php
|
433 |
-
} else if ($key === '
|
434 |
?>
|
435 |
<fieldset class="options">
|
436 |
-
<h4><?php _e('Protect RSS feed', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></h4>
|
437 |
-
|
438 |
<table class="form-table">
|
439 |
<tr>
|
440 |
<th><?php _e('Protect emails in RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
441 |
-
<td><label><input type="checkbox" id="filter_rss" name="<?php echo
|
442 |
<span><?php _e('Replace emails in RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
|
443 |
</td>
|
444 |
</tr>
|
445 |
<tr>
|
446 |
<th><?php _e('Remove shortcodes from RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
447 |
-
<td><label><input type="checkbox" id="remove_shortcodes_rss" name="<?php echo
|
448 |
<span><?php _e('Remove all shortcodes from the RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
|
449 |
</td>
|
450 |
</tr>
|
451 |
<tr>
|
452 |
<th><?php _e('Set protection text in RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
453 |
-
<td><label><input type="text" id="protection_text" class="regular-text" name="<?php echo
|
454 |
<br/><span class="description"><?php _e('Used as replacement for email addresses in RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
455 |
</label>
|
456 |
</td>
|
457 |
</tr>
|
458 |
</table>
|
|
|
459 |
|
460 |
-
|
461 |
-
|
462 |
-
|
|
|
|
|
|
|
|
|
|
|
463 |
<table class="form-table">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
464 |
<tr>
|
465 |
<th><?php _e('Use shortcodes in widgets', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
466 |
<td>
|
467 |
-
<label><input type="checkbox" name="<?php echo
|
468 |
<span><?php _e('Also use shortcodes in widgets.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
469 |
<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>
|
470 |
</label>
|
@@ -472,7 +458,7 @@ class Eeb_Admin {
|
|
472 |
</tr>
|
473 |
<tr>
|
474 |
<th><?php _e('Use deprecated names', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
475 |
-
<td><label><input type="checkbox" id="<?php echo
|
476 |
<span><?php _e('Keep supporting the old names for action, shortcodes and template functions.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
477 |
<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>
|
478 |
</tr>
|
@@ -487,25 +473,18 @@ class Eeb_Admin {
|
|
487 |
} else if ($key === 'admin_settings') {
|
488 |
?>
|
489 |
<fieldset class="options">
|
490 |
-
<h4><?php _e('Testing', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></h4>
|
491 |
-
|
492 |
<table class="form-table">
|
493 |
<tr>
|
494 |
<th><?php _e('Check "succesfully encoded"', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
495 |
-
<td><label><input type="checkbox" id="<?php echo
|
496 |
<span><?php _e('Show "successfully encoded" text for all encoded content, only when logged in as admin user.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
497 |
<br/><span class="description"><?php _e('This way you can check if emails are really encoded on your site.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
498 |
</label>
|
499 |
</td>
|
500 |
</tr>
|
501 |
-
</table>
|
502 |
-
|
503 |
-
<h4><?php _e('Menu', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></h4>
|
504 |
-
|
505 |
-
<table class="form-table">
|
506 |
<tr>
|
507 |
<th><?php _e('Choose admin menu position', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
508 |
-
<td><label><input type="checkbox" id="<?php echo
|
509 |
<span><?php _e('Show as main menu item.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
510 |
<br /><span class="description">When disabled this page will be available under "General settings".</span>
|
511 |
</label>
|
@@ -524,8 +503,6 @@ class Eeb_Admin {
|
|
524 |
?>
|
525 |
<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>
|
526 |
|
527 |
-
<h4><?php _e('Encoder Form', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></h4>
|
528 |
-
|
529 |
<hr style="border:1px solid #FFF; border-top:1px solid #EEE;" />
|
530 |
|
531 |
<?php echo $this->get_encoder_form(); ?>
|
@@ -534,13 +511,11 @@ class Eeb_Admin {
|
|
534 |
|
535 |
<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>
|
536 |
|
537 |
-
<h4><?php _e('Settings') ?></h4>
|
538 |
-
|
539 |
<fieldset class="options">
|
540 |
<table class="form-table">
|
541 |
<tr>
|
542 |
<th><?php _e('Show "powered by"', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
543 |
-
<td><label><input type="checkbox" id="<?php echo
|
544 |
<span><?php _e('Show the "powered by"-link on bottom of the encoder form', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
545 |
</label>
|
546 |
</td>
|
@@ -611,9 +586,9 @@ class Eeb_Admin {
|
|
611 |
$screen->set_help_sidebar($this->get_help_text('sidebar'));
|
612 |
|
613 |
$screen->add_help_tab(array(
|
614 |
-
'id' => '
|
615 |
-
'title' => __('
|
616 |
-
'content' => $this->get_help_text('
|
617 |
));
|
618 |
$screen->add_help_tab(array(
|
619 |
'id' => 'shortcodes',
|
@@ -622,13 +597,18 @@ class Eeb_Admin {
|
|
622 |
));
|
623 |
$screen->add_help_tab(array(
|
624 |
'id' => 'templatefunctions',
|
625 |
-
'title' => __('Template
|
626 |
'content' => $this->get_help_text('templatefunctions'),
|
627 |
));
|
628 |
$screen->add_help_tab(array(
|
629 |
-
'id' => '
|
630 |
-
'title' => __('Action
|
631 |
-
'content' => $this->get_help_text('
|
|
|
|
|
|
|
|
|
|
|
632 |
));
|
633 |
$screen->add_help_tab(array(
|
634 |
'id' => 'faq',
|
@@ -643,28 +623,16 @@ class Eeb_Admin {
|
|
643 |
* @return string
|
644 |
*/
|
645 |
private function get_help_text($key) {
|
646 |
-
if ($key === '
|
647 |
$plugin_title = get_admin_page_title();
|
648 |
$icon_url = plugins_url('images/icon-email-encoder-bundle.png', EMAIL_ENCODER_BUNDLE_FILE);
|
|
|
649 |
$version = EMAIL_ENCODER_BUNDLE_VERSION;
|
650 |
|
651 |
$content = sprintf(__('<h3><img src="%s" width="16" height="16" /> %s - version %s</h3>'
|
652 |
-
. '<p>
|
653 |
-
. '<
|
654 |
-
|
655 |
-
. '<li>Protect mailto links and plain email addresses</li>'
|
656 |
-
. '<li>Automatically or with shortcodes</li>'
|
657 |
-
. '<li>Scan posts, widgets and comments</li>'
|
658 |
-
. '<li>Also protect RSS feeds</li>'
|
659 |
-
. '</ul>'
|
660 |
-
. '<h4>Some extra features</h4>'
|
661 |
-
. '<ul>'
|
662 |
-
. '<li>Template functions</li>'
|
663 |
-
. '<li>Encode all kind of text</li>'
|
664 |
-
. '<li>Manually create protected links with the Encoder Form</li>'
|
665 |
-
. '<li>And more...</li>'
|
666 |
-
. '</ul>'
|
667 |
-
, EMAIL_ENCODER_BUNDLE_DOMAIN), $icon_url, $plugin_title, $version);
|
668 |
} else if ($key === 'shortcodes') {
|
669 |
$content = __('<h3>Shortcodes</h3>'
|
670 |
. '<p>You can use these shortcodes within your post or page.</p>'
|
@@ -687,55 +655,66 @@ class Eeb_Admin {
|
|
687 |
. '<p><code>[eeb_form]</code></p>'
|
688 |
, EMAIL_ENCODER_BUNDLE_DOMAIN);
|
689 |
} else if ($key === 'templatefunctions') {
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
<
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
<p>
|
707 |
-
<
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
<
|
715 |
-
<
|
716 |
-
<
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
<
|
725 |
-
<pre><code><?php
|
726 |
-
if (function_exists('eeb_form')) {
|
727 |
-
echo eeb_form();
|
728 |
-
}
|
729 |
-
?></code></pre>
|
730 |
-
TEMPLATEFUNCTIONS;
|
731 |
-
} else if ($key === 'hooks') {
|
732 |
-
$content = __('<h3>Hooks</h3>'
|
733 |
. '<h4>eeb_ready</h4>'
|
734 |
. '<p>Add extra code on initializing this plugin, like extra filters for encoding.</p>'
|
735 |
. '<pre><code><?php' . "\n"
|
736 |
. 'add_action(\'eeb_ready\', \'extra_encode_filters\');' . "\n\n"
|
737 |
-
. 'function extra_encode_filters(
|
738 |
-
. ' add_filter(\'some_filter\', array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
739 |
. '}' . "\n"
|
740 |
. '?></code></pre>'
|
741 |
, EMAIL_ENCODER_BUNDLE_DOMAIN);
|
@@ -743,16 +722,18 @@ TEMPLATEFUNCTIONS;
|
|
743 |
$content = __('<h3>FAQ</h3>'
|
744 |
. '<p>Please check the <a href="http://wordpress.org/extend/plugins/email-encoder-bundle/faq/" target="_blank">FAQ on the Plugin site</a>.'
|
745 |
, EMAIL_ENCODER_BUNDLE_DOMAIN);
|
746 |
-
|
747 |
$content = __('<h4>About the author</h4>'
|
748 |
. '<ul>'
|
749 |
. '<li><a href="http://www.freelancephp.net/" target="_blank">FreelancePHP.net</a></li>'
|
750 |
. '<li><a href="http://www.freelancephp.net/contact/" target="_blank">Contact</a></li>'
|
751 |
. '</ul>'
|
752 |
, EMAIL_ENCODER_BUNDLE_DOMAIN);
|
|
|
|
|
753 |
}
|
754 |
|
755 |
-
return
|
756 |
}
|
757 |
|
758 |
/* -------------------------------------------------------------------------
|
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,
|
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(
|
87 |
),
|
88 |
);
|
89 |
|
|
|
|
|
|
|
90 |
// set option values
|
91 |
$this->set_options();
|
92 |
|
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
|
160 |
}
|
161 |
|
162 |
// update version
|
163 |
+
update_option(EMAIL_ENCODER_BUNDLE_OPTIONS_NAME, $this->options);
|
164 |
}
|
165 |
|
166 |
// set encode method
|
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 |
}
|
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 |
/**
|
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 |
|
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 |
/* -------------------------------------------------------------------------
|
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 |
|
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 |
/**
|
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'; ?>">
|
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><a href="info@myemail.com">My Email</a></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>
|
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 |
|
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><noscript></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><noscript></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>
|
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>
|
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>
|
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(); ?>
|
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>
|
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',
|
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',
|
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>'
|
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><?php' . "\n"
|
662 |
+
. 'if (function_exists(\'eeb_email\')) {' . "\n"
|
663 |
+
. ' echo eeb_email(\'info@somedomain.com\');' . "\n"
|
664 |
+
. '}' . "\n"
|
665 |
+
. '?></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><?php' . "\n"
|
670 |
+
. 'if (function_exists(\'eeb_content\')) {' . "\n"
|
671 |
+
. ' echo eeb_content(\'Encode this text\');' . "\n"
|
672 |
+
. '}' . "\n"
|
673 |
+
. '?></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><?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 |
+
. '?></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><?php' . "\n"
|
686 |
+
. 'if (function_exists(\'eeb_form\')) {' . "\n"
|
687 |
+
. ' echo eeb_form();' . "\n"
|
688 |
+
. '}' . "\n"
|
689 |
+
. '?></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><?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 |
+
. '?></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><?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 |
+
. '?></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><?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 |
. '?></code></pre>'
|
720 |
, EMAIL_ENCODER_BUNDLE_DOMAIN);
|
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 |
/* -------------------------------------------------------------------------
|
includes/class-eeb-site.php
CHANGED
@@ -1,23 +1,34 @@
|
|
1 |
<?php defined('ABSPATH') OR die('No direct access.');
|
2 |
|
3 |
/**
|
4 |
-
* Class
|
|
|
|
|
5 |
*
|
6 |
* @extends Eeb_Admin
|
7 |
-
* @
|
8 |
*
|
9 |
* @package Email_Encoder_Bundle
|
10 |
* @category WordPress Plugins
|
11 |
*/
|
12 |
-
if (!class_exists('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
|
|
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
*
|
18 |
-
* @var array
|
19 |
*/
|
20 |
-
|
21 |
'mailto' => '/<a([^<>]*?)href=["\']mailto:(.*?)["\'](.*?)>(.*?)<\/a[\s+]*>/is',
|
22 |
'email' => '/([A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6})/is',
|
23 |
);
|
@@ -25,15 +36,39 @@ class EebSite extends Eeb_Admin {
|
|
25 |
/**
|
26 |
* Constructor
|
27 |
*/
|
28 |
-
|
29 |
parent::__construct();
|
30 |
}
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
/**
|
33 |
* wp action
|
34 |
*/
|
35 |
public function wp() {
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
if (is_feed()) {
|
39 |
// rss feed
|
@@ -123,7 +158,7 @@ CSS;
|
|
123 |
|
124 |
/* -------------------------------------------------------------------------
|
125 |
* Filter Callbacks
|
126 |
-
*
|
127 |
|
128 |
/**
|
129 |
* WP filter callback
|
@@ -137,7 +172,7 @@ CSS;
|
|
137 |
return $content;
|
138 |
}
|
139 |
|
140 |
-
return $this->encode_email_filter($content,
|
141 |
}
|
142 |
|
143 |
/**
|
@@ -166,12 +201,12 @@ CSS;
|
|
166 |
/**
|
167 |
* Filter content for encoding
|
168 |
* @param string $content
|
169 |
-
* @param boolean $enc_tags Optional, default
|
170 |
-
* @param boolean $enc_mailtos Optional, default
|
171 |
-
* @param boolean $enc_plain_emails Optional, default
|
172 |
* @return string
|
173 |
*/
|
174 |
-
public function encode_email_filter($content, $enc_tags =
|
175 |
// encode mailto links
|
176 |
if ($enc_mailtos) {
|
177 |
$content = preg_replace_callback($this->regexp_patterns['mailto'], array($this, 'callback_encode_email'), $content);
|
@@ -208,7 +243,7 @@ CSS;
|
|
208 |
|
209 |
/* -------------------------------------------------------------------------
|
210 |
* Shortcode Functions
|
211 |
-
*
|
212 |
|
213 |
/**
|
214 |
* Shortcode showing encoder form
|
@@ -216,7 +251,6 @@ CSS;
|
|
216 |
*/
|
217 |
public function shortcode_email_encoder_form() {
|
218 |
// add style and script for ajax encoder
|
219 |
-
// wp_enqueue_script('email_encoder', plugins_url('js/src/email-encoder-bundle.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
|
220 |
wp_enqueue_script('email_encoder', plugins_url('js/email-encoder-bundle.min.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
|
221 |
|
222 |
return $this->get_encoder_form();
|
@@ -234,8 +268,8 @@ CSS;
|
|
234 |
|
235 |
$email = $attrs['email'];
|
236 |
$display = (key_exists('display', $attrs)) ? $attrs['display'] : $attrs['email'];
|
237 |
-
$method = (key_exists('method', $attrs)) ? $attrs['method'] :
|
238 |
-
$extra_attrs = (key_exists('extra_attrs', $attrs)) ? $attrs['extra_attrs'] :
|
239 |
|
240 |
$encoded = $this->encode_email($email, $display, $extra_attrs, $method);
|
241 |
|
@@ -255,7 +289,7 @@ CSS;
|
|
255 |
* @return string
|
256 |
*/
|
257 |
public function shortcode_encode_content($attrs, $content = '') {
|
258 |
-
$method = (is_array($attrs) && key_exists('method', $attrs)) ? $attrs['method'] :
|
259 |
|
260 |
return $this->encode_content($content, $method);
|
261 |
}
|
@@ -271,7 +305,7 @@ CSS;
|
|
271 |
* @param boolean $no_html_checked
|
272 |
* @return string
|
273 |
*/
|
274 |
-
public function encode_content($content, $method =
|
275 |
// get encode method
|
276 |
$method = $this->get_method($method, $this->method);
|
277 |
|
@@ -279,7 +313,7 @@ CSS;
|
|
279 |
$content = $this->{$method}($content);
|
280 |
|
281 |
// add visual check
|
282 |
-
if ($no_html_checked !==
|
283 |
$content = $this->get_success_check($content);
|
284 |
}
|
285 |
|
@@ -295,7 +329,7 @@ CSS;
|
|
295 |
* @param boolean $no_html_checked
|
296 |
* @return string
|
297 |
*/
|
298 |
-
public function encode_email($email, $display =
|
299 |
// get encode method
|
300 |
$method = $this->get_method($method, $this->method);
|
301 |
|
@@ -303,7 +337,7 @@ CSS;
|
|
303 |
$email = html_entity_decode($email);
|
304 |
|
305 |
// set email as display
|
306 |
-
if ($display ===
|
307 |
$display = $email;
|
308 |
|
309 |
if ($method === 'enc_html') {
|
@@ -323,7 +357,7 @@ CSS;
|
|
323 |
|
324 |
if ($method === 'enc_html') {
|
325 |
// add visual check
|
326 |
-
if ($no_html_checked !==
|
327 |
$mailto = $this->get_success_check($mailto);
|
328 |
}
|
329 |
} else {
|
@@ -354,7 +388,12 @@ CSS;
|
|
354 |
|
355 |
/* -------------------------------------------------------------------------
|
356 |
* Different Encoding Methods
|
357 |
-
*
|
|
|
|
|
|
|
|
|
|
|
358 |
|
359 |
/**
|
360 |
* ASCII method
|
@@ -371,7 +410,7 @@ CSS;
|
|
371 |
for ($i = 0; $i < strlen($mail_link); $i ++) {
|
372 |
$l = substr($mail_link, $i, 1);
|
373 |
|
374 |
-
if (strpos($mail_letters, $l) ===
|
375 |
$p = rand(0, strlen($mail_letters));
|
376 |
$mail_letters = substr($mail_letters, 0, $p) .
|
377 |
$l . substr($mail_letters, $p, strlen($mail_letters));
|
@@ -394,6 +433,12 @@ CSS;
|
|
394 |
return '<script type="text/javascript">'
|
395 |
. '(function(){'
|
396 |
. 'var ml="'. $mail_letters_enc .'",mi="'. $mail_indices .'",o="";'
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
. 'for(var j=0,l=mi.length;j<l;j++){'
|
398 |
. 'o+=ml.charAt(mi.charCodeAt(j)-48);'
|
399 |
. '}document.write(o);'
|
@@ -413,12 +458,12 @@ CSS;
|
|
413 |
private function enc_escape($value) {
|
414 |
$string = 'document.write(\'' . $value . '\')';
|
415 |
|
416 |
-
|
417 |
$split = preg_split('||', $string);
|
418 |
$out = '<script type="text/javascript">' . "eval(unescape('";
|
419 |
|
420 |
foreach ($split as $c) {
|
421 |
-
|
422 |
if (!empty($c)) {
|
423 |
$out .= '%' . dechex(ord($c));
|
424 |
}
|
@@ -464,7 +509,7 @@ CSS;
|
|
464 |
return $emailNOSPAMaddy;
|
465 |
}
|
466 |
|
467 |
-
} // end class
|
468 |
|
469 |
endif;
|
470 |
|
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 |
);
|
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
|
158 |
|
159 |
/* -------------------------------------------------------------------------
|
160 |
* Filter Callbacks
|
161 |
+
* ------------------------------------------------------------------------*/
|
162 |
|
163 |
/**
|
164 |
* WP filter callback
|
172 |
return $content;
|
173 |
}
|
174 |
|
175 |
+
return $this->encode_email_filter($content, true, $this->options['encode_mailtos'], $this->options['encode_emails']);
|
176 |
}
|
177 |
|
178 |
/**
|
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);
|
243 |
|
244 |
/* -------------------------------------------------------------------------
|
245 |
* Shortcode Functions
|
246 |
+
* ------------------------------------------------------------------------*/
|
247 |
|
248 |
/**
|
249 |
* Shortcode showing encoder form
|
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();
|
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 |
|
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 |
}
|
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 |
|
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 |
|
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 |
|
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') {
|
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 {
|
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
|
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));
|
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);'
|
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 |
}
|
509 |
return $emailNOSPAMaddy;
|
510 |
}
|
511 |
|
512 |
+
} // end class Eeb_Site
|
513 |
|
514 |
endif;
|
515 |
|
includes/deprecated.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
*
|
13 |
* @deprecated
|
14 |
*
|
15 |
-
* @global
|
16 |
* @param string $email
|
17 |
* @param string $display if non given will be same as email
|
18 |
* @param string $method Optional, else the default setted method will; be used
|
@@ -20,7 +20,7 @@
|
|
20 |
* @return string
|
21 |
*/
|
22 |
if (!function_exists('encode_email')):
|
23 |
-
function encode_email($email, $display =
|
24 |
return eeb_email($email, $display, $extra_attrs, $method);
|
25 |
}
|
26 |
endif;
|
@@ -30,13 +30,13 @@ endif;
|
|
30 |
*
|
31 |
* @deprecated
|
32 |
*
|
33 |
-
* @global
|
34 |
* @param string $content
|
35 |
-
* @param string $method Optional, default
|
36 |
* @return string
|
37 |
*/
|
38 |
if (!function_exists('encode_content')):
|
39 |
-
function encode_content($content, $method =
|
40 |
return eeb_content($content, $method);
|
41 |
}
|
42 |
endif;
|
@@ -46,15 +46,15 @@ endif;
|
|
46 |
*
|
47 |
* @deprecated
|
48 |
*
|
49 |
-
* @global
|
50 |
* @param string $content
|
51 |
-
* @param boolean $enc_tags Optional, default
|
52 |
-
* @param boolean $enc_mailtos Optional, default
|
53 |
-
* @param boolean $enc_plain_emails Optional, default
|
54 |
* @return string
|
55 |
*/
|
56 |
if (!function_exists('encode_email_filter')):
|
57 |
-
function encode_email_filter($content, $enc_tags =
|
58 |
return eeb_email_filter($content, $enc_tags, $enc_mailtos, $enc_plain_emails);
|
59 |
}
|
60 |
endif;
|
12 |
*
|
13 |
* @deprecated
|
14 |
*
|
15 |
+
* @global Eeb_Site $Eeb_Site
|
16 |
* @param string $email
|
17 |
* @param string $display if non given will be same as email
|
18 |
* @param string $method Optional, else the default setted method will; be used
|
20 |
* @return string
|
21 |
*/
|
22 |
if (!function_exists('encode_email')):
|
23 |
+
function encode_email($email, $display = null, $method = null, $extra_attrs = '') {
|
24 |
return eeb_email($email, $display, $extra_attrs, $method);
|
25 |
}
|
26 |
endif;
|
30 |
*
|
31 |
* @deprecated
|
32 |
*
|
33 |
+
* @global Eeb_Site $Eeb_Site
|
34 |
* @param string $content
|
35 |
+
* @param string $method Optional, default null
|
36 |
* @return string
|
37 |
*/
|
38 |
if (!function_exists('encode_content')):
|
39 |
+
function encode_content($content, $method = null) {
|
40 |
return eeb_content($content, $method);
|
41 |
}
|
42 |
endif;
|
46 |
*
|
47 |
* @deprecated
|
48 |
*
|
49 |
+
* @global Eeb_Site $Eeb_Site
|
50 |
* @param string $content
|
51 |
+
* @param boolean $enc_tags Optional, default true
|
52 |
+
* @param boolean $enc_mailtos Optional, default true
|
53 |
+
* @param boolean $enc_plain_emails Optional, default true
|
54 |
* @return string
|
55 |
*/
|
56 |
if (!function_exists('encode_email_filter')):
|
57 |
+
function encode_email_filter($content, $enc_tags = true, $enc_mailtos = true, $enc_plain_emails = true) {
|
58 |
return eeb_email_filter($content, $enc_tags, $enc_mailtos, $enc_plain_emails);
|
59 |
}
|
60 |
endif;
|
includes/template-functions.php
CHANGED
@@ -6,64 +6,67 @@
|
|
6 |
* @package Email_Encoder_Bundle
|
7 |
* @category WordPress Plugins
|
8 |
*/
|
|
|
9 |
|
10 |
-
/**
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
if (!function_exists('eeb_email')):
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
endif;
|
25 |
|
26 |
|
27 |
-
/**
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
if (!function_exists('eeb_content')):
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
endif;
|
40 |
|
41 |
-
/**
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
if (!function_exists('eeb_email_filter')):
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
-
/**
|
58 |
-
* Template function for getting HTML of the encoder form (to put it on the site)
|
59 |
-
* @global EebSite $EebSite
|
60 |
-
* @return string
|
61 |
-
*/
|
62 |
-
if (!function_exists('eeb_form')):
|
63 |
-
function eeb_form() {
|
64 |
-
global $EebSite;
|
65 |
-
return $EebSite->get_encoder_form();
|
66 |
-
}
|
67 |
endif;
|
68 |
|
69 |
/* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
|
6 |
* @package Email_Encoder_Bundle
|
7 |
* @category WordPress Plugins
|
8 |
*/
|
9 |
+
if (!is_admin()):
|
10 |
|
11 |
+
/**
|
12 |
+
* Template function for encoding email
|
13 |
+
* @global Eeb_Site $Eeb_Site
|
14 |
+
* @param string $email
|
15 |
+
* @param string $display if non given will be same as email
|
16 |
+
* @param string $extra_attrs Optional
|
17 |
+
* @param string $method Optional, else the default setted method will; be used
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
if (!function_exists('eeb_email')):
|
21 |
+
function eeb_email($email, $display = null, $extra_attrs = '', $method = null) {
|
22 |
+
global $Eeb_Site;
|
23 |
+
return $Eeb_Site->encode_email($email, $display, $extra_attrs, $method);
|
24 |
+
}
|
25 |
+
endif;
|
26 |
|
27 |
|
28 |
+
/**
|
29 |
+
* Template function for encoding content
|
30 |
+
* @global Eeb_Site $Eeb_Site
|
31 |
+
* @param string $content
|
32 |
+
* @param string $method Optional, default null
|
33 |
+
* @return string
|
34 |
+
*/
|
35 |
+
if (!function_exists('eeb_content')):
|
36 |
+
function eeb_content($content, $method = null) {
|
37 |
+
global $Eeb_Site;
|
38 |
+
return $Eeb_Site->encode_content($content, $method);
|
39 |
+
}
|
40 |
+
endif;
|
41 |
|
42 |
+
/**
|
43 |
+
* Template function for encoding emails in the given content
|
44 |
+
* @global Eeb_Site $Eeb_Site
|
45 |
+
* @param string $content
|
46 |
+
* @param boolean $enc_tags Optional, default true
|
47 |
+
* @param boolean $enc_mailtos Optional, default true
|
48 |
+
* @param boolean $enc_plain_emails Optional, default true
|
49 |
+
* @return string
|
50 |
+
*/
|
51 |
+
if (!function_exists('eeb_email_filter')):
|
52 |
+
function eeb_email_filter($content, $enc_tags = true, $enc_mailtos = true, $enc_plain_emails = true) {
|
53 |
+
global $Eeb_Site;
|
54 |
+
return $Eeb_Site->encode_email_filter($content, $enc_tags, $enc_mailtos, $enc_plain_emails);
|
55 |
+
}
|
56 |
+
endif;
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Template function for getting HTML of the encoder form (to put it on the site)
|
60 |
+
* @global Eeb_Site $Eeb_Site
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
if (!function_exists('eeb_form')):
|
64 |
+
function eeb_form() {
|
65 |
+
global $Eeb_Site;
|
66 |
+
return $Eeb_Site->get_encoder_form();
|
67 |
+
}
|
68 |
+
endif;
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
endif;
|
71 |
|
72 |
/* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
|
js/src/email-encoder-bundle-admin.js
CHANGED
@@ -30,7 +30,6 @@ jQuery(function ($) {
|
|
30 |
$('.notice-form-field-bug')[$encodeEmails.prop('checked') ? 'fadeIn' : 'fadeOut']();
|
31 |
});
|
32 |
|
33 |
-
|
34 |
// add form-table class to Encoder Form tables
|
35 |
$('.eeb-form table').addClass('form-table');
|
36 |
|
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 |
|
readme.txt
CHANGED
@@ -2,37 +2,38 @@
|
|
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.
|
6 |
-
Stable tag: 1.0
|
7 |
|
8 |
-
Encode mailto links, email addresses or any text and hide them from spambots.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
-
Encode mailto links, email addresses or any text and hide them from spambots.
|
13 |
|
14 |
= Features =
|
15 |
-
* Protect mailto links
|
16 |
-
*
|
17 |
-
*
|
18 |
-
*
|
19 |
-
|
20 |
-
= Some extra features =
|
21 |
-
* Encode any text
|
22 |
-
* Template functions
|
23 |
-
* Manually create protected links with the Encoder Form
|
24 |
-
* And more...
|
25 |
|
26 |
= Easy to use =
|
27 |
-
The plugin works
|
|
|
28 |
|
29 |
-
=
|
30 |
* Documentation - Check the Help tab on the plugin Admin page
|
31 |
* [FAQ](http://wordpress.org/extend/plugins/email-encoder-bundle/faq/)
|
32 |
* [Report a problem](http://wordpress.org/support/plugin/email-encoder-bundle#postform)
|
33 |
|
|
|
|
|
|
|
34 |
= Like this plugin? =
|
35 |
-
|
|
|
|
|
36 |
|
37 |
== Installation ==
|
38 |
|
@@ -68,10 +69,10 @@ There are 2 ways to solve this problem:
|
|
68 |
|
69 |
You will have to use the template function `eeb_email()` or `eeb_content()`.
|
70 |
For example, if your template contains:
|
71 |
-
`echo get_post_meta($post->ID, 'emailaddress',
|
72 |
|
73 |
Then change it to:
|
74 |
-
`$emailaddress = get_post_meta($post->ID, 'emailaddress',
|
75 |
echo eeb_email($emailaddress, 'Mail Me');`
|
76 |
|
77 |
= How to create mailto links that opens in a new window? =
|
@@ -121,18 +122,22 @@ It's possible to filter all widgets by using the Widget Logic plugin and activat
|
|
121 |
|
122 |
== Changelog ==
|
123 |
|
|
|
|
|
|
|
|
|
124 |
= 1.0.2 =
|
125 |
-
*
|
126 |
-
*
|
127 |
|
128 |
= 1.0.1 =
|
129 |
* Fixed PHP support (same as WordPress)
|
130 |
|
131 |
= 1.0.0 =
|
132 |
* NOW ONLY SUPPORT FOR WP 3.4.0+
|
133 |
-
*
|
134 |
-
*
|
135 |
-
*
|
136 |
* Added option support shortcodes in widgets
|
137 |
* Added option removing shortcodes for RSS feed
|
138 |
* Removed "random" method option
|
@@ -164,7 +169,7 @@ It's possible to filter all widgets by using the Widget Logic plugin and activat
|
|
164 |
* Added hook "init_email_encoder_form" to add custom filters (of other plugins)
|
165 |
* Added JavaScript code encapsulation for ASCII method
|
166 |
* Solved reinstalling bug for setting right encoding method
|
167 |
-
*
|
168 |
|
169 |
= 0.50 =
|
170 |
* Added encode method for all kind of contents (template function and shortcode "encode_content")
|
@@ -178,7 +183,7 @@ It's possible to filter all widgets by using the Widget Logic plugin and activat
|
|
178 |
* Widget Logic options bug
|
179 |
|
180 |
= 0.41 =
|
181 |
-
*
|
182 |
* Changed script attribute `language` to `type`
|
183 |
* Script only loaded on options page (hopefully this solves the dashboard toggle problem some people are experiencing)
|
184 |
* Added support for widget_content filter of the Logic Widget plugin
|
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 |
|
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? =
|
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
|
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")
|
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
|
screenshot-1.png
CHANGED
Binary file
|