[buddypress-trac] [BuddyPress Trac] #6503: Separate functions for creating a new nav link and registering a screen function.

buddypress-trac noreply at wordpress.org
Wed Jul 8 01:57:32 UTC 2015


#6503: Separate functions for creating a new nav link and registering a screen
function.
------------------------------+-----------------------------
 Reporter:  dcavins           |       Owner:
     Type:  enhancement       |      Status:  new
 Priority:  normal            |   Milestone:  Future Release
Component:  Component - Core  |     Version:  2.3.1
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |
------------------------------+-----------------------------

Comment (by dcavins):

 I've added a patch for separating the addition of the nav link from
 registering the screen function in `bp_core_new_nav_item()`. In working
 through the changes, I had a few questions:

 1. This check occurs in the original file _after_ the link is added to the
 `$bp->bp_nav` global
 {{{
 if ( empty( $r['show_for_displayed_user'] ) && ! bp_user_has_access() ) {
         return false;
 }
 }}}
 Can anyone think of a reason for this order of operations? I moved it
 before things happen, so if the old order of operations is important,
 please let me know.

 2. There's a `do_action( 'bp_core_new_nav_item' )` at the end of
 `bp_core_new_nav_item()`. I had to choose where that should go, and left
 it after the screen function is registered. Is that appropriate?

 3. `bp_core_new_nav_item ()` is only called in `BP_Component::setup_nav()`
 which doesn't currently take advantage of the split, so I've left that
 call as is for now.

 Thanks for your feedback! I think there could be some more unit tests, so
 if anyone has ideas for cases to test, please let me know that as well,
 and I'll write some tests.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6503#comment:12>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list