akismet_verify_key

Definition:
function akismet_verify_key( $key, $ip = null ) {}

Parameters

  • $key
  • $ip

Source code

function akismet_verify_key( $key, $ip = null ) {

	global $akismet_api_host, $akismet_api_port, $wpcom_api_key;

	$blog = urlencode( get_option('home') );

	if ( $wpcom_api_key )

		$key = $wpcom_api_key;

	$response = akismet_http_post("key=$key&blog=$blog", 'rest.akismet.com', '/1.1/verify-key', $akismet_api_port, $ip);

	if ( !is_array($response) || !isset($response[1]) || $response[1] != 'valid' && $response[1] != 'invalid' )

		return 'failed';

	return $response[1];

}

523

akismet_transition_comment_status

Definition:
function akismet_transition_comment_status( $new_status, $old_status, $comment ) {}

Parameters

  • $new_status
  • $old_status
  • $comment

Source code

function akismet_transition_comment_status( $new_status, $old_status, $comment ) {

	if ( $new_status == $old_status )

		return;



	if ( $new_status == 'spam' ) {

		akismet_submit_spam_comment( $comment->comment_ID );

	} elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {

		akismet_submit_nonspam_comment( $comment->comment_ID );

	}

}

521

akismet_transition_comment_status

Definition:
function akismet_transition_comment_status( $new_status, $old_status, $comment ) {}

Parameters

  • $new_status
  • $old_status
  • $comment

Source code

function akismet_transition_comment_status( $new_status, $old_status, $comment ) {

	if ( $new_status == $old_status )

		return;



	# we don't need to record a history item for deleted comments

	if ( $new_status == 'delete' )

		return;

		

	if ( !is_admin() )

		return;

		

	if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )

		return;



	if ( defined('WP_IMPORTING') && WP_IMPORTING == true )

		return;

		

	global $current_user;

	$reporter = '';

	if ( is_object( $current_user ) )

		$reporter = $current_user->user_login;

	

	// Assumption alert:

	// We want to submit comments to Akismet only when a moderator explicitly spams or approves it - not if the status

	// is changed automatically by another plugin.  Unfortunately WordPress doesn't provide an unambiguous way to

	// determine why the transition_comment_status action was triggered.  And there are several different ways by which

	// to spam and unspam comments: bulk actions, ajax, links in moderation emails, the dashboard, and perhaps others.

	// We'll assume that this is an explicit user action if POST or GET has an 'action' key.

	if ( isset($_POST['action']) || isset($_GET['action']) ) {

		if ( $new_status == 'spam' && ( $old_status == 'approved' || $old_status == 'unapproved' || !$old_status ) ) {

				return akismet_submit_spam_comment( $comment->comment_ID );

		} elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {

				return akismet_submit_nonspam_comment( $comment->comment_ID );

		}

	}

	

	if ( !get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )

		akismet_update_comment_history( $comment->comment_ID, sprintf( __('%s changed the comment status to %s'), $reporter, $new_status ), 'status-' . $new_status );

}

519

akismet_submit_spam_comment

Definition:
function akismet_submit_spam_comment ( $comment_id ) {}

Parameters

  • $comment_id

Defined actions

  • akismet_submit_spam_comment
    do_action('akismet_submit_spam_comment', $comment_id, $response[1]);

Source code

function akismet_submit_spam_comment ( $comment_id ) {

	global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;

	$comment_id = (int) $comment_id;



	$comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");

	if ( !$comment ) // it was deleted

		return;

	if ( 'spam' != $comment->comment_approved )

		return;

	

	// use the original version stored in comment_meta if available	

	$as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);

	if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) ) {

		$comment = (object) array_merge( (array)$comment, $as_submitted );

	}

	

	$comment->blog = get_bloginfo('url');

	$comment->blog_lang = get_locale();

	$comment->blog_charset = get_option('blog_charset');

	$comment->permalink = get_permalink($comment->comment_post_ID);

	$comment->reporter_ip = $_SERVER['REMOTE_ADDR'];

	if ( is_object($current_user) ) {

	    $comment->reporter = $current_user->user_login;

	}

	if ( is_object($current_site) ) {

		$comment->site_domain = $current_site->domain;

	}



	$comment->user_role = '';

	if ( isset( $comment->user_ID ) )

		$comment->user_role = akismet_get_user_roles($comment->user_ID);



	if ( akismet_test_mode() )

		$comment->is_test = 'true';



	$query_string = '';

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

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



	$response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-spam", $akismet_api_port);

	if ( $comment->reporter ) {

		akismet_update_comment_history( $comment_id, sprintf( __('%s reported this comment as spam'), $comment->reporter ), 'report-spam' );

		update_comment_meta( $comment_id, 'akismet_user_result', 'true' );

		update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );

	}

	do_action('akismet_submit_spam_comment', $comment_id, $response[1]);

}

517

akismet_submit_spam_comment

Definition:
function akismet_submit_spam_comment ( $comment_id ) {}

Parameters

  • $comment_id

Defined actions

  • akismet_submit_spam_comment
    do_action('akismet_submit_spam_comment', $comment_id, $response[1]);

Source code

function akismet_submit_spam_comment ( $comment_id ) {

	global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;

	$comment_id = (int) $comment_id;



	$comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");

	if ( !$comment ) // it was deleted

		return;

	if ( 'spam' != $comment->comment_approved )

		return;

	$comment->blog = get_option('home');

	$comment->blog_lang = get_locale();

	$comment->blog_charset = get_option('blog_charset');

	$comment->permalink = get_permalink($comment->comment_post_ID);

	if ( is_object($current_user) ) {

	    $comment->reporter = $current_user->user_login;

	}

	if ( is_object($current_site) ) {

		$comment->site_domain = $current_site->domain;

	}



	$comment->user_role = '';

	if ( !isset( $comment->user_id ) )

		$comment->user_role = akismet_get_user_roles($comment->user_ID);



	$query_string = '';

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

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



	$response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-spam", $akismet_api_port);

	do_action('akismet_submit_spam_comment', $comment_id, $response[1]);

}

515