f09f3bbfef
- 首页文案更新为'自白者的栖息地' - 近笺 12 条 + 查看全部链接 - 笺文详情页加浏览量 - 登录弹窗替代 alert - 评论区修复双重 border-top - 退出登录带回跳 - 时间格式统一到秒 - 文案优化
88 lines
3.0 KiB
PHP
88 lines
3.0 KiB
PHP
<?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>
|
|
|
|
<ol class="comment-list">
|
|
<?php
|
|
wp_list_comments(array(
|
|
'style' => 'ol',
|
|
'avatar_size' => 32,
|
|
'short_ping' => true,
|
|
));
|
|
?>
|
|
</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"
|
|
comment_form(array(
|
|
'title_reply' => '笺下留言',
|
|
'title_reply_before' => '<h3 class="comment-reply-title">',
|
|
'title_reply_after' => '</h3>',
|
|
'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' => '落笔留痕',
|
|
));
|
|
else :
|
|
// 未登录:只显示输入框 + 按钮,提交时提示登录
|
|
?>
|
|
<h3 class="comment-reply-title">笺下留言</h3>
|
|
<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();
|
|
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');
|
|
}
|
|
function goLogin() {
|
|
window.location.href = '/wp-login.php?redirect_to=' + encodeURIComponent(window.location.href);
|
|
}
|
|
</script>
|
|
<?php endif; ?>
|
|
|
|
</div>
|