Skip to:
Content

Changeset 6368


Ignore:
Timestamp:
10/01/12 07:48:41 (19 months ago)
Author:
djpaul
Message:

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

This first pass adds classes for assistance with basic zebra striping and whether the user has recently been active.

File:
1 edited

Legend:

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

    r6342 r6368  
    386386 
    387387        return apply_filters( 'bp_get_member_user_id', $members_template->member->id ); 
     388    } 
     389 
     390/** 
     391 * Output the row class of a member 
     392 * 
     393 * @since BuddyPress (1.7) 
     394 */ 
     395function bp_member_class() { 
     396    echo bp_get_member_class(); 
     397} 
     398    /** 
     399     * Return the row class of a member 
     400     * 
     401     * @global BP_Core_Members_Template $members_template 
     402     * @return string Row class of the member 
     403     * @since BuddyPress (1.7) 
     404     */ 
     405    function bp_get_member_class() { 
     406        global $members_template; 
     407 
     408        $classes      = array(); 
     409        $current_time = bp_core_current_time(); 
     410        $pos_in_loop  = (int) $members_template->current_member; 
     411 
     412        // If we've only one group in the loop, don't both with odd and even. 
     413        if ( $members_template->member_count > 1 ) 
     414            $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd'; 
     415        else 
     416            $classes[] = 'bp-single-member'; 
     417 
     418        // Has the user been active recently? 
     419        if ( ! empty( $members_template->member->last_activity ) ) { 
     420            if ( strtotime( $current_time ) <= strtotime( '+5 minutes', strtotime( $members_template->member->last_activity ) ) ) 
     421                $classes[] = 'is-online'; 
     422        } 
     423 
     424        $classes = apply_filters( 'bp_get_member_class', $classes ); 
     425        $classes = array_merge( $classes, array() ); 
     426        $retval  = 'class="' . join( ' ', $classes ) . '"'; 
     427 
     428        return $retval; 
    388429    } 
    389430 
Note: See TracChangeset for help on using the changeset viewer.