comments.php 2.3 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://developer.wordpress.org/themes/basics/template-hierarchy/
  9. *
  10. * @package WordPress
  11. * @subpackage Twenty_Seventeen
  12. * @since 1.0
  13. * @version 1.0
  14. */
  15. /*
  16. * If the current post is protected by a password and
  17. * the visitor has not yet entered the password we will
  18. * return early without loading the comments.
  19. */
  20. if ( post_password_required() ) {
  21. return;
  22. }
  23. ?>
  24. <div id="comments" class="comments-area">
  25. <?php
  26. // You can start editing here -- including this comment!
  27. if ( have_comments() ) :
  28. ?>
  29. <h2 class="comments-title">
  30. <?php
  31. $comments_number = get_comments_number();
  32. if ( '1' === $comments_number ) {
  33. /* translators: %s: Post title. */
  34. printf( _x( 'One Reply to &ldquo;%s&rdquo;', 'comments title', 'twentyseventeen' ), get_the_title() );
  35. } else {
  36. printf(
  37. /* translators: 1: Number of comments, 2: Post title. */
  38. _nx(
  39. '%1$s Reply to &ldquo;%2$s&rdquo;',
  40. '%1$s Replies to &ldquo;%2$s&rdquo;',
  41. $comments_number,
  42. 'comments title',
  43. 'twentyseventeen'
  44. ),
  45. number_format_i18n( $comments_number ),
  46. get_the_title()
  47. );
  48. }
  49. ?>
  50. </h2>
  51. <ol class="comment-list">
  52. <?php
  53. wp_list_comments(
  54. array(
  55. 'avatar_size' => 100,
  56. 'style' => 'ol',
  57. 'short_ping' => true,
  58. 'reply_text' => twentyseventeen_get_svg( array( 'icon' => 'mail-reply' ) ) . __( 'Reply', 'twentyseventeen' ),
  59. )
  60. );
  61. ?>
  62. </ol>
  63. <?php
  64. the_comments_pagination(
  65. array(
  66. 'prev_text' => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous', 'twentyseventeen' ) . '</span>',
  67. 'next_text' => '<span class="screen-reader-text">' . __( 'Next', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ),
  68. )
  69. );
  70. endif; // Check for have_comments().
  71. // If comments are closed and there are comments, let's leave a little note, shall we?
  72. if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
  73. ?>
  74. <p class="no-comments"><?php _e( 'Comments are closed.', 'twentyseventeen' ); ?></p>
  75. <?php
  76. endif;
  77. comment_form();
  78. ?>
  79. </div><!-- #comments -->