X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/699231ae09f7057a4d0000cdf32e50a3df6a04ca..58f607a1de715c9bca69340a4d6fb9e1b9c2bed2:/wp-content/plugins/akismet/akismet.php diff --git a/wp-content/plugins/akismet/akismet.php b/wp-content/plugins/akismet/akismet.php index c70d9267..89c061f5 100644 --- a/wp-content/plugins/akismet/akismet.php +++ b/wp-content/plugins/akismet/akismet.php @@ -472,7 +472,15 @@ function akismet_auto_check_comment( $comment ) { die; } } - akismet_delete_old(); + + if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) { + // WP 2.1+: delete old comments daily + if ( !wp_next_scheduled('akismet_scheduled_delete') ) + wp_schedule_event(time(), 'daily', 'akismet_scheduled_delete'); + } elseif ( (mt_rand(1, 10) == 3) ) { + // WP 2.0: run this one time in ten + akismet_delete_old(); + } return $comment; } @@ -481,10 +489,12 @@ function akismet_delete_old() { $now_gmt = current_time('mysql', 1); $wpdb->query("DELETE FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'"); $n = mt_rand(1, 5000); - if ( $n == 11 ) // lucky number + if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number $wpdb->query("OPTIMIZE TABLE $wpdb->comments"); } +add_action('akismet_scheduled_delete', 'akismet_delete_old'); + function akismet_submit_nonspam_comment ( $comment_id ) { global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site; $comment_id = (int) $comment_id;