Make WordPress Core


Ignore:
Timestamp:
10/21/2016 05:00:29 PM (10 years ago)
Author:
ocean90
Message:

Revert [38859] due to an incomplete implementation.

See https://core.trac.wordpress.org/ticket/37128#comment:27.
See #37128.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/nav-menu.php

    r38859 r38863  
    559559
    560560/**
     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 */
     572function _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/**
    561593 * Return if a menu item is valid.
    562594 *
     
    651683
    652684    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');
    656687        $i = 1;
    657688        foreach ( $items as $k => $item ) {
     
    746777                $menu_item->type_label = __( 'Post Type Archive' );
    747778                $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; 
    749780                $menu_item->url = get_post_type_archive_link( $menu_item->object );
    750781            } elseif ( 'taxonomy' == $menu_item->type ) {
Note: See TracChangeset for help on using the changeset viewer.