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
251           // if the response is neither true nor false, hold the comment for moderation and schedule a recheck
252           if ( 'true' != $response[1] && 'false' != $response[1] ) {
253                if ( !current_user_can('moderate_comments') ) {
254                     // Comment status should be moderated
255                     self::$last_comment_result = '0';
256                }
257
258                if ( ! wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
259                     wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
260                     do_action( 'akismet_scheduled_recheck', 'invalid-response-' . $response[1] );
261                }
262
263                self::$prevent_moderation_email_for_these_comments[] = $commentdata;
264           }
265
266           // Delete old comments daily
267           if ( ! wp_next_scheduled( 'akismet_scheduled_delete' ) ) {
268                wp_schedule_event( time(), 'daily', 'akismet_scheduled_delete' );
269           }
 
Line Code
809      public static function cron_recheck() {
810           global $wpdb;
811
812           $api_key = self::get_api_key();
813
814           $status = self::verify_key( $api_key );
815           if ( get_option( 'akismet_alert_code' ) || $status == 'invalid' ) {
816                // since there is currently a problem with the key, reschedule a check for 6 hours hence
817                wp_schedule_single_event( time() + 21600, 'akismet_schedule_cron_recheck' );
818                do_action( 'akismet_scheduled_recheck', 'key-problem-' . get_option( 'akismet_alert_code' ) . '-' . $status );
819                return false;
820           }
821
822           delete_option('akismet_available_servers');
823
824           $comment_errors = $wpdb->get_col( "SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'     LIMIT 100" );
825           
826           load_plugin_textdomain( 'akismet' );
827
 
Line Code
876                     // If this comment has been pending moderation for longer than MAX_DELAY_BEFORE_MODERATION_EMAIL,
877                     // send a moderation email now.
878                     if ( ( intval( gmdate( 'U' ) ) - strtotime( $comment->comment_date_gmt ) ) < self::MAX_DELAY_BEFORE_MODERATION_EMAIL ) {
879                          delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
880                          wp_notify_moderator( $comment_id );
881                     }
882
883                     delete_comment_meta( $comment_id, 'akismet_rechecking' );
884                     wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
885                     do_action( 'akismet_scheduled_recheck', 'check-db-comment-' . $status );
886                     return;
887                }
888                delete_comment_meta( $comment_id, 'akismet_rechecking' );
889           }
890
891           $remaining = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'" );
892           if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) {
893                wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
894                do_action( 'akismet_scheduled_recheck', 'remaining' );
895           }
896      }
897
898      public static function fix_scheduled_recheck() {
899           $future_check = wp_next_scheduled( 'akismet_schedule_cron_recheck' );
900           if ( !$future_check ) {
901                return;
902           }
903
904           if ( get_option( 'akismet_alert_code' ) > 0 ) {
905                return;
906           }
907
908           $check_range = time() + 1200;
909           if ( $future_check > $check_range ) {
910                wp_clear_scheduled_hook( 'akismet_schedule_cron_recheck' );
911                wp_schedule_single_event( time() + 300, 'akismet_schedule_cron_recheck' );
912                do_action( 'akismet_scheduled_recheck', 'fix-scheduled-recheck' );
913           }
914      }
915
916      public static function add_comment_nonce( $post_id ) {
917           /**
918            * To disable the Akismet comment nonce, add a filter for the 'akismet_comment_nonce' tag
919            * and return any string value that is not 'true' or '' (empty string).
920            *
921            * Don't return boolean false, because that implies that the 'akismet_comment_nonce' option