public function get_item_permissions_check( $request ) {
		$id = (int) $request['id'];

		$comment = get_comment( $id );

		if ( ! $comment ) {
			return true;
		}

		if ( ! $this->check_read_permission( $comment ) ) {
			return new WP_Error( 'rest_cannot_read', __( 'Sorry, you cannot read this comment.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		$post = $this->get_post( $comment->comment_post_ID );

		if ( $post && ! $this->check_read_post_permission( $post ) ) {
			return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you cannot read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) {
			return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannot view this comment with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		return true;
	}
public function get_item_permissions_check( $request ) {
		$id = (int) $request['id'];

		$comment = get_comment( $id );

		if ( ! $comment ) {
			return true;
		}

		if ( ! $this->check_read_permission( $comment ) ) {
			return new WP_Error( 'rest_cannot_read', __( 'Sorry, you cannot read this comment.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		$post = $this->get_post( $comment->comment_post_ID );

		if ( $post && ! $this->check_read_post_permission( $post ) ) {
			return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you cannot read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) {
			return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannot view this comment with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		return true;
	}
public function get_item_permissions_check ( $ request ) { $ id = ( int ) $ request [ 'id' ] ; $ comment = get_comment ( $ id ) ; if ( ! $ comment ) { return true ; } if ( ! $ this -> check_read_permission ( $ comment ) ) { return new WP_Error ( 'rest_cannot_read' , __ ( 'Sorry, you cannot read this comment.' ) , array ( 'status' => rest_authorization_required_code ( ) ) ) ; } $ post = $ this -> get_post ( $ comment -> comment_post_ID ) ; if ( $ post && ! $ this -> check_read_post_permission ( $ post ) ) { return new WP_Error ( 'rest_cannot_read_post' , __ ( 'Sorry, you cannot read the post for this comment.' ) , array ( 'status' => rest_authorization_required_code ( ) ) ) ; } if ( ! empty ( $ request [ 'context' ] ) && 'edit' === $ request [ 'context' ] && ! current_user_can ( 'moderate_comments' ) ) { return new WP_Error ( 'rest_forbidden_context' , __ ( 'Sorry, you cannot view this comment with edit context.' ) , array ( 'status' => rest_authorization_required_code ( ) ) ) ; } return true ; }
Check if a given request has access to read the comment

@param  WP_REST_Request $request Full details about the request.
@return WP_Error|boolean
Check if a given request has access to read the comment