comments.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 Rebalance
  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 clear-fix">
  22. <?php // You can start editing here -- including this comment! ?>
  23. <?php if ( have_comments() ) : ?>
  24. <h2 class="comments-title">
  25. <?php
  26. printf( // WPCS: XSS OK.
  27. esc_html( _nx( '1 Comment', '%1$s Comments', get_comments_number(), 'comments title', 'rebalance' ) ),
  28. number_format_i18n( get_comments_number() )
  29. );
  30. ?>
  31. </h2>
  32. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
  33. <nav id="comment-nav-above" class="navigation comment-navigation" role="navigation">
  34. <h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'rebalance' ); ?></h2>
  35. <div class="nav-links">
  36. <?php if ( get_previous_comments_link() ) { ?>
  37. <div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'rebalance' ) ); ?></div>
  38. <?php } ?>
  39. <?php if ( get_next_comments_link() ) { ?>
  40. <div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'rebalance' ) ); ?></div>
  41. <?php } ?>
  42. </div><!-- .nav-links -->
  43. </nav><!-- #comment-nav-above -->
  44. <?php endif; // Check for comment navigation. ?>
  45. <ol class="comment-list">
  46. <?php
  47. wp_list_comments( array(
  48. 'style' => 'ol',
  49. 'avatar_size' => 111,
  50. 'short_ping' => true,
  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', 'rebalance' ); ?></h2>
  57. <div class="nav-links">
  58. <?php if ( get_previous_comments_link() ) { ?>
  59. <div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'rebalance' ) ); ?></div>
  60. <?php } ?>
  61. <?php if ( get_next_comments_link() ) { ?>
  62. <div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'rebalance' ) ); ?></div>
  63. <?php } ?>
  64. </div><!-- .nav-links -->
  65. </nav><!-- #comment-nav-below -->
  66. <?php endif; // Check for comment navigation. ?>
  67. <?php endif; // Check for have_comments(). ?>
  68. <?php
  69. // If comments are closed and there are comments, let's leave a little note, shall we?
  70. if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
  71. ?>
  72. <p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'rebalance' ); ?></p>
  73. <?php endif; ?>
  74. <?php comment_form( array(
  75. 'label_submit' => __( 'Submit', 'rebalance' ) ) // Escaped on core
  76. ); ?>
  77. </div><!-- #comments -->