Make WordPress Core

Opened 8 years ago

Last modified 7 years ago

#37079 new enhancement

Add new filter pre_wp_get_nav_menu_items

Reported by: spacedmonkey's profile spacedmonkey Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Menus Keywords: has-patch
Focuses: Cc:


Add a filter into wp_get_nav_menu_items function. This allows you to short-circuit the function and stop the get_objects_in_term (which is uncached) function from running.

Attachments (2)

37079.patch (1.8 KB) - added by spacedmonkey 8 years ago.
37079.1.patch (821 bytes) - added by spacedmonkey 8 years ago.

Download all attachments as: .zip

Change History (7)

8 years ago

#1 @Clorith
8 years ago

#37078 was marked as a duplicate.

This ticket was mentioned in Slack in #core by spacedmonkey. View the logs.

8 years ago

#3 @swissspidy
8 years ago

  • Keywords has-patch added

Hey there,

Thanks for creating this ticket! Can you give us an example of how you'd use the filter / explain the use case a bit more?

#4 @spacedmonkey
8 years ago

I have a navigation caching plugin called advanced-nav-cache.
This plugin is designed to cache the queries / output of menus. I have been able filter much of navigation piece to stop sql queries from running in get_objects_in_term. This function has no filter and is uncachable. Adding this filter will me to hot wire the wp_get_nav_menu_items function and stop this call.

#5 @david.binda
7 years ago

Hello there! After looking into performance of the wp_nav_menu function and possibilities of caching the nav menus, I came to the same conclusion as @spacedmonkey . Such a filter, as proposed in this ticket, could be used for effectively caching nav menu items in case persistent object caching is used.

There currently is no good way to cache the nav menus, unless breaking classes indicating current page and it's ancestors when caching the final output.

What could be done in order to keep this ticket moving?

Note: See TracTickets for help on using tickets.