bbp_get_single_topic_description( mixed $args = '' )

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

Description

Parameters

$args

(Optional) This function supports these arguments: - topic_id: Topic id - before: Before the text - after: After the text - size: Size of the avatar

Default value: ''

Return

(string) Filtered topic description

Source

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

	function bbp_get_single_topic_description( $args = '' ) {

		// Parse arguments against default values
		$r = bbp_parse_args( $args, array(
			'topic_id'  => 0,
			'before'    => '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><p class="bbp-topic-description">',
			'after'     => '</p></div>',
			'size'      => 14
		), 'get_single_topic_description' );

		// Validate topic_id
		$topic_id = bbp_get_topic_id( $r['topic_id'] );

		// Unhook the 'view all' query var adder
		remove_filter( 'bbp_get_topic_permalink', 'bbp_add_view_all' );

		// Build the topic description
		$vc_int      = bbp_get_topic_voice_count   ( $topic_id, true  );
		$voice_count = bbp_get_topic_voice_count   ( $topic_id, false );
		$reply_count = bbp_get_topic_replies_link  ( $topic_id        );
		$time_since  = bbp_get_topic_freshness_link( $topic_id        );

		// Singular/Plural
		$voice_count = sprintf( _n( '%s member', '%s members', $vc_int, 'buddyboss' ), $voice_count );

		// Topic has replies
		$last_reply = bbp_get_topic_last_reply_id( $topic_id );
		if ( !empty( $last_reply ) ) {
			$last_updated_by = bbp_get_author_link( array( 'post_id' => $last_reply, 'size' => $r['size'] ) );
			$retstr          = sprintf( esc_html__( 'This discussion contains %1$s, has %2$s, and was last updated by %3$s %4$s.', 'buddyboss' ), $reply_count, $voice_count, $last_updated_by, $time_since );

		// Topic has no replies
		} elseif ( ! empty( $voice_count ) && ! empty( $reply_count ) ) {
			$retstr = sprintf( esc_html__( 'This discussion contains %1$s and has %2$s.', 'buddyboss' ), $voice_count, $reply_count );

		// Topic has no replies and no members
		} elseif ( empty( $voice_count ) && empty( $reply_count ) ) {
			$retstr = sprintf( esc_html__( 'This discussion has no replies.', 'buddyboss' ), $voice_count, $reply_count );
		}

		// Add the 'view all' filter back
		add_filter( 'bbp_get_topic_permalink', 'bbp_add_view_all' );

		// Combine the elements together
		$retstr = $r['before'] . $retstr . $r['after'];

		// Return filtered result
		return apply_filters( 'bbp_get_single_topic_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.