comments.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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://developer.wordpress.org/themes/basics/template-hierarchy/
  9. *
  10. * @package WordPress
  11. * @subpackage Twenty_Twenty_One
  12. * @since Twenty Twenty-One 1.0
  13. */
  14. /*
  15. * If the current post is protected by a password and
  16. * the visitor has not yet entered the password,
  17. * return early without loading the comments.
  18. */
  19. if ( post_password_required() ) {
  20. return;
  21. }
  22. $twenty_twenty_one_comment_count = get_comments_number();
  23. ?>
  24. <div id="comments" class="comments-area default-max-width <?php echo get_option( 'show_avatars' ) ? 'show-avatars' : ''; ?>">
  25. <?php
  26. if ( have_comments() ) :
  27. ?>
  28. <h2 class="comments-title">
  29. <?php if ( '1' === $twenty_twenty_one_comment_count ) : ?>
  30. <?php esc_html_e( '1 comment', 'twentytwentyone' ); ?>
  31. <?php else : ?>
  32. <?php
  33. printf(
  34. /* translators: %s: Comment count number. */
  35. esc_html( _nx( '%s comment', '%s comments', $twenty_twenty_one_comment_count, 'Comments title', 'twentytwentyone' ) ),
  36. esc_html( number_format_i18n( $twenty_twenty_one_comment_count ) )
  37. );
  38. ?>
  39. <?php endif; ?>
  40. </h2><!-- .comments-title -->
  41. <ol class="comment-list">
  42. <?php
  43. wp_list_comments(
  44. array(
  45. 'avatar_size' => 60,
  46. 'style' => 'ol',
  47. 'short_ping' => true,
  48. )
  49. );
  50. ?>
  51. </ol><!-- .comment-list -->
  52. <?php
  53. the_comments_pagination(
  54. array(
  55. 'before_page_number' => esc_html__( 'Page', 'twentytwentyone' ) . ' ',
  56. 'mid_size' => 0,
  57. 'prev_text' => sprintf(
  58. '%s <span class="nav-prev-text">%s</span>',
  59. is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' ),
  60. esc_html__( 'Older comments', 'twentytwentyone' )
  61. ),
  62. 'next_text' => sprintf(
  63. '<span class="nav-next-text">%s</span> %s',
  64. esc_html__( 'Newer comments', 'twentytwentyone' ),
  65. is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' )
  66. ),
  67. )
  68. );
  69. ?>
  70. <?php if ( ! comments_open() ) : ?>
  71. <p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'twentytwentyone' ); ?></p>
  72. <?php endif; ?>
  73. <?php endif; ?>
  74. <?php
  75. comment_form(
  76. array(
  77. 'title_reply' => esc_html__( 'Leave a comment', 'twentytwentyone' ),
  78. 'title_reply_before' => '<h2 id="reply-title" class="comment-reply-title">',
  79. 'title_reply_after' => '</h2>',
  80. )
  81. );
  82. ?>
  83. </div><!-- #comments -->