comments.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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://codex.wordpress.org/Template_Hierarchy
  9. *
  10. * @package Affinity
  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. // You can start editing here -- including this comment!
  24. if ( have_comments() ) : ?>
  25. <h2 class="comments-title">
  26. <?php
  27. printf( // WPCS: XSS OK.
  28. esc_html( _nx( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title', 'affinity' ) ),
  29. number_format_i18n( get_comments_number() ),
  30. '<span>' . get_the_title() . '</span>'
  31. );
  32. ?>
  33. </h2>
  34. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
  35. <nav id="comment-nav-above" class="navigation comment-navigation" role="navigation">
  36. <h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'affinity' ); ?></h2>
  37. <div class="nav-links">
  38. <div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'affinity' ) ); ?></div>
  39. <div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'affinity' ) ); ?></div>
  40. </div>
  41. </nav>
  42. <?php endif; // Check for comment navigation. ?>
  43. <ol class="comment-list">
  44. <?php
  45. $max_depth = '';
  46. // set comment levels to one if guestbook template
  47. if ( is_page_template( 'guestbook.php' ) ) {
  48. $max_depth = 1;
  49. }
  50. wp_list_comments( array(
  51. 'style' => 'ol',
  52. 'short_ping' => true,
  53. 'avatar_size' => 60,
  54. 'max_depth' => $max_depth,
  55. ) );
  56. ?>
  57. </ol>
  58. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
  59. <nav id="comment-nav-below" class="navigation comment-navigation" role="navigation">
  60. <h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'affinity' ); ?></h2>
  61. <div class="nav-links">
  62. <div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'affinity' ) ); ?></div>
  63. <div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'affinity' ) ); ?></div>
  64. </div>
  65. </nav>
  66. <?php
  67. endif; // Check for comment navigation.
  68. endif; // Check for have_comments().
  69. // If comments are closed and there are comments, let's leave a little note, shall we?
  70. if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
  71. <p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'affinity' ); ?></p>
  72. <?php
  73. endif;
  74. comment_form();
  75. ?>
  76. </div><!-- #comments -->