PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php

https://gitlab.com/VTTE/sitios-vtte
PHP | 114 lines | 73 code | 13 blank | 28 comment | 8 complexity | 9fc73fa0a7d497b05821ae289d257065 MD5 | raw file
  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. * This class outputs custom comment walker for HTML5 friendly WordPress comment and threaded replies.
  11. *
  12. * @since 1.0.0
  13. */
  14. class TwentyNineteen_Walker_Comment extends Walker_Comment {
  15. /**
  16. * Outputs a comment in the HTML5 format.
  17. *
  18. * @see wp_list_comments()
  19. *
  20. * @param WP_Comment $comment Comment to display.
  21. * @param int $depth Depth of the current comment.
  22. * @param array $args An array of arguments.
  23. */
  24. protected function html5_comment( $comment, $depth, $args ) {
  25. $tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
  26. ?>
  27. <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?>>
  28. <article id="div-comment-<?php comment_ID(); ?>" class="comment-body">
  29. <footer class="comment-meta">
  30. <div class="comment-author vcard">
  31. <?php
  32. $comment_author_link = get_comment_author_link( $comment );
  33. $comment_author_url = get_comment_author_url( $comment );
  34. $comment_author = get_comment_author( $comment );
  35. $avatar = get_avatar( $comment, $args['avatar_size'] );
  36. if ( 0 != $args['avatar_size'] ) {
  37. if ( empty( $comment_author_url ) ) {
  38. echo $avatar;
  39. } else {
  40. printf( '<a href="%s" rel="external nofollow" class="url">', $comment_author_url );
  41. echo $avatar;
  42. }
  43. }
  44. /*
  45. * Using the `check` icon instead of `check_circle`, since we can't add a
  46. * fill color to the inner check shape when in circle form.
  47. */
  48. if ( twentynineteen_is_comment_by_post_author( $comment ) ) {
  49. /* translators: %s: SVG Icon */
  50. printf( '<span class="post-author-badge" aria-hidden="true">%s</span>', twentynineteen_get_icon_svg( 'check', 24 ) );
  51. }
  52. printf(
  53. /* translators: %s: comment author link */
  54. __( '%s <span class="screen-reader-text says">says:</span>', 'twentynineteen' ),
  55. sprintf( '<span class="fn">%s</span>', $comment_author )
  56. );
  57. if ( ! empty( $comment_author_url ) ) {
  58. echo '</a>';
  59. }
  60. ?>
  61. </div><!-- .comment-author -->
  62. <div class="comment-metadata">
  63. <a href="<?php echo esc_url( get_comment_link( $comment, $args ) ); ?>">
  64. <?php
  65. /* translators: 1: comment date, 2: comment time */
  66. $comment_timestamp = sprintf( __( '%1$s at %2$s', 'twentynineteen' ), get_comment_date( '', $comment ), get_comment_time() );
  67. ?>
  68. <time datetime="<?php comment_time( 'c' ); ?>" title="<?php echo $comment_timestamp; ?>">
  69. <?php echo $comment_timestamp; ?>
  70. </time>
  71. </a>
  72. <?php
  73. $edit_comment_icon = twentynineteen_get_icon_svg( 'edit', 16 );
  74. edit_comment_link( __( 'Edit', 'twentynineteen' ), '<span class="edit-link-sep">&mdash;</span> <span class="edit-link">' . $edit_comment_icon, '</span>' );
  75. ?>
  76. </div><!-- .comment-metadata -->
  77. <?php if ( '0' == $comment->comment_approved ) : ?>
  78. <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentynineteen' ); ?></p>
  79. <?php endif; ?>
  80. </footer><!-- .comment-meta -->
  81. <div class="comment-content">
  82. <?php comment_text(); ?>
  83. </div><!-- .comment-content -->
  84. </article><!-- .comment-body -->
  85. <?php
  86. comment_reply_link(
  87. array_merge(
  88. $args,
  89. array(
  90. 'add_below' => 'div-comment',
  91. 'depth' => $depth,
  92. 'max_depth' => $args['max_depth'],
  93. 'before' => '<div class="comment-reply">',
  94. 'after' => '</div>',
  95. )
  96. )
  97. );
  98. ?>
  99. <?php
  100. }
  101. }