bbp_get_single_forum_description( mixed $args = '' )

Return a fancy description of the current forum, including total topics, total replies, and last activity.

Description

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: ''

Return

(string) Filtered forum description

Source

File: bp-core/deprecated/buddyboss/1.0.php

	function bbp_get_single_forum_description( $args = '' ) {

		// Parse arguments against default values
		$r = bbp_parse_args( $args, array(
			'forum_id'  => 0,
			'before'    => '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><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, 'buddyboss' ), $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 discussion', '%s discussions', $tc_int, 'buddyboss' ), $topic_count );
		}

		// Forum has active data
		if ( !empty( $last_active ) ) {

			if ( !empty( $reply_count ) ) {

				if ( bbp_is_forum_category( $forum_id ) ) {
					$retstr = sprintf( esc_html__( 'This category contains %1$s and %2$s, and was last updated by %3$s %4$s.', 'buddyboss' ), $topic_text, $reply_text, $last_updated_by, $time_since );
				} else {
					$retstr = sprintf( esc_html__( 'This forum contains %1$s and %2$s, and was last updated by %3$s %4$s.',    'buddyboss' ), $topic_text, $reply_text, $last_updated_by, $time_since );
				}

			} else {

				if ( bbp_is_forum_category( $forum_id ) ) {
					$retstr = sprintf( esc_html__( 'This category contains %1$s, and was last updated by %2$s %3$s.', 'buddyboss' ), $topic_text, $last_updated_by, $time_since );
				} else {
					$retstr = sprintf( esc_html__( 'This forum contains %1$s, and was last updated by %2$s %3$s.',    'buddyboss' ), $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( esc_html__( 'This category contains %1$s and %2$s.', 'buddyboss' ), $topic_text, $reply_text );
				} else {
					$retstr = sprintf( esc_html__( 'This forum contains %1$s and %2$s.',    'buddyboss' ), $topic_text, $reply_text );
				}

			} else {

				if ( !empty( $topic_count ) ) {

					if ( bbp_is_forum_category( $forum_id ) ) {
						$retstr = sprintf( esc_html__( 'This category contains %1$s.', 'buddyboss' ), $topic_text );
					} else {
						$retstr = sprintf( esc_html__( 'This forum contains %1$s.',    'buddyboss' ), $topic_text );
					}

				} else {
					$retstr = esc_html__( 'This forum is empty.', 'buddyboss' );
				}
			}
		}

		// 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 );
	}

Changelog

Changelog
Version Description
bbPress (r2860) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.