Make WordPress Core


Ignore:
Timestamp:
10/21/2016 11:11:42 AM (8 years ago)
Author:
swissspidy
Message:

General: Introduce a wp_list_sort() helper function.

In addition to wp_list_filter() for filtering a list of objects, and wp_list_pluck() for plucking a certain field out of each object in a list, this new function can be used for sorting a list of objects by specific fields. These functions are now all contained within the new WP_List_Util() class and wp_list_sort() is used in various parts of core for sorting lists.

Props flixos90, DrewAPicture, jorbin.
Fixes #37128.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php

    r38618 r38859  
    533533
    534534        if ( ARRAY_A === $args['output'] ) {
    535             $GLOBALS['_menu_item_sort_prop'] = $args['output_key'];
    536             usort( $items, '_sort_nav_menu_items' );
     535            $items = wp_list_sort( $items, array(
     536                $args['output_key'] => 'ASC',
     537            ) );
    537538            $i = 1;
    538539
Note: See TracChangeset for help on using the changeset viewer.