comments.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /**
  3. * The template for displaying comments.
  4. *
  5. * This is the template that displays the area of the page that contains both the current comments
  6. * and the comment form.
  7. *
  8. * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
  9. *
  10. * @package Pen
  11. */
  12. /**
  13. * If the current post is protected by a password and
  14. * the visitor has not yet entered the password we will
  15. * return early without loading the comments.
  16. */
  17. if ( post_password_required() ) {
  18. return;
  19. }
  20. ?>
  21. <div id="comments" class="comments-area">
  22. <?php
  23. if ( have_comments() ) {
  24. ?>
  25. <h2 class="comments-title">
  26. <?php
  27. $pen_comment_count = get_comments_number();
  28. if ( '1' === $pen_comment_count ) {
  29. printf(
  30. /* Translators: 1: title. */
  31. esc_html__( 'One thought on &ldquo;%1$s&rdquo;', 'pen' ),
  32. '<span>' . get_the_title() . '</span>'
  33. );
  34. } else {
  35. printf( /* phpcs:ignore */
  36. /* Translators: %1$s: comment count number, %2$s: title. */
  37. esc_html( _nx( '%1$s thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', $pen_comment_count, 'comments title', 'pen' ) ),
  38. number_format_i18n( $pen_comment_count ),
  39. '<span>' . get_the_title() . '</span>'
  40. );
  41. }
  42. ?>
  43. </h2>
  44. <?php
  45. /* Are there comments to navigate through? */
  46. if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) {
  47. ?>
  48. <nav id="comment-nav-above" class="navigation comment-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Top Comments Menu', 'pen' ); ?>">
  49. <h2 class="screen-reader-text">
  50. <?php
  51. esc_html_e( 'Comment navigation', 'pen' );
  52. ?>
  53. </h2>
  54. <div class="nav-links">
  55. <div class="nav-previous">
  56. <?php
  57. previous_comments_link( esc_html__( 'Older Comments', 'pen' ) );
  58. ?>
  59. </div>
  60. <div class="nav-next">
  61. <?php
  62. next_comments_link( esc_html__( 'Newer Comments', 'pen' ) );
  63. ?>
  64. </div>
  65. </div><!-- .nav-links -->
  66. </nav><!-- #comment-nav-above -->
  67. <?php
  68. }
  69. ?>
  70. <ol class="comment-list">
  71. <?php
  72. wp_list_comments(
  73. array(
  74. 'style' => 'ol',
  75. 'short_ping' => true,
  76. )
  77. );
  78. ?>
  79. </ol><!-- .comment-list -->
  80. <?php
  81. /* Are there comments to navigate through? */
  82. if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) {
  83. ?>
  84. <nav id="comment-nav-below" class="navigation comment-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Bottom Comments Menu', 'pen' ); ?>">
  85. <h2 class="screen-reader-text">
  86. <?php
  87. esc_html_e( 'Comment navigation', 'pen' );
  88. ?>
  89. </h2>
  90. <div class="nav-links">
  91. <div class="nav-previous">
  92. <?php
  93. previous_comments_link( esc_html__( 'Older Comments', 'pen' ) );
  94. ?>
  95. </div>
  96. <div class="nav-next">
  97. <?php
  98. next_comments_link( esc_html__( 'Newer Comments', 'pen' ) );
  99. ?>
  100. </div>
  101. </div><!-- .nav-links -->
  102. </nav><!-- #comment-nav-below -->
  103. <?php
  104. }
  105. }
  106. /* If comments are closed and there are comments, let's leave a little note, shall we? */
  107. if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) {
  108. ?>
  109. <p class="no-comments">
  110. <?php
  111. esc_html_e( 'Comments are closed.', 'pen' );
  112. ?>
  113. </p>
  114. <?php
  115. }
  116. ?>
  117. <div id="pen_respond_wrapper" class="<?php pen_class_animation( 'comments' ); /* phpcs:ignore */ ?>">
  118. <?php
  119. $fields=array(
  120. 'author' => '<p class="comment-form-author">' . '<label for="author">姓名/联系方式:</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
  121. '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="50"' . $aria_req . ' /></p>',
  122. 'email' => '',
  123. 'url' => "",
  124. );
  125. $defaults=array(
  126. 'fields'=> apply_filters( 'comment_form_default_fields', $fields ),
  127. );
  128. comment_form($defaults);
  129. ?>
  130. </div>
  131. </div><!-- #comments -->