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