bp_get_blog_class

Return the row class of the current blog in the loop.

Description

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

Returns (string)

Row class of the site.

Parameters (1)

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

Usage

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

Defined (1)

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

/bp-blogs/bp-blogs-template.php  
  1. function bp_get_blog_class( $classes = array() ) { 
  2. global $blogs_template; 
  3.  
  4. // Add even/odd classes, but only if there's more than 1 group. 
  5. if ( $blogs_template->blog_count > 1 ) { 
  6. $pos_in_loop = (int) $blogs_template->current_blog; 
  7. $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd'; 
  8.  
  9. // If we've only one site in the loop, don't bother with odd and even. 
  10. } else { 
  11. $classes[] = 'bp-single-blog'; 
  12.  
  13. /** 
  14. * Filters the row class of the current blog in the loop. 
  15. * @since 1.7.0 
  16. * @param array $classes Array of classes to be applied to row. 
  17. */ 
  18. $classes = apply_filters( 'bp_get_blog_class', $classes ); 
  19. $classes = array_merge( $classes, array() ); 
  20. $retval = 'class="' . join( ' ', $classes ) . '"'; 
  21.  
  22. return $retval;