public function get_all_forums() { $bbp_f = bbp_parse_args($args, array('post_type' => bbp_get_forum_post_type(), 'post_parent' => 'any', 'post_status' => bbp_get_public_status_id(), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'ignore_sticky_posts' => true, 'orderby' => 'menu_order title', 'order' => 'ASC'), 'has_forums'); $bbp = bbpress(); $bbp->forum_query = new WP_Query($bbp_f); $data = array(); foreach ($bbp->forum_query->posts as $post) { $type = 'forum'; $is_parent = false; $is_category = bbp_forum_get_subforums($post->ID); if ($is_category) { $type = 'category'; $parent = true; } $settings = $this->wlm->GetOption('bbpsettings'); if ($settings && count($settings) > 0) { foreach ($settings as $setting) { if ($setting["id"] == $post->ID) { $data[$post->ID] = array("id" => $post->ID, "name" => $post->post_title, "level" => $setting["sku"], "protection" => $setting["protection"], "type" => $type, "parent" => $parent, "date" => ""); } } if (!isset($data[$post->ID])) { $data[$post->ID] = array("id" => $post->ID, "name" => $post->post_title, "level" => "", "protection" => "", "type" => $type, "parent" => $parent, "date" => ""); } } else { $data[$post->ID] = array("id" => $post->ID, "name" => $post->post_title, "level" => "", "protection" => "", "type" => $type, "parent" => $parent, "date" => ""); } } echo json_encode($data); die; }
/** * List subforums or forums * * Must be called within a loop or be assigned an forum id * * @param mixed $args The function supports these args: * - forum_id: Forum id. Defaults to '' * @uses bbp_forum_get_subforums() To check if the forum has subforums or not * @uses bbp_get_forum_permalink() To get forum permalink * @uses bbp_get_forum_title() To get forum title * @uses bbp_is_forum_category() To check if a forum is a category * @uses bbp_get_forum_topic_count() To get forum topic count * @uses bbp_get_forum_reply_count() To get forum reply count * @return void */ function ipt_kb_bbp_list_subforums($args = array()) { $r = bbp_parse_args($args, array('forum_id' => ''), 'ipt_kb_list_forums'); $sub_forums = bbp_forum_get_subforums($r['forum_id']); if (!empty($sub_forums)) { foreach ($sub_forums as $sub_forum) { ?> <li class="<?php if (bbp_is_forum_category($sub_forum->ID)) { echo 'bbp-forum-is-category'; } ?> list-group-item bbp-body ipt_kb_subforum_list"> <?php do_action('bbp_theme_before_forum_sub_forums'); ?> <ul id="bbp-forum-<?php bbp_forum_id($sub_forum->ID); ?> " <?php bbp_forum_class($sub_forum->ID); ?> > <li class="bbp-forum-info"> <span class="pull-left ipt_kb_bbpress_subforum_icon ipt_kb_bbpress_forum_icon"> <?php if (bbp_is_forum_category($sub_forum->ID)) { ?> <span class="glyphicon ipt-icomoon-folder-open"></span> <?php } else { ?> <span class="glyphicon ipt-icomoon-file4"></span> <?php } ?> </span> <?php ipt_kb_bbp_forum_title_in_list($sub_forum->ID); ?> <?php ipt_kb_bbp_forum_description_in_list($sub_forum->ID); ?> <?php bbp_forum_row_actions(); ?> </li> <li class="bbp-forum-topic-count"> <?php bbp_forum_topic_count($sub_forum->ID); ?> </li> <li class="bbp-forum-reply-count"> <?php bbp_show_lead_topic() ? bbp_forum_reply_count($sub_forum->ID) : bbp_forum_post_count($sub_forum->ID); ?> </li> <li class="bbp-forum-freshness"> <?php ipt_kb_bbp_forum_freshness_in_list($sub_forum->ID); ?> </li> </ul> <?php do_action('bbp_theme_after_forum_sub_forums'); ?> <div class="clearfix"></div> </li> <?php } } }
/** * Output a list of forums (can be used to list subforums) * * @param mixed $args The function supports these args: * - before: To put before the output. Defaults to '<ul class="bbp-forums">' * - after: To put after the output. Defaults to '</ul>' * - link_before: To put before every link. Defaults to '<li class="bbp-forum">' * - link_after: To put after every link. Defaults to '</li>' * - separator: Separator. Defaults to ', ' * - forum_id: Forum id. Defaults to '' * - show_topic_count - To show forum topic count or not. Defaults to true * - show_reply_count - To show forum reply count or not. Defaults to true * @uses bbp_forum_get_subforums() To check if the forum has subforums or not * @uses bbp_get_forum_permalink() To get forum permalink * @uses bbp_get_forum_title() To get forum title * @uses bbp_is_forum_category() To check if a forum is a category * @uses bbp_get_forum_topic_count() To get forum topic count * @uses bbp_get_forum_reply_count() To get forum reply count */ function bbp_list_forums($args = '') { // Define used variables $output = $sub_forums = $topic_count = $reply_count = $counts = ''; $i = 0; $count = array(); // Defaults and arguments $defaults = array('before' => '<ul class="bbp-forums-list">', 'after' => '</ul>', 'link_before' => '<li class="bbp-forum">', 'link_after' => '</li>', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => ', ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true); $r = bbp_parse_args($args, $defaults, 'list_forums'); extract($r, EXTR_SKIP); // Bail if there are no subforums if (!bbp_get_forum_subforum_count($forum_id)) { return; } // Loop through forums and create a list $sub_forums = bbp_forum_get_subforums($forum_id); if (!empty($sub_forums)) { // Total count (for separator) $total_subs = count($sub_forums); foreach ($sub_forums as $sub_forum) { $i++; // Separator count // Get forum details $count = array(); $show_sep = $total_subs > $i ? $separator : ''; $permalink = bbp_get_forum_permalink($sub_forum->ID); $title = bbp_get_forum_title($sub_forum->ID); // Show topic count if (!empty($show_topic_count) && !bbp_is_forum_category($sub_forum->ID)) { $count['topic'] = bbp_get_forum_topic_count($sub_forum->ID); } // Show reply count if (!empty($show_reply_count) && !bbp_is_forum_category($sub_forum->ID)) { $count['reply'] = bbp_get_forum_reply_count($sub_forum->ID); } // Counts to show if (!empty($count)) { $counts = $count_before . implode($count_sep, $count) . $count_after; } // Build this sub forums link $output .= $link_before . '<a href="' . $permalink . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $link_after; } // Output the list echo apply_filters('bbp_list_forums', $before . $output . $after, $args); } }
/** * Output a list of forums (can be used to list subforums) * * @param mixed $args The function supports these args: * - before: To put before the output. Defaults to '<ul class="bbp-forums">' * - after: To put after the output. Defaults to '</ul>' * - link_before: To put before every link. Defaults to '<li class="bbp-forum">' * - link_after: To put after every link. Defaults to '</li>' * - separator: Separator. Defaults to ', ' * - forum_id: Forum id. Defaults to '' * - show_topic_count - To show forum topic count or not. Defaults to true * - show_reply_count - To show forum reply count or not. Defaults to true * @uses bbp_forum_get_subforums() To check if the forum has subforums or not * @uses bbp_get_forum_permalink() To get forum permalink * @uses bbp_get_forum_title() To get forum title * @uses bbp_is_forum_category() To check if a forum is a category * @uses bbp_get_forum_topic_count() To get forum topic count * @uses bbp_get_forum_reply_count() To get forum reply count */ function bbp_list_forums($args = '') { // Define used variables $output = $sub_forums = $topic_count = $reply_count = $counts = ''; $i = 0; $count = array(); // Parse arguments against default values $r = bbp_parse_args($args, array('before' => '<ul class="bbp-forums-list">', 'after' => '</ul>', 'link_before' => '<li class="bbp-forum">', 'link_after' => '</li>', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => ', ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true), 'list_forums'); // Loop through forums and create a list $sub_forums = bbp_forum_get_subforums($r['forum_id']); if (!empty($sub_forums)) { // Total count (for separator) $total_subs = count($sub_forums); foreach ($sub_forums as $sub_forum) { $i++; // Separator count // Get forum details $count = array(); $show_sep = $total_subs > $i ? $r['separator'] : ''; $permalink = bbp_get_forum_permalink($sub_forum->ID); $title = bbp_get_forum_title($sub_forum->ID); // Show topic count if (!empty($r['show_topic_count']) && !bbp_is_forum_category($sub_forum->ID)) { $count['topic'] = bbp_get_forum_topic_count($sub_forum->ID); } // Show reply count if (!empty($r['show_reply_count']) && !bbp_is_forum_category($sub_forum->ID)) { $count['reply'] = bbp_get_forum_reply_count($sub_forum->ID); } // Counts to show if (!empty($count)) { $counts = $r['count_before'] . implode($r['count_sep'], $count) . $r['count_after']; } // Build this sub forums link $output .= $r['link_before'] . '<a href="' . esc_url($permalink) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after']; } // Output the list echo apply_filters('bbp_list_forums', $r['before'] . $output . $r['after'], $r); } }
function st_bbp_list_forums($args = '') { // Define used variables $output = $sub_forums = $topic_count = $reply_count = $counts = ''; $i = 0; $count = array(); // Defaults and arguments $defaults = array('before' => '<ul class="bbp-forums-list">', 'after' => '</ul>', 'link_before' => '<li class="bbp-forum">', 'link_after' => '</li>', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => ', ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true, 'show_freshness_link' => true); $r = bbp_parse_args($args, $defaults, 'list_forums'); extract($r, EXTR_SKIP); // Bail if there are no subforums if (!bbp_get_forum_subforum_count($forum_id)) { return; } // Loop through forums and create a list $sub_forums = bbp_forum_get_subforums($forum_id); if (!empty($sub_forums)) { // Total count (for separator) $total_subs = count($sub_forums); foreach ($sub_forums as $sub_forum) { $i++; // Separator count // Get forum details $count = array(); $show_sep = $total_subs > $i ? $separator : ''; $permalink = bbp_get_forum_permalink($sub_forum->ID); $title = bbp_get_forum_title($sub_forum->ID); $description = bbp_get_forum_content($sub_forum->ID); // Show topic count if (!empty($show_topic_count) && !bbp_is_forum_category($sub_forum->ID)) { $count['topic'] = bbp_get_forum_topic_count($sub_forum->ID); } // Show reply count if (!empty($show_reply_count) && !bbp_is_forum_category($sub_forum->ID)) { $count['reply'] = bbp_get_forum_reply_count($sub_forum->ID); } // Counts to show if (!empty($count)) { $counts = $count_before . implode($count_sep, $count) . $count_after; } if (!empty($show_freshness_link)) { $freshness_link = "<div class='freshness-forum-link'>" . st_get_last_poster_block($sub_forum->ID) . "</div>"; } // Build this sub forums link if ($i % 2) { $class = "odd-forum-row"; } else { $class = "even-forum-row"; } $output .= "<li class='{$class}'><ul>" . $link_before . '<div class="bbp-forum-title-container"><a href="' . $permalink . '" class="bbp-forum-link">' . $title . '</a><p class="bbp-forum-description">' . $description . '</p></div>' . $counts . $freshness_link . $link_after . "</ul></li>"; } // Output the list echo apply_filters('bbp_list_forums', $before . $output . $after, $args); } }
/** * Display nested subforums with a hierarchical structure using their parent category * @version 2.0 */ function apoc_loop_subforums() { // Exclude private forums $private = apoc_private_forum_ids(); // Check for subforums $subs = bbp_forum_get_subforums(array('post__not_in' => $private)); if (empty($subs)) { return; } // Buffer output ob_start(); // Print a header ?> <header class="forum-header"> <div class="forum-content"><h2><?php bbp_forum_title(); ?> </h2></div> <div class="forum-count">Topics</div> <div class="forum-freshness">Latest Post</div> </header> <ol class="forums category <?php bbp_forum_status(); ?> "><?php // Loop over forums foreach ($subs as $count => $sub) { // Get forum details $sub_id = $sub->ID; $title = $sub->post_title; $desc = $sub->post_content; $permalink = bbp_get_forum_permalink($sub_id); // Get topic counts $topics = bbp_get_forum_topic_count($sub_id, false); // Get the most recent reply and its topic $reply_id = bbp_get_forum_last_reply_id($sub_id); $topic_id = bbp_is_reply($reply_id) ? bbp_get_reply_topic_id($reply_id) : $reply_id; $topic_title = bbp_get_topic_title($topic_id); $link = bbp_get_reply_url($reply_id); // Get the author avatar $user_id = bbp_get_reply_author_id($reply_id); $avatar = apoc_get_avatar(array('user_id' => $user_id, 'link' => true, 'size' => 50)); // Toggle html class $class = $count % 2 ? 'odd' : 'even'; // Print output ?> <li id="forum-<?php echo $sub_id; ?> " class="forum <?php echo $class; ?> "> <div class="forum-content"> <h3 class="forum-title"><a href="<?php echo $permalink; ?> " title="Browse <?php echo $title; ?> "><?php echo $title; ?> </a></h3> <p class="forum-description"><?php echo $desc; ?> </p> </div> <div class="forum-count"> <?php echo $topics; ?> </div> <div class="forum-freshness"> <?php echo $avatar; ?> <div class="freshest-meta"> <a class="freshest-title" href="<?php echo $link; ?> " title="<?php echo $topic_title; ?> "><?php echo $topic_title; ?> </a> <span class="freshest-author">By <?php bbp_author_link(array('post_id' => $reply_id, 'type' => 'name')); ?> </span> <span class="freshest-time"><?php bbp_topic_last_active_time($topic_id); ?> </span> </div> </div> </li> <?php } ?> </ol> <?php // Retrieve from buffer $output = ob_get_contents(); ob_end_clean(); echo $output; }
<div class="clearfix"></div> <ul class="td-forum-list-head td-forum-list-table"> <li class="td-forum-category-title"> <span class="td-forum-category-name"> <?php echo $cur_forum_obj->post_title; ?> </span> </li><li class="td-forum-topics-replies"> Topics/Replies </li><li class="td-forum-last-comment"> Last comment </li> </ul> <?php $sub_forums_obj = bbp_forum_get_subforums(); if (is_array($sub_forums_obj)) { foreach ($sub_forums_obj as $sub_forum_obj) { td_show_forum($sub_forum_obj); } } } else { //show the normal forum - no header td_show_forum($cur_forum_obj); } ?> <!-- end forum loop --> <?php } ?> <?php
$topics = bbp_get_forum_topic_count('' , true ); $reply_id = bbp_get_forum_last_reply_id( ); $topic_id = bbp_is_reply( $reply_id ) ? bbp_get_reply_topic_id( $reply_id ) : $reply_id; $topic_title = bbp_get_topic_title( $topic_id ); $link = bbp_get_reply_url( $reply_id ); ?> <table class="forum" id="bbp-forum-<?php bbp_forum_id(); ?>"> <tr class="header"> <th colspan="4"><h3><?php bbp_forum_title(); ?></h3></th> </tr> <?php // Check for subforums $subs = bbp_forum_get_subforums( ); if ( !empty( $subs ) ) { ?> <tr> <th>Board</th> <th>Topics</th> <th>Posts</th> <th>Last Post</th> </tr> <?php // Buffer output ob_start();
function custom_list_forums($args = '') { // Define used variables global $rpg_settingsg; global $rpg_settingsf; $output = $sub_forums = $topic_count = $reply_count = $counts = ''; $i = 0; $count = array(); // Parse arguments against default values $r = bbp_parse_args($args, array('before' => '<ul class="bbp-forums-list">', 'after' => '</ul>', 'link_before' => '<li class="bbp-forum">', 'link_after' => '</li>', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => '<br> ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true), 'listb_forums'); // Loop through forums and create a list $sub_forums = bbp_forum_get_subforums($r['forum_id']); if (!empty($sub_forums)) { // Total count (for separator) $total_subs = count($sub_forums); foreach ($sub_forums as $sub_forum) { $i++; // Separator count // Get forum details $count = array(); $show_sep = $total_subs > $i ? $r['separator'] : ''; $permalink = bbp_get_forum_permalink($sub_forum->ID); $title = bbp_get_forum_title($sub_forum->ID); $content = bbp_get_forum_content($sub_forum->ID); if ($rpg_settingsg['activate_descriptions'] == true) { $content = bbp_get_forum_content($sub_forum->ID); } else { $content = ''; } // Show topic count if (!empty($r['show_topic_count']) && !bbp_is_forum_category($sub_forum->ID)) { $count['topic'] = bbp_get_forum_topic_count($sub_forum->ID); } // Show reply count if (!empty($r['show_reply_count']) && !bbp_is_forum_category($sub_forum->ID)) { $count['reply'] = bbp_get_forum_reply_count($sub_forum->ID); } // Counts to show if (!empty($count)) { $counts = $r['count_before'] . implode($r['count_sep'], $count) . $r['count_after']; } if ($rpg_settingsg['hide_counts'] == true) { $counts = ''; } //Build this sub forums link if (bbp_is_forum_private($sub_forum->ID)) { if (!current_user_can('read_private_forums')) { if (!$rpg_settingsf['redirect_page']) { $link = '/home'; } else { $link = $rpg_settingsf['redirect_page']; } $output .= $r['before'] . $r['link_before'] . '<a href="' . $link . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after']; } else { $output .= $r['before'] . $r['link_before'] . '<a href="' . esc_url($permalink) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after']; } } else { $output .= $r['before'] . $r['link_before'] . '<a href="' . esc_url($permalink) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after']; } } //Output the list return $output; } }
<li class="bbp-forum-reply-count"><?php bbp_show_lead_topic() ? _e('Replies', 'bbpress') : _e('Posts', 'bbpress'); ?> </li> <li class="bbp-forum-freshness"><?php _e('Freshness', 'bbpress'); ?> </li> </ul> </li><!-- .bbp-header --> <li class="bbp-body"> <?php $sub_forums = bbp_forum_get_subforums(bbp_get_forum_id()); ?> <?php foreach ($sub_forums as $sub_forum) { ?> <ul id="bbp-forum-<?php echo $sub_forum->ID; ?> " <?php bbp_get_forum_class($sub_forum->ID); ?> > <div class="forumhover"> <li class="bbp-forum-info">