public function updateComment()
    {
        $newComment = $_POST['comment'] ?? null;
        $commentId = $_POST['commentId'] ?? null;

        if (!$newComment || !$commentId || !$comment = get_comment($commentId)) {
            wp_send_json_error('Missing variables');
        }

        if (!current_user_can('edit_comment', $comment->comment_ID) && !($comment->user_id == get_current_user_id())) {
            wp_send_json_error('Missing authorization');
        }

        // Validate nonce
        if (!check_ajax_referer("update-comment_$comment->comment_ID", 'nonce', false)) {
            wp_send_json_error('Nonce failed');
        }

        $comment->comment_content = $newComment;
        if (wp_update_comment((array) $comment)) {
            wp_send_json_success('Update was successful');
        }

        wp_send_json();
    }