groups_ajax_widget_groups_list()
AJAX callback for the Groups List widget.
Description
Source
File: bp-groups/bp-groups-widgets.php
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | function groups_ajax_widget_groups_list() { check_ajax_referer( 'groups_widget_groups_list' ); switch ( $_POST [ 'filter' ] ) { case 'newest-groups' : $type = 'newest' ; break ; case 'recently-active-groups' : $type = 'active' ; break ; case 'popular-groups' : $type = 'popular' ; break ; case 'alphabetical-groups' : $type = 'alphabetical' ; break ; } $per_page = isset( $_POST [ 'max_groups' ] ) ? intval ( $_POST [ 'max_groups' ] ) : 5; $groups_args = array ( 'user_id' => 0, 'type' => $type , 'per_page' => $per_page , 'max' => $per_page , ); if ( bp_has_groups( $groups_args ) ) : ?> <?php echo "0[[SPLIT]]" ; ?> <?php while ( bp_groups() ) : bp_the_group(); ?> <li <?php bp_group_class(); ?>> <div class = "item-avatar" > <a href= "<?php bp_group_permalink() ?>" ><?php bp_group_avatar_thumb() ?></a> </div> <div class = "item" > <div class = "item-title" ><?php bp_group_link(); ?></div> <div class = "item-meta" > <span class = "activity" > <?php if ( 'newest' == $type ) { printf( __( 'created %s' , 'buddyboss' ), bp_get_group_date_created() ); } elseif ( 'popular' == $type ) { bp_group_member_count(); } else { printf( __( 'active %s' , 'buddyboss' ), bp_get_group_last_active() ); } ?> </span> </div> </div> </li> <?php endwhile ; ?> <?php wp_nonce_field( 'groups_widget_groups_list' , '_wpnonce-groups' ); ?> <input type= "hidden" name= "groups_widget_max" id= "groups_widget_max" value= "<?php echo esc_attr( $_POST['max_groups'] ); ?>" /> <?php else : ?> <?php echo "-1[[SPLIT]]<li>" . __( "No groups matched the current filter." , 'buddyboss' ); ?> <?php endif ; } |
Changelog
Version | Description |
---|---|
BuddyPress 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.