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']; |
| 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; |