Settings::sort_tabs( array $tabs, string $admin_page )
Sort the tabs, forcing some to the front and some to the end.
Contents
Parameters
- $tabs
-
(array) (Required) The array of tabs.
- $admin_page
-
(string) (Required) The ID of the admin page we are on.
Return
(array) The sorted array of tabs.
Source
File: src/Tribe/Admin/Settings.php
public function sort_tabs( $tabs, $admin_page ): array {
if ( $admin_page !== 'tec-events-settings' ) {
return $tabs;
}
// Ensure these are the first tabs.
$first = [ 'general', 'display' ];
$tabs = array_merge( array_flip( $first ), $tabs );
// Ensure these are the last tabs.
$last = [ 'licenses', 'addons', 'imports' ];
foreach( $last as $sort ) {
if ( ! isset( $tabs[ $sort ] ) ) {
continue;
}
// TL/DR: grab each tab, unset it and append it to the end of the array in order.
$temp = $tabs[ $sort ];
unset( $tabs[ $sort ] );
$tabs[ $sort ] = $temp;
}
return $tabs;
}
Changelog
| Version | Description |
|---|---|
| 6.2.1 | Correctly prepend 'general' and 'display' tabs to the beginning. |
| 6.0.5 | Introduced. |