v1.12 — 评论区重构
- 自定义评论列表,支持嵌套回复显示 - 回复显示 @作者名 + 左侧虚线缩进 - 评论时间中文化 Y-m-d H:i:s,无 at 后缀 - 清理 CSS 冲突和残留规则 - 回复标题/按钮样式优化
This commit is contained in:
+9
-4
@@ -9,16 +9,21 @@ if (post_password_required()) return;
|
||||
|
||||
|
||||
<?php if (have_comments()) : ?>
|
||||
<h3 class="comment-reply-title">笺下留言</h3>
|
||||
<ol class="comment-list">
|
||||
<?php
|
||||
$comments = get_comments(array('post_id' => get_the_ID(), 'status' => 'approve', 'order' => 'ASC'));
|
||||
foreach ($comments as $c) :
|
||||
$c_user = get_user_by('email', $c->comment_author_email);
|
||||
$is_reply = $c->comment_parent > 0;
|
||||
$parent = $is_reply ? get_comment($c->comment_parent) : null;
|
||||
?>
|
||||
<li class="comment-item">
|
||||
<li class="comment-item<?php echo $is_reply ? ' comment-item--reply' : ''; ?>">
|
||||
<div class="comment-item__meta">
|
||||
<?php echo get_avatar($c, 22, '', '', array('class' => 'comment-avatar')); ?>
|
||||
<?php echo get_avatar($c, 18, '', '', array('class' => 'comment-avatar')); ?>
|
||||
<span class="comment-item__author"><?php echo esc_html($c->comment_author); ?></span>
|
||||
<?php if ($parent) : ?>
|
||||
<span class="comment-item__replyto">回复 @<?php echo esc_html($parent->comment_author); ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="comment-item__time"><?php echo get_comment_date('Y-m-d H:i:s', $c); ?></span>
|
||||
</div>
|
||||
<div class="comment-item__text"><?php echo esc_html($c->comment_content); ?></div>
|
||||
@@ -31,7 +36,7 @@ if (post_password_required()) return;
|
||||
<?php if (is_user_logged_in()) : ?>
|
||||
<?php
|
||||
comment_form(array(
|
||||
'title_reply' => '笺下留言',
|
||||
'title_reply' => '',
|
||||
'comment_notes_before' => '',
|
||||
'comment_notes_after' => '',
|
||||
'logged_in_as' => '',
|
||||
|
||||
Reference in New Issue
Block a user