Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/18/2023 04:11:04 AM (2 years ago)
Author:
imath
Message:

BP Rewrites: optimize the code used to build URLs

The bp_members_get_path_chunks() & bp_groups_get_path_chunks() functions are making sure URL chunks are customized according to the slugs settings. Instead of redoing at many places all or some of the operations performed by these functions, update the code to build URLs so that it uses these functions.

See #4954
Fixes #8923
Closes https://github.com/buddypress/buddypress/pull/117

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-notifications/bp-notifications-adminbar.php

    r13499 r13503  
    3030
    3131    $notifications = bp_notifications_get_notifications_for_user( bp_loggedin_user_id(), 'object' );
    32     $count         = ! empty( $notifications ) ? count( $notifications ) : 0;
    33     $alert_class   = (int) $count > 0 ? 'pending-count alert' : 'count no-alert';
    34     $menu_title    = '<span id="ab-pending-notifications" class="' . $alert_class . '">' . number_format_i18n( $count ) . '</span>';
    35     $notifications_slug        = bp_get_notifications_slug();
    36     $custom_notifications_slug = bp_rewrites_get_slug( 'members', 'member_' . $notifications_slug, $notifications_slug );
    37     $menu_link                 = bp_loggedin_user_url(
    38         array(
    39             'single_item_component' => $custom_notifications_slug,
    40         )
    41     );
     32    $count       = ! empty( $notifications ) ? count( $notifications ) : 0;
     33    $alert_class = (int) $count > 0 ? 'pending-count alert' : 'count no-alert';
     34    $menu_title  = '<span id="ab-pending-notifications" class="' . $alert_class . '">' . number_format_i18n( $count ) . '</span>';
     35    $menu_link   = bp_loggedin_user_url( bp_members_get_path_chunks( array( bp_get_notifications_slug() ) ) );
    4236
    4337    // Add the top-level Notifications button.
Note: See TracChangeset for help on using the changeset viewer.