Make WordPress Core


Ignore:
Timestamp:
10/05/2017 01:37:39 AM (9 years ago)
Author:
SergeyBiryukov
Message:

Menus: Introduce wp_get_nav_menu_name() to retrieve the name of a navigation menu as set in the admin.

Props markoheijnen, christophherr, SpencerFinnell, wojtek.szkutnik, sagarprajapati, welcher, SergeyBiryukov.
Fixes #13910.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/nav-menu.php

    r41008 r41766  
    157157                $this->assertSame( $term->name, $menu_items[0]->title );
    158158                $this->assertEquals( $t, $menu_items[0]->object_id );
     159        }
     160
     161        /**
     162         * @ticket 13910
     163         */
     164        function test_wp_get_nav_menu_name() {
     165                // Register a nav menu location.
     166                register_nav_menu( 'primary', 'Primary Navigation' );
     167
     168                // Create a menu with a title.
     169                $menu = wp_create_nav_menu( 'My Menu' );
     170
     171                // Assign the menu to the `primary` location.
     172                $locations = get_nav_menu_locations();
     173                $menu_obj = wp_get_nav_menu_object( $menu );
     174                $locations['primary'] = $menu_obj->term_id;
     175                set_theme_mod( 'nav_menu_locations', $locations );
     176
     177                $this->assertEquals( 'My Menu', wp_get_nav_menu_name( 'primary' ) );
    159178        }
    160179
Note: See TracChangeset for help on using the changeset viewer.