Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/18/2021 10:18:06 AM (5 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-members/bp-members-template.php

    r12799 r12892  
    28012801         */
    28022802        function bp_get_members_component_link( $component, $action = '', $query_args = '', $nonce = false ) {
    2803 
    28042803                // Must be displayed user.
    2805                 if ( !bp_displayed_user_id() )
     2804                if ( ! bp_displayed_user_id() ) {
    28062805                        return;
     2806                }
    28072807
    28082808                $bp = buddypress();
    28092809
     2810                if ( 'xprofile' === $component ) {
     2811                        $component = 'profile';
     2812                }
     2813
    28102814                // Append $action to $url if there is no $type.
    2811                 if ( !empty( $action ) )
     2815                if ( ! empty( $action ) ) {
    28122816                        $url = bp_displayed_user_domain() . $bp->{$component}->slug . '/' . $action;
    2813                 else
     2817                } else {
    28142818                        $url = bp_displayed_user_domain() . $bp->{$component}->slug;
     2819                }
    28152820
    28162821                // Add a slash at the end of our user url.
     
    28182823
    28192824                // Add possible query arg.
    2820                 if ( !empty( $query_args ) && is_array( $query_args ) )
     2825                if ( ! empty( $query_args ) && is_array( $query_args ) ) {
    28212826                        $url = add_query_arg( $query_args, $url );
     2827                }
    28222828
    28232829                // To nonce, or not to nonce...
    2824                 if ( true === $nonce )
     2830                if ( true === $nonce ) {
    28252831                        $url = wp_nonce_url( $url );
    2826                 elseif ( is_string( $nonce ) )
     2832                } elseif ( is_string( $nonce ) ) {
    28272833                        $url = wp_nonce_url( $url, $nonce );
     2834                }
    28282835
    28292836                // Return the url, if there is one.
    2830                 if ( !empty( $url ) )
     2837                if ( ! empty( $url ) ) {
    28312838                        return $url;
     2839                }
    28322840        }
    28332841
Note: See TracChangeset for help on using the changeset viewer.