comments.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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_Fifteen
  10. * @since Twenty Fifteen 1.0
  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 if ( have_comments() ) : ?>
  23. <h2 class="comments-title">
  24. <?php
  25. $comments_number = get_comments_number();
  26. if ( '1' === $comments_number ) {
  27. /* translators: %s: post title */
  28. printf( _x( 'One thought on &ldquo;%s&rdquo;', 'comments title', 'twentyfifteen' ), get_the_title() );
  29. } else {
  30. printf(
  31. /* translators: 1: number of comments, 2: post title */
  32. _nx(
  33. '%1$s thought on &ldquo;%2$s&rdquo;',
  34. '%1$s thoughts on &ldquo;%2$s&rdquo;',
  35. $comments_number,
  36. 'comments title',
  37. 'twentyfifteen'
  38. ),
  39. number_format_i18n( $comments_number ),
  40. get_the_title()
  41. );
  42. }
  43. ?>
  44. </h2>
  45. <?php twentyfifteen_comment_nav(); ?>
  46. <ol class="comment-list">
  47. <?php
  48. wp_list_comments( array(
  49. 'style' => 'ol',
  50. 'short_ping' => true,
  51. 'avatar_size' => 56,
  52. ) );
  53. ?>
  54. </ol><!-- .comment-list -->
  55. <?php twentyfifteen_comment_nav(); ?>
  56. <?php endif; // have_comments() ?>
  57. <?php
  58. // If comments are closed and there are comments, let's leave a little note, shall we?
  59. if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
  60. ?>
  61. <p class="no-comments"><?php _e( 'Comments are closed.', 'twentyfifteen' ); ?></p>
  62. <?php endif; ?>
  63. <?php comment_form(); ?>
  64. </div><!-- .comments-area -->