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.

Built from https://develop.svn.wordpress.org/trunk@34370


git-svn-id: http://core.svn.wordpress.org/trunk@34334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-09-22 03:37:25 +00:00
parent 62a91851de
commit 3ad78c4ec5
2 changed files with 20 additions and 17 deletions

View File

@ -512,23 +512,26 @@ final class WP_Screen {
*/
public function get_help_tabs() {
$help_tabs = $this->_help_tabs;
uasort( $help_tabs, array( $this, '_sort_help_tabs' ) );
return $help_tabs;
}
/**
* Compares the difference between the help tabs priorities.
*
* Used for help tabs sorting.
*
* @since 4.4.0
*
* @param int $tab_a The priority argument for the first tab.
* @param int $tab_b The priority argument for the second tab.
* @return int The difference between the priority arguments.
*/
protected function _sort_help_tabs( $tab_a, $tab_b ) {
return $tab_a['priority'] - $tab_b['priority'];
$priorities = array();
foreach ( $help_tabs as $help_tab ) {
if ( isset( $priorities[ $help_tab['priority'] ] ) ) {
$priorities[ $help_tab['priority'] ][] = $help_tab;
} else {
$priorities[ $help_tab['priority'] ] = array( $help_tab );
}
}
sort( $priorities );
$sorted = array();
foreach ( $priorities as $list ) {
foreach ( $list as $tab ) {
$sorted[ $tab['id'] ] = $tab;
}
}
return $sorted;
}
/**

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34369';
$wp_version = '4.4-alpha-34370';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.