groups->slug );
}
/**
* Output the groups component root slug
*
* @since BuddyPress (1.5.0)
*/
function bp_groups_root_slug() {
echo bp_get_groups_root_slug();
}
/**
* Return the groups component root slug
*
* @since BuddyPress (1.5.0)
*
* @return string
*/
function bp_get_groups_root_slug() {
return apply_filters( 'bp_get_groups_root_slug', buddypress()->groups->root_slug );
}
/**
* Output group directory permalink
*
* @since BuddyPress (1.5.0)
*/
function bp_groups_directory_permalink() {
echo bp_get_groups_directory_permalink();
}
/**
* Return group directory permalink
*
* @since BuddyPress (1.5.0)
*
* @return string
*/
function bp_get_groups_directory_permalink() {
return apply_filters( 'bp_get_groups_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() ) );
}
/**
* The main Groups template loop class.
*
* Responsible for loading a group of groups into a loop for display.
*/
class BP_Groups_Template {
/**
* The loop iterator.
*
* @access public
* @var int
*/
var $current_group = -1;
/**
* The number of groups returned by the paged query.
*
* @access public
* @var int
*/
var $group_count;
/**
* Array of groups located by the query.
*
* @access public
* @var array
*/
var $groups;
/**
* The group object currently being iterated on.
*
* @access public
* @var object
*/
var $group;
/**
* A flag for whether the loop is currently being iterated.
*
* @access public
* @var bool
*/
var $in_the_loop;
/**
* The page number being requested.
*
* @access public
* @var public
*/
var $pag_page;
/**
* The number of items being requested per page.
*
* @access public
* @var public
*/
var $pag_num;
/**
* An HTML string containing pagination links.
*
* @access public
* @var string
*/
var $pag_links;
/**
* The total number of groups matching the query parameters.
*
* @access public
* @var int
*/
var $total_group_count;
/**
* Whether the template loop is for a single group page.
*
* @access public
* @var bool
*/
var $single_group = false;
/**
* Field to sort by.
*
* @access public
* @var string
*/
var $sort_by;
/**
* Sort order.
*
* @access public
* @var string
*/
var $order;
/**
* Constructor method.
*
* @see BP_Groups_Group::get() for an in-depth description of arguments.
*
* @param array $args {
* Array of arguments. Accepts all arguments accepted by
* {@link BP_Groups_Group::get()}. In cases where the default
* values of the params differ, they have been discussed below.
* @type int $per_page Default: 20.
* @type int $page Default: 1.
* }
*/
function __construct( $args = array() ){
// Backward compatibility with old method of passing arguments
if ( ! is_array( $args ) || func_num_args() > 1 ) {
_deprecated_argument( __METHOD__, '1.7', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
$old_args_keys = array(
0 => 'user_id',
1 => 'type',
2 => 'page',
3 => 'per_page',
4 => 'max',
5 => 'slug',
6 => 'search_terms',
7 => 'populate_extras',
8 => 'include',
9 => 'exclude',
10 => 'show_hidden',
11 => 'page_arg',
);
$func_args = func_get_args();
$args = bp_core_parse_args_array( $old_args_keys, $func_args );
}
$defaults = array(
'type' => 'active',
'page' => 1,
'per_page' => 20,
'max' => false,
'show_hidden' => false,
'page_arg' => 'grpage',
'user_id' => 0,
'slug' => false,
'include' => false,
'exclude' => false,
'search_terms' => '',
'meta_query' => false,
'populate_extras' => true,
'update_meta_cache' => true,
);
$r = wp_parse_args( $args, $defaults );
extract( $r );
$this->pag_page = isset( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : $page;
$this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
if ( bp_current_user_can( 'bp_moderate' ) || ( is_user_logged_in() && $user_id == bp_loggedin_user_id() ) )
$show_hidden = true;
if ( 'invites' == $type ) {
$this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page, $exclude );
} else if ( 'single-group' == $type ) {
$this->single_group = true;
if ( groups_get_current_group() ) {
$group = groups_get_current_group();
} else {
$group = groups_get_group( array(
'group_id' => BP_Groups_Group::get_id_from_slug( $r['slug'] ),
'populate_extras' => $r['populate_extras'],
) );
}
// backwards compatibility - the 'group_id' variable is not part of the
// BP_Groups_Group object, but we add it here for devs doing checks against it
//
// @see https://buddypress.trac.wordpress.org/changeset/3540
//
// this is subject to removal in a future release; devs should check against
// $group->id instead
$group->group_id = $group->id;
$this->groups = array( $group );
} else {
$this->groups = groups_get_groups( array(
'type' => $type,
'order' => $order,
'orderby' => $orderby,
'per_page' => $this->pag_num,
'page' => $this->pag_page,
'user_id' => $user_id,
'search_terms' => $search_terms,
'meta_query' => $meta_query,
'include' => $include,
'exclude' => $exclude,
'populate_extras' => $populate_extras,
'update_meta_cache' => $update_meta_cache,
'show_hidden' => $show_hidden
) );
}
if ( 'invites' == $type ) {
$this->total_group_count = (int) $this->groups['total'];
$this->group_count = (int) $this->groups['total'];
$this->groups = $this->groups['groups'];
} else if ( 'single-group' == $type ) {
if ( empty( $group->id ) ) {
$this->total_group_count = 0;
$this->group_count = 0;
} else {
$this->total_group_count = 1;
$this->group_count = 1;
}
} else {
if ( empty( $max ) || $max >= (int) $this->groups['total'] ) {
$this->total_group_count = (int) $this->groups['total'];
} else {
$this->total_group_count = (int) $max;
}
$this->groups = $this->groups['groups'];
if ( !empty( $max ) ) {
if ( $max >= count( $this->groups ) ) {
$this->group_count = count( $this->groups );
} else {
$this->group_count = (int) $max;
}
} else {
$this->group_count = count( $this->groups );
}
}
// Build pagination links
if ( (int) $this->total_group_count && (int) $this->pag_num ) {
$pag_args = array(
$page_arg => '%#%',
'num' => $this->pag_num,
'sortby' => $this->sort_by,
'order' => $this->order,
);
if ( defined( 'DOING_AJAX' ) && true === (bool) DOING_AJAX ) {
$base = remove_query_arg( 's', wp_get_referer() );
} else {
$base = '';
}
if ( ! empty( $search_terms ) ) {
$pag_args['s'] = $search_terms;
}
$this->pag_links = paginate_links( array(
'base' => add_query_arg( $pag_args, $base ),
'format' => '',
'total' => ceil( (int) $this->total_group_count / (int) $this->pag_num ),
'current' => $this->pag_page,
'prev_text' => _x( '←', 'Group pagination previous text', 'buddypress' ),
'next_text' => _x( '→', 'Group pagination next text', 'buddypress' ),
'mid_size' => 1
) );
}
}
/**
* Whether there are groups available in the loop.
*
* @see bp_has_groups()
*
* @return bool True if there are items in the loop, otherwise false.
*/
function has_groups() {
if ( $this->group_count )
return true;
return false;
}
/**
* Set up the next group and iterate index.
*
* @return object The next group to iterate over.
*/
function next_group() {
$this->current_group++;
$this->group = $this->groups[$this->current_group];
return $this->group;
}
/**
* Rewind the groups and reset member index.
*/
function rewind_groups() {
$this->current_group = -1;
if ( $this->group_count > 0 ) {
$this->group = $this->groups[0];
}
}
/**
* Whether there are groups left in the loop to iterate over.
*
* This method is used by {@link bp_groups()} as part of the while loop
* that controls iteration inside the groups loop, eg:
* while ( bp_groups() ) { ...
*
* @see bp_groups()
*
* @return bool True if there are more groups to show, otherwise false.
*/
function groups() {
if ( $this->current_group + 1 < $this->group_count ) {
return true;
} elseif ( $this->current_group + 1 == $this->group_count ) {
do_action('group_loop_end');
// Do some cleaning up after the loop
$this->rewind_groups();
}
$this->in_the_loop = false;
return false;
}
/**
* Set up the current group inside the loop.
*
* Used by {@link bp_the_group()} to set up the current group data
* while looping, so that template tags used during that iteration make
* reference to the current member.
*
* @see bp_the_group()
*/
function the_group() {
$this->in_the_loop = true;
$this->group = $this->next_group();
if ( 0 == $this->current_group ) // loop has just started
do_action('group_loop_start');
}
}
/**
* Start the Groups Template Loop.
*
* @since BuddyPress (1.0.0)
*
* @param array $args {
* Array of parameters. All items are optional.
* @type string $type Optional. Shorthand for certain orderby/
* order combinations. 'newest', 'active', 'popular',
* 'alphabetical', 'random'. When present, will override
* orderby and order params. Default: null.
* @type string $orderby Optional. Property to sort by.
* 'date_created', 'last_activity', 'total_member_count',
* 'name', 'random'. Default: 'date_created'.
* @type string $order Optional. Sort order. 'ASC' or 'DESC'.
* Default: 'DESC'.
* @type int $per_page Optional. Number of items to return per page
* of results. Default: null (no limit).
* @type int $page Optional. Page offset of results to return.
* Default: null (no limit).
* @type int $user_id Optional. If provided, results will be limited
* to groups of which the specified user is a member. Default:
* null.
* @type string $search_terms Optional. If provided, only groups
* whose names or descriptions match the search terms will be
* returned. Default: false.
* @type array $meta_query Optional. An array of meta_query
* conditions. See {@link WP_Meta_Query::queries} for
* description.
* @type array|string Optional. Array or comma-separated list of
* group IDs. Results will be limited to groups within the
* list. Default: false.
* @type bool $populate_extras Whether to fetch additional
* information (such as member count) about groups. Default:
* true.
* @type array|string Optional. Array or comma-separated list of
* group IDs. Results will exclude the listed groups.
* Default: false.
* @type bool $show_hidden Whether to include hidden groups in
* results. Default: false.
* }
* @return bool True if there are groups to display that match the params
*/
function bp_has_groups( $args = '' ) {
global $groups_template;
/***
* Defaults based on the current page & overridden by parsed $args
*/
$slug = false;
$type = '';
$search_terms = false;
// When looking your own groups, check for two action variables
if ( bp_is_current_action( 'my-groups' ) ) {
if ( bp_is_action_variable( 'most-popular', 0 ) ) {
$type = 'popular';
} elseif ( bp_is_action_variable( 'alphabetically', 0 ) ) {
$type = 'alphabetical';
}
// When looking at invites, set type to invites
} elseif ( bp_is_current_action( 'invites' ) ) {
$type = 'invites';
// When looking at a single group, set the type and slug
} elseif ( bp_get_current_group_slug() ) {
$type = 'single-group';
$slug = bp_get_current_group_slug();
}
// Default search string (too soon to escape here)
if ( ! empty( $_REQUEST['group-filter-box'] ) ) {
$search_terms = $_REQUEST['group-filter-box'];
} elseif ( !empty( $_REQUEST['s'] ) ) {
$search_terms = $_REQUEST['s'];
}
// Parse defaults and requested arguments
$r = bp_parse_args( $args, array(
'type' => $type,
'order' => 'DESC',
'orderby' => 'last_activity',
'page' => 1,
'per_page' => 20,
'max' => false,
'show_hidden' => false,
'page_arg' => 'grpage',
'user_id' => bp_displayed_user_id(),
'slug' => $slug,
'search_terms' => $search_terms,
'meta_query' => false,
'include' => false,
'exclude' => false,
'populate_extras' => true,
'update_meta_cache' => true,
), 'has_groups' );
// Setup the Groups template global
$groups_template = new BP_Groups_Template( array(
'type' => $r['type'],
'order' => $r['order'],
'orderby' => $r['orderby'],
'page' => (int) $r['page'],
'per_page' => (int) $r['per_page'],
'max' => (int) $r['max'],
'show_hidden' => $r['show_hidden'],
'page_arg' => $r['page_arg'],
'user_id' => (int) $r['user_id'],
'slug' => $r['slug'],
'search_terms' => $r['search_terms'],
'meta_query' => $r['meta_query'],
'include' => $r['include'],
'exclude' => $r['exclude'],
'populate_extras' => (bool) $r['populate_extras'],
'update_meta_cache' => (bool) $r['update_meta_cache'],
) );
// Filter and return whether or not the groups loop has groups in it
return apply_filters( 'bp_has_groups', $groups_template->has_groups(), $groups_template, $r );
}
/**
* Check whether there are more groups to iterate over.
*
* @return bool
*/
function bp_groups() {
global $groups_template;
return $groups_template->groups();
}
/**
* Set up the current group inside the loop.
*
* @return object
*/
function bp_the_group() {
global $groups_template;
return $groups_template->the_group();
}
/**
* Is the group visible to the currently logged-in user?
*
* @param object $group Optional. Group object. Default: current group in loop.
* @return bool
*/
function bp_group_is_visible( $group = false ) {
global $groups_template;
if ( bp_current_user_can( 'bp_moderate' ) )
return true;
if ( empty( $group ) )
$group =& $groups_template->group;
if ( 'public' == $group->status ) {
return true;
} else {
if ( groups_is_user_member( bp_loggedin_user_id(), $group->id ) ) {
return true;
}
}
return false;
}
/**
* Output the ID of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current group in loop.
*/
function bp_group_id( $group = false ) {
echo bp_get_group_id( $group );
}
/**
* Get the ID of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return int
*/
function bp_get_group_id( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
return apply_filters( 'bp_get_group_id', $group->id );
}
/**
* Output the row class of the current group in the loop.
*
* @since BuddyPress (1.7.0)
*/
function bp_group_class() {
echo bp_get_group_class();
}
/**
* Get the row class of the current group in the loop.
*
* @since BuddyPress (1.7.0)
*
* @return string Row class of the group.
*/
function bp_get_group_class() {
global $groups_template;
$classes = array();
$pos_in_loop = (int) $groups_template->current_group;
// If we've only one group in the loop, don't both with odd and even.
if ( $groups_template->group_count > 1 )
$classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd';
else
$classes[] = 'bp-single-group';
// Group type - public, private, hidden.
$classes[] = esc_attr( $groups_template->group->status );
// User's group status
if ( bp_is_user_active() ) {
if ( bp_group_is_admin() )
$classes[] = 'is-admin';
if ( bp_group_is_member() )
$classes[] = 'is-member';
if ( bp_group_is_mod() )
$classes[] = 'is-mod';
}
$classes = apply_filters( 'bp_get_group_class', $classes );
$classes = array_merge( $classes, array() );
$retval = 'class="' . join( ' ', $classes ) . '"';
return $retval;
}
/**
* Output the name of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_name( $group = false ) {
echo bp_get_group_name( $group );
}
/**
* Get the name of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return string
*/
function bp_get_group_name( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
return apply_filters( 'bp_get_group_name', $group->name );
}
/**
* Output the type of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_type( $group = false ) {
echo bp_get_group_type( $group );
}
/**
* Get the type of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return string
*/
function bp_get_group_type( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
if ( 'public' == $group->status ) {
$type = __( "Public Group", "buddypress" );
} else if ( 'hidden' == $group->status ) {
$type = __( "Hidden Group", "buddypress" );
} else if ( 'private' == $group->status ) {
$type = __( "Private Group", "buddypress" );
} else {
$type = ucwords( $group->status ) . ' ' . __( 'Group', 'buddypress' );
}
return apply_filters( 'bp_get_group_type', $type );
}
/**
* Output the status of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_status( $group = false ) {
echo bp_get_group_status( $group );
}
/**
* Get the status of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return string
*/
function bp_get_group_status( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
return apply_filters( 'bp_get_group_status', $group->status );
}
/**
* Output the group avatar while in the groups loop.
*
* @since BuddyPress (1.0.0)
*
* @param array $args {
* See {@link bp_get_group_avatar()} for description of arguments.
* }
*/
function bp_group_avatar( $args = '' ) {
echo bp_get_group_avatar( $args );
}
/**
* Return the group avatar while in the groups loop.
*
* @since BuddyPress (1.0.0)
*
* @param array $args {
* Array of arguments. See {@link bp_core_fetch_avatar()} for
* detailed description. Default values that differ from that
* function are described below.
* @type string $type Default: 'full'.
* @type string $id Passed to $css_id parameter.
* }
* @return string
*/
function bp_get_group_avatar( $args = '' ) {
global $groups_template;
// Bail if avatars are turned off
// @todo Should we maybe still filter this?
if ( ! buddypress()->avatar->show_avatars ) {
return false;
}
// Parse the arguments
$r = bp_parse_args( $args, array(
'type' => 'full',
'width' => false,
'height' => false,
'class' => 'avatar',
'id' => false,
'alt' => sprintf( __( 'Group logo of %s', 'buddypress' ), $groups_template->group->name )
) );
// Fetch the avatar from the folder
$avatar = bp_core_fetch_avatar( array(
'item_id' => $groups_template->group->id,
'title' => $groups_template->group->name,
'avatar_dir' => 'group-avatars',
'object' => 'group',
'type' => $r['type'],
'alt' => $r['alt'],
'css_id' => $r['id'],
'class' => $r['class'],
'width' => $r['width'],
'height' => $r['height']
) );
// If No avatar found, provide some backwards compatibility
if ( empty( $avatar ) ) {
$avatar = '';
}
return apply_filters( 'bp_get_group_avatar', $avatar, $r );
}
/**
* Output the group avatar thumbnail while in the groups loop.
*
* @since BuddyPress (1.0.0)
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_avatar_thumb( $group = false ) {
echo bp_get_group_avatar_thumb( $group );
}
/**
* Return the group avatar thumbnail while in the groups loop.
*
* @since BuddyPress (1.0.0)
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return string
*/
function bp_get_group_avatar_thumb( $group = false ) {
return bp_get_group_avatar( array(
'type' => 'thumb',
'id' => ! empty( $group->id ) ? $group->id : false
) );
}
/**
* Output the miniature group avatar thumbnail while in the groups loop.
*
* @since BuddyPress (1.0.0)
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_avatar_mini( $group = false ) {
echo bp_get_group_avatar_mini( $group );
}
/**
* Return the miniature group avatar thumbnail while in the groups loop.
*
* @since BuddyPress (1.0.0)
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_get_group_avatar_mini( $group = false ) {
return bp_get_group_avatar( array(
'type' => 'thumb',
'width' => 30,
'height' => 30,
'id' => ! empty( $group->id ) ? $group->id : false
) );
}
/**
* Output the 'last active' string for the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_last_active( $group = false ) {
echo bp_get_group_last_active( $group );
}
/**
* Return the 'last active' string for the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return string
*/
function bp_get_group_last_active( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
$last_active = $group->last_activity;
if ( !$last_active )
$last_active = groups_get_groupmeta( $group->id, 'last_activity' );
if ( empty( $last_active ) ) {
return __( 'not yet active', 'buddypress' );
} else {
return apply_filters( 'bp_get_group_last_active', bp_core_time_since( $last_active ) );
}
}
/**
* Output the permalink for the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_permalink( $group = false ) {
echo bp_get_group_permalink( $group );
}
/**
* Return the permalink for the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return string
*/
function bp_get_group_permalink( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
return apply_filters( 'bp_get_group_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/' ) );
}
/**
* Output the permalink for the admin section of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_admin_permalink( $group = false ) {
echo bp_get_group_admin_permalink( $group );
}
/**
* Return the permalink for the admin section of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return string
*/
function bp_get_group_admin_permalink( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
return apply_filters( 'bp_get_group_admin_permalink', trailingslashit( bp_get_group_permalink( $group ) . 'admin' ) );
}
/**
* Return the slug for the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_slug( $group = false ) {
echo bp_get_group_slug( $group );
}
/**
* Return the slug for the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return string
*/
function bp_get_group_slug( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
return apply_filters( 'bp_get_group_slug', $group->slug );
}
/**
* Output the description for the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_description( $group = false ) {
echo bp_get_group_description( $group );
}
/**
* Return the description for the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return string
*/
function bp_get_group_description( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
return apply_filters( 'bp_get_group_description', stripslashes($group->description) );
}
/**
* Output the description for the current group in the loop, for use in a textarea.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_description_editable( $group = false ) {
echo bp_get_group_description_editable( $group );
}
/**
* Return the permalink for the current group in the loop, for use in a textarea.
*
* 'bp_get_group_description_editable' does not have the formatting
* filters that 'bp_get_group_description' has, which makes it
* appropriate for "raw" editing.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return string
*/
function bp_get_group_description_editable( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
return apply_filters( 'bp_get_group_description_editable', $group->description );
}
/**
* Output an excerpt of the group description.
*
* @param object $group Optional. The group being referenced. Defaults to the
* group currently being iterated on in the groups loop.
*/
function bp_group_description_excerpt( $group = false ) {
echo bp_get_group_description_excerpt( $group );
}
/**
* Get an excerpt of a group description.
*
* @param object $group Optional. The group being referenced. Defaults
* to the group currently being iterated on in the groups loop.
* @return string Excerpt.
*/
function bp_get_group_description_excerpt( $group = false ) {
global $groups_template;
if ( empty( $group ) ) {
$group =& $groups_template->group;
}
return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description ), $group );
}
/**
* Output the status of the current group in the loop.
*
* Either 'Public' or 'Private'.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_public_status( $group = false ) {
echo bp_get_group_public_status( $group );
}
/**
* Return the status of the current group in the loop.
*
* Either 'Public' or 'Private'.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return string
*/
function bp_get_group_public_status( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
if ( $group->is_public ) {
return __( 'Public', 'buddypress' );
} else {
return __( 'Private', 'buddypress' );
}
}
/**
* Output whether the current group in the loop is public.
*
* No longer used in BuddyPress.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_is_public( $group = false ) {
echo bp_get_group_is_public( $group );
}
/**
* Return whether the current group in the loop is public.
*
* No longer used in BuddyPress.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return unknown
*/
function bp_get_group_is_public( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
return apply_filters( 'bp_get_group_is_public', $group->is_public );
}
/**
* Output the created date of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_date_created( $group = false ) {
echo bp_get_group_date_created( $group );
}
/**
* Return the created date of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return string
*/
function bp_get_group_date_created( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
return apply_filters( 'bp_get_group_date_created', bp_core_time_since( strtotime( $group->date_created ) ) );
}
/**
* Output the username of the creator of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_creator_username( $group = false ) {
echo bp_get_group_creator_username( $group );
}
/**
* Return the username of the creator of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return string
*/
function bp_get_group_creator_username( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
return apply_filters( 'bp_get_group_creator_username', bp_core_get_user_displayname( $group->creator_id ) );
}
/**
* Output the user ID of the creator of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_creator_id( $group = false ) {
echo bp_get_group_creator_id( $group );
}
/**
* Return the user ID of the creator of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return int
*/
function bp_get_group_creator_id( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
return apply_filters( 'bp_get_group_creator_id', $group->creator_id );
}
/**
* Output the permalink of the creator of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_creator_permalink( $group = false ) {
echo bp_get_group_creator_permalink( $group );
}
/**
* Return the permalink of the creator of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @return string
*/
function bp_get_group_creator_permalink( $group = false ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
return apply_filters( 'bp_get_group_creator_permalink', bp_core_get_user_domain( $group->creator_id ) );
}
/**
* Determine whether a user is the creator of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @param int $user_id ID of the user.
* @return bool
*/
function bp_is_group_creator( $group = false, $user_id = 0 ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
if ( empty( $user_id ) )
$user_id = bp_loggedin_user_id();
return (bool) ( $group->creator_id == $user_id );
}
/**
* Output the avatar of the creator of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @param array $args {
* Array of optional arguments. See {@link bp_get_group_creator_avatar()}
* for description.
* }
*/
function bp_group_creator_avatar( $group = false, $args = array() ) {
echo bp_get_group_creator_avatar( $group, $args );
}
/**
* Return the avatar of the creator of the current group in the loop.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
* @param array $args {
* Array of optional arguments. See {@link bp_core_fetch_avatar()}
* for detailed description of arguments.
* @type string $type Default: 'full'.
* @type int $width Default: false.
* @type int $height Default: false.
* @type int $class Default: 'avatar'.
* @type string $id Passed to 'css_id'. Default: false.
* @type string $alt Alt text. Default: 'Group creator profile
* photo of [user display name]'.
* }
* @return string
*/
function bp_get_group_creator_avatar( $group = false, $args = array() ) {
global $groups_template;
if ( empty( $group ) )
$group =& $groups_template->group;
$defaults = array(
'type' => 'full',
'width' => false,
'height' => false,
'class' => 'avatar',
'id' => false,
'alt' => sprintf( __( 'Group creator profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $group->creator_id ) )
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
$avatar = bp_core_fetch_avatar( array( 'item_id' => $group->creator_id, 'type' => $type, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'alt' => $alt ) );
return apply_filters( 'bp_get_group_creator_avatar', $avatar );
}
/**
* Determine whether the current user is the admin of the current group.
*
* Alias of {@link bp_is_item_admin()}.
*
* @return bool
*/
function bp_group_is_admin() {
return bp_is_item_admin();
}
/**
* Determine whether the current user is a mod of the current group.
*
* Alias of {@link bp_is_item_mod()}.
*
* @return bool
*/
function bp_group_is_mod() {
return bp_is_item_mod();
}
/**
* Output markup listing group admins.
*
* @param object $group Optional. Group object. Default: current
* group in loop.
*/
function bp_group_list_admins( $group = false ) {
global $groups_template;
if ( empty( $group ) ) {
$group =& $groups_template->group;
}
// fetch group admins if 'populate_extras' flag is false
if ( empty( $group->args['populate_extras'] ) ) {
$query = new BP_Group_Member_Query( array(
'group_id' => $group->id,
'group_role' => 'admin',
'type' => 'first_joined',
) );
if ( ! empty( $query->results ) ) {
$group->admins = $query->results;
}
}
if ( ! empty( $group->admins ) ) { ?>