/**
* Checks if a given request has access to create a comment.
*
* @since 4.7.0
*
* @param WP_REST_Request $request Full details about the request.
* @return true|WP_Error True if the request has access to create items, error object otherwise.
*/
public function create_item_permissions_check( $request ) { if ( !
is_user_logged_in() ) { if ( get_option( 'comment_registration'
) ) { return new WP_Error( 'rest_comment_login_required',
__( 'Sorry, you must be logged in to comment.'
),
array
( 'status' => 401
) );
} /**
* Filters whether comments can be created via the REST API without authentication.
*
* Enables creating comments for anonymous users.
*
* @since 4.7.0
*
* @param bool $allow_anonymous Whether to allow anonymous comments to
* be created. Default `false`.
* @param WP_REST_Request $request Request used to generate the
* response.
*/