WordPress.org

Make WordPress Core

Ticket #9766: 9766.diff

File 9766.diff, 1.2 KB (added by Denis-de-Bernardy, 9 years ago)
  • wp-admin/includes/widgets.php

     
    1818 */
    1919function wp_list_widgets() {
    2020        global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
     21       
     22        usort($wp_registered_widgets, 'wp_sort_widgets');
    2123
    2224        $done = array();
    23         $sort = array_keys($wp_registered_widgets);
    24         natcasesort($sort); ?>
     25        ?>
    2526
    2627        <div class="widget-holder">
    2728        <p class="description"><?php _e('Drag widgets from here to a sidebar on the right to activate them.'); ?></p>
    2829        <div id="widget-list">
    2930<?php
    30         foreach ( $sort as $val ) {
    31                 $widget = $wp_registered_widgets[$val];
     31        foreach ( $wp_registered_widgets as $widget ) {
    3232                if ( in_array( $widget['callback'], $done, true ) ) // We already showed this multi-widget
    3333                        continue;
    3434
     
    6161}
    6262
    6363/**
     64 * sort widget callback
     65 *
     66 * @param array $a first widget
     67 * @param array $b second widget
     68 * @return int -1|0|1 depending a and b's name
     69 **/
     70
     71function wp_sort_widgets($a, $b) {
     72        return strnatcmp($a['name'], $b['name']);
     73}
     74
     75/**
    6476 * {@internal Missing Short Description}}
    6577 *
    6678 * @since unknown