WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#13656 closed enhancement (fixed)

Allow multiple "contexts" for wp_nav_menu()

Reported by: nathanrice Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Menus Keywords: has-patch
Focuses: Cc:

Description

It occurred to me that 'frontend' or 'backend' as a context for the nav menus is only partially complete. For instance, I may want to specify that not only is this menu is displaying on the frontend, but that it's in the header, or footer, or sidebar, etc.

I think it's just more accurate that way. Patch submitted.

Attachments (1)

nav-menu-template.php.diff (1.0 KB) - added by nathanrice 9 years ago.

Download all attachments as: .zip

Change History (12)

#1 @nacin
9 years ago

The 'context' in _wp_menu_item_classes_by_context is not the same as the 'context' that is the argument to wp_nav_menu. That's really just an internal argument we use, as wp_nav_menu() is also used in the admin.

What you're probably looking for is theme_location. [14620], #13378.

#2 @nacin
9 years ago

  • Milestone 3.0 deleted
  • Resolution set to worksforme
  • Status changed from new to closed

#3 @filosofo
9 years ago

To elaborate on what nacin said, basically context acts as a private property just meant to say basically "don't use a fallback function" and "don't try to determine the current query context for class names" when the context is "backend."

Perhaps that could be better indicated with a name change or comments.

#4 @nacin
9 years ago

Perhaps that could be better indicated with a name change or comments.

Agreed. Thoughts? 'backend' = true, defaults to false?

#5 @filosofo
9 years ago

yeah, I like that idea

#6 @nacin
9 years ago

  • Milestone set to 3.0
  • Resolution worksforme deleted
  • Status changed from closed to reopened

#7 @automattor
9 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [15075]) Remove vestigial 'context' code for wp_nav_menu. This was used when we used to use the same function as a theme template tag and admin template function (now we don't.) fixes #13656.

#8 @nathanrice
9 years ago

OK, so "context" is only a means of indicating if the menu is being displayed on the front or back end? It does seem like it's misnamed. I like nacin's idea of renaming it as a true/false flag.

#9 follow-up: @filosofo
9 years ago

actually, as of r15075 context is gone.

When menus first went in wp_nav_menu was printing the menu edit page, but it no longer does it, so context is not needed.

#10 @nacin
9 years ago

Also, for what it's worth, theme_location was inspired by the menu assignment limitations that were painfully obvious when taking a look at what you guys came up with over at StudioPress.

#11 in reply to: ↑ 9 @nathanrice
9 years ago

Replying to filosofo:

actually, as of r15075 context is gone.

When menus first went in wp_nav_menu was printing the menu edit page, but it no longer does it, so context is not needed.

Ahh, good to know.

Replying to nacin:

Also, for what it's worth, theme_location was inspired by the menu assignment limitations that were painfully obvious when taking a look at what you guys came up with over at StudioPress.

Interesting :-) Good to know our pain can help make WordPress better. Hopefully, we can continue to provide good feedback to you guys from a themer's perspective, and help make the software better for everybody.

Note: See TracTickets for help on using tickets.