Akismet Anti-Spam - Version 3.3.4

Version Description

  • Disabled Akismet's debug log output by default unless AKISMET_DEBUG is defined.
  • URL previews now begin preloading when the mouse moves near them in the comments section of wp-admin.
  • When a comment is caught by the Comment Blacklist, Akismet will always allow it to stay in the trash even if it is spam as well.
  • Fixed a bug that was preventing an error from being shown when a site can't reach Akismet's servers.
Download this release

Release Info

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

Code changes from version 3.3.3 to 3.3.4

_inc/akismet.js CHANGED
@@ -3,6 +3,8 @@ jQuery( function ( $ ) {
3
  var mshotSecondTryTimer = null
4
  var mshotThirdTryTimer = null
5
 
 
 
6
  $('.akismet-status').each(function () {
7
  var thisId = $(this).attr('commentid');
8
  $(this).prependTo('#comment-' + thisId + ' .column-comment');
@@ -82,7 +84,7 @@ jQuery( function ( $ ) {
82
  });
83
 
84
  // Show a preview image of the hovered URL. Applies to author URLs and URLs inside the comments.
85
- $( '#the-comment-list' ).on( 'mouseover', 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a', function () {
86
  clearTimeout( mshotRemovalTimer );
87
 
88
  if ( $( '.akismet-mshot' ).length > 0 ) {
@@ -99,9 +101,9 @@ jQuery( function ( $ ) {
99
  clearTimeout( mshotSecondTryTimer );
100
  clearTimeout( mshotThirdTryTimer );
101
 
102
- var thisHref = encodeURIComponent( $( this ).attr( 'href' ) );
103
 
104
- var mShot = $( '<div class="akismet-mshot mshot-container"><div class="mshot-arrow"></div><img src="//s0.wordpress.com/mshots/v1/' + thisHref + '?w=900" width="450" height="338" class="mshot-image" /></div>' );
105
  mShot.data( 'link', this );
106
 
107
  var offset = $( this ).offset();
@@ -115,11 +117,11 @@ jQuery( function ( $ ) {
115
  // can return a "Generating thumbnail..." image if it doesn't have a thumbnail ready, so we need
116
  // to retry to see if we can get the newly generated thumbnail.
117
  mshotSecondTryTimer = setTimeout( function () {
118
- mShot.find( '.mshot-image' ).attr( 'src', '//s0.wordpress.com/mshots/v1/'+thisHref+'?w=900&r=2' );
119
  }, 6000 );
120
 
121
  mshotThirdTryTimer = setTimeout( function () {
122
- mShot.find( '.mshot-image' ).attr( 'src', '//s0.wordpress.com/mshots/v1/'+thisHref+'?w=900&r=3' );
123
  }, 12000 );
124
 
125
  $( 'body' ).append( mShot );
@@ -130,6 +132,18 @@ jQuery( function ( $ ) {
130
 
131
  $( '.akismet-mshot' ).remove();
132
  }, 200 );
 
 
 
 
 
 
 
 
 
 
 
 
133
  } );
134
 
135
  $('.checkforspam:not(.button-disabled)').click( function(e) {
@@ -226,4 +240,31 @@ jQuery( function ( $ ) {
226
  }
227
  });
228
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  });
3
  var mshotSecondTryTimer = null
4
  var mshotThirdTryTimer = null
5
 
6
+ var mshotEnabledLinkSelector = 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a';
7
+
8
  $('.akismet-status').each(function () {
9
  var thisId = $(this).attr('commentid');
10
  $(this).prependTo('#comment-' + thisId + ' .column-comment');
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 ) {
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();
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 );
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:not(.button-disabled)').click( function(e) {
240
  }
241
  });
242
  }
243
+
244
+ /**
245
+ * Generate an mShot URL if given a link URL.
246
+ *
247
+ * @param string linkUrl
248
+ * @param int retry If retrying a request, the number of the retry.
249
+ * @return string The mShot URL;
250
+ */
251
+ function akismet_mshot_url( linkUrl, retry ) {
252
+ var mshotUrl = '//s0.wordpress.com/mshots/v1/' + encodeURIComponent( linkUrl ) + '?w=900';
253
+
254
+ if ( retry ) {
255
+ mshotUrl += '&r=' + encodeURIComponent( retry );
256
+ }
257
+
258
+ return mshotUrl;
259
+ }
260
+
261
+ /**
262
+ * Begin loading an mShot preview of a link.
263
+ *
264
+ * @param string linkUrl
265
+ */
266
+ function akismet_preload_mshot( linkUrl ) {
267
+ var img = new Image();
268
+ img.src = akismet_mshot_url( linkUrl );
269
+ }
270
  });
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: 3.3.3
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', '3.3.3' );
41
  define( 'AKISMET__MINIMUM_WP_VERSION', '3.7' );
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: 3.3.4
10
  Author: Automattic
11
  Author URI: https://automattic.com/wordpress-plugins/
12
  License: GPLv2 or later
37
  exit;
38
  }
39
 
40
+ define( 'AKISMET_VERSION', '3.3.4' );
41
  define( 'AKISMET__MINIMUM_WP_VERSION', '3.7' );
42
  define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
43
  define( 'AKISMET_DELETE_LIMIT', 100000 );
class.akismet-admin.php CHANGED
@@ -1019,7 +1019,7 @@ class Akismet_Admin {
1019
 
1020
  public static function display_status() {
1021
  if ( ! self::get_server_connectivity() ) {
1022
- Akismet::view( 'notice', compact( 'servers-be-down' ) );
1023
  }
1024
  else if ( ! empty( self::$notices ) ) {
1025
  foreach ( self::$notices as $index => $type ) {
1019
 
1020
  public static function display_status() {
1021
  if ( ! self::get_server_connectivity() ) {
1022
+ Akismet::view( 'notice', array( 'type' => 'servers-be-down' ) );
1023
  }
1024
  else if ( ! empty( self::$notices ) ) {
1025
  foreach ( self::$notices as $index => $type ) {
class.akismet.php CHANGED
@@ -914,6 +914,15 @@ class Akismet {
914
  return $approved;
915
  }
916
 
 
 
 
 
 
 
 
 
 
917
  // bump the counter here instead of when the filter is added to reduce the possibility of overcounting
918
  if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
919
  update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
@@ -1198,7 +1207,7 @@ p {
1198
  * @param mixed $akismet_debug The data to log.
1199
  */
1200
  public static function log( $akismet_debug ) {
1201
- if ( apply_filters( 'akismet_debug_log', defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) ) {
1202
  error_log( print_r( compact( 'akismet_debug' ), true ) );
1203
  }
1204
  }
914
  return $approved;
915
  }
916
 
917
+ if ( 'trash' === $approved ) {
918
+ // If the last comment we checked has had its approval set to 'trash',
919
+ // then it failed the comment blacklist check. Let that blacklist override
920
+ // the spam check, since users have the (valid) expectation that when
921
+ // they fill out their blacklists, comments that match it will always
922
+ // end up in the trash.
923
+ return $approved;
924
+ }
925
+
926
  // bump the counter here instead of when the filter is added to reduce the possibility of overcounting
927
  if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
928
  update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
1207
  * @param mixed $akismet_debug The data to log.
1208
  */
1209
  public static function log( $akismet_debug ) {
1210
+ if ( apply_filters( 'akismet_debug_log', defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG && defined( 'AKISMET_DEBUG' ) && AKISMET_DEBUG ) ) {
1211
  error_log( print_r( compact( 'akismet_debug' ), true ) );
1212
  }
1213
  }
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs
3
  Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
4
  Requires at least: 3.7
5
- Tested up to: 4.8
6
- Stable tag: 3.3.3
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,13 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
30
 
31
  == Changelog ==
32
 
 
 
 
 
 
 
 
33
  = 3.3.3 =
34
  *Release Date - 13 July 2017*
35
 
2
  Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs
3
  Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
4
  Requires at least: 3.7
5
+ Tested up to: 4.8.1
6
+ Stable tag: 3.3.4
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
+ = 3.3.4 =
34
+
35
+ * Disabled Akismet's debug log output by default unless AKISMET_DEBUG is defined.
36
+ * URL previews now begin preloading when the mouse moves near them in the comments section of wp-admin.
37
+ * When a comment is caught by the Comment Blacklist, Akismet will always allow it to stay in the trash even if it is spam as well.
38
+ * Fixed a bug that was preventing an error from being shown when a site can't reach Akismet's servers.
39
+
40
  = 3.3.3 =
41
  *Release Date - 13 July 2017*
42
 
views/notice.php CHANGED
@@ -46,8 +46,8 @@
46
  </div>
47
  <?php elseif ( $type == 'servers-be-down' ) :?>
48
  <div class="akismet-alert akismet-critical">
49
- <h3 class="akismet-key-status failed"><?php esc_html_e("Akismet can&#8217;t connect to your site.", 'akismet'); ?></h3>
50
- <p class="akismet-description"><?php printf( __('Your firewall may be blocking Akismet. Please contact your host and refer to <a href="%s" target="_blank">our guide about firewalls</a>.', 'akismet'), 'https://blog.akismet.com/akismet-hosting-faq/'); ?></p>
51
  </div>
52
  <?php elseif ( $type == 'active-dunning' ) :?>
53
  <div class="akismet-alert akismet-critical">
46
  </div>
47
  <?php elseif ( $type == 'servers-be-down' ) :?>
48
  <div class="akismet-alert akismet-critical">
49
+ <h3 class="akismet-key-status failed"><?php esc_html_e("Your site can&#8217;t connect to the Akismet servers.", 'akismet'); ?></h3>
50
+ <p class="akismet-description"><?php printf( __('Your firewall may be blocking Akismet from connecting to its API. Please contact your host and refer to <a href="%s" target="_blank">our guide about firewalls</a>.', 'akismet'), 'https://blog.akismet.com/akismet-hosting-faq/'); ?></p>
51
  </div>
52
  <?php elseif ( $type == 'active-dunning' ) :?>
53
  <div class="akismet-alert akismet-critical">