Akismet Anti-Spam - Version 4.0.4

Version Description

Release Date - 26 May 2018

  • Added a hook to provide Akismet-specific privacy information for a site's privacy policy.
  • Added tools to control the display of a privacy related notice under comment forms.
  • Fixed HTML in activation failure message to close META and HEAD tag properly.
  • Fixed a bug that would sometimes prevent Akismet from being correctly auto-configured.
Download this release

Release Info

Developer stephdau
Plugin Icon 128x128 Akismet Anti-Spam
Version 4.0.4
Comparing to
See all releases

Code changes from version 4.0.3 to 4.0.4

_inc/akismet.css CHANGED
@@ -417,6 +417,10 @@ table.comments td.comment p a:after {
417
  padding: 1.5rem;
418
  }
419
 
 
 
 
 
420
  .akismet-card {
421
  margin-top: 1rem;
422
  margin-bottom: 0;
@@ -583,4 +587,4 @@ table.comments td.comment p a:after {
583
 
584
  .akismet-section-header__actions {
585
  line-height: 1.75rem;
586
- }
417
  padding: 1.5rem;
418
  }
419
 
420
+ .akismet-lower .notice {
421
+ margin-bottom: 2rem;
422
+ }
423
+
424
  .akismet-card {
425
  margin-top: 1rem;
426
  margin-bottom: 0;
587
 
588
  .akismet-section-header__actions {
589
  line-height: 1.75rem;
590
+ }
_inc/akismet.js CHANGED
@@ -273,4 +273,13 @@ jQuery( function ( $ ) {
273
  var img = new Image();
274
  img.src = akismet_mshot_url( linkUrl );
275
  }
276
- });
 
 
 
 
 
 
 
 
 
273
  var img = new Image();
274
  img.src = akismet_mshot_url( linkUrl );
275
  }
276
+
277
+ /**
278
+ * Sets the comment form privacy notice display to hide when one clicks Core's dismiss button on the related admin notice.
279
+ */
280
+ $( '#akismet-privacy-notice-admin-notice' ).on( 'click', '.notice-dismiss', function(){
281
+ $.ajax({
282
+ url: './options-general.php?page=akismet-key-config&akismet_comment_form_privacy_notice=hide',
283
+ });
284
+ });
285
+ });
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.0.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.0.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.0.4a7
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.0.4a7' );
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
@@ -32,6 +32,10 @@ class Akismet_Admin {
32
  if ( isset( $_POST['action'] ) && $_POST['action'] == 'enter-key' ) {
33
  self::enter_api_key();
34
  }
 
 
 
 
35
  }
36
 
37
  public static function init_hooks() {
@@ -65,11 +69,23 @@ class Akismet_Admin {
65
  add_filter( 'wxr_export_skip_commentmeta', array( 'Akismet_Admin', 'exclude_commentmeta_from_export' ), 10, 3 );
66
 
67
  add_filter( 'all_plugins', array( 'Akismet_Admin', 'modify_plugin_description' ) );
 
 
 
 
 
68
  }
69
 
70
  public static function admin_init() {
71
  load_plugin_textdomain( 'akismet' );
72
  add_meta_box( 'akismet-status', __('Comment History', 'akismet'), array( 'Akismet_Admin', 'comment_status_meta_box' ), 'comment', 'normal' );
 
 
 
 
 
 
 
73
  }
74
 
75
  public static function admin_menu() {
@@ -260,7 +276,13 @@ class Akismet_Admin {
260
  foreach( array( 'akismet_strictness', 'akismet_show_user_comments_approved' ) as $option ) {
261
  update_option( $option, isset( $_POST[$option] ) && (int) $_POST[$option] == 1 ? '1' : '0' );
262
  }
263
-
 
 
 
 
 
 
264
  if ( Akismet::predefined_api_key() ) {
265
  return false; //shouldn't have option to save key if already defined
266
  }
@@ -825,6 +847,14 @@ class Akismet_Admin {
825
  ) );
826
  }
827
 
 
 
 
 
 
 
 
 
828
  public static function display_spam_check_warning() {
829
  Akismet::fix_scheduled_recheck();
830
 
@@ -958,6 +988,10 @@ class Akismet_Admin {
958
  $notices[] = array( 'type' => $akismet_user->status );
959
  }
960
 
 
 
 
 
961
  /*
962
  // To see all variants when testing.
963
  $notices[] = array( 'type' => 'active-notice', 'time_saved' => 'Cleaning up spam takes time. Akismet has saved you 1 minute!' );
@@ -1023,6 +1057,8 @@ class Akismet_Admin {
1023
  }
1024
 
1025
  echo '<div class="notice notice-success"><p>' . esc_html( $message ) . '</p></div>';
 
 
1026
  }
1027
  }
1028
 
@@ -1128,4 +1164,14 @@ class Akismet_Admin {
1128
 
1129
  return $all_plugins;
1130
  }
 
 
 
 
 
 
 
 
 
 
1131
  }
32
  if ( isset( $_POST['action'] ) && $_POST['action'] == 'enter-key' ) {
33
  self::enter_api_key();
34
  }
35
+
36
+ if ( ! empty( $_GET['akismet_comment_form_privacy_notice'] ) && empty( $_GET['settings-updated']) ) {
37
+ self::set_form_privacy_notice_option( $_GET['akismet_comment_form_privacy_notice'] );
38
+ }
39
  }
40
 
41
  public static function init_hooks() {
69
  add_filter( 'wxr_export_skip_commentmeta', array( 'Akismet_Admin', 'exclude_commentmeta_from_export' ), 10, 3 );
70
 
71
  add_filter( 'all_plugins', array( 'Akismet_Admin', 'modify_plugin_description' ) );
72
+
73
+ if ( class_exists( 'Jetpack' ) ) {
74
+ add_filter( 'akismet_comment_form_privacy_notice_url_display', array( 'Akismet_Admin', 'jetpack_comment_form_privacy_notice_url' ) );
75
+ add_filter( 'akismet_comment_form_privacy_notice_url_hide', array( 'Akismet_Admin', 'jetpack_comment_form_privacy_notice_url' ) );
76
+ }
77
  }
78
 
79
  public static function admin_init() {
80
  load_plugin_textdomain( 'akismet' );
81
  add_meta_box( 'akismet-status', __('Comment History', 'akismet'), array( 'Akismet_Admin', 'comment_status_meta_box' ), 'comment', 'normal' );
82
+
83
+ if ( function_exists( 'wp_add_privacy_policy_content' ) ) {
84
+ wp_add_privacy_policy_content(
85
+ __( 'Akismet', 'akismet' ),
86
+ __( 'We collect information about visitors who comment on Sites that use our Akismet anti-spam service. The information we collect depends on how the User sets up Akismet for the Site, but typically includes the commenter\'s IP address, user agent, referrer, and Site URL (along with other information directly provided by the commenter such as their name, username, email address, and the comment itself).', 'akismet' )
87
+ );
88
+ }
89
  }
90
 
91
  public static function admin_menu() {
276
  foreach( array( 'akismet_strictness', 'akismet_show_user_comments_approved' ) as $option ) {
277
  update_option( $option, isset( $_POST[$option] ) && (int) $_POST[$option] == 1 ? '1' : '0' );
278
  }
279
+
280
+ if ( ! empty( $_POST['akismet_comment_form_privacy_notice'] ) ) {
281
+ self::set_form_privacy_notice_option( $_POST['akismet_comment_form_privacy_notice'] );
282
+ } else {
283
+ self::set_form_privacy_notice_option( 'hide' );
284
+ }
285
+
286
  if ( Akismet::predefined_api_key() ) {
287
  return false; //shouldn't have option to save key if already defined
288
  }
847
  ) );
848
  }
849
 
850
+ public static function display_privacy_notice_control_warning() {
851
+ if ( !current_user_can( 'manage_options' ) )
852
+ return;
853
+ Akismet::view( 'notice', array(
854
+ 'type' => 'privacy',
855
+ ) );
856
+ }
857
+
858
  public static function display_spam_check_warning() {
859
  Akismet::fix_scheduled_recheck();
860
 
988
  $notices[] = array( 'type' => $akismet_user->status );
989
  }
990
 
991
+ if ( false === get_option( 'akismet_comment_form_privacy_notice' ) ) {
992
+ $notices[] = array( 'type' => 'privacy' );
993
+ }
994
+
995
  /*
996
  // To see all variants when testing.
997
  $notices[] = array( 'type' => 'active-notice', 'time_saved' => 'Cleaning up spam takes time. Akismet has saved you 1 minute!' );
1057
  }
1058
 
1059
  echo '<div class="notice notice-success"><p>' . esc_html( $message ) . '</p></div>';
1060
+ } else if ( empty( get_option( 'akismet_comment_form_privacy_notice' ) ) ) {
1061
+ self::display_privacy_notice_control_warning();
1062
  }
1063
  }
1064
 
1164
 
1165
  return $all_plugins;
1166
  }
1167
+
1168
+ private static function set_form_privacy_notice_option( $state ) {
1169
+ if ( in_array( $state, array( 'display', 'hide' ) ) ) {
1170
+ update_option( 'akismet_comment_form_privacy_notice', $state );
1171
+ }
1172
+ }
1173
+
1174
+ public static function jetpack_comment_form_privacy_notice_url( $url ) {
1175
+ return str_replace( 'options-general.php', 'admin.php', $url );
1176
+ }
1177
  }
class.akismet.php CHANGED
@@ -51,6 +51,9 @@ class Akismet {
51
  // Jetpack compatibility
52
  add_filter( 'jetpack_options_whitelist', array( 'Akismet', 'add_to_jetpack_options_whitelist' ) );
53
  add_action( 'update_option_wordpress_api_key', array( 'Akismet', 'updated_option' ), 10, 2 );
 
 
 
54
  }
55
 
56
  public static function get_api_key() {
@@ -110,6 +113,18 @@ class Akismet {
110
  }
111
  }
112
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  public static function rest_auto_check_comment( $commentdata ) {
114
  self::$is_rest_api_call = true;
115
 
@@ -1187,7 +1202,7 @@ class Akismet {
1187
  <!doctype html>
1188
  <html>
1189
  <head>
1190
- <meta charset="<?php bloginfo( 'charset' ); ?>">
1191
  <style>
1192
  * {
1193
  text-align: center;
@@ -1200,6 +1215,7 @@ p {
1200
  font-size: 18px;
1201
  }
1202
  </style>
 
1203
  <body>
1204
  <p><?php echo esc_html( $message ); ?></p>
1205
  </body>
@@ -1388,4 +1404,21 @@ p {
1388
 
1389
  return apply_filters( 'akismet_predefined_api_key', false );
1390
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1391
  }
51
  // Jetpack compatibility
52
  add_filter( 'jetpack_options_whitelist', array( 'Akismet', 'add_to_jetpack_options_whitelist' ) );
53
  add_action( 'update_option_wordpress_api_key', array( 'Akismet', 'updated_option' ), 10, 2 );
54
+ add_action( 'add_option_wordpress_api_key', array( 'Akismet', 'added_option' ), 10, 2 );
55
+
56
+ add_action( 'comment_form_after', array( 'Akismet', 'display_comment_form_privacy_notice' ) );
57
  }
58
 
59
  public static function get_api_key() {
113
  }
114
  }
115
 
116
+ /**
117
+ * Treat the creation of an API key the same as updating the API key to a new value.
118
+ *
119
+ * @param mixed $option_name Will always be "wordpress_api_key", until something else hooks in here.
120
+ * @param mixed $value The option value.
121
+ */
122
+ public static function added_option( $option_name, $value ) {
123
+ if ( 'wordpress_api_key' === $option_name ) {
124
+ return self::updated_option( '', $value );
125
+ }
126
+ }
127
+
128
  public static function rest_auto_check_comment( $commentdata ) {
129
  self::$is_rest_api_call = true;
130
 
1202
  <!doctype html>
1203
  <html>
1204
  <head>
1205
+ <meta charset="<?php bloginfo( 'charset' ); ?>" />
1206
  <style>
1207
  * {
1208
  text-align: center;
1215
  font-size: 18px;
1216
  }
1217
  </style>
1218
+ </head>
1219
  <body>
1220
  <p><?php echo esc_html( $message ); ?></p>
1221
  </body>
1404
 
1405
  return apply_filters( 'akismet_predefined_api_key', false );
1406
  }
1407
+
1408
+ /**
1409
+ * Controls the display of a privacy related notice underneath the comment form using the `akismet_comment_form_privacy_notice` option and filter respectively.
1410
+ * Default is top not display the notice, leaving the choice to site admins, or integrators.
1411
+ */
1412
+ public static function display_comment_form_privacy_notice() {
1413
+ if ( 'display' !== apply_filters( 'akismet_comment_form_privacy_notice', get_option( 'akismet_comment_form_privacy_notice', 'hide' ) ) ) {
1414
+ return;
1415
+ }
1416
+ echo apply_filters(
1417
+ 'akismet_comment_form_privacy_notice_markup',
1418
+ '<p class="akismet_comment_form_privacy_notice">' . sprintf(
1419
+ __( 'This site uses Akismet to reduce spam. <a href="%s">Learn how your comment data is processed</a>.', 'akismet' ),
1420
+ 'https://akismet.com/privacy/'
1421
+ ) . '</p>'
1422
+ );
1423
+ }
1424
  }
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: 4.9.1
6
- Stable tag: 4.0.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,14 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
30
 
31
  == Changelog ==
32
 
 
 
 
 
 
 
 
 
33
  = 4.0.3 =
34
  *Release Date - 19 February 2018*
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: 4.9.6
6
+ Stable tag: 4.0.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.0.4 =
34
+ *Release Date - 26 May 2018*
35
+
36
+ * Added a hook to provide Akismet-specific privacy information for a site's privacy policy.
37
+ * Added tools to control the display of a privacy related notice under comment forms.
38
+ * Fixed HTML in activation failure message to close META and HEAD tag properly.
39
+ * Fixed a bug that would sometimes prevent Akismet from being correctly auto-configured.
40
+
41
  = 4.0.3 =
42
  *Release Date - 19 February 2018*
43
 
views/config.php CHANGED
@@ -151,6 +151,17 @@
151
  ?>
152
  </td>
153
  </tr>
 
 
 
 
 
 
 
 
 
 
 
154
  </tbody>
155
  </table>
156
  <div class="akismet-card-actions">
@@ -228,4 +239,4 @@
228
  <?php } ?>
229
  <?php endif;?>
230
  </div>
231
- </div>
151
  ?>
152
  </td>
153
  </tr>
154
+ <tr>
155
+ <th class="comment-form-privacy-notice" align="left" scope="row"><?php esc_html_e('Privacy', 'akismet'); ?></th>
156
+ <td></td>
157
+ <td align="left">
158
+ <fieldset><legend class="screen-reader-text"><span><?php esc_html_e('Akismet privacy notice', 'akismet'); ?></span></legend>
159
+ <p><label for="akismet_comment_form_privacy_notice_display"><input type="radio" name="akismet_comment_form_privacy_notice" id="akismet_comment_form_privacy_notice_display" value="display" <?php checked('display', get_option('akismet_comment_form_privacy_notice')); ?> /> <?php esc_html_e('Display a privacy notice under your comment forms.', 'akismet'); ?></label></p>
160
+ <p><label for="akismet_comment_form_privacy_notice_hide"><input type="radio" name="akismet_comment_form_privacy_notice" id="akismet_comment_form_privacy_notice_hide" value="hide" <?php echo in_array( get_option('akismet_comment_form_privacy_notice'), array('display', 'hide') ) ? checked('hide', get_option('akismet_comment_form_privacy_notice'), false) : 'checked="checked"'; ?> /> <?php esc_html_e('Do not display privacy notice.', 'akismet'); ?></label></p>
161
+ </fieldset>
162
+ <span class="akismet-note"><?php esc_html_e( 'To help your site be compliant with GDPR and other laws requiring notification of tracking, Akismet can display a notice to your users on your contact form. This feature is disabled by default, however, if you or your audience is located in Europe, you need to turn it on.', 'akismet' );?></span>
163
+ </td>
164
+ </tr>
165
  </tbody>
166
  </table>
167
  <div class="akismet-card-actions">
239
  <?php } ?>
240
  <?php endif;?>
241
  </div>
242
+ </div>
views/notice.php CHANGED
@@ -15,7 +15,7 @@
15
  <?php elseif ( $type == 'spam-check' ) :?>
16
  <div class="notice notice-warning">
17
  <p><strong><?php esc_html_e( 'Akismet has detected a problem.', 'akismet' );?></strong></p>
18
- <p><?php printf( __( 'Some comments have not yet been checked for spam by Akismet. They have been temporarily held for moderation and will automatically be rechecked later.', 'akismet' ) ); ?></p>
19
  <?php if ( $link_text ) { ?>
20
  <p><?php echo $link_text; ?></p>
21
  <?php } ?>
@@ -132,4 +132,10 @@
132
  </p>
133
  <?php endif; ?>
134
  </div>
135
- <?php endif;?>
 
 
 
 
 
 
15
  <?php elseif ( $type == 'spam-check' ) :?>
16
  <div class="notice notice-warning">
17
  <p><strong><?php esc_html_e( 'Akismet has detected a problem.', 'akismet' );?></strong></p>
18
+ <p><?php esc_html_e( 'Some comments have not yet been checked for spam by Akismet. They have been temporarily held for moderation and will automatically be rechecked later.', 'akismet' ); ?></p>
19
  <?php if ( $link_text ) { ?>
20
  <p><?php echo $link_text; ?></p>
21
  <?php } ?>
132
  </p>
133
  <?php endif; ?>
134
  </div>
135
+ <?php elseif ( $type == 'privacy' ) :?>
136
+ <div class="notice notice-warning is-dismissible" id="akismet-privacy-notice-admin-notice">
137
+ <p><strong><?php esc_html_e( 'Akismet & Privacy.', 'akismet' );?></strong></p>
138
+ <p><?php esc_html_e( 'To help your site be compliant with GDPR and other laws requiring notification of tracking, Akismet can display a notice to your users on your contact form. This feature is disabled by default, however, if you or your audience is located in Europe, you need to turn it on.', 'akismet' ); ?></p>
139
+ <p><?php printf( __(' Please <a href="%s">enable</a> or <a href="%s">disable</a> this feature. <a href="%s" id="akismet-privacy-notice-control-notice-info-link" target="_blank">More information</a>.', 'akismet' ), admin_url( apply_filters( 'akismet_comment_form_privacy_notice_url_display', 'options-general.php?page=akismet-key-config&akismet_comment_form_privacy_notice=display' ) ), admin_url( apply_filters( 'akismet_comment_form_privacy_notice_url_hide', 'options-general.php?page=akismet-key-config&akismet_comment_form_privacy_notice=hide' ) ), 'https://akismet.com/privacy/' ); ?></p>
140
+ </div>
141
+ <?php endif;?>