Opened 11 years ago
Last modified 11 years ago
#5198 new defect (bug)
WP menu current-menu-item class and BP components
Reported by: | henrywright | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Contributions | Priority: | normal |
Severity: | normal | Version: | 1.8.1 |
Component: | Route Parser | Keywords: | reporter-feedback |
Cc: |
Description
I recently noticed something strange with reference WP menus and BuddyPress components.
I use a WP menu in my site footer to output an unordered list of links (e.g. Members, Help, Privacy, Sitemap and so on).
A current-menu-item
class is automatically added to a <li>
element when appropriate - this is default WP menu behaviour.
The problem is, a current-menu-item
class gets added to my 'Members' list item when I am viewing any page which is part of a BP component e.g when I visit
members/username/settings/notifications/ members/username/messages/sentbox members/username/messages/compose members/username/following/
all result in the 'Members' list item looking like this
<li class="current-menu-item"><a href="/members/">Members</a></li>
Change History (3)
#2
@
11 years ago
Hi Boone,
Thanks for explaining the reason why it works how it does. I suppose I look at the members page as a discrete area of BuddyPress. The directory if you like, an area separate to the component pages (activity, profile and so on). I expected WP to treat it as such. That said, I can also see why it is treated as a mother page and as you say, the ideal behaviour is a bit of a grey area.
#3
@
11 years ago
- Component changed from Core to Rewrite Rules
- Milestone changed from Awaiting Review to Future Release
We should loop back to this in the future, as I agree it's a bit strange and I agree with henrywright's interpretation of how it should work -- but we need more feedback, and a better way to handle this inside BP. Perhaps the switch to rewrite rules would be a good time to revisit this if it's decided we want to change this.
WordPress adds the 'current-menu-item' class in wp-includes/nav-menu-template.php, starting around line 350. The logic is something like this: if the queried object is the 'Members' page, then the 'Members' nav item should get the 'current-menu-item' class. The way BP's template loader works, all pages underneath /members/ correspond to the 'Members' WP page. So, what you're seeing here is expected behavior.
I can see why it might not be what you want, but it's not obvious to me what the ideal behavior *should* be. Can you give details about what you'd expect to see?