Version Description
- NOW ONLY SUPPORT FOR PHP 5.4+ and WP 3.4.0+
- Solved bug deleting setting values when unregister (will now be deleted on uninstall)
- Solved bug also possible to set protection text when RSS disabled
- Solved bug saving metaboxes settings
- Added option support shortcodes in widgets
- Added option removing shortcodes for RSS feed
- Removed "random" method option
- Changed names for action and shortcode (prefixed with eeb_), optional the old names will still be supported
- Added template function for creating the encoder form
- Changed class en id names of the Encoder Form
Download this release
Release Info
| Developer | freelancephp |
| Plugin | |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Code changes from version 0.80 to 1.0.0
- email-encoder-bundle.php +65 -1114
- includes/class-eeb-admin.php +834 -0
- includes/class-eeb-site.php +458 -0
- includes/deprecated.php +62 -0
- includes/template-functions.php +69 -0
- js/email-encoder-bundle-admin.js +0 -69
- js/email-encoder-bundle.js +0 -74
- js/email-encoder-bundle.min.js +2 -0
- js/src/email-encoder-bundle-admin.js +60 -0
- js/src/email-encoder-bundle.js +74 -0
- readme.txt +64 -28
- screenshot-1.png +0 -0
- screenshot-3.png +0 -0
email-encoder-bundle.php
CHANGED
|
@@ -1,1130 +1,81 @@
|
|
| 1 |
-
<?php
|
| 2 |
/*
|
| 3 |
Plugin Name: Email Encoder Bundle
|
| 4 |
Plugin URI: http://www.freelancephp.net/email-encoder-php-class-wp-plugin/
|
| 5 |
Description: Protect email addresses on your site and hide them from spambots by using an encoding method. Easy to use, flexible .
|
| 6 |
Author: Victor Villaverde Laan
|
| 7 |
-
Version: 0.
|
| 8 |
Author URI: http://www.freelancephp.net
|
| 9 |
License: Dual licensed under the MIT and GPL licenses
|
|
|
|
|
|
|
| 10 |
*/
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
* @category WordPress Plugins
|
| 16 |
-
*/
|
| 17 |
-
if (!class_exists('WP_Email_Encoder_Bundle_Admin')):
|
| 18 |
-
|
| 19 |
-
class WP_Email_Encoder_Bundle_Admin {
|
| 20 |
-
|
| 21 |
-
/**
|
| 22 |
-
* Current version
|
| 23 |
-
* @var string
|
| 24 |
-
*/
|
| 25 |
-
var $version = '0.80';
|
| 26 |
-
|
| 27 |
-
/**
|
| 28 |
-
* Used as prefix for options entry and could be used as text domain (for translations)
|
| 29 |
-
* @var string
|
| 30 |
-
*/
|
| 31 |
-
var $domain = 'WP_Email_Encoder_Bundle';
|
| 32 |
-
|
| 33 |
-
/**
|
| 34 |
-
* Name of the options
|
| 35 |
-
* @var string
|
| 36 |
-
*/
|
| 37 |
-
var $options_name = 'WP_Email_Encoder_Bundle_options';
|
| 38 |
-
|
| 39 |
-
/**
|
| 40 |
-
* @var boolead
|
| 41 |
-
*/
|
| 42 |
-
var $is_admin_user = FALSE;
|
| 43 |
-
|
| 44 |
-
/**
|
| 45 |
-
* @var array
|
| 46 |
-
*/
|
| 47 |
-
var $options = array(
|
| 48 |
-
'method' => 'enc_ascii',
|
| 49 |
-
'encode_mailtos' => 1,
|
| 50 |
-
'encode_emails' => 0,
|
| 51 |
-
'skip_posts' => '',
|
| 52 |
-
'class_name' => 'mailto-link',
|
| 53 |
-
'filter_posts' => 1,
|
| 54 |
-
'filter_widgets' => 1,
|
| 55 |
-
'filter_comments' => 1,
|
| 56 |
-
'filter_rss' => 1,
|
| 57 |
-
'protection_text' => '*protected email*',
|
| 58 |
-
'widget_logic_filter' => 0,
|
| 59 |
-
'show_encoded_check' => 0,
|
| 60 |
-
'own_admin_menu' => 1,
|
| 61 |
-
'powered_by' => 1,
|
| 62 |
-
);
|
| 63 |
-
|
| 64 |
-
/**
|
| 65 |
-
* @var array
|
| 66 |
-
*/
|
| 67 |
-
var $skip_posts = array();
|
| 68 |
-
|
| 69 |
-
/**
|
| 70 |
-
* @var string
|
| 71 |
-
*/
|
| 72 |
-
var $method = 'enc_ascii';
|
| 73 |
-
|
| 74 |
-
/**
|
| 75 |
-
* @var array
|
| 76 |
-
*/
|
| 77 |
-
var $methods = array();
|
| 78 |
-
|
| 79 |
-
/**
|
| 80 |
-
* PHP5 constructor
|
| 81 |
-
*/
|
| 82 |
-
function __construct() {
|
| 83 |
-
// load text domain for translations
|
| 84 |
-
load_plugin_textdomain($this->domain, FALSE, dirname(plugin_basename(__FILE__)) . '/lang/');
|
| 85 |
-
|
| 86 |
-
// set methods
|
| 87 |
-
$this->methods = array(
|
| 88 |
-
'enc_ascii' => array(
|
| 89 |
-
'name' => __('JavaScript ASCII (recommended)', $this->domain),
|
| 90 |
-
'description' => __('This encoding method uses javascript (<a href="http://rumkin.com/tools/mailto_encoder/" target="_blank">original source</a>). <br />Recommended, the savest method.', $this->domain),
|
| 91 |
-
),
|
| 92 |
-
'enc_escape' => array(
|
| 93 |
-
'name' => __('JavaScript Escape', $this->domain),
|
| 94 |
-
'description' => __('This encoding method uses the javascript eval() function (<a href="http://blueberryware.net/2008/09/14/email-spam-protection/" target="_blank">original source</a>). <br />Pretty save method.', $this->domain),
|
| 95 |
-
),
|
| 96 |
-
'enc_html' => array(
|
| 97 |
-
'name' => __('Html Encode', $this->domain),
|
| 98 |
-
'description' => __('This encoding method uses the antispambot() function, built-in WordPress (<a href="http://codex.wordpress.org/Function_Reference/antispambot" target="_blank">more info</a>). <br />Not recommended, especially when using the shortcode [encode_content]).', $this->domain),
|
| 99 |
-
),
|
| 100 |
-
'random' => array(
|
| 101 |
-
'name' => __('Random', $this->domain),
|
| 102 |
-
'description' => __('Pick each time a random encoding method. <br />Not recommended, especially when using the shortcode [encode_content]).', $this->domain),
|
| 103 |
-
),
|
| 104 |
-
);
|
| 105 |
-
|
| 106 |
-
// set option values
|
| 107 |
-
$this->set_options();
|
| 108 |
-
|
| 109 |
-
// prepare vars
|
| 110 |
-
$skip_posts = $this->options['skip_posts'];
|
| 111 |
-
$skip_posts = str_replace(' ', '', $skip_posts);
|
| 112 |
-
$skip_posts = explode(',', $skip_posts);
|
| 113 |
-
$this->skip_posts = $skip_posts;
|
| 114 |
-
|
| 115 |
-
// set uninstall hook
|
| 116 |
-
if (function_exists('register_deactivation_hook')) {
|
| 117 |
-
register_deactivation_hook(__FILE__, array($this, 'deactivation'));
|
| 118 |
-
}
|
| 119 |
-
|
| 120 |
-
// add actions
|
| 121 |
-
add_action('wp', array($this, 'wp'));
|
| 122 |
-
add_action('admin_init', array($this, 'admin_init'));
|
| 123 |
-
add_action('admin_menu', array($this, 'admin_menu'));
|
| 124 |
-
}
|
| 125 |
-
|
| 126 |
-
/**
|
| 127 |
-
* Set options from save values or defaults
|
| 128 |
-
*/
|
| 129 |
-
function set_options() {
|
| 130 |
-
// set options
|
| 131 |
-
$saved_options = get_option($this->options_name);
|
| 132 |
-
|
| 133 |
-
// backwards compatible (old values)
|
| 134 |
-
if (empty($saved_options)) {
|
| 135 |
-
$saved_options = get_option($this->domain . 'options');
|
| 136 |
-
}
|
| 137 |
-
|
| 138 |
-
// set all options
|
| 139 |
-
if (!empty($saved_options)) {
|
| 140 |
-
foreach ($saved_options AS $key => $value) {
|
| 141 |
-
$this->options[$key] = $value;
|
| 142 |
-
}
|
| 143 |
-
}
|
| 144 |
-
|
| 145 |
-
// set encode method
|
| 146 |
-
$this->method = $this->get_method($this->options['method']);
|
| 147 |
-
|
| 148 |
-
// set widget_content filter of Widget Logic plugin
|
| 149 |
-
$widget_logic_opts = get_option('widget_logic');
|
| 150 |
-
if (is_array($widget_logic_opts) AND key_exists('widget_logic-options-filter', $widget_logic_opts)) {
|
| 151 |
-
$this->options['widget_logic_filter'] = ($widget_logic_opts['widget_logic-options-filter'] == 'checked') ? 1 : 0;
|
| 152 |
-
}
|
| 153 |
-
}
|
| 154 |
-
|
| 155 |
-
/**
|
| 156 |
-
* Get method name
|
| 157 |
-
* @param string $method
|
| 158 |
-
* @param string $defaultMethod Optional, default 'enc_html'
|
| 159 |
-
* @return string
|
| 160 |
-
*/
|
| 161 |
-
function get_method($method, $defaultMethod = 'enc_html') {
|
| 162 |
-
$method = strtolower($method);
|
| 163 |
-
|
| 164 |
-
if ('random' == $method) {
|
| 165 |
-
// set a random method
|
| 166 |
-
$method = array_rand($this->methods);
|
| 167 |
-
|
| 168 |
-
if ('random' == $method) {
|
| 169 |
-
$method = $this->get_method($method, $defaultMethod);
|
| 170 |
-
}
|
| 171 |
-
} else {
|
| 172 |
-
if (!method_exists($this, $method)) {
|
| 173 |
-
$method = $defaultMethod; // set default method
|
| 174 |
-
}
|
| 175 |
-
}
|
| 176 |
-
|
| 177 |
-
return $method;
|
| 178 |
-
}
|
| 179 |
-
|
| 180 |
-
/**
|
| 181 |
-
* Deactivation plugin method
|
| 182 |
-
*/
|
| 183 |
-
function deactivation() {
|
| 184 |
-
delete_option($this->options_name);
|
| 185 |
-
unregister_setting($this->domain, $this->options_name);
|
| 186 |
-
}
|
| 187 |
-
|
| 188 |
-
/**
|
| 189 |
-
* wp action
|
| 190 |
-
*/
|
| 191 |
-
function wp() {
|
| 192 |
-
// check admin
|
| 193 |
-
$this->is_admin_user = current_user_can('manage_options');
|
| 194 |
-
}
|
| 195 |
-
|
| 196 |
-
/**
|
| 197 |
-
* admin_init action
|
| 198 |
-
*/
|
| 199 |
-
function admin_init() {
|
| 200 |
-
// register settings
|
| 201 |
-
register_setting($this->domain, $this->options_name);
|
| 202 |
-
|
| 203 |
-
// actions
|
| 204 |
-
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
| 205 |
-
}
|
| 206 |
-
|
| 207 |
-
/**
|
| 208 |
-
* admin_enqueue_scripts action
|
| 209 |
-
* @param string $hook_suffix
|
| 210 |
-
*/
|
| 211 |
-
function admin_enqueue_scripts($hook_suffix) {
|
| 212 |
-
global $wp_version;
|
| 213 |
-
|
| 214 |
-
if ($hook_suffix == 'settings_page_email-encoder-bundle/email-encoder-bundle' || $hook_suffix == 'toplevel_page_email-encoder-bundle/email-encoder-bundle') {
|
| 215 |
-
// set dashboard postbox
|
| 216 |
-
wp_enqueue_script('dashboard');
|
| 217 |
-
|
| 218 |
-
// set dashboard style for wp < 3.2.0
|
| 219 |
-
if (version_compare(preg_replace('/-.*$/', '', $wp_version), '3.2.0', '<')) {
|
| 220 |
-
wp_admin_css('dashboard');
|
| 221 |
-
}
|
| 222 |
-
|
| 223 |
-
// add style and script for ajax encoder
|
| 224 |
-
wp_enqueue_script('email_encoder', plugins_url('js/email-encoder-bundle.js', __FILE__), array('jquery'), $this->version);
|
| 225 |
-
wp_enqueue_script('email_encoder_admin', plugins_url('js/email-encoder-bundle-admin.js', __FILE__), array('jquery'), $this->version);
|
| 226 |
-
}
|
| 227 |
-
}
|
| 228 |
-
|
| 229 |
-
/**
|
| 230 |
-
* admin_menu action
|
| 231 |
-
*/
|
| 232 |
-
function admin_menu() {
|
| 233 |
-
if ($this->is_admin_user) {
|
| 234 |
-
return;
|
| 235 |
-
}
|
| 236 |
-
|
| 237 |
-
// add page and menu item
|
| 238 |
-
if ($this->options['own_admin_menu']) {
|
| 239 |
-
// create main menu item
|
| 240 |
-
$page_hook = add_menu_page(__('Email Encoder Bundle', $this->domain), __('Email Encoder Bundle', $this->domain),
|
| 241 |
-
'manage_options', __FILE__, array($this, 'show_options_page'),
|
| 242 |
-
plugins_url('images/icon-email-encoder-bundle-16.png', __FILE__));
|
| 243 |
-
} else {
|
| 244 |
-
// create submenu item under "Settings"
|
| 245 |
-
$page_hook = add_options_page(__('Email Encoder Bundle', $this->domain), __('Email Encoder Bundle', $this->domain),
|
| 246 |
-
'manage_options', __FILE__, array($this, 'show_options_page'));
|
| 247 |
-
}
|
| 248 |
-
|
| 249 |
-
// load plugin page
|
| 250 |
-
add_action('load-' . $page_hook, array($this, 'load_options_page'));
|
| 251 |
-
}
|
| 252 |
-
|
| 253 |
-
/* -------------------------------------------------------------------------
|
| 254 |
-
* Admin Options Page
|
| 255 |
-
* ------------------------------------------------------------------------*/
|
| 256 |
-
|
| 257 |
-
/**
|
| 258 |
-
* Load admin options page
|
| 259 |
-
*/
|
| 260 |
-
function load_options_page() {
|
| 261 |
-
// add help tabs
|
| 262 |
-
$this->add_help_tabs();
|
| 263 |
-
|
| 264 |
-
// screen settings
|
| 265 |
-
if (function_exists('add_screen_option')) {
|
| 266 |
-
add_screen_option('layout_columns', array(
|
| 267 |
-
'max' => 2,
|
| 268 |
-
'default' => 2
|
| 269 |
-
));
|
| 270 |
-
}
|
| 271 |
-
|
| 272 |
-
// add meta boxes
|
| 273 |
-
add_meta_box('general_settings', __('General Settings'), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('general_settings'));
|
| 274 |
-
add_meta_box('admin_settings', __('Admin Settings'), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('admin_settings'));
|
| 275 |
-
add_meta_box('encode_form', __('Email Encoder Form'), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('encode_form'));
|
| 276 |
-
add_meta_box('other_plugins', __('Other Plugins'), array($this, 'show_meta_box_content'), null, 'side', 'core', array('other_plugins'));
|
| 277 |
-
}
|
| 278 |
-
|
| 279 |
-
/**
|
| 280 |
-
* Show admin options page
|
| 281 |
-
*/
|
| 282 |
-
function show_options_page() {
|
| 283 |
-
$this->set_options();
|
| 284 |
-
?>
|
| 285 |
-
<div class="wrap">
|
| 286 |
-
<div class="icon32" id="icon-options-custom" style="background:url(<?php echo plugins_url('images/icon-email-encoder-bundle.png', __FILE__) ?>) no-repeat 50% 50%"><br></div>
|
| 287 |
-
<h2><?php echo get_admin_page_title() ?> - <em><small><?php _e('Protecting Email Addresses', $this->domain) ?></small></em></h2>
|
| 288 |
-
|
| 289 |
-
<?php if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true'): ?>
|
| 290 |
-
<div class="updated settings-error" id="setting-error-settings_updated">
|
| 291 |
-
<p><strong><?php _e('Settings saved.' ) ?></strong></p>
|
| 292 |
-
</div>
|
| 293 |
-
<?php endif; ?>
|
| 294 |
-
|
| 295 |
-
<form method="post" action="options.php">
|
| 296 |
-
<?php settings_fields($this->domain); ?>
|
| 297 |
-
|
| 298 |
-
<input type="hidden" name="<?php echo $this->domain ?>_nonce" value="<?php echo wp_create_nonce($this->domain) ?>" />
|
| 299 |
-
<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
|
| 300 |
-
<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
|
| 301 |
-
|
| 302 |
-
<div id="poststuff">
|
| 303 |
-
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
|
| 304 |
-
<!--<div id="post-body-content"></div>-->
|
| 305 |
-
|
| 306 |
-
<div id="postbox-container-1" class="postbox-container">
|
| 307 |
-
<?php do_meta_boxes('', 'side', ''); ?>
|
| 308 |
-
</div>
|
| 309 |
-
|
| 310 |
-
<div id="postbox-container-2" class="postbox-container">
|
| 311 |
-
<?php do_meta_boxes('', 'normal', ''); ?>
|
| 312 |
-
<?php do_meta_boxes('', 'advanced', ''); ?>
|
| 313 |
-
</div>
|
| 314 |
-
</div> <!-- #post-body -->
|
| 315 |
-
</div> <!-- #poststuff -->
|
| 316 |
-
</form>
|
| 317 |
-
<script type="text/javascript">
|
| 318 |
-
var methodInfo = <?php echo json_encode($this->methods) ?>;
|
| 319 |
-
</script>
|
| 320 |
-
</div>
|
| 321 |
-
<?php
|
| 322 |
-
}
|
| 323 |
-
|
| 324 |
-
/**
|
| 325 |
-
* Show content of metabox (callback)
|
| 326 |
-
* @param array $post
|
| 327 |
-
* @param array $meta_box
|
| 328 |
-
*/
|
| 329 |
-
function show_meta_box_content($post, $meta_box) {
|
| 330 |
-
$key = $meta_box['args'][0];
|
| 331 |
-
$options = $this->options;
|
| 332 |
-
|
| 333 |
-
if ($key === 'general_settings') {
|
| 334 |
-
?>
|
| 335 |
-
<?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php')): ?>
|
| 336 |
-
<p class="description"><?php _e('Warning: "WP Mailto Links"-plugin is also activated, which could cause conflicts.', $this->domain) ?></p>
|
| 337 |
-
<?php endif; ?>
|
| 338 |
-
<fieldset class="options">
|
| 339 |
-
<table class="form-table">
|
| 340 |
-
<tr>
|
| 341 |
-
<th><?php _e('Encoding Method for Protection', $this->domain) ?></th>
|
| 342 |
-
<td><select id="<?php echo $this->options_name ?>[method]" name="<?php echo $this->options_name ?>[method]" class="method-info-select postform">
|
| 343 |
-
<?php foreach ($this->methods AS $method => $info): ?>
|
| 344 |
-
<option value="<?php echo $method ?>" <?php if ($this->method == $method) echo 'selected="selected"' ?>><?php echo $info['name']; if ($method == 'lim_email_ascii'){ echo ' (recommended)'; } ?></option>
|
| 345 |
-
<?php endforeach; ?>
|
| 346 |
-
</select>
|
| 347 |
-
<br />
|
| 348 |
-
<label><span class="description"></span></label>
|
| 349 |
-
</td>
|
| 350 |
-
</tr>
|
| 351 |
-
<tr>
|
| 352 |
-
<th><?php _e('Auto-Protect Emails', $this->domain) ?></th>
|
| 353 |
-
<td>
|
| 354 |
-
<label><input type="checkbox" id="encode_mailtos" name="<?php echo $this->options_name ?>[encode_mailtos]" value="1" <?php checked('1', (int) $options['encode_mailtos']); ?> />
|
| 355 |
-
<span><?php _e('Protect mailto links', $this->domain) ?></span> <span class="description"><?php _e('(example: <a href="info@myemail.com">My Email</a>)', $this->domain) ?></span>
|
| 356 |
-
</label>
|
| 357 |
-
<br/><label><input type="checkbox" id="encode_emails" name="<?php echo $this->options_name ?>[encode_emails]" value="1" <?php checked('1', (int) $options['encode_emails']); ?> />
|
| 358 |
-
<span><?php _e('Replace plain email addresses to protected mailto links', $this->domain) ?></span> <span class="description"><?php _e('(not recommended)', $this->domain) ?></span>
|
| 359 |
-
</label>
|
| 360 |
-
<br/>
|
| 361 |
-
<br/>
|
| 362 |
-
Apply on:
|
| 363 |
-
<br/>
|
| 364 |
-
<label><input type="checkbox" name="<?php echo $this->options_name ?>[filter_posts]" value="1" <?php checked('1', (int) $options['filter_posts']); ?> />
|
| 365 |
-
<span><?php _e('All posts', $this->domain) ?></span>
|
| 366 |
-
</label>
|
| 367 |
-
<br/><label><input type="checkbox" id="<?php echo $this->options_name ?>[filter_comments]" name="<?php echo $this->options_name ?>[filter_comments]" value="1" <?php checked('1', (int) $options['filter_comments']); ?> />
|
| 368 |
-
<span><?php _e('All comments', $this->domain) ?></span></label>
|
| 369 |
-
<br/><label><input type="checkbox" id="<?php echo $this->options_name ?>[filter_widgets]" name="<?php echo $this->options_name ?>[filter_widgets]" value="1" <?php checked('1', (int) $options['filter_widgets']); ?> />
|
| 370 |
-
<span><?php if ($this->options['widget_logic_filter']) { _e('All widgets (uses the <code>widget_content</code> filter of the Widget Logic plugin)', $this->domain); } else { _e('All text widgets', $this->domain); } ?></span></label>
|
| 371 |
-
<br/>
|
| 372 |
-
<br/>
|
| 373 |
-
<label>
|
| 374 |
-
<span><?php _e('Do <strong>not</strong> apply Auto-Protect on posts with ID:', $this->domain) ?></span>
|
| 375 |
-
<br/><input type="text" id="<?php echo $this->options_name ?>[skip_posts]" name="<?php echo $this->options_name ?>[skip_posts]" value="<?php echo $options['skip_posts']; ?>" />
|
| 376 |
-
<span class="description"><?php _e('(comma seperated, f.e.: 2, 7, 13, 32)', $this->domain) ?></span>
|
| 377 |
-
<br/><span class="description"><?php _e('Notice: shortcodes will still work on these posts.', $this->domain) ?></span>
|
| 378 |
-
</label>
|
| 379 |
-
</td>
|
| 380 |
-
</tr>
|
| 381 |
-
<tr>
|
| 382 |
-
<th><?php _e('Class for Protected Links', $this->domain) ?></th>
|
| 383 |
-
<td><label><input type="text" id="<?php echo $this->options_name ?>[class_name]" name="<?php echo $this->options_name ?>[class_name]" value="<?php echo $options['class_name']; ?>" />
|
| 384 |
-
<span class="description"><?php _e('All protected mailto links will get these class(es) <em>(optional, else keep blank)</em>', $this->domain) ?></span></label></td>
|
| 385 |
-
</tr>
|
| 386 |
-
<tr>
|
| 387 |
-
<th><?php _e('Protect Emails in RSS Feeds', $this->domain) ?></th>
|
| 388 |
-
<td><label><input type="checkbox" id="filter_rss" name="<?php echo $this->options_name ?>[filter_rss]" value="1" <?php checked('1', (int) $options['filter_rss']); ?> />
|
| 389 |
-
<span><?php _e('Replace emails in RSS feeds with the following text:', $this->domain) ?></span></label>
|
| 390 |
-
<label><input type="text" id="protection_text" name="<?php echo $this->options_name ?>[protection_text]" value="<?php echo $options['protection_text']; ?>" />
|
| 391 |
-
</td>
|
| 392 |
-
</tr>
|
| 393 |
-
</table>
|
| 394 |
-
</fieldset>
|
| 395 |
-
<p class="submit">
|
| 396 |
-
<input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
|
| 397 |
-
</p>
|
| 398 |
-
<br class="clear" />
|
| 399 |
-
<?php
|
| 400 |
-
} else if ($key === 'admin_settings') {
|
| 401 |
-
?>
|
| 402 |
-
<fieldset class="options">
|
| 403 |
-
<table class="form-table">
|
| 404 |
-
<tr>
|
| 405 |
-
<th><?php _e('Check encoded content', $this->domain) ?></th>
|
| 406 |
-
<td><label><input type="checkbox" id="<?php echo $this->options_name ?>[show_encoded_check]" name="<?php echo $this->options_name ?>[show_encoded_check]" value="1" <?php checked('1', (int) $options['show_encoded_check']); ?> /> <span><?php _e('Show "successfully encoded" text for all encoded content, only when logged in as admin user', $this->domain) ?></span> <br /><span class="description">(this way you can check if emails are really encoded on your site)</span></label></td>
|
| 407 |
-
</tr>
|
| 408 |
-
<tr>
|
| 409 |
-
<th><?php _e('Admin menu position', $this->domain) ?></th>
|
| 410 |
-
<td><label><input type="checkbox" id="<?php echo $this->options_name ?>[own_admin_menu]" name="<?php echo $this->options_name ?>[own_admin_menu]" value="1" <?php checked('1', (int) $options['own_admin_menu']); ?> /> <span><?php _e('Show as main menu item', $this->domain) ?></span> <span class="description">(when disabled item will be shown under "General settings")</span></label></td>
|
| 411 |
-
</tr>
|
| 412 |
-
<tr>
|
| 413 |
-
<th><?php _e('Email Encoder Form Settings', $this->domain) ?></th>
|
| 414 |
-
<td><label><input type="checkbox" id="<?php echo $this->options_name ?>[powered_by]" name="<?php echo $this->options_name ?>[powered_by]" value="1" <?php checked('1', (int) $options['powered_by']); ?> /> <span><?php _e('Show the "powered by"-link on bottom of the encoder form', $this->domain) ?></span></label></td>
|
| 415 |
-
</tr>
|
| 416 |
-
</table>
|
| 417 |
-
</fieldset>
|
| 418 |
-
<p class="submit">
|
| 419 |
-
<input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
|
| 420 |
-
</p>
|
| 421 |
-
<br class="clear" />
|
| 422 |
-
<?php
|
| 423 |
-
} else if ($key === 'encode_form') {
|
| 424 |
-
echo $this->get_encoder_form();
|
| 425 |
-
} else if ($key === 'other_plugins') {
|
| 426 |
-
?>
|
| 427 |
-
<h4><img src="<?php echo plugins_url('images/icon-wp-external-links.png', __FILE__) ?>" width="16" height="16" /> WP External Links -
|
| 428 |
-
<?php if (is_plugin_active('wp-external-links/wp-external-links.php')): ?>
|
| 429 |
-
<a href="<?php echo get_bloginfo('url') ?>/wp-admin/options-general.php?page=wp-external-links/wp-external-links.php"><?php _e('Settings') ?></a>
|
| 430 |
-
<?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-external-links/wp-external-links.php')): ?>
|
| 431 |
-
<a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate', $this->domain) ?></a>
|
| 432 |
-
<?php else: ?>
|
| 433 |
-
<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', $this->domain) ?></a>
|
| 434 |
-
<?php endif; ?>
|
| 435 |
-
</h4>
|
| 436 |
-
<p><?php _e('Manage external links on your site: open in new window/tab, set icon, add "external", add "nofollow" and more.', $this->domain) ?>
|
| 437 |
-
<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>
|
| 438 |
-
</p>
|
| 439 |
-
|
| 440 |
-
<h4><img src="<?php echo plugins_url('images/icon-wp-mailto-links.png', __FILE__) ?>" width="16" height="16" /> WP Mailto Links -
|
| 441 |
-
<?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php')): ?>
|
| 442 |
-
<a href="<?php echo get_bloginfo('url') ?>/wp-admin/options-general.php?page=wp-mailto-links/wp-mailto-links.php"><?php _e('Settings') ?></a>
|
| 443 |
-
<?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-mailto-links/wp-mailto-links.php')): ?>
|
| 444 |
-
<a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate', $this->domain) ?></a>
|
| 445 |
-
<?php else: ?>
|
| 446 |
-
<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', $this->domain) ?></a>
|
| 447 |
-
<?php endif; ?>
|
| 448 |
-
</h4>
|
| 449 |
-
<p><?php _e('Manage mailto links on your site and protect emails from spambots, set mail icon and more.', $this->domain) ?>
|
| 450 |
-
<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>
|
| 451 |
-
</p>
|
| 452 |
-
<?php
|
| 453 |
-
}
|
| 454 |
-
}
|
| 455 |
-
|
| 456 |
-
/* -------------------------------------------------------------------------
|
| 457 |
-
* Help Tabs
|
| 458 |
-
* ------------------------------------------------------------------------*/
|
| 459 |
-
|
| 460 |
-
/**
|
| 461 |
-
* Add help tabs
|
| 462 |
-
*/
|
| 463 |
-
function add_help_tabs() {
|
| 464 |
-
if (!function_exists('get_current_screen')) {
|
| 465 |
-
return;
|
| 466 |
-
}
|
| 467 |
-
|
| 468 |
-
$screen = get_current_screen();
|
| 469 |
-
|
| 470 |
-
$screen->set_help_sidebar($this->get_help_text('sidebar'));
|
| 471 |
-
|
| 472 |
-
$screen->add_help_tab(array(
|
| 473 |
-
'id' => 'about',
|
| 474 |
-
'title' => __('About'),
|
| 475 |
-
'content' => $this->get_help_text('about'),
|
| 476 |
-
));
|
| 477 |
-
$screen->add_help_tab(array(
|
| 478 |
-
'id' => 'shortcodes',
|
| 479 |
-
'title' => __('Shortcodes'),
|
| 480 |
-
'content' => $this->get_help_text('shortcodes'),
|
| 481 |
-
));
|
| 482 |
-
$screen->add_help_tab(array(
|
| 483 |
-
'id' => 'templatefunctions',
|
| 484 |
-
'title' => __('Template functions'),
|
| 485 |
-
'content' => $this->get_help_text('templatefunctions'),
|
| 486 |
-
));
|
| 487 |
-
$screen->add_help_tab(array(
|
| 488 |
-
'id' => 'hooks',
|
| 489 |
-
'title' => __('Hooks'),
|
| 490 |
-
'content' => $this->get_help_text('hooks'),
|
| 491 |
-
));
|
| 492 |
-
}
|
| 493 |
-
|
| 494 |
-
/**
|
| 495 |
-
* Get text for given help tab
|
| 496 |
-
* @param string $key
|
| 497 |
-
* @return string
|
| 498 |
-
*/
|
| 499 |
-
function get_help_text($key) {
|
| 500 |
-
if ($key === 'about') {
|
| 501 |
-
$plugin_title = get_admin_page_title();
|
| 502 |
-
$icon_url = plugins_url('images/icon-email-encoder-bundle.png', __FILE__);
|
| 503 |
-
$content = <<<ABOUT
|
| 504 |
-
<p><strong><img src="{$icon_url}" width="16" height="16" /> {$plugin_title} - version {$this->version}</strong></p>
|
| 505 |
-
<p>Encode mailto links and (plain) email addresses and hide them from spambots. Easy to use, plugin works directly when activated. Save way to protect email addresses on your site.</p>
|
| 506 |
-
ABOUT;
|
| 507 |
-
} else if ($key === 'shortcodes') {
|
| 508 |
-
$content = <<<SHORTCODES
|
| 509 |
-
<p>Encode an email address:
|
| 510 |
-
<br/><code>[encode_email email="..." display="..."]</code> ("display" is optional)
|
| 511 |
-
</p>
|
| 512 |
-
<p>Encode some content:
|
| 513 |
-
<br/><code>[encode_content method="..."]...[/encode_content]</code> ("method" is optional)
|
| 514 |
-
</p>
|
| 515 |
-
<p>Puts an encoder form in your post:
|
| 516 |
-
<br/><code>[email_encoder_form]</code>
|
| 517 |
-
</p>
|
| 518 |
-
SHORTCODES;
|
| 519 |
-
} else if ($key === 'templatefunctions') {
|
| 520 |
-
$content = <<<TEMPLATEFUNCTIONS
|
| 521 |
-
<p>Encode the given email (other params are optional):
|
| 522 |
-
<br/><code><?php echo encode_email(\$email, [\$display], [\$method], [\$extra_attrs]); ?></code>
|
| 523 |
-
</p>
|
| 524 |
-
<p>Encode the given content for emails to encode (other param is optional):
|
| 525 |
-
<br/><code><?php echo encode_content(\$content, [\$method]); ?></code>
|
| 526 |
-
</p>
|
| 527 |
-
<p>Filter the given content for emails to encode (other params are optional):
|
| 528 |
-
<br/><code><?php echo encode_email_filter(\$content, [\$enc_tags], [\$enc_mailtos], [\$enc_plain_emails]); ?></code>
|
| 529 |
-
</p>
|
| 530 |
-
TEMPLATEFUNCTIONS;
|
| 531 |
-
} else if ($key === 'hooks') {
|
| 532 |
-
$content = <<<HOOKS
|
| 533 |
-
<p>Add extra code on initializing this plugin, like extra filters for encoding.</p>
|
| 534 |
-
<pre>
|
| 535 |
-
function extra_encode_filters(\$filter_callback, \$object) {
|
| 536 |
-
add_filter('some_filter', \$filter_callback);
|
| 537 |
}
|
| 538 |
-
add_action('init_email_encoder_bundle', 'extra_encode_filters');
|
| 539 |
-
</pre>
|
| 540 |
-
HOOKS;
|
| 541 |
-
} else if ($key === 'sidebar') {
|
| 542 |
-
$content = <<<SIDEBAR
|
| 543 |
-
<p>See <a href="http://wordpress.org/extend/plugins/email-encoder-bundle/faq/" target="_blank">FAQ</a> at WordPress.org</p>
|
| 544 |
-
<p>Send your <a href="http://www.freelancephp.net/contact/" target="_blank">question</a></p>
|
| 545 |
-
<p><strong>Please <a href="http://wordpress.org/extend/plugins/email-encoder-bundle/" target="_blank">rate this plugin</a> and vote if the plugin works.</strong></p>
|
| 546 |
-
SIDEBAR;
|
| 547 |
-
}
|
| 548 |
-
|
| 549 |
-
return ((empty($content)) ? '' : __($content, $this->domain));
|
| 550 |
-
}
|
| 551 |
-
|
| 552 |
-
/* -------------------------------------------------------------------------
|
| 553 |
-
* Encoder Form
|
| 554 |
-
* -------------------------------------------------------------------------/
|
| 555 |
-
|
| 556 |
-
/**
|
| 557 |
-
* Get the encoder form (to use as a demo, like on the options page)
|
| 558 |
-
* @return string
|
| 559 |
-
*/
|
| 560 |
-
function get_encoder_form() {
|
| 561 |
-
$lang_email = __('Email Address:', $this->domain);
|
| 562 |
-
$lang_display = __('Display Text:', $this->domain);
|
| 563 |
-
$lang_mailto = __('Mailto Link:', $this->domain);
|
| 564 |
-
$lang_method = __('Encoding Method:', $this->domain);
|
| 565 |
-
$lang_create = __('Create Protected Mail Link >>', $this->domain);
|
| 566 |
-
$lang_output = __('Protected Mail Link (code):', $this->domain);
|
| 567 |
-
|
| 568 |
-
$method_options = '';
|
| 569 |
-
foreach ($this->methods as $method => $info) {
|
| 570 |
-
$method_options .= '<option value="' . $method . '"' . (($this->method == $method) ? ' selected="selected"' : '') . '>' . $info['name'] . '</option>';
|
| 571 |
-
}
|
| 572 |
-
|
| 573 |
-
$powered_by = '';
|
| 574 |
-
if ($this->options['powered_by']) {
|
| 575 |
-
$powered_by .= '<p class="powered-by">' . __('Powered by', $this->domain) . ' <a rel="external" href="http://www.freelancephp.net/email-encoder-php-class-wp-plugin/">Email Encoder Bundle</a></p>';
|
| 576 |
-
}
|
| 577 |
-
|
| 578 |
-
return <<<FORM
|
| 579 |
-
<div class="email-encoder-form">
|
| 580 |
-
<form>
|
| 581 |
-
<fieldset>
|
| 582 |
-
<div class="input">
|
| 583 |
-
<table>
|
| 584 |
-
<tbody>
|
| 585 |
-
<tr>
|
| 586 |
-
<th><label for="email">{$lang_email}</label></th>
|
| 587 |
-
<td><input type="text" class="regular-text" id="email" name="email" /></td>
|
| 588 |
-
</tr>
|
| 589 |
-
<tr>
|
| 590 |
-
<th><label for="display">{$lang_display}</label></th>
|
| 591 |
-
<td><input type="text" class="regular-text" id="display" name="display" /></td>
|
| 592 |
-
</tr>
|
| 593 |
-
<tr>
|
| 594 |
-
<th>{$lang_mailto}</th>
|
| 595 |
-
<td><span id="example"></span></td>
|
| 596 |
-
</tr>
|
| 597 |
-
<tr>
|
| 598 |
-
<th><label for="encode_method">{$lang_method}</label></th>
|
| 599 |
-
<td><select id="encode_method" name="encode_method" class="postform">
|
| 600 |
-
{$method_options}
|
| 601 |
-
</select>
|
| 602 |
-
<input type="button" id="ajax_encode" value="{$lang_create}" />
|
| 603 |
-
</td>
|
| 604 |
-
</tr>
|
| 605 |
-
</tbody>
|
| 606 |
-
</table>
|
| 607 |
-
</div>
|
| 608 |
-
<div class="output nodis">
|
| 609 |
-
<table>
|
| 610 |
-
<tbody>
|
| 611 |
-
<tr>
|
| 612 |
-
<th><label for="encoded_output">{$lang_output}</label></th>
|
| 613 |
-
<td><textarea class="large-text node" id="encoded_output" name="encoded_output" cols="50" rows="4"></textarea></td>
|
| 614 |
-
</tr>
|
| 615 |
-
</tbody>
|
| 616 |
-
</table>
|
| 617 |
-
</div>
|
| 618 |
-
{$powered_by}
|
| 619 |
-
</fieldset>
|
| 620 |
-
</form>
|
| 621 |
-
</div>
|
| 622 |
-
FORM;
|
| 623 |
-
}
|
| 624 |
-
|
| 625 |
-
} // end class WP_Email_Encoder_Bundle_Admin
|
| 626 |
-
|
| 627 |
-
endif;
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
/**
|
| 631 |
-
* Class WP_Email_Encoder_Bundle
|
| 632 |
-
* @package WP_Email_Encoder_Bundle
|
| 633 |
-
* @category WordPress Plugins
|
| 634 |
-
*/
|
| 635 |
-
if (!class_exists('WP_Email_Encoder_Bundle')):
|
| 636 |
-
|
| 637 |
-
class WP_Email_Encoder_Bundle extends WP_Email_Encoder_Bundle_Admin {
|
| 638 |
-
|
| 639 |
-
/**
|
| 640 |
-
* Regexp
|
| 641 |
-
* @var array
|
| 642 |
-
*/
|
| 643 |
-
var $regexp_patterns = array(
|
| 644 |
-
'mailto' => '/<a([^<>]*?)href=["\']mailto:(.*?)["\'](.*?)>(.*?)<\/a[\s+]*>/is',
|
| 645 |
-
'email' => '/([A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6})/is',
|
| 646 |
-
);
|
| 647 |
-
|
| 648 |
-
/**
|
| 649 |
-
* PHP4 constructor
|
| 650 |
-
*/
|
| 651 |
-
function WP_Email_Encoder_Bundle() {
|
| 652 |
-
parent::__construct();
|
| 653 |
-
}
|
| 654 |
-
|
| 655 |
-
/**
|
| 656 |
-
* wp action
|
| 657 |
-
*/
|
| 658 |
-
function wp() {
|
| 659 |
-
parent::wp();
|
| 660 |
-
|
| 661 |
-
if (is_feed()) {
|
| 662 |
-
// rss feed
|
| 663 |
-
if ($this->options['filter_rss']) {
|
| 664 |
-
$rss_filters = array('the_title', 'the_content', 'the_excerpt', 'the_title_rss', 'the_content_rss', 'the_excerpt_rss',
|
| 665 |
-
'comment_text_rss', 'comment_author_rss', 'the_category_rss', 'the_content_feed', 'author_feed_link', 'feed_link');
|
| 666 |
-
|
| 667 |
-
foreach($rss_filters as $filter) {
|
| 668 |
-
add_filter($filter, array($this, 'callback_filter_rss'), 100);
|
| 669 |
-
}
|
| 670 |
-
}
|
| 671 |
-
} else {
|
| 672 |
-
// site
|
| 673 |
-
$filters = array();
|
| 674 |
-
|
| 675 |
-
// post content
|
| 676 |
-
if ($this->options['filter_posts']) {
|
| 677 |
-
array_push($filters, 'the_title', 'the_content', 'the_excerpt', 'get_the_excerpt');
|
| 678 |
-
}
|
| 679 |
-
|
| 680 |
-
// comments
|
| 681 |
-
if ($this->options['filter_comments']) {
|
| 682 |
-
array_push($filters, 'comment_text', 'comment_excerpt', 'comment_url', 'get_comment_author_url', 'get_comment_author_link', 'get_comment_author_url_link');
|
| 683 |
-
}
|
| 684 |
-
|
| 685 |
-
// widgets
|
| 686 |
-
if ($this->options['filter_widgets']) {
|
| 687 |
-
array_push($filters, 'widget_title', 'widget_text', 'widget_content');
|
| 688 |
-
|
| 689 |
-
// also replace shortcodes
|
| 690 |
-
add_filter('widget_text', 'do_shortcode', 100);
|
| 691 |
-
add_filter('widget_content', 'do_shortcode', 100); // widget_content id filter of Widget Logic plugin
|
| 692 |
-
}
|
| 693 |
-
|
| 694 |
-
foreach($filters as $filter) {
|
| 695 |
-
add_filter($filter, array($this, 'callback_filter'), 100);
|
| 696 |
-
}
|
| 697 |
-
}
|
| 698 |
-
|
| 699 |
-
// shortcodes
|
| 700 |
-
add_shortcode('email_encoder_form', array($this, 'shortcode_email_encoder_form'));
|
| 701 |
-
add_shortcode('encode_email', array($this, 'shortcode_encode_email'));
|
| 702 |
-
add_shortcode('encode_content', array($this, 'shortcode_encode_content'));
|
| 703 |
-
|
| 704 |
-
// actions
|
| 705 |
-
add_action('wp_head', array($this, 'wp_head'));
|
| 706 |
-
|
| 707 |
-
// hook
|
| 708 |
-
do_action('init_email_encoder_bundle', array($this, 'callback_filter'), $this);
|
| 709 |
-
}
|
| 710 |
-
|
| 711 |
-
/**
|
| 712 |
-
* WP head
|
| 713 |
-
*/
|
| 714 |
-
function wp_head() {
|
| 715 |
-
// add styling for encoding check message + icon
|
| 716 |
-
if ($this->is_admin_user && $this->options['show_encoded_check']) {
|
| 717 |
-
echo <<<CSS
|
| 718 |
-
<style type="text/css">
|
| 719 |
-
a.encoded-check { opacity:0.5; position:absolute; text-decoration:none !important; font:10px Arial !important; margin-top:-3px; color:#629632; font-weight:bold; }
|
| 720 |
-
a.encoded-check:hover { opacity:1; cursor:help; }
|
| 721 |
-
a.encoded-check img { width:10px; height:10px; }
|
| 722 |
-
</style>
|
| 723 |
-
CSS;
|
| 724 |
-
}
|
| 725 |
-
}
|
| 726 |
-
|
| 727 |
-
/* -------------------------------------------------------------------------
|
| 728 |
-
* Filter Callbacks
|
| 729 |
-
* -------------------------------------------------------------------------/
|
| 730 |
-
|
| 731 |
-
/**
|
| 732 |
-
* WP filter callback
|
| 733 |
-
* @param string $content
|
| 734 |
-
* @return string
|
| 735 |
-
*/
|
| 736 |
-
function callback_filter($content) {
|
| 737 |
-
global $post;
|
| 738 |
-
|
| 739 |
-
if (isset($post) && in_array($post->ID, $this->skip_posts)) {
|
| 740 |
-
return $content;
|
| 741 |
-
}
|
| 742 |
-
|
| 743 |
-
return $this->encode_email_filter($content, TRUE, $this->options['encode_mailtos'], $this->options['encode_emails']);
|
| 744 |
-
}
|
| 745 |
-
|
| 746 |
-
/**
|
| 747 |
-
* RSS Filter callback
|
| 748 |
-
* @param string $content
|
| 749 |
-
* @return string
|
| 750 |
-
*/
|
| 751 |
-
function callback_filter_rss($content) {
|
| 752 |
-
return preg_replace($this->regexp_patterns, $this->options['protection_text'], $content);
|
| 753 |
-
}
|
| 754 |
-
|
| 755 |
-
/**
|
| 756 |
-
* Filter content for encoding
|
| 757 |
-
* @param string $content
|
| 758 |
-
* @param boolean $enc_tags Optional, default TRUE
|
| 759 |
-
* @param boolean $enc_mailtos Optional, default TRUE
|
| 760 |
-
* @param boolean $enc_plain_emails Optional, default TRUE
|
| 761 |
-
* @return string
|
| 762 |
-
*/
|
| 763 |
-
function encode_email_filter($content, $enc_tags = TRUE, $enc_mailtos = TRUE, $enc_plain_emails = TRUE) {
|
| 764 |
-
// encode mailto links
|
| 765 |
-
if ($enc_mailtos) {
|
| 766 |
-
$content = preg_replace_callback($this->regexp_patterns['mailto'], array($this, 'callback_encode_email'), $content);
|
| 767 |
-
}
|
| 768 |
-
|
| 769 |
-
// replace plain emails
|
| 770 |
-
if ($enc_plain_emails) {
|
| 771 |
-
$content = preg_replace_callback($this->regexp_patterns['email'], array($this, 'callback_encode_email'), $content);
|
| 772 |
-
}
|
| 773 |
-
|
| 774 |
-
// workaround for double encoding bug when auto-protect mailto is enabled and method is enc_html
|
| 775 |
-
if ($this->options['encode_mailtos'] == 1) {
|
| 776 |
-
// change back to html tag
|
| 777 |
-
$content = str_replace('[a-replacement]', '<a', $content);
|
| 778 |
-
}
|
| 779 |
-
|
| 780 |
-
return $content;
|
| 781 |
-
}
|
| 782 |
-
|
| 783 |
-
/**
|
| 784 |
-
* Callback for encoding email
|
| 785 |
-
* @param array $match
|
| 786 |
-
* @return string
|
| 787 |
-
*/
|
| 788 |
-
function callback_encode_email($match) {
|
| 789 |
-
if (count($match) < 3) {
|
| 790 |
-
return $this->encode_email($match[1]);
|
| 791 |
-
} else if (count($match) == 3) {
|
| 792 |
-
return $this->encode_email($match[2]);
|
| 793 |
-
}
|
| 794 |
-
|
| 795 |
-
return $this->encode_email($match[2], $match[4], null, $match[1] . ' ' . $match[3]);
|
| 796 |
-
}
|
| 797 |
-
|
| 798 |
-
/* -------------------------------------------------------------------------
|
| 799 |
-
* Shortcode Functions
|
| 800 |
-
* -------------------------------------------------------------------------/
|
| 801 |
-
|
| 802 |
-
/**
|
| 803 |
-
* Shortcode showing encoder form
|
| 804 |
-
* @return string
|
| 805 |
-
*/
|
| 806 |
-
function shortcode_email_encoder_form() {
|
| 807 |
-
// add style and script for ajax encoder
|
| 808 |
-
wp_enqueue_script('email_encoder', plugins_url('js/email-encoder-bundle.js', __FILE__), array('jquery'), $this->version);
|
| 809 |
-
|
| 810 |
-
return $this->get_encoder_form();
|
| 811 |
-
}
|
| 812 |
-
|
| 813 |
-
/**
|
| 814 |
-
* Shortcode encoding email
|
| 815 |
-
* @param array $attrs
|
| 816 |
-
* @return string
|
| 817 |
-
*/
|
| 818 |
-
function shortcode_encode_email($attrs) {
|
| 819 |
-
if (!is_array($attrs) || !key_exists('email', $attrs)) {
|
| 820 |
-
return '';
|
| 821 |
-
}
|
| 822 |
-
|
| 823 |
-
$email = $attrs['email'];
|
| 824 |
-
$display = (key_exists('display', $attrs)) ? $attrs['display'] : $attrs['email'];
|
| 825 |
-
$method = (key_exists('method', $attrs)) ? $attrs['method'] : NULL;
|
| 826 |
-
$extra_attrs = (key_exists('extra_attrs', $attrs)) ? $attrs['extra_attrs'] : NULL;
|
| 827 |
-
|
| 828 |
-
$encoded = $this->encode_email($email, $display, $method, $extra_attrs);
|
| 829 |
-
|
| 830 |
-
// workaround for double encoding bug when auto-protect mailto is enabled and method is enc_html
|
| 831 |
-
if ($this->options['encode_mailtos'] == 1 && $method === 'enc_html') {
|
| 832 |
-
// change html tag to entity
|
| 833 |
-
$encoded = str_replace('<a', '[a-replacement]', $encoded);
|
| 834 |
-
}
|
| 835 |
-
|
| 836 |
-
return $encoded;
|
| 837 |
-
}
|
| 838 |
-
|
| 839 |
-
/**
|
| 840 |
-
* Shortcode encoding content
|
| 841 |
-
* @param array $attrs
|
| 842 |
-
* @param string $content Optional
|
| 843 |
-
* @return string
|
| 844 |
-
*/
|
| 845 |
-
function shortcode_encode_content($attrs, $content = '') {
|
| 846 |
-
$method = (is_array($attrs) && key_exists('method', $attrs)) ? $attrs['method'] : NULL;
|
| 847 |
-
|
| 848 |
-
return $this->encode($content, $method);
|
| 849 |
-
}
|
| 850 |
-
|
| 851 |
-
/* -------------------------------------------------------------------------
|
| 852 |
-
* Encode Functions
|
| 853 |
-
* -------------------------------------------------------------------------/
|
| 854 |
-
|
| 855 |
-
/**
|
| 856 |
-
* Encode the given email into an encoded HTML link
|
| 857 |
-
* @param string $content
|
| 858 |
-
* @param string $method Optional, else the default setted method will; be used
|
| 859 |
-
* @param boolean $no_html_checked
|
| 860 |
-
* @return string
|
| 861 |
-
*/
|
| 862 |
-
function encode($content, $method = NULL, $no_html_checked = FALSE) {
|
| 863 |
-
// get encode method
|
| 864 |
-
$method = $this->get_method($method, $this->method);
|
| 865 |
-
|
| 866 |
-
// get encoded email code
|
| 867 |
-
$content = $this->{$method}($content);
|
| 868 |
-
|
| 869 |
-
// add visual check
|
| 870 |
-
if ($no_html_checked !== TRUE) {
|
| 871 |
-
$content = $this->get_success_check($content);
|
| 872 |
-
}
|
| 873 |
-
|
| 874 |
-
return $content;
|
| 875 |
-
}
|
| 876 |
-
|
| 877 |
-
/**
|
| 878 |
-
* Encode the given email into an encoded HTML link
|
| 879 |
-
* @param string $email
|
| 880 |
-
* @param string $display Optional, if not set display will be the email
|
| 881 |
-
* @param string $method Optional, else the default setted method will; be used
|
| 882 |
-
* @param string $extra_attrs Optional
|
| 883 |
-
* @return string
|
| 884 |
-
*/
|
| 885 |
-
function encode_email($email, $display = NULL, $method = NULL, $extra_attrs = '', $no_html_checked = FALSE) {
|
| 886 |
-
// get encode method
|
| 887 |
-
$method = $this->get_method($method, $this->method);
|
| 888 |
-
|
| 889 |
-
// decode entities
|
| 890 |
-
$email = html_entity_decode($email);
|
| 891 |
-
|
| 892 |
-
// set email as display
|
| 893 |
-
if ($display === NULL) {
|
| 894 |
-
$display = $email;
|
| 895 |
-
|
| 896 |
-
if ($method === 'enc_html') {
|
| 897 |
-
$display = $this->enc_html($display);
|
| 898 |
-
}
|
| 899 |
-
} else {
|
| 900 |
-
$display = html_entity_decode($display);
|
| 901 |
-
}
|
| 902 |
-
|
| 903 |
-
if ($method === 'enc_html') {
|
| 904 |
-
$email = $this->enc_html($email);
|
| 905 |
-
}
|
| 906 |
-
|
| 907 |
-
$class = $this->options['class_name'];
|
| 908 |
-
$extra_attrs = ' ' . trim($extra_attrs);
|
| 909 |
-
$mailto = '<a class="'. $class .'" href="mailto:' . $email . '"'. $extra_attrs . '>' . $display . '</a>';
|
| 910 |
-
|
| 911 |
-
if ($method === 'enc_html') {
|
| 912 |
-
// add visual check
|
| 913 |
-
if ($no_html_checked !== TRUE) {
|
| 914 |
-
$mailto = $this->get_success_check($mailto);
|
| 915 |
-
}
|
| 916 |
-
} else {
|
| 917 |
-
$mailto = $this->encode($mailto, $method, $no_html_checked);
|
| 918 |
-
}
|
| 919 |
-
|
| 920 |
-
// get encoded email code
|
| 921 |
-
return $mailto;
|
| 922 |
-
}
|
| 923 |
-
|
| 924 |
-
/**
|
| 925 |
-
* Add html to encoded content to show check icon and text
|
| 926 |
-
* @param string $content
|
| 927 |
-
* @return string
|
| 928 |
-
*/
|
| 929 |
-
function get_success_check($content) {
|
| 930 |
-
if (!$this->is_admin_user || !$this->options['show_encoded_check']) {
|
| 931 |
-
return $content;
|
| 932 |
-
}
|
| 933 |
-
|
| 934 |
-
return $content
|
| 935 |
-
. '<a href="javascript:;" class="encoded-check"'
|
| 936 |
-
. ' title="' . __('Successfully Encoded (this is a check and only visible when logged in as admin)', $this->domain) . '">'
|
| 937 |
-
. '<img class="encoded-check-icon" src="' . plugins_url('images/icon-email-encoder-bundle.png', __FILE__)
|
| 938 |
-
. '" alt="' . __('Encoded', $this->domain) . '" />'
|
| 939 |
-
. __('Successfully Encoded', $this->domain) . '</a>';
|
| 940 |
-
}
|
| 941 |
-
|
| 942 |
-
/* -------------------------------------------------------------------------
|
| 943 |
-
* Different Encoding Methods
|
| 944 |
-
* -------------------------------------------------------------------------/
|
| 945 |
-
|
| 946 |
-
/**
|
| 947 |
-
* ASCII method
|
| 948 |
-
* Based on function from Tyler Akins (http://rumkin.com/tools/mailto_encoder/)
|
| 949 |
-
*
|
| 950 |
-
* @param string $value
|
| 951 |
-
* @return string
|
| 952 |
-
*/
|
| 953 |
-
function enc_ascii($value) {
|
| 954 |
-
$mail_link = $value;
|
| 955 |
-
|
| 956 |
-
$mail_letters = '';
|
| 957 |
-
|
| 958 |
-
for ($i = 0; $i < strlen($mail_link); $i ++) {
|
| 959 |
-
$l = substr($mail_link, $i, 1);
|
| 960 |
-
|
| 961 |
-
if (strpos($mail_letters, $l) === false) {
|
| 962 |
-
$p = rand(0, strlen($mail_letters));
|
| 963 |
-
$mail_letters = substr($mail_letters, 0, $p) .
|
| 964 |
-
$l . substr($mail_letters, $p, strlen($mail_letters));
|
| 965 |
-
}
|
| 966 |
-
}
|
| 967 |
-
|
| 968 |
-
$mail_letters_enc = str_replace("\\", "\\\\", $mail_letters);
|
| 969 |
-
$mail_letters_enc = str_replace("\"", "\\\"", $mail_letters_enc);
|
| 970 |
-
|
| 971 |
-
$mail_indices = '';
|
| 972 |
-
for ($i = 0; $i < strlen($mail_link); $i ++) {
|
| 973 |
-
$index = strpos($mail_letters, substr($mail_link, $i, 1));
|
| 974 |
-
$index += 48;
|
| 975 |
-
$mail_indices .= chr($index);
|
| 976 |
-
}
|
| 977 |
-
|
| 978 |
-
$mail_indices = str_replace("\\", "\\\\", $mail_indices);
|
| 979 |
-
$mail_indices = str_replace("\"", "\\\"", $mail_indices);
|
| 980 |
-
|
| 981 |
-
return '<script type="text/javascript">'
|
| 982 |
-
. '(function(){'
|
| 983 |
-
. 'var ml="'. $mail_letters_enc .'",mi="'. $mail_indices .'",o="";'
|
| 984 |
-
. 'for(var j=0,l=mi.length;j<l;j++){'
|
| 985 |
-
. 'o+=ml.charAt(mi.charCodeAt(j)-48);'
|
| 986 |
-
. '}document.write(o);'
|
| 987 |
-
. '}());'
|
| 988 |
-
. '</script><noscript>'
|
| 989 |
-
. $this->options['protection_text']
|
| 990 |
-
. '</noscript>';
|
| 991 |
-
}
|
| 992 |
-
|
| 993 |
-
/**
|
| 994 |
-
* Escape method
|
| 995 |
-
* Taken from the plugin "Email Spam Protection" by Adam Hunter (http://blueberryware.net/2008/09/14/email-spam-protection/)
|
| 996 |
-
*
|
| 997 |
-
* @param string $value
|
| 998 |
-
* @return string
|
| 999 |
-
*/
|
| 1000 |
-
function enc_escape($value) {
|
| 1001 |
-
$string = 'document.write(\'' . $value . '\')';
|
| 1002 |
-
|
| 1003 |
-
/* break string into array of characters, we can't use string_split because its php5 only :( */
|
| 1004 |
-
$split = preg_split('||', $string);
|
| 1005 |
-
$out = '<script type="text/javascript">' . "eval(unescape('";
|
| 1006 |
-
|
| 1007 |
-
foreach ($split as $c) {
|
| 1008 |
-
/* preg split will return empty first and last characters, check for them and ignore */
|
| 1009 |
-
if (!empty($c)) {
|
| 1010 |
-
$out .= '%' . dechex(ord($c));
|
| 1011 |
-
}
|
| 1012 |
-
}
|
| 1013 |
-
|
| 1014 |
-
$out .= "'))" . '</script><noscript>'
|
| 1015 |
-
. $this->options['protection_text']
|
| 1016 |
-
. '</noscript>';
|
| 1017 |
-
|
| 1018 |
-
return $out;
|
| 1019 |
-
}
|
| 1020 |
-
|
| 1021 |
-
/**
|
| 1022 |
-
* Convert randomly chars to htmlentities
|
| 1023 |
-
* This method is partly taken from WordPress
|
| 1024 |
-
* @link http://codex.wordpress.org/Function_Reference/antispambot
|
| 1025 |
-
*
|
| 1026 |
-
* @param string $value
|
| 1027 |
-
* @return string
|
| 1028 |
-
*/
|
| 1029 |
-
function enc_html($value) {
|
| 1030 |
-
// check for built-in WP function
|
| 1031 |
-
if (function_exists('antispambot')) {
|
| 1032 |
-
$emailNOSPAMaddy = antispambot($value);
|
| 1033 |
-
} else {
|
| 1034 |
-
$emailNOSPAMaddy = '';
|
| 1035 |
-
srand ((float) microtime() * 1000000);
|
| 1036 |
-
for ($i = 0; $i < strlen($emailaddy); $i = $i + 1) {
|
| 1037 |
-
$j = floor(rand(0, 1+$mailto));
|
| 1038 |
-
if ($j==0) {
|
| 1039 |
-
$emailNOSPAMaddy .= '&#'.ord(substr($emailaddy,$i,1)).';';
|
| 1040 |
-
} elseif ($j==1) {
|
| 1041 |
-
$emailNOSPAMaddy .= substr($emailaddy,$i,1);
|
| 1042 |
-
} elseif ($j==2) {
|
| 1043 |
-
$emailNOSPAMaddy .= '%'.zeroise(dechex(ord(substr($emailaddy, $i, 1))), 2);
|
| 1044 |
-
}
|
| 1045 |
-
}
|
| 1046 |
-
$emailNOSPAMaddy = str_replace('@','@',$emailNOSPAMaddy);
|
| 1047 |
-
}
|
| 1048 |
-
|
| 1049 |
-
$emailNOSPAMaddy = str_replace('@', '@', $emailNOSPAMaddy);
|
| 1050 |
-
|
| 1051 |
-
return $emailNOSPAMaddy;
|
| 1052 |
-
}
|
| 1053 |
-
|
| 1054 |
-
} // end class WP_Email_Encoder_Bundle
|
| 1055 |
-
|
| 1056 |
-
endif;
|
| 1057 |
-
|
| 1058 |
-
|
| 1059 |
-
/*******************************************************************************
|
| 1060 |
-
* Create instance
|
| 1061 |
-
*******************************************************************************/
|
| 1062 |
-
|
| 1063 |
-
$WP_Email_Encoder_Bundle = new WP_Email_Encoder_Bundle;
|
| 1064 |
-
|
| 1065 |
-
|
| 1066 |
-
/**
|
| 1067 |
-
* Ajax Encoding request
|
| 1068 |
-
*/
|
| 1069 |
-
if (!empty($_GET['ajaxEncodeEmail'])):
|
| 1070 |
-
// input vars
|
| 1071 |
-
$method = $_GET['method'];
|
| 1072 |
-
$email = $_GET['email'];
|
| 1073 |
-
$display = (empty($_GET['display'])) ? $email : $_GET['display'];
|
| 1074 |
-
|
| 1075 |
-
echo $WP_Email_Encoder_Bundle->encode_email($email, $display, $method, '', TRUE);
|
| 1076 |
-
exit;
|
| 1077 |
-
endif;
|
| 1078 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1079 |
|
| 1080 |
-
|
| 1081 |
-
|
| 1082 |
-
|
|
|
|
| 1083 |
|
| 1084 |
-
|
| 1085 |
-
|
| 1086 |
-
|
| 1087 |
-
|
| 1088 |
-
* @param string $display if non given will be same as email
|
| 1089 |
-
* @param string $method Optional, else the default setted method will; be used
|
| 1090 |
-
* @param string $extra_attrs Optional
|
| 1091 |
-
* @return string
|
| 1092 |
-
*/
|
| 1093 |
-
if (!function_exists('encode_email')):
|
| 1094 |
-
function encode_email($email, $display = NULL, $method = NULL, $extra_attrs = '') {
|
| 1095 |
-
global $WP_Email_Encoder_Bundle;
|
| 1096 |
-
return $WP_Email_Encoder_Bundle->encode_email($email, $display, $method, $extra_attrs);
|
| 1097 |
-
}
|
| 1098 |
-
endif;
|
| 1099 |
|
| 1100 |
-
|
| 1101 |
-
|
| 1102 |
-
|
| 1103 |
-
|
| 1104 |
-
|
| 1105 |
-
|
| 1106 |
-
|
| 1107 |
-
|
| 1108 |
-
|
| 1109 |
-
|
| 1110 |
-
|
| 1111 |
-
|
| 1112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1113 |
|
| 1114 |
-
|
| 1115 |
-
* Template function for encoding emails in the given content
|
| 1116 |
-
* @global WP_Email_Encoder $WP_Email_Encoder_Bundle
|
| 1117 |
-
* @param string $content
|
| 1118 |
-
* @param boolean $enc_tags Optional, default TRUE
|
| 1119 |
-
* @param boolean $enc_mailtos Optional, default TRUE
|
| 1120 |
-
* @param boolean $enc_plain_emails Optional, default TRUE
|
| 1121 |
-
* @return string
|
| 1122 |
-
*/
|
| 1123 |
-
if (!function_exists('encode_email_filter')):
|
| 1124 |
-
function encode_email_filter($content, $enc_tags = TRUE, $enc_mailtos = TRUE, $enc_plain_emails = TRUE) {
|
| 1125 |
-
global $WP_Email_Encoder_Bundle;
|
| 1126 |
-
return $WP_Email_Encoder_Bundle->encode_email_filter($content, $enc_tags, $enc_mailtos, $enc_plain_emails);
|
| 1127 |
-
}
|
| 1128 |
-
endif;
|
| 1129 |
|
| 1130 |
-
|
| 1 |
+
<?php defined('ABSPATH') OR die('No direct access.');
|
| 2 |
/*
|
| 3 |
Plugin Name: Email Encoder Bundle
|
| 4 |
Plugin URI: http://www.freelancephp.net/email-encoder-php-class-wp-plugin/
|
| 5 |
Description: Protect email addresses on your site and hide them from spambots by using an encoding method. Easy to use, flexible .
|
| 6 |
Author: Victor Villaverde Laan
|
| 7 |
+
Version: 1.0.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 |
+
// plugin file
|
| 15 |
+
if (!defined('EMAIL_ENCODER_BUNDLE_FILE')) {
|
| 16 |
+
define('EMAIL_ENCODER_BUNDLE_FILE', __FILE__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
// plugin version
|
| 20 |
+
if (!defined('EMAIL_ENCODER_BUNDLE_VERSION')) {
|
| 21 |
+
define('EMAIL_ENCODER_BUNDLE_VERSION', '1.0.0');
|
| 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 |
+
AND version_compare(preg_replace('/-.*$/', '', $wp_version), '3.4', '>=')
|
| 37 |
+
AND version_compare(phpversion(), '5.3.13', '>=')) {
|
| 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 |
+
$EebSite = new EebSite;
|
| 52 |
+
|
| 53 |
+
// handle AJAX request
|
| 54 |
+
if (!empty($_GET['ajaxEncodeEmail'])):
|
| 55 |
+
// input vars
|
| 56 |
+
$method = $_GET['method'];
|
| 57 |
+
$email = $_GET['email'];
|
| 58 |
+
$display = (empty($_GET['display'])) ? $email : $_GET['display'];
|
| 59 |
+
|
| 60 |
+
echo $EebSite->encode_email($email, $display, '', $method, TRUE);
|
| 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>Email Encoder Bundle</strong> requires PHP 5.4+ and WP 3.4+.'
|
| 71 |
+
. ' Please upgrade your PHP and/or WordPress. '
|
| 72 |
+
. '<br/>Disable the plugin to remove this message.</p>', EMAIL_ENCODER_BUNDLE_DOMAIN)
|
| 73 |
+
. '</div>';
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
add_action('admin_notices', 'eeb_error_notice');
|
| 77 |
+
endif;
|
| 78 |
|
| 79 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
+
/* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
|
includes/class-eeb-admin.php
ADDED
|
@@ -0,0 +1,834 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php defined('ABSPATH') OR die('No direct access.');
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Class Eeb_Admin
|
| 5 |
+
*
|
| 6 |
+
* @description Contains all code nescessary for the Admin part
|
| 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,
|
| 37 |
+
'filter_posts' => 1,
|
| 38 |
+
'filter_widgets' => 1,
|
| 39 |
+
'filter_comments' => 1,
|
| 40 |
+
'skip_posts' => '',
|
| 41 |
+
'protection_text' => '*protected email*',
|
| 42 |
+
'class_name' => 'mailto-link',
|
| 43 |
+
'filter_rss' => 1,
|
| 44 |
+
'remove_shortcodes_rss' => 1,
|
| 45 |
+
'protection_text_rss' => '*protected email*',
|
| 46 |
+
'widget_logic_filter' => 0,
|
| 47 |
+
'show_encoded_check' => 0,
|
| 48 |
+
'shortcodes_in_widgets' => 0,
|
| 49 |
+
'support_deprecated_names' => 0,
|
| 50 |
+
'own_admin_menu' => 1,
|
| 51 |
+
'powered_by' => 1,
|
| 52 |
+
);
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* @var array
|
| 56 |
+
*/
|
| 57 |
+
protected $options = array();
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* @var array
|
| 61 |
+
*/
|
| 62 |
+
protected $skip_posts = array();
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* @var string
|
| 66 |
+
*/
|
| 67 |
+
protected $method = 'enc_ascii';
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* @var array
|
| 71 |
+
*/
|
| 72 |
+
private $methods = array();
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* Constructor
|
| 76 |
+
*/
|
| 77 |
+
public function __construct() {
|
| 78 |
+
// load text domain for translations
|
| 79 |
+
load_plugin_textdomain(EMAIL_ENCODER_BUNDLE_KEY, FALSE, dirname(plugin_basename(EMAIL_ENCODER_BUNDLE_FILE)) . '/languages/');
|
| 80 |
+
|
| 81 |
+
// set methods
|
| 82 |
+
$this->methods = array(
|
| 83 |
+
'enc_ascii' => array(
|
| 84 |
+
'name' => __('JS Rot13', EMAIL_ENCODER_BUNDLE_DOMAIN),
|
| 85 |
+
'description' => __('Recommended, the savest method using a rot13 method in JavaScript.', EMAIL_ENCODER_BUNDLE_DOMAIN),
|
| 86 |
+
),
|
| 87 |
+
'enc_escape' => array(
|
| 88 |
+
'name' => __('JS Escape', EMAIL_ENCODER_BUNDLE_DOMAIN),
|
| 89 |
+
'description' => __('Pretty save method using JavaScipt\'s escape function.', EMAIL_ENCODER_BUNDLE_DOMAIN),
|
| 90 |
+
),
|
| 91 |
+
'enc_html' => array(
|
| 92 |
+
'name' => __('Html Encode', EMAIL_ENCODER_BUNDLE_DOMAIN),
|
| 93 |
+
'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),
|
| 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 |
+
|
| 103 |
+
// prepare vars
|
| 104 |
+
$skip_posts = $this->options['skip_posts'];
|
| 105 |
+
$skip_posts = str_replace(' ', '', $skip_posts);
|
| 106 |
+
$skip_posts = explode(',', $skip_posts);
|
| 107 |
+
$this->skip_posts = $skip_posts;
|
| 108 |
+
|
| 109 |
+
// set uninstall hook
|
| 110 |
+
register_uninstall_hook(EMAIL_ENCODER_BUNDLE_FILE, array('Eeb_Admin', 'uninstall'));
|
| 111 |
+
|
| 112 |
+
// add actions
|
| 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 |
+
$previous_version = get_option('eeb_version');
|
| 123 |
+
$upgrade = FALSE;
|
| 124 |
+
|
| 125 |
+
// first set defaults
|
| 126 |
+
$this->options = $this->default_options;
|
| 127 |
+
|
| 128 |
+
// get saved options
|
| 129 |
+
$saved_options = get_option($this->options_name);
|
| 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 = TRUE;
|
| 139 |
+
|
| 140 |
+
foreach ($saved_options AS $key => $value) {
|
| 141 |
+
$this->options[$key] = $value;
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
if ($previous_version != EMAIL_ENCODER_BUNDLE_VERSION) {
|
| 146 |
+
if (empty($previous_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($this->options_name, $this->options);
|
| 153 |
+
} else {
|
| 154 |
+
// first time
|
| 155 |
+
|
| 156 |
+
}
|
| 157 |
+
} else {
|
| 158 |
+
// upgrading from version >= 1.0.0
|
| 159 |
+
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
// update version
|
| 163 |
+
update_option('eeb_version', EMAIL_ENCODER_BUNDLE_VERSION);
|
| 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) AND 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 |
+
public static function uninstall() {
|
| 196 |
+
delete_option($this->options_name);
|
| 197 |
+
unregister_setting(EMAIL_ENCODER_BUNDLE_KEY, $this->options_name);
|
| 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 |
+
/**
|
| 209 |
+
* Callbacka admin_init
|
| 210 |
+
*/
|
| 211 |
+
public function admin_init() {
|
| 212 |
+
// register settings
|
| 213 |
+
register_setting(EMAIL_ENCODER_BUNDLE_KEY, $this->options_name);
|
| 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 |
+
|
| 220 |
+
/**
|
| 221 |
+
* Callback add links on plugin page
|
| 222 |
+
* @param array $links
|
| 223 |
+
* @param string $file
|
| 224 |
+
* @return array
|
| 225 |
+
*/
|
| 226 |
+
public function plugin_action_links($links, $file) {
|
| 227 |
+
if ($file == plugin_basename(EMAIL_ENCODER_BUNDLE_FILE)) {
|
| 228 |
+
$settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/options-general.php?page=' . $file . '">' . __('Settings', EMAIL_ENCODER_BUNDLE_DOMAIN) . '</a>';
|
| 229 |
+
array_unshift($links, $settings_link);
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
return $links;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
/**
|
| 236 |
+
* Callback admin_enqueue_scripts
|
| 237 |
+
* @param string $hook_suffix
|
| 238 |
+
*/
|
| 239 |
+
public function admin_enqueue_scripts($hook_suffix) {
|
| 240 |
+
global $wp_version;
|
| 241 |
+
|
| 242 |
+
if ($hook_suffix == $this->page_hook || $hook_suffix == 'toplevel_page_email-encoder-bundle/email-encoder-bundle') {
|
| 243 |
+
// set dashboard postbox
|
| 244 |
+
wp_enqueue_script('dashboard');
|
| 245 |
+
|
| 246 |
+
// add script for ajax encoder
|
| 247 |
+
// wp_enqueue_script('email_encoder', plugins_url('js/src/email-encoder-bundle.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
|
| 248 |
+
// 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);
|
| 249 |
+
wp_enqueue_script('email_encoder', plugins_url('js/email-encoder-bundle.min.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
|
| 250 |
+
}
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
/**
|
| 254 |
+
* Callback admin_menu
|
| 255 |
+
*/
|
| 256 |
+
public function admin_menu() {
|
| 257 |
+
if ($this->is_admin_user) {
|
| 258 |
+
return;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
// add page and menu item
|
| 262 |
+
if ($this->options['own_admin_menu']) {
|
| 263 |
+
// create main menu item
|
| 264 |
+
$this->page_hook = add_menu_page(__('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN), __('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN),
|
| 265 |
+
'manage_options', 'email-encoder-bundle-settings', array($this, 'show_options_page'),
|
| 266 |
+
plugins_url('images/icon-email-encoder-bundle-16.png', EMAIL_ENCODER_BUNDLE_FILE));
|
| 267 |
+
} else {
|
| 268 |
+
// create submenu item under "Settings"
|
| 269 |
+
$this->page_hook = add_submenu_page('options-general.php', __('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN), __('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN),
|
| 270 |
+
'manage_options', 'email-encoder-bundle-settings', array($this, 'show_options_page'));
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
// load plugin page
|
| 274 |
+
add_action('load-' . $this->page_hook, array($this, 'load_options_page'));
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
/* -------------------------------------------------------------------------
|
| 278 |
+
* Admin Options Page
|
| 279 |
+
* ------------------------------------------------------------------------*/
|
| 280 |
+
|
| 281 |
+
/**
|
| 282 |
+
* Load admin options page
|
| 283 |
+
*/
|
| 284 |
+
public function load_options_page() {
|
| 285 |
+
// add help tabs
|
| 286 |
+
$this->add_help_tabs();
|
| 287 |
+
|
| 288 |
+
// screen settings
|
| 289 |
+
if (function_exists('add_screen_option')) {
|
| 290 |
+
add_screen_option('layout_columns', array(
|
| 291 |
+
'max' => 2,
|
| 292 |
+
'default' => 2
|
| 293 |
+
));
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
// add meta boxes
|
| 297 |
+
add_meta_box('general_settings', __('General Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), NULL, 'normal', 'core', array('general_settings'));
|
| 298 |
+
add_meta_box('advanced_settings', __('Advanced Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), NULL, 'normal', 'core', array('advanced_settings'));
|
| 299 |
+
add_meta_box('admin_settings', __('Admin Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), NULL, 'normal', 'core', array('admin_settings'));
|
| 300 |
+
add_meta_box('encode_form', __('Email Encoder Form', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), NULL, 'normal', 'core', array('encode_form'));
|
| 301 |
+
add_meta_box('this_plugin', __('Support', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), NULL, 'side', 'core', array('this_plugin'));
|
| 302 |
+
add_meta_box('other_plugins', __('Other Plugins', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), NULL, 'side', 'core', array('other_plugins'));
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
/**
|
| 306 |
+
* Show admin options page
|
| 307 |
+
*/
|
| 308 |
+
public function show_options_page() {
|
| 309 |
+
$this->set_options();
|
| 310 |
+
?>
|
| 311 |
+
<div class="wrap">
|
| 312 |
+
<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>
|
| 313 |
+
<h2><?php echo get_admin_page_title() ?> - <em><small><?php _e('Protecting Your Email Addresses', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></small></em></h2>
|
| 314 |
+
|
| 315 |
+
<?php if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' && $this->options['own_admin_menu']): ?>
|
| 316 |
+
<div class="updated settings-error" id="setting-error-settings_updated">
|
| 317 |
+
<p><strong><?php _e('Settings saved.' ) ?></strong></p>
|
| 318 |
+
</div>
|
| 319 |
+
<?php endif; ?>
|
| 320 |
+
|
| 321 |
+
<form method="post" action="options.php">
|
| 322 |
+
<?php settings_fields(EMAIL_ENCODER_BUNDLE_KEY); ?>
|
| 323 |
+
|
| 324 |
+
<input type="hidden" name="<?php echo EMAIL_ENCODER_BUNDLE_KEY ?>_nonce" value="<?php echo wp_create_nonce(EMAIL_ENCODER_BUNDLE_KEY) ?>" />
|
| 325 |
+
<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', FALSE); ?>
|
| 326 |
+
<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', FALSE); ?>
|
| 327 |
+
|
| 328 |
+
<div id="poststuff">
|
| 329 |
+
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
|
| 330 |
+
<!--<div id="post-body-content"></div>-->
|
| 331 |
+
|
| 332 |
+
<div id="postbox-container-1" class="postbox-container">
|
| 333 |
+
<?php do_meta_boxes('', 'side', ''); ?>
|
| 334 |
+
</div>
|
| 335 |
+
|
| 336 |
+
<div id="postbox-container-2" class="postbox-container">
|
| 337 |
+
<?php do_meta_boxes('', 'normal', ''); ?>
|
| 338 |
+
<?php do_meta_boxes('', 'advanced', ''); ?>
|
| 339 |
+
</div>
|
| 340 |
+
</div> <!-- #post-body -->
|
| 341 |
+
</div> <!-- #poststuff -->
|
| 342 |
+
</form>
|
| 343 |
+
</div>
|
| 344 |
+
<?php
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
/**
|
| 348 |
+
* Show content of metabox (callback)
|
| 349 |
+
* @param array $post
|
| 350 |
+
* @param array $meta_box
|
| 351 |
+
*/
|
| 352 |
+
public function show_meta_box_content($post, $meta_box) {
|
| 353 |
+
$key = $meta_box['args'][0];
|
| 354 |
+
$options = $this->options;
|
| 355 |
+
|
| 356 |
+
if ($key === 'general_settings') {
|
| 357 |
+
?>
|
| 358 |
+
<?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php')): ?>
|
| 359 |
+
<p class="description"><?php _e('Warning: "WP Mailto Links"-plugin is also activated, which could cause conflicts.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></p>
|
| 360 |
+
<?php endif; ?>
|
| 361 |
+
<fieldset class="options">
|
| 362 |
+
<table class="form-table">
|
| 363 |
+
<tr>
|
| 364 |
+
<th><?php _e('Choose protection method', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 365 |
+
<td>
|
| 366 |
+
<?php foreach ($this->methods AS $method => $info): ?>
|
| 367 |
+
<label>
|
| 368 |
+
<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"' ?> />
|
| 369 |
+
<span><?php echo $info['name'] ?></span>
|
| 370 |
+
- <span class="description"><?php echo $info['description'] ?></span>
|
| 371 |
+
</label>
|
| 372 |
+
<br/>
|
| 373 |
+
<?php endforeach; ?>
|
| 374 |
+
</td>
|
| 375 |
+
</tr>
|
| 376 |
+
<tr>
|
| 377 |
+
<th><?php _e('Choose what to protect', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 378 |
+
<td>
|
| 379 |
+
<label><input type="checkbox" id="encode_mailtos" name="<?php echo $this->options_name ?>[encode_mailtos]" value="1" <?php checked('1', (int) $options['encode_mailtos']); ?> />
|
| 380 |
+
<span><?php _e('Protect mailto links, like f.e. <code><a href="info@myemail.com">My Email</a></code>', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 381 |
+
<br/><label><input type="checkbox" id="encode_emails" name="<?php echo $this->options_name ?>[encode_emails]" value="1" <?php checked('1', (int) $options['encode_emails']); ?> disabled="disabled" />
|
| 382 |
+
<span><?php _e('Replace plain email addresses to protected mailto links.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 383 |
+
<span class="description notice-form-field-bug"><br/><?php _e('Notice: be carefull with this option when using emailaddresses 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>
|
| 384 |
+
</label>
|
| 385 |
+
<br/>
|
| 386 |
+
</td>
|
| 387 |
+
</tr>
|
| 388 |
+
<tr>
|
| 389 |
+
<th><?php _e('Apply on...', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 390 |
+
<td>
|
| 391 |
+
<label><input type="checkbox" name="<?php echo $this->options_name ?>[filter_posts]" value="1" <?php checked('1', (int) $options['filter_posts']); ?> />
|
| 392 |
+
<span><?php _e('All posts', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 393 |
+
</label>
|
| 394 |
+
<br/><label><input type="checkbox" id="<?php echo $this->options_name ?>[filter_comments]" name="<?php echo $this->options_name ?>[filter_comments]" value="1" <?php checked('1', (int) $options['filter_comments']); ?> />
|
| 395 |
+
<span><?php _e('All comments', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
|
| 396 |
+
<br/><label><input type="checkbox" id="<?php echo $this->options_name ?>[filter_widgets]" name="<?php echo $this->options_name ?>[filter_widgets]" value="1" <?php checked('1', (int) $options['filter_widgets']); ?> />
|
| 397 |
+
<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>
|
| 398 |
+
</td>
|
| 399 |
+
</tr>
|
| 400 |
+
<tr>
|
| 401 |
+
<th><?php _e('Set <code><noscript></code> text', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 402 |
+
<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']; ?>" />
|
| 403 |
+
<br/><span class="description"><?php _e('Used for the <code><noscript></code> fallback for JavaScrip methods.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 404 |
+
</label>
|
| 405 |
+
</td>
|
| 406 |
+
</tr>
|
| 407 |
+
<tr>
|
| 408 |
+
<th><?php _e('Add class to protected mailto links', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 409 |
+
<td><label><input type="text" id="<?php echo $this->options_name ?>[class_name]" class="regular-text" name="<?php echo $this->options_name ?>[class_name]" value="<?php echo $options['class_name']; ?>" />
|
| 410 |
+
<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>
|
| 411 |
+
</tr>
|
| 412 |
+
<tr>
|
| 413 |
+
<th><?php _e('Exclude posts', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 414 |
+
<td>
|
| 415 |
+
<label>
|
| 416 |
+
<span><?php _e('Do <strong>not</strong> apply protection on posts or pages with the folllowing ID:', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 417 |
+
<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']; ?>" />
|
| 418 |
+
<br/><span class="description"><?php _e('Seperate Id\'s by comma, f.e.: 2, 7, 13, 32.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 419 |
+
<br/><span class="description"><?php _e('Notice: shortcodes still work on these posts.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 420 |
+
</label>
|
| 421 |
+
</td>
|
| 422 |
+
</tr>
|
| 423 |
+
</table>
|
| 424 |
+
</fieldset>
|
| 425 |
+
|
| 426 |
+
<p class="submit">
|
| 427 |
+
<input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
|
| 428 |
+
</p>
|
| 429 |
+
<br class="clear" />
|
| 430 |
+
|
| 431 |
+
<?php
|
| 432 |
+
} else if ($key === 'advanced_settings') {
|
| 433 |
+
?>
|
| 434 |
+
<fieldset class="options">
|
| 435 |
+
<h4><?php _e('Protect RSS feed', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></h4>
|
| 436 |
+
|
| 437 |
+
<table class="form-table">
|
| 438 |
+
<tr>
|
| 439 |
+
<th><?php _e('Protect emails in RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 440 |
+
<td><label><input type="checkbox" id="filter_rss" name="<?php echo $this->options_name ?>[filter_rss]" value="1" <?php checked('1', (int) $options['filter_rss']); ?> />
|
| 441 |
+
<span><?php _e('Replace emails in RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
|
| 442 |
+
</td>
|
| 443 |
+
</tr>
|
| 444 |
+
<tr>
|
| 445 |
+
<th><?php _e('Remove shortcodes from RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 446 |
+
<td><label><input type="checkbox" id="remove_shortcodes_rss" name="<?php echo $this->options_name ?>[remove_shortcodes_rss]" value="1" <?php checked('1', (int) $options['remove_shortcodes_rss']); ?> />
|
| 447 |
+
<span><?php _e('Remove all shortcodes from the RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
|
| 448 |
+
</td>
|
| 449 |
+
</tr>
|
| 450 |
+
<tr>
|
| 451 |
+
<th><?php _e('Set protection text in RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 452 |
+
<td><label><input type="text" id="protection_text" class="regular-text" name="<?php echo $this->options_name ?>[protection_text_rss]" value="<?php echo $options['protection_text_rss']; ?>" />
|
| 453 |
+
<br/><span class="description"><?php _e('Used as replacement for emailaddresses in RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 454 |
+
</label>
|
| 455 |
+
</td>
|
| 456 |
+
</tr>
|
| 457 |
+
</table>
|
| 458 |
+
|
| 459 |
+
<h4><?php _e('Extra Settings', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></h4>
|
| 460 |
+
|
| 461 |
+
|
| 462 |
+
<table class="form-table">
|
| 463 |
+
<tr>
|
| 464 |
+
<th><?php _e('Use shortcodes in widgets', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 465 |
+
<td>
|
| 466 |
+
<label><input type="checkbox" name="<?php echo $this->options_name ?>[shortcodes_in_widgets]" value="1" <?php checked('1', (int) $options['shortcodes_in_widgets']); ?> />
|
| 467 |
+
<span><?php _e('Also use shortcodes in widgets.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 468 |
+
<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>
|
| 469 |
+
</label>
|
| 470 |
+
</td>
|
| 471 |
+
</tr>
|
| 472 |
+
<tr>
|
| 473 |
+
<th><?php _e('Use deprecated names', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 474 |
+
<td><label><input type="checkbox" id="<?php echo $this->options_name ?>[support_deprecated_names]" name="<?php echo $this->options_name ?>[support_deprecated_names]" value="1" <?php checked('1', (int) $options['support_deprecated_names']); ?> />
|
| 475 |
+
<span><?php _e('Keep supporting the old names for action, shortcodes and template functions.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 476 |
+
<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>
|
| 477 |
+
</tr>
|
| 478 |
+
</table>
|
| 479 |
+
</fieldset>
|
| 480 |
+
|
| 481 |
+
<p class="submit">
|
| 482 |
+
<input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
|
| 483 |
+
</p>
|
| 484 |
+
<br class="clear" />
|
| 485 |
+
<?php
|
| 486 |
+
} else if ($key === 'admin_settings') {
|
| 487 |
+
?>
|
| 488 |
+
<fieldset class="options">
|
| 489 |
+
<h4><?php _e('Testing', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></h4>
|
| 490 |
+
|
| 491 |
+
<table class="form-table">
|
| 492 |
+
<tr>
|
| 493 |
+
<th><?php _e('Check "succesfully encoded"', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 494 |
+
<td><label><input type="checkbox" id="<?php echo $this->options_name ?>[show_encoded_check]" name="<?php echo $this->options_name ?>[show_encoded_check]" value="1" <?php checked('1', (int) $options['show_encoded_check']); ?> />
|
| 495 |
+
<span><?php _e('Show "successfully encoded" text for all encoded content, only when logged in as admin user.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 496 |
+
<br/><span class="description"><?php _e('This way you can check if emails are really encoded on your site.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 497 |
+
</label>
|
| 498 |
+
</td>
|
| 499 |
+
</tr>
|
| 500 |
+
</table>
|
| 501 |
+
|
| 502 |
+
<h4><?php _e('Menu', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></h4>
|
| 503 |
+
|
| 504 |
+
<table class="form-table">
|
| 505 |
+
<tr>
|
| 506 |
+
<th><?php _e('Choose admin menu position', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 507 |
+
<td><label><input type="checkbox" id="<?php echo $this->options_name ?>[own_admin_menu]" name="<?php echo $this->options_name ?>[own_admin_menu]" value="1" <?php checked('1', (int) $options['own_admin_menu']); ?> />
|
| 508 |
+
<span><?php _e('Show as main menu item.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 509 |
+
<br /><span class="description">When disabled this page will be available under "General settings".</span>
|
| 510 |
+
</label>
|
| 511 |
+
</td>
|
| 512 |
+
</tr>
|
| 513 |
+
</table>
|
| 514 |
+
</fieldset>
|
| 515 |
+
|
| 516 |
+
<p class="submit">
|
| 517 |
+
<input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
|
| 518 |
+
</p>
|
| 519 |
+
|
| 520 |
+
<br class="clear" />
|
| 521 |
+
<?php
|
| 522 |
+
} else if ($key === 'encode_form') {
|
| 523 |
+
?>
|
| 524 |
+
<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>
|
| 525 |
+
|
| 526 |
+
<h4><?php _e('Encoder Form', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></h4>
|
| 527 |
+
|
| 528 |
+
<hr style="border:1px solid #FFF; border-top:1px solid #EEE;" />
|
| 529 |
+
|
| 530 |
+
<?php echo $this->get_encoder_form(); ?>
|
| 531 |
+
|
| 532 |
+
<hr style="border:1px solid #FFF; border-top:1px solid #EEE;"/>
|
| 533 |
+
|
| 534 |
+
<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>
|
| 535 |
+
|
| 536 |
+
<h4><?php _e('Settings') ?></h4>
|
| 537 |
+
|
| 538 |
+
<fieldset class="options">
|
| 539 |
+
<table class="form-table">
|
| 540 |
+
<tr>
|
| 541 |
+
<th><?php _e('Show "powered by"', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
|
| 542 |
+
<td><label><input type="checkbox" id="<?php echo $this->options_name ?>[powered_by]" name="<?php echo $this->options_name ?>[powered_by]" value="1" <?php checked('1', (int) $options['powered_by']); ?> />
|
| 543 |
+
<span><?php _e('Show the "powered by"-link on bottom of the encoder form', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
|
| 544 |
+
</label>
|
| 545 |
+
</td>
|
| 546 |
+
</tr>
|
| 547 |
+
</table>
|
| 548 |
+
</fieldset>
|
| 549 |
+
|
| 550 |
+
<p class="submit">
|
| 551 |
+
<input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
|
| 552 |
+
</p>
|
| 553 |
+
<br class="clear" />
|
| 554 |
+
|
| 555 |
+
<?php
|
| 556 |
+
} else if ($key === 'this_plugin') {
|
| 557 |
+
?>
|
| 558 |
+
<ul>
|
| 559 |
+
<li><a href="#" class="eeb-help-link"><?php _e('Documentation', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a></li>
|
| 560 |
+
<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>
|
| 561 |
+
</ul>
|
| 562 |
+
|
| 563 |
+
<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>
|
| 564 |
+
<?php
|
| 565 |
+
} else if ($key === 'other_plugins') {
|
| 566 |
+
?>
|
| 567 |
+
<h4><img src="<?php echo plugins_url('images/icon-wp-external-links.png', EMAIL_ENCODER_BUNDLE_FILE) ?>" width="16" height="16" /> WP External Links -
|
| 568 |
+
<?php if (is_plugin_active('wp-external-links/wp-external-links.php')): ?>
|
| 569 |
+
<a href="<?php echo get_bloginfo('url') ?>/wp-admin/options-general.php?page=wp-external-links/wp-external-links.php"><?php _e('Settings') ?></a>
|
| 570 |
+
<?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-external-links/wp-external-links.php')): ?>
|
| 571 |
+
<a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a>
|
| 572 |
+
<?php else: ?>
|
| 573 |
+
<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>
|
| 574 |
+
<?php endif; ?>
|
| 575 |
+
</h4>
|
| 576 |
+
<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) ?>
|
| 577 |
+
<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>
|
| 578 |
+
</p>
|
| 579 |
+
|
| 580 |
+
<h4><img src="<?php echo plugins_url('images/icon-wp-mailto-links.png', EMAIL_ENCODER_BUNDLE_FILE) ?>" width="16" height="16" /> WP Mailto Links -
|
| 581 |
+
<?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php')): ?>
|
| 582 |
+
<a href="<?php echo get_bloginfo('url') ?>/wp-admin/options-general.php?page=wp-mailto-links/wp-mailto-links.php"><?php _e('Settings') ?></a>
|
| 583 |
+
<?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-mailto-links/wp-mailto-links.php')): ?>
|
| 584 |
+
<a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a>
|
| 585 |
+
<?php else: ?>
|
| 586 |
+
<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>
|
| 587 |
+
<?php endif; ?>
|
| 588 |
+
</h4>
|
| 589 |
+
<p><?php _e('Manage mailto links on your site and protect emails from spambots, set mail icon and more.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?>
|
| 590 |
+
<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>
|
| 591 |
+
</p>
|
| 592 |
+
<?php
|
| 593 |
+
}
|
| 594 |
+
}
|
| 595 |
+
|
| 596 |
+
/* -------------------------------------------------------------------------
|
| 597 |
+
* Help Tabs
|
| 598 |
+
* ------------------------------------------------------------------------*/
|
| 599 |
+
|
| 600 |
+
/**
|
| 601 |
+
* Add help tabs
|
| 602 |
+
*/
|
| 603 |
+
public function add_help_tabs() {
|
| 604 |
+
if (!function_exists('get_current_screen')) {
|
| 605 |
+
return;
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
$screen = get_current_screen();
|
| 609 |
+
|
| 610 |
+
$screen->set_help_sidebar($this->get_help_text('sidebar'));
|
| 611 |
+
|
| 612 |
+
$screen->add_help_tab(array(
|
| 613 |
+
'id' => 'general',
|
| 614 |
+
'title' => __('General', EMAIL_ENCODER_BUNDLE_DOMAIN),
|
| 615 |
+
'content' => $this->get_help_text('general'),
|
| 616 |
+
));
|
| 617 |
+
$screen->add_help_tab(array(
|
| 618 |
+
'id' => 'shortcodes',
|
| 619 |
+
'title' => __('Shortcodes', EMAIL_ENCODER_BUNDLE_DOMAIN),
|
| 620 |
+
'content' => $this->get_help_text('shortcodes'),
|
| 621 |
+
));
|
| 622 |
+
$screen->add_help_tab(array(
|
| 623 |
+
'id' => 'templatefunctions',
|
| 624 |
+
'title' => __('Template functions', EMAIL_ENCODER_BUNDLE_DOMAIN),
|
| 625 |
+
'content' => $this->get_help_text('templatefunctions'),
|
| 626 |
+
));
|
| 627 |
+
$screen->add_help_tab(array(
|
| 628 |
+
'id' => 'hooks',
|
| 629 |
+
'title' => __('Action hook', EMAIL_ENCODER_BUNDLE_DOMAIN),
|
| 630 |
+
'content' => $this->get_help_text('hooks'),
|
| 631 |
+
));
|
| 632 |
+
$screen->add_help_tab(array(
|
| 633 |
+
'id' => 'faq',
|
| 634 |
+
'title' => __('FAQ', EMAIL_ENCODER_BUNDLE_DOMAIN),
|
| 635 |
+
'content' => $this->get_help_text('faq'),
|
| 636 |
+
));
|
| 637 |
+
}
|
| 638 |
+
|
| 639 |
+
/**
|
| 640 |
+
* Get text for given help tab
|
| 641 |
+
* @param string $key
|
| 642 |
+
* @return string
|
| 643 |
+
*/
|
| 644 |
+
private function get_help_text($key) {
|
| 645 |
+
if ($key === 'general') {
|
| 646 |
+
$plugin_title = get_admin_page_title();
|
| 647 |
+
$icon_url = plugins_url('images/icon-email-encoder-bundle.png', EMAIL_ENCODER_BUNDLE_FILE);
|
| 648 |
+
$version = EMAIL_ENCODER_BUNDLE_VERSION;
|
| 649 |
+
|
| 650 |
+
$content = sprintf(__('<h3><img src="%s" width="16" height="16" /> %s - version %s</h3>'
|
| 651 |
+
. '<p>Encode mailto links and (plain) email addresses on your site and hide them from spambots. Easy to use, plugin works directly when activated.</p>'
|
| 652 |
+
. '<h4>Features</h4>'
|
| 653 |
+
. '<ul>'
|
| 654 |
+
. '<li>Protect mailto links and plain emailaddresses</li>'
|
| 655 |
+
. '<li>Automatically or with shortcodes</li>'
|
| 656 |
+
. '<li>Scan posts, widgets and comments</li>'
|
| 657 |
+
. '<li>Also protect RSS feeds</li>'
|
| 658 |
+
. '</ul>'
|
| 659 |
+
. '<h4>Some extra features</h4>'
|
| 660 |
+
. '<ul>'
|
| 661 |
+
. '<li>Template functions</li>'
|
| 662 |
+
. '<li>Encode all kind of text</li>'
|
| 663 |
+
. '<li>Manually create protected links with the Encoder Form</li>'
|
| 664 |
+
. '<li>And more...</li>'
|
| 665 |
+
. '</ul>'
|
| 666 |
+
, EMAIL_ENCODER_BUNDLE_DOMAIN), $icon_url, $plugin_title, $version);
|
| 667 |
+
} else if ($key === 'shortcodes') {
|
| 668 |
+
$content = __('<h3>Shortcodes</h3>'
|
| 669 |
+
. '<p>You can use these shortcodes within your post or page.</p>'
|
| 670 |
+
. '<h4>eeb_email</h4>'
|
| 671 |
+
. '<p>Create an encoded mailto link:</p>'
|
| 672 |
+
. '<p><code>[eeb_email email="..." display="..."]</code></p>'
|
| 673 |
+
. '<ul>'
|
| 674 |
+
. '<li>"display" is optional or the email wil be shown as display (also protected)</li>'
|
| 675 |
+
. '<li>"extra_attrs" is optional, example: <code>extra_attrs="target=\'_blank\'"</code></li>'
|
| 676 |
+
. '<li>"method" is optional, else the method option will be used.</li>'
|
| 677 |
+
. '</ul>'
|
| 678 |
+
. '<h4>eeb_content</h4>'
|
| 679 |
+
. '<p>Encode some text:</p>'
|
| 680 |
+
. '<p><code>[eeb_content method="..."]...[/encode_content]</code></p>'
|
| 681 |
+
. '<ul>'
|
| 682 |
+
. '<li>"method" is optional, else the method option will be used.</li>'
|
| 683 |
+
. '</ul>'
|
| 684 |
+
. '<h4>eeb_form</h4>'
|
| 685 |
+
. '<p>Create an encoder form:</p>'
|
| 686 |
+
. '<p><code>[eeb_form]</code></p>'
|
| 687 |
+
, EMAIL_ENCODER_BUNDLE_DOMAIN);
|
| 688 |
+
} else if ($key === 'templatefunctions') {
|
| 689 |
+
// $content = __('<h3>Shortcodes</h3>'
|
| 690 |
+
// . ''
|
| 691 |
+
// , EMAIL_ENCODER_BUNDLE_DOMAIN);
|
| 692 |
+
$content = <<<TEMPLATEFUNCTIONS
|
| 693 |
+
<h3>Template functions</h3>
|
| 694 |
+
|
| 695 |
+
<h4>eeb_email()</h4>
|
| 696 |
+
<p>Create an encoded mailto link:</p>
|
| 697 |
+
<pre><code><?php
|
| 698 |
+
if (function_exists('eeb_email')) {
|
| 699 |
+
echo eeb_email('info@somedomain.com');
|
| 700 |
+
}
|
| 701 |
+
?></code></pre>
|
| 702 |
+
<p>You can pass a few extra optional params (in this order): <code>display</code>, <code>extra_attrs</code>, <code>method</code></p>
|
| 703 |
+
|
| 704 |
+
<h4>eeb_content()</h4>
|
| 705 |
+
<p>Encode some text:</p>
|
| 706 |
+
<pre><code><?php
|
| 707 |
+
if (function_exists('eeb_content')) {
|
| 708 |
+
echo eeb_content('Encode this text');
|
| 709 |
+
}
|
| 710 |
+
?></code></pre>
|
| 711 |
+
<p>You can pas an extra optional param: <code>method</code></p>
|
| 712 |
+
|
| 713 |
+
<h4>eeb_email_filter()</h4>
|
| 714 |
+
<p>Filter given content and encode all emailaddresses or mailto links:</p>
|
| 715 |
+
<pre><code><?php
|
| 716 |
+
if (function_exists('eeb_email_filter')) {
|
| 717 |
+
echo eeb_email_filter('Some content with email like info@somedomein.com or a mailto link');
|
| 718 |
+
}
|
| 719 |
+
?></code></pre>
|
| 720 |
+
<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>
|
| 721 |
+
|
| 722 |
+
<h4>eeb_form()</h4>
|
| 723 |
+
<p>Create an encoder form:</p>
|
| 724 |
+
<pre><code><?php
|
| 725 |
+
if (function_exists('eeb_form')) {
|
| 726 |
+
echo eeb_form();
|
| 727 |
+
}
|
| 728 |
+
?></code></pre>
|
| 729 |
+
TEMPLATEFUNCTIONS;
|
| 730 |
+
} else if ($key === 'hooks') {
|
| 731 |
+
$content = __('<h3>Hooks</h3>'
|
| 732 |
+
. '<h4>eeb_ready</h4>'
|
| 733 |
+
. '<p>Add extra code on initializing this plugin, like extra filters for encoding.</p>'
|
| 734 |
+
. '<pre><code><?php' . "\n"
|
| 735 |
+
. 'add_action(\'eeb_ready\', \'extra_encode_filters\');' . "\n\n"
|
| 736 |
+
. 'function extra_encode_filters(\$eeb_object) {' . "\n"
|
| 737 |
+
. ' add_filter(\'some_filter\', array(\$eeb_object, \'callback_filter\'));' . "\n"
|
| 738 |
+
. '}' . "\n"
|
| 739 |
+
. '?></code></pre>'
|
| 740 |
+
, EMAIL_ENCODER_BUNDLE_DOMAIN);
|
| 741 |
+
} else if ($key === 'faq') {
|
| 742 |
+
$content = __('<h3>FAQ</h3>'
|
| 743 |
+
. '<p>Please check the <a href="http://wordpress.org/extend/plugins/email-encoder-bundle/faq/" target="_blank">FAQ on the Plugin site</a>.'
|
| 744 |
+
, EMAIL_ENCODER_BUNDLE_DOMAIN);
|
| 745 |
+
} else if ($key === 'sidebar') {
|
| 746 |
+
$content = __('<h4>About the author</h4>'
|
| 747 |
+
. '<ul>'
|
| 748 |
+
. '<li><a href="http://www.freelancephp.net/" target="_blank">FreelancePHP.net</a></li>'
|
| 749 |
+
. '<li><a href="http://www.freelancephp.net/contact/" target="_blank">Contact</a></li>'
|
| 750 |
+
. '</ul>'
|
| 751 |
+
, EMAIL_ENCODER_BUNDLE_DOMAIN);
|
| 752 |
+
}
|
| 753 |
+
|
| 754 |
+
return ((empty($content)) ? '' : __($content, EMAIL_ENCODER_BUNDLE_DOMAIN));
|
| 755 |
+
}
|
| 756 |
+
|
| 757 |
+
/* -------------------------------------------------------------------------
|
| 758 |
+
* Encoder Form
|
| 759 |
+
* -------------------------------------------------------------------------/
|
| 760 |
+
|
| 761 |
+
/**
|
| 762 |
+
* Get the encoder form (to use as a demo, like on the options page)
|
| 763 |
+
* @return string
|
| 764 |
+
*/
|
| 765 |
+
public function get_encoder_form() {
|
| 766 |
+
$lang_email = __('Email Address:', EMAIL_ENCODER_BUNDLE_DOMAIN);
|
| 767 |
+
$lang_display = __('Display Text:', EMAIL_ENCODER_BUNDLE_DOMAIN);
|
| 768 |
+
$lang_mailto = __('Mailto Link:', EMAIL_ENCODER_BUNDLE_DOMAIN);
|
| 769 |
+
$lang_method = __('Encoding Method:', EMAIL_ENCODER_BUNDLE_DOMAIN);
|
| 770 |
+
$lang_create = __('Create Protected Mail Link >>', EMAIL_ENCODER_BUNDLE_DOMAIN);
|
| 771 |
+
$lang_output = __('Protected Mail Link (code):', EMAIL_ENCODER_BUNDLE_DOMAIN);
|
| 772 |
+
|
| 773 |
+
$method_options = '';
|
| 774 |
+
foreach ($this->methods as $method => $info) {
|
| 775 |
+
$method_options .= '<option value="' . $method . '"' . (($this->method == $method) ? ' selected="selected"' : '') . '>' . $info['name'] . '</option>';
|
| 776 |
+
}
|
| 777 |
+
|
| 778 |
+
$powered_by = '';
|
| 779 |
+
if ($this->options['powered_by']) {
|
| 780 |
+
$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>';
|
| 781 |
+
}
|
| 782 |
+
|
| 783 |
+
return <<<FORM
|
| 784 |
+
<div class="eeb-form">
|
| 785 |
+
<form>
|
| 786 |
+
<fieldset>
|
| 787 |
+
<div class="input">
|
| 788 |
+
<table>
|
| 789 |
+
<tbody>
|
| 790 |
+
<tr>
|
| 791 |
+
<th><label for="eeb-email">{$lang_email}</label></th>
|
| 792 |
+
<td><input type="text" class="regular-text" id="eeb-email" name="eeb-email" /></td>
|
| 793 |
+
</tr>
|
| 794 |
+
<tr>
|
| 795 |
+
<th><label for="eeb-display">{$lang_display}</label></th>
|
| 796 |
+
<td><input type="text" class="regular-text" id="eeb-display" name="eeb-display" /></td>
|
| 797 |
+
</tr>
|
| 798 |
+
<tr>
|
| 799 |
+
<th>{$lang_mailto}</th>
|
| 800 |
+
<td><span class="eeb-example"></span></td>
|
| 801 |
+
</tr>
|
| 802 |
+
<tr>
|
| 803 |
+
<th><label for="eeb-encode-method">{$lang_method}</label></th>
|
| 804 |
+
<td><select id="eeb-encode-method" name="eeb-encode-method" class="postform">
|
| 805 |
+
{$method_options}
|
| 806 |
+
</select>
|
| 807 |
+
<input type="button" id="eeb-ajax-encode" name="eeb-ajax-encode" value="{$lang_create}" />
|
| 808 |
+
</td>
|
| 809 |
+
</tr>
|
| 810 |
+
</tbody>
|
| 811 |
+
</table>
|
| 812 |
+
</div>
|
| 813 |
+
<div class="eeb-output">
|
| 814 |
+
<table>
|
| 815 |
+
<tbody>
|
| 816 |
+
<tr>
|
| 817 |
+
<th><label for="eeb-encoded-output">{$lang_output}</label></th>
|
| 818 |
+
<td><textarea class="large-text node" id="eeb-encoded-output" name="eeb-encoded-output" cols="50" rows="4"></textarea></td>
|
| 819 |
+
</tr>
|
| 820 |
+
</tbody>
|
| 821 |
+
</table>
|
| 822 |
+
</div>
|
| 823 |
+
{$powered_by}
|
| 824 |
+
</fieldset>
|
| 825 |
+
</form>
|
| 826 |
+
</div>
|
| 827 |
+
FORM;
|
| 828 |
+
}
|
| 829 |
+
|
| 830 |
+
} // end class Eeb_Admin
|
| 831 |
+
|
| 832 |
+
endif;
|
| 833 |
+
|
| 834 |
+
/* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
|
includes/class-eeb-site.php
ADDED
|
@@ -0,0 +1,458 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
<?php defined('ABSPATH') OR die('No direct access.');
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Class EebSite
|
| 5 |
+
*
|
| 6 |
+
* @extends Eeb_Admin
|
| 7 |
+
* @description Contains all nescessary code for the site part
|
| 8 |
+
*
|
| 9 |
+
* @package Email_Encoder_Bundle
|
| 10 |
+
* @category WordPress Plugins
|
| 11 |
+
*/
|
| 12 |
+
if (!class_exists('EebSite')):
|
| 13 |
+
|
| 14 |
+
class EebSite extends Eeb_Admin {
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Regexp
|
| 18 |
+
* @var array
|
| 19 |
+
*/
|
| 20 |
+
protected $regexp_patterns = array(
|
| 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 |
+
);
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Constructor
|
| 27 |
+
*/
|
| 28 |
+
public function __construct() {
|
| 29 |
+
parent::__construct();
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* wp action
|
| 34 |
+
*/
|
| 35 |
+
public function wp() {
|
| 36 |
+
parent::wp();
|
| 37 |
+
|
| 38 |
+
if (is_feed()) {
|
| 39 |
+
// rss feed
|
| 40 |
+
if ($this->options['filter_rss']) {
|
| 41 |
+
$rss_filters = array('the_title', 'the_content', 'the_excerpt', 'the_title_rss', 'the_content_rss', 'the_excerpt_rss',
|
| 42 |
+
'comment_text_rss', 'comment_author_rss', 'the_category_rss', 'the_content_feed', 'author_feed_link', 'feed_link');
|
| 43 |
+
|
| 44 |
+
foreach($rss_filters as $filter) {
|
| 45 |
+
add_filter($filter, array($this, 'callback_filter_rss'), 100);
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
} else {
|
| 49 |
+
// site
|
| 50 |
+
$filters = array();
|
| 51 |
+
|
| 52 |
+
// post content
|
| 53 |
+
if ($this->options['filter_posts']) {
|
| 54 |
+
array_push($filters, 'the_title', 'the_content', 'the_excerpt', 'get_the_excerpt');
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
// comments
|
| 58 |
+
if ($this->options['filter_comments']) {
|
| 59 |
+
array_push($filters, 'comment_text', 'comment_excerpt', 'comment_url', 'get_comment_author_url', 'get_comment_author_link', 'get_comment_author_url_link');
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
// widgets
|
| 63 |
+
if ($this->options['filter_widgets']) {
|
| 64 |
+
array_push($filters, 'widget_title', 'widget_text', 'widget_content');
|
| 65 |
+
|
| 66 |
+
// also replace shortcodes
|
| 67 |
+
if ($this->options['shortcodes_in_widgets']) {
|
| 68 |
+
add_filter('widget_text', 'do_shortcode', 100);
|
| 69 |
+
add_filter('widget_content', 'do_shortcode', 100); // widget_content id filter of Widget Logic plugin
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
foreach($filters as $filter) {
|
| 74 |
+
add_filter($filter, array($this, 'callback_filter'), 100);
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
// actions
|
| 79 |
+
add_action('wp_head', array($this, 'wp_head'));
|
| 80 |
+
|
| 81 |
+
// shortcodes
|
| 82 |
+
add_shortcode('eeb_form', array($this, 'shortcode_email_encoder_form'));
|
| 83 |
+
add_shortcode('eeb_email', array($this, 'shortcode_encode_email'));
|
| 84 |
+
add_shortcode('eeb_content', array($this, 'shortcode_encode_content'));
|
| 85 |
+
|
| 86 |
+
// hook
|
| 87 |
+
do_action('eeb_ready', array($this, 'callback_filter'), $this);
|
| 88 |
+
|
| 89 |
+
// support for deprecated action and shortcodes
|
| 90 |
+
if ($this->options['support_deprecated_names'] == 1) {
|
| 91 |
+
// deprecated template functions
|
| 92 |
+
require_once('deprecated.php');
|
| 93 |
+
|
| 94 |
+
// deprecated shortcodes
|
| 95 |
+
add_shortcode('email_encoder_form', array($this, 'shortcode_email_encoder_form'));
|
| 96 |
+
add_shortcode('encode_email', array($this, 'shortcode_encode_email'));
|
| 97 |
+
add_shortcode('encode_content', array($this, 'shortcode_encode_content'));
|
| 98 |
+
|
| 99 |
+
// deprecated hooks
|
| 100 |
+
do_action('init_email_encoder_bundle', array($this, 'callback_filter'), $this);
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
/**
|
| 105 |
+
* WP head
|
| 106 |
+
*/
|
| 107 |
+
public function wp_head() {
|
| 108 |
+
// add styling for encoding check message + icon
|
| 109 |
+
if ($this->is_admin_user && $this->options['show_encoded_check']) {
|
| 110 |
+
echo <<<CSS
|
| 111 |
+
<style type="text/css">
|
| 112 |
+
a.encoded-check { opacity:0.5; position:absolute; text-decoration:none !important; font:10px Arial !important; margin-top:-3px; color:#629632; font-weight:bold; }
|
| 113 |
+
a.encoded-check:hover { opacity:1; cursor:help; }
|
| 114 |
+
a.encoded-check img { width:10px; height:10px; }
|
| 115 |
+
</style>
|
| 116 |
+
CSS;
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
/* -------------------------------------------------------------------------
|
| 121 |
+
* Filter Callbacks
|
| 122 |
+
* -------------------------------------------------------------------------/
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
* WP filter callback
|
| 126 |
+
* @param string $content
|
| 127 |
+
* @return string
|
| 128 |
+
*/
|
| 129 |
+
public function callback_filter($content) {
|
| 130 |
+
global $post;
|
| 131 |
+
|
| 132 |
+
if (isset($post) && in_array($post->ID, $this->skip_posts)) {
|
| 133 |
+
return $content;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
return $this->encode_email_filter($content, TRUE, $this->options['encode_mailtos'], $this->options['encode_emails']);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* RSS Filter callback
|
| 141 |
+
* @param string $content
|
| 142 |
+
* @return string
|
| 143 |
+
*/
|
| 144 |
+
public function callback_filter_rss($content) {
|
| 145 |
+
$content = preg_replace($this->regexp_patterns, $this->options['protection_text_rss'], $content);
|
| 146 |
+
|
| 147 |
+
// strip shortcodes like [eeb_content], [eeb_form]
|
| 148 |
+
$content = strip_shortcodes($content);
|
| 149 |
+
|
| 150 |
+
return $content;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
/**
|
| 154 |
+
* Filter content for encoding
|
| 155 |
+
* @param string $content
|
| 156 |
+
* @param boolean $enc_tags Optional, default TRUE
|
| 157 |
+
* @param boolean $enc_mailtos Optional, default TRUE
|
| 158 |
+
* @param boolean $enc_plain_emails Optional, default TRUE
|
| 159 |
+
* @return string
|
| 160 |
+
*/
|
| 161 |
+
public function encode_email_filter($content, $enc_tags = TRUE, $enc_mailtos = TRUE, $enc_plain_emails = TRUE) {
|
| 162 |
+
// encode mailto links
|
| 163 |
+
if ($enc_mailtos) {
|
| 164 |
+
$content = preg_replace_callback($this->regexp_patterns['mailto'], array($this, 'callback_encode_email'), $content);
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
// replace plain emails
|
| 168 |
+
if ($enc_plain_emails) {
|
| 169 |
+
$content = preg_replace_callback($this->regexp_patterns['email'], array($this, 'callback_encode_email'), $content);
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
// workaround for double encoding bug when auto-protect mailto is enabled and method is enc_html
|
| 173 |
+
if ($this->options['encode_mailtos'] == 1) {
|
| 174 |
+
// change back to html tag
|
| 175 |
+
$content = str_replace('[a-replacement]', '<a', $content);
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
return $content;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
/**
|
| 182 |
+
* Callback for encoding email
|
| 183 |
+
* @param array $match
|
| 184 |
+
* @return string
|
| 185 |
+
*/
|
| 186 |
+
public function callback_encode_email($match) {
|
| 187 |
+
if (count($match) < 3) {
|
| 188 |
+
return $this->encode_email($match[1]);
|
| 189 |
+
} else if (count($match) == 3) {
|
| 190 |
+
return $this->encode_email($match[2]);
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
return $this->encode_email($match[2], $match[4], $match[1] . ' ' . $match[3]);
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
/* -------------------------------------------------------------------------
|
| 197 |
+
* Shortcode Functions
|
| 198 |
+
* -------------------------------------------------------------------------/
|
| 199 |
+
|
| 200 |
+
/**
|
| 201 |
+
* Shortcode showing encoder form
|
| 202 |
+
* @return string
|
| 203 |
+
*/
|
| 204 |
+
public function shortcode_email_encoder_form() {
|
| 205 |
+
// add style and script for ajax encoder
|
| 206 |
+
// wp_enqueue_script('email_encoder', plugins_url('js/src/email-encoder-bundle.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
|
| 207 |
+
wp_enqueue_script('email_encoder', plugins_url('js/email-encoder-bundle.min.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
|
| 208 |
+
|
| 209 |
+
return $this->get_encoder_form();
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
/**
|
| 213 |
+
* Shortcode encoding email
|
| 214 |
+
* @param array $attrs
|
| 215 |
+
* @return string
|
| 216 |
+
*/
|
| 217 |
+
public function shortcode_encode_email($attrs) {
|
| 218 |
+
if (!is_array($attrs) || !key_exists('email', $attrs)) {
|
| 219 |
+
return '';
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
$email = $attrs['email'];
|
| 223 |
+
$display = (key_exists('display', $attrs)) ? $attrs['display'] : $attrs['email'];
|
| 224 |
+
$method = (key_exists('method', $attrs)) ? $attrs['method'] : NULL;
|
| 225 |
+
$extra_attrs = (key_exists('extra_attrs', $attrs)) ? $attrs['extra_attrs'] : NULL;
|
| 226 |
+
|
| 227 |
+
$encoded = $this->encode_email($email, $display, $extra_attrs, $method);
|
| 228 |
+
|
| 229 |
+
// workaround for double encoding bug when auto-protect mailto is enabled and method is enc_html
|
| 230 |
+
if ($this->options['encode_mailtos'] == 1 && $method === 'enc_html') {
|
| 231 |
+
// change html tag to entity
|
| 232 |
+
$encoded = str_replace('<a', '[a-replacement]', $encoded);
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
return $encoded;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
/**
|
| 239 |
+
* Shortcode encoding content
|
| 240 |
+
* @param array $attrs
|
| 241 |
+
* @param string $content Optional
|
| 242 |
+
* @return string
|
| 243 |
+
*/
|
| 244 |
+
public function shortcode_encode_content($attrs, $content = '') {
|
| 245 |
+
$method = (is_array($attrs) && key_exists('method', $attrs)) ? $attrs['method'] : NULL;
|
| 246 |
+
|
| 247 |
+
return $this->encode_content($content, $method);
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
/* -------------------------------------------------------------------------
|
| 251 |
+
* Encode Functions
|
| 252 |
+
* -------------------------------------------------------------------------/
|
| 253 |
+
|
| 254 |
+
/**
|
| 255 |
+
* Encode the given email into an encoded HTML link
|
| 256 |
+
* @param string $content
|
| 257 |
+
* @param string $method Optional, else the default setted method will; be used
|
| 258 |
+
* @param boolean $no_html_checked
|
| 259 |
+
* @return string
|
| 260 |
+
*/
|
| 261 |
+
public function encode_content($content, $method = NULL, $no_html_checked = FALSE) {
|
| 262 |
+
// get encode method
|
| 263 |
+
$method = $this->get_method($method, $this->method);
|
| 264 |
+
|
| 265 |
+
// get encoded email code
|
| 266 |
+
$content = $this->{$method}($content);
|
| 267 |
+
|
| 268 |
+
// add visual check
|
| 269 |
+
if ($no_html_checked !== TRUE) {
|
| 270 |
+
$content = $this->get_success_check($content);
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
return $content;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
/**
|
| 277 |
+
* Encode the given email into an encoded HTML link
|
| 278 |
+
* @param string $email
|
| 279 |
+
* @param string $display Optional, if not set display will be the email
|
| 280 |
+
* @param string $extra_attrs Optional
|
| 281 |
+
* @param string $method Optional, else the default setted method will; be used
|
| 282 |
+
* @param boolean $no_html_checked
|
| 283 |
+
* @return string
|
| 284 |
+
*/
|
| 285 |
+
public function encode_email($email, $display = NULL, $extra_attrs = '', $method = NULL, $no_html_checked = FALSE) {
|
| 286 |
+
// get encode method
|
| 287 |
+
$method = $this->get_method($method, $this->method);
|
| 288 |
+
|
| 289 |
+
// decode entities
|
| 290 |
+
$email = html_entity_decode($email);
|
| 291 |
+
|
| 292 |
+
// set email as display
|
| 293 |
+
if ($display === NULL) {
|
| 294 |
+
$display = $email;
|
| 295 |
+
|
| 296 |
+
if ($method === 'enc_html') {
|
| 297 |
+
$display = $this->enc_html($display);
|
| 298 |
+
}
|
| 299 |
+
} else {
|
| 300 |
+
$display = html_entity_decode($display);
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
if ($method === 'enc_html') {
|
| 304 |
+
$email = $this->enc_html($email);
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
$class = $this->options['class_name'];
|
| 308 |
+
$extra_attrs = ' ' . trim($extra_attrs);
|
| 309 |
+
$mailto = '<a class="'. $class .'" href="mailto:' . $email . '"'. $extra_attrs . '>' . $display . '</a>';
|
| 310 |
+
|
| 311 |
+
if ($method === 'enc_html') {
|
| 312 |
+
// add visual check
|
| 313 |
+
if ($no_html_checked !== TRUE) {
|
| 314 |
+
$mailto = $this->get_success_check($mailto);
|
| 315 |
+
}
|
| 316 |
+
} else {
|
| 317 |
+
$mailto = $this->encode_content($mailto, $method, $no_html_checked);
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
// get encoded email code
|
| 321 |
+
return $mailto;
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
/**
|
| 325 |
+
* Add html to encoded content to show check icon and text
|
| 326 |
+
* @param string $content
|
| 327 |
+
* @return string
|
| 328 |
+
*/
|
| 329 |
+
private function get_success_check($content) {
|
| 330 |
+
if (!$this->is_admin_user || !$this->options['show_encoded_check']) {
|
| 331 |
+
return $content;
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
return $content
|
| 335 |
+
. '<a href="javascript:;" class="encoded-check"'
|
| 336 |
+
. ' title="' . __('Successfully Encoded (this is a check and only visible when logged in as admin)', EMAIL_ENCODER_BUNDLE_DOMAIN) . '">'
|
| 337 |
+
. '<img class="encoded-check-icon" src="' . plugins_url('images/icon-email-encoder-bundle.png', EMAIL_ENCODER_BUNDLE_FILE)
|
| 338 |
+
. '" alt="' . __('Encoded', EMAIL_ENCODER_BUNDLE_DOMAIN) . '" />'
|
| 339 |
+
. __('Successfully Encoded', EMAIL_ENCODER_BUNDLE_DOMAIN) . '</a>';
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
/* -------------------------------------------------------------------------
|
| 343 |
+
* Different Encoding Methods
|
| 344 |
+
* -------------------------------------------------------------------------/
|
| 345 |
+
|
| 346 |
+
/**
|
| 347 |
+
* ASCII method
|
| 348 |
+
* Based on function from Tyler Akins (http://rumkin.com/tools/mailto_encoder/)
|
| 349 |
+
*
|
| 350 |
+
* @param string $value
|
| 351 |
+
* @return string
|
| 352 |
+
*/
|
| 353 |
+
private function enc_ascii($value) {
|
| 354 |
+
$mail_link = $value;
|
| 355 |
+
|
| 356 |
+
$mail_letters = '';
|
| 357 |
+
|
| 358 |
+
for ($i = 0; $i < strlen($mail_link); $i ++) {
|
| 359 |
+
$l = substr($mail_link, $i, 1);
|
| 360 |
+
|
| 361 |
+
if (strpos($mail_letters, $l) === FALSE) {
|
| 362 |
+
$p = rand(0, strlen($mail_letters));
|
| 363 |
+
$mail_letters = substr($mail_letters, 0, $p) .
|
| 364 |
+
$l . substr($mail_letters, $p, strlen($mail_letters));
|
| 365 |
+
}
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
$mail_letters_enc = str_replace("\\", "\\\\", $mail_letters);
|
| 369 |
+
$mail_letters_enc = str_replace("\"", "\\\"", $mail_letters_enc);
|
| 370 |
+
|
| 371 |
+
$mail_indices = '';
|
| 372 |
+
for ($i = 0; $i < strlen($mail_link); $i ++) {
|
| 373 |
+
$index = strpos($mail_letters, substr($mail_link, $i, 1));
|
| 374 |
+
$index += 48;
|
| 375 |
+
$mail_indices .= chr($index);
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
$mail_indices = str_replace("\\", "\\\\", $mail_indices);
|
| 379 |
+
$mail_indices = str_replace("\"", "\\\"", $mail_indices);
|
| 380 |
+
|
| 381 |
+
return '<script type="text/javascript">'
|
| 382 |
+
. '(function(){'
|
| 383 |
+
. 'var ml="'. $mail_letters_enc .'",mi="'. $mail_indices .'",o="";'
|
| 384 |
+
. 'for(var j=0,l=mi.length;j<l;j++){'
|
| 385 |
+
. 'o+=ml.charAt(mi.charCodeAt(j)-48);'
|
| 386 |
+
. '}document.write(o);'
|
| 387 |
+
. '}());'
|
| 388 |
+
. '</script><noscript>'
|
| 389 |
+
. $this->options['protection_text']
|
| 390 |
+
. '</noscript>';
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
/**
|
| 394 |
+
* Escape method
|
| 395 |
+
* Taken from the plugin "Email Spam Protection" by Adam Hunter (http://blueberryware.net/2008/09/14/email-spam-protection/)
|
| 396 |
+
*
|
| 397 |
+
* @param string $value
|
| 398 |
+
* @return string
|
| 399 |
+
*/
|
| 400 |
+
private function enc_escape($value) {
|
| 401 |
+
$string = 'document.write(\'' . $value . '\')';
|
| 402 |
+
|
| 403 |
+
/* break string into array of characters, we can't use string_split because its php5 only :( */
|
| 404 |
+
$split = preg_split('||', $string);
|
| 405 |
+
$out = '<script type="text/javascript">' . "eval(unescape('";
|
| 406 |
+
|
| 407 |
+
foreach ($split as $c) {
|
| 408 |
+
/* preg split will return empty first and last characters, check for them and ignore */
|
| 409 |
+
if (!empty($c)) {
|
| 410 |
+
$out .= '%' . dechex(ord($c));
|
| 411 |
+
}
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
$out .= "'))" . '</script><noscript>'
|
| 415 |
+
. $this->options['protection_text']
|
| 416 |
+
. '</noscript>';
|
| 417 |
+
|
| 418 |
+
return $out;
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
/**
|
| 422 |
+
* Convert randomly chars to htmlentities
|
| 423 |
+
* This method is partly taken from WordPress
|
| 424 |
+
* @link http://codex.wordpress.org/Function_Reference/antispambot
|
| 425 |
+
*
|
| 426 |
+
* @param string $value
|
| 427 |
+
* @return string
|
| 428 |
+
*/
|
| 429 |
+
private function enc_html($value) {
|
| 430 |
+
// check for built-in WP function
|
| 431 |
+
if (function_exists('antispambot')) {
|
| 432 |
+
$emailNOSPAMaddy = antispambot($value);
|
| 433 |
+
} else {
|
| 434 |
+
$emailNOSPAMaddy = '';
|
| 435 |
+
srand ((float) microtime() * 1000000);
|
| 436 |
+
for ($i = 0; $i < strlen($emailaddy); $i = $i + 1) {
|
| 437 |
+
$j = floor(rand(0, 1+$mailto));
|
| 438 |
+
if ($j==0) {
|
| 439 |
+
$emailNOSPAMaddy .= '&#'.ord(substr($emailaddy,$i,1)).';';
|
| 440 |
+
} elseif ($j==1) {
|
| 441 |
+
$emailNOSPAMaddy .= substr($emailaddy,$i,1);
|
| 442 |
+
} elseif ($j==2) {
|
| 443 |
+
$emailNOSPAMaddy .= '%'.zeroise(dechex(ord(substr($emailaddy, $i, 1))), 2);
|
| 444 |
+
}
|
| 445 |
+
}
|
| 446 |
+
$emailNOSPAMaddy = str_replace('@','@',$emailNOSPAMaddy);
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
$emailNOSPAMaddy = str_replace('@', '@', $emailNOSPAMaddy);
|
| 450 |
+
|
| 451 |
+
return $emailNOSPAMaddy;
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
} // end class EebSite
|
| 455 |
+
|
| 456 |
+
endif;
|
| 457 |
+
|
| 458 |
+
/* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
|
includes/deprecated.php
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php defined('ABSPATH') OR die('No direct access.');
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Deprecated template Functions
|
| 5 |
+
*
|
| 6 |
+
* @package Email_Encoder_Bundle
|
| 7 |
+
* @category WordPress Plugins
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Template function for encoding email
|
| 12 |
+
*
|
| 13 |
+
* @deprecated
|
| 14 |
+
*
|
| 15 |
+
* @global EebSite $EebSite
|
| 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
|
| 19 |
+
* @param string $extra_attrs Optional
|
| 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;
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Template function for encoding content
|
| 30 |
+
*
|
| 31 |
+
* @deprecated
|
| 32 |
+
*
|
| 33 |
+
* @global EebSite $EebSite
|
| 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;
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Template function for encoding emails in the given content
|
| 46 |
+
*
|
| 47 |
+
* @deprecated
|
| 48 |
+
*
|
| 49 |
+
* @global EebSite $EebSite
|
| 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;
|
| 61 |
+
|
| 62 |
+
/* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
|
includes/template-functions.php
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php defined('ABSPATH') OR die('No direct access.');
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Template Functions
|
| 5 |
+
*
|
| 6 |
+
* @package Email_Encoder_Bundle
|
| 7 |
+
* @category WordPress Plugins
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Template function for encoding email
|
| 12 |
+
* @global EebSite $EebSite
|
| 13 |
+
* @param string $email
|
| 14 |
+
* @param string $display if non given will be same as email
|
| 15 |
+
* @param string $extra_attrs Optional
|
| 16 |
+
* @param string $method Optional, else the default setted method will; be used
|
| 17 |
+
* @return string
|
| 18 |
+
*/
|
| 19 |
+
if (!function_exists('eeb_email')):
|
| 20 |
+
function eeb_email($email, $display = NULL, $extra_attrs = '', $method = NULL) {
|
| 21 |
+
global $EebSite;
|
| 22 |
+
return $EebSite->encode_email($email, $display, $extra_attrs, $method);
|
| 23 |
+
}
|
| 24 |
+
endif;
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Template function for encoding content
|
| 29 |
+
* @global EebSite $EebSite
|
| 30 |
+
* @param string $content
|
| 31 |
+
* @param string $method Optional, default NULL
|
| 32 |
+
* @return string
|
| 33 |
+
*/
|
| 34 |
+
if (!function_exists('eeb_content')):
|
| 35 |
+
function eeb_content($content, $method = NULL) {
|
| 36 |
+
global $EebSite;
|
| 37 |
+
return $EebSite->encode_content($content, $method);
|
| 38 |
+
}
|
| 39 |
+
endif;
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Template function for encoding emails in the given content
|
| 43 |
+
* @global EebSite $EebSite
|
| 44 |
+
* @param string $content
|
| 45 |
+
* @param boolean $enc_tags Optional, default TRUE
|
| 46 |
+
* @param boolean $enc_mailtos Optional, default TRUE
|
| 47 |
+
* @param boolean $enc_plain_emails Optional, default TRUE
|
| 48 |
+
* @return string
|
| 49 |
+
*/
|
| 50 |
+
if (!function_exists('eeb_email_filter')):
|
| 51 |
+
function eeb_email_filter($content, $enc_tags = TRUE, $enc_mailtos = TRUE, $enc_plain_emails = TRUE) {
|
| 52 |
+
global $EebSite;
|
| 53 |
+
return $EebSite->encode_email_filter($content, $enc_tags, $enc_mailtos, $enc_plain_emails);
|
| 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 */
|
js/email-encoder-bundle-admin.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
| 1 |
-
/* Email Encoder Bundle Plugin - Admin */
|
| 2 |
-
/*global jQuery*/
|
| 3 |
-
jQuery(function ($) {
|
| 4 |
-
'use strict';
|
| 5 |
-
|
| 6 |
-
var methodInfo = window.methodInfo;
|
| 7 |
-
|
| 8 |
-
$('#setting-error-settings_updated').click(function () {
|
| 9 |
-
$(this).hide();
|
| 10 |
-
});
|
| 11 |
-
|
| 12 |
-
// set info text for selected encoding method
|
| 13 |
-
$('.method-info-select')
|
| 14 |
-
.bind('change', function () {
|
| 15 |
-
var method = $(this).val(),
|
| 16 |
-
$desc = $(this).parent().find('span.description');
|
| 17 |
-
|
| 18 |
-
if (methodInfo && methodInfo[method]) {
|
| 19 |
-
$desc.hide();
|
| 20 |
-
$desc.html(methodInfo[method].description || '');
|
| 21 |
-
$desc.fadeIn();
|
| 22 |
-
} else {
|
| 23 |
-
$desc.html('');
|
| 24 |
-
}
|
| 25 |
-
})
|
| 26 |
-
.change();
|
| 27 |
-
|
| 28 |
-
// "has effect on"
|
| 29 |
-
$('input#encode_emails')
|
| 30 |
-
.change(function () {
|
| 31 |
-
if ($(this).attr('checked')) {
|
| 32 |
-
$('input#encode_mailtos').attr('checked', true);
|
| 33 |
-
}
|
| 34 |
-
})
|
| 35 |
-
.change();
|
| 36 |
-
|
| 37 |
-
$('input#encode_mailtos')
|
| 38 |
-
.change(function () {
|
| 39 |
-
if (!$(this).attr('checked')) {
|
| 40 |
-
$('input#encode_emails').attr('checked', false);
|
| 41 |
-
}
|
| 42 |
-
});
|
| 43 |
-
|
| 44 |
-
// rss feed
|
| 45 |
-
$('input#filter_rss')
|
| 46 |
-
.change(function () {
|
| 47 |
-
$('input#protection_text').attr('disabled', !$(this).attr('checked'));
|
| 48 |
-
})
|
| 49 |
-
.change();
|
| 50 |
-
|
| 51 |
-
// add form-table class to Encoder Form tables
|
| 52 |
-
$('.email-encoder-form table').addClass('form-table');
|
| 53 |
-
|
| 54 |
-
// Workaround for saving disabled checkboxes in options db
|
| 55 |
-
// prepare checkboxes before submit
|
| 56 |
-
$('.wrap form').submit(function () {
|
| 57 |
-
// force value 0 being saved in options
|
| 58 |
-
$('*[type="checkbox"]:not(:checked)')
|
| 59 |
-
.css({ 'visibility': 'hidden' })
|
| 60 |
-
.attr({
|
| 61 |
-
'value': '0',
|
| 62 |
-
'checked': 'checked'
|
| 63 |
-
});
|
| 64 |
-
});
|
| 65 |
-
|
| 66 |
-
// enable submit buttons
|
| 67 |
-
$('*[type="submit"]').attr('disabled', false);
|
| 68 |
-
|
| 69 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/email-encoder-bundle.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
| 1 |
-
/* Email Encoder Bundle Plugin */
|
| 2 |
-
/*global jQuery*/
|
| 3 |
-
jQuery(function($){
|
| 4 |
-
'use strict';
|
| 5 |
-
|
| 6 |
-
var $wrap = $('div.email-encoder-form'),
|
| 7 |
-
$email = $wrap.find('#email'),
|
| 8 |
-
$display = $wrap.find('#display'),
|
| 9 |
-
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('#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('#encode_method').val()
|
| 27 |
-
}, function (data) {
|
| 28 |
-
$wrap.find('#encoded_output').val(data);
|
| 29 |
-
$wrap.find('.output').fadeIn();
|
| 30 |
-
});
|
| 31 |
-
};
|
| 32 |
-
|
| 33 |
-
// hide output
|
| 34 |
-
$wrap.find('.nodis').hide();
|
| 35 |
-
|
| 36 |
-
// auto-set display field
|
| 37 |
-
$email.keyup(function(){
|
| 38 |
-
var email = $email.val(),
|
| 39 |
-
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('#email, #display')
|
| 50 |
-
.keyup(function () {
|
| 51 |
-
if ($display.val().length > 0) {
|
| 52 |
-
// show example how it will appear on the page
|
| 53 |
-
$wrap.find('#example')
|
| 54 |
-
.html('<a href="mailto:' + $email.val() + '">' + $display.val() + '</a>')
|
| 55 |
-
.parents('tr').fadeIn();
|
| 56 |
-
} else {
|
| 57 |
-
$wrap.find('#example').parents('tr').fadeOut();
|
| 58 |
-
}
|
| 59 |
-
|
| 60 |
-
// clear code field
|
| 61 |
-
$wrap.find('.output').fadeOut();
|
| 62 |
-
$wrap.find('#encoded_output').val('');
|
| 63 |
-
})
|
| 64 |
-
.keyup();
|
| 65 |
-
|
| 66 |
-
$wrap.find('#encode_method').bind('change keyup', function () {
|
| 67 |
-
getEncoded();
|
| 68 |
-
});
|
| 69 |
-
|
| 70 |
-
$wrap.find('#ajax_encode').click(function(){
|
| 71 |
-
getEncoded();
|
| 72 |
-
});
|
| 73 |
-
|
| 74 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/email-encoder-bundle.min.js
ADDED
|
@@ -0,0 +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")})
|
js/src/email-encoder-bundle-admin.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 34 |
+
// add form-table class to Encoder Form tables
|
| 35 |
+
$('.eeb-form table').addClass('form-table');
|
| 36 |
+
|
| 37 |
+
//
|
| 38 |
+
$('.eeb-help-link').click(function (e) {
|
| 39 |
+
$('#contextual-help-link').click();
|
| 40 |
+
e.preventDefault();
|
| 41 |
+
});
|
| 42 |
+
|
| 43 |
+
// Workaround for saving disabled checkboxes in options db
|
| 44 |
+
// prepare checkboxes before submit
|
| 45 |
+
$('.wrap form').submit(function () {
|
| 46 |
+
// force value 0 being saved in options
|
| 47 |
+
$('*[type="checkbox"]:not(:checked)')
|
| 48 |
+
.css({ 'visibility': 'hidden' })
|
| 49 |
+
.attr({
|
| 50 |
+
'value': '0',
|
| 51 |
+
'checked': 'checked'
|
| 52 |
+
});
|
| 53 |
+
});
|
| 54 |
+
|
| 55 |
+
// enable submit buttons
|
| 56 |
+
$('*[type="submit"]')
|
| 57 |
+
.attr('disabled', false)
|
| 58 |
+
.removeClass('submit'); // remove class to fix button background
|
| 59 |
+
|
| 60 |
+
});
|
js/src/email-encoder-bundle.js
ADDED
|
@@ -0,0 +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 |
+
});
|
readme.txt
CHANGED
|
@@ -1,32 +1,39 @@
|
|
| 1 |
=== Email Encoder Bundle ===
|
| 2 |
Contributors: freelancephp
|
| 3 |
Tags: email address, protect, antispam, mailto, spambot, secure, e-mail, email, mail, obfuscate, encode, encoder, encrypt, hide, bot, crawl, spider, robots, spam, protection, harvest, harvesting, security
|
| 4 |
-
Requires at least: 3.
|
| 5 |
-
Tested up to: 3.
|
| 6 |
-
Stable tag: 0.
|
| 7 |
|
| 8 |
-
Encode mailto links
|
| 9 |
|
| 10 |
== Description ==
|
| 11 |
|
| 12 |
-
Encode mailto links
|
| 13 |
|
| 14 |
= Features =
|
| 15 |
-
* Protect
|
| 16 |
-
*
|
| 17 |
-
*
|
| 18 |
-
*
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
* And more...
|
| 21 |
|
| 22 |
-
=
|
| 23 |
-
|
| 24 |
|
| 25 |
= Support =
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
=
|
| 29 |
-
|
| 30 |
|
| 31 |
== Installation ==
|
| 32 |
|
|
@@ -40,20 +47,38 @@ Supports PHP 4.3+ and WP 3.0+.
|
|
| 40 |
= How do I encode my emailaddress(es)? =
|
| 41 |
|
| 42 |
In the posts you can use this shortcode:
|
| 43 |
-
`[
|
| 44 |
|
| 45 |
By default mailto links like this will also be encoded:
|
| 46 |
`<a href="mailto:myname@test.nl">My Email</a>`
|
| 47 |
|
| 48 |
-
The default method is `
|
| 49 |
`<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>`
|
| 50 |
|
| 51 |
This code is not readable by spambots and protects your emailaddress.
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
= How to create mailto links that opens in a new window? =
|
| 54 |
|
| 55 |
You could add extra params to the mailto link and add `target='_blank'` for opening them in a new window, like:
|
| 56 |
-
`[
|
| 57 |
|
| 58 |
In html this will look like:
|
| 59 |
`<a href="mailto:yourmail@test.nl" target="_blank">My Mail</a>`
|
|
@@ -63,7 +88,7 @@ In html this will look like:
|
|
| 63 |
If you use other plugins that needs to be encoded you can add a callback to the action "init_email_encoder_bundle".
|
| 64 |
For Example:
|
| 65 |
|
| 66 |
-
`add_action('
|
| 67 |
|
| 68 |
function extra_encode_filters($filter_callback) {
|
| 69 |
// add filters for BBPress
|
|
@@ -74,7 +99,7 @@ function extra_encode_filters($filter_callback) {
|
|
| 74 |
= Can I use special characters (like Chinese)? =
|
| 75 |
It's only possible to use special characters for the display. And only works by using the shortcode with the HTML encode method.
|
| 76 |
Example:
|
| 77 |
-
`[
|
| 78 |
|
| 79 |
= How to encode emails in all widgets (and not only text widgets)? =
|
| 80 |
|
|
@@ -89,9 +114,27 @@ It's possible to filter all widgets by using the Widget Logic plugin and activat
|
|
| 89 |
1. Check encoded email/content when logged in as admin
|
| 90 |
1. Email Encoder Form on the Site
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
== Changelog ==
|
| 93 |
|
| 94 |
-
= 0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
* Added screen settings
|
| 96 |
* Registered metaboxes
|
| 97 |
* Fixed bug random method
|
|
@@ -187,10 +230,3 @@ It's possible to filter all widgets by using the Widget Logic plugin and activat
|
|
| 187 |
* Methods: default_encode, wp_antispambot, anti_email_spam, email_escape, hide_email
|
| 188 |
* Use the tags: `[email_encode email=".." display=".."]`, `[email_encoder_form]`
|
| 189 |
* Template function: `email_encode()`
|
| 190 |
-
|
| 191 |
-
== Other Notes ==
|
| 192 |
-
|
| 193 |
-
= Credits =
|
| 194 |
-
* [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/)
|
| 195 |
-
* [Tyler Akins](http://rumkin.com) for the encode method 'JavaScript ASCII Mixer'
|
| 196 |
-
* Title icon on Admin Options Page was made by [Jack Cai](http://www.doublejdesign.co.uk/)
|
| 1 |
=== Email Encoder Bundle ===
|
| 2 |
Contributors: freelancephp
|
| 3 |
Tags: email address, protect, antispam, mailto, spambot, secure, e-mail, email, mail, obfuscate, encode, encoder, encrypt, hide, bot, crawl, spider, robots, spam, protection, harvest, harvesting, security
|
| 4 |
+
Requires at least: 3.4.0
|
| 5 |
+
Tested up to: 3.8.0
|
| 6 |
+
Stable tag: 1.0.0
|
| 7 |
|
| 8 |
+
Encode mailto links, emailaddresses or any text and hide them from spambots. Easy to use, plugin works directly when activated.
|
| 9 |
|
| 10 |
== Description ==
|
| 11 |
|
| 12 |
+
Encode mailto links, emailaddresses or any text and hide them from spambots. Easy to use, plugin works directly when activated.
|
| 13 |
|
| 14 |
= Features =
|
| 15 |
+
* Protect mailto links and plain emailaddresses
|
| 16 |
+
* Automatically or with shortcodes
|
| 17 |
+
* Scan posts, widgets and comments
|
| 18 |
+
* Also protect RSS feeds
|
| 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 directly when activated. If you like you can set many options in the Admin Panel.
|
| 28 |
|
| 29 |
= Support =
|
| 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 |
+
* PHP 5.4+ and WP 3.4+
|
| 34 |
|
| 35 |
+
= Like this plugin? =
|
| 36 |
+
You could show your appreciation by [rating this plugin](http://wordpress.org/support/view/plugin-reviews/email-encoder-bundle) and/or [posting a comment](http://www.freelancephp.net/email-encoder-php-class-wp-plugin/) on my blog.
|
| 37 |
|
| 38 |
== Installation ==
|
| 39 |
|
| 47 |
= How do I encode my emailaddress(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 emailaddress.
|
| 59 |
|
| 60 |
+
= Emailaddress in a form field is being encoded in a strange way. What to do? =
|
| 61 |
+
|
| 62 |
+
An emailaddress 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>`
|
| 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
|
| 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 |
|
| 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.0.0 =
|
| 126 |
+
* NOW ONLY SUPPORT FOR PHP 5.4+ and WP 3.4.0+
|
| 127 |
+
* Solved bug deleting setting values when unregister (will now be deleted on uninstall)
|
| 128 |
+
* Solved bug also possible to set protection text when RSS disabled
|
| 129 |
+
* Solved bug saving metaboxes settings
|
| 130 |
+
* Added option support shortcodes in widgets
|
| 131 |
+
* Added option removing shortcodes for RSS feed
|
| 132 |
+
* Removed "random" method option
|
| 133 |
+
* Changed names for action and shortcode (prefixed with eeb_), optional the old names will still be supported
|
| 134 |
+
* Added template function for creating the encoder form
|
| 135 |
+
* Changed class en id names of the Encoder Form
|
| 136 |
+
|
| 137 |
+
= 0.80 =
|
| 138 |
* Added screen settings
|
| 139 |
* Registered metaboxes
|
| 140 |
* Fixed bug random method
|
| 230 |
* Methods: default_encode, wp_antispambot, anti_email_spam, email_escape, hide_email
|
| 231 |
* Use the tags: `[email_encode email=".." display=".."]`, `[email_encoder_form]`
|
| 232 |
* Template function: `email_encode()`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
screenshot-1.png
CHANGED
|
Binary file
|
screenshot-3.png
CHANGED
|
Binary file
|
