comments.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. defined('ABSPATH') or die('This file can not be loaded directly.');
  3. global $comment_ids; $comment_ids = array();
  4. foreach ( $comments as $comment ) {
  5. if (get_comment_type() == "comment") {
  6. $comment_ids[get_comment_id()] = ++$comment_i;
  7. }
  8. }
  9. if ( !comments_open() ) return;
  10. $my_email = get_bloginfo ( 'admin_email' );
  11. $str = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = $post->ID AND comment_approved = '1' AND comment_type = '' AND comment_author_email";
  12. $count_t = $post->comment_count;
  13. date_default_timezone_set(PRC);
  14. $closeTimer = (strtotime(date('Y-m-d G:i:s'))-strtotime(get_the_time('Y-m-d G:i:s')))/86400;
  15. ?>
  16. <div id="respond" class="no_webshot">
  17. <?php if ( get_option('comment_registration') && !is_user_logged_in() ) { ?>
  18. <h3 class="queryinfo">
  19. <?php printf('您必须 <a href="%s">登录</a> 才能发表评论!', wp_login_url( get_permalink() ) );?>
  20. </h3>
  21. <?php }elseif( get_option('close_comments_for_old_posts') && $closeTimer > get_option('close_comments_days_old') ) { ?>
  22. <h3 class="queryinfo">
  23. 文章评论已关闭!
  24. </h3>
  25. <?php }else{ ?>
  26. <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
  27. <div class="comt-title">
  28. <div class="comt-avatar pull-left">
  29. <?php
  30. global $current_user;
  31. get_currentuserinfo();
  32. if ( is_user_logged_in() )
  33. echo get_avatar( $current_user->user_email, $size = '54' , deel_avatar_default() );
  34. elseif( !is_user_logged_in() && get_option('require_name_email') && $comment_author_email=='' )
  35. echo get_avatar( $current_user->user_email, $size = '54' , deel_avatar_default() );
  36. elseif( !is_user_logged_in() && get_option('require_name_email') && $comment_author_email!=='' )
  37. echo get_avatar( $comment->comment_author_email, $size = '54' , deel_avatar_default() );
  38. else
  39. echo get_avatar( $comment->comment_author_email, $size = '54' , deel_avatar_default() );
  40. ?>
  41. </div>
  42. <div class="comt-author pull-left">
  43. <?php
  44. if ( is_user_logged_in() ) {
  45. printf($user_identity.'<span>发表我的评论</span>');
  46. }else{
  47. if( get_option('require_name_email') && !empty($comment_author_email) ){
  48. printf($comment_author.' <span>发表我的评论</span> &nbsp; <a class="switch-author" href="javascript:;" data-type="switch-author" style="font-size:12px;">换个身份</a>');
  49. }else{
  50. printf('发表我的评论');
  51. }
  52. }
  53. ?>
  54. </div>
  55. <a id="cancel-comment-reply-link" class="pull-right" href="javascript:;">取消评论</a>
  56. </div>
  57. <div class="comt">
  58. <div class="comt-box">
  59. <textarea placeholder="写点什么..." class="input-block-level comt-area" name="comment" id="comment" cols="100%" rows="3" tabindex="1" onkeydown="if(event.ctrlKey&amp;&amp;event.keyCode==13){document.getElementById('submit').click();return false};"></textarea>
  60. <div class="comt-ctrl">
  61. <button class="btn btn-primary pull-right" type="submit" name="submit" id="submit" tabindex="5"><i class="fa fa-check-square-o"></i> 提交评论</button>
  62. <div class="comt-tips pull-right"><?php comment_id_fields(); do_action('comment_form', $post->ID); ?></div>
  63. <span data-type="comment-insert-smilie" class="muted comt-smilie"><i class="fa fa-smile-o"></i> 表情</span>
  64. <span class="muted comt-mailme"><?php deel_add_checkbox() ?></span>
  65. </div>
  66. </div>
  67. <?php if ( !is_user_logged_in() ) { ?>
  68. <?php if( get_option('require_name_email') ){ ?>
  69. <div class="comt-comterinfo" id="comment-author-info" <?php if ( !empty($comment_author) ) echo 'style="display:none"'; ?>>
  70. <h4>Hi,您需要填写昵称和邮箱!</h4>
  71. <ul>
  72. <li class="form-inline"><label class="hide" for="author">昵称</label><input class="ipt" type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" tabindex="2" placeholder="昵称"><span class="help-inline">昵称 (必填)</span></li>
  73. <li class="form-inline"><label class="hide" for="email">邮箱</label><input class="ipt" type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" tabindex="3" placeholder="邮箱"><span class="help-inline">邮箱 (必填)</span></li>
  74. <li class="form-inline"><label class="hide" for="url">网址</label><input class="ipt" type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" tabindex="4" placeholder="网址"><span class="help-inline">网址</span></li>
  75. </ul>
  76. </div>
  77. <?php } ?>
  78. <?php } ?>
  79. </div>
  80. </form>
  81. <?php } ?>
  82. </div>
  83. <?php
  84. if ( have_comments() ) {
  85. ?>
  86. <div id="postcomments">
  87. <div id="comments">
  88. <i class="fa fa-comments-o"></i> <b><?php echo ' ('.$count_t.')'; ?></b>个小伙伴在吐槽
  89. </div>
  90. <ol class="commentlist">
  91. <?php wp_list_comments('type=comment&callback=deel_comment_list') ?>
  92. </ol>
  93. <div class="commentnav" >
  94. <?php paginate_comments_links('prev_text=«&next_text=»');?>
  95. </div>
  96. </div>
  97. <?php
  98. }
  99. ?>