Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#25263 closed defect (bug) (fixed)

Use wp_get_nav_menus() instead of get_terms('nav_menu') in WP_Nav_Menu_Widget

Reported by: frank-klein's profile Frank Klein Owned by: wonderboymusic's profile wonderboymusic
Milestone: 3.7 Priority: normal
Severity: normal Version: 3.0
Component: Widgets Keywords: has-patch commit
Focuses: Cc:


The wp_get_nav_menus() function has a wp_get_nav_menus filter that allows you to filter the array of menu objects returned by the function.

The WP_Nav_Menu_Widget class however uses a direct call to get_terms('nav_menu') to render the widget form. As such, the wp_get_nav_menus filter is not applied to the menus available on the widget configuration screen.

The attached patch fixes this by using the wp_get_nav_menus() function.

Attachments (1)

25263.patch (545 bytes) - added by Frank Klein 10 years ago.

Download all attachments as: .zip

Change History (6)

#1 @SergeyBiryukov
10 years ago

  • Milestone changed from Awaiting Review to 3.7

This should probably be wp_get_nav_menus( array( 'orderby' => 'name' ) ) to keep the current ordering (unlike get_terms(), wp_get_nav_menus() uses 'none' by default).

@Frank Klein
10 years ago

#2 @Frank Klein
10 years ago

Thanks, I updated the patch accordingly.

#3 @SergeyBiryukov
10 years ago

  • Keywords commit added

When uploading a new version of a patch, please don't overwrite the old one, so that context is preserved.

#4 @DrewAPicture
10 years ago

Tested 25263.patch by filtering on the wp_get_nav_menus hook before and after.

Works for me.

#5 @wonderboymusic
10 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 25332:

Use wp_get_nav_menus() instead of get_terms('nav_menu') in WP_Nav_Menu_Widget to preserve use of `wp_get_nav_menus' filter.

Props Frank Klein.
Fixes #25263.

Note: See TracTickets for help on using tickets.