[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-content/themes/twentytwenty/ -> comments.php (source)

   1  <?php
   2  /**
   3   * The template file for displaying the comments and comment form for the
   4   * Twenty Twenty theme.
   5   *
   6   * @package WordPress
   7   * @subpackage Twenty_Twenty
   8   * @since Twenty Twenty 1.0
   9   */
  10  
  11  /*
  12   * If the current post is protected by a password and
  13   * the visitor has not yet entered the password we will
  14   * return early without loading the comments.
  15  */
  16  if ( post_password_required() ) {
  17      return;
  18  }
  19  
  20  if ( $comments ) {
  21      ?>
  22  
  23      <div class="comments" id="comments">
  24  
  25          <?php
  26          $comments_number = absint( get_comments_number() );
  27          ?>
  28  
  29          <div class="comments-header section-inner small max-percentage">
  30  
  31              <h2 class="comment-reply-title">
  32              <?php
  33              if ( ! have_comments() ) {
  34                  _e( 'Leave a comment', 'twentytwenty' );
  35              } elseif ( 1 === $comments_number ) {
  36                  /* translators: %s: Post title. */
  37                  printf( _x( 'One reply on &ldquo;%s&rdquo;', 'comments title', 'twentytwenty' ), get_the_title() );
  38              } else {
  39                  printf(
  40                      /* translators: 1: Number of comments, 2: Post title. */
  41                      _nx(
  42                          '%1$s reply on &ldquo;%2$s&rdquo;',
  43                          '%1$s replies on &ldquo;%2$s&rdquo;',
  44                          $comments_number,
  45                          'comments title',
  46                          'twentytwenty'
  47                      ),
  48                      number_format_i18n( $comments_number ),
  49                      get_the_title()
  50                  );
  51              }
  52  
  53              ?>
  54              </h2><!-- .comments-title -->
  55  
  56          </div><!-- .comments-header -->
  57  
  58          <div class="comments-inner section-inner thin max-percentage">
  59  
  60              <?php
  61              wp_list_comments(
  62                  array(
  63                      'walker'      => new TwentyTwenty_Walker_Comment(),
  64                      'avatar_size' => 120,
  65                      'style'       => 'div',
  66                  )
  67              );
  68  
  69              $comment_pagination = paginate_comments_links(
  70                  array(
  71                      'echo'      => false,
  72                      'end_size'  => 0,
  73                      'mid_size'  => 0,
  74                      'next_text' => __( 'Newer Comments', 'twentytwenty' ) . ' <span aria-hidden="true">&rarr;</span>',
  75                      'prev_text' => '<span aria-hidden="true">&larr;</span> ' . __( 'Older Comments', 'twentytwenty' ),
  76                  )
  77              );
  78  
  79              if ( $comment_pagination ) {
  80                  $pagination_classes = '';
  81  
  82                  // If we're only showing the "Next" link, add a class indicating so.
  83                  if ( false === strpos( $comment_pagination, 'prev page-numbers' ) ) {
  84                      $pagination_classes = ' only-next';
  85                  }
  86                  ?>
  87  
  88                  <nav class="comments-pagination pagination<?php echo $pagination_classes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>" aria-label="<?php esc_attr_e( 'Comments', 'twentytwenty' ); ?>">
  89                      <?php echo wp_kses_post( $comment_pagination ); ?>
  90                  </nav>
  91  
  92                  <?php
  93              }
  94              ?>
  95  
  96          </div><!-- .comments-inner -->
  97  
  98      </div><!-- comments -->
  99  
 100      <?php
 101  }
 102  
 103  if ( comments_open() || pings_open() ) {
 104  
 105      if ( $comments ) {
 106          echo '<hr class="styled-separator is-style-wide" aria-hidden="true" />';
 107      }
 108  
 109      comment_form(
 110          array(
 111              'class_form'         => 'section-inner thin max-percentage',
 112              'title_reply_before' => '<h2 id="reply-title" class="comment-reply-title">',
 113              'title_reply_after'  => '</h2>',
 114          )
 115      );
 116  
 117  } elseif ( is_single() ) {
 118  
 119      if ( $comments ) {
 120          echo '<hr class="styled-separator is-style-wide" aria-hidden="true" />';
 121      }
 122  
 123      ?>
 124  
 125      <div class="comment-respond" id="respond">
 126  
 127          <p class="comments-closed"><?php _e( 'Comments are closed.', 'twentytwenty' ); ?></p>
 128  
 129      </div><!-- #respond -->
 130  
 131      <?php
 132  }


Generated: Thu Nov 21 01:00:03 2024 Cross-referenced by PHPXref 0.7.1