Ticket #45018: 45018.3.diff
File 45018.3.diff, 2.3 KB (added by , 2 years ago) |
---|
-
src/wp-includes/nav-menu.php
1139 1139 foreach ( $registered_nav_menus as $new_location => $name ) { 1140 1140 1141 1141 // ...actually match! 1142 if ( false === stripos( $new_location, $slug ) && false === stripos( $slug, $new_location ) ) {1142 if ( is_string( $new_location ) && false === stripos( $new_location, $slug ) && false === stripos( $slug, $new_location ) ) { 1143 1143 continue; 1144 } elseif ( is_numeric( $new_location ) && $new_location !== $slug ) { 1145 continue; 1144 1146 } 1145 1147 1146 1148 // Then see if any of the old locations... … … 1150 1152 foreach ( $slug_group as $slug ) { 1151 1153 1152 1154 // ... have a match as well. 1153 if ( false === stripos( $location, $slug ) && false === stripos( $slug, $location ) ) {1155 if ( is_string( $location ) && false === stripos( $location, $slug ) && false === stripos( $slug, $location ) ) { 1154 1156 continue; 1157 } elseif ( is_numeric( $location ) && $location !== $slug ) { 1158 continue; 1155 1159 } 1156 1160 1157 1161 // Make sure this location wasn't mapped and removed previously. -
tests/phpunit/tests/menu/nav-menu.php
200 200 ); 201 201 $this->assertEqualSets( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); 202 202 } 203 204 /** 205 * Technically possible old nav menu locations were registered numerically. 206 * 207 * @covers wp_map_nav_menu_locations() 208 */ 209 public function test_numerical_old_locations() { 210 $this->register_nav_menu_locations( array( 'primary', 1 ) ); 211 212 $old_nav_menu_locations = array( 213 'primary' => 1, 214 'tertiary' => 2, 215 0 => 3, 216 ); 217 218 $next_theme_nav_menu_locations = array(); 219 $new_next_theme_nav_menu_locations = wp_map_nav_menu_locations( $next_theme_nav_menu_locations, $old_nav_menu_locations ); 220 221 $expected_nav_menu_locations = array( 222 'primary' => 1, 223 0 => 3, 224 ); 225 226 $this->assertEqualSets( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); 227 } 203 228 }