comments.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php declare( strict_types = 1 ); ?>
  2. <?php
  3. /**
  4. * The template for displaying comments
  5. *
  6. * This is the template that displays the area of the page that contains both the current comments
  7. * and the comment form.
  8. *
  9. * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
  10. *
  11. * @package Varia
  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. <div id="comments" class="comments-area responsive-max-width">
  23. <?php
  24. // You can start editing here -- including this comment!
  25. if ( have_comments() ) :
  26. ?>
  27. <h2 class="comments-title">
  28. <?php
  29. $varia_comment_count = get_comments_number();
  30. if ( '1' === $varia_comment_count ) {
  31. printf(
  32. /* translators: 1: title. */
  33. esc_html__( 'One thought on &ldquo;%1$s&rdquo;', 'varia' ),
  34. '<span>' . get_the_title() . '</span>'
  35. );
  36. } else {
  37. printf( // WPCS: XSS OK.
  38. /* translators: 1: comment count number, 2: title. */
  39. esc_html( _nx( '%1$s thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', $varia_comment_count, 'comments title', 'varia' ) ),
  40. number_format_i18n( $varia_comment_count ),
  41. '<span>' . get_the_title() . '</span>'
  42. );
  43. }
  44. ?>
  45. </h2><!-- .comments-title -->
  46. <?php the_comments_navigation(); ?>
  47. <ol class="comment-list">
  48. <?php
  49. wp_list_comments( array(
  50. 'style' => 'ol',
  51. 'short_ping' => true,
  52. ) );
  53. ?>
  54. </ol><!-- .comment-list -->
  55. <?php
  56. the_comments_navigation();
  57. // If comments are closed and there are comments, let's leave a little note, shall we?
  58. if ( ! comments_open() ) :
  59. ?>
  60. <p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'varia' ); ?></p>
  61. <?php
  62. endif;
  63. endif; // Check for have_comments().
  64. comment_form();
  65. ?>
  66. </div><!-- #comments -->