本文整理汇总了PHP中BP_Groups_Group::get方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Groups_Group::get方法的具体用法?PHP BP_Groups_Group::get怎么用?PHP BP_Groups_Group::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BP_Groups_Group
的用法示例。
在下文中一共展示了BP_Groups_Group::get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_group_organizer_export_csv
/**
* Export groups in CSV format
* @param string|array $format short name of format OR list of columns
* Column lists are based on properties of the Groups object, not columns in the database
*/
function bp_group_organizer_export_csv($format)
{
if (is_array($format)) {
$format = implode(',', $format);
}
// If Group Hierarchy is not installed, path is equivalent to slug
if ($format == 'path' && !bpgo_is_hierarchy_available()) {
$format == 'slug';
}
if (!strpos($format, ',')) {
// Short name was specified
switch ($format) {
case 'slug':
$fields = array('id', 'creator_id', 'name', 'slug', 'description', 'status', 'enable_forum', 'date_created');
if (bpgo_is_hierarchy_available()) {
$fields[] = 'parent_id';
}
break;
case 'path':
$fields = array('creator_id', 'name', 'path', 'description', 'status', 'enable_forum', 'date_created');
break;
default:
$fields = apply_filters('bp_group_organizer_get_csv_fields_format_' . $format, array());
break;
}
} else {
$fields = explode(',', $format);
}
if (!count($fields)) {
return false;
}
if (bpgo_is_hierarchy_available()) {
$groups_list = array('groups' => BP_Groups_Hierarchy::get_tree());
$groups_list['total'] = count($groups_list['groups']);
} else {
$groups_list = BP_Groups_Group::get('alphabetical');
}
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename="' . 'bp-group-export.csv' . '";');
// Print header row
echo implode(',', $fields) . "\n";
foreach ($groups_list['groups'] as $group) {
foreach ($fields as $key => $field) {
if ($field == 'path') {
echo BP_Groups_Hierarchy::get_path($group->id);
} else {
if (in_array($field, array('name', 'description'))) {
echo '"' . stripslashes($group->{$field}) . '"';
} else {
echo $group->{$field};
}
}
if ($key < count($fields) - 1) {
echo ',';
}
}
echo "\n";
}
die;
}
示例2: themefix_buddypress_groups_settings_extension
function themefix_buddypress_groups_settings_extension($args)
{
$groups = BP_Groups_Group::get(array('type' => 'alphabetical', 'per_page' => 100));
$the_groups = array();
foreach ($groups['groups'] as $key => $group) {
$the_groups[$group->id] = $group->name;
}
$extra = array('buddypress-group' => array('label' => __('Display a BuddyPress Group activity instead of post(s)', 'thememixfc'), 'description' => '', 'type' => 'checkbox'), 'buddypress-group-group' => array('label' => __('BuddyPress Group', 'thememixfc'), 'description' => '', 'type' => 'select', 'options' => $the_groups, 'requires' => array('buddypress-group', '', true)));
$args['col1'][0] = array_slice($args['col1'][0], 0, 1, true) + $extra + array_slice($args['col1'][0], 1, count($args['col1'][0]) - 1, true);
return $args;
}
示例3: themefix_buddypress_groups_settings_extension
function themefix_buddypress_groups_settings_extension($args)
{
if (!class_exists('BP_Groups_Group')) {
return $args;
}
$groups = BP_Groups_Group::get(array('type' => 'alphabetical', 'per_page' => 100));
$the_groups = array();
foreach ($groups['groups'] as $key => $group) {
$the_groups[$group->id] = $group->name;
}
$extra = array('buddypress-group' => array('label' => __('Display a BuddyPress Group activity instead of post(s)', 'thememix-pro-genesis'), 'description' => '', 'type' => 'checkbox'), 'buddypress-group-group' => array('label' => __('BuddyPress Group', 'thememix-pro-genesis'), 'description' => '', 'type' => 'select', 'options' => $the_groups, 'requires' => array('buddypress-group', '', true)), 'buddypress-group-count' => array('label' => __('Number of activities to show', 'thememix-pro-genesis'), 'description' => '', 'type' => 'select', 'options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 9), 'requires' => array('buddypress-group', '', true)));
$args['col1'][0] = array_slice($args['col1'][0], 0, 1, true) + $extra + array_slice($args['col1'][0], 1, count($args['col1'][0]) - 1, true);
return $args;
}
示例4: get_groups
function get_groups()
{
$user_id = get_current_user_id();
if (!isset($_POST['security']) || !wp_verify_nonce($_POST['security'], 'security') || !current_user_can('edit_posts')) {
_e('Security check Failed. Contact Administrator.', 'wplms-front-end');
die;
}
$q = $_POST['q'];
if (class_exists('BP_Groups_Group')) {
$vgroups = BP_Groups_Group::get(array('type' => 'alphabetical', 'per_page' => 999, 's' => $q['term']));
$return = array();
foreach ($vgroups['groups'] as $vgroup) {
$return[] = array('id' => $vgroup->id, 'text' => $vgroup->name);
}
}
print_r(json_encode($return));
die;
}
示例5: groups_get_groups
/**
* Get a collection of groups, based on the parameters passed.
*
* @param array|string $args {
* Array of arguments. Supports all arguments of
* {@link BP_Groups_Group::get()}. Where the default values differ, they
* have been described here.
* @type int $per_page Default: 20.
* @type int $page Default: 1.
* }
* @return array See {@link BP_Groups_Group::get()}.
*/
function groups_get_groups($args = '')
{
$defaults = array('type' => false, 'order' => 'DESC', 'orderby' => 'date_created', 'user_id' => false, 'include' => false, 'exclude' => false, 'search_terms' => false, 'meta_query' => false, 'show_hidden' => false, 'per_page' => 20, 'page' => 1, 'populate_extras' => true, 'update_meta_cache' => true);
$r = wp_parse_args($args, $defaults);
$groups = BP_Groups_Group::get(array('type' => $r['type'], 'user_id' => $r['user_id'], 'include' => $r['include'], 'exclude' => $r['exclude'], 'search_terms' => $r['search_terms'], 'meta_query' => $r['meta_query'], 'show_hidden' => $r['show_hidden'], 'per_page' => $r['per_page'], 'page' => $r['page'], 'populate_extras' => $r['populate_extras'], 'update_meta_cache' => $r['update_meta_cache'], 'order' => $r['order'], 'orderby' => $r['orderby']));
/**
* Filters the collection of groups based on parsed parameters.
*
* @since 1.2.0
*
* @param BP_Groups_Group $groups Object of found groups based on parameters.
* Passed by reference.
* @param array $r Array of parsed arguments used for group query.
* Passed by reference.
*/
return apply_filters_ref_array('groups_get_groups', array(&$groups, &$r));
}
示例6: test_get_groups_page_perpage_params
/**
* @group get
* @ticket BP5477
*/
public function test_get_groups_page_perpage_params()
{
// Create more than 20 groups (20 is the default per_page number)
$group_ids = array();
for ($i = 1; $i <= 25; $i++) {
$group_ids[] = $this->factory->group->create();
}
// Tests
// Passing false to 'per_page' and 'page' should result in pagination not being applied
$groups = BP_Groups_Group::get(array('per_page' => false, 'page' => false));
// Should return all groups; "paged" group total should be 25
$this->assertEquals(count($group_ids), count($groups['groups']));
unset($groups);
// Passing 'per_page' => -1 should result in pagination not being applied.
$groups = BP_Groups_Group::get(array('per_page' => -1));
// Should return all groups; "paged" group total should match 25
$this->assertEquals(count($group_ids), count($groups['groups']));
unset($groups);
// If "per_page" and "page" are both set, should result in pagination being applied.
$groups = BP_Groups_Group::get(array('per_page' => 12, 'page' => 1));
// Should return top 12 groups only
$this->assertEquals('12', count($groups['groups']));
}
示例7: form
function form($instance)
{
do_action('bp_group_documents_newest_widget_form');
$instance = wp_parse_args((array) $instance, array('num_items' => 5));
$title = esc_attr($instance['title']);
$group_filter = esc_attr($instance['group_filter']);
$featured = (bool) $instance['featured'];
$num_items = absint($instance['num_items']);
$download_count = esc_attr($instance['download_count']);
?>
<p><label><?php
_e('Title:', 'bp-group-documents');
?>
</label><input class="widefat" id="<?php
echo $this->get_field_id('title');
?>
" name="<?php
echo $this->get_field_name('title');
?>
" type="text" value="<?php
echo $title;
?>
" /></p>
<?php
if (BP_GROUP_DOCUMENTS_WIDGET_GROUP_FILTER) {
?>
<p><label><?php
_e('Filter by Group:', 'bp-group-documents');
?>
</label>
<select id="<?php
echo $this->get_field_id('group_filter');
?>
" name="<?php
echo $this->get_field_name('group_filter');
?>
" >
<option value="0"><?php
_e('Select Group...', 'bp-group-documents');
?>
</option>
<?php
$groups_list = BP_Groups_Group::get('alphabetical');
// get_alphabetically();
foreach ($groups_list['groups'] as $group) {
echo '<option value="' . $group->id . '" ';
if ($group->id == $group_filter) {
echo 'selected="selected"';
}
echo '>' . stripslashes($group->name) . '</option>';
}
?>
</select></p>
<?php
}
if (BP_GROUP_DOCUMENTS_FEATURED) {
?>
<p><label><?php
printf(__('Show featured %s only', 'bp-group-documents'), $this->bp_group_documents_name);
?>
</label>
<input type="checkbox" id="<?php
echo $this->get_field_id('featured');
?>
" name="<?php
echo $this->get_field_name('featured');
?>
" value="1" <?php
checked($featured);
?>
>
</p>
<?php
}
?>
<p><label><?php
_e('Number of items to show:', 'bp-group-documents');
?>
</label> <input class="widefat" id="<?php
echo $this->get_field_id('num_items');
?>
" name="<?php
echo $this->get_field_name('num_items');
?>
" type="text" value="<?php
echo absint($num_items);
?>
" style="width: 30%" /></p>
<p><input type="checkbox" id="<?php
echo $this->get_field_id('download_count');
?>
" name="<?php
echo $this->get_field_name('download_count');
?>
" value="1" <?php
if ($download_count) {
echo 'checked="checked"';
}
//.........这里部分代码省略.........
示例8: groups_get_groups
/**
* Get a collection of groups, based on the parameters passed
*
* @uses apply_filters_ref_array() Filter 'groups_get_groups' to modify return value
* @uses BP_Groups_Group::get()
* @param array $args See inline documentation for details
* @return array
*/
function groups_get_groups($args = '')
{
$defaults = array('type' => false, 'order' => 'DESC', 'orderby' => 'date_created', 'user_id' => false, 'include' => false, 'exclude' => false, 'search_terms' => false, 'meta_query' => false, 'show_hidden' => false, 'per_page' => 20, 'page' => 1, 'populate_extras' => true);
$r = wp_parse_args($args, $defaults);
$groups = BP_Groups_Group::get(array('type' => $r['type'], 'user_id' => $r['user_id'], 'include' => $r['include'], 'exclude' => $r['exclude'], 'search_terms' => $r['search_terms'], 'meta_query' => $r['meta_query'], 'show_hidden' => $r['show_hidden'], 'per_page' => $r['per_page'], 'page' => $r['page'], 'populate_extras' => $r['populate_extras'], 'order' => $r['order'], 'orderby' => $r['orderby']));
return apply_filters_ref_array('groups_get_groups', array(&$groups, &$r));
}
示例9: _e
<h3><?php
_e('Connect a Course Group', 'vibe');
?>
<span>
<select id="vibe_group" class="chosen">
<option value=""><?php
_e('None', 'vibe');
?>
</option>
<option value="add_new"><?php
_e('Add new Group', 'vibe');
?>
</option>
<?php
if (class_exists('BP_Groups_Group')) {
$vgroups = BP_Groups_Group::get(array('type' => 'alphabetical', 'per_page' => 999));
foreach ($vgroups['groups'] as $vgroup) {
echo '<option value="' . $vgroup->id . '" ' . selected($vgroup->id, $course_settings['vibe_group']) . '>' . $vgroup->name . '</option>';
}
}
?>
</select>
</span>
</h3>
</li>
<?php
}
if (post_type_exists('forum')) {
?>
<li data-help-tag="17"><label><?php
_e('Course Forum', 'vibe');
示例10: groups_get_groups
function groups_get_groups($args = '')
{
global $bp;
$defaults = array('type' => 'active', 'user_id' => false, 'include' => false, 'exclude' => false, 'search_terms' => false, 'show_hidden' => false, 'per_page' => 20, 'page' => 1, 'populate_extras' => true);
$params = nxt_parse_args($args, $defaults);
extract($params, EXTR_SKIP);
$groups = BP_Groups_Group::get($type, $per_page, $page, $user_id, $search_terms, $include, $populate_extras, $exclude, $show_hidden);
return apply_filters_ref_array('groups_get_groups', array(&$groups, &$params));
}
示例11: auto_register_bp_groups_context
function auto_register_bp_groups_context()
{
if (class_exists('BP_Groups_Group')) {
$bpGroups = BP_Groups_Group::get();
// database look up of all bp groups
foreach ($bpGroups['groups'] as $group) {
register_context("<strong>" . __('BP Group') . ": </strong>" . esc_attr(stripslashes($group->name)), 'bp-group-' . $group->id, 'verify_bp_groups_context');
}
}
}
示例12: test_get_by_parent_id_top_level_groups_using_false
/**
* @group hierarchical_groups
*/
public function test_get_by_parent_id_top_level_groups_using_false()
{
$g1 = $this->factory->group->create();
$g2 = $this->factory->group->create(array('parent_id' => $g1));
$g3 = $this->factory->group->create(array('parent_id' => $g2));
$g4 = $this->factory->group->create();
$groups = BP_Groups_Group::get(array('parent_id' => false));
$found = wp_list_pluck($groups['groups'], 'id');
$this->assertEqualSets(array($g1, $g4), $found);
}
示例13: bp_get_groups_to_edit
/**
* Returns the menu formatted to edit.
*
* @return string|WP_Error $output The menu formatted to edit or error object on failure.
*/
function bp_get_groups_to_edit()
{
// TODO: verify whether this is needed
// $groups_list = groups_get_groups(array(
// 'per_page' => groups_get_total_group_count()
// ));
if (bpgo_is_hierarchy_available()) {
$groups_list = array('groups' => BP_Groups_Hierarchy::get_tree());
$groups_list['total'] = count($groups_list['groups']);
} else {
$groups_list = BP_Groups_Group::get('alphabetical');
}
$result = '<div id="menu-instructions" class="post-body-plain';
$result .= !empty($menu_items) ? ' menu-instructions-inactive">' : '">';
$result .= __('Add groups using the box to the left, or arrange groups below.', 'bp-group-organizer');
$result .= '</div>';
if ($groups_list['total'] == 0) {
return $result . ' <ul class="menu" id="menu-to-edit"><li>' . __('No groups were found.', 'bp-group-organizer') . '</li></ul>';
}
if ($groups_list['total'] != 0) {
$walker_class_name = apply_filters('wp_edit_group_walker', 'Walker_Group_Edit');
if (class_exists($walker_class_name)) {
$walker = new $walker_class_name();
} else {
return new WP_Error('menu_walker_not_exist', sprintf(__('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name));
}
$result .= '<ul class="menu" id="menu-to-edit"> ';
$result .= walk_group_tree($groups_list['groups'], 0, (object) array('walker' => $walker));
$result .= ' </ul> ';
return $result;
}
}