[ 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-wrap -->
  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 comment-form-wrapper">
 105                  <h2 class="comments-title"><?php _e( 'Leave a comment', 'twentynineteen' ); ?></h2>
 106                  <?php twentynineteen_comment_form( 'asc' ); ?>
 107              </div>
 108              <?php
 109          endif;
 110  
 111          // If comments are closed and there are comments, let's leave a little note, shall we?
 112          if ( ! comments_open() ) :
 113              ?>
 114              <p class="no-comments">
 115                  <?php _e( 'Comments are closed.', 'twentynineteen' ); ?>
 116              </p>
 117              <?php
 118          endif;
 119  
 120      else :
 121  
 122          // Show comment form.
 123          twentynineteen_comment_form( true );
 124  
 125      endif; // if have_comments();
 126      ?>
 127  </div><!-- #comments -->


Generated: Tue Nov 12 01:00:02 2024 Cross-referenced by PHPXref 0.7.1