[buddypress-trac] [BuddyPress] #5012: bp_nav_menu() function problems

buddypress-trac noreply at wordpress.org
Mon May 20 13:03:01 UTC 2013


#5012: bp_nav_menu() function problems
-------------------------------+------------------------------
 Reporter:  therearwindow      |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Core               |     Version:  1.7
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |
-------------------------------+------------------------------
Changes (by boonebgorges):

 * keywords:   => reporter-feedback


Old description:

> WP (latest version) & BP (1.7.2) Fresh installation.
>
> Here is the problem with bp_nav_menu()
>
> Default menu for admin user:
>
> <div class="menu-bp-container"><ul id="menu-bp" class="menu"><li id
> ="activity-personal-li"><a href="http://activity/">Activity</a>
> <ul class="sub-menu">
>         <li id="just-me-personal-li"><a
> href="http://example.com/wp2/members/admin/activity/">Personal</a></li>
>         <li id="activity-mentions-personal-li"><a
> href="http://example.com/wp2/members/admin/activity/mentions/">Mentions</a></li>
>         <li id="activity-favs-personal-li"><a
> href="http://example.com/wp2/members/admin/activity/favorites/">Favorites</a></li>
>         <li id="activity-friends-personal-li"><a
> href="http://example.com/wp2/members/admin/activity/friends/">Friends</a></li>
>         <li id="activity-groups-personal-li"><a
> href="http://example.com/wp2/members/admin/activity/groups/">Groups</a></li>
> </ul>
> </li>
> <li id="xprofile-personal-li"><a href="http://profile/">Profile</a>
> <ul class="sub-menu">
>         <li id="public-personal-li"><a
> href="http://example.com/wp2/members/admin/profile/">View</a></li>
>         <li id="edit-personal-li"><a
> href="http://example.com/wp2/members/admin/profile/edit/">Edit</a></li>
>         <li id="change-avatar-personal-li"><a
> href="http://example.com/wp2/members/admin/profile/change-avatar/">Change
> Avatar</a></li>
> </ul>
> </li>
> <li id="messages-personal-li"><a href="http://messages/">Messages
> <span>0</span></a>
> <ul class="sub-menu">
>         <li id="inbox-personal-li"><a
> href="http://example.com/wp2/members/admin/messages/">Inbox</a></li>
>         <li id="sentbox-personal-li"><a
> href="http://example.com/wp2/members/admin/messages/sentbox/">Sent</a></li>
>         <li id="compose-personal-li"><a
> href="http://example.com/wp2/members/admin/messages/compose/">Compose</a></li>
>         <li id="notices-personal-li"><a
> href="http://example.com/wp2/members/admin/messages/notices/">Notices</a></li>
> </ul>
> </li>
> <li id="friends-personal-li"><a href="http://friends/">Friends
> <span>0</span></a>
> <ul class="sub-menu">
>         <li id="friends-my-friends-personal-li"><a
> href="http://example.com/wp2/members/admin/friends/">Friendships</a></li>
>         <li id="requests-personal-li"><a
> href="http://example.com/wp2/members/admin/friends/requests/">Requests</a></li>
> </ul>
> </li>
> <li id="groups-personal-li"><a href="http://groups/">Groups
> <span>0</span></a>
> <ul class="sub-menu">
>         <li id="groups-my-groups-personal-li"><a
> href="http://example.com/wp2/members/admin/groups/">Memberships</a></li>
>         <li id="invites-personal-li"><a
> href="http://example.com/wp2/members/admin/groups/invites/">Invitations</a></li>
> </ul>
> </li>
> <li id="settings-personal-li"><a href="http://settings/">Settings</a>
> <ul class="sub-menu">
>         <li id="general-personal-li"><a
> href="http://example.com/wp2/members/admin/settings/">General</a></li>
>         <li id="notifications-personal-li"><a
> href="http://example.com/wp2/members/admin/settings/notifications/">Notifications</a></li>
>         <li id="capabilities-personal-li"><a
> href="http://example.com/wp2/members/admin/settings/capabilities/">Capabilities</a></li>
> </ul>
> </li>
> </ul></div>
>

>
> Default menu for normal user:
>
> <div class="menu-bp-container"><ul class="menu" id="menu-bp"><li id
> ="activity-personal-li"><a href="http://activity/">Activity</a>
> <ul class="sub-menu">
>         <li id="just-me-personal-li"><a
> href="http://example.com/wp2/members/antton/activity/">Personal</a></li>
>         <li id="activity-mentions-personal-li"><a
> href="http://example.com/wp2/members/antton/activity/mentions/">Mentions</a></li>
>         <li id="activity-favs-personal-li"><a
> href="http://example.com/wp2/members/antton/activity/favorites/">Favorites</a></li>
>         <li id="activity-friends-personal-li"><a
> href="http://example.com/wp2/members/antton/activity/friends/">Friends</a></li>
>         <li id="activity-groups-personal-li"><a
> href="http://example.com/wp2/members/antton/activity/groups/">Groups</a></li>
> </ul>
> </li>
> <li id="xprofile-personal-li"><a href="http://profile/">Profile</a>
> <ul class="sub-menu">
>         <li id="public-personal-li"><a
> href="http://example.com/wp2/members/antton/profile/">View</a></li>
> </ul>
> </li>
> <li id="friends-personal-li"><a href="http://friends/">Friends
> <span>0</span></a>
> <ul class="sub-menu">
>         <li id="friends-my-friends-personal-li"><a
> href="http://example.com/wp2/members/antton/friends/">Friendships</a></li>
> </ul>
> </li>
> <li id="groups-personal-li"><a href="http://groups/">Groups
> <span>0</span></a>
> <ul class="sub-menu">
>         <li id="groups-my-groups-personal-li"><a
> href="http://example.com/wp2/members/antton/groups/">Memberships</a></li>
> </ul>
> </li>
> </ul></div>
>

>
> Default menu inside a group created by normal user:
> http://example.com/wp2/groups/example_group/
>
> <div class="menu-bp-container">
> <ul class="menu" id="menu-bp">
> <li id="groups-personal-li"><a
> href="http://example_group/">Memberships</a>
> <ul class="sub-menu">
>         <li id="groups-my-groups-personal-li"><a
> href="http://example.com/wp2/members/antton/groups/">Memberships</a></li>
> </ul>
> </li>
> <li id="activity-personal-li"><a href="http://activity/">Activity</a>
> <ul class="sub-menu">
>         <li id="just-me-personal-li"><a
> href="http://example.com/wp2/members/antton/activity/">Personal</a></li>
>         <li id="activity-mentions-personal-li"><a
> href="http://example.com/wp2/members/antton/activity/mentions/">Mentions</a></li>
>         <li id="activity-favs-personal-li"><a
> href="http://example.com/wp2/members/antton/activity/favorites/">Favorites</a></li>
>         <li id="activity-friends-personal-li"><a
> href="http://example.com/wp2/members/antton/activity/friends/">Friends</a></li>
>         <li id="activity-groups-personal-li"><a
> href="http://example.com/wp2/members/antton/activity/groups/">Groups</a></li>
> </ul>
> </li>
> <li id="xprofile-personal-li"><a href="http://profile/">Profile</a>
> <ul class="sub-menu">
>         <li id="public-personal-li"><a
> href="http://example.com/wp2/members/antton/profile/">View</a></li>
> </ul>
> </li>
> <li id="friends-personal-li"><a href="http://friends/">Friends
> <span>0</span></a>
> <ul class="sub-menu">
>         <li id="friends-my-friends-personal-li"><a
> href="http://example.com/wp2/members/antton/friends/">Friendships</a></li>
> </ul>
> </li>
> <li id="groups-personal-li"><a href="http://groups/">Groups
> <span>1</span></a></li>
> <li class="current-menu-item" id="home-personal-li"><a
> href="http://example.com/wp2/groups/example_group/">Home</a></li>
> <li id="members-personal-li"><a
> href="http://example.com/wp2/groups/example_group/members/">Members
> <span>1</span></a></li>
> <li id="invite-personal-li"><a
> href="http://example.com/wp2/groups/example_group/send-invites/">Send
> Invites</a></li>
> <li id="admin-personal-li"><a
> href="http://example.com/wp2/groups/example_group/admin/">Admin</a></li>
> </ul></div>
>

> As you can see the top level URLs are broken. Also groups-personal-li id
> is used twice, and I really can't appreciate the difference between
> Memberships or Groups Top levels, there are more problems as you can see
> that the Messages Top level menu disappear, and except the submenus of
> the TopLevel Activity the others doesn't have all their sub-menus.
>
> About the submenus html structure of the groups submenu It's quite
> obvious that we need to rewrite.
>

> I found a 'solution' about missing submenu items, but I'm not sure if
> it's gonna be soo good. Change the following function the menu works
> properly. Messages toplevel appear and load all submenu items as well.
>

> function bp_core_can_edit_settings() {
>         if ( bp_is_my_profile() )
>                 return true;
>
>         //if ( bp_current_user_can( 'bp_moderate' ) || current_user_can(
> 'edit_users' ) )
>         if ( bp_current_user_can( 'bp_moderate' ) || !current_user_can(
> 'edit_users' ) )  // Maybe I'm opening a new bug :(
>                 return true;
>
>         return false;
> }

New description:

 WP (latest version) & BP (1.7.2) Fresh installation.

 Here is the problem with bp_nav_menu()

 Default menu for admin user:
 {{{
 <div class="menu-bp-container"><ul id="menu-bp" class="menu"><li id
 ="activity-personal-li"><a href="http://activity/">Activity</a>
 <ul class="sub-menu">
         <li id="just-me-personal-li"><a
 href="http://example.com/wp2/members/admin/activity/">Personal</a></li>
         <li id="activity-mentions-personal-li"><a
 href="http://example.com/wp2/members/admin/activity/mentions/">Mentions</a></li>
         <li id="activity-favs-personal-li"><a
 href="http://example.com/wp2/members/admin/activity/favorites/">Favorites</a></li>
         <li id="activity-friends-personal-li"><a
 href="http://example.com/wp2/members/admin/activity/friends/">Friends</a></li>
         <li id="activity-groups-personal-li"><a
 href="http://example.com/wp2/members/admin/activity/groups/">Groups</a></li>
 </ul>
 </li>
 <li id="xprofile-personal-li"><a href="http://profile/">Profile</a>
 <ul class="sub-menu">
         <li id="public-personal-li"><a
 href="http://example.com/wp2/members/admin/profile/">View</a></li>
         <li id="edit-personal-li"><a
 href="http://example.com/wp2/members/admin/profile/edit/">Edit</a></li>
         <li id="change-avatar-personal-li"><a
 href="http://example.com/wp2/members/admin/profile/change-avatar/">Change
 Avatar</a></li>
 </ul>
 </li>
 <li id="messages-personal-li"><a href="http://messages/">Messages
 <span>0</span></a>
 <ul class="sub-menu">
         <li id="inbox-personal-li"><a
 href="http://example.com/wp2/members/admin/messages/">Inbox</a></li>
         <li id="sentbox-personal-li"><a
 href="http://example.com/wp2/members/admin/messages/sentbox/">Sent</a></li>
         <li id="compose-personal-li"><a
 href="http://example.com/wp2/members/admin/messages/compose/">Compose</a></li>
         <li id="notices-personal-li"><a
 href="http://example.com/wp2/members/admin/messages/notices/">Notices</a></li>
 </ul>
 </li>
 <li id="friends-personal-li"><a href="http://friends/">Friends
 <span>0</span></a>
 <ul class="sub-menu">
         <li id="friends-my-friends-personal-li"><a
 href="http://example.com/wp2/members/admin/friends/">Friendships</a></li>
         <li id="requests-personal-li"><a
 href="http://example.com/wp2/members/admin/friends/requests/">Requests</a></li>
 </ul>
 </li>
 <li id="groups-personal-li"><a href="http://groups/">Groups
 <span>0</span></a>
 <ul class="sub-menu">
         <li id="groups-my-groups-personal-li"><a
 href="http://example.com/wp2/members/admin/groups/">Memberships</a></li>
         <li id="invites-personal-li"><a
 href="http://example.com/wp2/members/admin/groups/invites/">Invitations</a></li>
 </ul>
 </li>
 <li id="settings-personal-li"><a href="http://settings/">Settings</a>
 <ul class="sub-menu">
         <li id="general-personal-li"><a
 href="http://example.com/wp2/members/admin/settings/">General</a></li>
         <li id="notifications-personal-li"><a
 href="http://example.com/wp2/members/admin/settings/notifications/">Notifications</a></li>
         <li id="capabilities-personal-li"><a
 href="http://example.com/wp2/members/admin/settings/capabilities/">Capabilities</a></li>
 </ul>
 </li>
 </ul></div>

 }}}

 Default menu for normal user:
 {{{
 <div class="menu-bp-container"><ul class="menu" id="menu-bp"><li id
 ="activity-personal-li"><a href="http://activity/">Activity</a>
 <ul class="sub-menu">
         <li id="just-me-personal-li"><a
 href="http://example.com/wp2/members/antton/activity/">Personal</a></li>
         <li id="activity-mentions-personal-li"><a
 href="http://example.com/wp2/members/antton/activity/mentions/">Mentions</a></li>
         <li id="activity-favs-personal-li"><a
 href="http://example.com/wp2/members/antton/activity/favorites/">Favorites</a></li>
         <li id="activity-friends-personal-li"><a
 href="http://example.com/wp2/members/antton/activity/friends/">Friends</a></li>
         <li id="activity-groups-personal-li"><a
 href="http://example.com/wp2/members/antton/activity/groups/">Groups</a></li>
 </ul>
 </li>
 <li id="xprofile-personal-li"><a href="http://profile/">Profile</a>
 <ul class="sub-menu">
         <li id="public-personal-li"><a
 href="http://example.com/wp2/members/antton/profile/">View</a></li>
 </ul>
 </li>
 <li id="friends-personal-li"><a href="http://friends/">Friends
 <span>0</span></a>
 <ul class="sub-menu">
         <li id="friends-my-friends-personal-li"><a
 href="http://example.com/wp2/members/antton/friends/">Friendships</a></li>
 </ul>
 </li>
 <li id="groups-personal-li"><a href="http://groups/">Groups
 <span>0</span></a>
 <ul class="sub-menu">
         <li id="groups-my-groups-personal-li"><a
 href="http://example.com/wp2/members/antton/groups/">Memberships</a></li>
 </ul>
 </li>
 </ul></div>
 }}}


 Default menu inside a group created by normal user:
 http://example.com/wp2/groups/example_group/
 {{{
 <div class="menu-bp-container">
 <ul class="menu" id="menu-bp">
 <li id="groups-personal-li"><a
 href="http://example_group/">Memberships</a>
 <ul class="sub-menu">
         <li id="groups-my-groups-personal-li"><a
 href="http://example.com/wp2/members/antton/groups/">Memberships</a></li>
 </ul>
 </li>
 <li id="activity-personal-li"><a href="http://activity/">Activity</a>
 <ul class="sub-menu">
         <li id="just-me-personal-li"><a
 href="http://example.com/wp2/members/antton/activity/">Personal</a></li>
         <li id="activity-mentions-personal-li"><a
 href="http://example.com/wp2/members/antton/activity/mentions/">Mentions</a></li>
         <li id="activity-favs-personal-li"><a
 href="http://example.com/wp2/members/antton/activity/favorites/">Favorites</a></li>
         <li id="activity-friends-personal-li"><a
 href="http://example.com/wp2/members/antton/activity/friends/">Friends</a></li>
         <li id="activity-groups-personal-li"><a
 href="http://example.com/wp2/members/antton/activity/groups/">Groups</a></li>
 </ul>
 </li>
 <li id="xprofile-personal-li"><a href="http://profile/">Profile</a>
 <ul class="sub-menu">
         <li id="public-personal-li"><a
 href="http://example.com/wp2/members/antton/profile/">View</a></li>
 </ul>
 </li>
 <li id="friends-personal-li"><a href="http://friends/">Friends
 <span>0</span></a>
 <ul class="sub-menu">
         <li id="friends-my-friends-personal-li"><a
 href="http://example.com/wp2/members/antton/friends/">Friendships</a></li>
 </ul>
 </li>
 <li id="groups-personal-li"><a href="http://groups/">Groups
 <span>1</span></a></li>
 <li class="current-menu-item" id="home-personal-li"><a
 href="http://example.com/wp2/groups/example_group/">Home</a></li>
 <li id="members-personal-li"><a
 href="http://example.com/wp2/groups/example_group/members/">Members
 <span>1</span></a></li>
 <li id="invite-personal-li"><a
 href="http://example.com/wp2/groups/example_group/send-invites/">Send
 Invites</a></li>
 <li id="admin-personal-li"><a
 href="http://example.com/wp2/groups/example_group/admin/">Admin</a></li>
 </ul></div>
 }}}

 As you can see the top level URLs are broken. Also groups-personal-li id
 is used twice, and I really can't appreciate the difference between
 Memberships or Groups Top levels, there are more problems as you can see
 that the Messages Top level menu disappear, and except the submenus of the
 TopLevel Activity the others doesn't have all their sub-menus.

 About the submenus html structure of the groups submenu It's quite obvious
 that we need to rewrite.


 I found a 'solution' about missing submenu items, but I'm not sure if it's
 gonna be soo good. Change the following function the menu works properly.
 Messages toplevel appear and load all submenu items as well.

 {{{
 function bp_core_can_edit_settings() {
         if ( bp_is_my_profile() )
                 return true;

         //if ( bp_current_user_can( 'bp_moderate' ) || current_user_can(
 'edit_users' ) )
         if ( bp_current_user_can( 'bp_moderate' ) || !current_user_can(
 'edit_users' ) )  // Maybe I'm opening a new bug :(
                 return true;

         return false;
 }
 }}}

--

Comment:

 > As you can see the top level URLs are broken

 I see that in the markup you've pasted here, but I can't reproduce it on
 my current setup. What URL are you looking at when the nav menu is
 rendered? Is it a user page (example.com/members/foo/)?

 > groups-personal-li id is used twice

 Confirmed. This does look like a bug. It looks like bp_nav_menu() has code
 that's supposed to prevent these sorts of duplicates, but I guess it's not
 working.

 > I really can't appreciate the difference between Memberships or Groups
 Top levels

 I don't believe that Memberships is supposed to be a top level item - I
 think it's supposed to fall under Groups. I'm guessing that the nesting is
 breaking because of whatever's causing your top-level URLs to break.

 > the Messages Top level menu disappear, and except the submenus of the
 TopLevel? Activity the others doesn't have all their sub-menus.

 Ditto. I'm guessing that something funny is happening because of where you
 are loading the menu, and this is the single cause of several of these
 issues. If you can provide more info about how you're using bp_nav_menu(),
 it'd be helpful.

 >  found a 'solution' about missing submenu items, but I'm not sure if
 it's gonna be soo good.

 You're right, it's not good :) It will allow anyone to edit anyone else's
 settings.

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


More information about the buddypress-trac mailing list