wp/wp-content/themes/twentysixteen/comments.php
changeset 7 cf61fcea0001
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
       
     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 WordPress
       
     9  * @subpackage Twenty_Sixteen
       
    10  * @since Twenty Sixteen 1.0
       
    11  */
       
    12 
       
    13 /*
       
    14  * If the current post is protected by a password and
       
    15  * the visitor has not yet entered the password we will
       
    16  * return early without loading the comments.
       
    17  */
       
    18 if ( post_password_required() ) {
       
    19 	return;
       
    20 }
       
    21 ?>
       
    22 
       
    23 <div id="comments" class="comments-area">
       
    24 
       
    25 	<?php if ( have_comments() ) : ?>
       
    26 		<h2 class="comments-title">
       
    27 			<?php
       
    28 				$comments_number = get_comments_number();
       
    29 				if ( '1' === $comments_number ) {
       
    30 					/* translators: %s: post title */
       
    31 					printf( _x( 'One thought on &ldquo;%s&rdquo;', 'comments title', 'twentysixteen' ), get_the_title() );
       
    32 				} else {
       
    33 					printf(
       
    34 						/* translators: 1: number of comments, 2: post title */
       
    35 						_nx(
       
    36 							'%1$s thought on &ldquo;%2$s&rdquo;',
       
    37 							'%1$s thoughts on &ldquo;%2$s&rdquo;',
       
    38 							$comments_number,
       
    39 							'comments title',
       
    40 							'twentysixteen'
       
    41 						),
       
    42 						number_format_i18n( $comments_number ),
       
    43 						get_the_title()
       
    44 					);
       
    45 				}
       
    46 			?>
       
    47 		</h2>
       
    48 
       
    49 		<?php the_comments_navigation(); ?>
       
    50 
       
    51 		<ol class="comment-list">
       
    52 			<?php
       
    53 				wp_list_comments( array(
       
    54 					'style'       => 'ol',
       
    55 					'short_ping'  => true,
       
    56 					'avatar_size' => 42,
       
    57 				) );
       
    58 			?>
       
    59 		</ol><!-- .comment-list -->
       
    60 
       
    61 		<?php the_comments_navigation(); ?>
       
    62 
       
    63 	<?php endif; // Check for have_comments(). ?>
       
    64 
       
    65 	<?php
       
    66 		// If comments are closed and there are comments, let's leave a little note, shall we?
       
    67 		if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
       
    68 	?>
       
    69 		<p class="no-comments"><?php _e( 'Comments are closed.', 'twentysixteen' ); ?></p>
       
    70 	<?php endif; ?>
       
    71 
       
    72 	<?php
       
    73 		comment_form( array(
       
    74 			'title_reply_before' => '<h2 id="reply-title" class="comment-reply-title">',
       
    75 			'title_reply_after'  => '</h2>',
       
    76 		) );
       
    77 	?>
       
    78 
       
    79 </div><!-- .comments-area -->