Пример #1
0
$discourse_info = (object) wp_parse_args((array) $discourse_info, $defaults);
$more_replies = $discourse_info->posts_count - count($discourse_info->posts) - 1;
$more = count($discourse_info->posts) == 0 ? '' : 'more ';
if ($more_replies == 0) {
    $more_replies = '';
} elseif ($more_replies == 1) {
    $more_replies = '1 ' . $more . 'reply';
} else {
    $more_replies = $more_replies . ' ' . $more . 'replies';
}
$discourse_html = '';
$comments_html = '';
$participants_html = '';
if (count($discourse_info->posts) > 0) {
    foreach ($discourse_info->posts as &$post) {
        $comment_html = wp_kses_post(Discourse::comment_html());
        $comment_html = str_replace('{discourse_url}', esc_url($options['url']), $comment_html);
        $comment_html = str_replace('{discourse_url_name}', esc_html($discourse_url_name), $comment_html);
        $comment_html = str_replace('{topic_url}', esc_url($permalink), $comment_html);
        $comment_html = str_replace('{avatar_url}', esc_url(Discourse::avatar($post->avatar_template, 64)), $comment_html);
        $comment_html = str_replace('{user_url}', esc_url(Discourse::homepage($options['url'], $post)), $comment_html);
        $comment_html = str_replace('{username}', esc_html($post->username), $comment_html);
        $comment_html = str_replace('{fullname}', esc_html($post->name), $comment_html);
        $comment_html = str_replace('{comment_body}', wp_kses_post($post->cooked), $comment_html);
        // emoticons don't have absolute urls
        $comment_html = str_replace('{comment_created_at}', mysql2date(get_option('date_format'), $post->created_at), $comment_html);
        $comments_html .= $comment_html;
    }
    foreach ($discourse_info->participants as &$participant) {
        $participant_html = wp_kses_post(Discourse::participant_html());
        $participant_html = str_replace('{discourse_url}', esc_url($options['url']), $participant_html);