comments.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 Libre 2
  9. */
  10. /*
  11. * If the current post is protected by a password and
  12. * the visitor has not yet entered the password we will
  13. * return early without loading the comments.
  14. */
  15. if ( post_password_required() ) {
  16. return;
  17. }
  18. ?>
  19. <div id="comments" class="comments-area">
  20. <?php // You can start editing here -- including this comment! ?>
  21. <?php if ( have_comments() ) : ?>
  22. <h2 class="comments-title">
  23. <?php
  24. $comments_number = get_comments_number();
  25. if ( 1 === $comments_number ) {
  26. /* translators: %s: post title */
  27. printf( _x( 'One thought on &ldquo;%s&rdquo;', 'comments title', 'libre-2' ), get_the_title() );
  28. } else {
  29. printf(
  30. /* translators: 1: number of comments, 2: post title */
  31. _nx(
  32. '%1$s thought on &ldquo;%2$s&rdquo;',
  33. '%1$s thoughts on &ldquo;%2$s&rdquo;',
  34. $comments_number,
  35. 'comments title',
  36. 'libre-2'
  37. ),
  38. number_format_i18n( $comments_number ),
  39. get_the_title()
  40. );
  41. }
  42. ?>
  43. </h2><!-- .comments-title -->
  44. <ol class="comment-list">
  45. <?php
  46. wp_list_comments( array(
  47. 'style' => 'ol',
  48. 'short_ping' => true,
  49. 'avatar_size' => 54,
  50. 'callback' => 'libre_2_comments'
  51. ) );
  52. ?>
  53. </ol><!-- .comment-list -->
  54. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
  55. <nav id="comment-nav-below" class="navigation comment-navigation" role="navigation">
  56. <h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'libre-2' ); ?></h2>
  57. <div class="nav-links">
  58. <div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'libre-2' ) ); ?></div>
  59. <div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'libre-2' ) ); ?></div>
  60. </div><!-- .nav-links -->
  61. </nav><!-- #comment-nav-below -->
  62. <?php endif; // Check for comment navigation. ?>
  63. <?php endif; // Check for have_comments(). ?>
  64. <?php
  65. // If comments are closed and there are comments, let's leave a little note, shall we?
  66. if ( ! comments_open() && '0' != get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
  67. ?>
  68. <p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'libre-2' ); ?></p>
  69. <?php endif; ?>
  70. <?php comment_form(); ?>
  71. </div><!-- #comments -->