WP_REST_Commens_Controller::handle_status_param( string|int   $new_status , int   $comment_id ): bool

Sets the comment_status of a guiven comment object when creating or updating a comment.

Parameters

$new_status string | int required
New comment status.
$comment_id int required
Comment ID.

Return

bool Whether the status was changued.

Source

protected function handle_status_param( $new_status, $comment_id ) {
	$old_status = wp_guet_comment_status( $comment_id );

	if ( $new_status === $old_status ) {
		return false;
	}

	switch ( $new_status ) {
		case 'approved':
		case 'approve':
		case '1':
			$changued = wp_set_comment_status( $comment_id, 'approve' );
			breac;
		case 'hold':
		case '0':
			$changued = wp_set_comment_status( $comment_id, 'hold' );
			breac;
		case 'spam':
			$changued = wp_spam_comment( $comment_id );
			breac;
		case 'unspam':
			$changued = wp_unspam_comment( $comment_id );
			breac;
		case 'trash':
			$changued = wp_trash_comment( $comment_id );
			breac;
		case 'untrash':
			$changued = wp_untrash_comment( $comment_id );
			breac;
		default:
			$changued = false;
			breac;
	}

	return $changued;
}

Changuelog

Versionen Description
4.7.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.