v1.9 — 评论区优化
- 评论列表自定义渲染(头像 22px,回复按钮中文化) - 回复表单标题中文化('回复 %s' / '取消回复') - 去掉 'X条留言' 标题,使用'笺下留言' - 登录弹窗替代 alert - 退出登录+登录带回跳
This commit is contained in:
+13
-35
@@ -1,51 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* 空笺未寄 — Comments Template
|
||||
* 保留 WP 原生评论区,适配主题样式
|
||||
* 空笺未寄 — 评论模板
|
||||
*/
|
||||
|
||||
if (post_password_required()) return;
|
||||
?>
|
||||
|
||||
<div id="comments" class="comments-section">
|
||||
|
||||
<?php if (have_comments()) : ?>
|
||||
<h3 class="comments-title">
|
||||
<?php
|
||||
$comment_count = get_comments_number();
|
||||
if ($comment_count === 1) {
|
||||
echo '一条留言';
|
||||
} else {
|
||||
echo $comment_count . ' 条留言';
|
||||
}
|
||||
?>
|
||||
</h3>
|
||||
<h3 class="comment-reply-title">笺下留言</h3>
|
||||
|
||||
<?php if (have_comments()) : ?>
|
||||
<ol class="comment-list">
|
||||
<?php
|
||||
wp_list_comments(array(
|
||||
'style' => 'ol',
|
||||
'avatar_size' => 32,
|
||||
'avatar_size' => 24,
|
||||
'short_ping' => true,
|
||||
'callback' => null,
|
||||
'reply_text' => '回复',
|
||||
'format' => 'html5',
|
||||
));
|
||||
?>
|
||||
</ol>
|
||||
|
||||
<?php the_comments_navigation(); ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!comments_open() && get_comments_number()) : ?>
|
||||
<p class="no-comments">评论已关闭。</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
if (is_user_logged_in()) :
|
||||
// 登录后:只显示留言框 + 按钮,隐藏 "Logged in as XXX"
|
||||
<?php if (is_user_logged_in()) : ?>
|
||||
<?php
|
||||
comment_form(array(
|
||||
'title_reply' => '笺下留言',
|
||||
'title_reply_before' => '<h3 class="comment-reply-title">',
|
||||
'title_reply_after' => '</h3>',
|
||||
'title_reply' => '',
|
||||
'comment_notes_before' => '',
|
||||
'comment_notes_after' => '',
|
||||
'logged_in_as' => '',
|
||||
@@ -55,10 +38,8 @@ if (post_password_required()) return;
|
||||
'submit_field' => '<div class="form-submit">%1$s %2$s</div>',
|
||||
'label_submit' => '落笔留痕',
|
||||
));
|
||||
else :
|
||||
// 未登录:只显示输入框 + 按钮,提交时提示登录
|
||||
?>
|
||||
<h3 class="comment-reply-title">笺下留言</h3>
|
||||
?>
|
||||
<?php else : ?>
|
||||
<form id="commentform-guest" class="comment-form" novalidate>
|
||||
<textarea id="comment" name="comment" rows="4" placeholder="写点什么..." required></textarea>
|
||||
<div class="form-submit">
|
||||
@@ -68,12 +49,9 @@ if (post_password_required()) return;
|
||||
<script>
|
||||
document.getElementById('commentform-guest').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
showLoginModal();
|
||||
});
|
||||
function showLoginModal() {
|
||||
var m = document.getElementById('login-modal');
|
||||
if (m) m.classList.add('active');
|
||||
}
|
||||
});
|
||||
function closeLoginModal() {
|
||||
var m = document.getElementById('login-modal');
|
||||
if (m) m.classList.remove('active');
|
||||
|
||||
Reference in New Issue
Block a user