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