feat: add comment reader url feature

pull/230/head
Seaton Jiang 2020-03-14 09:12:43 +08:00
parent 3ebbc9896b
commit 07145166be
1 changed files with 23 additions and 15 deletions

View File

@ -3,26 +3,26 @@
* 评论模板
* @author Seaton Jiang <seaton@vtrois.com>
* @license MIT License
* @version 2020.03.12
* @version 2020.03.14
*/
if (isset($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) {
die();
}
require get_template_directory() . '/pages/page-smilies.php';
if (comments_open()) { ?>
if (comments_open()) {?>
<div class="comments" id="comments">
<h3 class="title"><?php if(is_single()){_e('文章评论', 'kratos');}else{_e('评论内容', 'kratos');} ?></h3>
<h3 class="title"><?php if (is_single()) {_e('文章评论', 'kratos');} else {_e('评论内容', 'kratos');}?></h3>
<div class="list">
<?php wp_list_comments('type=comment&callback=comment_callbacks'); ?>
<?php wp_list_comments('type=comment&callback=comment_callbacks');?>
</div>
<div id="commentpage" class="nav text-center my-3">
<?php previous_comments_link(__('加载更多', 'kratos')); ?>
<?php previous_comments_link(__('加载更多', 'kratos'));?>
</div>
<div id="respond" class="comment-respond mt-2">
<?php if (!comments_open()): elseif (get_option('comment_registration') && !is_user_logged_in()): ?>
<div class="error text-center">
<?php printf(__('您需要 <a href="%s">登录</a> 之后才可以评论', 'kratos'), wp_login_url(get_permalink())); ?>
<?php printf(__('您需要 <a href="%s">登录</a> 之后才可以评论', 'kratos'), wp_login_url(get_permalink()));?>
</div>
<?php else: ?>
<form id="commentform" name="commentform" action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post">
@ -34,7 +34,7 @@ if (comments_open()) { ?>
<div class="input-group-prepend">
<span class="input-group-text"><i class="kicon i-user"></i></span>
</div>
<input class="form-control" id="author" placeholder="昵称" name="author" type="text" value="<?php echo $comment_author; ?>" required="required">
<input class="form-control" id="author" placeholder="昵称" name="author" type="text" value="<?php echo esc_attr($commenter['comment_author']); ?>" required="required">
</div>
</div>
<div class="col-md-6 mt-3 mt-md-0 comment-form-email">
@ -42,11 +42,19 @@ if (comments_open()) { ?>
<div class="input-group-prepend">
<span class="input-group-text"><i class="kicon i-cemail"></i></span>
</div>
<input id="email" class="form-control" name="email" placeholder="邮箱" type="email" value="<?php echo $comment_author_email; ?>" required="required">
<input id="email" class="form-control" name="email" placeholder="邮箱" type="email" value="<?php echo esc_attr($commenter['comment_author_email']); ?>" required="required">
</div>
</div>
<div class="col-md-6 mt-3 comment-form-author">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="kicon i-url"></i></span>
</div>
<input class="form-control" id="author" placeholder="网址" name="url" type="url" value="<?php echo esc_attr($commenter['comment_author_url']); ?>">
</div>
</div>
</div>
<?php endif; ?>
<?php endif;?>
<div class="comment-textarea">
<textarea class="form-control" id="comment" name="comment" rows="7" required="required"></textarea>
<div class="text-bar clearfix">
@ -59,16 +67,16 @@ if (comments_open()) { ?>
</div>
</div>
<div class="float-right">
<?php cancel_comment_reply_link(__('取消回复', 'kratos')); ?>
<input name="submit" type="submit" id="submit" class="btn btn-primary" value="<?php _e('提交评论', 'kratos'); ?>">
<?php cancel_comment_reply_link(__('取消回复', 'kratos'));?>
<input name="submit" type="submit" id="submit" class="btn btn-primary" value="<?php _e('提交评论', 'kratos');?>">
</div>
</div>
</div>
</div>
<?php comment_id_fields(); ?>
<?php do_action('comment_form', $post->ID); ?>
<?php comment_id_fields();?>
<?php do_action('comment_form', $post->ID);?>
</form>
<?php endif; ?>
<?php endif;?>
</div>
</div><!-- .comments -->
</div>
<?php }?>