comments.php 2.7 KB

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