Skip to content

Commit

Permalink
refactored comment-loop
Browse files Browse the repository at this point in the history
  • Loading branch information
yankairalla committed Aug 25, 2021
1 parent a9b1491 commit d1afd62
Showing 1 changed file with 56 additions and 41 deletions.
97 changes: 56 additions & 41 deletions inc/comments-loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,33 @@ function haste_starter_comments_loop( $comment, $args, $depth ) {
switch ( $comment->comment_type ) {
case 'pingback':
case 'trackback':
?>
<li class="media post pingback">
<p><?php _e( 'Pingback:', 'haste-starter' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( 'Edit', 'haste-starter' ), '<span class="edit-link">', '</span>' ); ?></p>
<?php
haste_starter_comment_trackback();
break;
default:
?>
<li <?php comment_class( 'media' ); ?> id="li-comment-<?php comment_ID(); ?>">
<article id="div-comment-<?php comment_ID(); ?>" class="comment-body comment-author vcard">
<div class="media-meta">
<?php echo str_replace( "class='avatar", "class='media-object avatar", get_avatar( $comment, 64 ) ); ?>
<?php echo str_replace( "class='avatar", "class='media-object avatar", get_avatar( $comment, 64 ) ); ?>
<h5 class="media-author">
<?php
echo sprintf(
'<strong><span class="fn">%1$s</span></strong>',
get_comment_author_link()
);
?>
<?php
echo sprintf(
'<strong><span class="fn">%1$s</span></strong>',
get_comment_author_link()
);
?>
</h5>
<h5 class="media-date">
<?php
echo sprintf(
'<a href="%1$s"><time datetime="%2$s">%3$s %4$s </time></a>
<span class="says"> %5$s</span>',
esc_url( get_comment_link( $comment->comment_ID ) ),
get_comment_time( 'c' ),
get_comment_date(),
__( 'at', 'haste-starter' ),
get_comment_time(),
__( 'said:', 'haste-starter' )
);
?>
<?php
echo haste_starter_comment_date( $comment );
?>
</h5>
</div>
<div class="media-body">
<footer class="comment-meta">


<?php edit_comment_link( __( 'Edit comment', 'haste-starter' ), '<span class="edit-link">', ' </span>' ); ?>
<?php edit_comment_link( __( 'Edit comment', 'haste-starter' ), '<span class="edit-link">', ' </span>' ); ?>

<?php if ( '0' === $comment->comment_approved ) : ?>
<p class="comment-awaiting-moderation alert alert-info"><?php _e( 'Your comment is awaiting moderation.', 'haste-starter' ); ?></p>
<?php endif; ?>
<?php haste_starter_comment_approve( $comment ); ?>
</footer><!-- .comment-meta -->

<div class="comment-content">
Expand All @@ -67,24 +51,55 @@ function haste_starter_comments_loop( $comment, $args, $depth ) {

<div class="comment-metadata">
<span class="btn btn-outline-primary reply-link">
<?php
comment_reply_link(
array_merge(
$args,
array(
'reply_text' => __( 'Respond', 'haste-starter' ),
'depth' => $depth,
'max_depth' => $args['max_depth'],
)
<?php
comment_reply_link(
array_merge(
$args,
array(
'reply_text' => __( 'Respond', 'haste-starter' ),
'depth' => $depth,
'max_depth' => $args['max_depth'],
)
);
?>
)
);
?>
</span>
</div><!-- .comment-metadata -->
</div>
</article><!-- .comment-body -->
<?php
<?php
break;
}
}
}


function haste_starter_comment_date( $comment ) {
return sprintf(
'<a href="%1$s"><time datetime="%2$s">%3$s %4$s </time></a>
<span class="says"> %5$s</span>',
esc_url( get_comment_link( $comment->comment_ID ) ),
get_comment_time( 'c' ),
get_comment_date(),
__( 'at', 'haste-starter' ),
get_comment_time(),
__( 'said:', 'haste-starter' )
);
}


function haste_starter_comment_trackback() {
?>

<li class="media post pingback">
<p><?php _e( 'Pingback:', 'haste-starter' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( 'Edit', 'haste-starter' ), '<span class="edit-link">', '</span>' ); ?></p>
<?php
}

function haste_starter_comment_approve( $comment ) {
if ( $comment->comment_aprove ) {
?>
<p class="comment-awaiting-moderation alert alert-info"><?php _e( 'Your comment is awaiting moderation.', 'haste-starter' ); ?></p>
<?php
}
}

0 comments on commit d1afd62

Please sign in to comment.