Make WordPress Core


Ignore:
Timestamp:
10/10/2017 05:07:31 PM (7 years ago)
Author:
obenland
Message:

Menus: Limit mapping to registered locations

Weeds out orphaned locations, so their information will not continue to be mapped to future themes.

Fixes #42121.

File:
1 edited

Legend:

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

    r41237 r41811  
    4949
    5050    /**
     51     * Only registered locations should be mapped and returned.
     52     *
     53     * @covers wp_map_nav_menu_locations()
     54     */
     55    function test_filter_registered_locations() {
     56        $this->register_nav_menu_locations( array( 'primary', 'secondary' ) );
     57        $old_next_theme_nav_menu_locations = $prev_theme_nav_menu_locations = array(
     58            'primary' => 1,
     59            'secondary' => 2,
     60            'social' => 3,
     61        );
     62        $new_next_theme_nav_menu_locations = wp_map_nav_menu_locations( $old_next_theme_nav_menu_locations, $prev_theme_nav_menu_locations );
     63
     64        $expected_nav_menu_locations = array(
     65            'primary' => 1,
     66            'secondary' => 2,
     67        );
     68        $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations );
     69    }
     70
     71    /**
    5172     * Locations with the same name should map, switching to a theme not previously-active.
    5273     *
Note: See TracChangeset for help on using the changeset viewer.