v1.7 — 登录态 + 评论优化
- 隐藏 WP admin bar - 导航栏右侧登录用户头像+姓名下拉菜单 - 笺文评论:只显示输入框+按钮,未登录点提交提示登录 - 评论无需审核直接显示
This commit is contained in:
+33
-10
@@ -40,16 +40,39 @@ if (post_password_required()) return;
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
comment_form(array(
|
||||
'title_reply' => '笺下留言',
|
||||
'title_reply_before' => '<h3 class="comment-reply-title">',
|
||||
'title_reply_after' => '</h3>',
|
||||
'comment_notes_before' => '',
|
||||
'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' => '落笔留痕',
|
||||
));
|
||||
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();
|
||||
if (confirm('请先登录')) {
|
||||
window.location.href = '/wp-login.php';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user