Changeset 38859 for trunk/src/wp-includes/nav-menu.php
- Timestamp:
- 10/21/2016 11:11:42 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/nav-menu.php
r38744 r38859 559 559 560 560 /** 561 * Sort menu items by the desired key.562 *563 * @since 3.0.0564 * @access private565 *566 * @global string $_menu_item_sort_prop567 *568 * @param object $a The first object to compare569 * @param object $b The second object to compare570 * @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 else589 return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop );590 }591 592 /**593 561 * Return if a menu item is valid. 594 562 * … … 683 651 684 652 if ( ARRAY_A == $args['output'] ) { 685 $GLOBALS['_menu_item_sort_prop'] = $args['output_key']; 686 usort($items, '_sort_nav_menu_items'); 653 $items = wp_list_sort( $items, array( 654 $args['output_key'] => 'ASC', 655 ) ); 687 656 $i = 1; 688 657 foreach ( $items as $k => $item ) { … … 777 746 $menu_item->type_label = __( 'Post Type Archive' ); 778 747 $post_content = wp_trim_words( $menu_item->post_content, 200 ); 779 $post_type_description = '' == $post_content ? $post_type_description : $post_content; 748 $post_type_description = '' == $post_content ? $post_type_description : $post_content; 780 749 $menu_item->url = get_post_type_archive_link( $menu_item->object ); 781 750 } elseif ( 'taxonomy' == $menu_item->type ) {
Note: See TracChangeset
for help on using the changeset viewer.