akismet_recheck_queue

Definition:
function akismet_recheck_queue() {}

Source code

function akismet_recheck_queue() {

	global $wpdb, $akismet_api_host, $akismet_api_port;



	if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) )

		return;

		

	$moderation = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'", ARRAY_A );

	foreach ( (array) $moderation as $c ) {

		$c['user_ip']    = $c['comment_author_IP'];

		$c['user_agent'] = $c['comment_agent'];

		$c['referrer']   = '';

		$c['blog']       = get_bloginfo('url');

		$c['blog_lang']  = get_locale();

		$c['blog_charset'] = get_option('blog_charset');

		$c['permalink']  = get_permalink($c['comment_post_ID']);



		$c['user_role'] = '';

		if ( isset( $c['user_ID'] ) )

			$c['user_role']  = akismet_get_user_roles($c['user_ID']);



		if ( akismet_test_mode() )

			$c['is_test'] = 'true';



		$id = (int) $c['comment_ID'];



		$query_string = '';

		foreach ( $c as $key => $data )

		$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';



		$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);

		if ( 'true' == $response[1] ) {

			wp_set_comment_status($c['comment_ID'], 'spam');

			update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' );

			akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam' );

		

		} elseif ( 'false' == $response[1] ) {

			update_comment_meta( $c['comment_ID'], 'akismet_result', 'false' );

			akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and cleared this comment'), 'check-ham' );

		// abnormal result: error

		} else {

			update_comment_meta( $c['comment_ID'], 'akismet_result', 'error' );

			akismet_update_comment_history( $c['comment_ID'], sprintf( __('Akismet was unable to re-check this comment (response: %s)'), $response[1]), 'check-error' );

		}



	}

	wp_redirect( $_SERVER['HTTP_REFERER'] );

	exit;

}

473

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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: