Skip to:
Content

BuddyPress.org

Changeset 6366


Ignore:
Timestamp:
09/30/2012 10:44:15 PM (14 years ago)
Author:
djpaul
Message:

Add new bp_group_class() template function to generate row class styles for the groups directory template parts. See #3741

This first pass adds classes for assistance with basic zebra striping, user status in the group (admin/member/mod), and the type of group (public/private/hidden).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-template.php

    r6342 r6366  
    383383
    384384        return apply_filters( 'bp_get_group_id', $group->id );
     385    }
     386
     387/**
     388 * Output the row class of a group
     389 *
     390 * @since BuddyPress (1.7)
     391 */
     392function bp_group_class() {
     393    echo bp_get_group_class();
     394}
     395    /**
     396     * Return the row class of a group
     397     *
     398     * @global BP_Groups_Template $groups_template
     399     * @return string Row class of the group
     400     * @since BuddyPress (1.7)
     401     */
     402    function bp_get_group_class() {
     403        global $groups_template;
     404
     405        $classes      = array();
     406        $pos_in_loop  = (int) $groups_template->current_group;
     407
     408        // If we've only one group in the loop, don't both with odd and even.
     409        if ( $groups_template->group_count > 1 )
     410            $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd';
     411        else
     412            $classes[] = 'bp-single-group';
     413
     414        // Group type - public, private, hidden.
     415        $classes[] = esc_attr( $groups_template->group->status );
     416
     417        // User's group status
     418        if ( bp_is_user_active() ) {
     419            if ( bp_group_is_admin() )
     420                $classes[] = 'is-admin';
     421
     422            if ( bp_group_is_member() )
     423                $classes[] = 'is-member';
     424
     425            if ( bp_group_is_mod() )
     426                $classes[] = 'is-mod';
     427        }
     428
     429        $classes = apply_filters( 'bp_get_group_class', $classes );
     430        $classes = array_merge( $classes, array() );
     431        $retval = 'class="' . join( ' ', $classes ) . '"';
     432
     433        return $retval;
    385434    }
    386435
Note: See TracChangeset for help on using the changeset viewer.