Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/01/2021 06:13:15 PM (4 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/ajax.php

    r12908 r13136  
    44 *
    55 * @since 3.0.0
    6  * @version 8.0.0
     6 * @version 10.0.0
    77 */
    88
     
    2222    }
    2323
    24     if ( empty( $_POST['object'] ) ) {
    25         wp_send_json_error();
    26     }
     24    $post_vars = bp_parse_args(
     25        $_POST,
     26        array(
     27            'action'   => '',
     28            'object'   => '',
     29            'scope'    => '',
     30            'filter'   => '',
     31            'nonce'    => '',
     32            'template' => '',
     33        )
     34    );
    2735
    28     $object = sanitize_title( $_POST['object'] );
     36    $object = sanitize_title( $post_vars['object'] );
    2937
    3038    // Bail if object is not an active component to prevent arbitrary file inclusion.
     
    3442
    3543    // Nonce check!
    36     if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'bp_nouveau_' . $object ) ) {
     44    if ( ! $post_vars['nonce'] || ! wp_verify_nonce( $post_vars['nonce'], 'bp_nouveau_' . $object ) ) {
    3745        wp_send_json_error();
    3846    }
     
    4250    if ( 'activity' === $object ) {
    4351        $scope = '';
    44         if ( ! empty( $_POST['scope'] ) ) {
    45             $scope = sanitize_text_field( $_POST['scope'] );
     52        if ( $post_vars['scope'] ) {
     53            $scope = sanitize_text_field( $post_vars['scope'] );
    4654        }
    4755
     
    99107
    100108    // Get the template path based on the 'template' variable via the AJAX request.
    101     $template = isset( $_POST['template'] ) ? wp_unslash( $_POST['template'] ) : '';
     109    $template = '';
     110    if ( $post_vars['template'] ) {
     111        $template = wp_unslash( $post_vars['template'] );
     112    }
    102113
    103114    switch ( $template ) {
     
    141152    ob_end_clean();
    142153
     154    /**
     155     * Add additional info to the Ajax response.
     156     *
     157     * @since 10.0.0
     158     *
     159     * @param array $value     An associative array with additional information to include in the Ajax response.
     160     * @param array $post_vars An associative array containing the Ajax request arguments.
     161     */
     162    $additional_info = apply_filters( "bp_nouveau_{$object}_ajax_object_template_response", array(), $post_vars );
     163    if ( $additional_info ) {
     164        // Prevents content overrides.
     165        if ( isset( $additional_info['contents'] ) ) {
     166            unset( $additional_info['contents'] );
     167        }
     168
     169        $result = array_merge( $result, $additional_info );
     170    }
     171
    143172    // Locate the object template.
    144173    wp_send_json_success( $result );
Note: See TracChangeset for help on using the changeset viewer.