Akismet Anti-Spam - Version 4.1.4

Version Description

Release Date - 17 March 2020

  • Only redirect to the Akismet setup screen upon plugin activation if the plugin was activated manually from within the plugin-related screens, to help users with non-standard install workflows, like WP-CLI.
  • Update the layout of the initial setup screen to be more readable on small screens.
  • If no API key has been entered, don't run code that expects an API key.
  • Improve the readability of the comment history entries.
  • Don't modify the comment form HTML if no API key has been set.
Download this release

Release Info

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

Code changes from version 4.1.3 to 4.1.4

_inc/akismet.css CHANGED
@@ -661,3 +661,11 @@ table.comments td.comment p a:after {
661
  .akismet-section-header__actions {
662
  line-height: 1.75rem;
663
  }
 
 
 
 
 
 
 
 
661
  .akismet-section-header__actions {
662
  line-height: 1.75rem;
663
  }
664
+
665
+ .akismet-setup-instructions {
666
+ text-align: center;
667
+ }
668
+
669
+ .akismet-setup-instructions form {
670
+ padding-bottom: 1.5rem;
671
+ }
_inc/akismet.js CHANGED
@@ -147,6 +147,11 @@ jQuery( function ( $ ) {
147
  } );
148
 
149
  $( '.checkforspam' ).click( function( e ) {
 
 
 
 
 
150
  e.preventDefault();
151
 
152
  if ( $( this ).hasClass( 'button-disabled' ) ) {
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
+ }
154
+
155
  e.preventDefault();
156
 
157
  if ( $( this ).hasClass( 'button-disabled' ) ) {
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.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', '4.1.3' );
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.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', '4.1.4' );
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
@@ -398,8 +398,23 @@ class Akismet_Admin {
398
 
399
  echo '</div>';
400
  echo '<div class="alignleft actions">';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
401
  echo '<a
402
- class="button-secondary checkforspam' . ( $comments_count->moderated == 0 ? ' button-disabled' : '' ) . '"
403
  href="' . esc_url( $link ) . '"
404
  data-active-label="' . esc_attr( __( 'Checking for Spam', 'akismet' ) ) . '"
405
  data-progress-label-format="' . esc_attr( __( '(%1$s%)', 'akismet' ) ) . '"
@@ -575,10 +590,8 @@ class Akismet_Admin {
575
  $history = Akismet::get_comment_history( $comment->comment_ID );
576
 
577
  if ( $history ) {
578
- echo '<div class="akismet-history" style="margin: 13px;">';
579
-
580
  foreach ( $history as $row ) {
581
- $time = date( 'D d M Y @ h:i:m a', $row['time'] ) . ' GMT';
582
 
583
  $message = '';
584
 
@@ -588,56 +601,62 @@ class Akismet_Admin {
588
  // 1) Save space.
589
  // 2) The message can be translated into the current language of the blog, not stuck
590
  // in the language of the blog when the comment was made.
591
- $message = $row['message'];
592
  }
593
 
594
  // If possible, use a current translation.
595
  switch ( $row['event'] ) {
596
  case 'recheck-spam';
597
- $message = __( 'Akismet re-checked and caught this comment as spam.', 'akismet' );
598
  break;
599
  case 'check-spam':
600
- $message = __( 'Akismet caught this comment as spam.', 'akismet' );
601
  break;
602
  case 'recheck-ham':
603
- $message = __( 'Akismet re-checked and cleared this comment.', 'akismet' );
604
  break;
605
  case 'check-ham':
606
- $message = __( 'Akismet cleared this comment.', 'akismet' );
607
  break;
608
  case 'wp-blacklisted':
609
- $message = __( 'Comment was caught by wp_blacklist_check.', 'akismet' );
610
  break;
611
  case 'report-spam':
612
  if ( isset( $row['user'] ) ) {
613
- $message = sprintf( __( '%s reported this comment as spam.', 'akismet' ), $row['user'] );
614
  }
615
  else if ( ! $message ) {
616
- $message = __( 'This comment was reported as spam.', 'akismet' );
617
  }
618
  break;
619
  case 'report-ham':
620
  if ( isset( $row['user'] ) ) {
621
- $message = sprintf( __( '%s reported this comment as not spam.', 'akismet' ), $row['user'] );
622
  }
623
  else if ( ! $message ) {
624
- $message = __( 'This comment was reported as not spam.', 'akismet' );
625
  }
626
  break;
627
  case 'cron-retry-spam':
628
- $message = __( 'Akismet caught this comment as spam during an automatic retry.' , 'akismet');
629
  break;
630
  case 'cron-retry-ham':
631
- $message = __( 'Akismet cleared this comment during an automatic retry.', 'akismet');
632
  break;
633
  case 'check-error':
634
  if ( isset( $row['meta'], $row['meta']['response'] ) ) {
635
- $message = sprintf( __( 'Akismet was unable to check this comment (response: %s) but will automatically retry later.', 'akismet'), $row['meta']['response'] );
 
 
 
636
  }
637
  break;
638
  case 'recheck-error':
639
  if ( isset( $row['meta'], $row['meta']['response'] ) ) {
640
- $message = sprintf( __( 'Akismet was unable to recheck this comment (response: %s).', 'akismet'), $row['meta']['response'] );
 
 
 
641
  }
642
  break;
643
  default:
@@ -645,27 +664,32 @@ class Akismet_Admin {
645
  // Half of these used to be saved without the dash after 'status-changed'.
646
  // See https://plugins.trac.wordpress.org/changeset/1150658/akismet/trunk
647
  $new_status = preg_replace( '/^status-changed-?/', '', $row['event'] );
648
- $message = sprintf( __( 'Comment status was changed to %s', 'akismet' ), $new_status );
649
  }
650
  else if ( preg_match( '/^status-/', $row['event'] ) ) {
651
  $new_status = preg_replace( '/^status-/', '', $row['event'] );
652
 
653
  if ( isset( $row['user'] ) ) {
654
- $message = sprintf( __( '%1$s changed the comment status to %2$s.', 'akismet' ), $row['user'], $new_status );
655
  }
656
  }
657
  break;
658
 
659
  }
660
 
661
- echo '<div style="margin-bottom: 13px;">';
 
662
  echo '<span style="color: #999;" alt="' . $time . '" title="' . $time . '">' . sprintf( esc_html__('%s ago', 'akismet'), human_time_diff( $row['time'] ) ) . '</span>';
663
  echo ' - ';
664
- echo esc_html( $message );
665
- echo '</div>';
 
666
  }
667
-
668
- echo '</div>';
 
 
 
669
  }
670
  }
671
 
@@ -1056,12 +1080,13 @@ class Akismet_Admin {
1056
  elseif ( $hook_suffix == 'edit-comments.php' && wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
1057
  self::display_spam_check_warning();
1058
  }
1059
- else if ( isset( $_GET['akismet_recheck_complete'] ) ) {
 
1060
  $recheck_count = (int) $_GET['recheck_count'];
1061
  $spam_count = (int) $_GET['spam_count'];
1062
 
1063
  if ( $recheck_count === 0 ) {
1064
- $message = __( 'There were no comments to check. Akismet will only check comments in the Pending queue.', 'akismet' );
1065
  }
1066
  else {
1067
  $message = sprintf( _n( 'Akismet checked %s comment.', 'Akismet checked %s comments.', $recheck_count, 'akismet' ), number_format( $recheck_count ) );
398
 
399
  echo '</div>';
400
  echo '<div class="alignleft actions">';
401
+
402
+ $classes = array(
403
+ 'button-secondary',
404
+ 'checkforspam',
405
+ );
406
+
407
+ if ( ! Akismet::get_api_key() ) {
408
+ $link = admin_url( 'options-general.php?page=akismet-key-config' );
409
+
410
+ $classes[] = 'checkforspam-pending-config';
411
+ }
412
+
413
+ if ( $comments_count->moderated == 0 ) {
414
+ $classes[] = 'button-disabled';
415
+ }
416
  echo '<a
417
+ class="' . esc_attr( implode( ' ', $classes ) ) . '"
418
  href="' . esc_url( $link ) . '"
419
  data-active-label="' . esc_attr( __( 'Checking for Spam', 'akismet' ) ) . '"
420
  data-progress-label-format="' . esc_attr( __( '(%1$s%)', 'akismet' ) ) . '"
590
  $history = Akismet::get_comment_history( $comment->comment_ID );
591
 
592
  if ( $history ) {
 
 
593
  foreach ( $history as $row ) {
594
+ $time = date( 'D d M Y @ h:i:s a', $row['time'] ) . ' GMT';
595
 
596
  $message = '';
597
 
601
  // 1) Save space.
602
  // 2) The message can be translated into the current language of the blog, not stuck
603
  // in the language of the blog when the comment was made.
604
+ $message = esc_html( $row['message'] );
605
  }
606
 
607
  // If possible, use a current translation.
608
  switch ( $row['event'] ) {
609
  case 'recheck-spam';
610
+ $message = esc_html( __( 'Akismet re-checked and caught this comment as spam.', 'akismet' ) );
611
  break;
612
  case 'check-spam':
613
+ $message = esc_html( __( 'Akismet caught this comment as spam.', 'akismet' ) );
614
  break;
615
  case 'recheck-ham':
616
+ $message = esc_html( __( 'Akismet re-checked and cleared this comment.', 'akismet' ) );
617
  break;
618
  case 'check-ham':
619
+ $message = esc_html( __( 'Akismet cleared this comment.', 'akismet' ) );
620
  break;
621
  case 'wp-blacklisted':
622
+ $message = sprintf( esc_html( __( 'Comment was caught by %s.', 'akismet' ) ), '<code>wp_blacklist_check</code>' );
623
  break;
624
  case 'report-spam':
625
  if ( isset( $row['user'] ) ) {
626
+ $message = esc_html( sprintf( __( '%s reported this comment as spam.', 'akismet' ), $row['user'] ) );
627
  }
628
  else if ( ! $message ) {
629
+ $message = esc_html( __( 'This comment was reported as spam.', 'akismet' ) );
630
  }
631
  break;
632
  case 'report-ham':
633
  if ( isset( $row['user'] ) ) {
634
+ $message = esc_html( sprintf( __( '%s reported this comment as not spam.', 'akismet' ), $row['user'] ) );
635
  }
636
  else if ( ! $message ) {
637
+ $message = esc_html( __( 'This comment was reported as not spam.', 'akismet' ) );
638
  }
639
  break;
640
  case 'cron-retry-spam':
641
+ $message = esc_html( __( 'Akismet caught this comment as spam during an automatic retry.' , 'akismet') );
642
  break;
643
  case 'cron-retry-ham':
644
+ $message = esc_html( __( 'Akismet cleared this comment during an automatic retry.', 'akismet') );
645
  break;
646
  case 'check-error':
647
  if ( isset( $row['meta'], $row['meta']['response'] ) ) {
648
+ $message = sprintf( esc_html( __( 'Akismet was unable to check this comment (response: %s) but will automatically retry later.', 'akismet') ), '<code>' . esc_html( $row['meta']['response'] ) . '</code>' );
649
+ }
650
+ else {
651
+ $message = esc_html( __( 'Akismet was unable to check this comment but will automatically retry later.', 'akismet' ) );
652
  }
653
  break;
654
  case 'recheck-error':
655
  if ( isset( $row['meta'], $row['meta']['response'] ) ) {
656
+ $message = sprintf( esc_html( __( 'Akismet was unable to recheck this comment (response: %s).', 'akismet') ), '<code>' . esc_html( $row['meta']['response'] ) . '</code>' );
657
+ }
658
+ else {
659
+ $message = esc_html( __( 'Akismet was unable to recheck this comment.', 'akismet' ) );
660
  }
661
  break;
662
  default:
664
  // Half of these used to be saved without the dash after 'status-changed'.
665
  // See https://plugins.trac.wordpress.org/changeset/1150658/akismet/trunk
666
  $new_status = preg_replace( '/^status-changed-?/', '', $row['event'] );
667
+ $message = sprintf( esc_html( __( 'Comment status was changed to %s', 'akismet' ) ), '<code>' . esc_html( $new_status ) . '</code>' );
668
  }
669
  else if ( preg_match( '/^status-/', $row['event'] ) ) {
670
  $new_status = preg_replace( '/^status-/', '', $row['event'] );
671
 
672
  if ( isset( $row['user'] ) ) {
673
+ $message = sprintf( esc_html( __( '%1$s changed the comment status to %2$s.', 'akismet' ) ), $row['user'], '<code>' . esc_html( $new_status ) . '</code>' );
674
  }
675
  }
676
  break;
677
 
678
  }
679
 
680
+ if ( ! empty( $message ) ) {
681
+ echo '<p>';
682
  echo '<span style="color: #999;" alt="' . $time . '" title="' . $time . '">' . sprintf( esc_html__('%s ago', 'akismet'), human_time_diff( $row['time'] ) ) . '</span>';
683
  echo ' - ';
684
+ echo $message; // esc_html() is done above so that we can use HTML in some messages.
685
+ echo '</p>';
686
+ }
687
  }
688
+ }
689
+ else {
690
+ echo '<p>';
691
+ echo esc_html( __( 'No comment history.', 'akismet' ) );
692
+ echo '</p>';
693
  }
694
  }
695
 
1080
  elseif ( $hook_suffix == 'edit-comments.php' && wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
1081
  self::display_spam_check_warning();
1082
  }
1083
+
1084
+ if ( isset( $_GET['akismet_recheck_complete'] ) ) {
1085
  $recheck_count = (int) $_GET['recheck_count'];
1086
  $spam_count = (int) $_GET['spam_count'];
1087
 
1088
  if ( $recheck_count === 0 ) {
1089
+ $message = __( 'There were no comments to check. Akismet will only check comments awaiting moderation.', 'akismet' );
1090
  }
1091
  else {
1092
  $message = sprintf( _n( 'Akismet checked %s comment.', 'Akismet checked %s comments.', $recheck_count, 'akismet' ), number_format( $recheck_count ) );
class.akismet.php CHANGED
@@ -137,6 +137,11 @@ class Akismet {
137
  }
138
 
139
  public static function auto_check_comment( $commentdata ) {
 
 
 
 
 
140
  self::$last_comment_result = null;
141
 
142
  $comment = $commentdata;
@@ -469,6 +474,43 @@ class Akismet {
469
  // get the full comment history for a given comment, as an array in reverse chronological order
470
  public static function get_comment_history( $comment_id ) {
471
  $history = get_comment_meta( $comment_id, 'akismet_history', false );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
472
  usort( $history, array( 'Akismet', '_cmp_time' ) );
473
  return $history;
474
  }
@@ -506,6 +548,10 @@ class Akismet {
506
  public static function check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
507
  global $wpdb;
508
 
 
 
 
 
509
  $c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $id ), ARRAY_A );
510
 
511
  if ( ! $c ) {
@@ -653,6 +699,13 @@ class Akismet {
653
  if ( 'spam' != $comment->comment_approved )
654
  return;
655
 
 
 
 
 
 
 
 
656
  // use the original version stored in comment_meta if available
657
  $as_submitted = self::sanitize_comment_as_submitted( get_comment_meta( $comment_id, 'akismet_as_submitted', true ) );
658
 
@@ -685,9 +738,10 @@ class Akismet {
685
  }
686
 
687
  $response = Akismet::http_post( Akismet::build_query( $comment ), 'submit-spam' );
 
 
 
688
  if ( $comment->reporter ) {
689
- self::update_comment_history( $comment_id, '', 'report-spam' );
690
- update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
691
  update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
692
  }
693
 
@@ -703,6 +757,13 @@ class Akismet {
703
  if ( !$comment ) // it was deleted
704
  return;
705
 
 
 
 
 
 
 
 
706
  // use the original version stored in comment_meta if available
707
  $as_submitted = self::sanitize_comment_as_submitted( get_comment_meta( $comment_id, 'akismet_as_submitted', true ) );
708
 
@@ -735,9 +796,10 @@ class Akismet {
735
  }
736
 
737
  $response = self::http_post( Akismet::build_query( $comment ), 'submit-ham' );
 
 
 
738
  if ( $comment->reporter ) {
739
- self::update_comment_history( $comment_id, '', 'report-ham' );
740
- update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
741
  update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
742
  }
743
 
@@ -860,6 +922,11 @@ class Akismet {
860
  * has not been set and that Akismet should just choose the default behavior for that
861
  * situation.
862
  */
 
 
 
 
 
863
  $akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
864
 
865
  if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' ) {
@@ -1187,6 +1254,10 @@ class Akismet {
1187
  return;
1188
  }
1189
 
 
 
 
 
1190
  wp_register_script( 'akismet-form', plugin_dir_url( __FILE__ ) . '_inc/form.js', array(), AKISMET_VERSION, true );
1191
  wp_enqueue_script( 'akismet-form' );
1192
  }
@@ -1277,7 +1348,7 @@ p {
1277
  $message = '<strong>'.sprintf(esc_html__( 'Akismet %s requires WordPress %s or higher.' , 'akismet'), AKISMET_VERSION, AKISMET__MINIMUM_WP_VERSION ).'</strong> '.sprintf(__('Please <a href="%1$s">upgrade WordPress</a> to a current version, or <a href="%2$s">downgrade to version 2.4 of the Akismet plugin</a>.', 'akismet'), 'https://codex.wordpress.org/Upgrading_WordPress', 'https://wordpress.org/extend/plugins/akismet/download/');
1278
 
1279
  Akismet::bail_on_activation( $message );
1280
- } else {
1281
  add_option( 'Activated_Akismet', true );
1282
  }
1283
  }
137
  }
138
 
139
  public static function auto_check_comment( $commentdata ) {
140
+ // If no key is configured, then there's no point in doing any of this.
141
+ if ( ! self::get_api_key() ) {
142
+ return $commentdata;
143
+ }
144
+
145
  self::$last_comment_result = null;
146
 
147
  $comment = $commentdata;
474
  // get the full comment history for a given comment, as an array in reverse chronological order
475
  public static function get_comment_history( $comment_id ) {
476
  $history = get_comment_meta( $comment_id, 'akismet_history', false );
477
+ if ( empty( $history ) || empty( $history[ 0 ] ) ) {
478
+ return false;
479
+ }
480
+
481
+ /*
482
+ // To see all variants when testing.
483
+ $history[] = array( 'time' => 445856401, 'message' => 'Old versions of Akismet stored the message as a literal string in the commentmeta.', 'event' => null );
484
+ $history[] = array( 'time' => 445856402, 'event' => 'recheck-spam' );
485
+ $history[] = array( 'time' => 445856403, 'event' => 'check-spam' );
486
+ $history[] = array( 'time' => 445856404, 'event' => 'recheck-ham' );
487
+ $history[] = array( 'time' => 445856405, 'event' => 'check-ham' );
488
+ $history[] = array( 'time' => 445856406, 'event' => 'wp-blacklisted' );
489
+ $history[] = array( 'time' => 445856407, 'event' => 'report-spam' );
490
+ $history[] = array( 'time' => 445856408, 'event' => 'report-spam', 'user' => 'sam' );
491
+ $history[] = array( 'message' => 'sam reported this comment as spam (hardcoded message).', 'time' => 445856400, 'event' => 'report-spam', 'user' => 'sam' );
492
+ $history[] = array( 'time' => 445856409, 'event' => 'report-ham', 'user' => 'sam' );
493
+ $history[] = array( 'message' => 'sam reported this comment as ham (hardcoded message).', 'time' => 445856400, 'event' => 'report-ham', 'user' => 'sam' ); //
494
+ $history[] = array( 'time' => 445856410, 'event' => 'cron-retry-spam' );
495
+ $history[] = array( 'time' => 445856411, 'event' => 'cron-retry-ham' );
496
+ $history[] = array( 'time' => 445856412, 'event' => 'check-error' ); //
497
+ $history[] = array( 'time' => 445856413, 'event' => 'check-error', 'meta' => array( 'response' => 'The server was taking a nap.' ) );
498
+ $history[] = array( 'time' => 445856414, 'event' => 'recheck-error' ); // Should not generate a message.
499
+ $history[] = array( 'time' => 445856415, 'event' => 'recheck-error', 'meta' => array( 'response' => 'The server was taking a nap.' ) );
500
+ $history[] = array( 'time' => 445856416, 'event' => 'status-changedtrash' );
501
+ $history[] = array( 'time' => 445856417, 'event' => 'status-changedspam' );
502
+ $history[] = array( 'time' => 445856418, 'event' => 'status-changedhold' );
503
+ $history[] = array( 'time' => 445856419, 'event' => 'status-changedapprove' );
504
+ $history[] = array( 'time' => 445856420, 'event' => 'status-changed-trash' );
505
+ $history[] = array( 'time' => 445856421, 'event' => 'status-changed-spam' );
506
+ $history[] = array( 'time' => 445856422, 'event' => 'status-changed-hold' );
507
+ $history[] = array( 'time' => 445856423, 'event' => 'status-changed-approve' );
508
+ $history[] = array( 'time' => 445856424, 'event' => 'status-trash', 'user' => 'sam' );
509
+ $history[] = array( 'time' => 445856425, 'event' => 'status-spam', 'user' => 'sam' );
510
+ $history[] = array( 'time' => 445856426, 'event' => 'status-hold', 'user' => 'sam' );
511
+ $history[] = array( 'time' => 445856427, 'event' => 'status-approve', 'user' => 'sam' );
512
+ */
513
+
514
  usort( $history, array( 'Akismet', '_cmp_time' ) );
515
  return $history;
516
  }
548
  public static function check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
549
  global $wpdb;
550
 
551
+ if ( ! self::get_api_key() ) {
552
+ return new WP_Error( 'akismet-not-configured', __( 'Akismet is not configured. Please enter an API key.', 'akismet' ) );
553
+ }
554
+
555
  $c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $id ), ARRAY_A );
556
 
557
  if ( ! $c ) {
699
  if ( 'spam' != $comment->comment_approved )
700
  return;
701
 
702
+ self::update_comment_history( $comment_id, '', 'report-spam' );
703
+
704
+ // If the user hasn't configured Akismet, there's nothing else to do at this point.
705
+ if ( ! self::get_api_key() ) {
706
+ return;
707
+ }
708
+
709
  // use the original version stored in comment_meta if available
710
  $as_submitted = self::sanitize_comment_as_submitted( get_comment_meta( $comment_id, 'akismet_as_submitted', true ) );
711
 
738
  }
739
 
740
  $response = Akismet::http_post( Akismet::build_query( $comment ), 'submit-spam' );
741
+
742
+ update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
743
+
744
  if ( $comment->reporter ) {
 
 
745
  update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
746
  }
747
 
757
  if ( !$comment ) // it was deleted
758
  return;
759
 
760
+ self::update_comment_history( $comment_id, '', 'report-ham' );
761
+
762
+ // If the user hasn't configured Akismet, there's nothing else to do at this point.
763
+ if ( ! self::get_api_key() ) {
764
+ return;
765
+ }
766
+
767
  // use the original version stored in comment_meta if available
768
  $as_submitted = self::sanitize_comment_as_submitted( get_comment_meta( $comment_id, 'akismet_as_submitted', true ) );
769
 
796
  }
797
 
798
  $response = self::http_post( Akismet::build_query( $comment ), 'submit-ham' );
799
+
800
+ update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
801
+
802
  if ( $comment->reporter ) {
 
 
803
  update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
804
  }
805
 
922
  * has not been set and that Akismet should just choose the default behavior for that
923
  * situation.
924
  */
925
+
926
+ if ( ! self::get_api_key() ) {
927
+ return;
928
+ }
929
+
930
  $akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
931
 
932
  if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' ) {
1254
  return;
1255
  }
1256
 
1257
+ if ( ! self::get_api_key() ) {
1258
+ return;
1259
+ }
1260
+
1261
  wp_register_script( 'akismet-form', plugin_dir_url( __FILE__ ) . '_inc/form.js', array(), AKISMET_VERSION, true );
1262
  wp_enqueue_script( 'akismet-form' );
1263
  }
1348
  $message = '<strong>'.sprintf(esc_html__( 'Akismet %s requires WordPress %s or higher.' , 'akismet'), AKISMET_VERSION, AKISMET__MINIMUM_WP_VERSION ).'</strong> '.sprintf(__('Please <a href="%1$s">upgrade WordPress</a> to a current version, or <a href="%2$s">downgrade to version 2.4 of the Akismet plugin</a>.', 'akismet'), 'https://codex.wordpress.org/Upgrading_WordPress', 'https://wordpress.org/extend/plugins/akismet/download/');
1349
 
1350
  Akismet::bail_on_activation( $message );
1351
+ } elseif ( ! empty( $_SERVER['SCRIPT_NAME'] ) && false !== strpos( $_SERVER['SCRIPT_NAME'], '/wp-admin/plugins.php' ) ) {
1352
  add_option( 'Activated_Akismet', true );
1353
  }
1354
  }
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer, stephdau
3
  Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
4
  Requires at least: 4.0
5
- Tested up to: 5.3
6
- Stable tag: 4.1.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,15 @@ Upload the Akismet plugin to your blog, activate it, and then enter your Akismet
30
 
31
  == Changelog ==
32
 
 
 
 
 
 
 
 
 
 
33
  = 4.1.3 =
34
  *Release Date - 31 October 2019*
35
 
2
  Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer, stephdau
3
  Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
4
  Requires at least: 4.0
5
+ Tested up to: 5.4
6
+ Stable tag: 4.1.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
+ = 4.1.4 =
34
+ *Release Date - 17 March 2020*
35
+
36
+ * Only redirect to the Akismet setup screen upon plugin activation if the plugin was activated manually from within the plugin-related screens, to help users with non-standard install workflows, like WP-CLI.
37
+ * Update the layout of the initial setup screen to be more readable on small screens.
38
+ * If no API key has been entered, don't run code that expects an API key.
39
+ * Improve the readability of the comment history entries.
40
+ * Don't modify the comment form HTML if no API key has been set.
41
+
42
  = 4.1.3 =
43
  *Release Date - 31 October 2019*
44
 
views/setup.php CHANGED
@@ -1,5 +1,4 @@
1
- <h3><?php esc_html_e( 'Set Up Akismet' , 'akismet' );?></h3>
2
- <div class="akismet-right">
3
  <?php Akismet::view( 'get', array( 'text' => __( 'Set up your Akismet account' , 'akismet' ), 'classes' => array( 'akismet-button', 'akismet-is-primary' ) ) ); ?>
4
  </div>
5
- <p><?php esc_html_e( 'Set up your Akismet account to enable spam filtering on this site.', 'akismet' ); ?></p>
1
+ <div class="akismet-setup-instructions">
2
+ <p><?php esc_html_e( 'Set up your Akismet account to enable spam filtering on this site.', 'akismet' ); ?></p>
3
  <?php Akismet::view( 'get', array( 'text' => __( 'Set up your Akismet account' , 'akismet' ), 'classes' => array( 'akismet-button', 'akismet-is-primary' ) ) ); ?>
4
  </div>