comments.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 photos
  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
  23. // You can start editing here -- including this comment!
  24. if ( have_comments() ) : ?>
  25. <h2 class="comments-title">
  26. <?php
  27. $photos_comment_count = get_comments_number();
  28. if ( '1' === $photos_comment_count ) {
  29. printf(
  30. /* translators: 1: title. */
  31. esc_html__( 'One reply to &ldquo;%1$s&rdquo;', 'photos' ),
  32. '<span>' . get_the_title() . '</span>'
  33. );
  34. } else {
  35. printf( // WPCS: XSS OK.
  36. /* translators: 1: comment count number, 2: title. */
  37. esc_html( _nx( '%1$s reply to &ldquo;%2$s&rdquo;', '%1$s replies to &ldquo;%2$s&rdquo;', $photos_comment_count, 'comments title', 'photos' ) ),
  38. number_format_i18n( $photos_comment_count ),
  39. '<span>' . get_the_title() . '</span>'
  40. );
  41. }
  42. ?>
  43. </h2><!-- .comments-title -->
  44. <ol class="comment-list">
  45. <?php
  46. wp_list_comments( array(
  47. 'avatar_size' => 46,
  48. 'short_ping' => true,
  49. 'style' => 'ol',
  50. ) );
  51. ?>
  52. </ol><!-- .comment-list -->
  53. <?php
  54. the_comments_pagination( array(
  55. 'prev_text' => photos_get_svg( array( 'icon' => 'previous' ) ) . '<span class="screen-reader-text">' . esc_html__( 'Previous', 'photos' ) . '</span>',
  56. 'next_text' => '<span class="screen-reader-text">' . esc_html__( 'Next', 'photos' ) . '</span>' . photos_get_svg( array( 'icon' => 'next' ) ),
  57. ) );
  58. // If comments are closed and there are comments, let's leave a little note, shall we?
  59. if ( ! comments_open() ) :
  60. ?>
  61. <p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'photos' ); ?></p>
  62. <?php
  63. endif;
  64. endif; // Check for have_comments().
  65. comment_form();
  66. ?>
  67. </div><!-- #comments -->