Last active
November 3, 2019 11:32
-
-
Save ButlerFuqua/e00da85ff74b2618357419f3dd71f543 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Outputs a modified comment markup. | |
* | |
* | |
* @see wp_list_comments() | |
* | |
* @param WP_Comment $comment Comment to display. | |
* @param int $depth Depth of the current comment. | |
* @param array $args An array of arguments. | |
*/ | |
function pressfore_modify_comment_output( $comment, $depth, $args ) { | |
$tag = ( 'div' === $args['style'] ) ? 'div' : 'li'; | |
?> | |
<<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent', $comment ); ?>> | |
<article id="div-comment-<?php comment_ID(); ?>" class="comment-body"> | |
<footer class="comment-meta"> | |
<div class="comment-author vcard"> | |
<?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?> | |
<?php | |
/* translators: %s: comment author link */ | |
printf( __( '%s <span class="says">says:</span>' ), | |
sprintf( '<b class="fn">%s</b>', get_comment_author_link( $comment ) ) | |
); | |
?> | |
</div><!-- .comment-author --> | |
<div class="comment-metadata"> | |
<a href="<?php echo esc_url( get_comment_link( $comment, $args ) ); ?>"> | |
<time datetime="<?php comment_time( 'c' ); ?>"> | |
<?php | |
printf( _x( '%s ago', '%s = human-readable time difference', 'your-text-domain' ), human_time_diff( get_comment_time( 'U' ), current_time( 'timestamp' ) ) ); | |
?> | |
</time> | |
</a> | |
<?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?> | |
</div><!-- .comment-metadata --> | |
<?php if ( '0' == $comment->comment_approved ) : ?> | |
<p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></p> | |
<?php endif; ?> | |
</footer><!-- .comment-meta --> | |
<div class="comment-content"> | |
<?php comment_text(); ?> | |
<?php | |
$post_id = get_the_ID(); | |
$comment_id = get_comment_ID(); | |
//get the setting configured in the admin panel under settings discussions "Enable threaded (nested) comments levels deep" | |
$max_depth = get_option('thread_comments_depth'); | |
//add max_depth to the array and give it the value from above and set the depth to 1 | |
$default = array( | |
'add_below' => 'comment', | |
'respond_id' => 'respond', | |
'reply_text' => __('Reply'), | |
'login_text' => __('Log in to Reply'), | |
'depth' => 1, | |
'before' => '', | |
'after' => '', | |
'max_depth' => $max_depth | |
); | |
comment_reply_link($default, $comment_id, $post_id); | |
?> | |
</div><!-- .comment-content --> | |
</article><!-- .comment-body --> | |
<?php | |
} | |
<?php | |
wp_list_comments(array( | |
'style' => 'ol', | |
'short_ping' => true, | |
'callback' => 'pressfore_modify_comment_output' | |
)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment