Advertisements

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

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: