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