/** * Return a fancy description of the current forum, including total * topics, total replies, and last activity. * * @since bbPress (r2860) * * @param mixed $args This function supports these arguments: * - forum_id: Forum id * - before: Before the text * - after: After the text * - size: Size of the avatar * @uses bbp_get_forum_id() To get the forum id * @uses bbp_get_forum_topic_count() To get the forum topic count * @uses bbp_get_forum_reply_count() To get the forum reply count * @uses bbp_get_forum_subforum_count() To get the forum subforum count * @uses bbp_get_forum_freshness_link() To get the forum freshness link * @uses bbp_get_forum_last_active_id() To get the forum last active id * @uses bbp_get_author_link() To get the author link * @uses add_filter() To add the 'view all' filter back * @uses apply_filters() Calls 'bbp_get_single_forum_description' with * the description and args * @return string Filtered forum description */ function bbp_get_single_forum_description($args = '') { // Default arguments $defaults = array('forum_id' => 0, 'before' => '<div class="bbp-template-notice info"><p class="bbp-forum-description">', 'after' => '</p></div>', 'size' => 14, 'feed' => true); $r = bbp_parse_args($args, $defaults, 'get_single_forum_description'); extract($r); // Validate forum_id $forum_id = bbp_get_forum_id($forum_id); // Unhook the 'view all' query var adder remove_filter('bbp_get_forum_permalink', 'bbp_add_view_all'); // Get some forum data $topic_count = bbp_get_forum_topic_count($forum_id); $reply_count = bbp_get_forum_reply_count($forum_id); $last_active = bbp_get_forum_last_active_id($forum_id); // Has replies if (!empty($reply_count)) { $reply_text = sprintf(_n('%s reply', '%s replies', $reply_count, 'bbpress'), $reply_count); } // Forum has active data if (!empty($last_active)) { $topic_text = bbp_get_forum_topics_link($forum_id); $time_since = bbp_get_forum_freshness_link($forum_id); $last_updated_by = bbp_get_author_link(array('post_id' => $last_active, 'size' => $size)); // Forum has no last active data } else { $topic_text = sprintf(_n('%s topic', '%s topics', $topic_count, 'bbpress'), $topic_count); } // Forum has active data if (!empty($last_active)) { if (!empty($reply_count)) { if (bbp_is_forum_category($forum_id)) { $retstr = sprintf(__('This category contains %1$s and %2$s, and was last updated by %3$s %4$s.', 'bbpress'), $topic_text, $reply_text, $last_updated_by, $time_since); } else { $retstr = sprintf(__('This forum contains %1$s and %2$s, and was last updated by %3$s %4$s.', 'bbpress'), $topic_text, $reply_text, $last_updated_by, $time_since); } } else { if (bbp_is_forum_category($forum_id)) { $retstr = sprintf(__('This category contains %1$s, and was last updated by %2$s %3$s.', 'bbpress'), $topic_text, $last_updated_by, $time_since); } else { $retstr = sprintf(__('This forum contains %1$s, and was last updated by %2$s %3$s.', 'bbpress'), $topic_text, $last_updated_by, $time_since); } } // Forum has no last active data } else { if (!empty($reply_count)) { if (bbp_is_forum_category($forum_id)) { $retstr = sprintf(__('This category contains %1$s and %2$s.', 'bbpress'), $topic_text, $reply_text); } else { $retstr = sprintf(__('This forum contains %1$s and %2$s.', 'bbpress'), $topic_text, $reply_text); } } else { if (!empty($topic_count)) { if (bbp_is_forum_category($forum_id)) { $retstr = sprintf(__('This category contains %1$s.', 'bbpress'), $topic_text); } else { $retstr = sprintf(__('This forum contains %1$s.', 'bbpress'), $topic_text); } } else { $retstr = __('This forum is empty.', 'bbpress'); } } } // Add feeds //$feed_links = ( !empty( $feed ) ) ? bbp_get_forum_topics_feed_link ( $forum_id ) . bbp_get_forum_replies_feed_link( $forum_id ) : ''; // Add the 'view all' filter back add_filter('bbp_get_forum_permalink', 'bbp_add_view_all'); // Combine the elements together $retstr = $before . $retstr . $after; // Return filtered result return apply_filters('bbp_get_single_forum_description', $retstr, $args); }
/** * Return a fancy description of the current forum, including total * topics, total replies, and last activity. * * @since Boss 1.0.0 * * @param mixed $args This function supports these arguments: * - forum_id: Forum id * - before: Before the text * - after: After the text * - size: Size of the avatar * @uses bbp_get_forum_id() To get the forum id * @uses bbp_get_forum_topic_count() To get the forum topic count * @uses bbp_get_forum_reply_count() To get the forum reply count * @uses bbp_get_forum_freshness_link() To get the forum freshness link * @uses bbp_get_forum_last_active_id() To get the forum last active id * @uses bbp_get_author_link() To get the author link * @uses add_filter() To add the 'view all' filter back * @uses apply_filters() Calls 'bbp_get_single_forum_description' with * the description and args * @return string Filtered forum description */ function buddyboss_bbp_get_single_forum_description($args = '') { // Parse arguments against default values $r = bbp_parse_args($args, array('forum_id' => 0, 'before' => '<div class="bbp-template-notice info"><p class="bbp-forum-description">', 'after' => '</p></div>', 'size' => 14, 'feed' => true), 'get_single_forum_description'); // Validate forum_id $forum_id = bbp_get_forum_id($r['forum_id']); // Unhook the 'view all' query var adder remove_filter('bbp_get_forum_permalink', 'bbp_add_view_all'); // Get some forum data $tc_int = bbp_get_forum_topic_count($forum_id, false); $rc_int = bbp_get_forum_reply_count($forum_id, false); $topic_count = bbp_get_forum_topic_count($forum_id); $reply_count = bbp_get_forum_reply_count($forum_id); $last_active = bbp_get_forum_last_active_id($forum_id); // Has replies if (!empty($reply_count)) { $reply_text = sprintf(_n('%s reply', '%s replies', $rc_int, 'boss'), $reply_count); } // Forum has active data if (!empty($last_active)) { $topic_text = bbp_get_forum_topics_link($forum_id); $time_since = bbp_get_forum_freshness_link($forum_id); $last_updated_by = bbp_get_author_link(array('post_id' => $last_active, 'size' => $r['size'])); // Forum has no last active data } else { $topic_text = sprintf(_n('%s topic', '%s topics', $tc_int, 'boss'), $topic_count); } // Forum has active data if (!empty($last_active)) { if (!empty($reply_count)) { if (bbp_is_forum_category($forum_id)) { $retstr = sprintf(__('<span class="post-num">%1$s and %2$s</span> <span class="last-activity">Last updated by %3$s %4$s</span>', 'boss'), $topic_text, $reply_text, $last_updated_by, $time_since); } else { $retstr = sprintf(__('<span class="post-num">%1$s and %2$s</span> <span class="last-activity">Last updated by %3$s %4$s<span>', 'boss'), $topic_text, $reply_text, $last_updated_by, $time_since); } } else { if (bbp_is_forum_category($forum_id)) { $retstr = sprintf(__('<span class="post-num">%1$s</span> <span class="last-activity">Last updated by %2$s %3$s</span>', 'boss'), $topic_text, $last_updated_by, $time_since); } else { $retstr = sprintf(__('<span class="post-num">%1$s</span> <span class="last-activity">Last updated by %2$s %3$s</span>', 'boss'), $topic_text, $last_updated_by, $time_since); } } // Forum has no last active data } else { if (!empty($reply_count)) { if (bbp_is_forum_category($forum_id)) { $retstr = sprintf(__('<span class="post-num">%1$s and %2$s</span>', 'boss'), $topic_text, $reply_text); } else { $retstr = sprintf(__('<span class="post-num">%1$s and %2$s</span>', 'boss'), $topic_text, $reply_text); } } else { if (!empty($topic_count)) { if (bbp_is_forum_category($forum_id)) { $retstr = sprintf(__('<span class="post-num">%1$s</span>', 'boss'), $topic_text); } else { $retstr = sprintf(__('<span class="post-num">%1$s</span>', 'boss'), $topic_text); } } else { $retstr = __('<span class="post-num">0 topics and 0 posts</span>', 'boss'); } } } // Add feeds //$feed_links = ( !empty( $r['feed'] ) ) ? bbp_get_forum_topics_feed_link ( $forum_id ) . bbp_get_forum_replies_feed_link( $forum_id ) : ''; // Add the 'view all' filter back add_filter('bbp_get_forum_permalink', 'bbp_add_view_all'); // Combine the elements together $retstr = $r['before'] . $retstr . $r['after']; // Return filtered result return apply_filters('bbp_get_single_forum_description', $retstr, $r); }