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
208           // if the response is neither true nor false, hold the comment for moderation and schedule a recheck
209           if ( 'true' != $response[1] && 'false' != $response[1] ) {
210                if ( !current_user_can('moderate_comments') ) {
211                     // Comment status should be moderated
212                     self::$last_comment_result = '0';
213                }
214                if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_single_event') ) {
215                     if ( !wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
216                          wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
217                          do_action( 'akismet_scheduled_recheck', 'invalid-response-' . $response[1] );
218                     }
219                }
220
221                self::$prevent_moderation_email_for_these_comments[] = $commentdata;
222           }
223
224           if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) {
225                // WP 2.1+: delete old comments daily
226                if ( !wp_next_scheduled( 'akismet_scheduled_delete' ) )
 
Line Code
618      public static function cron_recheck() {
619           global $wpdb;
620
621           $api_key = self::get_api_key();
622
623           $status = self::verify_key( $api_key );
624           if ( get_option( 'akismet_alert_code' ) || $status == 'invalid' ) {
625                // since there is currently a problem with the key, reschedule a check for 6 hours hence
626                wp_schedule_single_event( time() + 21600, 'akismet_schedule_cron_recheck' );
627                do_action( 'akismet_scheduled_recheck', 'key-problem-' . get_option( 'akismet_alert_code' ) . '-' . $status );
628                return false;
629           }
630
631           delete_option('akismet_available_servers');
632
633           $comment_errors = $wpdb->get_col( "SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'     LIMIT 100" );
634           
635           load_plugin_textdomain( 'akismet' );
636
 
Line Code
680                     // If this comment has been pending moderation for longer than MAX_DELAY_BEFORE_MODERATION_EMAIL,
681                     // send a moderation email now.
682                     if ( ( intval( gmdate( 'U' ) ) - strtotime( $comment->comment_date_gmt ) ) < self::MAX_DELAY_BEFORE_MODERATION_EMAIL ) {
683                          delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
684                          wp_notify_moderator( $comment_id );
685                     }
686
687                     delete_comment_meta( $comment_id, 'akismet_rechecking' );
688                     wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
689                     do_action( 'akismet_scheduled_recheck', 'check-db-comment-' . $status );
690                     return;
691                }
692                delete_comment_meta( $comment_id, 'akismet_rechecking' );
693           }
694
695           $remaining = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'" );
696           if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) {
697                wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
698                do_action( 'akismet_scheduled_recheck', 'remaining' );
699           }
700      }
701
702      public static function fix_scheduled_recheck() {
703           $future_check = wp_next_scheduled( 'akismet_schedule_cron_recheck' );
704           if ( !$future_check ) {
705                return;
706           }
707
708           if ( get_option( 'akismet_alert_code' ) > 0 ) {
709                return;
710           }
711
712           $check_range = time() + 1200;
713           if ( $future_check > $check_range ) {
714                wp_clear_scheduled_hook( 'akismet_schedule_cron_recheck' );
715                wp_schedule_single_event( time() + 300, 'akismet_schedule_cron_recheck' );
716                do_action( 'akismet_scheduled_recheck', 'fix-scheduled-recheck' );
717           }
718      }
719
720      public static function add_comment_nonce( $post_id ) {
721           echo '<p style="display: none;">';
722           wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE );
723           echo '</p>';
724      }
725