[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Custom comment walker for this theme.
   4   *
   5   * @package WordPress
   6   * @subpackage Twenty_Twenty
   7   * @since 1.0.0
   8   */
   9  
  10  if ( ! class_exists( 'TwentyTwenty_Walker_Comment' ) ) {
  11      /**
  12       * CUSTOM COMMENT WALKER
  13       * A custom walker for comments, based on the walker in Twenty Nineteen.
  14       */
  15      class TwentyTwenty_Walker_Comment extends Walker_Comment {
  16  
  17          /**
  18           * Outputs a comment in the HTML5 format.
  19           *
  20           * @see wp_list_comments()
  21           * @see https://developer.wordpress.org/reference/functions/get_comment_author_url/
  22           * @see https://developer.wordpress.org/reference/functions/get_comment_author/
  23           * @see https://developer.wordpress.org/reference/functions/get_avatar/
  24           * @see https://developer.wordpress.org/reference/functions/get_comment_reply_link/
  25           * @see https://developer.wordpress.org/reference/functions/get_edit_comment_link/
  26           *
  27           * @param WP_Comment $comment Comment to display.
  28           * @param int        $depth   Depth of the current comment.
  29           * @param array      $args    An array of arguments.
  30           */
  31  		protected function html5_comment( $comment, $depth, $args ) {
  32  
  33              $tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
  34  
  35              ?>
  36              <<?php echo $tag; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?>>
  37                  <article id="div-comment-<?php comment_ID(); ?>" class="comment-body">
  38                      <footer class="comment-meta">
  39                          <div class="comment-author vcard">
  40                              <?php
  41                              $comment_author_url = get_comment_author_url( $comment );
  42                              $comment_author     = get_comment_author( $comment );
  43                              $avatar             = get_avatar( $comment, $args['avatar_size'] );
  44                              if ( 0 !== $args['avatar_size'] ) {
  45                                  if ( empty( $comment_author_url ) ) {
  46                                      echo wp_kses_post( $avatar );
  47                                  } else {
  48                                      printf( '<a href="%s" rel="external nofollow" class="url">', $comment_author_url ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped --Escaped in https://developer.wordpress.org/reference/functions/get_comment_author_url/
  49                                      echo wp_kses_post( $avatar );
  50                                  }
  51                              }
  52  
  53                              printf(
  54                                  '<span class="fn">%1$s</span><span class="screen-reader-text says">%2$s</span>',
  55                                  esc_html( $comment_author ),
  56                                  __( 'says:', 'twentytwenty' )
  57                              );
  58  
  59                              if ( ! empty( $comment_author_url ) ) {
  60                                  echo '</a>';
  61                              }
  62                              ?>
  63                          </div><!-- .comment-author -->
  64  
  65                          <div class="comment-metadata">
  66                              <a href="<?php echo esc_url( get_comment_link( $comment, $args ) ); ?>">
  67                                  <?php
  68                                  /* Translators: 1 = comment date, 2 = comment time */
  69                                  $comment_timestamp = sprintf( __( '%1$s at %2$s', 'twentytwenty' ), get_comment_date( '', $comment ), get_comment_time() );
  70                                  ?>
  71                                  <time datetime="<?php comment_time( 'c' ); ?>" title="<?php echo esc_attr( $comment_timestamp ); ?>">
  72                                      <?php echo esc_html( $comment_timestamp ); ?>
  73                                  </time>
  74                              </a>
  75                              <?php
  76                              if ( get_edit_comment_link() ) {
  77                                  echo ' <span aria-hidden="true">&bull;</span> <a class="comment-edit-link" href="' . esc_url( get_edit_comment_link() ) . '">' . __( 'Edit', 'twentytwenty' ) . '</a>';
  78                              }
  79                              ?>
  80                          </div><!-- .comment-metadata -->
  81  
  82                      </footer><!-- .comment-meta -->
  83  
  84                      <div class="comment-content entry-content">
  85  
  86                          <?php
  87  
  88                          comment_text();
  89  
  90                          if ( '0' === $comment->comment_approved ) {
  91                              ?>
  92                              <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentytwenty' ); ?></p>
  93                              <?php
  94                          }
  95  
  96                          ?>
  97  
  98                      </div><!-- .comment-content -->
  99  
 100                      <?php
 101  
 102                      $comment_reply_link = get_comment_reply_link(
 103                          array_merge(
 104                              $args,
 105                              array(
 106                                  'add_below' => 'div-comment',
 107                                  'depth'     => $depth,
 108                                  'max_depth' => $args['max_depth'],
 109                                  'before'    => '<span class="comment-reply">',
 110                                  'after'     => '</span>',
 111                              )
 112                          )
 113                      );
 114  
 115                      $by_post_author = twentytwenty_is_comment_by_post_author( $comment );
 116  
 117                      if ( $comment_reply_link || $by_post_author ) {
 118                          ?>
 119  
 120                          <footer class="comment-footer-meta">
 121  
 122                              <?php
 123                              if ( $comment_reply_link ) {
 124                                  echo $comment_reply_link; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped --Link is escaped in https://developer.wordpress.org/reference/functions/get_comment_reply_link/
 125                              }
 126                              if ( $by_post_author ) {
 127                                  echo '<span class="by-post-author">' . __( 'By Post Author', 'twentytwenty' ) . '</span>';
 128                              }
 129                              ?>
 130  
 131                          </footer>
 132  
 133                          <?php
 134                      }
 135                      ?>
 136  
 137                  </article><!-- .comment-body -->
 138  
 139              <?php
 140          }
 141      }
 142  }


Generated: Tue Nov 12 01:00:03 2019 Cross-referenced by PHPXref 0.7.1