/** * Gets user data for a forum reply or article comment */ function get_data($group_id) { // Get the meta from cache $allmeta = wp_cache_get('bp_groups_allmeta_' . $group_id, 'bp'); // Otherwise query the groupmeta table if (false === $allmeta) { global $bp, $wpdb; $allmeta = array(); $rawmeta = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id)); foreach ($rawmeta as $meta) { $allmeta[$meta->meta_key] = $meta->meta_value; } wp_cache_set('bp_groups_allmeta_' . $group_id, $allmeta, 'bp'); } // Add data to the class object $this->id = $group_id; $this->fullname = bp_get_group_name(); $this->domain = bp_get_group_permalink(); $this->slug = bp_get_group_slug(); $this->guild = isset($allmeta['is_guild']) ? $allmeta['is_guild'] : 0; $this->members = bp_get_group_member_count(); $this->alliance = isset($allmeta['group_faction']) ? $allmeta['group_faction'] : 'neutral'; $this->server = isset($allmeta['group_server']) ? $allmeta['group_server'] : NULL; $this->style = isset($allmeta['group_style']) ? $allmeta['group_style'] : NULL; $this->interests = isset($allmeta['group_interests']) ? unserialize($allmeta['group_interests']) : array(); $this->website = isset($allmeta['group_website']) ? $allmeta['group_website'] : NULL; // Get some derived data $this->type = $this->type(); $this->faction = $this->allegiance(); $this->servname = $this->server_name($this->server); $this->tooltip = $this->tooltip(); // Get some extra stuff on user profiles if ($this->context == 'profile') { $this->byline = $this->byline(); $this->admins = $this->admins(); $this->mods = $this->mods(); } }
function bp_group_member_count() { echo bp_get_group_member_count(); }
<a href="<?php echo esc_attr(bp_get_group_permalink()); ?> " title="<?php echo esc_attr(bp_get_group_name()); ?> "> <?php echo esc_attr(bp_get_group_name()); ?> </a> </h5> <div class="meta small"> <span class="activity"> <?php echo bp_get_group_type() . '/' . bp_get_group_member_count(); ?> </span> </div> </div> </li> <?php } ?> </ul> </div> <?php } else { ?> <div class="alert alert-info"> <?php
/** * BP Groups Grid */ function bp_groups_grid($atts) { $default_columns = 3; //four columns $allowed_columns = array(2, 3, 4, 6); extract(shortcode_atts(array('type' => 'active', 'max_item' => 10, 'columns' => $default_columns), $atts)); $columns = floor(12 / $columns); // ensure that columns is scalable if (!in_array($columns, $allowed_columns)) { // default to default columns settings, just in case $columns = $default_columns; } $columns_classes = 'col-md-' . $columns . ' col-sm-' . $columns . ' col-xs-6'; $params = array('type' => $type, 'per_page' => $max_item); $output = ''; if (function_exists('bp_has_groups')) { if (bp_has_groups($params)) { ob_start(); ?> <ul class="clearfix gears-bp-groups-grid"> <?php while (bp_groups()) { ?> <?php bp_the_group(); ?> <li class="bp-groups-grid-item <?php echo $columns_classes; ?> "> <?php $name = bp_get_group_name(); ?> <?php $permalink = bp_get_group_permalink(); ?> <?php $last_active = bp_get_group_last_active(); ?> <?php $members_count = bp_get_group_member_count(); ?> <?php $modal_content = esc_attr($members_count . ' · ' . __('Active ', 'gears') . $last_active . ''); ?> <a title="<?php echo esc_attr($name); ?> " href="<?php echo esc_url($permalink); ?> "> <span class="groups-name"> <?php echo esc_attr($name); ?> <span class="groups-count"> <?php echo intval($members_count); ?> <?php if ($members_count == 1) { ?> <?php _e('Member', 'gears'); ?> <?php } else { ?> <?php _e('Members', 'gears'); ?> <?php } ?> </span> </span> </a> <a title="<?php echo esc_attr($name); ?> " href="<?php echo esc_url($permalink); ?> "> <?php echo bp_get_group_avatar(array('type' => 'full')); ?> </a> </li> <?php } ?> </ul> <?php $output = ob_get_clean(); return $output; } else { return '<div class="alert alert-info">' . __('There are no groups to display. Please try again soon.', 'gears') . '</div>'; } } else { return $this->bp_not_installed; } }
<li <?php bp_group_class(); ?> > <div class="group-inner-list animated animate-when-almost-visible bottom-to-top"> <div class="item-avatar rounded"> <a href="<?php bp_group_permalink(); ?> "><?php bp_group_avatar('type=full&width=80&height=80'); ?> </a> <span class="member-count"><?php echo preg_replace('/\\D/', '', bp_get_group_member_count()); ?> </span> </div> <div class="item"> <div class="item-title"><a href="<?php bp_group_permalink(); ?> "><?php bp_group_name(); ?> </a></div> <div class="item-meta"><span class="activity"><?php printf(__('active %s', 'buddypress'), bp_get_group_last_active()); ?>
/** * @group bp_get_group_member_count */ public function test_bp_get_group_member_count_2_members() { global $groups_template; $gt = $groups_template; $groups_template = new stdClass(); $groups_template->group = new stdClass(); $groups_template->group->total_member_count = 2; $found = bp_get_group_member_count(); $groups_template = $gt; $this->assertSame('2 members', $found); }