comments.php 3.0 KB

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