bp_get_group_class

Get the row class of the current group in the loop.

Description

(string) bp_get_group_class( (array) $classes = array() ); 

Returns (string)

Row class of the group.

Parameters (1)

0. $classes — Optional. (array) => array()
Array of custom classes.

Usage

  1. if ( !function_exists( 'bp_get_group_class' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-groups/bp-groups-template.php'; 
  3.  
  4. // Array of custom classes. 
  5. $classes = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_get_group_class($classes); 
  9.  

Defined (1)

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

/bp-groups/bp-groups-template.php  
  1. function bp_get_group_class( $classes = array() ) { 
  2. global $groups_template; 
  3.  
  4. // Add even/odd classes, but only if there's more than 1 group. 
  5. if ( $groups_template->group_count > 1 ) { 
  6. $pos_in_loop = (int) $groups_template->current_group; 
  7. $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd'; 
  8.  
  9. // If we've only one group in the loop, don't bother with odd and even. 
  10. } else { 
  11. $classes[] = 'bp-single-group'; 
  12.  
  13. // Group type - public, private, hidden. 
  14. $classes[] = sanitize_key( $groups_template->group->status ); 
  15.  
  16. // Add current group types. 
  17. if ( $group_types = bp_groups_get_group_type( bp_get_group_id(), false ) ) { 
  18. foreach ( $group_types as $group_type ) { 
  19. $classes[] = sprintf( 'group-type-%s', esc_attr( $group_type ) ); 
  20.  
  21. // User's group role. 
  22. if ( bp_is_user_active() ) { 
  23.  
  24. // Admin. 
  25. if ( bp_group_is_admin() ) { 
  26. $classes[] = 'is-admin'; 
  27.  
  28. // Moderator. 
  29. if ( bp_group_is_mod() ) { 
  30. $classes[] = 'is-mod'; 
  31.  
  32. // Member. 
  33. if ( bp_group_is_member() ) { 
  34. $classes[] = 'is-member'; 
  35.  
  36. // Whether a group avatar will appear. 
  37. if ( bp_disable_group_avatar_uploads() || !buddypress)->avatar->show_avatars ) { 
  38. $classes[] = 'group-no-avatar'; 
  39. } else { 
  40. $classes[] = 'group-has-avatar'; 
  41.  
  42. /** 
  43. * Filters classes that will be applied to row class of the current group in the loop. 
  44. * @since 1.7.0 
  45. * @param array $classes Array of determined classes for the row. 
  46. */ 
  47. $classes = apply_filters( 'bp_get_group_class', $classes ); 
  48. $classes = array_merge( $classes, array() ); 
  49. $retval = 'class="' . join( ' ', $classes ) . '"'; 
  50.  
  51. return $retval;