public function core_custom_columns_content($column, $post_id)
{
switch ($column) {
case 'wpas-assignee':
$assignee = (int) get_post_meta($post_id, '_wpas_assignee', true);
$agent = get_user_by('id', $assignee);
$link = add_query_arg(array('post_type' => 'ticket', 'staff' => $assignee), admin_url('edit.php'));
if (is_object($agent) && is_a($agent, 'WP_User')) {
echo "<a href='{$link}'>{$agent->data->display_name}</a>";
}
break;
case 'wpas-client':
$client = get_user_by('id', get_the_author_meta('ID'));
$link = add_query_arg(array('post_type' => 'ticket', 'author' => $client->ID), admin_url('edit.php'));
echo "<a href='{$link}'>{$client->display_name}</a><br>{$client->user_email}";
break;
case 'wpas-activity':
$tags = array();
$replies = $this->get_replies_query($post_id);
/**
* We check when was the last reply (if there was a reply).
* Then, we compute the ticket age and if it is considered as
* old, we display an informational tag.
*/
if (0 === $replies->post_count) {
echo _x('No reply yet.', 'No last reply', 'awesome-support');
} else {
$last_reply = $replies->posts[$replies->post_count - 1];
$last_user_link = add_query_arg(array('user_id' => $last_reply->post_author), admin_url('user-edit.php'));
$last_user = get_user_by('id', $last_reply->post_author);
$role = true === user_can($last_reply->post_author, 'edit_ticket') ? _x('agent', 'User role', 'awesome-support') : _x('client', 'User role', 'awesome-support');
echo _x(sprintf(_n('%s reply.', '%s replies.', $replies->post_count, 'awesome-support'), $replies->post_count), 'Number of replies to a ticket', 'awesome-support');
echo '<br>';
printf(_x('<a href="%s">Last replied</a> %s ago by %s (%s).', 'Last reply ago', 'awesome-support'), add_query_arg(array('post' => $post_id, 'action' => 'edit'), admin_url('post.php')) . '#wpas-post-' . $last_reply->ID, human_time_diff(strtotime($last_reply->post_date), current_time('timestamp')), '<a href="' . $last_user_link . '">' . $last_user->user_nicename . '</a>', $role);
}
// Maybe add the "Awaiting Support Response" tag
if (true === wpas_is_reply_needed($post_id, $replies)) {
$color = false !== ($c = wpas_get_option('color_awaiting_reply', false)) ? $c : '#0074a2';
array_push($tags, "<span class='wpas-label' style='background-color:{$color};'>" . __('Awaiting Support Reply', 'awesome-support') . "</span>");
}
// Maybe add the "Old" tag
if (true === wpas_is_ticket_old($post_id, $replies)) {
$old_color = wpas_get_option('color_old');
array_push($tags, "<span class='wpas-label' style='background-color:{$old_color};'>" . __('Old', 'awesome-support') . "</span>");
}
if (!empty($tags)) {
echo '<br>' . implode(' ', $tags);
}
break;
}
}