bbp_get_forum_class

Return the row class of a forum.

Description

(string) bbp_get_forum_class( (int) $forum_id = 0, (array) $classes = array() ); 

Returns (string)

Row class of the forum

Parameters (2)

0. $forum_id — Optional. (int)
Forum ID
1. $classes — Optional. (array) => array()
Extra classes you can pass when calling this function

Usage

  1. if ( !function_exists( 'bbp_get_forum_class' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/forums/template.php'; 
  3.  
  4. // Optional. Forum ID 
  5. $forum_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_forum_class($forum_id, $classes); 
  12.  

Defined (1)

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

/includes/forums/template.php  
  1. function bbp_get_forum_class( $forum_id = 0, $classes = array() ) { 
  2. $bbp =bbpress); 
  3. $forum_id = bbp_get_forum_id( $forum_id ); 
  4. $count = isset( $bbp->forum_query->current_post ) ? $bbp->forum_query->current_post : 1; 
  5. $classes = (array) $classes; 
  6.  
  7. // Get some classes 
  8. $classes[] = 'loop-item-' . $count; 
  9. $classes[] = ( (int) $count % 2 ) ? 'even' : 'odd'; 
  10. $classes[] = bbp_is_forum_category( $forum_id ) ? 'status-category' : ''; 
  11. $classes[] = bbp_get_forum_subforum_count( $forum_id ) ? 'bbp-has-subforums' : ''; 
  12. $classes[] = bbp_get_forum_parent_id( $forum_id ) ? 'bbp-parent-forum-' . bbp_get_forum_parent_id( $forum_id ) : ''; 
  13. $classes[] = 'bbp-forum-status-' . bbp_get_forum_status( $forum_id ); 
  14. $classes[] = 'bbp-forum-visibility-' . bbp_get_forum_visibility( $forum_id ); 
  15.  
  16. // Ditch the empties 
  17. $classes = array_filter( $classes ); 
  18. $classes = get_post_class( $classes, $forum_id ); 
  19.  
  20. // Filter the results 
  21. $classes = apply_filters( 'bbp_get_forum_class', $classes, $forum_id ); 
  22. $retval = 'class="' . implode( ' ', $classes ) . '"'; 
  23.  
  24. return $retval;