bbp_get_reply_class( int $reply_id,  $classes = array() )

Return the row class of a reply


Description Description


Parameters Parameters

$reply_id

(Optional) Reply ID

(Optional) Extra classes you can pass when calling this function


Top ↑

Return Return

(string) Row class of the reply


Top ↑

Source Source

File: includes/replies/template.php

	function bbp_get_reply_class( $reply_id = 0, $classes = array() ) {
		$bbp       = bbpress();
		$reply_id  = bbp_get_reply_id( $reply_id );
		$topic_id  = bbp_get_reply_topic_id( $reply_id );
		$forum_id  = bbp_get_reply_forum_id( $reply_id );
		$author_id = bbp_get_reply_author_id( $reply_id );
		$reply_pos = bbp_get_reply_position( $reply_id, true );
		$classes   = array_filter( (array) $classes );
		$count     = isset( $bbp->reply_query->current_post )
			? (int) $bbp->reply_query->current_post
			: 1;

		//  Stripes
		$even_odd = ( $count % 2 )
			? 'even'
			: 'odd';

		// Forum moderator replied to topic
		$forum_moderator = ( bbp_is_user_forum_moderator( $author_id, $forum_id ) === $author_id )
			? 'forum-mod'
			: '';

		// Topic author replied to others
		$topic_author = ( bbp_get_topic_author_id( $topic_id ) === $author_id )
			? 'topic-author'
			: '';

		// Get reply classes
		$reply_classes = array(
			'loop-item-'          . $count,
			'user-id-'            . $author_id,
			'bbp-parent-forum-'   . $forum_id,
			'bbp-parent-topic-'   . $topic_id,
			'bbp-reply-position-' . $reply_pos,
			$even_odd,
			$topic_author,
			$forum_moderator
		);

		// Run the topic classes through the post-class filters, which also
		// handles the escaping of each individual class.
		$post_classes = get_post_class( array_merge( $classes, $reply_classes ), $reply_id );

		// Filter
		$new_classes  = apply_filters( 'bbp_get_reply_class', $post_classes, $reply_id, $classes );

		// Return
		return 'class="' . implode( ' ', $new_classes ) . '"';
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.