bp_groups_admin_create_pagination_links( BP_Group_Member_Query $query, string $member_type )
Create pagination links out of a BP_Group_Member_Query.
Description
This function is intended to create pagination links for use under the Manage Members section of the Groups Admin Dashboard pages. It is a stopgap measure until a more general pagination solution is in place for BuddyPress. Plugin authors should not use this function, as it is likely to be deprecated soon.
Parameters
- $query
-
(Required) A BP_Group_Member_Query object.
- $member_type
-
(Required) member|mod|admin|banned.
Return
(string) Pagination links HTML.
Source
File: bp-groups/bp-groups-admin.php
1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 | function bp_groups_admin_create_pagination_links( BP_Group_Member_Query $query , $member_type ) { $pagination = '' ; if ( ! in_array( $member_type , array ( 'admin' , 'mod' , 'member' , 'banned' ) ) ) { return $pagination ; } // The key used to paginate this profile type in the $_GET global. $qs_key = $member_type . '_page' ; $url_base = remove_query_arg( array ( $qs_key , 'updated' , 'success_modified' ), $_SERVER [ 'REQUEST_URI' ] ); $page = isset( $_GET [ $qs_key ] ) ? absint( $_GET [ $qs_key ] ) : 1; /** * Filters the number of members per profile type that is displayed in group editing admin area. * * @since BuddyPress 2.8.0 * * @param string $member_type profile type, which is a group role (admin, mod etc). */ $per_page = apply_filters( 'bp_groups_admin_members_type_per_page' , 10, $member_type ); // Don't show anything if there's no pagination. if ( 1 === $page && $query ->total_users <= $per_page ) { return $pagination ; } $current_page_start = ( ( $page - 1 ) * $per_page ) + 1; $current_page_end = $page * $per_page > intval ( $query ->total_users ) ? $query ->total_users : $page * $per_page ; $pag_links = paginate_links( array ( 'base' => add_query_arg( $qs_key , '%#%' , $url_base ), 'format' => '' , 'prev_text' => __( '«' , 'buddyboss' ), 'next_text' => __( '»' , 'buddyboss' ), 'total' => ceil ( $query ->total_users / $per_page ), 'current' => $page , ) ); $viewing_text = sprintf( _n( 'Viewing 1 member' , 'Viewing %1$s - %2$s of %3$s members' , $query ->total_users, 'buddyboss' ), bp_core_number_format( $current_page_start ), bp_core_number_format( $current_page_end ), bp_core_number_format( $query ->total_users ) ); $pagination .= '<span class="bp-group-admin-pagination-viewing">' . $viewing_text . '</span>' ; $pagination .= '<span class="bp-group-admin-pagination-links">' . $pag_links . '</span>' ; return $pagination ; } |
Changelog
Version | Description |
---|---|
BuddyPress 1.8.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.