Kaliceos

loop-forums.php

Sep 13th, 2013
1,588
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /**
  4.  * Forums Loop
  5.  *
  6.  * @package bbPress
  7.  * @subpackage Theme
  8.  */
  9.  
  10. ?>
  11.  
  12. <?php do_action( 'bbp_template_before_forums_loop' ); ?>
  13.  
  14. <?php while ( bbp_forums() ) : bbp_the_forum();
  15.        
  16.         /* We print the header only if we want to show a category or if it's the first item of a no-parent forum list */
  17.         if (bbp_is_forum_category() OR !$bbp_forums_noheader)
  18.             { ?>
  19.  
  20.             <ul id="forums-list-<?php bbp_forum_id(); ?>" class="bbp-forums">
  21.  
  22.                 <li class="bbp-header">
  23.  
  24.                     <ul class="forum-titles">
  25.                         <li class="bbp-forum-info"><?php if(bbp_is_forum_category()) { ?><a class="bbp-forum-title" href="<?php bbp_forum_permalink(bbp_get_forum_parent_id()); ?>"><?php bbp_forum_title(bbp_get_forum_parent_id()); ?></a><?php } else { _e( 'Forum', 'bbpress' ); } ?></li>
  26.                         <li class="bbp-forum-topic-count"><?php _e( 'Topics', 'bbpress' ); ?></li>
  27.                         <li class="bbp-forum-reply-count"><?php bbp_show_lead_topic() ? _e( 'Replies', 'bbpress' ) : _e( 'Posts', 'bbpress' ); ?></li>
  28.                         <li class="bbp-forum-freshness"><?php _e( 'Freshness', 'bbpress' ); ?></li>
  29.                     </ul>
  30.  
  31.                 </li><!-- .bbp-header -->
  32. <?php       } ?>
  33.  
  34.             <li class="bbp-body">
  35.    
  36. <?php       /* If the forum is a category, we're gonna make another loop to show its subforums and sub-subforums as if those were forums */
  37.             if(bbp_is_forum_category())
  38.                 {
  39.  
  40.                 $temp_query = clone bbpress()->forum_query;
  41.                 bbp_has_forums('post_parent='.bbp_get_forum_id());
  42.                 while ( bbp_forums() ) : bbp_the_forum();
  43.                 bbp_get_template_part( 'loop', 'single-forum' );
  44.                 endwhile;
  45.                 bbpress()->forum_query = clone $temp_query;
  46.  
  47.                 }
  48.                     else /* Otherwise, we print the forums the normal way */
  49.                 {  
  50.  
  51.                 bbp_get_template_part( 'loop', 'single-forum' );
  52.                 $bbp_forums_noheader = 1; /* This prevents the header part to be printed again on next post in the loop */
  53.  
  54.                 } ?>
  55.  
  56.             </li><!-- .bbp-body -->
  57.  
  58. <?php       /* Prints the footer only if :
  59.                 - it's a category
  60.                 - or if it's the last forum of a no-parent forum list
  61.                 - or if the next forum in the loop is a category */
  62.  
  63.             if( bbp_is_forum_category()
  64.             OR  (bbpress()->forum_query->current_post+1) == bbpress()->forum_query->post_count
  65.             OR  bbp_is_forum_category(bbpress()->forum_query->posts[ bbpress()->forum_query->current_post + 1 ]->ID))
  66.             { ?>
  67.  
  68.             <li class="bbp-footer">
  69.  
  70.                 <div class="tr">
  71.                     <p class="td colspan4">&nbsp;</p>
  72.                 </div><!-- .tr -->
  73.  
  74.             </li><!-- .bbp-footer -->
  75.  
  76.         </ul><!-- .forums-directory -->
  77.  
  78. <?php   unset($bbp_forums_noheader); /* Needed if we have 2+ no-parent forums with at least 1 category between them */
  79.         }  ?>
  80.  
  81. <?php endwhile; ?>
  82.  
  83.  
  84. <?php do_action( 'bbp_template_after_forums_loop' ); ?>
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×