Commit ad25902
committed
General: Introduce a
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.
This was previously committed in [38859] but got reverted in [38862] and [38863]. To fix the previous issues, `wp_list_sort()` supports now an additional argument to preserve array keys via `uasort()`.
Props flixos90, DrewAPicture, jorbin.
Fixes #37128.
git-svn-id: https://develop.svn.wordpress.org/trunk@38928 602fd350-edb4-49c9-b593-d223f7449a82wp_list_sort() helper function, v2.1 parent 0c14ff0 commit ad25902
12 files changed
Lines changed: 956 additions & 149 deletions
File tree
- src
- wp-includes
- customize
- tests/phpunit/tests
- customize
- functions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | 102 | | |
142 | 103 | | |
143 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2505 | 2505 | | |
2506 | 2506 | | |
2507 | 2507 | | |
| 2508 | + | |
2508 | 2509 | | |
2509 | 2510 | | |
2510 | 2511 | | |
2511 | 2512 | | |
2512 | 2513 | | |
2513 | 2514 | | |
| 2515 | + | |
| 2516 | + | |
2514 | 2517 | | |
2515 | 2518 | | |
2516 | 2519 | | |
| |||
2530 | 2533 | | |
2531 | 2534 | | |
2532 | 2535 | | |
2533 | | - | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
2534 | 2540 | | |
2535 | 2541 | | |
2536 | 2542 | | |
| |||
2543 | 2549 | | |
2544 | 2550 | | |
2545 | 2551 | | |
2546 | | - | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
2547 | 2556 | | |
2548 | 2557 | | |
2549 | 2558 | | |
2550 | 2559 | | |
2551 | 2560 | | |
2552 | 2561 | | |
2553 | 2562 | | |
2554 | | - | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
2555 | 2568 | | |
2556 | 2569 | | |
2557 | 2570 | | |
| |||
2566 | 2579 | | |
2567 | 2580 | | |
2568 | 2581 | | |
2569 | | - | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
2570 | 2586 | | |
2571 | 2587 | | |
2572 | 2588 | | |
2573 | 2589 | | |
2574 | 2590 | | |
2575 | 2591 | | |
2576 | 2592 | | |
2577 | | - | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
2578 | 2597 | | |
2579 | 2598 | | |
2580 | 2599 | | |
2581 | 2600 | | |
2582 | 2601 | | |
2583 | 2602 | | |
2584 | | - | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
2585 | 2607 | | |
2586 | 2608 | | |
2587 | 2609 | | |
| |||
0 commit comments