bp_get_group_class( array $classes = array() )
Get the row class of the current group in the loop.
Description
Parameters
- $classes
-
(Optional) Array of custom classes.
Default value: array()
Return
(string) Row class of the group.
Source
File: bp-groups/bp-groups-template.php
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | function bp_get_group_class( $classes = array () ) { global $groups_template ; // Add even/odd classes, but only if there's more than 1 group. if ( $groups_template ->group_count > 1 ) { $pos_in_loop = (int) $groups_template ->current_group; $classes [] = ( $pos_in_loop % 2 ) ? 'even' : 'odd' ; // If we've only one group in the loop, don't bother with odd and even. } else { $classes [] = 'bp-single-group' ; } // Group type - public, private, hidden. $classes [] = sanitize_key( $groups_template ->group->status ); // Add current group types. if ( $group_types = bp_groups_get_group_type( bp_get_group_id(), false ) ) { foreach ( $group_types as $group_type ) { $classes [] = sprintf( 'group-type-%s' , esc_attr( $group_type ) ); } } // User's group role. if ( bp_is_user_active() ) { // Admin. if ( bp_group_is_admin() ) { $classes [] = 'is-admin' ; } // Moderator. if ( bp_group_is_mod() ) { $classes [] = 'is-mod' ; } // Member. if ( bp_group_is_member() ) { $classes [] = 'is-member' ; } } // Whether a group avatar will appear. if ( bp_disable_group_avatar_uploads() || ! buddypress()->avatar->show_avatars ) { $classes [] = 'group-no-avatar' ; } else { $classes [] = 'group-has-avatar' ; } /** * Filters classes that will be applied to row class of the current group in the loop. * * @since BuddyPress 1.7.0 * * @param array $classes Array of determined classes for the row. */ $classes = apply_filters( 'bp_get_group_class' , $classes ); $classes = array_merge ( $classes , array () ); $retval = 'class="' . join( ' ' , $classes ) . '"' ; return $retval ; } |
Changelog
Version | Description |
---|---|
BuddyPress 1.7.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.