public function _ajax_view_comments($agents = null)
 {
     global $zendesk_support;
     if (empty($agents)) {
         $agents = Zendesk_Wordpress_Agents::get_instance();
     }
     if (isset($_REQUEST['ticket_id']) && is_numeric($_REQUEST['ticket_id']) && $agents->_is_agent()) {
         $ticket_id = $_REQUEST['ticket_id'];
         $comments = $zendesk_support->api->get_comments($ticket_id);
         if (!is_wp_error($comments)) {
             $html = array();
             $html[] = '<div class="zendesk-comment-to-ticket">';
             foreach ($comments as $comment) {
                 $author = $zendesk_support->api->get_user($comment->author_id);
                 if (is_wp_error($author)) {
                     $author = new StdClass();
                     $author->name = 'Unknown';
                     $author->email = '*****@*****.**';
                 } else {
                     $author = $author->user;
                 }
                 $html[] = '<a target="_blank" href="' . Zendesk_Wordpress_Utilities::_user_url($comment->author_id) . '">' . get_avatar($author->email, 40) . '</a>';
                 $html[] = '<div class="zendesk-comment-box">';
                 $html[] = '<div class="zendesk-comment-arrow"></div>';
                 $html[] = '<p class="zendesk-author">' . sprintf(__('%s said...', 'zendesk'), '<a target="_blank" href="' . Zendesk_Wordpress_Utilities::_user_url($comment->author_id) . '">' . $author->name . '</a>') . '</p>';
                 $html[] = wpautop($comment->body);
                 // Let's see if we have any attachments there.
                 if (isset($comment->attachments) && count($comment->attachments)) {
                     $html[] = '<div class="zendesk-comment-attachments">';
                     foreach ($comment->attachments as $attachment) {
                         $html[] = '<p class="zendesk-comment-attachment"><a target="_blank" href="' . $attachment->url . '">' . $attachment->file_name . '</a> <span class="zendesk-attachment-size">(' . Zendesk_Wordpress_Utilities::_file_size($attachment->size) . ')</span></p>';
                     }
                     $html[] = '</div>';
                 }
                 $html[] = '<p class="zendesk-comment-date">' . date(get_option('date_format') . ' \\a\\t ' . get_option('time_format'), strtotime($comment->created_at)) . '</p>';
                 $html[] = '</div>';
                 $html[] = '<br class="clear" />';
             }
             $html[] = '</div>';
             $html[] = '<br class="clear" />';
             $html = implode("\n", $html);
             $response = array('status' => 200, 'html' => $html);
         } else {
             $error_data = $comments->get_error_data();
             $response = array('status' => $error_data['status'], 'error' => $comments->get_error_message());
         }
     }
     echo json_encode($response);
     $this->terminate();
 }