$1', $escaped);
$escaped = preg_replace('/\*\*([^*\n]+)\*\*/', '$1', $escaped);
}
$html = make_clickable(nl2br($escaped));
return preg_replace(
'/]*>/i',
'',
$html
);
}
function rapidchat_short_date($mysql_date) {
if (!$mysql_date) {
return '';
}
return mysql2date('Y/m/d', $mysql_date) === current_time('Y/m/d')
? mysql2date('H:i', $mysql_date)
: mysql2date('d/m/y', $mysql_date);
}
/** "Today", "Yesterday", or a short date for a Y/m/d day stamp. */
function rapidchat_date_divider_label($ymd) {
$ymd = (string) $ymd;
if ($ymd === wp_date('Y/m/d')) {
return __('Today', 'rapidchat');
}
if ($ymd === wp_date('Y/m/d', time() - DAY_IN_SECONDS)) {
return __('Yesterday', 'rapidchat');
}
$ts = strtotime(str_replace('/', '-', $ymd));
return $ts ? date_i18n(_x('M j, Y', 'chat date divider', 'rapidchat'), $ts) : $ymd;
}
function rapidchat_initial($name) {
$name = trim((string) $name);
return $name === '' ? '?' : mb_strtoupper(mb_substr($name, 0, 1));
}
/** Shared message-list markup. */
/** Do two messages belong to the same visual run? */
function rapidchat_messages_grouped($previous, $current) {
if (!$previous || !$current) {
return false;
}
if ((int) $previous->account_id !== (int) $current->account_id) {
return false;
}
$window = (int) apply_filters('rapidchat_message_group_window', 5 * MINUTE_IN_SECONDS);
$gap = abs((int) mysql2date('U', $current->submit_date) - (int) mysql2date('U', $previous->submit_date));
return $gap <= $window;
}
function rapidchat_render_messages($messages, array $names, $viewer_account_id, array $operator_ids = array(), $style = 'guest', $read_through = 0) {
$output = '';
return $output;
}
function rapidchat_render_message_row(array $row, $style = 'guest', $starts_group = true, $ends_group = true) {
if (!empty($row['msg_type']) && $row['msg_type'] === 'system') {
return '';
}
if (!empty($row['msg_type']) && $row['msg_type'] === 'note') {
if ($style !== 'admin') {
return '';
}
return '';
}
$own = ($style === 'admin') ? $row['staff'] : $row['mine'];
$alt = $own ? '' : ' alt';
$output = '';
$group = ($starts_group ? ' rc-group-start' : '') . ($ends_group ? ' rc-group-end' : '');
$attachment_html = '';
if (!empty($row['attachment_url'])) {
if ($row['attachment_type'] === 'image') {
$attachment_html = '';
} else {
$size_html = !empty($row['attachment_size']) ? '' . esc_html(size_format((int) $row['attachment_size'])) . '' : '';
$attachment_html = '';
}
}
$is_operator_authored = ($style === 'admin') ? !empty($row['staff']) : !$row['mine'];
$body_html = '';
if (!empty($row['msg'])) {
$body_html = '';
}
if ($style === 'admin') {
$output .= '';
} else {
if (!$own) {
$output .= '';
}
}
if ($ends_group) {
$output .= '' . esc_html($row['time']); if ($row['author'] !== '' && ($style === 'admin' || !$own)) { $output .= ' · ' . esc_html($row['author']); } $output .= '
'; } return $output; } function rapidchat_render_composer($conversation_id, $is_open) { if (!$is_open) { return '' . esc_html__('Chat session has ended.', 'rapidchat') . '