WPDiscourse\Templates\HTMLTemplates::comment_html PHP Method

comment_html() public static method

Can be customized from within a theme using the filter provided. Available tags: {discourse_url}, {discourse_url_name}, {topic_url}, {avatar_url}, {user_url}, {username}, {fullname}, {comment_body}, {comment_created_at}, {comment_url}
public static comment_html ( ) : mixed | void
return mixed | void
    public static function comment_html()
    {
        ob_start();
        ?>
		<li class="comment even thread-even depth-1">
			<article class="comment-body">
				<footer class="comment-meta">
					<div class="comment-author vcard">
						<img alt="" src="{avatar_url}" class="avatar avatar-64 photo avatar-default" height="64"
						     width="64">
						<b class="fn"><a href="{topic_url}" rel="external" class="url">{fullname}</a></b>
						<span class="says">says:</span>
					</div>
					<!-- .comment-author -->
					<div class="comment-metadata">
						<time pubdate="" datetime="{comment_created_at}">{comment_created_at}</time>
					</div>
					<!-- .comment-metadata -->
				</footer>
				<!-- .comment-meta -->
				<div class="comment-content">{comment_body}</div>
				<!-- .comment-content -->
			</article>
			<!-- .comment-body -->
		</li>
		<?php 
        $output = ob_get_clean();
        return apply_filters('discourse_comment_html', $output);
    }

Usage Example

Example #1
0
 $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_url = esc_url($options['url']);
 $discourse_html = '';
 $comments_html = '';
 $participants_html = '';
 if (count($discourse_info->posts) > 0) {
     foreach ($discourse_info->posts as &$post) {
         $comment_html = wp_kses_post(Templates\HTMLTemplates::comment_html());
         $comment_html = str_replace('{discourse_url}', $discourse_url, $comment_html);
         $comment_html = str_replace('{discourse_url_name}', $discourse_url_name, $comment_html);
         $comment_html = str_replace('{topic_url}', $permalink, $comment_html);
         $avatar_url = Discourse::avatar($post->avatar_template, 64);
         $comment_html = str_replace('{avatar_url}', esc_url($avatar_url), $comment_html);
         $user_url = Discourse::homepage($options['url'], $post);
         $comment_html = str_replace('{user_url}', esc_url($user_url), $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_body = Discourse::convert_relative_img_src_to_absolute($discourse_url, $post->cooked);
         $comment_html = str_replace('{comment_body}', wp_kses_post($comment_body), $comment_html);
         $comment_html = str_replace('{comment_created_at}', mysql2date($datetime_format, get_date_from_gmt($post->created_at)), $comment_html);
         $comments_html .= $comment_html;
     }
     foreach ($discourse_info->participants as &$participant) {