Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/29/2022 08:00:56 PM (4 years ago)
Author:
imath
Message:

BP Nouveau: support custom slugs in Messages UI

The Messages UI Backbone Router is no more using hardcoded slugs to define its routes. It's now possible to use customized slugs for the BP Messages component and still enjoy this UI.

Fixes #8691 (branch 10.0)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/10.0/src/bp-messages/classes/class-bp-messages-component.php

    r13196 r13275  
    269269        );
    270270
    271         // Show certain screens only if the current user is the displayed user.
    272         if ( bp_is_my_profile() ) {
    273 
    274             // Show "Compose" on the logged-in user's profile only.
    275             $sub_nav[] = array(
    276                 'name'            => __( 'Compose', 'buddypress' ),
    277                 'slug'            => 'compose',
    278                 'parent_url'      => $messages_link,
    279                 'parent_slug'     => $slug,
    280                 'screen_function' => 'messages_screen_compose',
    281                 'position'        => 30,
    282                 'user_has_access' => $access
    283             );
    284 
    285             /*
    286              * Show "Notices" on the logged-in user's profile only
    287              * and then only if the user can create notices.
    288              */
    289             if ( bp_current_user_can( 'bp_moderate' ) ) {
    290                 $sub_nav[] = array(
    291                     'name'            => __( 'Notices', 'buddypress' ),
    292                     'slug'            => 'notices',
    293                     'parent_url'      => $messages_link,
    294                     'parent_slug'     => $slug,
    295                     'screen_function' => 'messages_screen_notices',
    296                     'position'        => 90,
    297                     'user_has_access' => true
    298                 );
    299             }
    300         }
     271        // Show "Compose" on the logged-in user's profile only.
     272        $sub_nav[] = array(
     273            'name'            => __( 'Compose', 'buddypress' ),
     274            'slug'            => 'compose',
     275            'parent_url'      => $messages_link,
     276            'parent_slug'     => $slug,
     277            'screen_function' => 'messages_screen_compose',
     278            'position'        => 30,
     279            'user_has_access' => bp_is_my_profile(),
     280        );
     281
     282        // Show "Notices" to community admins only.
     283        $sub_nav[] = array(
     284            'name'            => __( 'Notices', 'buddypress' ),
     285            'slug'            => 'notices',
     286            'parent_url'      => $messages_link,
     287            'parent_slug'     => $slug,
     288            'screen_function' => 'messages_screen_notices',
     289            'position'        => 90,
     290            'user_has_access' => bp_current_user_can( 'bp_moderate' )
     291        );
    301292
    302293        parent::setup_nav( $main_nav, $sub_nav );
Note: See TracChangeset for help on using the changeset viewer.