Make WordPress Core

Changeset 8962


Ignore:
Timestamp:
09/24/2008 04:45:50 AM (16 years ago)
Author:
ryan
Message:

Add thread alt classes. see #7635

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment-template.php

    r8961 r8962  
    248248 */
    249249function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
    250     static $comment_alt;
     250    global $comment_alt, $comment_depth, $comment_thread_alt;
    251251
    252252    $comment = get_comment($comment_id);
     
    270270    if ( empty($comment_alt) )
    271271        $comment_alt = 0;
     272    if ( empty($comment_depth) )
     273        $comment_depth = 1;
     274    if ( empty($comment_thread_alt) )
     275        $comment_thread_alt = 0;
    272276
    273277    if ( $comment_alt % 2 ) {
     
    279283
    280284    $comment_alt++;
     285
     286    // Alt for top-level comments
     287    if ( 1 == $comment_depth ) {
     288        if ( $comment_thread_alt % 2 ) {
     289            $classes[] = 'thread-odd';
     290            $classes[] = 'thread-alt';
     291        } else {
     292            $classes[] = 'thread-even';
     293        }
     294        $comment_thread_alt++;
     295    }
     296
     297    $classes[] = "depth-$comment_depth";
    281298
    282299    if ( !empty($class) ) {
     
    883900
    884901    function start_lvl(&$output, $depth, $args) {
     902        $GLOBALS['comment_depth'] = $depth + 1;
     903
    885904        switch ( $args['style'] ) {
    886905            case 'div':
     
    897916
    898917    function end_lvl(&$output, $depth, $args) {
     918        $GLOBALS['comment_depth'] = $depth + 1;
     919
    899920        switch ( $args['style'] ) {
    900921            case 'div':
     
    912933    function start_el(&$output, $comment, $depth, $args) {
    913934        $depth++;
     935        $GLOBALS['comment_depth'] = $depth;
    914936
    915937        if ( !empty($args['callback']) ) {
     
    921943        extract($args, EXTR_SKIP);
    922944
    923         if ( 'div' == $args['style'] )
     945        if ( 'div' == $args['style'] ) {
    924946            $tag = 'div';
    925         else
     947            $add_below = 'comment';
     948        } else {
    926949            $tag = 'li';
     950            $add_below = 'div-comment';
     951        }
    927952?>
    928953        <<?php echo $tag ?> <?php comment_class() ?> id="comment-<?php comment_ID() ?>">
     
    944969
    945970        <div class='reply'>
    946         <?php echo comment_reply_link(array('add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['depth'])) ?>
     971        <?php echo comment_reply_link(array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['depth'])) ?>
    947972        <?php if ( 'list' == $args['style'] ) : ?>
    948973        </div>
     
    9771002 */
    9781003function wp_list_comments($args = array(), $comments = null ) {
    979     global $wp_query;
     1004    global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt;
     1005
     1006    $comment_alt = $comment_thread_alt = 0;
     1007    $comment_depth = 1;
    9801008
    9811009    $defaults = array('walker' => null, 'depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all',
Note: See TracChangeset for help on using the changeset viewer.