[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

   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 WordPress
  11   * @subpackage Twenty_Nineteen
  12   * @since Twenty Nineteen 1.0
  13   */
  14  
  15  /*
  16   * If the current post is protected by a password and
  17   * the visitor has not yet entered the password we will
  18   * return early without loading the comments.
  19  */
  20  if ( post_password_required() ) {
  21      return;
  22  }
  23  
  24  $discussion = twentynineteen_get_discussion_data();
  25  ?>
  26  
  27  <div id="comments" class="<?php echo comments_open() ? 'comments-area' : 'comments-area comments-closed'; ?>">
  28      <div class="<?php echo $discussion->responses > 0 ? 'comments-title-wrap' : 'comments-title-wrap no-responses'; ?>">
  29          <h2 class="comments-title">
  30          <?php
  31          if ( comments_open() ) {
  32              if ( have_comments() ) {
  33                  _e( 'Join the Conversation', 'twentynineteen' );
  34              } else {
  35                  _e( 'Leave a comment', 'twentynineteen' );
  36              }
  37          } else {
  38              if ( '1' == $discussion->responses ) {
  39                  /* translators: %s: Post title. */
  40                  printf( _x( 'One reply on &ldquo;%s&rdquo;', 'comments title', 'twentynineteen' ), get_the_title() );
  41              } else {
  42                  printf(
  43                      /* translators: 1: Number of comments, 2: Post title. */
  44                      _nx(
  45                          '%1$s reply on &ldquo;%2$s&rdquo;',
  46                          '%1$s replies on &ldquo;%2$s&rdquo;',
  47                          $discussion->responses,
  48                          'comments title',
  49                          'twentynineteen'
  50                      ),
  51                      number_format_i18n( $discussion->responses ),
  52                      get_the_title()
  53                  );
  54              }
  55          }
  56          ?>
  57          </h2><!-- .comments-title -->
  58          <?php
  59              // Only show discussion meta information when comments are open and available.
  60          if ( have_comments() && comments_open() ) {
  61              get_template_part( 'template-parts/post/discussion', 'meta' );
  62          }
  63          ?>
  64      </div><!-- .comments-title-flex -->
  65      <?php
  66      if ( have_comments() ) :
  67  
  68          // Show comment form at top if showing newest comments at the top.
  69          if ( comments_open() ) {
  70              twentynineteen_comment_form( 'desc' );
  71          }
  72  
  73          ?>
  74          <ol class="comment-list">
  75              <?php
  76              wp_list_comments(
  77                  array(
  78                      'walker'      => new TwentyNineteen_Walker_Comment(),
  79                      'avatar_size' => twentynineteen_get_avatar_size(),
  80                      'short_ping'  => true,
  81                      'style'       => 'ol',
  82                  )
  83              );
  84              ?>
  85          </ol><!-- .comment-list -->
  86          <?php
  87  
  88          // Show comment navigation
  89          if ( have_comments() ) :
  90              $prev_icon     = twentynineteen_get_icon_svg( 'chevron_left', 22 );
  91              $next_icon     = twentynineteen_get_icon_svg( 'chevron_right', 22 );
  92              $comments_text = __( 'Comments', 'twentynineteen' );
  93              the_comments_navigation(
  94                  array(
  95                      'prev_text' => sprintf( '%s <span class="nav-prev-text"><span class="primary-text">%s</span> <span class="secondary-text">%s</span></span>', $prev_icon, __( 'Previous', 'twentynineteen' ), __( 'Comments', 'twentynineteen' ) ),
  96                      'next_text' => sprintf( '<span class="nav-next-text"><span class="primary-text">%s</span> <span class="secondary-text">%s</span></span> %s', __( 'Next', 'twentynineteen' ), __( 'Comments', 'twentynineteen' ), $next_icon ),
  97                  )
  98              );
  99          endif;
 100  
 101          // Show comment form at bottom if showing newest comments at the bottom.
 102          if ( comments_open() && 'asc' === strtolower( get_option( 'comment_order', 'asc' ) ) ) :
 103              ?>
 104              <div class="comment-form-flex">
 105                  <span class="screen-reader-text"><?php _e( 'Leave a comment', 'twentynineteen' ); ?></span>
 106                  <?php twentynineteen_comment_form( 'asc' ); ?>
 107                  <h2 class="comments-title" aria-hidden="true"><?php _e( 'Leave a comment', 'twentynineteen' ); ?></h2>
 108              </div>
 109              <?php
 110          endif;
 111  
 112          // If comments are closed and there are comments, let's leave a little note, shall we?
 113          if ( ! comments_open() ) :
 114              ?>
 115              <p class="no-comments">
 116                  <?php _e( 'Comments are closed.', 'twentynineteen' ); ?>
 117              </p>
 118              <?php
 119          endif;
 120  
 121      else :
 122  
 123          // Show comment form.
 124          twentynineteen_comment_form( true );
 125  
 126      endif; // if have_comments();
 127      ?>
 128  </div><!-- #comments -->


Generated: Wed Dec 11 01:00:03 2019 Cross-referenced by PHPXref 0.7.1