Ticket #42121: 42121.2.diff
File 42121.2.diff, 2.7 KB (added by , 8 years ago) |
---|
-
src/wp-includes/class-wp-customize-nav-menus.php
597 597 // Attempt to re-map the nav menu location assignments when previewing a theme switch. 598 598 $mapped_nav_menu_locations = array(); 599 599 if ( ! $this->manager->is_theme_active() ) { 600 $mapped_nav_menu_locations = wp_map_nav_menu_locations( get_nav_menu_locations(), $this->original_nav_menu_locations ); 600 $theme_mods = get_option( 'theme_mods_' . $this->manager->get_stylesheet(), array() ); 601 602 // If there is no data from a previous activation, start fresh. 603 if ( empty( $theme_mods['nav_menu_locations'] ) ) { 604 $theme_mods['nav_menu_locations'] = array(); 605 } 606 607 $mapped_nav_menu_locations = wp_map_nav_menu_locations( $theme_mods['nav_menu_locations'], $this->original_nav_menu_locations ); 601 608 } 602 609 603 610 foreach ( $locations as $location => $description ) { -
src/wp-includes/nav-menu.php
1084 1084 * @return array Nav menus mapped to new nav menu locations. 1085 1085 */ 1086 1086 function wp_map_nav_menu_locations( $new_nav_menu_locations, $old_nav_menu_locations ) { 1087 $registered_nav_menus = get_registered_nav_menus(); 1087 $registered_nav_menus = get_registered_nav_menus(); 1088 $new_nav_menu_locations = array_intersect_key( $new_nav_menu_locations, $registered_nav_menus ); 1088 1089 1089 1090 // Short-circuit if there are no old nav menu location assignments to map. 1090 1091 if ( empty( $old_nav_menu_locations ) ) { -
tests/phpunit/tests/menu/nav-menu.php
47 47 $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); 48 48 } 49 49 50 51 function test_filter_registered_locations() { 52 $this->register_nav_menu_locations( array( 'primary', 'secondary' ) ); 53 $old_next_theme_nav_menu_locations = $prev_theme_nav_menu_locations = array( 54 'primary' => 1, 55 'secondary' => 2, 56 'social' => 3, 57 ); 58 $new_next_theme_nav_menu_locations = wp_map_nav_menu_locations( $old_next_theme_nav_menu_locations, $prev_theme_nav_menu_locations ); 59 60 $expected_nav_menu_locations = array( 61 'primary' => 1, 62 'secondary' => 2, 63 ); 64 $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); 65 } 66 50 67 /** 51 68 * Locations with the same name should map, switching to a theme not previously-active. 52 69 *