Ticket #29460: 29460.patch
File 29460.patch, 3.1 KB (added by , 10 years ago) |
---|
-
src/wp-admin/nav-menus.php
380 380 } 381 381 382 382 // Get all nav menus. 383 $nav_menus = wp_get_nav_menus( array('orderby' => 'name'));383 $nav_menus = wp_get_nav_menus(); 384 384 $menu_count = count( $nav_menus ); 385 385 386 386 // Are we on the add new screen? -
src/wp-includes/default-widgets.php
1344 1344 $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : ''; 1345 1345 1346 1346 // Get menus 1347 $menus = wp_get_nav_menus( array( 'orderby' => 'name' ));1347 $menus = wp_get_nav_menus(); 1348 1348 1349 1349 // If no menus exists, direct the user to go and create some. 1350 1350 if ( !$menus ) { -
src/wp-includes/nav-menu-template.php
277 277 278 278 // get the first menu that has items if we still can't find a menu 279 279 if ( ! $menu && !$args->theme_location ) { 280 $menus = wp_get_nav_menus( array( 'orderby' => 'name' ));280 $menus = wp_get_nav_menus(); 281 281 foreach ( $menus as $menu_maybe ) { 282 282 if ( $menu_items = wp_get_nav_menu_items( $menu_maybe->term_id, array( 'update_post_term_cache' => false ) ) ) { 283 283 $menu = $menu_maybe; -
src/wp-includes/nav-menu.php
465 465 * @return array menu objects 466 466 */ 467 467 function wp_get_nav_menus( $args = array() ) { 468 $defaults = array( 'hide_empty' => false, 'orderby' => 'n one' );468 $defaults = array( 'hide_empty' => false, 'orderby' => 'name' ); 469 469 $args = wp_parse_args( $args, $defaults ); 470 470 471 471 /** -
tests/phpunit/tests/post/nav-menu.php
116 116 $this->assertEquals( 'WordPress.org', $custom_item->title ); 117 117 118 118 } 119 120 /** 121 * @ticket 29460 122 */ 123 function test_orderby_name_by_default() { 124 // We are going to create a random number of menus more (min 2, max 10) 125 $menus_no = rand( 2, 10 ); 126 127 for ( $i = 0; $i <= $menus_no; $i++ ) { 128 wp_create_nav_menu( rand_str() ); 129 } 130 131 // This is the expected array of menu names 132 $expected_nav_menus_names = wp_list_pluck( 133 get_terms( 'nav_menu', array( 'hide_empty' => false, 'orderby' => 'name' ) ), 134 'name' 135 ); 136 137 // And this is what we got when calling wp_get_nav_menus() 138 $nav_menus_names = wp_list_pluck( wp_get_nav_menus(), 'name' ); 139 140 $this->assertEquals( $nav_menus_names, $expected_nav_menus_names ); 141 } 119 142 } 143 144 No newline at end of file