bbp_get_topic_class( int $topic_id, $classes = array() )
Return the row class of a topic
Description Description
Parameters Parameters
- $topic_id
-
(Optional) Topic id
-
(Optional) Extra classes you can pass when calling this function
Return Return
(string) Row class of a topic
Source Source
File: includes/topics/template.php
function bbp_get_topic_class( $topic_id = 0, $classes = array() ) { $bbp = bbpress(); $topic_id = bbp_get_topic_id( $topic_id ); $forum_id = bbp_get_topic_forum_id( $topic_id ); $author_id = bbp_get_topic_author_id( $topic_id ); $classes = array_filter( (array) $classes ); $count = isset( $bbp->topic_query->current_post ) ? (int) $bbp->topic_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' : ''; // Is this topic a sticky? $sticky = bbp_is_topic_sticky( $topic_id, false ) ? 'sticky' : ''; // Is this topic a super-sticky? $super_sticky = bbp_is_topic_super_sticky( $topic_id ) ? 'super-sticky' : ''; // Get topic classes $topic_classes = array( 'loop-item-' . $count, 'user-id-' . $author_id, 'bbp-parent-forum-' . $forum_id, $even_odd, $forum_moderator, $sticky, $super_sticky ); // 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, $topic_classes ), $topic_id ); // Filter $new_classes = apply_filters( 'bbp_get_topic_class', $post_classes, $topic_id, $classes ); // Return return 'class="' . implode( ' ', $new_classes ) . '"'; }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |