bbp_get_single_forum_description( array $args = array() )
Return a fancy description of the current forum, including total topics, total replies, and last activity.
Description Description
Parameters Parameters
- $args
-
(Optional) This function supports these arguments: - forum_id: Forum id - before: Before the text - after: After the text - size: Size of the avatar
Default value: array()
Return Return
(string) Filtered forum description
Source Source
File: includes/forums/template.php
function bbp_get_single_forum_description( $args = array() ) { // Parse arguments against default values $r = bbp_parse_args( $args, array( 'forum_id' => 0, 'before' => '<div class="bbp-template-notice info"><ul><li class="bbp-forum-description">', 'after' => '</li></ul></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, true, true ); $rc_int = bbp_get_forum_reply_count( $forum_id, true, true ); $topic_count = bbp_get_forum_topic_count( $forum_id, true, false ); $reply_count = bbp_get_forum_reply_count( $forum_id, true, false ); $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, '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' => $r['size'] ) ); // Forum has no last active data } else { $topic_text = sprintf( _n( '%s topic', '%s topics', $tc_int, 'bbpress' ), $topic_count ); } // Forum has active data if ( ! empty( $last_active ) ) { // Has replies if ( ! empty( $reply_count ) ) { $retstr = bbp_is_forum_category( $forum_id ) ? sprintf( esc_html__( 'This category has %1$s, %2$s, and was last updated %3$s by %4$s.', 'bbpress' ), $topic_text, $reply_text, $time_since, $last_updated_by ) : sprintf( esc_html__( 'This forum has %1$s, %2$s, and was last updated %3$s by %4$s.', 'bbpress' ), $topic_text, $reply_text, $time_since, $last_updated_by ); // Only has topics } else { $retstr = bbp_is_forum_category( $forum_id ) ? sprintf( esc_html__( 'This category has %1$s, and was last updated %2$s by %3$s.', 'bbpress' ), $topic_text, $time_since, $last_updated_by ) : sprintf( esc_html__( 'This forum has %1$s, and was last updated %2$s by %3$s.', 'bbpress' ), $topic_text, $time_since, $last_updated_by ); } // Forum has no last active data (but does have topics & replies) } elseif ( ! empty( $reply_count ) ) { $retstr = bbp_is_forum_category( $forum_id ) ? sprintf( esc_html__( 'This category has %1$s and %2$s.', 'bbpress' ), $topic_text, $reply_text ) : sprintf( esc_html__( 'This forum has %1$s and %2$s.', 'bbpress' ), $topic_text, $reply_text ); // Forum has no last active data or replies (but does have topics) } elseif ( ! empty( $topic_count ) ) { $retstr = bbp_is_forum_category( $forum_id ) ? sprintf( esc_html__( 'This category has %1$s.', 'bbpress' ), $topic_text ) : sprintf( esc_html__( 'This forum has %1$s.', 'bbpress' ), $topic_text ); // Forum is empty } else { $retstr = esc_html__( 'This forum is empty.', 'bbpress' ); } // 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']; // Filter & return return apply_filters( 'bbp_get_single_forum_description', $retstr, $r, $args ); }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |