Threaded comments improvements from DD32. see #7635

git-svn-id: http://svn.automattic.com/wordpress/trunk@8876 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-09-12 19:18:39 +00:00
parent 3c789c1cb3
commit 5e8c59bea7

View File

@ -878,17 +878,31 @@ class Walker_Comment extends Walker {
var $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID'); var $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID');
function start_lvl(&$output, $depth, $args) { function start_lvl(&$output, $depth, $args) {
if ( 'div' == $args['style'] ) switch ( $args['style'] ) {
return; case 'div':
break;
echo "<ul class='children'>\n"; case 'ol':
echo "<ol class='children'>\n";
break;
default:
case 'ul':
echo "<ul class='children'>\n";
break;
}
} }
function end_lvl(&$output, $depth, $args) { function end_lvl(&$output, $depth, $args) {
if ( 'div' == $args['style'] ) switch ( $args['style'] ) {
return; case 'div':
break;
echo "</ul>\n"; case 'ol':
echo "</ol>\n";
break;
default:
case 'ul':
echo "</ul>\n";
break;
}
} }
function start_el(&$output, $comment, $depth, $args) { function start_el(&$output, $comment, $depth, $args) {
@ -907,7 +921,7 @@ class Walker_Comment extends Walker {
else else
$tag = 'li'; $tag = 'li';
?> ?>
<<?php echo $tag ?> "<?php comment_class() ?>" id="comment-<?php comment_ID() ?>"> <<?php echo $tag ?> <?php comment_class() ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'list' == $args['style'] ) : ?> <?php if ( 'list' == $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>"> <div id="div-comment-<?php comment_ID() ?>">
<?php endif; ?> <?php endif; ?>
@ -925,7 +939,7 @@ class Walker_Comment extends Walker {
<?php echo apply_filters('comment_text', get_comment_text()) ?> <?php echo apply_filters('comment_text', get_comment_text()) ?>
<div class='reply'> <div class='reply'>
<?php if ( $depth < $args['depth'] ) echo comment_reply_link(array('add_below' => 'div-comment')) ?> <?php if ( 0 == $args['depth'] || $depth < $args['depth'] ) echo comment_reply_link(array('add_below' => 'div-comment')) ?>
<?php if ( 'list' == $args['style'] ) : ?> <?php if ( 'list' == $args['style'] ) : ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
@ -934,6 +948,10 @@ class Walker_Comment extends Walker {
} }
function end_el(&$output, $comment, $depth, $args) { function end_el(&$output, $comment, $depth, $args) {
if ( !empty($args['end-callback']) ) {
call_user_func($args['end-callback'], $comment, $args, $depth);
return;
}
if ( 'div' == $args['style'] ) if ( 'div' == $args['style'] )
echo "</div>\n"; echo "</div>\n";
else else
@ -954,7 +972,7 @@ class Walker_Comment extends Walker {
* @param $args string|array Additional arguments * @param $args string|array Additional arguments
*/ */
function wp_list_comments(&$comments, $args = array() ) { function wp_list_comments(&$comments, $args = array() ) {
$defaults = array('walker' => null, 'depth' => 3, 'style' => 'list', 'callback' => null); $defaults = array('walker' => null, 'depth' => 3, 'style' => 'ul', 'callback' => null, 'end-callback' => null);
$r = wp_parse_args( $args, $defaults ); $r = wp_parse_args( $args, $defaults );