Akismet Anti-Spam - Version 4.1.11

Version Description

Release Date - 23 August 2021

  • Added support for Akismet API usage notifications on Akismet settings and edit-comments admin pages.
  • Added support for the deleted_comment action when bulk-deleting comments from Spam.
Download this release

Release Info

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

Code changes from version 4.1.10 to 4.1.11

.htaccess CHANGED
@@ -23,7 +23,7 @@
23
  </FilesMatch>
24
 
25
  # Akismet images
26
- <FilesMatch "^logo-full-2x\.png$">
27
  <IfModule !mod_authz_core.c>
28
  Allow from all
29
  </IfModule>
23
  </FilesMatch>
24
 
25
  # Akismet images
26
+ <FilesMatch "^logo-(a|full)-2x\.png$">
27
  <IfModule !mod_authz_core.c>
28
  Allow from all
29
  </IfModule>
_inc/akismet.css CHANGED
@@ -659,4 +659,63 @@ table.comments td.comment p a:after {
659
 
660
  .akismet-setup-instructions form {
661
  padding-bottom: 1.5rem;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662
  }
659
 
660
  .akismet-setup-instructions form {
661
  padding-bottom: 1.5rem;
662
+ }
663
+
664
+ div.error.akismet-usage-limit-alert {
665
+ padding: 25px 45px 25px 15px;
666
+ display: flex;
667
+ align-items: center;
668
+ }
669
+
670
+ #akismet-plugin-container .akismet-usage-limit-alert {
671
+ margin: 0 auto 0.625rem auto;
672
+ box-sizing: border-box;
673
+ box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
674
+ border: none;
675
+ border-left: 4px solid #d63638;
676
+ }
677
+
678
+ .akismet-usage-limit-alert .akismet-usage-limit-logo {
679
+ width: 38px;
680
+ min-width: 38px;
681
+ height: 38px;
682
+ border-radius: 20px;
683
+ margin-right: 18px;
684
+ background: black;
685
+ position: relative;
686
+ }
687
+
688
+ .akismet-usage-limit-alert .akismet-usage-limit-logo img {
689
+ position: absolute;
690
+ width: 22px;
691
+ left: 8px;
692
+ top: 10px;
693
+ }
694
+
695
+ .akismet-usage-limit-alert .akismet-usage-limit-text {
696
+ flex-grow: 1;
697
+ margin-right: 18px;
698
+ }
699
+
700
+ .akismet-usage-limit-alert h3 {
701
+ margin: 0;
702
+ }
703
+
704
+ .akismet-usage-limit-alert .akismet-usage-limit-cta {
705
+ text-align: right;
706
+ }
707
+
708
+ @media (max-width: 550px) {
709
+ div.error.akismet-usage-limit-alert {
710
+ display: block;
711
+ }
712
+
713
+ .akismet-usage-limit-alert .akismet-usage-limit-logo,
714
+ .akismet-usage-limit-alert .akismet-usage-limit-text {
715
+ margin-bottom: 15px;
716
+ }
717
+
718
+ .akismet-usage-limit-alert .akismet-usage-limit-cta {
719
+ text-align: left;
720
+ }
721
  }
_inc/img/logo-a-2x.png ADDED
Binary file
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.10
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.10' );
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.11
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.11' );
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
@@ -888,6 +888,22 @@ class Akismet_Admin {
888
  ) );
889
  }
890
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
891
  public static function display_spam_check_warning() {
892
  Akismet::fix_scheduled_recheck();
893
 
@@ -1021,6 +1037,11 @@ class Akismet_Admin {
1021
  $notices[] = array( 'type' => $akismet_user->status );
1022
  }
1023
 
 
 
 
 
 
1024
  /*
1025
  // To see all variants when testing.
1026
  $notices[] = array( 'type' => 'active-notice', 'time_saved' => 'Cleaning up spam takes time. Akismet has saved you 1 minute!' );
@@ -1040,6 +1061,7 @@ class Akismet_Admin {
1040
  $notices[] = array( 'type' => 'new-key-failed' );
1041
  $notices[] = array( 'type' => 'limit-reached', 'level' => 'yellow' );
1042
  $notices[] = array( 'type' => 'limit-reached', 'level' => 'red' );
 
1043
  */
1044
 
1045
  Akismet::log( compact( 'stat_totals', 'akismet_user' ) );
@@ -1056,9 +1078,14 @@ class Akismet_Admin {
1056
 
1057
  if ( in_array( $hook_suffix, array( 'edit-comments.php' ) ) && (int) get_option( 'akismet_alert_code' ) > 0 ) {
1058
  Akismet::verify_key( Akismet::get_api_key() ); //verify that the key is still in alert state
1059
-
1060
- if ( get_option( 'akismet_alert_code' ) > 0 )
 
 
 
 
1061
  self::display_alert();
 
1062
  }
1063
  elseif ( ( 'plugins.php' === $hook_suffix || 'edit-comments.php' === $hook_suffix ) && ! Akismet::get_api_key() ) {
1064
  // Show the "Set Up Akismet" banner on the comments and plugin pages if no API key has been set.
888
  ) );
889
  }
890
 
891
+ public static function get_usage_limit_alert_data() {
892
+ return array(
893
+ 'type' => 'usage-limit',
894
+ 'code' => (int) get_option( 'akismet_alert_code' ),
895
+ 'msg' => get_option( 'akismet_alert_msg' ),
896
+ 'api_calls' => get_option( 'akismet_alert_api_calls' ),
897
+ 'usage_limit' => get_option( 'akismet_alert_usage_limit' ),
898
+ 'upgrade_plan' => get_option( 'akismet_alert_upgrade_plan' ),
899
+ 'upgrade_url' => get_option( 'akismet_alert_upgrade_url' ),
900
+ );
901
+ }
902
+
903
+ public static function display_usage_limit_alert() {
904
+ Akismet::view( 'notice', self::get_usage_limit_alert_data() );
905
+ }
906
+
907
  public static function display_spam_check_warning() {
908
  Akismet::fix_scheduled_recheck();
909
 
1037
  $notices[] = array( 'type' => $akismet_user->status );
1038
  }
1039
 
1040
+ $alert_code = get_option( 'akismet_alert_code' );
1041
+ if ( isset( Akismet::$LIMIT_NOTICES[ $alert_code ] ) ) {
1042
+ $notices[] = self::get_usage_limit_alert_data();
1043
+ }
1044
+
1045
  /*
1046
  // To see all variants when testing.
1047
  $notices[] = array( 'type' => 'active-notice', 'time_saved' => 'Cleaning up spam takes time. Akismet has saved you 1 minute!' );
1061
  $notices[] = array( 'type' => 'new-key-failed' );
1062
  $notices[] = array( 'type' => 'limit-reached', 'level' => 'yellow' );
1063
  $notices[] = array( 'type' => 'limit-reached', 'level' => 'red' );
1064
+ $notices[] = array( 'type' => 'usage-limit', 'api_calls' => '15000', 'usage_limit' => '10000', 'upgrade_plan' => 'Enterprise', 'upgrade_url' => 'https://akismet.com/account/' );
1065
  */
1066
 
1067
  Akismet::log( compact( 'stat_totals', 'akismet_user' ) );
1078
 
1079
  if ( in_array( $hook_suffix, array( 'edit-comments.php' ) ) && (int) get_option( 'akismet_alert_code' ) > 0 ) {
1080
  Akismet::verify_key( Akismet::get_api_key() ); //verify that the key is still in alert state
1081
+
1082
+ $alert_code = get_option( 'akismet_alert_code' );
1083
+ if ( isset( Akismet::$LIMIT_NOTICES[ $alert_code ] ) ) {
1084
+ self::display_usage_limit_alert();
1085
+ }
1086
+ elseif ( $alert_code > 0 ) {
1087
  self::display_alert();
1088
+ }
1089
  }
1090
  elseif ( ( 'plugins.php' === $hook_suffix || 'edit-comments.php' === $hook_suffix ) && ! Akismet::get_api_key() ) {
1091
  // Show the "Set Up Akismet" banner on the comments and plugin pages if no API key has been set.
class.akismet.php CHANGED
@@ -5,6 +5,14 @@ class Akismet {
5
  const API_PORT = 80;
6
  const MAX_DELAY_BEFORE_MODERATION_EMAIL = 86400; // One day in seconds
7
 
 
 
 
 
 
 
 
 
8
  private static $last_comment = '';
9
  private static $initiated = false;
10
  private static $prevent_moderation_email_for_these_comments = array();
@@ -408,6 +416,10 @@ class Akismet {
408
 
409
  clean_comment_cache( $comment_ids );
410
  do_action( 'akismet_delete_comment_batch', count( $comment_ids ) );
 
 
 
 
411
  }
412
 
413
  if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->comments ) ) // lucky number
@@ -1254,21 +1266,31 @@ class Akismet {
1254
 
1255
  // given a response from an API call like check_key_status(), update the alert code options if an alert is present.
1256
  public static function update_alert( $response ) {
1257
- $code = $msg = null;
1258
- if ( isset( $response[0]['x-akismet-alert-code'] ) ) {
1259
- $code = $response[0]['x-akismet-alert-code'];
1260
- $msg = $response[0]['x-akismet-alert-msg'];
1261
- }
 
 
 
 
 
1262
 
1263
- // only call update_option() if the value has changed
1264
- if ( $code != get_option( 'akismet_alert_code' ) ) {
1265
- if ( ! $code ) {
1266
- delete_option( 'akismet_alert_code' );
1267
- delete_option( 'akismet_alert_msg' );
1268
  }
1269
- else {
1270
- update_option( 'akismet_alert_code', $code );
1271
- update_option( 'akismet_alert_msg', $msg );
 
 
 
 
 
 
1272
  }
1273
  }
1274
  }
5
  const API_PORT = 80;
6
  const MAX_DELAY_BEFORE_MODERATION_EMAIL = 86400; // One day in seconds
7
 
8
+ public static $LIMIT_NOTICES = array(
9
+ 10501 => 'FIRST_MONTH_OVER_LIMIT',
10
+ 10502 => 'SECOND_MONTH_OVER_LIMIT',
11
+ 10504 => 'THIRD_MONTH_APPROACHING_LIMIT',
12
+ 10508 => 'THIRD_MONTH_OVER_LIMIT',
13
+ 10516 => 'FOUR_PLUS_MONTHS_OVER_LIMIT',
14
+ );
15
+
16
  private static $last_comment = '';
17
  private static $initiated = false;
18
  private static $prevent_moderation_email_for_these_comments = array();
416
 
417
  clean_comment_cache( $comment_ids );
418
  do_action( 'akismet_delete_comment_batch', count( $comment_ids ) );
419
+
420
+ foreach ( $comment_ids as $comment_id ) {
421
+ do_action( 'deleted_comment', comment_id );
422
+ }
423
  }
424
 
425
  if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->comments ) ) // lucky number
1266
 
1267
  // given a response from an API call like check_key_status(), update the alert code options if an alert is present.
1268
  public static function update_alert( $response ) {
1269
+ $alert_option_prefix = 'akismet_alert_';
1270
+ $alert_header_prefix = 'x-akismet-alert-';
1271
+ $alert_header_names = array(
1272
+ 'code',
1273
+ 'msg',
1274
+ 'api-calls',
1275
+ 'usage-limit',
1276
+ 'upgrade-plan',
1277
+ 'upgrade-url',
1278
+ );
1279
 
1280
+ foreach( $alert_header_names as $alert_header_name ) {
1281
+ $value = null;
1282
+ if ( isset( $response[0][$alert_header_prefix . $alert_header_name] ) ) {
1283
+ $value = $response[0][$alert_header_prefix . $alert_header_name];
 
1284
  }
1285
+
1286
+ $option_name = $alert_option_prefix . str_replace( '-', '_', $alert_header_name );
1287
+ if ( $value != get_option( $option_name ) ) {
1288
+ if ( ! $value ) {
1289
+ delete_option( $option_name );
1290
+ }
1291
+ else {
1292
+ update_option( $option_name, $value );
1293
+ }
1294
  }
1295
  }
1296
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eo
3
  Tags: comments, spam, antispam, anti-spam, contact form, anti spam, comment moderation, comment spam, contact form spam, spam comments
4
  Requires at least: 4.6
5
  Tested up to: 5.8
6
- Stable tag: 4.1.10
7
  License: GPLv2 or later
8
 
9
  The best anti-spam protection to block spam comments and spam in a contact form. The most trusted antispam solution for WordPress and WooCommerce.
@@ -30,6 +30,12 @@ Upload the Akismet plugin to your blog, activate it, and then enter your Akismet
30
 
31
  == Changelog ==
32
 
 
 
 
 
 
 
33
  = 4.1.10 =
34
  *Release Date - 6 July 2021*
35
 
3
  Tags: comments, spam, antispam, anti-spam, contact form, anti spam, comment moderation, comment spam, contact form spam, spam comments
4
  Requires at least: 4.6
5
  Tested up to: 5.8
6
+ Stable tag: 4.1.11
7
  License: GPLv2 or later
8
 
9
  The best anti-spam protection to block spam comments and spam in a contact form. The most trusted antispam solution for WordPress and WooCommerce.
30
 
31
  == Changelog ==
32
 
33
+ = 4.1.11 =
34
+ *Release Date - 23 August 2021*
35
+
36
+ * Added support for Akismet API usage notifications on Akismet settings and edit-comments admin pages.
37
+ * Added support for the deleted_comment action when bulk-deleting comments from Spam.
38
+
39
  = 4.1.10 =
40
  *Release Date - 6 July 2021*
41
 
views/enter.php CHANGED
@@ -1,5 +1,5 @@
1
  <div class="akismet-enter-api-key-box centered">
2
- <a href="#"><?php esc_html_e( 'Manually enter an API key' ); ?></a>
3
  <div class="enter-api-key">
4
  <form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post">
5
  <?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
1
  <div class="akismet-enter-api-key-box centered">
2
+ <a href="#"><?php esc_html_e( 'Manually enter an API key', 'akismet' ); ?></a>
3
  <div class="enter-api-key">
4
  <form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post">
5
  <?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
views/notice.php CHANGED
@@ -139,4 +139,59 @@
139
  </p>
140
  <?php endif; ?>
141
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  <?php endif;?>
139
  </p>
140
  <?php endif; ?>
141
  </div>
142
+ <?php elseif ( $type == 'usage-limit' && isset( Akismet::$LIMIT_NOTICES[ $code ] ) ) :?>
143
+ <div class="error akismet-usage-limit-alert">
144
+ <div class="akismet-usage-limit-logo">
145
+ <img src="<?php echo esc_url( plugins_url( '../_inc/img/logo-a-2x.png', __FILE__ ) ); ?>" alt="Akismet" />
146
+ </div>
147
+ <div class="akismet-usage-limit-text">
148
+ <h3>
149
+ <?php
150
+ switch ( Akismet::$LIMIT_NOTICES[ $code ] ) {
151
+ case 'FIRST_MONTH_OVER_LIMIT':
152
+ case 'SECOND_MONTH_OVER_LIMIT':
153
+ esc_html_e( 'Your Akismet account usage is over your plan\'s limit', 'akismet' );
154
+ break;
155
+ case 'THIRD_MONTH_APPROACHING_LIMIT':
156
+ esc_html_e( 'Your Akismet account usage is approaching your plan\'s limit', 'akismet' );
157
+ break;
158
+ case 'THIRD_MONTH_OVER_LIMIT':
159
+ case 'FOUR_PLUS_MONTHS_OVER_LIMIT':
160
+ esc_html_e( 'Your account has been restricted', 'akismet' );
161
+ break;
162
+ default:
163
+ }
164
+ ?>
165
+ </h3>
166
+ <p>
167
+ <?php
168
+ switch ( Akismet::$LIMIT_NOTICES[ $code ] ) {
169
+ case 'FIRST_MONTH_OVER_LIMIT':
170
+ printf(
171
+ __( 'Since %s, your account made %s API calls, compared to your plan\'s limit of %s. <a href="%s" target="_blank">Learn more</a> about usage limits.', 'akismet' ),
172
+ esc_html( gmdate( 'F' ) . ' 1' ),
173
+ number_format( $api_calls ),
174
+ number_format( $usage_limit ),
175
+ 'https://docs.akismet.com/akismet-api-usage-limits/'
176
+ );
177
+ break;
178
+ case 'SECOND_MONTH_OVER_LIMIT':
179
+ esc_html_e( 'Your Akismet usage has been over your plan\'s limit for two consecutive months. Next month, we will restrict your account after you reach the limit. Please consider upgrading your plan.', 'akismet' );
180
+ break;
181
+ case 'THIRD_MONTH_APPROACHING_LIMIT':
182
+ esc_html_e( 'Your Akismet usage is nearing your plan\'s limit for the third consecutive month. We will restrict your account after you reach the limit. Upgrade your plan so Akismet can continue blocking spam.', 'akismet' );
183
+ break;
184
+ case 'THIRD_MONTH_OVER_LIMIT':
185
+ case 'FOUR_PLUS_MONTHS_OVER_LIMIT':
186
+ esc_html_e( 'Your Akismet usage has been over your plan\'s limit for three consecutive months. We have restricted your account for the rest of the month. Upgrade your plan so Akismet can continue blocking spam.', 'akismet' );
187
+ break;
188
+ default:
189
+ }
190
+ ?>
191
+ </p>
192
+ </div>
193
+ <div class="akismet-usage-limit-cta">
194
+ <?php printf( __( '<a href="%1$s" class="button" target="_blank">Upgrade to %2$s</a>', 'akismet' ), esc_attr( $upgrade_url ), esc_html( $upgrade_plan ) ); ?>
195
+ </div>
196
+ </div>
197
  <?php endif;?>