[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-content/themes/twentynineteen/classes/ -> class-twentynineteen-walker-comment.php (source)

   1  <?php
   2  /**
   3   * Custom comment walker for this theme
   4   *
   5   * @package WordPress
   6   * @subpackage Twenty_Nineteen
   7   * @since 1.0.0
   8   */
   9  
  10  /**
  11   * This class outputs custom comment walker for HTML5 friendly WordPress comment and threaded replies.
  12   *
  13   * @since 1.0.0
  14   */
  15  class TwentyNineteen_Walker_Comment extends Walker_Comment {
  16  
  17      /**
  18       * Outputs a comment in the HTML5 format.
  19       *
  20       * @see wp_list_comments()
  21       *
  22       * @param WP_Comment $comment Comment to display.
  23       * @param int        $depth   Depth of the current comment.
  24       * @param array      $args    An array of arguments.
  25       */
  26  	protected function html5_comment( $comment, $depth, $args ) {
  27  
  28          $tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
  29  
  30          ?>
  31          <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?>>
  32              <article id="div-comment-<?php comment_ID(); ?>" class="comment-body">
  33                  <footer class="comment-meta">
  34                      <div class="comment-author vcard">
  35                          <?php
  36                          $comment_author_url = get_comment_author_url( $comment );
  37                          $comment_author     = get_comment_author( $comment );
  38                          $avatar             = get_avatar( $comment, $args['avatar_size'] );
  39                          if ( 0 != $args['avatar_size'] ) {
  40                              if ( empty( $comment_author_url ) ) {
  41                                  echo $avatar;
  42                              } else {
  43                                  printf( '<a href="%s" rel="external nofollow" class="url">', $comment_author_url );
  44                                  echo $avatar;
  45                              }
  46                          }
  47  
  48                          /*
  49                           * Using the `check` icon instead of `check_circle`, since we can't add a
  50                           * fill color to the inner check shape when in circle form.
  51                           */
  52                          if ( twentynineteen_is_comment_by_post_author( $comment ) ) {
  53                              printf( '<span class="post-author-badge" aria-hidden="true">%s</span>', twentynineteen_get_icon_svg( 'check', 24 ) );
  54                          }
  55  
  56                          printf(
  57                              wp_kses(
  58                                  /* translators: %s: Comment author link. */
  59                                  __( '%s <span class="screen-reader-text says">says:</span>', 'twentynineteen' ),
  60                                  array(
  61                                      'span' => array(
  62                                          'class' => array(),
  63                                      ),
  64                                  )
  65                              ),
  66                              '<b class="fn">' . $comment_author . '</b>'
  67                          );
  68  
  69                          if ( ! empty( $comment_author_url ) ) {
  70                              echo '</a>';
  71                          }
  72                          ?>
  73                      </div><!-- .comment-author -->
  74  
  75                      <div class="comment-metadata">
  76                          <a href="<?php echo esc_url( get_comment_link( $comment, $args ) ); ?>">
  77                              <?php
  78                                  /* translators: 1: Comment date, 2: Comment time. */
  79                                  $comment_timestamp = sprintf( __( '%1$s at %2$s', 'twentynineteen' ), get_comment_date( '', $comment ), get_comment_time() );
  80                              ?>
  81                              <time datetime="<?php comment_time( 'c' ); ?>" title="<?php echo $comment_timestamp; ?>">
  82                                  <?php echo $comment_timestamp; ?>
  83                              </time>
  84                          </a>
  85                          <?php
  86                              $edit_comment_icon = twentynineteen_get_icon_svg( 'edit', 16 );
  87                              edit_comment_link( __( 'Edit', 'twentynineteen' ), '<span class="edit-link-sep">&mdash;</span> <span class="edit-link">' . $edit_comment_icon, '</span>' );
  88                          ?>
  89                      </div><!-- .comment-metadata -->
  90  
  91                      <?php
  92                      $commenter = wp_get_current_commenter();
  93                      if ( $commenter['comment_author_email'] ) {
  94                          $moderation_note = __( 'Your comment is awaiting moderation.', 'twentynineteen' );
  95                      } else {
  96                          $moderation_note = __( 'Your comment is awaiting moderation. This is a preview, your comment will be visible after it has been approved.', 'twentynineteen' );
  97                      }
  98                      ?>
  99  
 100                      <?php if ( '0' == $comment->comment_approved ) : ?>
 101                      <p class="comment-awaiting-moderation"><?php echo $moderation_note; ?></p>
 102                      <?php endif; ?>
 103  
 104                  </footer><!-- .comment-meta -->
 105  
 106                  <div class="comment-content">
 107                      <?php comment_text(); ?>
 108                  </div><!-- .comment-content -->
 109  
 110              </article><!-- .comment-body -->
 111  
 112              <?php
 113              comment_reply_link(
 114                  array_merge(
 115                      $args,
 116                      array(
 117                          'add_below' => 'div-comment',
 118                          'depth'     => $depth,
 119                          'max_depth' => $args['max_depth'],
 120                          'before'    => '<div class="comment-reply">',
 121                          'after'     => '</div>',
 122                      )
 123                  )
 124              );
 125              ?>
 126          <?php
 127      }
 128  }


Generated: Tue Oct 22 08:20:01 2019 Cross-referenced by PHPXref 0.7