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
374           // if the response is neither true nor false, hold the comment for moderation and schedule a recheck
375           if ( 'true' != $response[1] && 'false' != $response[1] ) {
376                if ( !current_user_can('moderate_comments') ) {
377                     // Comment status should be moderated
378                     self::$last_comment_result = '0';
379                }
380
381                if ( ! wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
382                     wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
383                     do_action( 'akismet_scheduled_recheck', 'invalid-response-' . $response[1] );
384                }
385
386                self::$prevent_moderation_email_for_these_comments[] = $commentdata;
387           }
388
389           // Delete old comments daily
390           if ( ! wp_next_scheduled( 'akismet_scheduled_delete' ) ) {
391                wp_schedule_event( time(), 'daily', 'akismet_scheduled_delete' );
392           }
 
Line Code
1009      public static function cron_recheck() {
1010           global $wpdb;
1011
1012           $api_key = self::get_api_key();
1013
1014           $status = self::verify_key( $api_key );
1015           if ( get_option( 'akismet_alert_code' ) || $status == 'invalid' ) {
1016                // since there is currently a problem with the key, reschedule a check for 6 hours hence
1017                wp_schedule_single_event( time() + 21600, 'akismet_schedule_cron_recheck' );
1018                do_action( 'akismet_scheduled_recheck', 'key-problem-' . get_option( 'akismet_alert_code' ) . '-' . $status );
1019                return false;
1020           }
1021
1022           delete_option('akismet_available_servers');
1023
1024           $comment_errors = $wpdb->get_col( "SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'     LIMIT 100" );
1025           
1026           load_plugin_textdomain( 'akismet' );
1027
 
Line Code
1076                     // If this comment has been pending moderation for longer than MAX_DELAY_BEFORE_MODERATION_EMAIL,
1077                     // send a moderation email now.
1078                     if ( ( intval( gmdate( 'U' ) ) - strtotime( $comment->comment_date_gmt ) ) < self::MAX_DELAY_BEFORE_MODERATION_EMAIL ) {
1079                          delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
1080                          wp_notify_moderator( $comment_id );
1081                     }
1082
1083                     delete_comment_meta( $comment_id, 'akismet_rechecking' );
1084                     wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
1085                     do_action( 'akismet_scheduled_recheck', 'check-db-comment-' . $status );
1086                     return;
1087                }
1088                delete_comment_meta( $comment_id, 'akismet_rechecking' );
1089           }
1090
1091           $remaining = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'" );
1092           if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) {
1093                wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
1094                do_action( 'akismet_scheduled_recheck', 'remaining' );
1095           }
1096      }
1097
1098      public static function fix_scheduled_recheck() {
1099           $future_check = wp_next_scheduled( 'akismet_schedule_cron_recheck' );
1100           if ( !$future_check ) {
1101                return;
1102           }
1103
1104           if ( get_option( 'akismet_alert_code' ) > 0 ) {
1105                return;
1106           }
1107
1108           $check_range = time() + 1200;
1109           if ( $future_check > $check_range ) {
1110                wp_clear_scheduled_hook( 'akismet_schedule_cron_recheck' );
1111                wp_schedule_single_event( time() + 300, 'akismet_schedule_cron_recheck' );
1112                do_action( 'akismet_scheduled_recheck', 'fix-scheduled-recheck' );
1113           }
1114      }
1115
1116      public static function add_comment_nonce( $post_id ) {
1117           /**
1118            * To disable the Akismet comment nonce, add a filter for the 'akismet_comment_nonce' tag
1119            * and return any string value that is not 'true' or '' (empty string).
1120            *
1121            * Don't return boolean false, because that implies that the 'akismet_comment_nonce' option