Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: akismet_scheduled_recheck

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 5 times in this file.

Line Code
492                if ( ! current_user_can( 'moderate_comments' ) ) {
493                     // Comment status should be moderated
494                     self::$last_comment_result = '0';
495                }
496
497                $commentdata['comment_meta']['akismet_delay_moderation_email'] = true;
498
499                if ( ! wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
500                     wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
501                     do_action( 'akismet_scheduled_recheck', 'invalid-response-' . $response[1] );
502                }
503           }
504
505           // Delete old comments daily
506           if ( ! wp_next_scheduled( 'akismet_scheduled_delete' ) ) {
507                wp_schedule_event( time(), 'daily', 'akismet_scheduled_delete' );
508           }
509
510           self::set_last_comment( $commentdata );
 
Line Code
1274      public static function cron_recheck() {
1275           global $wpdb;
1276
1277           $api_key = self::get_api_key();
1278
1279           $status = self::verify_key( $api_key );
1280           if ( get_option( 'akismet_alert_code' ) || $status == 'invalid' ) {
1281                // since there is currently a problem with the key, reschedule a check for 6 hours hence
1282                wp_schedule_single_event( time() + 21600, 'akismet_schedule_cron_recheck' );
1283                do_action( 'akismet_scheduled_recheck', 'key-problem-' . get_option( 'akismet_alert_code' ) . '-' . $status );
1284                return false;
1285           }
1286
1287           delete_option( 'akismet_available_servers' );
1288
1289           $comment_errors = $wpdb->get_col( "SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'     LIMIT 100" );
1290
1291           foreach ( (array) $comment_errors as $comment_id ) {
1292                // if the comment no longer exists, or is too old, remove the meta entry from the queue to avoid getting stuck
 
Line Code
1348                          delete_comment_meta( $comment_id, 'akismet_delay_moderation_email' );
1349                          delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
1350
1351                          wp_new_comment_notify_moderator( $comment_id );
1352                          wp_new_comment_notify_postauthor( $comment_id );
1353                     }
1354
1355                     delete_comment_meta( $comment_id, 'akismet_rechecking' );
1356                     wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
1357                     do_action( 'akismet_scheduled_recheck', 'check-db-comment-' . $status );
1358
1359                     return;
1360                }
1361
1362                delete_comment_meta( $comment_id, 'akismet_rechecking' );
1363           }
1364
1365           $remaining = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'" );
1366
1367           if ( $remaining && ! wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
1368                wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
1369                do_action( 'akismet_scheduled_recheck', 'remaining' );
1370           }
1371      }
1372
1373      public static function fix_scheduled_recheck() {
1374           $future_check = wp_next_scheduled( 'akismet_schedule_cron_recheck' );
1375           if ( ! $future_check ) {
1376                return;
1377           }
1378
1379           if ( get_option( 'akismet_alert_code' ) > 0 ) {
1380                return;
1381           }
1382
1383           $check_range = time() + 1200;
1384           if ( $future_check > $check_range ) {
1385                wp_clear_scheduled_hook( 'akismet_schedule_cron_recheck' );
1386                wp_schedule_single_event( time() + 300, 'akismet_schedule_cron_recheck' );
1387                do_action( 'akismet_scheduled_recheck', 'fix-scheduled-recheck' );
1388           }
1389      }
1390
1391      public static function add_comment_nonce( $post_id ) {
1392           /**
1393            * To disable the Akismet comment nonce, add a filter for the 'akismet_comment_nonce' tag
1394            * and return any string value that is not 'true' or '' (empty string).
1395            *
1396            * Don't return boolean false, because that implies that the 'akismet_comment_nonce' option