bbp_get_topic_class

Return the row class of a topic.

Description

(string) bbp_get_topic_class( (int) $topic_id = 0, (array) $classes = array() ); 

Returns (string)

Row class of a topic

Parameters (2)

0. $topic_id — Optional. (int)
Topic id
1. $classes — Optional. (array) => array()
Extra classes you can pass when calling this function

Usage

  1. if ( !function_exists( 'bbp_get_topic_class' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/topics/template.php'; 
  3.  
  4. // Optional. Topic id 
  5. $topic_id = -1; 
  6.  
  7. // Extra classes you can pass when calling this function 
  8. $classes = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bbp_get_topic_class($topic_id, $classes); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/topics/template.php  
  1. function bbp_get_topic_class( $topic_id = 0, $classes = array() ) { 
  2. $bbp =bbpress); 
  3. $topic_id = bbp_get_topic_id( $topic_id ); 
  4. $count = isset( $bbp->topic_query->current_post ) ? $bbp->topic_query->current_post : 1; 
  5. $classes = (array) $classes; 
  6. $classes[] = ( (int) $count % 2 ) ? 'even' : 'odd'; 
  7. $classes[] = bbp_is_topic_sticky( $topic_id, false ) ? 'sticky' : ''; 
  8. $classes[] = bbp_is_topic_super_sticky( $topic_id ) ? 'super-sticky' : ''; 
  9. $classes[] = 'bbp-parent-forum-' . bbp_get_topic_forum_id( $topic_id ); 
  10. $classes[] = 'user-id-' . bbp_get_topic_author_id( $topic_id ); 
  11. $classes = array_filter( $classes ); 
  12. $classes = get_post_class( $classes, $topic_id ); 
  13. $classes = apply_filters( 'bbp_get_topic_class', $classes, $topic_id ); 
  14. $retval = 'class="' . implode( ' ', $classes ) . '"'; 
  15.  
  16. return $retval;