[buddypress-trac] [BuddyPress] #4209: bp_get_displayed_user_nav() should have exclusion argument. (code included)

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Thu May 17 13:09:13 UTC 2012


#4209: bp_get_displayed_user_nav() should have exclusion argument. (code included)
-------------------------------------------------+-------------------------
 Reporter:  DennisSmolek                         |       Owner:
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Future
Component:  Members                              |  Release
 Severity:  normal                               |     Version:  1.5.5
 Keywords:  1.7-early needs-testing dev-         |  Resolution:
  feedback                                       |
-------------------------------------------------+-------------------------
Changes (by boonebgorges):

 * keywords:  needs-testing dev-feedback => 1.7-early needs-testing dev-
     feedback
 * milestone:  Awaiting Review => Future Release


Comment:

 See also #2644. You're right that this should be possible without messing
 with the global.

 An alternative strategy is to provide a function that does what it sounds
 like `bp_core_remove_nav_item()` and `bp_core_remove_subnav_item()`
 *should* do - namely, remove *just* the nav item, not access to the
 screen. Maybe adding a 'nav_only' parameter for these functions, so that
 your goal can be accomplished like this:


 {{{
 function bp_4209_remove_nav_items() {
     bp_core_remove_nav_item( 'profile', 'nav_only' );
     bp_core_remove_nav_item( 'settings', 'nav_only' );
 }
 add_action( 'bp_setup_nav', 'bp_4209_remove_nav_items', 100 );

 }}}

 and then modding bp_core_remove_nav_item() like so:

 {{{
 function bp_core_remove_nav_item( $parent_id, $type = 'all' ) {
     // ...

     if ( 'nav_only' != $type && $function =
 $bp->bp_nav[$parent_id]['screen_function'] ) {
     // ...
 }
 }}}

 What I like about this approach, in contrast to DennisSmolek's original
 suggestion (which would definitely work) is that it keeps navigation
 management out of the template functions. As with the rest of BP, adding
 and removing nav items happens in a function hooked to `bp_setup_nav`. We
 should shoot to be internally consistent if possible. Also, there's a big
 advantage to having nav management happen outside of templates, because it
 makes it easy for plugins to modify navigation without requiring that site
 owners make manual changes to their template files.

 Also: We could consider extending the `$type` strategy to the
 `bp_core_new_*_item()` function too, so that you could (for instance) add
 an arbitrary link to the nav bar (without having to add a BP screen
 function, as you have to do now). See #2389.

 Opinions from other devs?

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4209#comment:1>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list