WP_REST_Comments_Controller::prepare_status_response( string|int $comment_approved ): string

In this article

Checks comment_approved to set comment status for single comment output.

Parameters

$comment_approvedstring|intrequired
comment status.

Return

string Comment status.

Source

protected function prepare_status_response( $comment_approved ) {

	switch ( $comment_approved ) {
		case 'hold':
		case '0':
			$status = 'hold';
			break;

		case 'approve':
		case '1':
			$status = 'approved';
			break;

		case 'spam':
		case 'trash':
		default:
			$status = $comment_approved;
			break;
	}

	return $status;
}

Changelog

VersionDescription
4.7.0Introduced.

User Contributed Notes

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