Akismet Anti-Spam - Version 4.1.6

Version Description

Release Date - 4 June 2020

  • Disable "Check for Spam" button until the page is loaded to avoid errors with clicking through to queue recheck endpoint directly.
  • Add filter "akismet_enable_mshots" to allow disabling screenshot popups on the edit comments admin page.
Download this release

Release Info

Developer procifer
Plugin Icon 128x128 Akismet Anti-Spam
Version 4.1.6
Comparing to
See all releases

Code changes from version 4.1.5 to 4.1.6

Files changed (5) hide show
  1. _inc/akismet.css +0 -9
  2. _inc/akismet.js +55 -55
  3. akismet.php +2 -2
  4. class.akismet-admin.php +19 -17
  5. readme.txt +8 -2
_inc/akismet.css CHANGED
@@ -79,15 +79,6 @@ table.comments td.comment p a:after {
79
  .checkforspam {
80
  display: inline-block !important;
81
  }
82
- .checkforspam-progress {
83
- display: none;
84
- }
85
- .checkforspam.checking .checkforspam-progress {
86
- padding-left: 1ex;
87
- }
88
- .checkforspam.button-disabled .checkforspam-progress {
89
- display: inline;
90
- }
91
 
92
  .checkforspam-spinner {
93
  display: inline-block;
79
  .checkforspam {
80
  display: inline-block !important;
81
  }
 
 
 
 
 
 
 
 
 
82
 
83
  .checkforspam-spinner {
84
  display: inline-block;
_inc/akismet.js CHANGED
@@ -84,70 +84,72 @@ jQuery( function ( $ ) {
84
  });
85
 
86
  // Show a preview image of the hovered URL. Applies to author URLs and URLs inside the comments.
87
- $( '#the-comment-list' ).on( 'mouseover', mshotEnabledLinkSelector, function () {
88
- clearTimeout( mshotRemovalTimer );
 
89
 
90
- if ( $( '.akismet-mshot' ).length > 0 ) {
91
- if ( $( '.akismet-mshot:first' ).data( 'link' ) == this ) {
92
- // The preview is already showing for this link.
93
- return;
94
- }
95
- else {
96
- // A new link is being hovered, so remove the old preview.
97
- $( '.akismet-mshot' ).remove();
 
98
  }
99
- }
100
 
101
- clearTimeout( mshotSecondTryTimer );
102
- clearTimeout( mshotThirdTryTimer );
103
 
104
- var thisHref = $( this ).attr( 'href' );
105
 
106
- var mShot = $( '<div class="akismet-mshot mshot-container"><div class="mshot-arrow"></div><img src="' + akismet_mshot_url( thisHref ) + '" width="450" height="338" class="mshot-image" /></div>' );
107
- mShot.data( 'link', this );
108
 
109
- var offset = $( this ).offset();
110
 
111
- mShot.offset( {
112
- left : Math.min( $( window ).width() - 475, offset.left + $( this ).width() + 10 ), // Keep it on the screen if the link is near the edge of the window.
113
- top: offset.top + ( $( this ).height() / 2 ) - 101 // 101 = top offset of the arrow plus the top border thickness
114
- } );
115
 
116
- // These retries appear to be superfluous if .mshot-image has already loaded, but it's because mShots
117
- // can return a "Generating thumbnail..." image if it doesn't have a thumbnail ready, so we need
118
- // to retry to see if we can get the newly generated thumbnail.
119
- mshotSecondTryTimer = setTimeout( function () {
120
- mShot.find( '.mshot-image' ).attr( 'src', akismet_mshot_url( thisHref, 2 ) );
121
- }, 6000 );
122
 
123
- mshotThirdTryTimer = setTimeout( function () {
124
- mShot.find( '.mshot-image' ).attr( 'src', akismet_mshot_url( thisHref, 3 ) );
125
- }, 12000 );
126
 
127
- $( 'body' ).append( mShot );
128
- } ).on( 'mouseout', 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a', function () {
129
- mshotRemovalTimer = setTimeout( function () {
130
- clearTimeout( mshotSecondTryTimer );
131
- clearTimeout( mshotThirdTryTimer );
132
 
133
- $( '.akismet-mshot' ).remove();
134
- }, 200 );
135
- } ).on( 'mouseover', 'tr', function () {
136
- // When the mouse hovers over a comment row, begin preloading mshots for any links in the comment or the comment author.
137
- var linksToPreloadMshotsFor = $( this ).find( mshotEnabledLinkSelector );
138
-
139
- linksToPreloadMshotsFor.each( function () {
140
- // Don't attempt to preload an mshot for a single link twice. Browser caching should cover this, but in case of
141
- // race conditions, save a flag locally when we've begun trying to preload one.
142
- if ( ! $( this ).data( 'akismet-mshot-preloaded' ) ) {
143
- akismet_preload_mshot( $( this ).attr( 'href' ) );
144
- $( this ).data( 'akismet-mshot-preloaded', true );
145
- }
 
146
  } );
147
- } );
148
 
149
- $( '.checkforspam' ).click( function( e ) {
150
- if ( $( this ).hasClass( 'checkforspam-pending-config' ) ) {
151
  // Akismet hasn't been configured yet. Allow the user to proceed to the button's link.
152
  return;
153
  }
@@ -162,11 +164,9 @@ jQuery( function ( $ ) {
162
  $('.checkforspam').addClass('button-disabled').addClass( 'checking' );
163
  $('.checkforspam-spinner').addClass( 'spinner' ).addClass( 'is-active' );
164
 
165
- // Update the label on the "Check for Spam" button to use the active "Checking for Spam" language.
166
- $( '.checkforspam .akismet-label' ).text( $( '.checkforspam' ).data( 'active-label' ) );
167
-
168
  akismet_check_for_spam(0, 100);
169
  });
 
170
 
171
  var spam_count = 0;
172
  var recheck_count = 0;
@@ -181,7 +181,7 @@ jQuery( function ( $ ) {
181
  var percentage_complete = Math.round( ( recheck_count / check_for_spam_buttons.data( 'pending-comment-count' ) ) * 1000 ) / 10;
182
 
183
  // Update the progress counter on the "Check for Spam" button.
184
- $( '.checkforspam-progress' ).text( check_for_spam_buttons.data( 'progress-label-format' ).replace( '%1$s', percentage_complete ) );
185
 
186
  $.post(
187
  ajaxurl,
84
  });
85
 
86
  // Show a preview image of the hovered URL. Applies to author URLs and URLs inside the comments.
87
+ if ( "enable_mshots" in WPAkismet && WPAkismet.enable_mshots ) {
88
+ $( '#the-comment-list' ).on( 'mouseover', mshotEnabledLinkSelector, function () {
89
+ clearTimeout( mshotRemovalTimer );
90
 
91
+ if ( $( '.akismet-mshot' ).length > 0 ) {
92
+ if ( $( '.akismet-mshot:first' ).data( 'link' ) == this ) {
93
+ // The preview is already showing for this link.
94
+ return;
95
+ }
96
+ else {
97
+ // A new link is being hovered, so remove the old preview.
98
+ $( '.akismet-mshot' ).remove();
99
+ }
100
  }
 
101
 
102
+ clearTimeout( mshotSecondTryTimer );
103
+ clearTimeout( mshotThirdTryTimer );
104
 
105
+ var thisHref = $( this ).attr( 'href' );
106
 
107
+ var mShot = $( '<div class="akismet-mshot mshot-container"><div class="mshot-arrow"></div><img src="' + akismet_mshot_url( thisHref ) + '" width="450" height="338" class="mshot-image" /></div>' );
108
+ mShot.data( 'link', this );
109
 
110
+ var offset = $( this ).offset();
111
 
112
+ mShot.offset( {
113
+ left : Math.min( $( window ).width() - 475, offset.left + $( this ).width() + 10 ), // Keep it on the screen if the link is near the edge of the window.
114
+ top: offset.top + ( $( this ).height() / 2 ) - 101 // 101 = top offset of the arrow plus the top border thickness
115
+ } );
116
 
117
+ // These retries appear to be superfluous if .mshot-image has already loaded, but it's because mShots
118
+ // can return a "Generating thumbnail..." image if it doesn't have a thumbnail ready, so we need
119
+ // to retry to see if we can get the newly generated thumbnail.
120
+ mshotSecondTryTimer = setTimeout( function () {
121
+ mShot.find( '.mshot-image' ).attr( 'src', akismet_mshot_url( thisHref, 2 ) );
122
+ }, 6000 );
123
 
124
+ mshotThirdTryTimer = setTimeout( function () {
125
+ mShot.find( '.mshot-image' ).attr( 'src', akismet_mshot_url( thisHref, 3 ) );
126
+ }, 12000 );
127
 
128
+ $( 'body' ).append( mShot );
129
+ } ).on( 'mouseout', 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a', function () {
130
+ mshotRemovalTimer = setTimeout( function () {
131
+ clearTimeout( mshotSecondTryTimer );
132
+ clearTimeout( mshotThirdTryTimer );
133
 
134
+ $( '.akismet-mshot' ).remove();
135
+ }, 200 );
136
+ } ).on( 'mouseover', 'tr', function () {
137
+ // When the mouse hovers over a comment row, begin preloading mshots for any links in the comment or the comment author.
138
+ var linksToPreloadMshotsFor = $( this ).find( mshotEnabledLinkSelector );
139
+
140
+ linksToPreloadMshotsFor.each( function () {
141
+ // Don't attempt to preload an mshot for a single link twice. Browser caching should cover this, but in case of
142
+ // race conditions, save a flag locally when we've begun trying to preload one.
143
+ if ( ! $( this ).data( 'akismet-mshot-preloaded' ) ) {
144
+ akismet_preload_mshot( $( this ).attr( 'href' ) );
145
+ $( this ).data( 'akismet-mshot-preloaded', true );
146
+ }
147
+ } );
148
  } );
149
+ }
150
 
151
+ $( '.checkforspam.enable-on-load' ).click( function( e ) {
152
+ if ( $( this ).hasClass( 'ajax-disabled' ) ) {
153
  // Akismet hasn't been configured yet. Allow the user to proceed to the button's link.
154
  return;
155
  }
164
  $('.checkforspam').addClass('button-disabled').addClass( 'checking' );
165
  $('.checkforspam-spinner').addClass( 'spinner' ).addClass( 'is-active' );
166
 
 
 
 
167
  akismet_check_for_spam(0, 100);
168
  });
169
+ $( '.checkforspam.enable-on-load' ).removeClass( 'button-disabled' );
170
 
171
  var spam_count = 0;
172
  var recheck_count = 0;
181
  var percentage_complete = Math.round( ( recheck_count / check_for_spam_buttons.data( 'pending-comment-count' ) ) * 1000 ) / 10;
182
 
183
  // Update the progress counter on the "Check for Spam" button.
184
+ $( '.checkforspam' ).text( check_for_spam_buttons.data( 'progress-label' ).replace( '%1$s', percentage_complete ) );
185
 
186
  $.post(
187
  ajaxurl,
akismet.php CHANGED
@@ -6,7 +6,7 @@
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: 4.1.5
10
  Author: Automattic
11
  Author URI: https://automattic.com/wordpress-plugins/
12
  License: GPLv2 or later
@@ -37,7 +37,7 @@ if ( !function_exists( 'add_action' ) ) {
37
  exit;
38
  }
39
 
40
- define( 'AKISMET_VERSION', '4.1.5' );
41
  define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' );
42
  define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
43
  define( 'AKISMET_DELETE_LIMIT', 100000 );
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: 4.1.6
10
  Author: Automattic
11
  Author URI: https://automattic.com/wordpress-plugins/
12
  License: GPLv2 or later
37
  exit;
38
  }
39
 
40
+ define( 'AKISMET_VERSION', '4.1.6' );
41
  define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' );
42
  define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
43
  define( 'AKISMET_DELETE_LIMIT', 100000 );
class.akismet-admin.php CHANGED
@@ -137,7 +137,7 @@ class Akismet_Admin {
137
 
138
  wp_register_script( 'akismet.js', plugin_dir_url( __FILE__ ) . '_inc/akismet.js', array('jquery'), AKISMET_VERSION );
139
  wp_enqueue_script( 'akismet.js' );
140
-
141
  $inline_js = array(
142
  'comment_author_url_nonce' => wp_create_nonce( 'comment_author_url_nonce' ),
143
  'strings' => array(
@@ -153,6 +153,10 @@ class Akismet_Admin {
153
  $inline_js['start_recheck'] = true;
154
  }
155
 
 
 
 
 
156
  wp_localize_script( 'akismet.js', 'WPAkismet', $inline_js );
157
  }
158
  }
@@ -383,7 +387,7 @@ class Akismet_Admin {
383
  return;
384
  }
385
 
386
- $link = add_query_arg( array( 'action' => 'akismet_recheck_queue' ), admin_url( 'admin.php' ) );
387
 
388
  $comments_count = wp_count_comments();
389
 
@@ -393,32 +397,30 @@ class Akismet_Admin {
393
  $classes = array(
394
  'button-secondary',
395
  'checkforspam',
 
396
  );
397
 
398
- if ( ! Akismet::get_api_key() ) {
399
- $link = admin_url( 'options-general.php?page=akismet-key-config' );
400
 
401
- $classes[] = 'checkforspam-pending-config';
 
 
 
402
  }
403
 
404
- if ( $comments_count->moderated == 0 ) {
405
- $classes[] = 'button-disabled';
406
- }
407
  echo '<a
408
- class="' . esc_attr( implode( ' ', $classes ) ) . '"
409
- href="' . esc_url( $link ) . '"
410
- data-active-label="' . esc_attr( __( 'Checking for Spam', 'akismet' ) ) . '"
411
- data-progress-label-format="' . esc_attr( __( '(%1$s%)', 'akismet' ) ) . '"
412
  data-success-url="' . esc_attr( remove_query_arg( array( 'akismet_recheck', 'akismet_recheck_error' ), add_query_arg( array( 'akismet_recheck_complete' => 1, 'recheck_count' => urlencode( '__recheck_count__' ), 'spam_count' => urlencode( '__spam_count__' ) ) ) ) ) . '"
413
  data-failure-url="' . esc_attr( remove_query_arg( array( 'akismet_recheck', 'akismet_recheck_complete' ), add_query_arg( array( 'akismet_recheck_error' => 1 ) ) ) ) . '"
414
  data-pending-comment-count="' . esc_attr( $comments_count->moderated ) . '"
415
  data-nonce="' . esc_attr( wp_create_nonce( 'akismet_check_for_spam' ) ) . '"
416
- >';
417
- echo '<span class="akismet-label">' . esc_html__('Check for Spam', 'akismet') . '</span>';
418
- echo '<span class="checkforspam-progress"></span>';
419
- echo '</a>';
420
  echo '<span class="checkforspam-spinner"></span>';
421
-
422
  }
423
 
424
  public static function recheck_queue() {
137
 
138
  wp_register_script( 'akismet.js', plugin_dir_url( __FILE__ ) . '_inc/akismet.js', array('jquery'), AKISMET_VERSION );
139
  wp_enqueue_script( 'akismet.js' );
140
+
141
  $inline_js = array(
142
  'comment_author_url_nonce' => wp_create_nonce( 'comment_author_url_nonce' ),
143
  'strings' => array(
153
  $inline_js['start_recheck'] = true;
154
  }
155
 
156
+ if ( apply_filters( 'akismet_enable_mshots', true ) ) {
157
+ $inline_js['enable_mshots'] = true;
158
+ }
159
+
160
  wp_localize_script( 'akismet.js', 'WPAkismet', $inline_js );
161
  }
162
  }
387
  return;
388
  }
389
 
390
+ $link = '';
391
 
392
  $comments_count = wp_count_comments();
393
 
397
  $classes = array(
398
  'button-secondary',
399
  'checkforspam',
400
+ 'button-disabled' // Disable button until the page is loaded
401
  );
402
 
403
+ if ( $comments_count->moderated > 0 ) {
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
  }
411
 
 
 
 
412
  echo '<a
413
+ class="' . esc_attr( implode( ' ', $classes ) ) . '"' .
414
+ ( ! empty( $link ) ? ' href="' . esc_url( $link ) . '"' : '' ) .
415
+ /* translators: The placeholder is for showing how much of the process has completed, as a percent. e.g., "Checking for Spam (40%)" */
416
+ ' data-progress-label="' . esc_attr( __( 'Checking for Spam (%1$s%)', 'akismet' ) ) . '"
417
  data-success-url="' . esc_attr( remove_query_arg( array( 'akismet_recheck', 'akismet_recheck_error' ), add_query_arg( array( 'akismet_recheck_complete' => 1, 'recheck_count' => urlencode( '__recheck_count__' ), 'spam_count' => urlencode( '__spam_count__' ) ) ) ) ) . '"
418
  data-failure-url="' . esc_attr( remove_query_arg( array( 'akismet_recheck', 'akismet_recheck_complete' ), add_query_arg( array( 'akismet_recheck_error' => 1 ) ) ) ) . '"
419
  data-pending-comment-count="' . esc_attr( $comments_count->moderated ) . '"
420
  data-nonce="' . esc_attr( wp_create_nonce( 'akismet_check_for_spam' ) ) . '"
421
+ ' . ( ! in_array( 'ajax-disabled', $classes ) ? 'onclick="return false;"' : '' ) . '
422
+ >' . esc_html__('Check for Spam', 'akismet') . '</a>';
 
 
423
  echo '<span class="checkforspam-spinner"></span>';
 
424
  }
425
 
426
  public static function recheck_queue() {
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eo
3
  Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
4
  Requires at least: 4.6
5
  Tested up to: 5.4
6
- Stable tag: 4.1.5
7
  License: GPLv2 or later
8
 
9
  Akismet checks your comments and contact form submissions against our global database of spam to protect you and your site from malicious content.
@@ -30,6 +30,12 @@ Upload the Akismet plugin to your blog, activate it, and then enter your Akismet
30
 
31
  == Changelog ==
32
 
 
 
 
 
 
 
33
  = 4.1.5 =
34
  *Release Date - 29 April 2020*
35
 
@@ -77,4 +83,4 @@ Upload the Akismet plugin to your blog, activate it, and then enter your Akismet
77
  * Hooked into the new "Personal Data Eraser" functionality from WordPress 4.9.6.
78
  * Added functionality to clear outdated alerts from Akismet.com.
79
 
80
- For older changelog entries, please see the [additional changelog.txt file](https://plugins.svn.wordpress.org/akismet/trunk/changelog.txt) delivered with the plugin.
3
  Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
4
  Requires at least: 4.6
5
  Tested up to: 5.4
6
+ Stable tag: 4.1.6
7
  License: GPLv2 or later
8
 
9
  Akismet checks your comments and contact form submissions against our global database of spam to protect you and your site from malicious content.
30
 
31
  == Changelog ==
32
 
33
+ = 4.1.6 =
34
+ *Release Date - 4 June 2020*
35
+
36
+ * Disable "Check for Spam" button until the page is loaded to avoid errors with clicking through to queue recheck endpoint directly.
37
+ * Add filter "akismet_enable_mshots" to allow disabling screenshot popups on the edit comments admin page.
38
+
39
  = 4.1.5 =
40
  *Release Date - 29 April 2020*
41
 
83
  * Hooked into the new "Personal Data Eraser" functionality from WordPress 4.9.6.
84
  * Added functionality to clear outdated alerts from Akismet.com.
85
 
86
+ For older changelog entries, please see the [additional changelog.txt file](https://plugins.svn.wordpress.org/akismet/trunk/changelog.txt) delivered with the plugin.