bbp_get_topic_class( int $topic_id,  $classes = array() )

Return the row class of a topic

Description

Parameters

$topic_id

(Optional) Topic id

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

Return

(string) Row class of a topic

Source

File: bp-forums/topics/template.php

2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
function bbp_get_topic_class( $topic_id = 0, $classes = array() ) {
    $bbp       = bbpress();
    $topic_id  = bbp_get_topic_id( $topic_id );
    $count     = isset( $bbp->topic_query->current_post ) ? $bbp->topic_query->current_post : 1;
    $classes   = (array) $classes;
    $classes[] = ( (int) $count % 2 )                    ? 'even'         : 'odd';
    $classes[] = bbp_is_topic_sticky( $topic_id, false ) ? 'sticky'       : '';
    $classes[] = bbp_is_topic_super_sticky( $topic_id  ) ? 'super-sticky' : '';
    $classes[] = 'bbp-parent-forum-' . bbp_get_topic_forum_id( $topic_id );
    $classes[] = 'user-id-' . bbp_get_topic_author_id( $topic_id );
    $classes   = array_filter( $classes );
    $classes   = get_post_class( $classes, $topic_id );
    $classes   = apply_filters( 'bbp_get_topic_class', $classes, $topic_id );
    $retval    = 'class="' . implode( ' ', $classes ) . '"';
 
    return $retval;
}

Changelog

Changelog
Version Description
bbPress (r2667) 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.