Created
June 29, 2011 19:43
-
-
Save thefuxia/1054730 to your computer and use it in GitHub Desktop.
Sample Comment Walker for WordPress
This file contains hidden or 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 | |
/** | |
* Callback for wp_list_comments() | |
* @param object $comment | |
* @param array $args | |
* @param int $depth | |
* @return void | |
*/ | |
function extra_comment_callback( $comment, $args, $depth ) | |
{ | |
$GLOBALS['comment'] = $comment; | |
?> | |
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>"> | |
<div id="comment-<?php comment_ID(); ?>"> | |
<?php if ( $comment->comment_approved == '0' ) | |
{ | |
?> | |
<p class="approval-notice"><?php | |
print get_theme_mod( | |
'text_moderation_notice' | |
, 'Ihr Kommentar wird moderiert. Bitte haben Sie etwas Geduld.' | |
); | |
?></p> | |
<?php | |
} | |
if ( 'pingback' == $comment->comment_type or 'trackback' == $comment->comment_type ) | |
{ | |
#pre_dump( $comment ); | |
print 'Link: ' . get_comment_author_link( get_comment_ID() ); | |
edit_comment_link( 'Bearbeiten', ' · ' ); | |
comment_text( get_comment_ID() ); | |
} | |
else | |
{ | |
comment_text( get_comment_ID() ); | |
?> | |
<div class="comment-author vcard reply"> | |
<?php comment_author_link(); ?> | | |
<?php printf( '%1$s | %2$s', get_comment_date(), get_comment_time() ); | |
if ( 0 == $depth || $args['max_depth'] <= $depth ) | |
{ | |
$depth += 1; | |
$args['max_depth'] +=2; | |
} | |
comment_reply_link( | |
array_merge( | |
$args, | |
array( | |
'depth' => $depth | |
, 'max_depth' => $args['max_depth'] | |
, 'before' => ' | ' | |
, 'after' => '' | |
) | |
) | |
); | |
edit_comment_link( 'Bearbeiten', ' | ' ); | |
?> | |
</div> | |
<?php | |
} | |
?> | |
</div> | |
<?php | |
// the closing </li> will be inserted by WordPress. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See http://blog.zdf.de/hyperland/2011/06/dieter-gorny-wir-muessen-reden/#comments for a live example.