Changeset 38863 for trunk/src/wp-includes/nav-menu.php
- Timestamp:
- 10/21/2016 05:00:29 PM (10 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/nav-menu.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/nav-menu.php
r38859 r38863 559 559 560 560 /** 561 * Sort menu items by the desired key. 562 * 563 * @since 3.0.0 564 * @access private 565 * 566 * @global string $_menu_item_sort_prop 567 * 568 * @param object $a The first object to compare 569 * @param object $b The second object to compare 570 * @return int -1, 0, or 1 if $a is considered to be respectively less than, equal to, or greater than $b. 571 */ 572 function _sort_nav_menu_items( $a, $b ) { 573 global $_menu_item_sort_prop; 574 575 if ( empty( $_menu_item_sort_prop ) ) 576 return 0; 577 578 if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) ) 579 return 0; 580 581 $_a = (int) $a->$_menu_item_sort_prop; 582 $_b = (int) $b->$_menu_item_sort_prop; 583 584 if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop ) 585 return 0; 586 elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop ) 587 return $_a < $_b ? -1 : 1; 588 else 589 return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop ); 590 } 591 592 /** 561 593 * Return if a menu item is valid. 562 594 * … … 651 683 652 684 if ( ARRAY_A == $args['output'] ) { 653 $items = wp_list_sort( $items, array( 654 $args['output_key'] => 'ASC', 655 ) ); 685 $GLOBALS['_menu_item_sort_prop'] = $args['output_key']; 686 usort($items, '_sort_nav_menu_items'); 656 687 $i = 1; 657 688 foreach ( $items as $k => $item ) { … … 746 777 $menu_item->type_label = __( 'Post Type Archive' ); 747 778 $post_content = wp_trim_words( $menu_item->post_content, 200 ); 748 $post_type_description = '' == $post_content ? $post_type_description : $post_content; 779 $post_type_description = '' == $post_content ? $post_type_description : $post_content; 749 780 $menu_item->url = get_post_type_archive_link( $menu_item->object ); 750 781 } elseif ( 'taxonomy' == $menu_item->type ) {
Note: See TracChangeset
for help on using the changeset viewer.