WP_REST_Comments_Controller::check_is_comment_content_allowed() WordPress Method

The WP_REST_Comments_Controller::check_is_comment_content_allowed() function is used to check if the current user is allowed to edit the comment content. If the user is not allowed, an error will be returned.

WP_REST_Comments_Controller::check_is_comment_content_allowed( array $prepared_comment ) #

If empty comments are not allowed, checks if the provided comment content is not empty.


Parameters

$prepared_comment

(array)(Required)The prepared comment data.


Top ↑

Return

(bool) True if the content is allowed, false otherwise.


Top ↑

Source

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

	protected function check_is_comment_content_allowed( $prepared_comment ) {
		$check = wp_parse_args(
			$prepared_comment,
			array(
				'comment_post_ID'      => 0,
				'comment_parent'       => 0,
				'user_ID'              => 0,
				'comment_author'       => null,
				'comment_author_email' => null,
				'comment_author_url'   => null,
			)
		);

		/** This filter is documented in wp-includes/comment.php */
		$allow_empty = apply_filters( 'allow_empty_comment', false, $check );

		if ( $allow_empty ) {
			return true;
		}

		/*
		 * Do not allow a comment to be created with missing or empty
		 * comment_content. See wp_handle_comment_submission().
		 */
		return '' !== $check['comment_content'];
	}


Top ↑

Changelog

Changelog
VersionDescription
5.6.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.