Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/01/2021 06:13:15 PM (5 years ago)
Author:
imath
Message:

BP Nouveau: improve the Members' directory primary nav's text

The Nouveau template pack will from now on update the Members's directory primary nav's text according to the members displayed list. The 'All Members' text will only be used when filtering this list alphabetically. When using the default filter (last active), this text will now be 'Active Members'. Finally, when filtering the list using the "Newest registered" option, this text will now be 'Newest Members'.

We believe this improvement can avoid the confusion we often make about this nav's count information. To be sure to get the 'All Members' count right, you need to sort the list alphabetically.

Props ketan_chawda

Fixes #8101

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/includes/members/functions.php

    r12921 r13136  
    44 *
    55 * @since 3.0.0
    6  * @version 8.0.0
     6 * @version 10.0.0
    77 */
    88
     
    530530        return $nav->get_primary();
    531531}
     532
     533/**
     534 * Includes additional information about the Members loop Ajax response.
     535 *
     536 * @since 10.0.0
     537 *
     538 * @param array $additional_info An associative array with additional information to include in the Ajax response.
     539 * @param array $args            The Ajax query arguments.
     540 * @return array                 Additional information about the members loop.
     541 */
     542function bp_nouveau_members_loop_additional_info( $additional_info = array(), $args = array() ) {
     543        if ( ! isset( $GLOBALS['members_template'] ) || ! $GLOBALS['members_template'] ) {
     544                return $additional_info;
     545        }
     546
     547        $members_template = $GLOBALS['members_template'];
     548
     549        if ( isset( $members_template->member_count ) && 'all' === $args['scope'] ) {
     550                $additional_info['totalItems'] = bp_core_number_format( $members_template->member_count );
     551                $additional_info['navLabel']   = esc_html__( 'All Members', 'buddypress' );
     552
     553                $nav_labels = array(
     554                        'active' => esc_html__( 'Active Members', 'buddypress' ),
     555                        'newest' => esc_html__( 'Newest Members', 'buddypress' ),
     556                );
     557
     558                if ( isset( $nav_labels[ $args['filter'] ] ) ) {
     559                        $additional_info['navLabel'] = $nav_labels[ $args['filter'] ];
     560                }
     561        }
     562
     563        return $additional_info;
     564}
     565add_filter( 'bp_nouveau_members_ajax_object_template_response', 'bp_nouveau_members_loop_additional_info', 10, 2 );
Note: See TracChangeset for help on using the changeset viewer.