[buddypress-trac] [BuddyPress Trac] #6534: A new API to manage single items navigation

buddypress-trac noreply at wordpress.org
Sat Apr 30 22:51:11 UTC 2016

#6534: A new API to manage single items navigation
 Reporter:  imath                   |       Owner:
     Type:  enhancement             |      Status:  new
 Priority:  high                    |   Milestone:  2.6
Component:  API                     |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  dev-feedback has-patch  |

Comment (by r-a-y):

 Great work, @imath!

 For point 7, I made a few changes to ensure that devs accessing the
 `$bp->bp_nav` and `$bp->bp_options_nav` globals manually should still
 work.  In order to do this, I made changes to the `BP_Core_BackCompat_Nav`
 and `BP_Core_BackCompat_Options_Nav` classes.  The code is a little ugly
 because I needed to create a few `$bp` singleton markers to keep track of
 the current component and action - `buddypress()->backpat_nav_component`
 and `buddypress()->backpat_nav_action`.  See the `set_component_props()`
 method for more details.

 This ensures that something like this still works:

 // The old way of manually changing BP nav menu props.
 add_action( 'get_header', function() {
         // User page.
         buddypress()->bp_nav['activity']['name'] = 'Ray Activity';
         buddypress()->bp_nav['friends']['name'] = 'Ray Friends';
         buddypress()->bp_options_nav['activity']['mentions']['name'] =
 'Ray Mentions';

         // Single group page.
         $group_slug = bp_current_item();
         buddypress()->bp_options_nav[$group_slug]['home']['name'] = 'Ray
 } );

 Hopefully, the `set_component_props()` technique can be removed with
 something a little more elegant.

 I also fixed a bug with the user's "Profile" nav not showing up and added
 a debug trace to the deprecated nav functions so devs can easily find out
 where the deprecated nav calls are coming from.

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6534#comment:22>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac

More information about the buddypress-trac mailing list