Skip to:
Content

bbPress.org

Changeset 7242


Ignore:
Timestamp:
03/07/2022 08:46:09 PM (3 years ago)
Author:
johnjamesjacoby
Message:

Replies: use correct wrapper element in bbp_list_replies().

This change ensures that the proper div/ol/ul wrapper is applied (via the style parameter argument) to the walked replies hierarchy, and avoids the potential for generating invalid HTML mark-up.

In branches/2.6, for 2.6.10.

Props mdjwel via GitHub pull request.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/src/includes/replies/functions.php

    r7208 r7242  
    24092409    ), 'list_replies' );
    24102410
    2411     // Get replies to loop through in $_replies
    2412     echo '<ul>' . $r['walker']->paged_walk( $bbp->reply_query->posts, $r['max_depth'], $r['page'], $r['per_page'], $r ) . '</ul>';
    2413 
    2414     $bbp->max_num_pages            = $r['walker']->max_pages;
     2411    // Allowed styles (supported by BBP_Walker_Reply)
     2412    $allowed = array( 'div', 'ol', 'ul' );
     2413
     2414    // Get style
     2415    $style = in_array( $r['style'], $allowed, true )
     2416        ? $r['style']
     2417        : 'ul';
     2418
     2419    // Walk the replies
     2420    $walked_html = $r['walker']->paged_walk(
     2421        $bbp->reply_query->posts,
     2422        $r['max_depth'],
     2423        $r['page'],
     2424        $r['per_page'],
     2425        $r
     2426    );
     2427
     2428    // Override the "max_num_pages" setting
     2429    $bbp->max_num_pages = $r['walker']->max_pages;
     2430
     2431    // No longer in reply loop
    24152432    $bbp->reply_query->in_the_loop = false;
     2433
     2434    // Output the replies list
     2435    echo "<{$style} class='bbp-replies-list'>" . $walked_html . "</{$style}>";
    24162436}
    24172437
Note: See TracChangeset for help on using the changeset viewer.