Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/18/2021 10:18:06 AM (4 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/buddypress/common/search-and-filters-bar.php

    r12156 r12892  
    44 *
    55 * @since 3.0.0
    6  * @version 3.1.0
     6 * @version 8.0.0
    77 */
    88?>
    99<div class="subnav-filters filters no-ajax" id="subnav-filters">
    1010
    11     <?php if ( 'friends' !== bp_current_component() ) : ?>
    12     <div class="subnav-search clearfix">
     11    <?php if ( bp_get_friends_slug() !== bp_current_component() ) : ?>
     12        <div class="subnav-search clearfix">
    1313
    14         <?php if ( 'activity' === bp_current_component() ) : ?>
    15             <div class="feed"><a href="<?php bp_sitewide_activity_feed_link(); ?>" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>"><span class="bp-screen-reader-text"><?php esc_html_e( 'RSS', 'buddypress' ); ?></span></a></div>
    16         <?php endif; ?>
     14            <?php if ( bp_get_activity_slug() === bp_current_component() ) : ?>
     15                <div class="feed"><a href="<?php bp_sitewide_activity_feed_link(); ?>" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>"><span class="bp-screen-reader-text"><?php esc_html_e( 'RSS', 'buddypress' ); ?></span></a></div>
     16            <?php endif; ?>
    1717
    18         <?php bp_nouveau_search_form(); ?>
     18            <?php bp_nouveau_search_form(); ?>
    1919
    20     </div>
     20        </div>
    2121    <?php endif; ?>
    2222
    2323        <?php if ( bp_is_user() && ! bp_is_current_action( 'requests' ) ) : ?>
    2424            <?php bp_get_template_part( 'common/filters/user-screens-filters' ); ?>
    25         <?php elseif ( 'groups' === bp_current_component() ) : ?>
     25        <?php elseif ( bp_get_groups_slug() === bp_current_component() ) : ?>
    2626            <?php bp_get_template_part( 'common/filters/groups-screens-filters' ); ?>
    2727        <?php else : ?>
Note: See TracChangeset for help on using the changeset viewer.