PluginProbe ʕ •ᴥ•ʔ
Email Encoder – Protect Email Addresses and Phone Numbers / 1.2.1
Email Encoder – Protect Email Addresses and Phone Numbers v1.2.1
2.5.2 2.5.1 2.5.0 2.4.8 trunk 0.10 0.11 0.12 0.20 0.21 0.22 0.30 0.31 0.32 0.40 0.41 0.42 0.50 0.60 0.70 0.71 0.80 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.5 1.5.2 1.51 1.53 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7
email-encoder-bundle / includes / class-eeb-admin.php
email-encoder-bundle / includes Last commit date
class-eeb-admin.php 11 years ago class-eeb-site.php 11 years ago deprecated.php 11 years ago template-functions.php 11 years ago
class-eeb-admin.php
838 lines
1 <?php defined('ABSPATH') OR die('No direct access.');
2
3 /**
4 * Class Eeb_Admin
5 *
6 * Contains all code nescessary for the Admin part
7 *
8 * @abstract
9 *
10 * @package Email_Encoder_Bundle
11 * @category WordPress Plugins
12 */
13 if (!class_exists('Eeb_Admin')):
14
15 abstract class Eeb_Admin {
16
17 /**
18 * @var array
19 */
20 private $default_options = array(
21 'version' => null,
22 'method' => 'enc_ascii',
23 'encode_mailtos' => 1,
24 'encode_emails' => 0,
25 'filter_posts' => 1,
26 'filter_widgets' => 1,
27 'filter_comments' => 1,
28 'skip_posts' => '',
29 'protection_text' => '*protected email*',
30 'class_name' => 'mailto-link',
31 'filter_rss' => 1,
32 'remove_shortcodes_rss' => 1,
33 'protection_text_rss' => '*protected email*',
34 'widget_logic_filter' => 0,
35 'show_encoded_check' => 0,
36 'shortcodes_in_widgets' => 0,
37 'support_deprecated_names' => 0,
38 'own_admin_menu' => 1,
39 'powered_by' => 1,
40 );
41
42 /**
43 * @var array
44 */
45 protected $options = array();
46
47 /**
48 * @var array
49 */
50 protected $skip_posts = array();
51
52 /**
53 * @var string
54 */
55 protected $method = 'enc_ascii';
56
57 /**
58 * @var array
59 */
60 private $methods = array();
61
62 /**
63 * @var boolean
64 */
65 private $initial_metabox_settings = false;
66
67 /**
68 * Constructor
69 */
70 protected function __construct() {
71 // load text domain for translations
72 load_plugin_textdomain(EMAIL_ENCODER_BUNDLE_DOMAIN, false, dirname(plugin_basename(EMAIL_ENCODER_BUNDLE_FILE)) . '/languages/');
73
74 // set methods
75 $this->methods = array(
76 'enc_ascii' => array(
77 'name' => __('JS Rot13', EMAIL_ENCODER_BUNDLE_DOMAIN),
78 'description' => __('Recommended, the savest method using a rot13 method in JavaScript.', EMAIL_ENCODER_BUNDLE_DOMAIN),
79 ),
80 'enc_escape' => array(
81 'name' => __('JS Escape', EMAIL_ENCODER_BUNDLE_DOMAIN),
82 'description' => __('Pretty save method using JavaScipt\'s escape function.', EMAIL_ENCODER_BUNDLE_DOMAIN),
83 ),
84 'enc_html' => array(
85 'name' => __('Html Encode', EMAIL_ENCODER_BUNDLE_DOMAIN),
86 'description' => __('Not recommended, equal to <a href="http://codex.wordpress.org/Function_Reference/antispambot" target="_blank"><code>antispambot()</code></a> function of WordPress.', EMAIL_ENCODER_BUNDLE_DOMAIN),
87 ),
88 );
89
90 // set option values
91 $this->set_options();
92
93 // prepare vars
94 $skip_posts = $this->options['skip_posts'];
95 $skip_posts = str_replace(' ', '', $skip_posts);
96 $skip_posts = explode(',', $skip_posts);
97 $this->skip_posts = $skip_posts;
98
99 // set uninstall hook
100 register_uninstall_hook(EMAIL_ENCODER_BUNDLE_FILE, array('Eeb_Admin', 'uninstall'));
101
102 // add actions
103 add_action('wp', array($this, 'wp'));
104 add_action('admin_init', array($this, 'admin_init'));
105 add_action('admin_menu', array($this, 'admin_menu'));
106 }
107
108 /**
109 * Set options from save values or defaults
110 */
111 private function set_options() {
112 $upgrade = false;
113
114 // first set defaults
115 $this->options = $this->default_options;
116
117 // get saved options
118 $saved_options = get_option(EMAIL_ENCODER_BUNDLE_OPTIONS_NAME);
119
120 // backwards compatible (old values)
121 if (empty($saved_options)) {
122 $saved_options = get_option(EMAIL_ENCODER_BUNDLE_KEY . 'options');
123
124 // cleanup old values
125 delete_option(EMAIL_ENCODER_BUNDLE_KEY . 'options');
126 }
127
128 $version = get_option('eeb_version');
129 if ($version !== false) {
130 $saved_options['version'] = $version;
131
132 // cleanup old value
133 delete_option('eeb_version');
134 }
135
136 // set all options
137 if (!empty($saved_options)) {
138 $upgrade = true;
139
140 foreach ($saved_options AS $key => $value) {
141 $this->options[$key] = $value;
142 }
143 }
144
145 if (!isset($saved_options['version']) || $saved_options['version'] != EMAIL_ENCODER_BUNDLE_VERSION) {
146 if (empty($saved_options['version'])) {
147 if ($upgrade) {
148 // upgrade from version < 1.0.0
149 $this->options['support_deprecated_names'] = 1;
150 $this->options['shortcodes_in_widgets'] = 1;
151
152 //update_option(EMAIL_ENCODER_BUNDLE_OPTIONS_NAME, $this->options);
153 } else {
154 // first time
155 $this->initial_metabox_settings = true;
156 }
157 } else {
158 // upgrading from version >= 1.0.0
159
160 }
161
162 // update version
163 update_option(EMAIL_ENCODER_BUNDLE_OPTIONS_NAME, $this->options);
164 }
165
166 // set encode method
167 $this->method = $this->get_method($this->options['method'], 'enc_ascii');
168
169 // set widget_content filter of Widget Logic plugin
170 $widget_logic_opts = get_option('widget_logic');
171 if (is_array($widget_logic_opts) && key_exists('widget_logic-options-filter', $widget_logic_opts)) {
172 $this->options['widget_logic_filter'] = ($widget_logic_opts['widget_logic-options-filter'] == 'checked') ? 1 : 0;
173 }
174 }
175
176 /**
177 * Get method name
178 * @param string $method
179 * @param string $defaultMethod Optional, default 'enc_html'
180 * @return string
181 */
182 protected function get_method($method, $defaultMethod = 'enc_html') {
183 $method = strtolower($method);
184
185 if (!method_exists($this, $method)) {
186 $method = $defaultMethod; // set default method
187 }
188
189 return $method;
190 }
191
192 /**
193 * Callback Uninstall
194 */
195 static public function uninstall() {
196 delete_option(EMAIL_ENCODER_BUNDLE_OPTIONS_NAME);
197 unregister_setting(EMAIL_ENCODER_BUNDLE_KEY, EMAIL_ENCODER_BUNDLE_OPTIONS_NAME);
198 }
199
200 /**
201 * Callbacka admin_init
202 */
203 public function admin_init() {
204 // register settings
205 register_setting(EMAIL_ENCODER_BUNDLE_KEY, EMAIL_ENCODER_BUNDLE_OPTIONS_NAME);
206
207 // actions and filters
208 add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2);
209 }
210
211 /**
212 * Callback add links on plugin page
213 * @param array $links
214 * @param string $file
215 * @return array
216 */
217 public function plugin_action_links($links, $file) {
218 if ($file == plugin_basename(EMAIL_ENCODER_BUNDLE_FILE)) {
219 $page = ($this->options['own_admin_menu']) ? 'admin.php' : 'options-general.php';
220 $settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/' . $page . '?page=' . EMAIL_ENCODER_BUNDLE_ADMIN_PAGE . '">' . __('Settings', EMAIL_ENCODER_BUNDLE_DOMAIN) . '</a>';
221 array_unshift($links, $settings_link);
222 }
223
224 return $links;
225 }
226
227 /**
228 * Callback admin_menu
229 */
230 public function admin_menu() {
231 // add page and menu item
232 if ($this->options['own_admin_menu']) {
233 // create main menu item
234 $page_hook = add_menu_page(__('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN), __('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN),
235 'manage_options', EMAIL_ENCODER_BUNDLE_ADMIN_PAGE, array($this, 'show_options_page'),
236 plugins_url('images/icon-email-encoder-bundle-16.png', EMAIL_ENCODER_BUNDLE_FILE));
237 } else {
238 // create submenu item under "Settings"
239 $page_hook = add_submenu_page('options-general.php', __('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN), __('Email Encoder Bundle', EMAIL_ENCODER_BUNDLE_DOMAIN),
240 'manage_options', EMAIL_ENCODER_BUNDLE_ADMIN_PAGE, array($this, 'show_options_page'));
241 }
242
243 // load plugin page
244 add_action('load-' . $page_hook, array($this, 'load_options_page'));
245 }
246
247 /* -------------------------------------------------------------------------
248 * Admin Options Page
249 * ------------------------------------------------------------------------*/
250
251 /**
252 * Load admin options page
253 */
254 public function load_options_page() {
255 // set dashboard postbox
256 wp_enqueue_script('dashboard');
257
258 // add script for ajax encoder
259 //wp_enqueue_script('email_encoder', plugins_url('js/src/email-encoder-bundle.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
260 //wp_enqueue_script('email_encoder_admin', plugins_url('js/src/email-encoder-bundle-admin.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
261 wp_enqueue_script('email_encoder', plugins_url('js/email-encoder-bundle.min.js', EMAIL_ENCODER_BUNDLE_FILE), array('jquery'), EMAIL_ENCODER_BUNDLE_VERSION);
262
263 // add help tabs
264 $this->add_help_tabs();
265
266 // screen settings
267 if (function_exists('add_screen_option')) {
268 add_screen_option('layout_columns', array(
269 'max' => 2,
270 'default' => 2
271 ));
272 }
273
274 // add meta boxes
275 add_meta_box('main_settings', __('Main Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('main_settings'));
276 add_meta_box('additional_settings', __('Additional Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('additional_settings'));
277 add_meta_box('rss_settings', __('RSS Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('rss_settings'));
278 add_meta_box('admin_settings', __('Admin Settings', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('admin_settings'));
279 add_meta_box('encode_form', __('Email Encoder Form', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'normal', 'core', array('encode_form'));
280 add_meta_box('this_plugin', __('Support', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'side', 'core', array('this_plugin'));
281 add_meta_box('other_plugins', __('Other Plugins', EMAIL_ENCODER_BUNDLE_DOMAIN), array($this, 'show_meta_box_content'), null, 'side', 'core', array('other_plugins'));
282 }
283
284 /**
285 * Show admin options page
286 */
287 public function show_options_page() {
288 $this->set_options();
289 ?>
290 <div class="wrap">
291 <div class="icon32" id="icon-options-custom" style="background:url(<?php echo plugins_url('images/icon-email-encoder-bundle.png', EMAIL_ENCODER_BUNDLE_FILE) ?>) no-repeat 50% 50%"><br></div>
292 <h2><?php echo get_admin_page_title() ?> - <em><small><?php _e('Protect Email Addresses', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></small></em></h2>
293
294 <?php if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' && $this->options['own_admin_menu']): ?>
295 <div class="updated settings-error" id="setting-error-settings_updated">
296 <p><strong><?php _e('Settings saved.' ) ?></strong></p>
297 </div>
298 <?php endif; ?>
299
300 <?php if ($this->initial_metabox_settings): ?>
301 <script type="text/javascript">jQuery(function($){ $('#additional_settings, #rss_settings, #admin_settings, #encode_form').addClass('closed'); });</script>
302 <?php endif; ?>
303
304 <form method="post" action="options.php">
305 <?php settings_fields(EMAIL_ENCODER_BUNDLE_KEY); ?>
306
307 <input type="hidden" name="<?php echo EMAIL_ENCODER_BUNDLE_KEY ?>_nonce" value="<?php echo wp_create_nonce(EMAIL_ENCODER_BUNDLE_KEY) ?>" />
308 <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
309 <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
310
311 <div id="poststuff">
312 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
313 <!--<div id="post-body-content"></div>-->
314
315 <div id="postbox-container-1" class="postbox-container">
316 <?php do_meta_boxes('', 'side', ''); ?>
317 </div>
318
319 <div id="postbox-container-2" class="postbox-container">
320 <?php do_meta_boxes('', 'normal', ''); ?>
321 <?php do_meta_boxes('', 'advanced', ''); ?>
322 </div>
323 </div> <!-- #post-body -->
324 </div> <!-- #poststuff -->
325 </form>
326 </div>
327 <?php
328 }
329
330 /**
331 * Show content of metabox (callback)
332 * @param array $post
333 * @param array $meta_box
334 */
335 public function show_meta_box_content($post, $meta_box) {
336 $key = $meta_box['args'][0];
337 $options = $this->options;
338
339 if ($key === 'main_settings') {
340 ?>
341 <?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php')): ?>
342 <p class="description"><?php _e('Warning: "WP Mailto Links"-plugin is also activated, which could cause conflicts.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></p>
343 <?php endif; ?>
344 <fieldset class="options">
345 <table class="form-table">
346 <tr>
347 <th><?php _e('Choose what to protect', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
348 <td>
349 <label><input type="checkbox" id="encode_mailtos" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[encode_mailtos]" value="1" <?php checked('1', (int) $options['encode_mailtos']); ?> />
350 <span><?php _e('Protect mailto links, like f.e. <code>&lt;a href="info@myemail.com"&gt;My Email&lt;/a&gt;</code>', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
351 <br/><label><input type="checkbox" id="encode_emails" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[encode_emails]" value="1" <?php checked('1', (int) $options['encode_emails']); ?> disabled="disabled" />
352 <span><?php _e('Replace plain email addresses to protected mailto links.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
353 <span class="description notice-form-field-bug"><br/><?php _e('Notice: be carefull with this option when using email addresses on form fields, please <a href="http://wordpress.org/extend/plugins/email-encoder-bundle/faq/" target="_blank">check the FAQ</a> for more info.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
354 </label>
355 <br/>
356 </td>
357 </tr>
358 <tr>
359 <th><?php _e('Apply on...', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
360 <td>
361 <label><input type="checkbox" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_posts]" value="1" <?php checked('1', (int) $options['filter_posts']); ?> />
362 <span><?php _e('All posts and pages', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
363 </label>
364 <br/><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_comments]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_comments]" value="1" <?php checked('1', (int) $options['filter_comments']); ?> />
365 <span><?php _e('All comments', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
366 <br/><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_widgets]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_widgets]" value="1" <?php checked('1', (int) $options['filter_widgets']); ?> />
367 <span><?php if ($this->options['widget_logic_filter']) { _e('All widgets (uses the <code>widget_content</code> filter of the Widget Logic plugin)', EMAIL_ENCODER_BUNDLE_DOMAIN); } else { _e('All text widgets', EMAIL_ENCODER_BUNDLE_DOMAIN); } ?></span></label>
368 </td>
369 </tr>
370 <tr>
371 <th><?php _e('Add class to protected mailto links', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
372 <td><label><input type="text" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[class_name]" class="regular-text" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[class_name]" value="<?php echo $options['class_name']; ?>" />
373 <br/><span class="description"><?php _e('All protected mailto links will get these class(es). Optional, else keep blank.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label></td>
374 </tr>
375 </table>
376 </fieldset>
377
378 <p class="submit">
379 <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
380 </p>
381 <br class="clear" />
382
383 <?php
384 } else if ($key === 'rss_settings') {
385 ?>
386 <fieldset class="options">
387 <table class="form-table">
388 <tr>
389 <th><?php _e('Protect emails in RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
390 <td><label><input type="checkbox" id="filter_rss" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[filter_rss]" value="1" <?php checked('1', (int) $options['filter_rss']); ?> />
391 <span><?php _e('Replace emails in RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
392 </td>
393 </tr>
394 <tr>
395 <th><?php _e('Remove shortcodes from RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
396 <td><label><input type="checkbox" id="remove_shortcodes_rss" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[remove_shortcodes_rss]" value="1" <?php checked('1', (int) $options['remove_shortcodes_rss']); ?> />
397 <span><?php _e('Remove all shortcodes from the RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span></label>
398 </td>
399 </tr>
400 <tr>
401 <th><?php _e('Set protection text in RSS feeds', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
402 <td><label><input type="text" id="protection_text" class="regular-text" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[protection_text_rss]" value="<?php echo $options['protection_text_rss']; ?>" />
403 <br/><span class="description"><?php _e('Used as replacement for email addresses in RSS feeds.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
404 </label>
405 </td>
406 </tr>
407 </table>
408 </fieldset>
409
410 <p class="submit">
411 <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
412 </p>
413 <br class="clear" />
414 <?php
415 } else if ($key === 'additional_settings') {
416 ?>
417 <fieldset class="options">
418 <table class="form-table">
419 <tr>
420 <th><?php _e('Choose protection method', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
421 <td>
422 <?php foreach ($this->methods AS $method => $info): ?>
423 <label>
424 <input type="radio" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[method]" class="protection-method" value="<?php echo $method ?>" <?php if ($this->method == $method) echo 'checked="checked"' ?> />
425 <span><?php echo $info['name'] ?></span>
426 - <span class="description"><?php echo $info['description'] ?></span>
427 </label>
428 <br/>
429 <?php endforeach; ?>
430 </td>
431 </tr>
432 <tr>
433 <th><?php _e('Set <code>&lt;noscript&gt;</code> text', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
434 <td><label><input type="text" id="protection_text" class="regular-text" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[protection_text]" value="<?php echo $options['protection_text']; ?>" />
435 <br/><span class="description"><?php _e('Used for the <code>&lt;noscript&gt;</code> fallback for JavaScrip methods.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
436 </label>
437 </td>
438 </tr>
439 <tr>
440 <th><?php _e('Exclude posts', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
441 <td>
442 <label>
443 <span><?php _e('Do <strong>not</strong> apply protection on posts or pages with the folllowing ID:', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
444 <br/><input type="text" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[skip_posts]" class="regular-text" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[skip_posts]" value="<?php echo $options['skip_posts']; ?>" />
445 <br/><span class="description"><?php _e('Seperate Id\'s by comma, f.e.: 2, 7, 13, 32.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
446 <br/><span class="description"><?php _e('Notice: shortcodes still work on these posts.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
447 </label>
448 </td>
449 </tr>
450 <tr>
451 <th><?php _e('Use shortcodes in widgets', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
452 <td>
453 <label><input type="checkbox" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[shortcodes_in_widgets]" value="1" <?php checked('1', (int) $options['shortcodes_in_widgets']); ?> />
454 <span><?php _e('Also use shortcodes in widgets.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
455 <br/><span class="description"><?php if (!$this->options['widget_logic_filter']) { _e('Notice: only works for text widgets!', EMAIL_ENCODER_BUNDLE_DOMAIN); } else { _e('All text widgets', EMAIL_ENCODER_BUNDLE_DOMAIN); } ?></span></label>
456 </label>
457 </td>
458 </tr>
459 <tr>
460 <th><?php _e('Use deprecated names', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
461 <td><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[support_deprecated_names]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[support_deprecated_names]" value="1" <?php checked('1', (int) $options['support_deprecated_names']); ?> />
462 <span><?php _e('Keep supporting the old names for action, shortcodes and template functions.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
463 <br /><span class="description">These deprecated will still be available: <code>init_email_encoder_bundle</code>, <code>[encode_email]</code>, <code>[encode_content]</code>, <code>[email_encoder_form]</code>, <code>encode_email()</code>, <code>encode_content()</code>, <code>encode_email_filter()</code></span></label></td>
464 </tr>
465 </table>
466 </fieldset>
467
468 <p class="submit">
469 <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
470 </p>
471 <br class="clear" />
472 <?php
473 } else if ($key === 'admin_settings') {
474 ?>
475 <fieldset class="options">
476 <table class="form-table">
477 <tr>
478 <th><?php _e('Check "succesfully encoded"', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
479 <td><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[show_encoded_check]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[show_encoded_check]" value="1" <?php checked('1', (int) $options['show_encoded_check']); ?> />
480 <span><?php _e('Show "successfully encoded" text for all encoded content, only when logged in as admin user.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
481 <br/><span class="description"><?php _e('This way you can check if emails are really encoded on your site.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
482 </label>
483 </td>
484 </tr>
485 <tr>
486 <th><?php _e('Choose admin menu position', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
487 <td><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[own_admin_menu]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[own_admin_menu]" value="1" <?php checked('1', (int) $options['own_admin_menu']); ?> />
488 <span><?php _e('Show as main menu item.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
489 <br /><span class="description">When disabled this page will be available under "General settings".</span>
490 </label>
491 </td>
492 </tr>
493 </table>
494 </fieldset>
495
496 <p class="submit">
497 <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
498 </p>
499
500 <br class="clear" />
501 <?php
502 } else if ($key === 'encode_form') {
503 ?>
504 <p><?php _e('If you like you can also create you own secure mailto links manually with this form. Just copy the generated code and put it on your post, page or template.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></p>
505
506 <hr style="border:1px solid #FFF; border-top:1px solid #EEE;" />
507
508 <?php echo $this->get_encoder_form(); ?>
509
510 <hr style="border:1px solid #FFF; border-top:1px solid #EEE;"/>
511
512 <p class="description"><?php _e('You can also put the encoder form on your site by using the shortcode <code>[eeb_form]</code> or the template function <code>eeb_form()</code>.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></p>
513
514 <fieldset class="options">
515 <table class="form-table">
516 <tr>
517 <th><?php _e('Show "powered by"', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></th>
518 <td><label><input type="checkbox" id="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[powered_by]" name="<?php echo EMAIL_ENCODER_BUNDLE_OPTIONS_NAME ?>[powered_by]" value="1" <?php checked('1', (int) $options['powered_by']); ?> />
519 <span><?php _e('Show the "powered by"-link on bottom of the encoder form', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></span>
520 </label>
521 </td>
522 </tr>
523 </table>
524 </fieldset>
525
526 <p class="submit">
527 <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes') ?>" />
528 </p>
529 <br class="clear" />
530
531 <?php
532 } else if ($key === 'this_plugin') {
533 ?>
534 <ul>
535 <li><a href="#" class="eeb-help-link"><?php _e('Documentation', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a></li>
536 <li><a href="http://wordpress.org/support/plugin/email-encoder-bundle#postform" target="_blank"><?php _e('Report a problem', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a></li>
537 </ul>
538
539 <p><strong><a href="http://wordpress.org/support/view/plugin-reviews/email-encoder-bundle" target="_blank"><?php _e('Please rate this plugin!', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a></strong></p>
540 <?php
541 } else if ($key === 'other_plugins') {
542 ?>
543 <h4><img src="<?php echo plugins_url('images/icon-wp-external-links.png', EMAIL_ENCODER_BUNDLE_FILE) ?>" width="16" height="16" /> WP External Links -
544 <?php if (is_plugin_active('wp-external-links/wp-external-links.php')): ?>
545 <a href="<?php echo get_bloginfo('url') ?>/wp-admin/options-general.php?page=wp-external-links/wp-external-links.php"><?php _e('Settings') ?></a>
546 <?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-external-links/wp-external-links.php')): ?>
547 <a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a>
548 <?php else: ?>
549 <a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugin-install.php?tab=search&type=term&s=WP+External+Links+freelancephp&plugin-search-input=Search+Plugins"><?php _e('Get this plugin', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a>
550 <?php endif; ?>
551 </h4>
552 <p><?php _e('Manage external links on your site: open in new window/tab, set icon, add "external", add "nofollow" and more.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?>
553 <br /><a href="http://wordpress.org/extend/plugins/wp-external-links/" target="_blank">WordPress.org</a> | <a href="http://www.freelancephp.net/wp-external-links-plugin/" target="_blank">FreelancePHP.net</a>
554 </p>
555
556 <h4><img src="<?php echo plugins_url('images/icon-wp-mailto-links.png', EMAIL_ENCODER_BUNDLE_FILE) ?>" width="16" height="16" /> WP Mailto Links -
557 <?php if (is_plugin_active('wp-mailto-links/wp-mailto-links.php')): ?>
558 <a href="<?php echo get_bloginfo('url') ?>/wp-admin/options-general.php?page=wp-mailto-links/wp-mailto-links.php"><?php _e('Settings') ?></a>
559 <?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-mailto-links/wp-mailto-links.php')): ?>
560 <a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e('Activate', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a>
561 <?php else: ?>
562 <a href="<?php echo get_bloginfo('url') ?>/wp-admin/plugin-install.php?tab=search&type=term&s=WP+Mailto+Links+freelancephp&plugin-search-input=Search+Plugins"><?php _e('Get this plugin', EMAIL_ENCODER_BUNDLE_DOMAIN) ?></a>
563 <?php endif; ?>
564 </h4>
565 <p><?php _e('Manage mailto links on your site and protect emails from spambots, set mail icon and more.', EMAIL_ENCODER_BUNDLE_DOMAIN) ?>
566 <br /><a href="http://wordpress.org/extend/plugins/wp-mailto-links/" target="_blank">WordPress.org</a> | <a href="http://www.freelancephp.net/wp-mailto-links-plugin/" target="_blank">FreelancePHP.net</a>
567 </p>
568 <?php
569 }
570 }
571
572 /* -------------------------------------------------------------------------
573 * Help Tabs
574 * ------------------------------------------------------------------------*/
575
576 /**
577 * Add help tabs
578 */
579 public function add_help_tabs() {
580 if (!function_exists('get_current_screen')) {
581 return;
582 }
583
584 $screen = get_current_screen();
585
586 $screen->set_help_sidebar($this->get_help_text('sidebar'));
587
588 $screen->add_help_tab(array(
589 'id' => 'quickstart',
590 'title' => __('Quick Start', EMAIL_ENCODER_BUNDLE_DOMAIN),
591 'content' => $this->get_help_text('quickstart'),
592 ));
593 $screen->add_help_tab(array(
594 'id' => 'shortcodes',
595 'title' => __('Shortcodes', EMAIL_ENCODER_BUNDLE_DOMAIN),
596 'content' => $this->get_help_text('shortcodes'),
597 ));
598 $screen->add_help_tab(array(
599 'id' => 'templatefunctions',
600 'title' => __('Template Functions', EMAIL_ENCODER_BUNDLE_DOMAIN),
601 'content' => $this->get_help_text('templatefunctions'),
602 ));
603 $screen->add_help_tab(array(
604 'id' => 'actions',
605 'title' => __('Action Hook', EMAIL_ENCODER_BUNDLE_DOMAIN),
606 'content' => $this->get_help_text('actions'),
607 ));
608 $screen->add_help_tab(array(
609 'id' => 'filters',
610 'title' => __('Filter Hooks', EMAIL_ENCODER_BUNDLE_DOMAIN),
611 'content' => $this->get_help_text('filters'),
612 ));
613 $screen->add_help_tab(array(
614 'id' => 'faq',
615 'title' => __('FAQ', EMAIL_ENCODER_BUNDLE_DOMAIN),
616 'content' => $this->get_help_text('faq'),
617 ));
618 }
619
620 /**
621 * Get text for given help tab
622 * @param string $key
623 * @return string
624 */
625 private function get_help_text($key) {
626 if ($key === 'quickstart') {
627 $plugin_title = get_admin_page_title();
628 $icon_url = plugins_url('images/icon-email-encoder-bundle.png', EMAIL_ENCODER_BUNDLE_FILE);
629 $quick_start_url = plugins_url('images/quick-start.png', EMAIL_ENCODER_BUNDLE_FILE);
630 $version = EMAIL_ENCODER_BUNDLE_VERSION;
631
632 $content = sprintf(__('<h3><img src="%s" width="16" height="16" /> %s - version %s</h3>'
633 . '<p>The plugin works out-of-the-box. All mailto links in your posts, pages, comments and (text) widgets will be encoded (by default). <br/>If you also want to encode plain email address as well, you have to check the option.</p>'
634 . '<img src="%s" width="600" height="273" />'
635 , EMAIL_ENCODER_BUNDLE_DOMAIN), $icon_url, $plugin_title, $version, $quick_start_url);
636 } else if ($key === 'shortcodes') {
637 $content = __('<h3>Shortcodes</h3>'
638 . '<p>You can use these shortcodes within your post or page.</p>'
639 . '<h4>eeb_email</h4>'
640 . '<p>Create an encoded mailto link:</p>'
641 . '<p><code>[eeb_email email="..." display="..."]</code></p>'
642 . '<ul>'
643 . '<li>"display" is optional or the email wil be shown as display (also protected)</li>'
644 . '<li>"extra_attrs" is optional, example: <code>extra_attrs="target=\'_blank\'"</code></li>'
645 . '<li>"method" is optional, else the method option will be used.</li>'
646 . '</ul>'
647 . '<h4>eeb_content</h4>'
648 . '<p>Encode some text:</p>'
649 . '<p><code>[eeb_content method="..."]...[/eeb_content]</code></p>'
650 . '<ul>'
651 . '<li>"method" is optional, else the method option will be used.</li>'
652 . '</ul>'
653 . '<h4>eeb_form</h4>'
654 . '<p>Create an encoder form:</p>'
655 . '<p><code>[eeb_form]</code></p>'
656 , EMAIL_ENCODER_BUNDLE_DOMAIN);
657 } else if ($key === 'templatefunctions') {
658 $content = __('<h3>Template Functions</h3>'
659 . '<h4>eeb_email()</h4>'
660 . '<p>Create an encoded mailto link:</p>'
661 . '<pre><code><&#63;php' . "\n"
662 . 'if (function_exists(\'eeb_email\')) {' . "\n"
663 . ' echo eeb_email(\'info@somedomain.com\');' . "\n"
664 . '}' . "\n"
665 . '&#63;></code></pre>'
666 . '<p>You can pass a few extra optional params (in this order): <code>display</code>, <code>extra_attrs</code>, <code>method</code></p>'
667 . '<h4>eeb_content()</h4>'
668 . '<p>Encode some text:</p>'
669 . '<pre><code><&#63;php' . "\n"
670 . 'if (function_exists(\'eeb_content\')) {' . "\n"
671 . ' echo eeb_content(\'Encode this text\');' . "\n"
672 . '}' . "\n"
673 . '&#63;></code></pre>'
674 . '<p>You can pas an extra optional param: <code>method</code></p>'
675 . '<h4>eeb_email_filter()</h4>'
676 . '<p>Filter given content and encode all email addresses or mailto links:</p>'
677 . '<pre><code><&#63;php' . "\n"
678 . 'if (function_exists(\'eeb_email_filter\')) {' . "\n"
679 . ' echo eeb_email_filter(\'Some content with email like info@somedomein.com or a mailto link\');' . "\n"
680 . '}' . "\n"
681 . '&#63;></code></pre>'
682 . '<p>You can pass a few extra optional params (in this order): <code>enc_tags</code>, <code>enc_mailtos</code>, <code>enc_plain_emails</code></p>'
683 . '<h4>eeb_form()</h4>'
684 . '<p>Create an encoder form:</p>'
685 . '<pre><code><&#63;php' . "\n"
686 . 'if (function_exists(\'eeb_form\')) {' . "\n"
687 . ' echo eeb_form();' . "\n"
688 . '}' . "\n"
689 . '&#63;></code></pre>'
690 , EMAIL_ENCODER_BUNDLE_DOMAIN);
691 } else if ($key === 'actions') {
692 $content = __('<h3>Action Hooks</h3>'
693 . '<h4>eeb_ready</h4>'
694 . '<p>Add extra code on initializing this plugin, like extra filters for encoding.</p>'
695 . '<pre><code><&#63;php' . "\n"
696 . 'add_action(\'eeb_ready\', \'extra_encode_filters\');' . "\n\n"
697 . 'function extra_encode_filters($eeb_object) {' . "\n"
698 . ' add_filter(\'some_filter\', array($eeb_object, \'callback_filter\'));' . "\n"
699 . '}' . "\n"
700 . '&#63;></code></pre>'
701 , EMAIL_ENCODER_BUNDLE_DOMAIN);
702 } else if ($key === 'filters') {
703 $content = __('<h3>Filter Hooks</h3>'
704 . '<h4>eeb_mailto_regexp</h4>'
705 . '<p>You can change the regular expression used for searching mailto links.</p>'
706 . '<pre><code><&#63;php' . "\n"
707 . 'add_filter(\'eeb_mailto_regexp\', \'change_mailto_regexp\');' . "\n\n"
708 . 'function change_mailto_regexp($regexp) {' . "\n"
709 . ' return \'-your regular expression-\';' . "\n"
710 . '}' . "\n"
711 . '&#63;></code></pre>'
712 . '<h4>eeb_email_regexp</h4>'
713 . '<p>You can change the regular expression used for searching mailto links.</p>'
714 . '<pre><code><&#63;php' . "\n"
715 . 'add_filter(\'eeb_email_regexp\', \'change_email_regexp\');' . "\n\n"
716 . 'function change_email_regexp($regexp) {' . "\n"
717 . ' return \'-your regular expression-\';' . "\n"
718 . '}' . "\n"
719 . '&#63;></code></pre>'
720 . '<h4>eeb_form_content</h4>'
721 . '<p>Filter for changing the form layout.</p>'
722 . '<pre><code><&#63;php' . "\n"
723 . 'add_filter(\'eeb_form_content\', \'eeb_form_content\', 10, 4);' . "\n\n"
724 . 'function eeb_form_content($content, $labels, $show_powered_by, $methods) {' . "\n"
725 . ' // add a &lt;div&gt;-wrapper' . "\n"
726 . ' return \'&lt;div class="form-wrapper"&gt;\' . $content . \'&lt;/div&gt;\';' . "\n"
727 . '}' . "\n"
728 . '&#63;></code></pre>'
729 , EMAIL_ENCODER_BUNDLE_DOMAIN);
730 } else if ($key === 'faq') {
731 $content = __('<h3>FAQ</h3>'
732 . '<p>Please check the <a href="http://wordpress.org/extend/plugins/email-encoder-bundle/faq/" target="_blank">FAQ on the Plugin site</a>.'
733 , EMAIL_ENCODER_BUNDLE_DOMAIN);
734 } else if ($key === 'sidebar') {
735 $content = __('<h4>About the author</h4>'
736 . '<ul>'
737 . '<li><a href="http://www.freelancephp.net/" target="_blank">FreelancePHP.net</a></li>'
738 . '<li><a href="http://www.freelancephp.net/contact/" target="_blank">Contact</a></li>'
739 . '</ul>'
740 , EMAIL_ENCODER_BUNDLE_DOMAIN);
741 } else {
742 $content = '';
743 }
744
745 return $content;
746 }
747
748 /* -------------------------------------------------------------------------
749 * Encoder Form
750 * -------------------------------------------------------------------------/
751
752 /**
753 * Get the encoder form (to use as a demo, like on the options page)
754 * @return string
755 */
756 public function get_encoder_form() {
757 $method_options = '';
758 foreach ($this->methods as $method_name => $info) {
759 $method_options .= '<option value="' . $method_name . '"' . (($this->method == $method_name) ? ' selected="selected"' : '') . '>' . $info['name'] . '</option>';
760 }
761
762 $show_powered_by = (bool) $this->options['powered_by'];
763 $powered_by = '';
764 if ($show_powered_by) {
765 $powered_by .= '<p class="powered-by">' . __('Powered by', EMAIL_ENCODER_BUNDLE_DOMAIN) . ' <a rel="external" href="http://www.freelancephp.net/email-encoder-php-class-wp-plugin/">Email Encoder Bundle</a></p>';
766 }
767
768 $labels = array(
769 'email' => __('Email Address:', EMAIL_ENCODER_BUNDLE_DOMAIN),
770 'display' => __('Display Text:', EMAIL_ENCODER_BUNDLE_DOMAIN),
771 'mailto' => __('Mailto Link:', EMAIL_ENCODER_BUNDLE_DOMAIN),
772 'method' => __('Encoding Method:', EMAIL_ENCODER_BUNDLE_DOMAIN),
773 'create_link' => __('Create Protected Mail Link &gt;&gt;', EMAIL_ENCODER_BUNDLE_DOMAIN),
774 'output' => __('Protected Mail Link (code):', EMAIL_ENCODER_BUNDLE_DOMAIN),
775 'method_options' => $method_options,
776 'powered_by' => $powered_by,
777 );
778
779 extract($labels);
780
781 $form = <<<FORM
782 <div class="eeb-form">
783 <form>
784 <fieldset>
785 <div class="input">
786 <table>
787 <tbody>
788 <tr>
789 <th><label for="eeb-email">{$email}</label></th>
790 <td><input type="text" class="regular-text" id="eeb-email" name="eeb-email" /></td>
791 </tr>
792 <tr>
793 <th><label for="eeb-display">{$display}</label></th>
794 <td><input type="text" class="regular-text" id="eeb-display" name="eeb-display" /></td>
795 </tr>
796 <tr>
797 <th>{$mailto}</th>
798 <td><span class="eeb-example"></span></td>
799 </tr>
800 <tr>
801 <th><label for="eeb-encode-method">{$method}</label></th>
802 <td><select id="eeb-encode-method" name="eeb-encode-method" class="postform">
803 {$method_options}
804 </select>
805 <input type="button" id="eeb-ajax-encode" name="eeb-ajax-encode" value="{$create_link}" />
806 </td>
807 </tr>
808 </tbody>
809 </table>
810 </div>
811 <div class="eeb-output">
812 <table>
813 <tbody>
814 <tr>
815 <th><label for="eeb-encoded-output">{$output}</label></th>
816 <td><textarea class="large-text node" id="eeb-encoded-output" name="eeb-encoded-output" cols="50" rows="4"></textarea></td>
817 </tr>
818 </tbody>
819 </table>
820 </div>
821 {$powered_by}
822 </fieldset>
823 </form>
824 </div>
825 FORM;
826
827 // apply filters
828 $form = apply_filters('eeb_form_content', $form, $labels, $show_powered_by, $this->methods);
829
830 return $form;
831 }
832
833 } // end class Eeb_Admin
834
835 endif;
836
837 /* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */
838