comments.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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://codex.wordpress.org/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. <h2 class="comments-title">
  29. <?php
  30. $comments_number = get_comments_number();
  31. if ( '1' === $comments_number ) {
  32. /* translators: %s: post title */
  33. printf( _x( 'One Reply to &ldquo;%s&rdquo;', 'comments title', 'twentyseventeen' ), get_the_title() );
  34. } else {
  35. printf(
  36. /* translators: 1: number of comments, 2: post title */
  37. _nx(
  38. '%1$s Reply to &ldquo;%2$s&rdquo;',
  39. '%1$s Replies to &ldquo;%2$s&rdquo;',
  40. $comments_number,
  41. 'comments title',
  42. 'twentyseventeen'
  43. ),
  44. number_format_i18n( $comments_number ),
  45. get_the_title()
  46. );
  47. }
  48. ?>
  49. </h2>
  50. <ol class="comment-list">
  51. <?php
  52. wp_list_comments( array(
  53. 'avatar_size' => 100,
  54. 'style' => 'ol',
  55. 'short_ping' => true,
  56. 'reply_text' => twentyseventeen_get_svg( array( 'icon' => 'mail-reply' ) ) . __( 'Reply', 'twentyseventeen' ),
  57. ) );
  58. ?>
  59. </ol>
  60. <?php the_comments_pagination( array(
  61. 'prev_text' => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous', 'twentyseventeen' ) . '</span>',
  62. 'next_text' => '<span class="screen-reader-text">' . __( 'Next', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ),
  63. ) );
  64. endif; // Check for have_comments().
  65. // If comments are closed and there are comments, let's leave a little note, shall we?
  66. if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
  67. <p class="no-comments"><?php _e( 'Comments are closed.', 'twentyseventeen' ); ?></p>
  68. <?php
  69. endif;
  70. comment_form();
  71. ?>
  72. </div><!-- #comments -->