bbp_get_tools_admin_tabs( string $active_tab = '' )
Output the tabs in the admin area
Description Description
Parameters Parameters
- $active_tab
-
(Optional) Name of the tab that is active
Default value: ''
Source Source
File: includes/admin/tools.php
function bbp_get_tools_admin_tabs( $active_tab = '' ) {
// Declare local variables
$tabs_html = '';
$idle_class = 'nav-tab';
$active_class = 'nav-tab nav-tab-active';
// Setup core admin tabs
$tabs = bbp_get_tools_admin_pages();
// Loop through tabs and build navigation
foreach ( $tabs as $tab ) {
// Skip if user cannot visit page
if ( ! current_user_can( $tab['cap'] ) ) {
continue;
}
// Setup tab HTML
$is_current = (bool) ( $tab['page'] === $active_tab );
$tab_class = $is_current ? $active_class : $idle_class;
$tab_url = add_query_arg( array( 'page' => $tab['page'] ), admin_url( 'tools.php' ) );
// Tab name is not escaped - may contain HTML
$tabs_html .= '<a href="' . esc_url( $tab_url ) . '" class="' . esc_attr( $tab_class ) . '">' . $tab['name'] . '</a>';
}
// Output the tabs
return $tabs_html;
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |