Akismet Anti-Spam - Version 2.5.4

Version Description

  • Limit Akismet CSS and Javascript loading in wp-admin to just the pages that need it
  • Added author URL quick removal functionality
  • Added mShot preview on Author URL hover
  • Added empty index.php to prevent directory listing
  • Move wp-admin menu items under Jetpack, if it is installed
  • Purge old Akismet comment meta data, default of 15 days
Download this release

Release Info

Developer josephscott
Plugin Icon 128x128 Akismet Anti-Spam
Version 2.5.4
Comparing to
See all releases

Code changes from version 2.5.3 to 2.5.4

Files changed (7) hide show
  1. admin.php +84 -25
  2. akismet.css +5 -0
  3. akismet.js +94 -0
  4. akismet.php +50 -7
  5. index.php +2 -0
  6. legacy.php +3 -3
  7. readme.txt +10 -2
admin.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
- add_action( 'admin_menu', 'akismet_config_page' );
3
- add_action( 'admin_menu', 'akismet_stats_page' );
4
  akismet_admin_warnings();
5
 
6
  function akismet_admin_init() {
@@ -25,24 +25,35 @@ 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');
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  function akismet_nonce_field($action = -1) { return wp_nonce_field($action); }
36
  $akismet_nonce = 'akismet-update-key';
37
 
38
- function akismet_config_page() {
39
- if ( function_exists('add_submenu_page') )
40
- add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf');
41
- }
42
-
43
  function akismet_plugin_action_links( $links, $file ) {
44
  if ( $file == plugin_basename( dirname(__FILE__).'/akismet.php' ) ) {
45
- $links[] = '<a href="plugins.php?page=akismet-key-config">'.__('Settings').'</a>';
46
  }
47
 
48
  return $links;
@@ -124,7 +135,7 @@ function akismet_conf() {
124
  'new_key_invalid' => array('color' => '888', 'text' => __('The key you entered is invalid. Please double-check it.')),
125
  'new_key_failed' => array('color' => '888', 'text' => __('The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.')),
126
  'no_connection' => array('color' => '888', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')),
127
- 'key_empty' => array('color' => 'aa0', 'text' => sprintf(__('Please enter an API key. (<a href="%s" style="color:#fff">Get your key.</a>)'), 'http://akismet.com/get/')),
128
  'key_valid' => array('color' => '4AB915', 'text' => __('This key is valid.')),
129
  'key_failed' => array('color' => 'aa0', 'text' => __('The key below was previously validated but a connection to akismet.com can not be established at this time. Please check your server configuration.')),
130
  'bad_home_url' => array('color' => '888', 'text' => sprintf( __('Your WordPress home URL %s is invalid. Please fix the <a href="%s">home option</a>.'), esc_html( get_bloginfo('url') ), admin_url('options.php#home') ) ),
@@ -141,13 +152,13 @@ function akismet_conf() {
141
  <div class="narrow">
142
  <form action="" method="post" id="akismet-conf" style="margin: auto; width: 400px; ">
143
  <?php if ( !$wpcom_api_key ) { ?>
144
- <p><?php printf(__('For many people, <a href="%1$s">Akismet</a> will greatly reduce or even completely eliminate the comment and trackback spam you get on your site. If one does happen to get through, simply mark it as "spam" on the moderation screen and Akismet will learn from the mistakes. If you don\'t have an API key yet, you can get one at <a href="%2$s">Akismet.com</a>.'), 'http://akismet.com/', 'http://akismet.com/get/'); ?></p>
145
 
146
  <h3><label for="key"><?php _e('Akismet API Key'); ?></label></h3>
147
  <?php foreach ( $ms as $m ) : ?>
148
  <p style="padding: .5em; background-color: #<?php echo $messages[$m]['color']; ?>; color: #fff; font-weight: bold;"><?php echo $messages[$m]['text']; ?></p>
149
  <?php endforeach; ?>
150
- <p><input id="key" name="key" type="text" size="15" maxlength="12" value="<?php echo get_option('wordpress_api_key'); ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php _e('<a href="http://akismet.com/get/">What is this?</a>'); ?>)</p>
151
  <?php if ( isset( $invalid_key) && $invalid_key ) { ?>
152
  <h3><?php _e('Why might my key be invalid?'); ?></h3>
153
  <p><?php _e('This can mean one of two things, either you copied the key wrong or that the plugin is unable to reach the Akismet servers, which is most often caused by an issue with your web host around firewalls or similar.'); ?></p>
@@ -226,12 +237,6 @@ function akismet_conf() {
226
  <?php
227
  }
228
 
229
- function akismet_stats_page() {
230
- if ( function_exists('add_submenu_page') )
231
- add_submenu_page('index.php', __('Akismet Stats'), __('Akismet Stats'), 'manage_options', 'akismet-stats-display', 'akismet_stats_display');
232
-
233
- }
234
-
235
  function akismet_stats_script() {
236
  ?>
237
  <script type="text/javascript">
@@ -278,7 +283,7 @@ function akismet_stats() {
278
  $link = 'edit-comments.php';
279
  else
280
  $link = 'edit.php';
281
- 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>';
282
  }
283
  add_action('activity_box_end', 'akismet_stats');
284
 
@@ -445,9 +450,9 @@ function akismet_rightnow() {
445
  '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already. ',
446
  '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already. ',
447
  $count
448
- ), 'http://akismet.com/', number_format_i18n( $count ) );
449
  } else {
450
- $intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog. '), 'http://akismet.com/' );
451
  }
452
 
453
  if ( $queue_count = akismet_spam_count() ) {
@@ -512,6 +517,9 @@ function akismet_submit_nonspam_comment ( $comment_id ) {
512
  if ( akismet_test_mode() )
513
  $comment->is_test = 'true';
514
 
 
 
 
515
  $query_string = '';
516
  foreach ( $comment as $key => $data )
517
  $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
@@ -561,6 +569,9 @@ function akismet_submit_spam_comment ( $comment_id ) {
561
  if ( akismet_test_mode() )
562
  $comment->is_test = 'true';
563
 
 
 
 
564
  $query_string = '';
565
  foreach ( $comment as $key => $data )
566
  $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
@@ -689,12 +700,43 @@ function akismet_recheck_queue() {
689
  }
690
 
691
  }
692
- wp_redirect( $_SERVER['HTTP_REFERER'] );
693
  exit;
694
  }
695
 
696
  add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue');
697
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
698
  // Check connectivity between the WordPress blog and Akismet's servers.
699
  // Returns an associative array of server IP addresses, where the key is the IP address, and value is true (available) or false (unable to connect).
700
  function akismet_check_server_connectivity() {
@@ -748,3 +790,20 @@ function akismet_server_connectivity_ok() {
748
  return !( empty($servers) || !count($servers) || count( array_filter($servers) ) < count($servers) );
749
  }
750
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ add_action( 'admin_menu', 'akismet_admin_menu' );
3
+
4
  akismet_admin_warnings();
5
 
6
  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
  }
29
  add_action('admin_init', 'akismet_admin_init');
30
 
31
+ add_action( 'admin_enqueue_scripts', 'akismet_load_js_and_css' );
32
+ function akismet_load_js_and_css() {
33
+ global $hook_suffix;
34
+
35
+ if (
36
+ $hook_suffix == 'index.php' # dashboard
37
+ || $hook_suffix == 'edit-comments.php'
38
+ || $hook_suffix == 'comment.php'
39
+ || $hook_suffix == 'post.php'
40
+ || $hook_suffix == 'plugins_page_akismet-key-config'
41
+ ) {
42
+ wp_register_style( 'akismet.css', AKISMET_PLUGIN_URL . 'akismet.css', array(), '2.5.4.4' );
43
+ wp_enqueue_style( 'akismet.css');
44
+
45
+ wp_register_script( 'akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery'), '2.5.4.6' );
46
+ wp_enqueue_script( 'akismet.js' );
47
+ }
48
+ }
49
+
50
+
51
  function akismet_nonce_field($action = -1) { return wp_nonce_field($action); }
52
  $akismet_nonce = 'akismet-update-key';
53
 
 
 
 
 
 
54
  function akismet_plugin_action_links( $links, $file ) {
55
  if ( $file == plugin_basename( dirname(__FILE__).'/akismet.php' ) ) {
56
+ $links[] = '<a href="admin.php?page=akismet-key-config">'.__('Settings').'</a>';
57
  }
58
 
59
  return $links;
135
  'new_key_invalid' => array('color' => '888', 'text' => __('The key you entered is invalid. Please double-check it.')),
136
  'new_key_failed' => array('color' => '888', 'text' => __('The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.')),
137
  'no_connection' => array('color' => '888', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')),
138
+ 'key_empty' => array('color' => 'aa0', 'text' => sprintf(__('Please enter an API key. (<a href="%s" style="color:#fff">Get your key.</a>)'), 'http://akismet.com/get/?return=true')),
139
  'key_valid' => array('color' => '4AB915', 'text' => __('This key is valid.')),
140
  'key_failed' => array('color' => 'aa0', 'text' => __('The key below was previously validated but a connection to akismet.com can not be established at this time. Please check your server configuration.')),
141
  'bad_home_url' => array('color' => '888', 'text' => sprintf( __('Your WordPress home URL %s is invalid. Please fix the <a href="%s">home option</a>.'), esc_html( get_bloginfo('url') ), admin_url('options.php#home') ) ),
152
  <div class="narrow">
153
  <form action="" method="post" id="akismet-conf" style="margin: auto; width: 400px; ">
154
  <?php if ( !$wpcom_api_key ) { ?>
155
+ <p><?php printf(__('For many people, <a href="%1$s">Akismet</a> will greatly reduce or even completely eliminate the comment and trackback spam you get on your site. If one does happen to get through, simply mark it as "spam" on the moderation screen and Akismet will learn from the mistakes. If you don\'t have an API key yet, you can get one at <a href="%2$s">Akismet.com</a>.'), 'http://akismet.com/?return=true', 'http://akismet.com/get/?return=true'); ?></p>
156
 
157
  <h3><label for="key"><?php _e('Akismet API Key'); ?></label></h3>
158
  <?php foreach ( $ms as $m ) : ?>
159
  <p style="padding: .5em; background-color: #<?php echo $messages[$m]['color']; ?>; color: #fff; font-weight: bold;"><?php echo $messages[$m]['text']; ?></p>
160
  <?php endforeach; ?>
161
+ <p><input id="key" name="key" type="text" size="15" maxlength="12" value="<?php echo get_option('wordpress_api_key'); ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php _e('<a href="http://akismet.com/get/?return=true">What is this?</a>'); ?>)</p>
162
  <?php if ( isset( $invalid_key) && $invalid_key ) { ?>
163
  <h3><?php _e('Why might my key be invalid?'); ?></h3>
164
  <p><?php _e('This can mean one of two things, either you copied the key wrong or that the plugin is unable to reach the Akismet servers, which is most often caused by an issue with your web host around firewalls or similar.'); ?></p>
237
  <?php
238
  }
239
 
 
 
 
 
 
 
240
  function akismet_stats_script() {
241
  ?>
242
  <script type="text/javascript">
283
  $link = 'edit-comments.php';
284
  else
285
  $link = 'edit.php';
286
+ 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/?return=true', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'</p>';
287
  }
288
  add_action('activity_box_end', 'akismet_stats');
289
 
450
  '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already. ',
451
  '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already. ',
452
  $count
453
+ ), 'http://akismet.com/?return=true', number_format_i18n( $count ) );
454
  } else {
455
+ $intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog. '), 'http://akismet.com/?return=true' );
456
  }
457
 
458
  if ( $queue_count = akismet_spam_count() ) {
517
  if ( akismet_test_mode() )
518
  $comment->is_test = 'true';
519
 
520
+ $post = get_post( $comment->comment_post_ID );
521
+ $comment->comment_post_modified_gmt = $post->post_modified_gmt;
522
+
523
  $query_string = '';
524
  foreach ( $comment as $key => $data )
525
  $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
569
  if ( akismet_test_mode() )
570
  $comment->is_test = 'true';
571
 
572
+ $post = get_post( $comment->comment_post_ID );
573
+ $comment->comment_post_modified_gmt = $post->post_modified_gmt;
574
+
575
  $query_string = '';
576
  foreach ( $comment as $key => $data )
577
  $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
700
  }
701
 
702
  }
703
+ wp_safe_redirect( $_SERVER['HTTP_REFERER'] );
704
  exit;
705
  }
706
 
707
  add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue');
708
 
709
+ // Adds an 'x' link next to author URLs, clicking will remove the author URL and show an undo link
710
+ function akismet_remove_comment_author_url() {
711
+ if (!empty($_POST['id'])) {
712
+ global $wpdb;
713
+ $comment = get_comment( intval($_POST['id']), ARRAY_A );
714
+ if (current_user_can('edit_comment', $comment['comment_ID'])) {
715
+ $comment['comment_author_url'] = '';
716
+ do_action( 'comment_remove_author_url' );
717
+ print(wp_update_comment( $comment ));
718
+ die();
719
+ }
720
+ }
721
+ }
722
+
723
+ add_action('wp_ajax_comment_author_deurl', 'akismet_remove_comment_author_url');
724
+
725
+ function akismet_add_comment_author_url() {
726
+ if (!empty($_POST['id']) && !empty($_POST['url'])) {
727
+ global $wpdb;
728
+ $comment = get_comment( intval($_POST['id']), ARRAY_A );
729
+ if (current_user_can('edit_comment', $comment['comment_ID'])) {
730
+ $comment['comment_author_url'] = esc_url($_POST['url']);
731
+ do_action( 'comment_add_author_url' );
732
+ print(wp_update_comment( $comment ));
733
+ die();
734
+ }
735
+ }
736
+ }
737
+
738
+ add_action('wp_ajax_comment_author_reurl', 'akismet_add_comment_author_url');
739
+
740
  // Check connectivity between the WordPress blog and Akismet's servers.
741
  // Returns an associative array of server IP addresses, where the key is the IP address, and value is true (available) or false (unable to connect).
742
  function akismet_check_server_connectivity() {
790
  return !( empty($servers) || !count($servers) || count( array_filter($servers) ) < count($servers) );
791
  }
792
 
793
+ function akismet_admin_menu() {
794
+ if ( class_exists( 'Jetpack' ) ) {
795
+ add_action( 'jetpack_admin_menu', 'akismet_load_menu' );
796
+ } else {
797
+ akismet_load_menu();
798
+ }
799
+ }
800
+
801
+ function akismet_load_menu() {
802
+ if ( class_exists( 'Jetpack' ) ) {
803
+ add_submenu_page( 'jetpack', __( 'Akismet Configuration' ), __( 'Akismet Configuration' ), 'manage_options', 'akismet-key-config', 'akismet_conf' );
804
+ add_submenu_page( 'jetpack', __( 'Akismet Stats' ), __( 'Akismet Stats' ), 'manage_options', 'akismet-stats-display', 'akismet_stats_display' );
805
+ } else {
806
+ add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf');
807
+ add_submenu_page('index.php', __('Akismet Stats'), __('Akismet Stats'), 'manage_options', 'akismet-stats-display', 'akismet_stats_display');
808
+ }
809
+ }
akismet.css CHANGED
@@ -1,7 +1,12 @@
1
  #submitted-on { position: relative; }
2
  #the-comment-list .author .akismet-user-comment-count { display: inline; }
 
 
 
3
  #dashboard_recent_comments .akismet-status { display: none; } /* never show the flagged by text on the dashboard */
4
  .akismet-status { float: right; }
5
  .akismet-status a { color: #AAA; font-style: italic; }
6
  span.comment-link a { text-decoration: underline; }
7
  span.comment-link:after { content: " " attr(title) " "; color: #aaa; text-decoration: none; }
 
 
1
  #submitted-on { position: relative; }
2
  #the-comment-list .author .akismet-user-comment-count { display: inline; }
3
+ #the-comment-list .author a span { text-decoration: none; color: #999; }
4
+ #the-comment-list .remove_url { margin-left: 3px; color: #999; padding: 2px 3px 2px 0; }
5
+ #the-comment-list .remove_url:hover { color: #A7301F; font-weight: bold; padding: 2px 2px 2px 0; }
6
  #dashboard_recent_comments .akismet-status { display: none; } /* never show the flagged by text on the dashboard */
7
  .akismet-status { float: right; }
8
  .akismet-status a { color: #AAA; font-style: italic; }
9
  span.comment-link a { text-decoration: underline; }
10
  span.comment-link:after { content: " " attr(title) " "; color: #aaa; text-decoration: none; }
11
+ .mshot-arrow { width: 0; height: 0; border-top: 10px solid transparent; border-bottom: 10px solid transparent; border-right:10px solid #5C5C5C; position: absolute; left: -6px; top: 91px; }
12
+ .mshot-container { background: #5C5C5C; position: absolute; top: -94px; padding: 7px; width: 450px; height: 338px; z-index: 20000; -moz-border-radius:6px; border-radius:6px; -webkit-border-radius:6px; }
akismet.js CHANGED
@@ -7,4 +7,98 @@ jQuery(document).ready(function () {
7
  var thisId = jQuery(this).attr('commentid');
8
  jQuery(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
9
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  });
7
  var thisId = jQuery(this).attr('commentid');
8
  jQuery(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
9
  });
10
+ jQuery('#the-comment-list tr.comment .column-author a[title ^= "http://"]').each(function () {
11
+ var thisTitle = jQuery(this).attr('title');
12
+ thisCommentId = jQuery(this).parents('tr:first').attr('id').split("-");
13
+
14
+ jQuery(this).attr("id", "author_comment_url_"+ thisCommentId[1]);
15
+
16
+ if (thisTitle) {
17
+ jQuery(this).after(' <a href="#" class="remove_url" commentid="'+ thisCommentId[1] +'" title="Remove this URL">x</a>');
18
+ }
19
+ });
20
+ jQuery('.remove_url').live('click', function () {
21
+ var thisId = jQuery(this).attr('commentid');
22
+ var data = {
23
+ action: 'comment_author_deurl',
24
+ id: thisId
25
+ };
26
+ jQuery.ajax({
27
+ url: ajaxurl,
28
+ type: 'POST',
29
+ data: data,
30
+ beforeSend: function () {
31
+ // Removes "x" link
32
+ jQuery("a[commentid='"+ thisId +"']").hide();
33
+ // Show temp status
34
+ jQuery("#author_comment_url_"+ thisId).html('<span>Removing...</span>');
35
+ },
36
+ success: function (response) {
37
+ if (response) {
38
+ // Show status/undo link
39
+ jQuery("#author_comment_url_"+ thisId).attr('cid', thisId).addClass('akismet_undo_link_removal').html('<span>URL removed (</span>undo<span>)</span>');
40
+ }
41
+ }
42
+ });
43
+
44
+ return false;
45
+ });
46
+ jQuery('.akismet_undo_link_removal').live('click', function () {
47
+ var thisId = jQuery(this).attr('cid');
48
+ var thisUrl = jQuery(this).attr('href').replace("http://www.", "").replace("http://", "");
49
+ var data = {
50
+ action: 'comment_author_reurl',
51
+ id: thisId,
52
+ url: thisUrl
53
+ };
54
+ jQuery.ajax({
55
+ url: ajaxurl,
56
+ type: 'POST',
57
+ data: data,
58
+ beforeSend: function () {
59
+ // Show temp status
60
+ jQuery("#author_comment_url_"+ thisId).html('<span>Re-adding…</span>');
61
+ },
62
+ success: function (response) {
63
+ if (response) {
64
+ // Add "x" link
65
+ jQuery("a[commentid='"+ thisId +"']").show();
66
+ // Show link
67
+ jQuery("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').html(thisUrl);
68
+ }
69
+ }
70
+ });
71
+
72
+ return false;
73
+ });
74
+ jQuery('a[id^="author_comment_url"]').mouseover(function () {
75
+ // Need to determine size of author column
76
+ var thisParentWidth = jQuery(this).parent().width();
77
+ // It changes based on if there is a gravatar present
78
+ thisParentWidth = (jQuery(this).parent().find('.grav-hijack').length) ? thisParentWidth - 42 + 'px' : thisParentWidth + 'px';
79
+ if (jQuery(this).find('.mShot').length == 0 && !jQuery(this).hasClass('akismet_undo_link_removal')) {
80
+ var thisId = jQuery(this).attr('id').replace('author_comment_url_', '');
81
+ jQuery('.widefat td').css('overflow', 'visible');
82
+ jQuery(this).css('position', 'relative');
83
+ var thisHref = jQuery.URLEncode(jQuery(this).attr('href'));
84
+ jQuery(this).append('<div class="mShot mshot-container" style="left: '+thisParentWidth+'"><div class="mshot-arrow"></div><img src="http://s.wordpress.com/mshots/v1/'+thisHref+'?w=450" width="450" class="mshot-image_'+thisId+'" style="margin: 0;" /></div>');
85
+ setTimeout(function () {
86
+ jQuery('.mshot-image_'+thisId).attr('src', 'http://s.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=2');
87
+ }, 6000);
88
+ setTimeout(function () {
89
+ jQuery('.mshot-image_'+thisId).attr('src', 'http://s.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=3');
90
+ }, 12000);
91
+ } else {
92
+ jQuery(this).find('.mShot').css('left', thisParentWidth).show();
93
+ }
94
+ }).mouseout(function () {
95
+ jQuery(this).find('.mShot').hide();
96
+ });
97
+ });
98
+ // URL encode plugin
99
+ jQuery.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
100
+ while(x<c.length){var m=r.exec(c.substr(x));
101
+ if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
102
+ }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
103
+ o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;}
104
  });
akismet.php CHANGED
@@ -4,9 +4,9 @@
4
  */
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 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/?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.3
10
  Author: Automattic
11
  Author URI: http://automattic.com/wordpress-plugins/
12
  License: GPLv2 or later
@@ -28,7 +28,7 @@ along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
  */
30
 
31
- define('AKISMET_VERSION', '2.5.3');
32
  define('AKISMET_PLUGIN_URL', plugin_dir_url( __FILE__ ));
33
 
34
  /** If you hardcode a WP.com API key here, all key config screens will be hidden */
@@ -120,6 +120,8 @@ function akismet_http_post($request, $host, $path, $port = 80, $ip=null) {
120
  $akismet_ua = "WordPress/{$wp_version} | ";
121
  $akismet_ua .= 'Akismet/' . constant( 'AKISMET_VERSION' );
122
 
 
 
123
  $content_length = strlen( $request );
124
 
125
  $http_host = $host;
@@ -303,7 +305,9 @@ function akismet_auto_check_comment( $commentdata ) {
303
  $comment['blog_charset'] = get_option('blog_charset');
304
  $comment['permalink'] = get_permalink($comment['comment_post_ID']);
305
 
306
- $comment['user_role'] = akismet_get_user_roles($comment['user_ID']);
 
 
307
 
308
  $akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
309
  $comment['akismet_comment_nonce'] = 'inactive';
@@ -335,6 +339,9 @@ function akismet_auto_check_comment( $commentdata ) {
335
  $comment["$key"] = '';
336
  }
337
 
 
 
 
338
  $query_string = '';
339
  foreach ( $comment as $key => $data )
340
  $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
@@ -349,7 +356,6 @@ function akismet_auto_check_comment( $commentdata ) {
349
 
350
  do_action( 'akismet_spam_caught' );
351
 
352
- $post = get_post( $comment['comment_post_ID'] );
353
  $last_updated = strtotime( $post->post_modified_gmt );
354
  $diff = time() - $last_updated;
355
  $diff = $diff / 86400;
@@ -358,14 +364,16 @@ function akismet_auto_check_comment( $commentdata ) {
358
  // akismet_result_spam() won't be called so bump the counter here
359
  if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
360
  update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
361
- wp_redirect( $_SERVER['HTTP_REFERER'] );
362
  die();
363
  }
364
  }
365
 
366
  // if the response is neither true nor false, hold the comment for moderation and schedule a recheck
367
  if ( 'true' != $response[1] && 'false' != $response[1] ) {
368
- add_filter('pre_comment_approved', 'akismet_result_hold');
 
 
369
  wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
370
  }
371
 
@@ -402,7 +410,42 @@ function akismet_delete_old() {
402
 
403
  }
404
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
405
  add_action('akismet_scheduled_delete', 'akismet_delete_old');
 
406
 
407
  function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
408
  global $wpdb, $akismet_api_host, $akismet_api_port;
4
  */
5
  /*
6
  Plugin Name: Akismet
7
+ Plugin URI: http://akismet.com/?return=true
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/?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.4
10
  Author: Automattic
11
  Author URI: http://automattic.com/wordpress-plugins/
12
  License: GPLv2 or later
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
  */
30
 
31
+ define('AKISMET_VERSION', '2.5.4');
32
  define('AKISMET_PLUGIN_URL', plugin_dir_url( __FILE__ ));
33
 
34
  /** If you hardcode a WP.com API key here, all key config screens will be hidden */
120
  $akismet_ua = "WordPress/{$wp_version} | ";
121
  $akismet_ua .= 'Akismet/' . constant( 'AKISMET_VERSION' );
122
 
123
+ $akismet_ua = apply_filters( 'akismet_ua', $akismet_ua );
124
+
125
  $content_length = strlen( $request );
126
 
127
  $http_host = $host;
305
  $comment['blog_charset'] = get_option('blog_charset');
306
  $comment['permalink'] = get_permalink($comment['comment_post_ID']);
307
 
308
+ if ( !empty( $comment['user_ID'] ) ) {
309
+ $comment['user_role'] = akismet_get_user_roles($comment['user_ID']);
310
+ }
311
 
312
  $akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
313
  $comment['akismet_comment_nonce'] = 'inactive';
339
  $comment["$key"] = '';
340
  }
341
 
342
+ $post = get_post( $comment['comment_post_ID'] );
343
+ $comment[ 'comment_post_modified_gmt' ] = $post->post_modified_gmt;
344
+
345
  $query_string = '';
346
  foreach ( $comment as $key => $data )
347
  $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
356
 
357
  do_action( 'akismet_spam_caught' );
358
 
 
359
  $last_updated = strtotime( $post->post_modified_gmt );
360
  $diff = time() - $last_updated;
361
  $diff = $diff / 86400;
364
  // akismet_result_spam() won't be called so bump the counter here
365
  if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
366
  update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
367
+ wp_safe_redirect( $_SERVER['HTTP_REFERER'] );
368
  die();
369
  }
370
  }
371
 
372
  // if the response is neither true nor false, hold the comment for moderation and schedule a recheck
373
  if ( 'true' != $response[1] && 'false' != $response[1] ) {
374
+ if ( !wp_get_current_user() ) {
375
+ add_filter('pre_comment_approved', 'akismet_result_hold');
376
+ }
377
  wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
378
  }
379
 
410
 
411
  }
412
 
413
+ function akismet_delete_old_metadata() {
414
+ global $wpdb;
415
+
416
+ $now_gmt = current_time( 'mysql', 1 );
417
+ $interval = apply_filters( 'akismet_delete_commentmeta_interval', 15 );
418
+
419
+ # enfore a minimum of 1 day
420
+ $interval = absint( $interval );
421
+ if ( $interval < 1 ) {
422
+ return;
423
+ }
424
+
425
+ // akismet_as_submitted meta values are large, so expire them
426
+ // after $interval days regardless of the comment status
427
+ while ( TRUE ) {
428
+ $comment_ids = $wpdb->get_col( "SELECT $wpdb->comments.comment_id FROM $wpdb->commentmeta INNER JOIN $wpdb->comments USING(comment_id) WHERE meta_key = 'akismet_as_submitted' AND DATE_SUB('$now_gmt', INTERVAL {$interval} DAY) > comment_date_gmt LIMIT 10000" );
429
+
430
+ if ( empty( $comment_ids ) ) {
431
+ return;
432
+ }
433
+
434
+ foreach ( $comment_ids as $comment_id ) {
435
+ delete_comment_meta( $comment_id, 'akismet_as_submitted' );
436
+ }
437
+ }
438
+
439
+ /*
440
+ $n = mt_rand( 1, 5000 );
441
+ if ( apply_filters( 'akismet_optimize_table', ( $n == 11 ), 'commentmeta' ) ) { // lucky number
442
+ $wpdb->query( "OPTIMIZE TABLE $wpdb->commentmeta" );
443
+ }
444
+ */
445
+ }
446
+
447
  add_action('akismet_scheduled_delete', 'akismet_delete_old');
448
+ add_action('akismet_scheduled_delete', 'akismet_delete_old_metadata');
449
 
450
  function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
451
  global $wpdb, $akismet_api_host, $akismet_api_port;
index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ # Silence is golden.
legacy.php CHANGED
@@ -71,7 +71,7 @@ function akismet_caught() {
71
  ++$i;
72
  endforeach;
73
  $to = add_query_arg( 'recovered', $i, $_SERVER['HTTP_REFERER'] );
74
- wp_redirect( $to );
75
  exit;
76
  }
77
  if ('delete' == $_POST['action']) {
@@ -87,7 +87,7 @@ function akismet_caught() {
87
  wp_cache_delete( 'akismet_spam_count', 'widget' );
88
  }
89
  $to = add_query_arg( 'deleted', 'all', $_SERVER['HTTP_REFERER'] );
90
- wp_redirect( $to );
91
  exit;
92
  }
93
 
@@ -366,7 +366,7 @@ function redirect_old_akismet_urls( ) {
366
  // 2.7 redirect for people who might have bookmarked the old page
367
  if ( 8204 < $wp_db_version && ( 'edit-comments.php' == $script_name || 'edit.php' == $script_name ) && 'akismet-admin' == $page ) {
368
  $new_url = esc_url( 'edit-comments.php?comment_status=spam' );
369
- wp_redirect( $new_url, 301 );
370
  exit;
371
  }
372
  }
71
  ++$i;
72
  endforeach;
73
  $to = add_query_arg( 'recovered', $i, $_SERVER['HTTP_REFERER'] );
74
+ wp_safe_redirect( $to );
75
  exit;
76
  }
77
  if ('delete' == $_POST['action']) {
87
  wp_cache_delete( 'akismet_spam_count', 'widget' );
88
  }
89
  $to = add_query_arg( 'deleted', 'all', $_SERVER['HTTP_REFERER'] );
90
+ wp_safe_redirect( $to );
91
  exit;
92
  }
93
 
366
  // 2.7 redirect for people who might have bookmarked the old page
367
  if ( 8204 < $wp_db_version && ( 'edit-comments.php' == $script_name || 'edit.php' == $script_name ) && 'akismet-admin' == $page ) {
368
  $new_url = esc_url( 'edit-comments.php?comment_status=spam' );
369
+ wp_safe_redirect( $new_url, 301 );
370
  exit;
371
  }
372
  }
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.1
6
- Stable tag: 2.5.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.
@@ -31,6 +31,14 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
31
 
32
  == Changelog ==
33
 
 
 
 
 
 
 
 
 
34
  = 2.5.3 =
35
  * Specify the license is GPL v2 or later
36
  * Fix a bug that could result in orphaned commentmeta entries
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.3.1
6
+ Stable tag: 2.5.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.
31
 
32
  == Changelog ==
33
 
34
+ = 2.5.4 =
35
+ * Limit Akismet CSS and Javascript loading in wp-admin to just the pages that need it
36
+ * Added author URL quick removal functionality
37
+ * Added mShot preview on Author URL hover
38
+ * Added empty index.php to prevent directory listing
39
+ * Move wp-admin menu items under Jetpack, if it is installed
40
+ * Purge old Akismet comment meta data, default of 15 days
41
+
42
  = 2.5.3 =
43
  * Specify the license is GPL v2 or later
44
  * Fix a bug that could result in orphaned commentmeta entries