false, 'plural' => 'groups', 'singular' => 'group', ) ); // Add Group Type column and bulk change controls. if ( bp_groups_get_group_types() ) { // Add Group Type column. add_filter( 'bp_groups_list_table_get_columns', array( $this, 'add_type_column' ) ); add_filter( 'bp_groups_admin_get_group_custom_column', array( $this, 'column_content_group_type' ), 10, 3 ); // Add the bulk change select. add_action( 'bp_groups_list_table_after_bulk_actions', array( $this, 'add_group_type_bulk_change_select' ) ); } } /** * Set up items for display in the list table. * * Handles filtering of data, sorting, pagination, and any other data * manipulation required prior to rendering. * * @since 1.7.0 */ public function prepare_items() { global $groups_template; $screen = get_current_screen(); // Option defaults. $include_id = false; $search_terms = false; // Set current page. $page = $this->get_pagenum(); // Set per page from the screen options. $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$screen->id}_per_page" ) ); // Sort order. $order = 'DESC'; if ( ! empty( $_REQUEST['order'] ) ) { $order = bp_esc_sql_order( $_REQUEST['order'] ); } // Order by - default to newest. $orderby = 'last_activity'; if ( ! empty( $_REQUEST['orderby'] ) ) { switch ( $_REQUEST['orderby'] ) { case 'name' : $orderby = 'name'; break; case 'id' : $orderby = 'date_created'; break; case 'members' : $orderby = 'total_member_count'; break; case 'last_active' : $orderby = 'last_activity'; break; } } // Are we doing a search? if ( ! empty( $_REQUEST['s'] ) ) { $search_terms = $_REQUEST['s']; // Set the view as a search request. $this->view = 'search'; } // Check if user has clicked on a specific group (if so, fetch only that group). if ( ! empty( $_REQUEST['gid'] ) ) { $include_id = (int) $_REQUEST['gid']; // Set the view as a single activity. $this->view = 'single'; } // Use the status request to set the current view. if ( isset( $_GET['group_status'] ) && in_array( $_GET['group_status'], array( 'public', 'private', 'hidden' ) ) ) { $this->view = $_GET['group_status']; } // We'll use the ids of group status types for the 'include' param. $this->group_type_ids = BP_Groups_Group::get_group_type_ids(); // Pass a dummy array if there are no groups of this type. $include = false; if ( 'all' != $this->view && isset( $this->group_type_ids[ $this->view ] ) ) { $include = ! empty( $this->group_type_ids[ $this->view ] ) ? $this->group_type_ids[ $this->view ] : array( 0 ); } // Get group type counts for display in the filter tabs. $this->group_counts = array(); foreach ( $this->group_type_ids as $group_type => $group_ids ) { $this->group_counts[ $group_type ] = count( $group_ids ); } // Group types $group_type = false; if ( isset( $_GET['bp-group-type'] ) && null !== bp_groups_get_group_type_object( $_GET['bp-group-type'] ) ) { $group_type = $_GET['bp-group-type']; } // If we're viewing a specific group, flatten all activities into a single array. if ( $include_id ) { $groups = array( (array) groups_get_group( $include_id ) ); } else { $groups_args = array( 'include' => $include, 'per_page' => $per_page, 'page' => $page, 'orderby' => $orderby, 'order' => $order ); if ( $group_type ) { $groups_args['group_type'] = $group_type; } $groups = array(); if ( bp_has_groups( $groups_args ) ) { while ( bp_groups() ) { bp_the_group(); $groups[] = (array) $groups_template->group; } } } // Set raw data to display. $this->items = $groups; // Store information needed for handling table pagination. $this->set_pagination_args( array( 'per_page' => $per_page, 'total_items' => $groups_template->total_group_count, 'total_pages' => ceil( $groups_template->total_group_count / $per_page ) ) ); // Set the Total number of groups. if ( 'all' === $this->view ) { $this->group_counts['all'] = (int) $groups_template->total_group_count; // Only perform a query if not on the main list view. } elseif ( 'single' !== $this->view ) { $count_groups = groups_get_groups( array( 'fields' => 'ids', 'show_hidden' => true, ) ); if ( $count_groups['total'] ) { $this->group_counts['all'] = (int) $count_groups['total']; } } } /** * Get an array of all the columns on the page. * * @since 1.7.0 * * @return array Array of column headers. */ public function get_column_info() { $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns(), $this->get_default_primary_column_name(), ); return $this->_column_headers; } /** * Get name of default primary column * * @since 2.3.3 * * @return string */ protected function get_default_primary_column_name() { // Comment column is mapped to Group's name. return 'comment'; } /** * Display a message on screen when no items are found ("No groups found"). * * @since 1.7.0 */ public function no_items() { _e( 'No groups found.', 'buddypress' ); } /** * Output the Groups data table. * * @since 1.7.0 */ public function display() { $this->display_tablenav( 'top' ); ?>

print_column_headers(); ?> display_rows_or_placeholder(); ?> print_column_headers( false ); ?>
display_tablenav( 'bottom' ); } /** * Extra controls to be displayed between bulk actions and pagination * * @since 2.7.0 * @access protected * * @param string $which */ protected function extra_tablenav( $which ) { /** * Fires just after the bulk action controls in the WP Admin groups list table. * * @since 2.7.0 * * @param string $which The location of the extra table nav markup: 'top' or 'bottom'. */ do_action( 'bp_groups_list_table_after_bulk_actions', $which ); } /** * Generate content for a single row of the table. * * @since 1.7.0 * * @param object|array $item The current group item in the loop. */ public function single_row( $item = array() ) { static $even = false; $row_classes = array(); if ( $even ) { $row_classes = array( 'even' ); } else { $row_classes = array( 'alternate', 'odd' ); } /** * Filters the classes applied to a single row in the groups list table. * * @since 1.9.0 * * @param array $row_classes Array of classes to apply to the row. * @param string $value ID of the current group being displayed. */ $row_classes = apply_filters( 'bp_groups_admin_row_class', $row_classes, $item['id'] ); $row_class = ' class="' . implode( ' ', $row_classes ) . '"'; echo ''; echo $this->single_row_columns( $item ); echo ''; $even = ! $even; } /** * Get the list of views available on this table (e.g. "all", "public"). * * @since 1.7.0 */ public function get_views() { $url_base = bp_get_admin_url( 'admin.php?page=bp-groups' ); ?>

__( 'Delete', 'buddypress' ) ) ); } /** * Get the table column titles. * * @since 1.7.0 * * @see WP_List_Table::single_row_columns() * * @return array Array of column titles. */ public function get_columns() { /** * Filters the titles for the columns for the groups list table. * * @since 2.0.0 * * @param array $value Array of slugs and titles for the columns. */ return apply_filters( 'bp_groups_list_table_get_columns', array( 'cb' => '', 'comment' => _x( 'Name', 'Groups admin Group Name column header', 'buddypress' ), 'description' => _x( 'Description', 'Groups admin Group Description column header', 'buddypress' ), 'status' => _x( 'Status', 'Groups admin Privacy Status column header', 'buddypress' ), 'members' => _x( 'Members', 'Groups admin Members column header', 'buddypress' ), 'last_active' => _x( 'Last Active', 'Groups admin Last Active column header', 'buddypress' ) ) ); } /** * Get the column names for sortable columns. * * Note: It's not documented in WP, but the second item in the * nested arrays below is $desc_first. Normally, we would set * last_active to be desc_first (since you're generally interested in * the *most* recently active group, not the *least*). But because * the default sort for the Groups admin screen is DESC by last_active, * we want the first click on the Last Active column header to switch * the sort order - ie, to make it ASC. Thus last_active is set to * $desc_first = false. * * @since 1.7.0 * * @return array Array of sortable column names. */ public function get_sortable_columns() { /** * Filters the column names for the sortable columns. * * @since 5.0.0 * * @param array $value Array of keys and their values. */ return apply_filters( 'bp_groups_list_table_get_sortable_columns', array( 'gid' => array( 'gid', false ), 'comment' => array( 'name', false ), 'members' => array( 'members', false ), 'last_active' => array( 'last_active', false ), ) ); } /** * Override WP_List_Table::row_actions(). * * Basically a duplicate of the row_actions() method, but removes the * unnecessary