Email Address Encoder - Version 1.0.9

Version Description

  • Made page scanner notice dismissable
  • Only show page scanner notice on Dashboard
  • Added setting for filter priority
  • Added EAE_DISABLE_NOTICES constant to disable all notices and promotions
  • Pass site URL along to page scanner
  • Moved cross-promotion to plugin screen
Download this release

Release Info

Developer tillkruess
Plugin Icon 128x128 Email Address Encoder
Version 1.0.9
Comparing to
See all releases

Code changes from version 1.0.8 to 1.0.9

email-address-encoder.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Email Address Encoder
4
  Plugin URI: https://encoder.till.im/
5
  Description: A lightweight plugin to protect email addresses from email-harvesting robots by encoding them into decimal and hexadecimal entities.
6
- Version: 1.0.8
7
  Author: Till Krüss
8
  Author URI: https://till.im/
9
  Text Domain: email-address-encoder
@@ -20,10 +20,13 @@ if ( ! defined( 'ABSPATH' ) ) exit;
20
  require_once __DIR__ . '/includes/admin.php';
21
 
22
  /**
23
- * Define default filter-priority constant, unless it has already been defined.
24
  */
25
  if ( ! defined( 'EAE_FILTER_PRIORITY' ) ) {
26
- define( 'EAE_FILTER_PRIORITY', 1000 );
 
 
 
27
  }
28
 
29
  /**
3
  Plugin Name: Email Address Encoder
4
  Plugin URI: https://encoder.till.im/
5
  Description: A lightweight plugin to protect email addresses from email-harvesting robots by encoding them into decimal and hexadecimal entities.
6
+ Version: 1.0.9
7
  Author: Till Krüss
8
  Author URI: https://till.im/
9
  Text Domain: email-address-encoder
20
  require_once __DIR__ . '/includes/admin.php';
21
 
22
  /**
23
+ * Define filter-priority constant, unless it has already been defined.
24
  */
25
  if ( ! defined( 'EAE_FILTER_PRIORITY' ) ) {
26
+ define(
27
+ 'EAE_FILTER_PRIORITY',
28
+ get_option( 'eae_filter_priority', 1000 )
29
+ );
30
  }
31
 
32
  /**
includes/admin.php CHANGED
@@ -2,7 +2,9 @@
2
 
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
- include __DIR__ . '/mo-notice.php';
 
 
6
 
7
  /**
8
  * Load the plugin's text domain.
@@ -29,6 +31,16 @@ add_filter( 'plugin_action_links', 'eae_plugin_actions_links', 10, 2 );
29
  */
30
  add_action( 'admin_notices', 'eae_page_scanner_notice' );
31
 
 
 
 
 
 
 
 
 
 
 
32
  /**
33
  * Callback to load the plugin's text domain.
34
  *
@@ -65,6 +77,7 @@ function eae_register_ui() {
65
  function eae_register_settings() {
66
  register_setting( 'email-address-encoder', 'eae_search_in' );
67
  register_setting( 'email-address-encoder', 'eae_technique' );
 
68
  }
69
 
70
  /**
@@ -73,8 +86,6 @@ function eae_register_settings() {
73
  * @return void
74
  */
75
  function eae_options_page() {
76
- update_user_meta( get_current_user_id(), 'eae_has_seen_options', '1' );
77
-
78
  include __DIR__ . '/ui.php';
79
  }
80
 
@@ -101,27 +112,72 @@ function eae_plugin_actions_links( $links, $file ) {
101
  }
102
 
103
  /**
104
- * Admin notices callback that display "Page Scanner" notice.
105
  *
106
  * @return void
107
  */
108
- function eae_page_scanner_notice() {
109
  $screen = get_current_screen();
110
 
111
- if ( isset( $screen->id ) && $screen->id === 'settings_page_email-address-encoder' ) {
112
  return;
113
  }
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  if ( ! current_user_can( 'manage_options' ) ) {
116
  return;
117
  }
118
 
119
- if ( get_user_meta( get_current_user_id(), 'eae_has_seen_options', true ) === '1' ) {
 
 
 
 
120
  return;
121
  }
122
 
123
  printf(
124
- '<div class="notice notice-info"><p><strong>%s</strong> %s</p></div>',
125
  __( 'Make sure all your email addresses are encoded!', 'email-address-encoder' ),
126
  sprintf(
127
  __( 'Use the <a href="%s">Page Scanner</a> to test your site.', 'email-address-encoder' ),
2
 
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
+ if ( ! defined( 'EAE_DISABLE_NOTICES' ) ) {
6
+ include __DIR__ . '/mo-notice.php';
7
+ }
8
 
9
  /**
10
  * Load the plugin's text domain.
31
  */
32
  add_action( 'admin_notices', 'eae_page_scanner_notice' );
33
 
34
+ /**
35
+ * Register admin scripts callback.
36
+ */
37
+ add_action( 'admin_enqueue_scripts', 'eae_enqueue_script' );
38
+
39
+ /**
40
+ * Register AJAX callback for "eae_dismiss_notice" action.
41
+ */
42
+ add_action( 'wp_ajax_eae_dismiss_notice', 'eae_dismiss_notice' );
43
+
44
  /**
45
  * Callback to load the plugin's text domain.
46
  *
77
  function eae_register_settings() {
78
  register_setting( 'email-address-encoder', 'eae_search_in' );
79
  register_setting( 'email-address-encoder', 'eae_technique' );
80
+ register_setting( 'email-address-encoder', 'eae_filter_priority' );
81
  }
82
 
83
  /**
86
  * @return void
87
  */
88
  function eae_options_page() {
 
 
89
  include __DIR__ . '/ui.php';
90
  }
91
 
112
  }
113
 
114
  /**
115
+ * Callback to add dismissible notices script on Dashboard screen.
116
  *
117
  * @return void
118
  */
119
+ function eae_enqueue_script() {
120
  $screen = get_current_screen();
121
 
122
+ if ( ! isset( $screen->id ) || $screen->id !== 'dashboard' ) {
123
  return;
124
  }
125
 
126
+ wp_enqueue_script(
127
+ 'dismissible-notices',
128
+ plugins_url( 'dismiss-notice.js', __FILE__ ),
129
+ array( 'jquery', 'common' )
130
+ );
131
+ }
132
+
133
+ /**
134
+ * Callback for "eae_dismiss_notice" AJAX requests.
135
+ *
136
+ * @return void
137
+ */
138
+ function eae_dismiss_notice() {
139
+ $notice = sprintf(
140
+ 'eae_dismissed_%s',
141
+ sanitize_key( $_POST[ 'notice' ] )
142
+ );
143
+
144
+ update_user_meta( get_current_user_id(), $notice, '1' );
145
+
146
+ wp_die();
147
+ }
148
+
149
+ /**
150
+ * Admin notices callback that display the "Page Scanner" notice.
151
+ *
152
+ * @return void
153
+ */
154
+ function eae_page_scanner_notice() {
155
+ $screen = get_current_screen();
156
+
157
+ if ( isset( $screen->id ) ) {
158
+ if ( $screen->id === 'settings_page_email-address-encoder' ) {
159
+ return;
160
+ }
161
+
162
+ if ( $screen->id !== 'dashboard' ) {
163
+ return;
164
+ }
165
+ }
166
+
167
  if ( ! current_user_can( 'manage_options' ) ) {
168
  return;
169
  }
170
 
171
+ if ( defined( 'EAE_DISABLE_NOTICES' ) ) {
172
+ return;
173
+ }
174
+
175
+ if ( get_user_meta( get_current_user_id(), 'eae_dismissed_page_scanner_notice', true ) === '1' ) {
176
  return;
177
  }
178
 
179
  printf(
180
+ '<div class="notice notice-info is-dismissible" data-dismissible="page_scanner_notice"><p><strong>%s</strong> %s</p></div>',
181
  __( 'Make sure all your email addresses are encoded!', 'email-address-encoder' ),
182
  sprintf(
183
  __( 'Use the <a href="%s">Page Scanner</a> to test your site.', 'email-address-encoder' ),
includes/dismiss-notice.js ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ( function ( $ ) {
2
+ $( function () {
3
+ $( ".notice[data-dismissible] .notice-dismiss" ).click(function (event) {
4
+ $.post( ajaxurl, {
5
+ notice: $( this ).parent().attr( "data-dismissible" ),
6
+ action: "eae_dismiss_notice",
7
+ } );
8
+
9
+ event.preventDefault();
10
+ } );
11
+ } );
12
+ } ( jQuery ) );
includes/mo-notice.php CHANGED
@@ -26,10 +26,10 @@ class MO_Admin_Notice
26
 
27
  public function admin_notice()
28
  {
29
- global $pagenow;
30
 
31
- if ($pagenow !== 'index.php') {
32
- return; // Only show on dashboard to avoid rendering issues on other admin pages
33
  }
34
 
35
  if ( get_option( 'mo_dismiss_adnotice', 'false' ) === 'true' ) {
@@ -71,7 +71,6 @@ class MO_Admin_Notice
71
  '<span class="mo-stylize"><strong>', '</strong></span>');
72
  ?>
73
  </p>
74
- <p style="text-decoration: underline;font-size: 12px;">Recommended by Email Address Encoder.</p>
75
  </div>
76
  <div class="mo-notice-other-half">
77
  <?php if ( ! $this->is_plugin_installed()) : ?>
@@ -113,6 +112,7 @@ class MO_Admin_Notice
113
  { ?>
114
  <style type="text/css">
115
  .mo-admin-notice {
 
116
  background: #fff;
117
  color: #000;
118
  border-left-color: #46b450;
@@ -131,15 +131,16 @@ class MO_Admin_Notice
131
  box-shadow: none;
132
  }
133
  .mo-notice-first-half {
 
134
  width: 66%;
135
- display: inline-block;
136
- margin: 10px 0;
137
  }
138
  .mo-notice-other-half {
 
139
  width: 33%;
140
- display: inline-block;
141
  padding: 20px 0;
142
- position: absolute;
143
  text-align: center;
144
  }
145
  .mo-notice-first-half p {
26
 
27
  public function admin_notice()
28
  {
29
+ $screen = get_current_screen();
30
 
31
+ if ( isset( $screen->id ) && $screen->id !== 'settings_page_email-address-encoder' ) {
32
+ return;
33
  }
34
 
35
  if ( get_option( 'mo_dismiss_adnotice', 'false' ) === 'true' ) {
71
  '<span class="mo-stylize"><strong>', '</strong></span>');
72
  ?>
73
  </p>
 
74
  </div>
75
  <div class="mo-notice-other-half">
76
  <?php if ( ! $this->is_plugin_installed()) : ?>
112
  { ?>
113
  <style type="text/css">
114
  .mo-admin-notice {
115
+ overflow: hidden;
116
  background: #fff;
117
  color: #000;
118
  border-left-color: #46b450;
131
  box-shadow: none;
132
  }
133
  .mo-notice-first-half {
134
+ float: left;
135
  width: 66%;
136
+ display: block;
137
+ margin: 0 0 10px 0;
138
  }
139
  .mo-notice-other-half {
140
+ float: right;
141
  width: 33%;
142
+ display: block;
143
  padding: 20px 0;
 
144
  text-align: center;
145
  }
146
  .mo-notice-first-half p {
includes/ui.php CHANGED
@@ -66,6 +66,18 @@
66
  </td>
67
  </tr>
68
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  </tbody>
70
  </table>
71
 
@@ -83,7 +95,7 @@
83
  <?php _e( 'For your peace of mind and a spam-free inbox, test whether email addresses are encoded on your site.', 'email-address-encoder' ); ?>
84
  </p>
85
  <p>
86
- <a class="button button-secondary" target="_blank" rel="noopener" href="https://encoder.till.im/?utm_source=wp-plugin&utm_medium=banner">
87
  <?php _e( 'Open Page Scanner', 'email-address-encoder' ); ?>
88
  </a>
89
  </p>
66
  </td>
67
  </tr>
68
 
69
+ <tr>
70
+ <th scope="row">
71
+ <?php _e( 'Filter priority', 'email-address-encoder' ); ?>
72
+ </th>
73
+ <td>
74
+ <input name="eae_filter_priority" type="number" min="1" value="<?php echo EAE_FILTER_PRIORITY; ?>" class="small-text">
75
+ <p class="description" style="max-width: 40em;">
76
+ <?php _e( 'The filter priority specifies when the plugin searches for and encodes email addresses. The default value of <code>1000</code> ensures that all other plugins have finished their execution and no emails are missed.', 'email-address-encoder' ); ?>
77
+ </p>
78
+ </td>
79
+ </tr>
80
+
81
  </tbody>
82
  </table>
83
 
95
  <?php _e( 'For your peace of mind and a spam-free inbox, test whether email addresses are encoded on your site.', 'email-address-encoder' ); ?>
96
  </p>
97
  <p>
98
+ <a class="button button-secondary" target="_blank" rel="noopener" href="https://encoder.till.im/?utm_source=wp-plugin&amp;utm_medium=banner&amp;domain=<?php echo urlencode( get_home_url() ) ?>">
99
  <?php _e( 'Open Page Scanner', 'email-address-encoder' ); ?>
100
  </a>
101
  </p>
readme.txt CHANGED
@@ -45,6 +45,15 @@ You can use the "Page Scanner" found under _Settings -> Email Encoder_ to test i
45
 
46
  == Changelog ==
47
 
 
 
 
 
 
 
 
 
 
48
  = 1.0.8 =
49
 
50
  * Added user interface
@@ -88,6 +97,10 @@ You can use the "Page Scanner" found under _Settings -> Email Encoder_ to test i
88
 
89
  == Upgrade Notice ==
90
 
 
 
 
 
91
  = 1.0.8 =
92
 
93
  This release adds a minimal user interface and page scanner.
45
 
46
  == Changelog ==
47
 
48
+ = 1.0.9 =
49
+
50
+ * Made page scanner notice dismissable
51
+ * Only show page scanner notice on Dashboard
52
+ * Added setting for filter priority
53
+ * Added `EAE_DISABLE_NOTICES` constant to disable all notices and promotions
54
+ * Pass site URL along to page scanner
55
+ * Moved cross-promotion to plugin screen
56
+
57
  = 1.0.8 =
58
 
59
  * Added user interface
97
 
98
  == Upgrade Notice ==
99
 
100
+ = 1.0.9 =
101
+
102
+ This release includes several improvements related to admin notices.
103
+
104
  = 1.0.8 =
105
 
106
  This release adds a minimal user interface and page scanner.