Advertisement
Guest User

Untitled

a guest
Feb 11th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.74 KB | None | 0 0
  1. function custom_list_forums_RL2( $args = '' ) {
  2.  
  3.     // Define used variables
  4.     global $rpg_settingsg ;
  5.     global $rpg_settingsf ;
  6.     $output = $sub_forums = $topic_count = $reply_count = $counts = '';
  7.     $i = 0;
  8.     $count = array();
  9.  
  10.     // Parse arguments against default values
  11.     $r = bbp_parse_args( $args, array(
  12.         'before'            => '<ul class="bbp-forums-list">',
  13.         'after'             => '</ul>',
  14.         'link_before'       => '<li class="bbp-forum">',
  15.         'link_after'        => '</li>',
  16.         'count_before'      => ' (',
  17.         'count_after'       => ')',
  18.         'count_sep'         => ', ',
  19.         'separator'         => '<br> ',
  20.         'forum_id'          => '',
  21.         'show_topic_count'  => true,
  22.         'show_reply_count'  => true,
  23.     ), 'listb_forums' );
  24.    
  25.  
  26.     // Loop through forums and create a list
  27.     $sub_forums = bbp_forum_get_subforums( $r['forum_id'] );
  28.     if ( !empty( $sub_forums ) ) {
  29.  
  30.         // Total count (for separator)
  31.         $total_subs = count( $sub_forums );
  32.         foreach ( $sub_forums as $sub_forum ) {
  33.             $i++; // Separator count
  34.  
  35.             // Get forum details
  36.             $count     = array();
  37.             $show_sep  = $total_subs > $i ? $r['separator'] : '';
  38.             $permalink = bbp_get_forum_permalink( $sub_forum->ID );
  39.             $title     = bbp_get_forum_title( $sub_forum->ID );
  40.             $content = bbp_get_forum_content($sub_forum->ID) ;
  41.            
  42.             if($rpg_settingsg['activate_descriptions'] == true) {
  43.                 $content = bbp_get_forum_content($sub_forum->ID) ;
  44.             }
  45.             else {
  46.                 $content='';
  47.             }
  48.            
  49.  
  50.             // Show topic count
  51.             if ( !empty( $r['show_topic_count'] ) && !bbp_is_forum_category( $sub_forum->ID ) ) {
  52.                 $count['topic'] = bbp_get_forum_topic_count( $sub_forum->ID );
  53.             }
  54.  
  55.             // Show reply count
  56.             if ( !empty( $r['show_reply_count'] ) && !bbp_is_forum_category( $sub_forum->ID ) ) {
  57.                 $count['reply'] = bbp_get_forum_reply_count( $sub_forum->ID );
  58.             }
  59.  
  60.             // Counts to show
  61.             if ( !empty( $count ) ) {
  62.                 $counts = $r['count_before'] . implode( $r['count_sep'], $count ) . $r['count_after'];
  63.             }
  64.            
  65.             if($rpg_settingsg['hide_counts'] == true) {
  66.                 $counts='';
  67.             }
  68.             //Build this sub forums link
  69.             if (bbp_is_forum_private($sub_forum->ID)) {
  70.                 if (!current_user_can( 'read_private_forums' ) ) {
  71.                     if(!$rpg_settingsf['redirect_page']) {
  72.                         $link='/home' ;
  73.                     }
  74.                     else {
  75.                         $link=$rpg_settingsf['redirect_page'] ;
  76.                     }
  77.                    
  78.                     $output .= $r['link_before'] . '<a href="' .$link . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'];
  79.                 }
  80.                 else {
  81.                     $output .= $r['link_before'] . '<a href="' . esc_url( $permalink ) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'];
  82.                 }
  83.             }
  84.             else {
  85.                 $output .= $r['link_before'] . '<a href="' . esc_url( $permalink ) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'];
  86.             }
  87.            
  88.                                                
  89.             if ( !empty($content) )
  90.                 $output .= '<div class="bbp-forum-content">'.$content.'</div>';
  91.     }
  92.      //Output the list
  93.     return $r['before'] . $output . $r['after'];
  94.    
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement