Advertisement
Guest User

Untitled

a guest
Jul 12th, 2012
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.13 KB | None | 0 0
  1.     function custom_bbp_list_forums( $args = '' ) {
  2.  
  3.         // Define used variables
  4.         $output = $sub_forums = $topic_count = $reply_count = $counts = '';
  5.         $i = 0;
  6.         $count = array();
  7.  
  8.         // Defaults and arguments
  9.         $defaults = array (
  10.             'before'            => '<ul class="bbp-forums-list">',
  11.             'after'             => '</ul>',
  12.             'link_before'       => '<li class="bbp-forum">',
  13.             'link_after'        => '</li>',
  14.             'count_before'      => '',
  15.             'count_after'       => '',
  16.             'count_sep'         => '',
  17.             'separator'         => '',
  18.             'forum_id'          => '',
  19.             'show_topic_count'  => true,
  20.             'show_reply_count'  => true,
  21.         );
  22.         $r = bbp_parse_args( $args, $defaults, 'list_forums' );
  23.         extract( $r, EXTR_SKIP );
  24.  
  25.         // Bail if there are no subforums
  26.         if ( !bbp_get_forum_subforum_count( $forum_id ) )
  27.             return;
  28.  
  29.         // Loop through forums and create a list
  30.         $sub_forums = bbp_forum_get_subforums( $forum_id );
  31.         if ( !empty( $sub_forums ) ) {
  32.  
  33.             // Total count (for separator)
  34.             $total_subs = count( $sub_forums );
  35.             foreach ( $sub_forums as $sub_forum ) {
  36.                 $i++; // Separator count
  37.  
  38.                 // Get forum details
  39.                 $count     = array();
  40.                 $show_sep  = $total_subs > $i ? $separator : '';
  41.                 $permalink = bbp_get_forum_permalink( $sub_forum->ID );
  42.                 $title     = bbp_get_forum_title( $sub_forum->ID );
  43.  
  44.                 // Show topic count
  45.                 if ( !empty( $show_topic_count ) && !bbp_is_forum_category( $sub_forum->ID ) ) {
  46.                     $count['topic'] = bbp_get_forum_topic_count( $sub_forum->ID );
  47.                 }
  48.  
  49.                 // Show reply count
  50.                 if ( !empty( $show_reply_count ) && !bbp_is_forum_category( $sub_forum->ID ) ) {
  51.                     $count['reply'] = bbp_get_forum_reply_count( $sub_forum->ID );
  52.                 }
  53.  
  54.                 // Counts to show
  55.                 if ( !empty( $count ) ) {
  56.                     $counts = $count_before . implode( $count_sep, $count ) . $count_after;
  57.                 }
  58.  
  59.                 // Build this sub forums link
  60.                 $output .= $link_before . '<a href="' . $permalink . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $freshness_link . $show_sep . $link_after;
  61.             }
  62.  
  63.             // Output the list
  64.             echo apply_filters( 'bbp_list_forums', $before . $output . $after, $args );
  65.         }
  66.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement