bbp_get_reply_class

Return the row class of a reply.

Description

(string) bbp_get_reply_class( (int) $reply_id = 0, (array) $classes = array() ); 

Returns (string)

Row class of the reply

Parameters (2)

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

Usage

  1. if ( !function_exists( 'bbp_get_reply_class' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/replies/template.php'; 
  3.  
  4. // Optional. Reply ID 
  5. $reply_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_reply_class($reply_id, $classes); 
  12.  

Defined (1)

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

/includes/replies/template.php  
  1. function bbp_get_reply_class( $reply_id = 0, $classes = array() ) { 
  2. $bbp =bbpress); 
  3. $reply_id = bbp_get_reply_id( $reply_id ); 
  4. $count = isset( $bbp->reply_query->current_post ) ? $bbp->reply_query->current_post : 1; 
  5. $classes = (array) $classes; 
  6. $classes[] = ( (int) $count % 2 ) ? 'even' : 'odd'; 
  7. $classes[] = 'bbp-parent-forum-' . bbp_get_reply_forum_id( $reply_id ); 
  8. $classes[] = 'bbp-parent-topic-' . bbp_get_reply_topic_id( $reply_id ); 
  9. $classes[] = 'bbp-reply-position-' . bbp_get_reply_position( $reply_id ); 
  10. $classes[] = 'user-id-' . bbp_get_reply_author_id( $reply_id ); 
  11. $classes[] = ( bbp_get_reply_author_id( $reply_id ) === bbp_get_topic_author_id( bbp_get_reply_topic_id( $reply_id ) ) ? 'topic-author' : '' ); 
  12. $classes = array_filter( $classes ); 
  13. $classes = get_post_class( $classes, $reply_id ); 
  14. $classes = apply_filters( 'bbp_get_reply_class', $classes, $reply_id ); 
  15. $retval = 'class="' . implode( ' ', $classes ) . '"'; 
  16.  
  17. return $retval;