[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Custom comment walker for this theme 4 * 5 * @package WordPress 6 * @subpackage Twenty_Nineteen 7 * @since Twenty Nineteen 1.0 8 */ 9 10 /** 11 * This class outputs custom comment walker for HTML5 friendly WordPress comment and threaded replies. 12 * 13 * @since Twenty Nineteen 1.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 !== (int) $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 <?php 77 /* translators: 1: Comment date, 2: Comment time. */ 78 $comment_timestamp = sprintf( __( '%1$s at %2$s', 'twentynineteen' ), get_comment_date( '', $comment ), get_comment_time() ); 79 80 printf( 81 '<a href="%s"><time datetime="%s">%s</time></a>', 82 esc_url( get_comment_link( $comment, $args ) ), 83 get_comment_time( 'c' ), 84 $comment_timestamp 85 ); 86 87 $edit_comment_icon = twentynineteen_get_icon_svg( 'edit', 16 ); 88 edit_comment_link( __( 'Edit', 'twentynineteen' ), ' <span class="edit-link-sep">—</span> <span class="edit-link">' . $edit_comment_icon, '</span>' ); 89 ?> 90 </div><!-- .comment-metadata --> 91 92 <?php 93 $commenter = wp_get_current_commenter(); 94 if ( $commenter['comment_author_email'] ) { 95 $moderation_note = __( 'Your comment is awaiting moderation.', 'twentynineteen' ); 96 } else { 97 $moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.', 'twentynineteen' ); 98 } 99 ?> 100 101 <?php if ( '0' === $comment->comment_approved ) : ?> 102 <p class="comment-awaiting-moderation"><?php echo $moderation_note; ?></p> 103 <?php endif; ?> 104 105 </footer><!-- .comment-meta --> 106 107 <div class="comment-content"> 108 <?php comment_text(); ?> 109 </div><!-- .comment-content --> 110 111 </article><!-- .comment-body --> 112 113 <?php 114 comment_reply_link( 115 array_merge( 116 $args, 117 array( 118 'add_below' => 'div-comment', 119 'depth' => $depth, 120 'max_depth' => $args['max_depth'], 121 'before' => '<div class="comment-reply">', 122 'after' => '</div>', 123 ) 124 ) 125 ); 126 ?> 127 <?php 128 } 129 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Dec 21 08:20:01 2024 | Cross-referenced by PHPXref |