2 add_action( 'admin_menu', 'akismet_config_page' );
3 add_action( 'admin_menu', 'akismet_stats_page' );
4 akismet_admin_warnings();
6 function akismet_admin_init() {
9 // all admin functions are disabled in old versions
10 if ( version_compare( $wp_version, '3.0', '<' ) ) {
12 function akismet_version_warning() {
14 <div id='akismet-warning' class='updated fade'><p><strong>".sprintf(__('Akismet %s required WordPress 3.0 or higher.'), AKISMET_VERSION) ."</strong> ".sprintf(__('Please <a href="%s">upgrade WordPress</a> to a current version, or <a href="%s">downgrade to version 2.4 of the Akismet plugin</a>.'), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/akismet/download/'). "</p></div>
17 add_action('admin_notices', 'akismet_version_warning');
22 if ( function_exists( 'get_plugin_page_hook' ) )
23 $hook = get_plugin_page_hook( 'akismet-stats-display', 'index.php' );
25 $hook = 'dashboard_page_akismet-stats-display';
26 add_action('admin_head-'.$hook, 'akismet_stats_script');
27 add_meta_box('akismet-status', __('Akismet Status'), 'akismet_comment_status_meta_box', 'comment', 'normal');
29 add_action('admin_init', 'akismet_admin_init');
31 function akismet_nonce_field($action = -1) { return wp_nonce_field($action); }
32 $akismet_nonce = 'akismet-update-key';
34 function akismet_config_page() {
35 if ( function_exists('add_submenu_page') )
36 add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf');
40 function akismet_conf() {
41 global $akismet_nonce, $wpcom_api_key;
43 if ( isset($_POST['submit']) ) {
44 if ( function_exists('current_user_can') && !current_user_can('manage_options') )
45 die(__('Cheatin’ uh?'));
47 check_admin_referer( $akismet_nonce );
48 $key = preg_replace( '/[^a-h0-9]/i', '', $_POST['key'] );
51 $key_status = 'empty';
52 $ms[] = 'new_key_empty';
53 delete_option('wordpress_api_key');
55 $key_status = akismet_verify_key( $key );
58 if ( $key_status == 'valid' ) {
59 update_option('wordpress_api_key', $key);
60 $ms[] = 'new_key_valid';
61 } else if ( $key_status == 'invalid' ) {
62 $ms[] = 'new_key_invalid';
63 } else if ( $key_status == 'failed' ) {
64 $ms[] = 'new_key_failed';
67 if ( isset( $_POST['akismet_discard_month'] ) )
68 update_option( 'akismet_discard_month', 'true' );
70 update_option( 'akismet_discard_month', 'false' );
71 } elseif ( isset($_POST['check']) ) {
72 akismet_get_server_connectivity(0);
75 if ( empty( $key_status) || $key_status != 'valid' ) {
76 $key = get_option('wordpress_api_key');
77 if ( empty( $key ) ) {
78 if ( empty( $key_status ) || $key_status != 'failed' ) {
79 if ( akismet_verify_key( '1234567890ab' ) == 'failed' )
80 $ms[] = 'no_connection';
84 $key_status = 'empty';
86 $key_status = akismet_verify_key( $key );
88 if ( $key_status == 'valid' ) {
90 } else if ( $key_status == 'invalid' ) {
91 delete_option('wordpress_api_key');
93 } else if ( !empty($key) && $key_status == 'failed' ) {
99 'new_key_empty' => array('color' => 'aa0', 'text' => __('Your key has been cleared.')),
100 'new_key_valid' => array('color' => '2d2', 'text' => __('Your key has been verified. Happy blogging!')),
101 'new_key_invalid' => array('color' => 'd22', 'text' => __('The key you entered is invalid. Please double-check it.')),
102 'new_key_failed' => array('color' => 'd22', 'text' => __('The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.')),
103 'no_connection' => array('color' => 'd22', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')),
104 '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/')),
105 'key_valid' => array('color' => '2d2', 'text' => __('This key is valid.')),
106 '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.')));
108 <?php if ( !empty($_POST['submit'] ) ) : ?>
109 <div id="message" class="updated fade"><p><strong><?php _e('Options saved.') ?></strong></p></div>
112 <h2><?php _e('Akismet Configuration'); ?></h2>
114 <form action="" method="post" id="akismet-conf" style="margin: auto; width: 400px; ">
115 <?php if ( !$wpcom_api_key ) { ?>
116 <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>
118 <h3><label for="key"><?php _e('Akismet API Key'); ?></label></h3>
119 <?php foreach ( $ms as $m ) : ?>
120 <p style="padding: .5em; background-color: #<?php echo $messages[$m]['color']; ?>; color: #fff; font-weight: bold;"><?php echo $messages[$m]['text']; ?></p>
122 <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>
123 <?php if ( isset( $invalid_key) && $invalid_key ) { ?>
124 <h3><?php _e('Why might my key be invalid?'); ?></h3>
125 <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>
128 <?php akismet_nonce_field($akismet_nonce) ?>
129 <p><label><input name="akismet_discard_month" id="akismet_discard_month" value="true" type="checkbox" <?php if ( get_option('akismet_discard_month') == 'true' ) echo ' checked="checked" '; ?> /> <?php _e('Automatically discard spam comments on posts older than a month.'); ?></label></p>
130 <p class="submit"><input type="submit" name="submit" value="<?php _e('Update options »'); ?>" /></p>
133 <form action="" method="post" id="akismet-connectivity" style="margin: auto; width: 400px; ">
135 <h3><?php _e('Server Connectivity'); ?></h3>
137 if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') ) {
139 <p style="padding: .5em; background-color: #d22; color: #fff; font-weight:bold;"><?php _e('Network functions are disabled.'); ?></p>
140 <p><?php echo sprintf( __('Your web host or server administrator has disabled PHP\'s <code>fsockopen</code> or <code>gethostbynamel</code> functions. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet\'s system requirements</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
143 $servers = akismet_get_server_connectivity();
144 $fail_count = count($servers) - count( array_filter($servers) );
145 if ( is_array($servers) && count($servers) > 0 ) {
146 // some connections work, some fail
147 if ( $fail_count > 0 && $fail_count < count($servers) ) { ?>
148 <p style="padding: .5em; background-color: #aa0; color: #fff; font-weight:bold;"><?php _e('Unable to reach some Akismet servers.'); ?></p>
149 <p><?php echo sprintf( __('A network problem or firewall is blocking some connections from your web server to Akismet.com. Akismet is working but this may cause problems during times of network congestion. Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
151 // all connections fail
152 } elseif ( $fail_count > 0 ) { ?>
153 <p style="padding: .5em; background-color: #d22; color: #fff; font-weight:bold;"><?php _e('Unable to reach any Akismet servers.'); ?></p>
154 <p><?php echo sprintf( __('A network problem or firewall is blocking all connections from your web server to Akismet.com. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
156 // all connections work
158 <p style="padding: .5em; background-color: #2d2; color: #fff; font-weight:bold;"><?php _e('All Akismet servers are available.'); ?></p>
159 <p><?php _e('Akismet is working correctly. All servers are accessible.'); ?></p>
164 <p style="padding: .5em; background-color: #d22; color: #fff; font-weight:bold;"><?php _e('Unable to find Akismet servers.'); ?></p>
165 <p><?php echo sprintf( __('A DNS problem or firewall is preventing all access from your web server to Akismet.com. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
170 if ( !empty($servers) ) {
172 <table style="width: 100%;">
173 <thead><th><?php _e('Akismet server'); ?></th><th><?php _e('Network Status'); ?></th></thead>
177 foreach ( $servers as $ip => $status ) {
178 $color = ( $status ? '#2d2' : '#d22');
181 <td><?php echo htmlspecialchars($ip); ?></td>
182 <td style="padding: 0 .5em; font-weight:bold; color: #fff; background-color: <?php echo $color; ?>"><?php echo ($status ? __('No problems') : __('Obstructed') ); ?></td>
190 <p><?php if ( get_option('akismet_connectivity_time') ) echo sprintf( __('Last checked %s ago.'), human_time_diff( get_option('akismet_connectivity_time') ) ); ?></p>
191 <p class="submit"><input type="submit" name="check" value="<?php _e('Check network status »'); ?>" /></p>
199 function akismet_stats_page() {
200 if ( function_exists('add_submenu_page') )
201 add_submenu_page('index.php', __('Akismet Stats'), __('Akismet Stats'), 'manage_options', 'akismet-stats-display', 'akismet_stats_display');
205 function akismet_stats_script() {
207 <script type="text/javascript">
208 function resizeIframe() {
209 var height = document.documentElement.clientHeight;
210 height -= document.getElementById('akismet-stats-frame').offsetTop;
211 height += 100; // magic padding
213 document.getElementById('akismet-stats-frame').style.height = height +"px";
216 function resizeIframeInit() {
217 document.getElementById('akismet-stats-frame').onload = resizeIframe;
218 window.onresize = resizeIframe;
220 addLoadEvent(resizeIframeInit);
225 function akismet_stats_display() {
226 global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
227 $blog = urlencode( get_option('home') );
233 $url .= 'akismet.com/web/1.0/user-stats.php';
234 $url .= "?blog={$blog}&api_key=" . akismet_get_key();
237 <iframe src="<?php echo $url; ?>" width="100%" height="100%" frameborder="0" id="akismet-stats-frame"></iframe>
242 function akismet_stats() {
243 if ( !function_exists('did_action') || did_action( 'rightnow_end' ) ) // We already displayed this info in the "Right Now" section
245 if ( !$count = get_option('akismet_spam_count') )
247 $path = plugin_basename(__FILE__);
248 echo '<h3>'.__('Spam').'</h3>';
250 if ( isset( $submenu['edit-comments.php'] ) )
251 $link = 'edit-comments.php';
254 echo '<p>'.sprintf(__('<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.'), 'http://akismet.com/', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'</p>';
256 add_action('activity_box_end', 'akismet_stats');
258 function akismet_admin_warnings() {
259 global $wpcom_api_key;
260 if ( !get_option('wordpress_api_key') && !$wpcom_api_key && !isset($_POST['submit']) ) {
261 function akismet_warning() {
263 <div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet is almost ready.')."</strong> ".sprintf(__('You must <a href="%1$s">enter your Akismet API key</a> for it to work.'), "plugins.php?page=akismet-key-config")."</p></div>
266 add_action('admin_notices', 'akismet_warning');
268 } elseif ( get_option('akismet_connectivity_time') && empty($_POST) && is_admin() && !akismet_server_connectivity_ok() ) {
269 function akismet_warning() {
271 <div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet has detected a problem.')."</strong> ".sprintf(__('A server or network problem is preventing Akismet from working correctly. <a href="%1$s">Click here for more information</a> about how to fix the problem.'), "plugins.php?page=akismet-key-config")."</p></div>
274 add_action('admin_notices', 'akismet_warning');
281 function akismet_comment_row_action( $a, $comment ) {
284 $akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );
285 $user_result = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);
287 if ( !$user_result || $user_result == $akismet_result ) {
288 // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
289 if ( $akismet_result == 'true' )
290 $desc = 'Flagged as spam by Akismet';
291 elseif ( $akismet_result == 'false' )
292 $desc = 'Cleared by Akismet';
294 $who = get_comment_meta( $comment->comment_ID, 'akismet_user', true );
295 if ( $user_result == 'true' )
296 $desc = sprintf( __('Flagged as spam by %s'), $who );
298 $desc = sprintf( __('Un-spammed by %s'), $who );
302 echo '<span style="background: #EEE; border: 1px solid #E4E4E4; margin-top: 3px; color: #999; padding: 1px 8px 2px 8px; -moz-border-radius:6px; border-radius:6px; -webkit-border-radius:6px; float: right; line-height: 1.2em;"><a href="comment.php?action=editcomment&c='.$comment->comment_ID.'#akismet-status" title="' . esc_attr__( 'View comment history' ) . '">'.htmlspecialchars($desc).'</a></span>';
307 add_filter( 'comment_row_actions', 'akismet_comment_row_action', 10, 2 );
310 function akismet_comment_status_meta_box($comment) {
311 $history = akismet_get_comment_history( $comment->comment_ID );
314 echo '<div class="akismet-history" style="margin: 13px;">';
315 foreach ( $history as $row ) {
316 $time = date( 'D d M Y @ h:i:m a', $row['time'] ) . ' GMT';
317 echo '<div style="margin-bottom: 13px;"><span style="color: #999;" alt="' . $time . '" title="' . $time . '">' . sprintf( __('%s ago'), human_time_diff( $row['time'] ) ) . '</span> - ';
318 echo htmlspecialchars( $row['message'] ) . '</div>';
327 // add an extra column header to the comments screen
328 function akismet_comments_columns( $columns ) {
329 $columns[ 'akismet' ] = __( 'Akismet' );
333 #add_filter( 'manage_edit-comments_columns', 'akismet_comments_columns' );
335 // Show stuff in the extra column
336 function akismet_comment_column_row( $column, $comment_id ) {
337 if ( $column != 'akismet' )
340 $history = akismet_get_comment_history( $comment_id );
343 echo '<dl class="akismet-history">';
344 foreach ( $history as $row ) {
345 echo '<dt>' . sprintf( __('%s ago'), human_time_diff( $row['time'] ) ) . '</dt>';
346 echo '<dd>' . htmlspecialchars( $row['message'] ) . '</dd>';
353 #add_action( 'manage_comments_custom_column', 'akismet_comment_column_row', 10, 2 );
358 function akismet_rightnow() {
359 global $submenu, $wp_db_version;
361 $plural_func = '__ngettext';
362 if ( function_exists( '_n' ) )
365 // clean_url was deprecated in WP 3.0
366 $esc_url = 'clean_url';
367 if ( function_exists( 'esc_url' ) )
368 $esc_url = 'esc_url';
370 if ( 8645 < $wp_db_version ) // 2.7
371 $link = 'edit-comments.php?comment_status=spam';
372 elseif ( isset( $submenu['edit-comments.php'] ) )
373 $link = 'edit-comments.php?page=akismet-admin';
375 $link = 'edit.php?page=akismet-admin';
377 if ( $count = get_option('akismet_spam_count') ) {
378 $intro = sprintf( $plural_func(
379 '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already,',
380 '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already,',
382 ), 'http://akismet.com/', number_format_i18n( $count ) );
384 $intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog,'), 'http://akismet.com/' );
387 if ( $queue_count = akismet_spam_count() ) {
388 $queue_text = sprintf( $plural_func(
389 'and there\'s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
390 'and there are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
392 ), number_format_i18n( $queue_count ), $esc_url($link) );
394 $queue_text = sprintf( __( " but there's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), $esc_url($link) );
397 // _c was deprecated in WP 2.9.0
398 if ( function_exists( '_x' ) )
399 $text = sprintf( _x( '%1$s%2$s', 'akismet_rightnow' ), $intro, $queue_text );
401 $text = sprintf( _c( '%1$s%2$s|akismet_rightnow' ), $intro, $queue_text );
403 echo "<p class='akismet-right-now'>$text</p>\n";
406 add_action('rightnow_end', 'akismet_rightnow');
410 function akismet_check_for_spam_button($comment_status) {
411 if ( 'approved' == $comment_status )
413 if ( function_exists('plugins_url') )
414 $link = 'admin.php?action=akismet_recheck_queue';
416 $link = 'edit-comments.php?page=akismet-admin&recheckqueue=true&noheader=true';
417 echo "</div><div class='alignleft'><a class='button-secondary checkforspam' href='$link'>" . __('Check for Spam') . "</a>";
419 add_action('manage_comments_nav', 'akismet_check_for_spam_button');
421 function akismet_submit_nonspam_comment ( $comment_id ) {
422 global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
423 $comment_id = (int) $comment_id;
425 $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
426 if ( !$comment ) // it was deleted
428 $comment->blog = get_option('home');
429 $comment->blog_lang = get_locale();
430 $comment->blog_charset = get_option('blog_charset');
431 $comment->permalink = get_permalink($comment->comment_post_ID);
432 if ( is_object($current_user) ) {
433 $comment->reporter = $current_user->user_login;
435 if ( is_object($current_site) ) {
436 $comment->site_domain = $current_site->domain;
439 $comment->user_role = '';
440 if ( isset( $comment->user_ID ) )
441 $comment->user_role = akismet_get_user_roles($comment->user_ID);
444 foreach ( $comment as $key => $data )
445 $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
447 $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-ham", $akismet_api_port);
448 if ( $comment->reporter ) {
449 akismet_update_comment_history( $comment_id, sprintf( __('%s un-spammed this comment'), $comment->reporter ), 'report-ham' );
450 update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
451 update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
453 akismet_update_comment_history( $comment_id, 'A plugin un-spammed this comment', 'report-ham' );
456 do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
459 function akismet_submit_spam_comment ( $comment_id ) {
460 global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
461 $comment_id = (int) $comment_id;
463 $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
464 if ( !$comment ) // it was deleted
466 if ( 'spam' != $comment->comment_approved )
468 $comment->blog = get_option('home');
469 $comment->blog_lang = get_locale();
470 $comment->blog_charset = get_option('blog_charset');
471 $comment->permalink = get_permalink($comment->comment_post_ID);
472 if ( is_object($current_user) ) {
473 $comment->reporter = $current_user->user_login;
475 if ( is_object($current_site) ) {
476 $comment->site_domain = $current_site->domain;
479 $comment->user_role = '';
480 if ( !isset( $comment->user_id ) )
481 $comment->user_role = akismet_get_user_roles($comment->user_ID);
484 foreach ( $comment as $key => $data )
485 $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
487 $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-spam", $akismet_api_port);
488 if ( $comment->reporter ) {
489 akismet_update_comment_history( $comment_id, sprintf( __('%s spammed this comment'), $comment->reporter ), 'report-spam' );
490 update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
491 update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
493 akismet_update_comment_history( $comment_id, 'A plugin spammed this comment', 'report-ham' );
494 do_action('akismet_submit_spam_comment', $comment_id, $response[1]);
498 function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
499 if ( $new_status == $old_status )
502 if ( $new_status == 'spam' ) {
503 akismet_submit_spam_comment( $comment->comment_ID );
504 } elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {
505 akismet_submit_nonspam_comment( $comment->comment_ID );
509 add_action( 'transition_comment_status', 'akismet_transition_comment_status', 10, 3 );
511 // Total spam in queue
512 // get_option( 'akismet_spam_count' ) is the total caught ever
513 function akismet_spam_count( $type = false ) {
516 if ( !$type ) { // total
517 $count = wp_cache_get( 'akismet_spam_count', 'widget' );
518 if ( false === $count ) {
519 if ( function_exists('wp_count_comments') ) {
520 $count = wp_count_comments();
521 $count = $count->spam;
523 $count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'");
525 wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 );
528 } elseif ( 'comments' == $type || 'comment' == $type ) { // comments
530 } else { // pingback, trackback, ...
531 $type = $wpdb->escape( $type );
534 return (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type'");
538 function akismet_recheck_queue() {
539 global $wpdb, $akismet_api_host, $akismet_api_port;
541 if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) )
544 $moderation = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'", ARRAY_A );
545 foreach ( (array) $moderation as $c ) {
546 $c['user_ip'] = $c['comment_author_IP'];
547 $c['user_agent'] = $c['comment_agent'];
549 $c['blog'] = get_option('home');
550 $c['blog_lang'] = get_locale();
551 $c['blog_charset'] = get_option('blog_charset');
552 $c['permalink'] = get_permalink($c['comment_post_ID']);
554 $c['user_role'] = '';
555 if ( isset( $c['user_ID'] ) )
556 $c['user_role'] = akismet_get_user_roles($c['user_ID']);
558 $id = (int) $c['comment_ID'];
561 foreach ( $c as $key => $data )
562 $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
564 $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
565 if ( 'true' == $response[1] ) {
566 wp_set_comment_status($c['comment_ID'], 'spam');
567 update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' );
568 akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam' );
570 } elseif ( 'false' == $response[1] ) {
571 update_comment_meta( $c['comment_ID'], 'akismet_result', 'false' );
572 akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and cleared this comment'), 'check-ham' );
573 // abnormal result: error
575 update_comment_meta( $c['comment_ID'], 'akismet_result', 'error' );
576 akismet_update_comment_history( $c['comment_ID'], sprintf( __('Akismet was unable to re-check this comment (response: %s)'), $response[1]), 'check-error' );
580 wp_redirect( $_SERVER['HTTP_REFERER'] );
584 add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue');