Skip to:
Content

bbPress.org

Changeset 6317


Ignore:
Timestamp:
02/26/2017 08:15:20 AM (9 years ago)
Author:
johnjamesjacoby
Message:

Replies: Ensure hierarchical replies are correctly wrapped & concatenated into their output buffers in the correct order.

This updates the walker class to not immediately echo it's contents, and wraps it in an ul element.

Fixes #2757. See #2830.

Location:
trunk/src/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/classes.php

    r6250 r6317  
    326326                                break;
    327327                        case 'ol':
    328                                 echo "<ol class='bbp-threaded-replies'>\n";
     328                                $output .= "<ol class='bbp-threaded-replies'>\n";
    329329                                break;
    330330                        case 'ul':
    331331                        default:
    332                                 echo "<ul class='bbp-threaded-replies'>\n";
     332                                $output .= "<ul class='bbp-threaded-replies'>\n";
    333333                                break;
    334334                }
     
    351351                                break;
    352352                        case 'ol':
    353                                 echo "</ol>\n";
     353                                $output .= "</ol>\n";
    354354                                break;
    355355                        case 'ul':
    356356                        default:
    357                                 echo "</ul>\n";
     357                                $output .= "</ul>\n";
    358358                                break;
    359359                }
     
    401401                // Check for a callback and use it if specified
    402402                if ( ! empty( $args['callback'] ) ) {
     403                        ob_start();
    403404                        call_user_func( $args['callback'], $object, $args, $depth );
     405                        $output .= ob_get_clean();
    404406                        return;
    405407                }
     
    407409                // Style for div or list element
    408410                if ( ! empty( $args['style'] ) && ( 'div' === $args['style'] ) ) {
    409                         echo "<div>\n";
     411                        $output .= "<div>\n";
    410412                } else {
    411                         echo "<li>\n";
    412                 }
    413 
    414                 bbp_get_template_part( 'loop', 'single-reply' );
     413                        $output .= "<li>\n";
     414                }
     415
     416                $output .= bbp_buffer_template_part( 'loop', 'single-reply', false );
    415417        }
    416418
     
    422424                // Check for a callback and use it if specified
    423425                if ( ! empty( $args['end-callback'] ) ) {
     426                        ob_start();
    424427                        call_user_func( $args['end-callback'], $object, $args, $depth );
     428                        $output .= ob_get_clean();
    425429                        return;
    426430                }
     
    428432                // Style for div or list element
    429433                if ( ! empty( $args['style'] ) && ( 'div' === $args['style'] ) ) {
    430                         echo "</div>\n";
     434                        $output .= "</div>\n";
    431435                } else {
    432                         echo "</li>\n";
     436                        $output .= "</li>\n";
    433437                }
    434438        }
     
    536540
    537541                <option class="<?php echo esc_attr( $class ); ?>" value="<?php echo esc_attr( $value ); ?>"<?php selected( $args['selected'], $object->ID ); ?> <?php disabled( in_array( $reply_id, $ancestors ), true ); ?>><?php echo $pad . esc_html( $title ); ?></option>
    538                
     542
    539543                <?php
    540544
  • trunk/src/includes/replies/functions.php

    r6310 r6317  
    25392539function bbp_list_replies( $args = array() ) {
    25402540
     2541        // Get bbPress
     2542        $bbp = bbpress();
     2543
    25412544        // Reset the reply depth
    2542         bbpress()->reply_query->reply_depth = 0;
     2545        $bbp->reply_query->reply_depth = 0;
    25432546
    25442547        // In reply loop
    2545         bbpress()->reply_query->in_the_loop = true;
    2546 
     2548        $bbp->reply_query->in_the_loop = true;
     2549
     2550        // Parse arguments
    25472551        $r = bbp_parse_args( $args, array(
    2548                 'walker'       => null,
     2552                'walker'       => new BBP_Walker_Reply,
    25492553                'max_depth'    => bbp_thread_replies_depth(),
    25502554                'style'        => 'ul',
     
    25562560
    25572561        // Get replies to loop through in $_replies
    2558         $walker = new BBP_Walker_Reply;
    2559         $walker->paged_walk( bbpress()->reply_query->posts, $r['max_depth'], $r['page'], $r['per_page'], $r );
    2560 
    2561         bbpress()->max_num_pages            = $walker->max_pages;
    2562         bbpress()->reply_query->in_the_loop = false;
     2562        echo '<ul>' . $r['walker']->paged_walk( $bbp->reply_query->posts, $r['max_depth'], $r['page'], $r['per_page'], $r ) . '</ul>';
     2563
     2564        $bbp->max_num_pages            = $r['walker']->max_pages;
     2565        $bbp->reply_query->in_the_loop = false;
    25632566}
    25642567
Note: See TracChangeset for help on using the changeset viewer.