Make WordPress Core


Ignore:
Timestamp:
09/22/2015 03:36:27 AM (9 years ago)
Author:
wonderboymusic
Message:

Help Tabs: when returning help tabs, return them in order of priority, but also return the items in each priority in the order that they were added.

Fixes #33941.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-screen.php

    r34169 r34370  
    513513    public function get_help_tabs() {
    514514        $help_tabs = $this->_help_tabs;
    515         uasort( $help_tabs, array( $this, '_sort_help_tabs' ) );
    516         return $help_tabs;
    517     }
    518 
    519     /**
    520      * Compares the difference between the help tabs priorities.
    521      *
    522      * Used for help tabs sorting.
    523      *
    524      * @since 4.4.0
    525      *
    526      * @param int $tab_a The priority argument for the first tab.
    527      * @param int $tab_b The priority argument for the second tab.
    528      * @return int The difference between the priority arguments.
    529      */
    530     protected function _sort_help_tabs( $tab_a, $tab_b ) {
    531         return $tab_a['priority'] - $tab_b['priority'];
     515
     516        $priorities = array();
     517        foreach ( $help_tabs as $help_tab ) {
     518            if ( isset( $priorities[ $help_tab['priority'] ] ) ) {
     519                $priorities[ $help_tab['priority'] ][] = $help_tab;
     520            } else {
     521                $priorities[ $help_tab['priority'] ] = array( $help_tab );
     522            }
     523        }
     524
     525        sort( $priorities );
     526
     527        $sorted = array();
     528        foreach ( $priorities as $list ) {
     529            foreach ( $list as $tab ) {
     530                $sorted[ $tab['id'] ] = $tab;
     531            }
     532        }
     533
     534        return $sorted;
    532535    }
    533536
Note: See TracChangeset for help on using the changeset viewer.