WP_REST_Comments_Controller::prepare_status_response() WordPress Method

The prepare_status_response() method is used to prepare the response for the WP_REST_Comments_Controller::get_item() method. This method is used to get a single comment.

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

Checks comment_approved to set comment status for single comment output.


Parameters

$comment_approved

(string|int)(Required)comment status.


Top ↑

Return

(string) Comment status.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

	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;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.