Akismet Anti-Spam - Version 2.5.1

Version Description

  • Fix a bug that caused the "Auto delete" option to fail to discard comments correctly
  • Remove the comment nonce form field from the 'Akismet Configuration' page in favor of using a filter, akismet_comment_nonce
  • Fixed padding bug in "author" column of posts screen
  • Added margin-top to "cleared by ..." badges on dashboard
  • Fix possible error when calling akismet_cron_recheck()
  • Fix more PHP warnings
  • Clean up XHTML warnings for comment nonce
  • Fix for possible condition where scheduled comment re-checks could get stuck
  • Clean up the comment meta details after deleting a comment
  • Only show the status badge if the comment status has been changed by someone/something other than Akismet
  • Show a 'History' link in the row-actions
  • Translation fixes
  • Reduced font-size on author name
  • Moved "flagged by..." notification to top right corner of comment container and removed heavy styling
  • Hid "flagged by..." notification while on dashboard
Download this release

Release Info

Developer tellyworth
Plugin Icon 128x128 Akismet Anti-Spam
Version 2.5.1
Comparing to
See all releases

Code changes from version 2.5.0 to 2.5.1

Files changed (6) hide show
  1. admin.php +38 -30
  2. akismet.css +10 -10
  3. akismet.js +1 -1
  4. akismet.php +29 -10
  5. readme.txt +21 -3
  6. widget.php +4 -6
admin.php CHANGED
@@ -25,9 +25,9 @@ function akismet_admin_init() {
25
  $hook = 'dashboard_page_akismet-stats-display';
26
  add_action('admin_head-'.$hook, 'akismet_stats_script');
27
  add_meta_box('akismet-status', __('Comment History'), 'akismet_comment_status_meta_box', 'comment', 'normal');
28
- wp_register_style('akismet.css', AKISMET_PLUGIN_URL . '/akismet.css');
29
  wp_enqueue_style('akismet.css');
30
- wp_register_script('akismet.js', AKISMET_PLUGIN_URL . '/akismet.js', array('jquery'));
31
  wp_enqueue_script('akismet.js');
32
  }
33
  add_action('admin_init', 'akismet_admin_init');
@@ -91,11 +91,6 @@ function akismet_conf() {
91
  else
92
  update_option( 'akismet_show_user_comments_approved', 'false' );
93
 
94
- if ( isset( $_POST['akismet_comment_nonce'] ) )
95
- update_option( 'akismet_comment_nonce', 'true' );
96
- else
97
- update_option( 'akismet_comment_nonce', 'false' );
98
-
99
  } elseif ( isset($_POST['check']) ) {
100
  akismet_get_server_connectivity(0);
101
  }
@@ -141,7 +136,7 @@ function akismet_conf() {
141
  <div class="wrap">
142
  <h2><?php _e('Akismet Configuration'); ?></h2>
143
  <?php if (isset($_GET['message']) && $_GET['message'] == 'success') { ?>
144
- <div class="updated below-h2" id="message"><p><strong>Sign up success!</strong> Please check your email for your Akismet API Key and enter it below.</p></div>
145
  <?php } ?>
146
  <div class="narrow">
147
  <form action="" method="post" id="akismet-conf" style="margin: auto; width: 400px; ">
@@ -161,7 +156,6 @@ function akismet_conf() {
161
  <?php akismet_nonce_field($akismet_nonce) ?>
162
  <p><label><input name="akismet_discard_month" id="akismet_discard_month" value="true" type="checkbox" <?php if ( get_option('akismet_discard_month') == 'true' ) echo ' checked="checked" '; ?> /> <?php _e('Auto-delete spam submitted on posts more than a month old.'); ?></label></p>
163
  <p><label><input name="akismet_show_user_comments_approved" id="akismet_show_user_comments_approved" value="true" type="checkbox" <?php if ( get_option('akismet_show_user_comments_approved') == 'true' ) echo ' checked="checked" '; ?> /> <?php _e('Show the number of comments you\'ve approved beside each comment author.'); ?></label></p>
164
- <p><label><input name="akismet_comment_nonce" id="akismet_comment_nonce" value="true" type="checkbox" <?php if ( get_option( 'akismet_comment_nonce' ) == 'true' || get_option( 'akismet_comment_nonce' ) == '' ) echo ' checked="checked" '; ?> /> <?php _e( 'Use a nonce on the comment form.' ); ?></label></p>
165
  <p class="submit"><input type="submit" name="submit" value="<?php _e('Update options &raquo;'); ?>" /></p>
166
  </form>
167
 
@@ -281,13 +275,13 @@ function akismet_stats() {
281
  if ( !$count = get_option('akismet_spam_count') )
282
  return;
283
  $path = plugin_basename(__FILE__);
284
- echo '<h3>'.__('Spam').'</h3>';
285
  global $submenu;
286
  if ( isset( $submenu['edit-comments.php'] ) )
287
  $link = 'edit-comments.php';
288
  else
289
  $link = 'edit.php';
290
- echo '<p>'.sprintf(__('<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.'), 'http://akismet.com/', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'</p>';
291
  }
292
  add_action('activity_box_end', 'akismet_stats');
293
 
@@ -308,7 +302,7 @@ function akismet_admin_warnings() {
308
  $next_check = human_time_diff( wp_next_scheduled('akismet_schedule_cron_recheck') );
309
  if ( $waiting > 0 )
310
  echo "
311
- <div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet has detected a problem.')."</strong> ".sprintf(_n('A server or network problem prevented Akismet from checking %d comment. It has been temporarily held for moderation and will be automatically re-checked in %s.', 'A server or network problem prevented Akismet from checking %d comments. They have been temporarily held for moderation and will be automatically re-checked in %s.', $waiting), $waiting, $next_check)."</p></div>
312
  ";
313
  }
314
  add_action('admin_notices', 'akismet_warning');
@@ -326,13 +320,14 @@ function akismet_comment_row_action( $a, $comment ) {
326
 
327
  $akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );
328
  $user_result = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);
 
329
  $desc = null;
330
  if ( !$user_result || $user_result == $akismet_result ) {
331
  // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
332
- if ( $akismet_result == 'true' )
333
- $desc = 'Flagged as spam by Akismet';
334
- elseif ( $akismet_result == 'false' )
335
- $desc = 'Cleared by Akismet';
336
  } else {
337
  $who = get_comment_meta( $comment->comment_ID, 'akismet_user', true );
338
  if ( $user_result == 'true' )
@@ -340,13 +335,25 @@ function akismet_comment_row_action( $a, $comment ) {
340
  else
341
  $desc = sprintf( __('Un-spammed by %s'), $who );
342
  }
343
-
 
 
 
 
 
 
 
 
 
 
 
 
344
  if ( $desc )
345
  echo '<span class="akismet-status" commentid="'.$comment->comment_ID.'"><a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="' . esc_attr__( 'View comment history' ) . '">'.htmlspecialchars($desc).'</a></span>';
346
 
347
  if ( apply_filters( 'akismet_show_user_comments_approved', get_option('akismet_show_user_comments_approved') ) == 'true' ) {
348
  $comment_count = akimset_get_user_comments_approved( $comment->user_id, $comment->comment_author_email, $comment->comment_author, $comment->comment_author_url );
349
- echo '<span class="akismet-user-comment-count" commentid="'.$comment->comment_ID.'" style="display:none;"><br><span class="akismet-user-comment-counts">'.sprintf( __( '%s approved' ), intval($comment_count) ).'</span></span>';
350
  }
351
 
352
  return $a;
@@ -441,30 +448,25 @@ function akismet_rightnow() {
441
 
442
  if ( $count = get_option('akismet_spam_count') ) {
443
  $intro = sprintf( $plural_func(
444
- '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already,',
445
- '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already,',
446
  $count
447
  ), 'http://akismet.com/', number_format_i18n( $count ) );
448
  } else {
449
- $intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog,'), 'http://akismet.com/' );
450
  }
451
 
452
  if ( $queue_count = akismet_spam_count() ) {
453
  $queue_text = sprintf( $plural_func(
454
- 'and there\'s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
455
- 'and there are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
456
  $queue_count
457
  ), number_format_i18n( $queue_count ), $esc_url($link) );
458
  } else {
459
- $queue_text = sprintf( __( " but there's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), $esc_url($link) );
460
  }
461
 
462
- // _c was deprecated in WP 2.9.0
463
- if ( function_exists( '_x' ) )
464
- $text = sprintf( _x( '%1$s%2$s', 'akismet_rightnow' ), $intro, $queue_text );
465
- else
466
- $text = sprintf( _c( '%1$s%2$s|akismet_rightnow' ), $intro, $queue_text );
467
-
468
  echo "<p class='akismet-right-now'>$text</p>\n";
469
  }
470
 
@@ -582,6 +584,12 @@ function akismet_submit_spam_comment ( $comment_id ) {
582
  function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
583
  if ( $new_status == $old_status )
584
  return;
 
 
 
 
 
 
585
 
586
  if ( defined('WP_IMPORTING') && WP_IMPORTING == true )
587
  return;
25
  $hook = 'dashboard_page_akismet-stats-display';
26
  add_action('admin_head-'.$hook, 'akismet_stats_script');
27
  add_meta_box('akismet-status', __('Comment History'), 'akismet_comment_status_meta_box', 'comment', 'normal');
28
+ wp_register_style('akismet.css', AKISMET_PLUGIN_URL . 'akismet.css');
29
  wp_enqueue_style('akismet.css');
30
+ wp_register_script('akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery'));
31
  wp_enqueue_script('akismet.js');
32
  }
33
  add_action('admin_init', 'akismet_admin_init');
91
  else
92
  update_option( 'akismet_show_user_comments_approved', 'false' );
93
 
 
 
 
 
 
94
  } elseif ( isset($_POST['check']) ) {
95
  akismet_get_server_connectivity(0);
96
  }
136
  <div class="wrap">
137
  <h2><?php _e('Akismet Configuration'); ?></h2>
138
  <?php if (isset($_GET['message']) && $_GET['message'] == 'success') { ?>
139
+ <div class="updated below-h2" id="message"><p><?php _e( '<strong>Sign up success!</strong> Please check your email for your Akismet API Key and enter it below.' ); ?></p></div>
140
  <?php } ?>
141
  <div class="narrow">
142
  <form action="" method="post" id="akismet-conf" style="margin: auto; width: 400px; ">
156
  <?php akismet_nonce_field($akismet_nonce) ?>
157
  <p><label><input name="akismet_discard_month" id="akismet_discard_month" value="true" type="checkbox" <?php if ( get_option('akismet_discard_month') == 'true' ) echo ' checked="checked" '; ?> /> <?php _e('Auto-delete spam submitted on posts more than a month old.'); ?></label></p>
158
  <p><label><input name="akismet_show_user_comments_approved" id="akismet_show_user_comments_approved" value="true" type="checkbox" <?php if ( get_option('akismet_show_user_comments_approved') == 'true' ) echo ' checked="checked" '; ?> /> <?php _e('Show the number of comments you\'ve approved beside each comment author.'); ?></label></p>
 
159
  <p class="submit"><input type="submit" name="submit" value="<?php _e('Update options &raquo;'); ?>" /></p>
160
  </form>
161
 
275
  if ( !$count = get_option('akismet_spam_count') )
276
  return;
277
  $path = plugin_basename(__FILE__);
278
+ echo '<h3>' . _x( 'Spam', 'comments' ) . '</h3>';
279
  global $submenu;
280
  if ( isset( $submenu['edit-comments.php'] ) )
281
  $link = 'edit-comments.php';
282
  else
283
  $link = 'edit.php';
284
+ echo '<p>'.sprintf( _n( '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', $count ), 'http://akismet.com/', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'</p>';
285
  }
286
  add_action('activity_box_end', 'akismet_stats');
287
 
302
  $next_check = human_time_diff( wp_next_scheduled('akismet_schedule_cron_recheck') );
303
  if ( $waiting > 0 )
304
  echo "
305
+ <div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet has detected a problem.')."</strong> ".sprintf(_n('A server or network problem prevented Akismet from checking %d comment. It has been temporarily held for moderation and will be automatically re-checked in %s.', 'A server or network problem prevented Akismet from checking %d comments. They have been temporarily held for moderation and will be automatically re-checked in %s.', $waiting), number_format_i18n( $waiting ), $next_check)."</p></div>
306
  ";
307
  }
308
  add_action('admin_notices', 'akismet_warning');
320
 
321
  $akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );
322
  $user_result = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);
323
+ $comment_status = wp_get_comment_status( $comment->comment_ID );
324
  $desc = null;
325
  if ( !$user_result || $user_result == $akismet_result ) {
326
  // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
327
+ if ( $akismet_result == 'true' && $comment_status != 'spam' && $comment_status != 'trash' )
328
+ $desc = __( 'Flagged as spam by Akismet' );
329
+ elseif ( $akismet_result == 'false' && $comment_status == 'spam' )
330
+ $desc = __( 'Cleared by Akismet' );
331
  } else {
332
  $who = get_comment_meta( $comment->comment_ID, 'akismet_user', true );
333
  if ( $user_result == 'true' )
335
  else
336
  $desc = sprintf( __('Un-spammed by %s'), $who );
337
  }
338
+
339
+ // add a History item to the hover links, just after Edit
340
+ if ( $akismet_result ) {
341
+ $b = array();
342
+ foreach ( $a as $k => $item ) {
343
+ $b[ $k ] = $item;
344
+ if ( $k == 'edit' )
345
+ $b['history'] = '<a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="'. esc_attr__( 'View comment history' ) . '"> '. __('History') . '</a>';
346
+ }
347
+
348
+ $a = $b;
349
+ }
350
+
351
  if ( $desc )
352
  echo '<span class="akismet-status" commentid="'.$comment->comment_ID.'"><a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="' . esc_attr__( 'View comment history' ) . '">'.htmlspecialchars($desc).'</a></span>';
353
 
354
  if ( apply_filters( 'akismet_show_user_comments_approved', get_option('akismet_show_user_comments_approved') ) == 'true' ) {
355
  $comment_count = akimset_get_user_comments_approved( $comment->user_id, $comment->comment_author_email, $comment->comment_author, $comment->comment_author_url );
356
+ echo '<span class="akismet-user-comment-count" commentid="'.$comment->comment_ID.'" style="display:none;"><br><span class="akismet-user-comment-counts">'.sprintf( _n( '%s approved', '%s approved', $comment_count ), intval($comment_count) ).'</span></span>';
357
  }
358
 
359
  return $a;
448
 
449
  if ( $count = get_option('akismet_spam_count') ) {
450
  $intro = sprintf( $plural_func(
451
+ '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already. ',
452
+ '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already. ',
453
  $count
454
  ), 'http://akismet.com/', number_format_i18n( $count ) );
455
  } else {
456
+ $intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog. '), 'http://akismet.com/' );
457
  }
458
 
459
  if ( $queue_count = akismet_spam_count() ) {
460
  $queue_text = sprintf( $plural_func(
461
+ 'There\'s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
462
+ 'There are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
463
  $queue_count
464
  ), number_format_i18n( $queue_count ), $esc_url($link) );
465
  } else {
466
+ $queue_text = sprintf( __( "There's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), $esc_url($link) );
467
  }
468
 
469
+ $text = $intro . '<br />' . $queue_text;
 
 
 
 
 
470
  echo "<p class='akismet-right-now'>$text</p>\n";
471
  }
472
 
584
  function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
585
  if ( $new_status == $old_status )
586
  return;
587
+
588
+ if ( !is_admin() )
589
+ return;
590
+
591
+ if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )
592
+ return;
593
 
594
  if ( defined('WP_IMPORTING') && WP_IMPORTING == true )
595
  return;
akismet.css CHANGED
@@ -1,12 +1,12 @@
1
-
2
  #submitted-on { position: relative; }
3
- .author { padding-bottom: 5px !important; white-space: nowrap; }
4
- .author a { padding-left: 42px !important; }
5
- .author img { position: absolute; top: 1px; left: 0; }
6
- .author strong { padding-left: 42px; font-size: 14px; position: relative; }
7
- .author .akismet-user-comment-count { display: inline; }
8
- .author .akismet-user-comment-counts { padding-left: 42px; }
9
- .akismet-status { background: #EEE; border: 1px solid #E4E4E4; color: #999; margin-bottom: 5px; padding: 1px 8px 2px 8px; -moz-border-radius:6px; border-radius:6px; -webkit-border-radius:6px; float: right; line-height: 1.2em; }
10
- .row-actions { margin-top: -3px; }
 
11
  span.comment-link a { text-decoration: underline; }
12
- span.comment-link:after { content: " " attr(title) " "; color: #aaa; text-decoration: none; }
 
1
  #submitted-on { position: relative; }
2
+ #the-comment-list .author { padding-bottom: 5px !important; white-space: nowrap; }
3
+ #the-comment-list .author a { padding-left: 42px !important; }
4
+ #the-comment-list .author img { position: absolute; top: 0; left: 0; }
5
+ #the-comment-list .author strong { padding-left: 42px; font-size: 12px; position: relative; }
6
+ #the-comment-list .author .akismet-user-comment-count { display: inline; }
7
+ #the-comment-list .author .akismet-user-comment-counts { padding-left: 42px; }
8
+ #dashboard_recent_comments .akismet-status { display: none; } /* never show the flagged by text on the dashboard */
9
+ .akismet-status { float: right; }
10
+ .akismet-status a { color: #AAA; font-style: italic; }
11
  span.comment-link a { text-decoration: underline; }
12
+ span.comment-link:after { content: " " attr(title) " "; color: #aaa; text-decoration: none; }
akismet.js CHANGED
@@ -1,7 +1,7 @@
1
  jQuery(document).ready(function () {
2
  jQuery('.akismet-status').each(function () {
3
  var thisId = jQuery(this).attr('commentid');
4
- jQuery(this).prependTo('#comment-' + thisId + ' #submitted-on');
5
  });
6
  jQuery('.akismet-user-comment-count').each(function () {
7
  var thisId = jQuery(this).attr('commentid');
1
  jQuery(document).ready(function () {
2
  jQuery('.akismet-status').each(function () {
3
  var thisId = jQuery(this).attr('commentid');
4
+ jQuery(this).prependTo('#comment-' + thisId + ' .column-comment div:first-child');
5
  });
6
  jQuery('.akismet-user-comment-count').each(function () {
7
  var thisId = jQuery(this).attr('commentid');
akismet.php CHANGED
@@ -5,8 +5,8 @@
5
  /*
6
  Plugin Name: Akismet
7
  Plugin URI: http://akismet.com/
8
- Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and track-back spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="https:akismet.com/signup/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your <a href="plugins.php?page=akismet-key-config">Akismet configuration</a> page, and save your API key.
9
- Version: 2.5.0
10
  Author: Automattic
11
  Author URI: http://automattic.com/wordpress-plugins/
12
  License: GPLv2
@@ -83,8 +83,6 @@ function akismet_verify_key( $key, $ip = null ) {
83
 
84
  // if we're in debug or test modes, use a reduced service level so as not to polute training or stats data
85
  function akismet_test_mode() {
86
- if ( defined('WP_DEBUG') && WP_DEBUG )
87
- return true;
88
  if ( defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE )
89
  return true;
90
  return false;
@@ -207,7 +205,7 @@ function akismet_update_comment_history( $comment_id, $message, $event=null ) {
207
  return false;
208
 
209
  $user = '';
210
- if ( is_object($current_user) )
211
  $user = $current_user->user_login;
212
 
213
  $event = array(
@@ -297,7 +295,7 @@ function akismet_auto_check_comment( $commentdata ) {
297
 
298
  $comment['user_role'] = akismet_get_user_roles($comment['user_ID']);
299
 
300
- $akismet_nonce_option = get_option( 'akismet_comment_nonce' );
301
  $comment['akismet_comment_nonce'] = 'inactive';
302
  if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) {
303
  $comment['akismet_comment_nonce'] = 'failed';
@@ -351,6 +349,7 @@ function akismet_auto_check_comment( $commentdata ) {
351
  if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
352
  update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
353
  wp_redirect( $_SERVER['HTTP_REFERER'] );
 
354
  }
355
  }
356
 
@@ -380,9 +379,13 @@ function akismet_delete_old() {
380
  $comment_ids = $wpdb->get_col("SELECT comment_id FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'");
381
  if ( empty( $comment_ids ) )
382
  return;
 
 
383
 
384
  do_action( 'delete_comment', $comment_ids );
385
- $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( " . implode( ', ', $comment_ids ) . " )");
 
 
386
  $n = mt_rand(1, 5000);
387
  if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number
388
  $wpdb->query("OPTIMIZE TABLE $wpdb->comments");
@@ -419,7 +422,7 @@ function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
419
  return $response[1];
420
  }
421
 
422
- function akismet_cron_recheck( $data ) {
423
  global $wpdb;
424
 
425
  delete_option('akismet_available_servers');
@@ -428,9 +431,16 @@ function akismet_cron_recheck( $data ) {
428
  SELECT comment_id
429
  FROM {$wpdb->prefix}commentmeta
430
  WHERE meta_key = 'akismet_error'
 
431
  " );
432
-
433
  foreach ( (array) $comment_errors as $comment_id ) {
 
 
 
 
 
 
434
  add_comment_meta( $comment_id, 'akismet_rechecking', true );
435
  $status = akismet_check_db_comment( $comment_id, 'retry' );
436
 
@@ -466,12 +476,21 @@ function akismet_cron_recheck( $data ) {
466
  return;
467
  }
468
  }
 
 
 
 
 
469
  }
470
  add_action( 'akismet_schedule_cron_recheck', 'akismet_cron_recheck' );
471
 
472
  function akismet_add_comment_nonce( $post_id ) {
 
473
  wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE );
 
474
  }
475
 
476
- if ( get_option( 'akismet_comment_nonce' ) == 'true' || get_option( 'akismet_comment_nonce' ) == '' )
 
 
477
  add_action( 'comment_form', 'akismet_add_comment_nonce' );
5
  /*
6
  Plugin Name: Akismet
7
  Plugin URI: http://akismet.com/
8
+ Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and track-back spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your <a href="plugins.php?page=akismet-key-config">Akismet configuration</a> page, and save your API key.
9
+ Version: 2.5.1
10
  Author: Automattic
11
  Author URI: http://automattic.com/wordpress-plugins/
12
  License: GPLv2
83
 
84
  // if we're in debug or test modes, use a reduced service level so as not to polute training or stats data
85
  function akismet_test_mode() {
 
 
86
  if ( defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE )
87
  return true;
88
  return false;
205
  return false;
206
 
207
  $user = '';
208
+ if ( is_object($current_user) && isset($current_user->user_login) )
209
  $user = $current_user->user_login;
210
 
211
  $event = array(
295
 
296
  $comment['user_role'] = akismet_get_user_roles($comment['user_ID']);
297
 
298
+ $akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
299
  $comment['akismet_comment_nonce'] = 'inactive';
300
  if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) {
301
  $comment['akismet_comment_nonce'] = 'failed';
349
  if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
350
  update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
351
  wp_redirect( $_SERVER['HTTP_REFERER'] );
352
+ die();
353
  }
354
  }
355
 
379
  $comment_ids = $wpdb->get_col("SELECT comment_id FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'");
380
  if ( empty( $comment_ids ) )
381
  return;
382
+
383
+ $comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) );
384
 
385
  do_action( 'delete_comment', $comment_ids );
386
+ $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( $comma_comment_ids )");
387
+ $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id IN ( $comma_comment_ids )");
388
+ clean_comment_cache( $comment_ids );
389
  $n = mt_rand(1, 5000);
390
  if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number
391
  $wpdb->query("OPTIMIZE TABLE $wpdb->comments");
422
  return $response[1];
423
  }
424
 
425
+ function akismet_cron_recheck() {
426
  global $wpdb;
427
 
428
  delete_option('akismet_available_servers');
431
  SELECT comment_id
432
  FROM {$wpdb->prefix}commentmeta
433
  WHERE meta_key = 'akismet_error'
434
+ LIMIT 100
435
  " );
436
+
437
  foreach ( (array) $comment_errors as $comment_id ) {
438
+ // if the comment no longer exists, remove the meta entry from the queue to avoid getting stuck
439
+ if ( !get_comment( $comment_id ) ) {
440
+ delete_comment_meta( $comment_id, 'akismet_error' );
441
+ continue;
442
+ }
443
+
444
  add_comment_meta( $comment_id, 'akismet_rechecking', true );
445
  $status = akismet_check_db_comment( $comment_id, 'retry' );
446
 
476
  return;
477
  }
478
  }
479
+
480
+ $remaining = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" ) );
481
+ if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) {
482
+ wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
483
+ }
484
  }
485
  add_action( 'akismet_schedule_cron_recheck', 'akismet_cron_recheck' );
486
 
487
  function akismet_add_comment_nonce( $post_id ) {
488
+ echo '<p style="display: none;">';
489
  wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE );
490
+ echo '</p>';
491
  }
492
 
493
+ $akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
494
+
495
+ if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' )
496
  add_action( 'comment_form', 'akismet_add_comment_nonce' );
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, automattic
3
  Tags: akismet, comments, spam
4
  Requires at least: 3.0
5
- Tested up to: 3.0
6
- Stable tag: 2.5.0
7
  License: GPLv2
8
 
9
  Akismet checks your comments against the Akismet web service to see if they look like spam or not.
@@ -21,7 +21,7 @@ Major new features in Akismet 2.5 include:
21
  * Moderators can see the number of approved comments for each user
22
  * Spam and Unspam reports now include more information, to help improve accuracy
23
 
24
- PS: You'll need an [Akismet.com API key](http://akismet.com/signup/) to use it. Keys are free for personal blogs, with paid subscriptions available for businesses and commercial sites.
25
 
26
  == Installation ==
27
 
@@ -31,6 +31,24 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
31
 
32
  == Changelog ==
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  = 2.5.0 =
35
 
36
  * Track comment actions under 'Akismet Status' on the edit comment screen
2
  Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, automattic
3
  Tags: akismet, comments, spam
4
  Requires at least: 3.0
5
+ Tested up to: 3.1
6
+ Stable tag: 2.5.1
7
  License: GPLv2
8
 
9
  Akismet checks your comments against the Akismet web service to see if they look like spam or not.
21
  * Moderators can see the number of approved comments for each user
22
  * Spam and Unspam reports now include more information, to help improve accuracy
23
 
24
+ PS: You'll need an [Akismet.com API key](http://akismet.com/get/) to use it. Keys are free for personal blogs, with paid subscriptions available for businesses and commercial sites.
25
 
26
  == Installation ==
27
 
31
 
32
  == Changelog ==
33
 
34
+ = 2.5.1 =
35
+
36
+ * Fix a bug that caused the "Auto delete" option to fail to discard comments correctly
37
+ * Remove the comment nonce form field from the 'Akismet Configuration' page in favor of using a filter, akismet_comment_nonce
38
+ * Fixed padding bug in "author" column of posts screen
39
+ * Added margin-top to "cleared by ..." badges on dashboard
40
+ * Fix possible error when calling akismet_cron_recheck()
41
+ * Fix more PHP warnings
42
+ * Clean up XHTML warnings for comment nonce
43
+ * Fix for possible condition where scheduled comment re-checks could get stuck
44
+ * Clean up the comment meta details after deleting a comment
45
+ * Only show the status badge if the comment status has been changed by someone/something other than Akismet
46
+ * Show a 'History' link in the row-actions
47
+ * Translation fixes
48
+ * Reduced font-size on author name
49
+ * Moved "flagged by..." notification to top right corner of comment container and removed heavy styling
50
+ * Hid "flagged by..." notification while on dashboard
51
+
52
  = 2.5.0 =
53
 
54
  * Track comment actions under 'Akismet Status' on the edit comment screen
widget.php CHANGED
@@ -8,11 +8,11 @@ function widget_akismet_register() {
8
  function widget_akismet($args) {
9
  extract($args);
10
  $options = get_option('widget_akismet');
11
- $count = number_format_i18n(get_option('akismet_spam_count'));
12
  ?>
13
  <?php echo $before_widget; ?>
14
  <?php echo $before_title . $options['title'] . $after_title; ?>
15
- <div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><?php printf( __( '%1$s %2$sspam comments%3$s %4$sblocked by%5$s<br />%6$sAkismet%7$s' ), '<span id="akismet1"><span id="akismetcount">' . $count . '</span>', '<span id="akismetsc">', '</span></span>', '<span id="akismet2"><span id="akismetbb">', '</span>', '<span id="akismeta">', '</span></span>' ); ?></a></div></div>
16
  <?php echo $after_widget; ?>
17
  <?php
18
  }
@@ -85,8 +85,6 @@ function akismet_counter() {
85
  #akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'), $plugin_dir; ?>/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}
86
  </style>
87
  <?php
88
- $count = number_format_i18n(get_option('akismet_spam_count'));
89
- ?>
90
- <div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><div id="akismet1"><span id="akismetcount"><?php echo $count; ?></span> <span id="akismetsc"><?php _e('spam comments') ?></span></div> <div id="akismet2"><span id="akismetbb"><?php _e('blocked by') ?></span><br /><span id="akismeta">Akismet</span></div></a></div></div>
91
- <?php
92
  }
8
  function widget_akismet($args) {
9
  extract($args);
10
  $options = get_option('widget_akismet');
11
+ $count = get_option('akismet_spam_count');
12
  ?>
13
  <?php echo $before_widget; ?>
14
  <?php echo $before_title . $options['title'] . $after_title; ?>
15
+ <div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><?php printf( _n( '%1$s%2$s%3$s %4$sspam comment%5$s %6$sblocked by%7$s<br />%8$sAkismet%9$s', '%1$s%2$s%3$s %4$sspam comments%5$s %6$sblocked by%7$s<br />%8$sAkismet%9$s', $count ), '<span id="akismet1"><span id="akismetcount">', number_format_i18n( $count ), '</span>', '<span id="akismetsc">', '</span></span>', '<span id="akismet2"><span id="akismetbb">', '</span>', '<span id="akismeta">', '</span></span>' ); ?></a></div></div>
16
  <?php echo $after_widget; ?>
17
  <?php
18
  }
85
  #akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'), $plugin_dir; ?>/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}
86
  </style>
87
  <?php
88
+ $count = get_option('akismet_spam_count');
89
+ printf( _n( '<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><div id="akismet1"><span id="akismetcount">%1$s</span> <span id="akismetsc">spam comment</span></div> <div id="akismet2"><span id="akismetbb">blocked by</span><br /><span id="akismeta">Akismet</span></div></a></div></div>', '<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><div id="akismet1"><span id="akismetcount">%1$s</span> <span id="akismetsc">spam comments</span></div> <div id="akismet2"><span id="akismetbb">blocked by</span><br /><span id="akismeta">Akismet</span></div></a></div></div>', $count ), number_format_i18n( $count ) );
 
 
90
  }