Files
kjweiji/comments.php
T
liaoxin fef6379522 v1.9 — 评论区优化
- 评论列表自定义渲染(头像 22px,回复按钮中文化)
- 回复表单标题中文化('回复 %s' / '取消回复')
- 去掉 'X条留言' 标题,使用'笺下留言'
- 登录弹窗替代 alert
- 退出登录+登录带回跳
2026-05-04 13:46:15 +08:00

66 lines
2.3 KiB
PHP

<?php
/**
* 空笺未寄 — 评论模板
*/
if (post_password_required()) return;
?>
<div id="comments" class="comments-section">
<h3 class="comment-reply-title">笺下留言</h3>
<?php if (have_comments()) : ?>
<ol class="comment-list">
<?php
wp_list_comments(array(
'style' => 'ol',
'avatar_size' => 24,
'short_ping' => true,
'callback' => null,
'reply_text' => '回复',
'format' => 'html5',
));
?>
</ol>
<?php the_comments_navigation(); ?>
<?php endif; ?>
<?php if (is_user_logged_in()) : ?>
<?php
comment_form(array(
'title_reply' => '',
'comment_notes_before' => '',
'comment_notes_after' => '',
'logged_in_as' => '',
'fields' => array(),
'comment_field' => '<textarea id="comment" name="comment" rows="4" placeholder="写点什么..." required></textarea>',
'submit_button' => '<button type="submit" class="submit">落笔留痕</button>',
'submit_field' => '<div class="form-submit">%1$s %2$s</div>',
'label_submit' => '落笔留痕',
));
?>
<?php else : ?>
<form id="commentform-guest" class="comment-form" novalidate>
<textarea id="comment" name="comment" rows="4" placeholder="写点什么..." required></textarea>
<div class="form-submit">
<button type="submit" class="submit">落笔留痕</button>
</div>
</form>
<script>
document.getElementById('commentform-guest').addEventListener('submit', function(e) {
e.preventDefault();
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');
}
function goLogin() {
window.location.href = '/wp-login.php?redirect_to=' + encodeURIComponent(window.location.href);
}
</script>
<?php endif; ?>
</div>