From f9d18568057d4d131ceb03909210d7709d9452e2 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 22 Sep 2015 03:36:27 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@34370 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-screen.php | 35 +++++++++++--------- tests/phpunit/tests/admin/includesScreen.php | 2 +- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/wp-admin/includes/class-wp-screen.php b/src/wp-admin/includes/class-wp-screen.php index a9064fca46..7d08b2ae4b 100644 --- a/src/wp-admin/includes/class-wp-screen.php +++ b/src/wp-admin/includes/class-wp-screen.php @@ -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; } /** diff --git a/tests/phpunit/tests/admin/includesScreen.php b/tests/phpunit/tests/admin/includesScreen.php index 898bb4608c..65603e315d 100644 --- a/tests/phpunit/tests/admin/includesScreen.php +++ b/tests/phpunit/tests/admin/includesScreen.php @@ -38,7 +38,7 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { function tearDown() { unset( $GLOBALS['wp_taxonomies']['old-or-new'] ); - set_current_screen( 'front' ); + unset( $GLOBALS['screen'] ); parent::tearDown(); }