Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/18/2021 10:18:06 AM (3 years ago)
Author:
imath
Message:

Nouveau: improve the way customizable slugs are handled

BuddyPress uses constants such as BP_FRIENDS_SLUG to let advanced users customize component URL slugs. The Nouveau template pack was wrongly checking hardcoded component names at various places into its code, in particular into the following functions and template tags:

  • bp_nouveau_current_object()
  • bp_nouveau_filter_options()
  • bp_nouveau_wrapper()

This commit also introduces a new BP Core function to get the active BP Component objects: bp_core_get_active_components(). The $args argument can be used to filter the active components according to their slugs, names, ids or root slugs. Nouveau uses it to determine the component ID out of its slug and use this component ID instead of slugs to create its needed dynamic selectors, classes and data attributes.

Props mattneil

Fixes #8133

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/includes/template-tags.php

    r12887 r12892  
    44 *
    55 * @since 3.0.0
    6  * @version 7.0.0
     6 * @version 8.0.0
    77 */
    88
     
    20692069
    20702070    } else {
    2071         $data_filter = bp_current_component();
     2071        $component_id = bp_current_component();
     2072        if ( ! bp_is_directory() ) {
     2073            $component_id = bp_core_get_active_components( array( 'slug' => $component_id ) );
     2074            $component_id = reset( $component_id );
     2075        }
     2076
     2077        $data_filter  = $component_id;
     2078
    20722079        if ( 'friends' === $data_filter && bp_is_user_friend_requests() ) {
    20732080            $data_filter = 'friend_requests';
     
    20762083        $component['members_select']   = 'members-order-select';
    20772084        $component['members_order_by'] = 'members-order-by';
    2078         $component['object']           = bp_current_component();
     2085        $component['object']           = $component_id;
    20792086        $component['data_filter']      = $data_filter;
    20802087    }
     
    22332240        $output = '';
    22342241
    2235         if ( 'notifications' === bp_current_component() ) {
     2242        if ( bp_get_notifications_slug() === bp_current_component() ) {
    22362243            $output = bp_nouveau_get_notifications_filters();
    22372244
Note: See TracChangeset for help on using the changeset viewer.