Add echo arguments to wp_list_comments() and Walker_Comment, allowing non-echo usage.
props mikelittle. fixes #10948. Built from https://develop.svn.wordpress.org/trunk@26353 git-svn-id: http://core.svn.wordpress.org/trunk@26254 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fd14a5df71
commit
808653e2a3
|
@ -1517,11 +1517,11 @@ class Walker_Comment extends Walker {
|
||||||
case 'div':
|
case 'div':
|
||||||
break;
|
break;
|
||||||
case 'ol':
|
case 'ol':
|
||||||
echo '<ol class="children">' . "\n";
|
$output .= '<ol class="children">' . "\n";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case 'ul':
|
case 'ul':
|
||||||
echo '<ul class="children">' . "\n";
|
$output .= '<ul class="children">' . "\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1544,11 +1544,11 @@ class Walker_Comment extends Walker {
|
||||||
case 'div':
|
case 'div':
|
||||||
break;
|
break;
|
||||||
case 'ol':
|
case 'ol':
|
||||||
echo "</ol><!-- .children -->\n";
|
$output .= "</ol><!-- .children -->\n";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case 'ul':
|
case 'ul':
|
||||||
echo "</ul><!-- .children -->\n";
|
$output .= "</ul><!-- .children -->\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1623,16 +1623,24 @@ class Walker_Comment extends Walker {
|
||||||
$GLOBALS['comment'] = $comment;
|
$GLOBALS['comment'] = $comment;
|
||||||
|
|
||||||
if ( !empty( $args['callback'] ) ) {
|
if ( !empty( $args['callback'] ) ) {
|
||||||
|
ob_start();
|
||||||
call_user_func( $args['callback'], $comment, $args, $depth );
|
call_user_func( $args['callback'], $comment, $args, $depth );
|
||||||
|
$output .= ob_get_clean();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) && $args['short_ping'] ) {
|
if ( ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) && $args['short_ping'] ) {
|
||||||
|
ob_start();
|
||||||
$this->ping( $comment, $depth, $args );
|
$this->ping( $comment, $depth, $args );
|
||||||
|
$output .= ob_get_clean();
|
||||||
} elseif ( 'html5' === $args['format'] ) {
|
} elseif ( 'html5' === $args['format'] ) {
|
||||||
|
ob_start();
|
||||||
$this->html5_comment( $comment, $depth, $args );
|
$this->html5_comment( $comment, $depth, $args );
|
||||||
|
$output .= ob_get_clean();
|
||||||
} else {
|
} else {
|
||||||
|
ob_start();
|
||||||
$this->comment( $comment, $depth, $args );
|
$this->comment( $comment, $depth, $args );
|
||||||
|
$output .= ob_get_clean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1650,13 +1658,15 @@ class Walker_Comment extends Walker {
|
||||||
*/
|
*/
|
||||||
function end_el( &$output, $comment, $depth = 0, $args = array() ) {
|
function end_el( &$output, $comment, $depth = 0, $args = array() ) {
|
||||||
if ( !empty( $args['end-callback'] ) ) {
|
if ( !empty( $args['end-callback'] ) ) {
|
||||||
|
ob_start();
|
||||||
call_user_func( $args['end-callback'], $comment, $args, $depth );
|
call_user_func( $args['end-callback'], $comment, $args, $depth );
|
||||||
|
$output .= ob_get_clean();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( 'div' == $args['style'] )
|
if ( 'div' == $args['style'] )
|
||||||
echo "</div><!-- #comment-## -->\n";
|
$output .= "</div><!-- #comment-## -->\n";
|
||||||
else
|
else
|
||||||
echo "</li><!-- #comment-## -->\n";
|
$output .= "</li><!-- #comment-## -->\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1801,6 +1811,7 @@ class Walker_Comment extends Walker {
|
||||||
* @type string 'format' How to format the comments list.
|
* @type string 'format' How to format the comments list.
|
||||||
* Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
|
* Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
|
||||||
* @type bool 'short_ping' Whether to output short pings. Default false.
|
* @type bool 'short_ping' Whether to output short pings. Default false.
|
||||||
|
* @type bool 'echo' Whether to echo the output or return it. Default true.
|
||||||
* }
|
* }
|
||||||
* @param array $comments Optional. Array of comment objects. @see WP_Query->comments
|
* @param array $comments Optional. Array of comment objects. @see WP_Query->comments
|
||||||
*/
|
*/
|
||||||
|
@ -1826,6 +1837,7 @@ function wp_list_comments( $args = array(), $comments = null ) {
|
||||||
'reverse_children' => '',
|
'reverse_children' => '',
|
||||||
'format' => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml',
|
'format' => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml',
|
||||||
'short_ping' => false,
|
'short_ping' => false,
|
||||||
|
'echo' => true,
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = wp_parse_args( $args, $defaults );
|
$r = wp_parse_args( $args, $defaults );
|
||||||
|
@ -1894,10 +1906,15 @@ function wp_list_comments( $args = array(), $comments = null ) {
|
||||||
if ( empty($walker) )
|
if ( empty($walker) )
|
||||||
$walker = new Walker_Comment;
|
$walker = new Walker_Comment;
|
||||||
|
|
||||||
$walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
|
$output = $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
|
||||||
$wp_query->max_num_comment_pages = $walker->max_pages;
|
$wp_query->max_num_comment_pages = $walker->max_pages;
|
||||||
|
|
||||||
$in_comment_loop = false;
|
$in_comment_loop = false;
|
||||||
|
|
||||||
|
if ( $r['echo'] )
|
||||||
|
echo $output;
|
||||||
|
else
|
||||||
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue