Advertisements

akismet_delete_old

Definition:
function akismet_delete_old() {}

Defined filters

  • akismet_optimize_table
    apply_filters('akismet_optimize_table', ($n == 11)

Defined actions

  • delete_comment
    do_action( 'delete_comment', $comment_ids );

Source code

function akismet_delete_old() {

	global $wpdb;

	$now_gmt = current_time('mysql', 1);

	$comment_ids = $wpdb->get_col("SELECT comment_id FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'");

	if ( empty( $comment_ids ) )

		return;

		

	$comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) );



	do_action( 'delete_comment', $comment_ids );

	$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( $comma_comment_ids )");

	$wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id IN ( $comma_comment_ids )");

	clean_comment_cache( $comment_ids );

	$n = mt_rand(1, 5000);

	if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number

		$wpdb->query("OPTIMIZE TABLE $wpdb->comments");



}

447

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: