Akismet Anti-Spam - Version 5.0.1

Version Description

Release Date - 28 September 2022

  • Added an empty state for the Statistics section on the admin page.
  • Fixed a bug that broke some admin page links when Jetpack plugins are active.
  • Marked some event listeners as passive to improve performance in newer browsers.
  • Disabled interaction observation on forms that post to other domains.
Download this release

Release Info

Developer cfinke
Plugin Icon 128x128 Akismet Anti-Spam
Version 5.0.1
Comparing to
See all releases

Code changes from version 5.0 to 5.0.1

Files changed (5) hide show
  1. _inc/akismet-frontend.js +40 -12
  2. akismet.php +4 -2
  3. class.akismet-admin.php +12 -9
  4. readme.txt +10 -2
  5. views/config.php +23 -14
_inc/akismet-frontend.js CHANGED
@@ -5,6 +5,22 @@
5
  */
6
 
7
  ( function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  function init() {
9
  var input_begin = '';
10
 
@@ -44,6 +60,18 @@
44
  for ( var i = 0; i < forms.length; i++ ) {
45
  var form = forms[i];
46
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  form.addEventListener( 'submit', function () {
48
  var ak_bkp = prepare_timestamp_array_for_request( keypresses );
49
  var ak_bmc = prepare_timestamp_array_for_request( mouseclicks );
@@ -101,7 +129,7 @@
101
  field.setAttribute( 'value', input_fields[ field_name ] );
102
  this.appendChild( field );
103
  }
104
- } );
105
 
106
  form.addEventListener( 'keydown', function ( e ) {
107
  // If you hold a key down, some browsers send multiple keydown events in a row.
@@ -129,7 +157,7 @@
129
  }
130
 
131
  lastKeydown = keydownTime;
132
- } );
133
 
134
  form.addEventListener( 'keyup', function ( e ) {
135
  if ( ! ( e.key in keydowns ) ) {
@@ -167,24 +195,24 @@
167
  delete keydowns[ e.key ];
168
 
169
  lastKeyup = keyupTime;
170
- } );
171
 
172
  form.addEventListener( "focusin", function ( e ) {
173
  lastKeydown = null;
174
  lastKeyup = null;
175
  keydowns = {};
176
- } );
177
 
178
  form.addEventListener( "focusout", function ( e ) {
179
  lastKeydown = null;
180
  lastKeyup = null;
181
  keydowns = {};
182
- } );
183
  }
184
 
185
  document.addEventListener( 'mousedown', function ( e ) {
186
  lastMousedown = ( new Date() ).getTime();
187
- } );
188
 
189
  document.addEventListener( 'mouseup', function ( e ) {
190
  if ( ! lastMousedown ) {
@@ -209,7 +237,7 @@
209
  lastKeydown = null;
210
  lastKeyup = null;
211
  keydowns = {};
212
- } );
213
 
214
  document.addEventListener( 'mousemove', function ( e ) {
215
  if ( mousemoveTimer ) {
@@ -244,7 +272,7 @@
244
  mousemoveStart = null;
245
  mousemoveTimer = null;
246
  }, 250, e, mousemoveStart );
247
- } );
248
 
249
  document.addEventListener( 'touchmove', function ( e ) {
250
  if ( touchmoveCountTimer ) {
@@ -254,11 +282,11 @@
254
  touchmoveCountTimer = setTimeout( function () {
255
  touchmoveCount++;
256
  }, 250 );
257
- } );
258
 
259
  document.addEventListener( 'touchstart', function ( e ) {
260
  lastTouchStart = ( new Date() ).getTime();
261
- } );
262
 
263
  document.addEventListener( 'touchend', function ( e ) {
264
  if ( ! lastTouchStart ) {
@@ -283,7 +311,7 @@
283
  lastKeydown = null;
284
  lastKeyup = null;
285
  keydowns = {};
286
- } );
287
 
288
  document.addEventListener( 'scroll', function ( e ) {
289
  if ( scrollCountTimer ) {
@@ -293,7 +321,7 @@
293
  scrollCountTimer = setTimeout( function () {
294
  scrollCount++;
295
  }, 250 );
296
- } );
297
  }
298
 
299
  /**
5
  */
6
 
7
  ( function() {
8
+ // Passive event listeners are guaranteed to never call e.preventDefault(),
9
+ // but they're not supported in all browsers. Use this feature detection
10
+ // to determine whether they're available for use.
11
+ var supportsPassive = false;
12
+
13
+ try {
14
+ var opts = Object.defineProperty( {}, 'passive', {
15
+ get : function() {
16
+ supportsPassive = true;
17
+ }
18
+ } );
19
+
20
+ window.addEventListener( 'testPassive', null, opts );
21
+ window.removeEventListener( 'testPassive', null, opts );
22
+ } catch ( e ) {}
23
+
24
  function init() {
25
  var input_begin = '';
26
 
60
  for ( var i = 0; i < forms.length; i++ ) {
61
  var form = forms[i];
62
 
63
+ var formAction = form.getAttribute( 'action' );
64
+
65
+ // Ignore forms that POST directly to other domains; these could be things like payment forms.
66
+ if ( formAction ) {
67
+ // Check that the form is posting to an external URL, not a path.
68
+ if ( formAction.indexOf( 'http://' ) == 0 || formAction.indexOf( 'https://' ) == 0 ) {
69
+ if ( formAction.indexOf( 'http://' + window.location.hostname + '/' ) != 0 && formAction.indexOf( 'https://' + window.location.hostname + '/' ) != 0 ) {
70
+ continue;
71
+ }
72
+ }
73
+ }
74
+
75
  form.addEventListener( 'submit', function () {
76
  var ak_bkp = prepare_timestamp_array_for_request( keypresses );
77
  var ak_bmc = prepare_timestamp_array_for_request( mouseclicks );
129
  field.setAttribute( 'value', input_fields[ field_name ] );
130
  this.appendChild( field );
131
  }
132
+ }, supportsPassive ? { passive: true } : false );
133
 
134
  form.addEventListener( 'keydown', function ( e ) {
135
  // If you hold a key down, some browsers send multiple keydown events in a row.
157
  }
158
 
159
  lastKeydown = keydownTime;
160
+ }, supportsPassive ? { passive: true } : false );
161
 
162
  form.addEventListener( 'keyup', function ( e ) {
163
  if ( ! ( e.key in keydowns ) ) {
195
  delete keydowns[ e.key ];
196
 
197
  lastKeyup = keyupTime;
198
+ }, supportsPassive ? { passive: true } : false );
199
 
200
  form.addEventListener( "focusin", function ( e ) {
201
  lastKeydown = null;
202
  lastKeyup = null;
203
  keydowns = {};
204
+ }, supportsPassive ? { passive: true } : false );
205
 
206
  form.addEventListener( "focusout", function ( e ) {
207
  lastKeydown = null;
208
  lastKeyup = null;
209
  keydowns = {};
210
+ }, supportsPassive ? { passive: true } : false );
211
  }
212
 
213
  document.addEventListener( 'mousedown', function ( e ) {
214
  lastMousedown = ( new Date() ).getTime();
215
+ }, supportsPassive ? { passive: true } : false );
216
 
217
  document.addEventListener( 'mouseup', function ( e ) {
218
  if ( ! lastMousedown ) {
237
  lastKeydown = null;
238
  lastKeyup = null;
239
  keydowns = {};
240
+ }, supportsPassive ? { passive: true } : false );
241
 
242
  document.addEventListener( 'mousemove', function ( e ) {
243
  if ( mousemoveTimer ) {
272
  mousemoveStart = null;
273
  mousemoveTimer = null;
274
  }, 250, e, mousemoveStart );
275
+ }, supportsPassive ? { passive: true } : false );
276
 
277
  document.addEventListener( 'touchmove', function ( e ) {
278
  if ( touchmoveCountTimer ) {
282
  touchmoveCountTimer = setTimeout( function () {
283
  touchmoveCount++;
284
  }, 250 );
285
+ }, supportsPassive ? { passive: true } : false );
286
 
287
  document.addEventListener( 'touchstart', function ( e ) {
288
  lastTouchStart = ( new Date() ).getTime();
289
+ }, supportsPassive ? { passive: true } : false );
290
 
291
  document.addEventListener( 'touchend', function ( e ) {
292
  if ( ! lastTouchStart ) {
311
  lastKeydown = null;
312
  lastKeyup = null;
313
  keydowns = {};
314
+ }, supportsPassive ? { passive: true } : false );
315
 
316
  document.addEventListener( 'scroll', function ( e ) {
317
  if ( scrollCountTimer ) {
321
  scrollCountTimer = setTimeout( function () {
322
  scrollCount++;
323
  }, 250 );
324
+ }, supportsPassive ? { passive: true } : false );
325
  }
326
 
327
  /**
akismet.php CHANGED
@@ -6,7 +6,9 @@
6
  Plugin Name: Akismet Anti-Spam
7
  Plugin URI: https://akismet.com/
8
  Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from spam</strong>. It keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key.
9
- Version: 5.0
 
 
10
  Author: Automattic
11
  Author URI: https://automattic.com/wordpress-plugins/
12
  License: GPLv2 or later
@@ -37,7 +39,7 @@ if ( !function_exists( 'add_action' ) ) {
37
  exit;
38
  }
39
 
40
- define( 'AKISMET_VERSION', '5.0' );
41
  define( 'AKISMET__MINIMUM_WP_VERSION', '5.0' );
42
  define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
43
  define( 'AKISMET_DELETE_LIMIT', 10000 );
6
  Plugin Name: Akismet Anti-Spam
7
  Plugin URI: https://akismet.com/
8
  Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from spam</strong>. It keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key.
9
+ Version: 5.0.1
10
+ Requires at least: 5.0
11
+ Requires PHP: 5.2
12
  Author: Automattic
13
  Author URI: https://automattic.com/wordpress-plugins/
14
  License: GPLv2 or later
39
  exit;
40
  }
41
 
42
+ define( 'AKISMET_VERSION', '5.0.1' );
43
  define( 'AKISMET__MINIMUM_WP_VERSION', '5.0' );
44
  define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
45
  define( 'AKISMET_DELETE_LIMIT', 10000 );
class.akismet-admin.php CHANGED
@@ -74,7 +74,8 @@ class Akismet_Admin {
74
  if ( get_option( 'Activated_Akismet' ) ) {
75
  delete_option( 'Activated_Akismet' );
76
  if ( ! headers_sent() ) {
77
- wp_redirect( add_query_arg( array( 'page' => 'akismet-key-config', 'view' => 'start' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'options-general.php' ) ) );
 
78
  }
79
  }
80
 
@@ -90,10 +91,11 @@ class Akismet_Admin {
90
  }
91
 
92
  public static function admin_menu() {
93
- if ( class_exists( 'Jetpack' ) )
94
  add_action( 'jetpack_admin_menu', array( 'Akismet_Admin', 'load_menu' ) );
95
- else
96
  self::load_menu();
 
97
  }
98
 
99
  public static function admin_head() {
@@ -404,7 +406,7 @@ class Akismet_Admin {
404
  $classes[] = 'enable-on-load';
405
 
406
  if ( ! Akismet::get_api_key() ) {
407
- $link = add_query_arg( array( 'page' => 'akismet-key-config' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'options-general.php' ) );
408
  $classes[] = 'ajax-disabled';
409
  }
410
  }
@@ -825,14 +827,15 @@ class Akismet_Admin {
825
 
826
  $args = array( 'page' => 'akismet-key-config' );
827
 
828
- if ( $page == 'stats' )
829
  $args = array( 'page' => 'akismet-key-config', 'view' => 'stats' );
830
- elseif ( $page == 'delete_key' )
831
  $args = array( 'page' => 'akismet-key-config', 'view' => 'start', 'action' => 'delete-key', '_wpnonce' => wp_create_nonce( self::NONCE ) );
 
 
 
832
 
833
- $url = add_query_arg( $args, class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'options-general.php' ) );
834
-
835
- return $url;
836
  }
837
 
838
  public static function get_akismet_user( $api_key ) {
74
  if ( get_option( 'Activated_Akismet' ) ) {
75
  delete_option( 'Activated_Akismet' );
76
  if ( ! headers_sent() ) {
77
+ $admin_url = self::get_page_url( 'init' );
78
+ wp_redirect( $admin_url );
79
  }
80
  }
81
 
91
  }
92
 
93
  public static function admin_menu() {
94
+ if ( class_exists( 'Jetpack' ) ) {
95
  add_action( 'jetpack_admin_menu', array( 'Akismet_Admin', 'load_menu' ) );
96
+ } else {
97
  self::load_menu();
98
+ }
99
  }
100
 
101
  public static function admin_head() {
406
  $classes[] = 'enable-on-load';
407
 
408
  if ( ! Akismet::get_api_key() ) {
409
+ $link = self::get_page_url();
410
  $classes[] = 'ajax-disabled';
411
  }
412
  }
827
 
828
  $args = array( 'page' => 'akismet-key-config' );
829
 
830
+ if ( $page == 'stats' ) {
831
  $args = array( 'page' => 'akismet-key-config', 'view' => 'stats' );
832
+ } elseif ( $page == 'delete_key' ) {
833
  $args = array( 'page' => 'akismet-key-config', 'view' => 'start', 'action' => 'delete-key', '_wpnonce' => wp_create_nonce( self::NONCE ) );
834
+ } elseif ( $page === 'init' ) {
835
+ $args = array( 'page' => 'akismet-key-config', 'view' => 'start' );
836
+ }
837
 
838
+ return add_query_arg( $args, menu_page_url( 'akismet-key-config', false ) );
 
 
839
  }
840
 
841
  public static function get_akismet_user( $api_key ) {
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer, stephdau, kbrownkd
3
  Tags: comments, spam, antispam, anti-spam, contact form, anti spam, comment moderation, comment spam, contact form spam, spam comments
4
  Requires at least: 5.0
5
- Tested up to: 6.0.1
6
- Stable tag: 5.0
7
  License: GPLv2 or later
8
 
9
  The best anti-spam protection to block spam comments and spam in a contact form. The most trusted antispam solution for WordPress and WooCommerce.
@@ -30,6 +30,14 @@ Upload the Akismet plugin to your blog, activate it, and then enter your Akismet
30
 
31
  == Changelog ==
32
 
 
 
 
 
 
 
 
 
33
  = 5.0 =
34
  *Release Date - 26 July 2022*
35
 
2
  Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer, stephdau, kbrownkd
3
  Tags: comments, spam, antispam, anti-spam, contact form, anti spam, comment moderation, comment spam, contact form spam, spam comments
4
  Requires at least: 5.0
5
+ Tested up to: 6.1
6
+ Stable tag: 5.0.1
7
  License: GPLv2 or later
8
 
9
  The best anti-spam protection to block spam comments and spam in a contact form. The most trusted antispam solution for WordPress and WooCommerce.
30
 
31
  == Changelog ==
32
 
33
+ = 5.0.1 =
34
+ *Release Date - 28 September 2022*
35
+
36
+ * Added an empty state for the Statistics section on the admin page.
37
+ * Fixed a bug that broke some admin page links when Jetpack plugins are active.
38
+ * Marked some event listeners as passive to improve performance in newer browsers.
39
+ * Disabled interaction observation on forms that post to other domains.
40
+
41
  = 5.0 =
42
  *Release Date - 26 July 2022*
43
 
views/config.php CHANGED
@@ -21,19 +21,21 @@
21
  <?php Akismet::view( 'notice', $notice ); ?>
22
  <?php } ?>
23
  <?php } ?>
24
- <?php if ( $stat_totals && isset( $stat_totals['all'] ) && (int) $stat_totals['all']->spam > 0 ) : ?>
25
- <div class="akismet-card">
26
- <div class="akismet-section-header">
27
- <div class="akismet-section-header__label">
28
- <span><?php esc_html_e( 'Statistics' , 'akismet'); ?></span>
29
- </div>
30
- <div class="akismet-section-header__actions">
31
- <a href="<?php echo esc_url( Akismet_Admin::get_page_url( 'stats' ) ); ?>">
32
- <?php esc_html_e( 'Detailed Stats' , 'akismet');?>
33
- </a>
34
- </div>
35
  </div>
36
-
 
 
 
 
 
 
 
 
37
  <div class="akismet-new-snapshot">
38
  <iframe allowtransparency="true" scrolling="no" frameborder="0" style="width: 100%; height: 220px; overflow: hidden;" src="<?php echo esc_url( sprintf( 'https://tools.akismet.com/1.0/snapshot.php?blog=%s&api_key=%s&height=200&locale=%s', urlencode( get_option( 'home' ) ), Akismet::get_api_key(), get_locale() ) ); ?>"></iframe>
39
  <ul>
@@ -55,9 +57,16 @@
55
  <?php printf( _n( '%s false positive', '%s false positives', $stat_totals['all']->false_positives, 'akismet' ), number_format( $stat_totals['all']->false_positives ) ); ?>
56
  </li>
57
  </ul>
58
- </div>
 
 
 
 
 
59
  </div>
60
- <?php endif;?>
 
 
61
 
62
  <?php if ( $akismet_user ) : ?>
63
  <div class="akismet-card">
21
  <?php Akismet::view( 'notice', $notice ); ?>
22
  <?php } ?>
23
  <?php } ?>
24
+
25
+ <div class="akismet-card">
26
+ <div class="akismet-section-header">
27
+ <div class="akismet-section-header__label">
28
+ <span><?php esc_html_e( 'Statistics', 'akismet' ); ?></span>
 
 
 
 
 
 
29
  </div>
30
+
31
+ <?php if ( $stat_totals && isset( $stat_totals['all'] ) && (int) $stat_totals['all']->spam > 0 ) : ?>
32
+ <div class="akismet-section-header__actions">
33
+ <a href="<?php echo esc_url( Akismet_Admin::get_page_url( 'stats' ) ); ?>">
34
+ <?php esc_html_e( 'Detailed Stats', 'akismet' ); ?>
35
+ </a>
36
+ </div>
37
+ </div> <!-- close akismet-section-header -->
38
+
39
  <div class="akismet-new-snapshot">
40
  <iframe allowtransparency="true" scrolling="no" frameborder="0" style="width: 100%; height: 220px; overflow: hidden;" src="<?php echo esc_url( sprintf( 'https://tools.akismet.com/1.0/snapshot.php?blog=%s&api_key=%s&height=200&locale=%s', urlencode( get_option( 'home' ) ), Akismet::get_api_key(), get_locale() ) ); ?>"></iframe>
41
  <ul>
57
  <?php printf( _n( '%s false positive', '%s false positives', $stat_totals['all']->false_positives, 'akismet' ), number_format( $stat_totals['all']->false_positives ) ); ?>
58
  </li>
59
  </ul>
60
+ </div> <!-- close akismet-new-snapshot -->
61
+
62
+ <?php else : ?>
63
+ </div> <!-- close akismet-section-header -->
64
+ <div class="inside">
65
+ <p>Akismet is active and ready to stop spam. Your site's spam statistics will be displayed here.</p>
66
  </div>
67
+ <?php endif; ?>
68
+
69
+ </div> <!-- close akismet-card -->
70
 
71
  <?php if ( $akismet_user ) : ?>
72
  <div class="akismet-card">