Changeset 9886
- Timestamp:
- 05/21/2015 07:34:40 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/bp-blogs-template.php
r9819 r9886 713 713 * 714 714 * @since BuddyPress (1.7.0) 715 */ 716 function bp_blog_class() { 717 echo bp_get_blog_class(); 715 * 716 * @param array $classes Array of custom classes 717 */ 718 function bp_blog_class( $classes = array() ) { 719 echo bp_get_blog_class( $classes ); 718 720 } 719 721 /** … … 723 725 * 724 726 * @global BP_Blogs_Template $blogs_template 727 * @param array $classes Array of custom classes 725 728 * 726 729 * @return string Row class of the site. 727 730 */ 728 function bp_get_blog_class( ) {731 function bp_get_blog_class( $classes = array() ) { 729 732 global $blogs_template; 730 733 731 $classes = array();732 $pos_in_loop = (int) $blogs_template->current_blog;733 734 // If we've only one site in the loop, don't bother with odd and even.735 if ( $blogs_template->blog_count > 1 ) 736 $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd';737 else734 // Add even/odd classes, but only if there's more than 1 group 735 if ( $blogs_template->blog_count > 1 ) { 736 $pos_in_loop = (int) $blogs_template->current_blog; 737 $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd'; 738 739 // If we've only one site in the loop, don't bother with odd and even 740 } else { 738 741 $classes[] = 'bp-single-blog'; 742 } 739 743 740 744 /** … … 747 751 $classes = apply_filters( 'bp_get_blog_class', $classes ); 748 752 $classes = array_merge( $classes, array() ); 749 750 $retval = 'class="' . join( ' ', $classes ) . '"'; 753 $retval = 'class="' . join( ' ', $classes ) . '"'; 754 751 755 return $retval; 752 756 }
Note: See TracChangeset
for help on using the changeset viewer.