bp_get_member_class (数组美元的类=数组())
返回循环中当前成员的行类。
描述
参数
- 美元的类
-
(数组)(可选)自定义类的数组。
默认值:数组()
返回
(字符串)成员的行类
源
文件:bp-members / bp-members-template.php
函数bp_get_member_class($classes = array()){全局$members_template;//添加偶数/奇数类,但仅当有一个以上的成员。If ($members_template->member_count > 1) {$pos_in_loop = (int) $members_template->current_member;$classes[] = ($pos_in_loop % 2) ?“甚至”:“奇怪”;//如果循环中只有一个成员,则不要考虑奇数和偶数。} else {$classes[] = 'bp-single-member';} //可能添加'is-online'类。如果(!empty($members_template->member->last_activity)){//计算一些次数。 $current_time = bp_core_current_time( true, 'timestamp' ); $last_activity = strtotime( $members_template->member->last_activity ); $still_online = strtotime( '+5 minutes', $last_activity ); // Has the user been active recently? if ( $current_time <= $still_online ) { $classes[] = 'is-online'; } } // Add current user class. if ( bp_loggedin_user_id() === (int) $members_template->member->id ) { $classes[] = 'is-current-user'; } // Add current user profile types. if ( $member_types = bp_get_member_type( $members_template->member->id, false ) ) { foreach ( $member_types as $member_type ) { $classes[] = sprintf( 'member-type-%s', esc_attr( $member_type ) ); } } /** * Filters the determined classes to add to the HTML element. * * @since BuddyPress 1.7.0 * * @param string $classes Classes to be added to the HTML element. */ $classes = apply_filters( 'bp_get_member_class', $classes ); $classes = array_merge( $classes, array() ); $retval = 'class="' . join( ' ', $classes ) . '"'; return $retval; }
更新日志
版本 | 描述 |
---|---|
BuddyPress 1.7.0 | 介绍了。 |