Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#29461 closed enhancement (fixed)

Use get_registered_nav_menus() instead of $_wp_registered_nav_menus

Reported by: nacin's profile nacin Owned by: voldemortensen's profile voldemortensen
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.0
Component: Menus Keywords: good-first-bug has-patch
Focuses: Cc:

Description

Follow up to #27735. Whenever we're only reading from this value, we should use the public API.

Attachments (1)

29461.diff (1.2 KB) - added by voldemortensen 10 years ago.

Download all attachments as: .zip

Change History (7)

#1 @jesin
10 years ago

I could only find 4 uses of $_wp_registered_nav_menus in wp-includes/nav-menu.php.

  1. register_nav_menus()
  2. unregister_nav_menu()
  3. get_registered_nav_menus()
  4. has_nav_menu()

This variable is modified in 1 and 2. So the only valid change would be 4. I think this patch should do.

I couldn't find other occurrences of $_wp_registered_nav_menus.

$grep -rn "\$_wp_registered_nav_menus" --exclude-dir=.svn src/ | cut -d':' -f1-2

src/wp-includes/nav-menu.php:74
src/wp-includes/nav-menu.php:78
src/wp-includes/nav-menu.php:89
src/wp-includes/nav-menu.php:91
src/wp-includes/nav-menu.php:92
src/wp-includes/nav-menu.php:93
src/wp-includes/nav-menu.php:119
src/wp-includes/nav-menu.php:120
src/wp-includes/nav-menu.php:121
src/wp-includes/nav-menu.php:145
src/wp-includes/nav-menu.php:147

#2 @voldemortensen
10 years ago

My screen didn't refresh before I added the patch. If comment:1 is correct, my patch can be ignored.

#3 @voldemortensen
10 years ago

  • Keywords has-patch added

#4 @SergeyBiryukov
10 years ago

  • Milestone changed from Future Release to 4.1

#5 @DrewAPicture
10 years ago

  • Owner set to voldemortensen
  • Status changed from new to assigned

#6 @SergeyBiryukov
10 years ago

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

In 29717:

Use get_registered_nav_menus() in has_nav_menu().

props voldemortensen.
fixes #29461.

Note: See TracTickets for help on using tickets.