Akismet Anti-Spam - Version 3.0.4

Version Description

Release Date - 11th December, 2014

  • Fix to make .htaccess compatible with Apache 2.4.
  • Fix to allow removal of https author URLs.
  • Fix to avoid stripping part of the author URL when removing and re-adding.
  • Removed the "Check for Spam" button from the "Trash" and "Approved" queues, where it would have no effect.
  • Allow automatic API key configuration when Jetpack is installed and connected to a WordPress.com account
Download this release

Release Info

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

Code changes from version 3.0.3 to 3.0.4

Files changed (6) hide show
  1. .htaccess +28 -5
  2. _inc/akismet.js +4 -4
  3. akismet.php +2 -2
  4. class.akismet-admin.php +29 -10
  5. readme.txt +12 -3
  6. views/config.php +17 -1
.htaccess CHANGED
@@ -1,11 +1,34 @@
1
- Order Deny,Allow
2
- Deny from all
3
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  <FilesMatch "^(form|akismet)\.(css|js)$">
5
- Allow from all
 
 
 
 
 
 
6
  </FilesMatch>
7
 
8
- #allow access to any image
9
  <FilesMatch "^(.+)\.(png|gif)$">
10
- Allow from all
 
 
 
 
 
 
11
  </FilesMatch>
1
+ # Only allow direct access to specific Web-available files.
 
2
 
3
+ # Apache 2.2
4
+ <IfModule !mod_authz_core.c>
5
+ Order Deny,Allow
6
+ Deny from all
7
+ </IfModule>
8
+
9
+ # Apache 2.4
10
+ <IfModule mod_authz_core.c>
11
+ Require all denied
12
+ </IfModule>
13
+
14
+ # Akismet CSS and JS
15
  <FilesMatch "^(form|akismet)\.(css|js)$">
16
+ <IfModule !mod_authz_core.c>
17
+ Allow from all
18
+ </IfModule>
19
+
20
+ <IfModule mod_authz_core.c>
21
+ Require all granted
22
+ </IfModule>
23
  </FilesMatch>
24
 
25
+ # Akismet images
26
  <FilesMatch "^(.+)\.(png|gif)$">
27
+ <IfModule !mod_authz_core.c>
28
+ Allow from all
29
+ </IfModule>
30
+
31
+ <IfModule mod_authz_core.c>
32
+ Require all granted
33
+ </IfModule>
34
  </FilesMatch>
_inc/akismet.js CHANGED
@@ -18,7 +18,7 @@ jQuery( function ( $ ) {
18
  var thisId = $(this).attr('commentid');
19
  $(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
20
  });
21
- $('#the-comment-list').find('tr.comment, tr[id ^= "comment-"]').find('.column-author a[title ^= "http://"]').each(function () {
22
  var thisTitle = $(this).attr('title');
23
  thisCommentId = $(this).parents('tr:first').attr('id').split("-");
24
 
@@ -72,7 +72,7 @@ jQuery( function ( $ ) {
72
  });
73
  $('.akismet_undo_link_removal').live('click', function () {
74
  var thisId = $(this).attr('cid');
75
- var thisUrl = $(this).attr('href').replace("http://www.", "").replace("http://", "");
76
  var data = {
77
  action: 'comment_author_reurl',
78
  _wpnonce: WPAkismet.comment_author_url_nonce,
@@ -91,8 +91,8 @@ jQuery( function ( $ ) {
91
  if (response) {
92
  // Add "x" link
93
  $("a[commentid='"+ thisId +"']").show();
94
- // Show link
95
- $("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').html(thisUrl);
96
  }
97
  }
98
  });
18
  var thisId = $(this).attr('commentid');
19
  $(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
20
  });
21
+ $('#the-comment-list').find('tr.comment, tr[id ^= "comment-"]').find('.column-author a[title ^= "http://"], .column-author a[title ^= "https://"]').each(function () {
22
  var thisTitle = $(this).attr('title');
23
  thisCommentId = $(this).parents('tr:first').attr('id').split("-");
24
 
72
  });
73
  $('.akismet_undo_link_removal').live('click', function () {
74
  var thisId = $(this).attr('cid');
75
+ var thisUrl = $(this).attr('href');
76
  var data = {
77
  action: 'comment_author_reurl',
78
  _wpnonce: WPAkismet.comment_author_url_nonce,
91
  if (response) {
92
  // Add "x" link
93
  $("a[commentid='"+ thisId +"']").show();
94
+ // Show link. Core strips leading http://, so let's do that too.
95
+ $("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').text( thisUrl.replace( /^http:\/\/(www\.)?/ig, '' ) );
96
  }
97
  }
98
  });
akismet.php CHANGED
@@ -6,7 +6,7 @@
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 trackback 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/">Sign up for an Akismet API key</a>, and 3) Go to your Akismet configuration page, and save your API key.
9
- Version: 3.0.3
10
  Author: Automattic
11
  Author URI: http://automattic.com/wordpress-plugins/
12
  License: GPLv2 or later
@@ -35,7 +35,7 @@ if ( !function_exists( 'add_action' ) ) {
35
  exit;
36
  }
37
 
38
- define( 'AKISMET_VERSION', '3.0.3' );
39
  define( 'AKISMET__MINIMUM_WP_VERSION', '3.1' );
40
  define( 'AKISMET__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
41
  define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
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 trackback 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/">Sign up for an Akismet API key</a>, and 3) Go to your Akismet configuration page, and save your API key.
9
+ Version: 3.0.4
10
  Author: Automattic
11
  Author URI: http://automattic.com/wordpress-plugins/
12
  License: GPLv2 or later
35
  exit;
36
  }
37
 
38
+ define( 'AKISMET_VERSION', '3.0.4' );
39
  define( 'AKISMET__MINIMUM_WP_VERSION', '3.1' );
40
  define( 'AKISMET__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
41
  define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
class.akismet-admin.php CHANGED
@@ -37,6 +37,7 @@ class Akismet_Admin {
37
  add_action( 'wp_ajax_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) );
38
  add_action( 'wp_ajax_comment_author_deurl', array( 'Akismet_Admin', 'remove_comment_author_url' ) );
39
  add_action( 'wp_ajax_comment_author_reurl', array( 'Akismet_Admin', 'add_comment_author_url' ) );
 
40
 
41
  add_filter( 'plugin_action_links', array( 'Akismet_Admin', 'plugin_action_links' ), 10, 2 );
42
  add_filter( 'comment_row_actions', array( 'Akismet_Admin', 'comment_row_action' ), 10, 2 );
@@ -324,10 +325,10 @@ class Akismet_Admin {
324
  }
325
 
326
  public static function check_for_spam_button( $comment_status ) {
327
- if ( 'approved' == $comment_status )
328
- return;
329
-
330
- if ( 'spam' == $comment_status ) {
331
  return;
332
  }
333
 
@@ -653,13 +654,12 @@ class Akismet_Admin {
653
  return $stat_totals;
654
  }
655
 
656
- public static function verify_wpcom_key( $api_key, $user_id, $token = '' ) {
657
- $akismet_account = Akismet::http_post( Akismet::build_query( array(
658
  'user_id' => $user_id,
659
  'api_key' => $api_key,
660
- 'token' => $token,
661
  'get_account_type' => 'true'
662
- ) ), 'verify-wpcom-key' );
663
 
664
  if ( ! empty( $akismet_account[1] ) )
665
  $akismet_account = json_decode( $akismet_account[1] );
@@ -668,6 +668,22 @@ class Akismet_Admin {
668
 
669
  return $akismet_account;
670
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
671
 
672
  public static function display_alert() {
673
  Akismet::view( 'notice', array(
@@ -723,7 +739,7 @@ class Akismet_Admin {
723
  $akismet_user = false;
724
 
725
  if ( isset( $_GET['token'] ) && preg_match('/^(\d+)-[0-9a-f]{20}$/', $_GET['token'] ) )
726
- $akismet_user = self::verify_wpcom_key( '', '', $_GET['token'] );
727
  elseif ( $jetpack_user = self::get_jetpack_user() )
728
  $akismet_user = self::verify_wpcom_key( $jetpack_user['api_key'], $jetpack_user['user_id'] );
729
 
@@ -797,7 +813,10 @@ class Akismet_Admin {
797
  global $hook_suffix;
798
 
799
  if ( in_array( $hook_suffix, array( 'jetpack_page_akismet-key-config', 'settings_page_akismet-key-config', 'edit-comments.php' ) ) && (int) get_option( 'akismet_alert_code' ) > 0 ) {
800
- self::display_alert();
 
 
 
801
  }
802
  elseif ( $hook_suffix == 'plugins.php' && !Akismet::get_api_key() ) {
803
  self::display_api_key_warning();
37
  add_action( 'wp_ajax_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) );
38
  add_action( 'wp_ajax_comment_author_deurl', array( 'Akismet_Admin', 'remove_comment_author_url' ) );
39
  add_action( 'wp_ajax_comment_author_reurl', array( 'Akismet_Admin', 'add_comment_author_url' ) );
40
+ add_action( 'jetpack_auto_activate_akismet', array( 'Akismet_Admin', 'connect_jetpack_user' ) );
41
 
42
  add_filter( 'plugin_action_links', array( 'Akismet_Admin', 'plugin_action_links' ), 10, 2 );
43
  add_filter( 'comment_row_actions', array( 'Akismet_Admin', 'comment_row_action' ), 10, 2 );
325
  }
326
 
327
  public static function check_for_spam_button( $comment_status ) {
328
+ // The "Check for Spam" button should only appear when the page might be showing
329
+ // a comment with comment_approved=0, which means an un-trashed, un-spammed,
330
+ // not-yet-moderated comment.
331
+ if ( 'all' != $comment_status && 'moderated' != $comment_status ) {
332
  return;
333
  }
334
 
654
  return $stat_totals;
655
  }
656
 
657
+ public static function verify_wpcom_key( $api_key, $user_id, $extra = array() ) {
658
+ $akismet_account = Akismet::http_post( Akismet::build_query( array_merge( array(
659
  'user_id' => $user_id,
660
  'api_key' => $api_key,
 
661
  'get_account_type' => 'true'
662
+ ), $extra ) ), 'verify-wpcom-key' );
663
 
664
  if ( ! empty( $akismet_account[1] ) )
665
  $akismet_account = json_decode( $akismet_account[1] );
668
 
669
  return $akismet_account;
670
  }
671
+
672
+ public static function connect_jetpack_user() {
673
+
674
+ if ( $jetpack_user = self::get_jetpack_user() ) {
675
+ if ( isset( $jetpack_user['user_id'] ) && isset( $jetpack_user['api_key'] ) ) {
676
+ $akismet_user = self::verify_wpcom_key( $jetpack_user['api_key'], $jetpack_user['user_id'], array( 'action' => 'connect_jetpack_user' ) );
677
+
678
+ if ( is_object( $akismet_user ) ) {
679
+ self::save_key( $akismet_user->api_key );
680
+ return in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub' ) );
681
+ }
682
+ }
683
+ }
684
+
685
+ return false;
686
+ }
687
 
688
  public static function display_alert() {
689
  Akismet::view( 'notice', array(
739
  $akismet_user = false;
740
 
741
  if ( isset( $_GET['token'] ) && preg_match('/^(\d+)-[0-9a-f]{20}$/', $_GET['token'] ) )
742
+ $akismet_user = self::verify_wpcom_key( '', '', array( 'token' => $_GET['token'] ) );
743
  elseif ( $jetpack_user = self::get_jetpack_user() )
744
  $akismet_user = self::verify_wpcom_key( $jetpack_user['api_key'], $jetpack_user['user_id'] );
745
 
813
  global $hook_suffix;
814
 
815
  if ( in_array( $hook_suffix, array( 'jetpack_page_akismet-key-config', 'settings_page_akismet-key-config', 'edit-comments.php' ) ) && (int) get_option( 'akismet_alert_code' ) > 0 ) {
816
+ Akismet::verify_key( Akismet::get_api_key() ); //verify that the key is still in alert state
817
+
818
+ if ( get_option( 'akismet_alert_code' ) > 0 )
819
+ self::display_alert();
820
  }
821
  elseif ( $hook_suffix == 'plugins.php' && !Akismet::get_api_key() ) {
822
  self::display_api_key_warning();
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Akismet ===
2
- Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic
3
  Tags: akismet, comments, spam
4
  Requires at least: 3.1
5
- Tested up to: 4.0
6
- Stable tag: 3.0.3
7
  License: GPLv2 or later
8
 
9
  Akismet checks your comments against the Akismet Web service to see if they look like spam or not.
@@ -30,6 +30,15 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
30
 
31
  == Changelog ==
32
 
 
 
 
 
 
 
 
 
 
33
  = 3.0.3 =
34
  *Release Date - 3rd November, 2014*
35
 
1
  === Akismet ===
2
+ Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs
3
  Tags: akismet, comments, spam
4
  Requires at least: 3.1
5
+ Tested up to: 4.1
6
+ Stable tag: 3.0.4
7
  License: GPLv2 or later
8
 
9
  Akismet checks your comments against the Akismet Web service to see if they look like spam or not.
30
 
31
  == Changelog ==
32
 
33
+ = 3.0.4 =
34
+ *Release Date - 11th December, 2014*
35
+
36
+ * Fix to make .htaccess compatible with Apache 2.4.
37
+ * Fix to allow removal of https author URLs.
38
+ * Fix to avoid stripping part of the author URL when removing and re-adding.
39
+ * Removed the "Check for Spam" button from the "Trash" and "Approved" queues, where it would have no effect.
40
+ * Allow automatic API key configuration when Jetpack is installed and connected to a WordPress.com account
41
+
42
  = 3.0.3 =
43
  *Release Date - 3rd November, 2014*
44
 
views/config.php CHANGED
@@ -88,7 +88,23 @@
88
  <p><label for="akismet_strictness_1"><input type="radio" name="akismet_strictness" id="akismet_strictness_1" value="1" <?php checked('1', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Silently discard the worst and most pervasive spam so I never see it.', 'akismet'); ?></label></p>
89
  <p><label for="akismet_strictness_0"><input type="radio" name="akismet_strictness" id="akismet_strictness_0" value="0" <?php checked('0', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Always put spam in the Spam folder for review.', 'akismet'); ?></label></p>
90
  </fieldset>
91
- <span class="note"><strong><?php esc_html_e('Note:', 'akismet');?></strong> <?php printf( __( 'Spam in the <a href="%s">spam folder</a> older than 15 days is deleted automatically.' , 'akismet'), admin_url( 'edit-comments.php?comment_status=spam' ) );?></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  </td>
93
  </tr>
94
  </tbody>
88
  <p><label for="akismet_strictness_1"><input type="radio" name="akismet_strictness" id="akismet_strictness_1" value="1" <?php checked('1', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Silently discard the worst and most pervasive spam so I never see it.', 'akismet'); ?></label></p>
89
  <p><label for="akismet_strictness_0"><input type="radio" name="akismet_strictness" id="akismet_strictness_0" value="0" <?php checked('0', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Always put spam in the Spam folder for review.', 'akismet'); ?></label></p>
90
  </fieldset>
91
+ <span class="note"><strong><?php esc_html_e('Note:', 'akismet');?></strong>
92
+ <?php
93
+
94
+ $delete_interval = max( 1, intval( apply_filters( 'akismet_delete_comment_interval', 15 ) ) );
95
+
96
+ printf(
97
+ _n(
98
+ 'Spam in the <a href="%s">spam folder</a> older than 1 day is deleted automatically.',
99
+ 'Spam in the <a href="%1$s">spam folder</a> older than %2$d days is deleted automatically.',
100
+ $delete_interval,
101
+ 'akismet'
102
+ ),
103
+ admin_url( 'edit-comments.php?comment_status=spam' ),
104
+ $delete_interval
105
+ );
106
+
107
+ ?>
108
  </td>
109
  </tr>
110
  </tbody>