[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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' === (string) $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              the_comments_navigation(
  93                  array(
  94                      'prev_text' => sprintf(
  95                          '%1$s <span class="nav-prev-text">%2$s</span>',
  96                          $prev_icon,
  97                          /* translators: Comments navigation link text. The secondary-text element is hidden on small screens. */
  98                          __( '<span class="primary-text">Previous</span> <span class="secondary-text">Comments</span>', 'twentynineteen' )
  99                      ),
 100                      'next_text' => sprintf(
 101                          '<span class="nav-next-text">%1$s</span> %2$s',
 102                          /* translators: Comments navigation link text. The secondary-text element is hidden on small screens. */
 103                          __( '<span class="primary-text">Next</span> <span class="secondary-text">Comments</span>', 'twentynineteen' ),
 104                          $next_icon
 105                      ),
 106                  )
 107              );
 108          endif;
 109  
 110          // Show comment form at bottom if showing newest comments at the bottom.
 111          if ( comments_open() && 'asc' === strtolower( get_option( 'comment_order', 'asc' ) ) ) :
 112              ?>
 113              <div class="comment-form-flex comment-form-wrapper">
 114                  <h2 class="comments-title"><?php _e( 'Leave a comment', 'twentynineteen' ); ?></h2>
 115                  <?php twentynineteen_comment_form( 'asc' ); ?>
 116              </div>
 117              <?php
 118          endif;
 119  
 120          // If comments are closed and there are comments, let's leave a little note, shall we?
 121          if ( ! comments_open() ) :
 122              ?>
 123              <p class="no-comments">
 124                  <?php _e( 'Comments are closed.', 'twentynineteen' ); ?>
 125              </p>
 126              <?php
 127          endif;
 128  
 129      else :
 130  
 131          // Show comment form.
 132          twentynineteen_comment_form( true );
 133  
 134      endif; // if have_comments();
 135      ?>
 136  </div><!-- #comments -->


Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref