Created
May 13, 2022 13:40
-
-
Save wpdew/3b0403a272a939c9a1b98f2f5a74c422 to your computer and use it in GitHub Desktop.
Customizing Comment form WordPress
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
<?php | |
/** | |
* Comment Style Callback | |
*/ | |
function fuji_comment_callback($comment, $args, $depth) { | |
$GLOBALS['comment'] = $comment; | |
extract($args, EXTR_SKIP); | |
if ( 'div' == $args['style'] ) { | |
$tag = 'div'; | |
$add_below = 'comment'; | |
} else { | |
$tag = '<li'; | |
$add_below = 'div-comment'; | |
} | |
?> | |
<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>"> | |
<?php if ( 'div' != $args['style'] ) : ?> | |
<div id="div-comment-<?php comment_ID() ?>" class="comment-body"> | |
<?php endif; ?> | |
<div class="comment-meta-custom"> | |
<div class="comment-author vcard"> | |
<?php if ( $args['avatar_size'] != 0 ) echo get_avatar( $comment, $args['avatar_size'] ); ?> | |
</div> | |
<cite class="fn"><?php echo get_comment_author_link();?></cite> | |
<?php if ( $comment->comment_approved == '0' ) : ?> | |
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em> | |
<br /> | |
<?php endif; ?> | |
<div class="comment-meta commentmetadata"> | |
<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>"></a> | |
<?php | |
/* translators: 1: date, 2: time */ | |
printf( __('%1$s'), get_comment_date('M d Y') ); ?></a><?php edit_comment_link( __( '(Edit)' ), ' ', '' ); | |
?> | |
</div> | |
</div> | |
<div class="comment-content-custom"> | |
<?php comment_text(); ?> | |
</div> | |
<?php if( is_user_logged_in() ) : ?> | |
<div class="reply"> | |
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> | |
</div> | |
<?php else : ?> | |
<div class="reply"> | |
<a href="javascript:void(0);" class="not-logged-in-user"><?php _e('Reply', '_cpm');?></a> | |
</div> | |
<?php endif; ?> | |
<?php if ( 'div' != $args['style'] ) : ?> | |
</div> | |
<?php endif; ?> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment