comments.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * The template for displaying comments.
  4. *
  5. * The area of the page that contains both current comments
  6. * and the comment form.
  7. *
  8. * @package Libretto
  9. */
  10. /*
  11. * If the current post is protected by a password and
  12. * the visitor has not yet entered the password we will
  13. * return early without loading the comments.
  14. */
  15. if ( post_password_required() ) {
  16. return;
  17. }
  18. ?>
  19. <div id="comments" class="comments-area">
  20. <?php if ( have_comments() ) : // Show list of comments ?>
  21. <h2 class="comments-title">
  22. <?php
  23. printf( // WPCS: XSS OK.
  24. esc_html( _nx( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title', 'libretto' ) ),
  25. number_format_i18n( get_comments_number() ),
  26. '<span>' . get_the_title() . '</span>'
  27. );
  28. ?>
  29. </h2>
  30. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Show comment navigation at top ?>
  31. <nav id="comment-nav-above" class="comment-navigation" role="navigation">
  32. <h1 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'libretto' ); ?></h1>
  33. <div class="previous">
  34. <?php previous_comments_link( '<span class="meta-nav">' . esc_html__( 'Older Comments', 'libretto' ) . '</span>' ); ?>
  35. </div>
  36. <div class="next">
  37. <?php next_comments_link( '<span class="meta-nav">' . esc_html__( 'Newer Comments', 'libretto' ) . '</span>' ); ?>
  38. </div>
  39. </nav><!-- #comment-nav-above -->
  40. <?php endif; // End comment navigation ?>
  41. <ol class="comment-list">
  42. <?php
  43. wp_list_comments( array(
  44. 'style' => 'ol',
  45. 'short_ping' => true,
  46. 'avatar_size' => 64,
  47. ) );
  48. ?>
  49. </ol><!-- .comment-list -->
  50. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Show comment navigation at bottom ?>
  51. <nav id="comment-nav-below" class="comment-navigation" role="navigation">
  52. <h1 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'libretto' ); ?></h1>
  53. <div class="previous">
  54. <?php previous_comments_link( '<span class="meta-nav">' . esc_html__( 'Older Comments', 'libretto' ) . '</span>' ); ?>
  55. </div>
  56. <div class="next">
  57. <?php next_comments_link( '<span class="meta-nav">' . esc_html__( 'Newer Comments', 'libretto' ) . '</span>' ); ?>
  58. </div>
  59. </nav><!-- #comment-nav-above -->
  60. <?php endif; // End comment navigation ?>
  61. <?php endif; // have_comments() ?>
  62. <?php // If comments are closed and there are comments, let's leave a little note, shall we?
  63. if ( ! comments_open() && '0' !== get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
  64. ?>
  65. <h3 class="no-comments"><?php esc_html_e( 'Comments are now closed.', 'libretto' ); ?></h3>
  66. <?php endif; ?>
  67. <?php comment_form(); ?>
  68. </div><!-- #comments -->