comments.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @package Apostrophe 2
  4. *
  5. * The template for displaying comments.
  6. */
  7. /*
  8. * If the current post is protected by a password and
  9. * the visitor has not yet entered the password we will
  10. * return early without loading the comments.
  11. */
  12. if ( post_password_required() ) {
  13. return;
  14. }
  15. ?>
  16. <div id="comments" class="comments-area">
  17. <?php // Display the comments, if we have some ?>
  18. <?php if ( have_comments() ) : ?>
  19. <h2 class="comments-title">
  20. <?php
  21. printf( // WPCS: XSS OK.
  22. esc_html( _nx( 'One comment', '%s comments', get_comments_number(), 'comments title', 'apostrophe-2' ) ),
  23. number_format_i18n( get_comments_number() ) );
  24. ?>
  25. </h2>
  26. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
  27. <nav id="comment-nav-above" class="comment-navigation" role="navigation">
  28. <h1 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'apostrophe-2' ); ?></h1>
  29. <div class="nav-previous"><?php previous_comments_link( esc_html__( '&laquo; Older Comments', 'apostrophe-2' ) ); ?></div>
  30. <div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments &raquo;', 'apostrophe-2' ) ); ?></div>
  31. </nav><!-- #comment-nav-above -->
  32. <?php endif; // check for comment navigation ?>
  33. <ol class="comment-list">
  34. <?php
  35. wp_list_comments( array(
  36. 'avatar_size' => 120,
  37. ) );
  38. ?>
  39. </ol><!-- .comment-list -->
  40. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
  41. <nav id="comment-nav-below" class="comment-navigation" role="navigation">
  42. <h1 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'apostrophe-2' ); ?></h1>
  43. <div class="nav-previous"><?php previous_comments_link( esc_html__( '&laquo; Older Comments', 'apostrophe-2' ) ); ?></div>
  44. <div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments &raquo;', 'apostrophe-2' ) ); ?></div>
  45. </nav><!-- #comment-nav-below -->
  46. <?php endif; // check for comment navigation ?>
  47. <?php endif; // have_comments() ?>
  48. <?php
  49. // If comments are closed and there are comments, let's leave a little note, shall we?
  50. if ( ! comments_open() && '0' !== get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
  51. ?>
  52. <h2 class="no-comments"><?php esc_html_e( 'Comments are closed.', 'apostrophe-2' ); ?></h2>
  53. <?php endif; ?>
  54. <?php comment_form(); ?>
  55. </div><!-- #comments -->