Ticket #13378: 13378.diff

File 13378.diff, 1.7 KB (added by ryan, 3 years ago)

Beginning of register_nav_menus()

Line 
1Index: wp-includes/nav-menu-template.php
2===================================================================
3--- wp-includes/nav-menu-template.php   (revision 14604)
4+++ wp-includes/nav-menu-template.php   (working copy)
5@@ -192,7 +192,7 @@
6 function wp_nav_menu( $args = array() ) {
7        $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'menu_class' => 'menu', 'echo' => true,
8        'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '',
9-       'depth' => 0, 'walker' => '', 'context' => 'frontend' );
10+       'depth' => 0, 'walker' => '', 'context' => 'frontend', 'slot' => '' );
11 
12        $args = wp_parse_args( $args, $defaults );
13        $args = apply_filters( 'wp_nav_menu_args', $args );
14@@ -201,6 +201,12 @@
15        // Get the nav menu
16        $menu = wp_get_nav_menu_object( $args->menu );
17 
18+       if ( ! $menu && $slot ) {
19+               $slots = get_option('nav_menu_slots');
20+               if ( isset($slots) && isset($slots[$slot]) )
21+                       $menu = wp_get_nav_menu_object( $slots['slot'] );
22+       }
23+
24        // If we couldn't find a menu based off the menu argument
25        // get the first menu that has items.
26        if ( ! $menu ) {
27Index: wp-includes/nav-menu.php
28===================================================================
29--- wp-includes/nav-menu.php    (revision 14604)
30+++ wp-includes/nav-menu.php    (working copy)
31@@ -62,6 +62,21 @@
32 }
33 
34 /**
35+ * Register nav menus for a theme.
36+ *
37+ * @since 3.0.0
38+ *
39+ * @param array Associative array of menu slot identifiers and descriptions.
40+ */
41+function register_nav_menus( $menus = array() ) {
42+       global $_wp_registered_nav_menus;
43+
44+       add_theme_support( 'nav-menus' );
45+
46+       $_wp_registered_nav_menus = $menus;
47+}
48+
49+/**
50  * Determine whether the given ID is a nav menu item.
51  *
52  * @since 3.0.0