Skip to content

Instantly share code, notes, and snippets.

@tylersticka
Created January 9, 2012 23:00
Show Gist options
  • Save tylersticka/1585484 to your computer and use it in GitHub Desktop.
Save tylersticka/1585484 to your computer and use it in GitHub Desktop.
Sample WP comment callback function
<?php
function tsticka14_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
// I kind of cheat here by not doing anything for pingbacks
// and trackbacks, which means the amount of stuff that
// displays may differ from the comment count unless
// pingbacks and trackbacks are disabled in the admin.
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
break;
default :
$is_post_author = ( $comment->comment_author_email == get_the_author_email() );
$is_tyler = ( $is_post_author && $comment->comment_author_email == 'fake@email.com' );
?>
<article class="post post-comment" id="comment-<?php comment_ID(); ?>">
<figure class="supporting">
<?php echo get_avatar( $comment, 68, get_bloginfo( 'template_directory' ) . '/img/avatar-default.png' ); //68 ?>
</figure>
<div class="primary content">
<header>
<h4<?php if ( $is_tyler ) : ?> class="icon-pre icon-verified"<?php endif; ?>><?php comment_author_link(); ?> says</h4>
</header>
<?php //echo wptexturize( Markdown( get_comment_text() ) ); ?>
<?php comment_text(); ?>
</div>
<footer class="primary meta note">
<?php if ( $comment->comment_approved == '0' ) : ?>
<p><span class="important"><strong>Thanks!</strong> Your response is awaiting moderation.</span></p>
<?php else : ?>
<p>Responded <time pubdate datetime="<?php comment_time('Y-m-d\TH:i'); ?>"><?php comment_time('F j, Y \a\t g:ia'); ?> <span class="human-time-diff">(<?php echo human_time_diff_years( get_comment_time('U'), current_time('timestamp') ); ?> ago)</span></time></p>
<?php endif; ?>
</footer>
</article>
<?php break;
endswitch;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment