Skip to:
Content

bbPress.org

Changeset 3166


Ignore:
Timestamp:
05/16/2011 07:45:01 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Fix possible errors when no counts are available or requested.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-forum-template.php

    r3164 r3166  
    586586
    587587    // Define used variables
    588     $output = $sub_forums = $topic_count = $reply_count = '';
     588    $output = $sub_forums = $topic_count = $reply_count = $counts = '';
    589589    $i = 0;
     590    $count = array();
    590591
    591592    // Defaults and arguments
     
    608609    // Loop through forums and create a list
    609610    if ( $sub_forums = bbp_forum_get_subforums( $forum_id ) ) {
     611
    610612        // Total count (for separator)
    611613        $total_subs = count( $sub_forums );
    612         foreach( $sub_forums as $sub_forum ) {
     614        foreach ( $sub_forums as $sub_forum ) {
    613615            $i++; // Separator count
    614616
    615617            // Get forum details
     618            $count     = array();
    616619            $show_sep  = $total_subs > $i ? $separator : '';
    617620            $permalink = bbp_get_forum_permalink( $sub_forum->ID );
    618621            $title     = bbp_get_forum_title( $sub_forum->ID );
    619622
    620             // Show topic and reply counts
     623            // Show topic count
    621624            if ( !empty( $show_topic_count ) && !bbp_is_forum_category( $sub_forum->ID ) )
    622625                $count['topic'] = bbp_get_forum_topic_count( $sub_forum->ID );
    623626
     627            // Show reply count
    624628            if ( !empty( $show_reply_count ) && !bbp_is_forum_category( $sub_forum->ID ) )
    625629                $count['reply'] = bbp_get_forum_reply_count( $sub_forum->ID );
    626630
    627             $output .= $link_before . '<a href="' . $permalink . '" class="bbp-forum-link">' . $title . $count_before . implode( $count_sep, $count ) . $count_after . '</a>' . $show_sep . $link_after;
     631            // Counts to show
     632            if ( !empty( $count ) )
     633                $counts = $count_before . implode( $count_sep, $count ) . $count_after;
     634
     635            // Build this sub forums link
     636            $output .= $link_before . '<a href="' . $permalink . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $link_after;
    628637        }
    629638
Note: See TracChangeset for help on using the changeset viewer.