WordPress.org

Make WordPress Core

Opened 18 months ago

Last modified 3 months ago

#37079 new enhancement

Add new filter pre_wp_get_nav_menu_items

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

Description

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 18 months ago.
37079.1.patch (821 bytes) - added by spacedmonkey 18 months ago.

Download all attachments as: .zip

Change History (7)

#1 @Clorith
18 months ago

#37078 was marked as a duplicate.

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


18 months ago

#3 @swissspidy
17 months 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
17 months 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
3 months 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.