bbp_admin_menu_order( array $menu_order )
Move our custom separator above our custom post types
Description
Parameters
- $menu_order
-
(Required) Menu Order
Return
(array) Modified menu order
Source
File: bp-forums/admin/functions.php
function bbp_admin_menu_order( $menu_order ) {
// Bail if user cannot see any top level Forums menus
if ( empty( $menu_order ) || ( false === bbpress()->admin->show_separator ) )
return $menu_order;
// Initialize our custom order array
$bbp_menu_order = array();
// Menu values
$second_sep = 'separator2';
$custom_menus = array(
'separator-bbpress', // Separator
'edit.php?post_type=' . bbp_get_forum_post_type(), // Forums
'edit.php?post_type=' . bbp_get_topic_post_type(), // Topics
'edit.php?post_type=' . bbp_get_reply_post_type() // Replies
);
// Loop through menu order and do some rearranging
foreach ( $menu_order as $item ) {
// Position Forums menus above appearance
if ( $second_sep == $item ) {
// Add our custom menus
foreach ( $custom_menus as $custom_menu ) {
if ( array_search( $custom_menu, $menu_order ) ) {
$bbp_menu_order[] = $custom_menu;
}
}
// Add the appearance separator
$bbp_menu_order[] = $second_sep;
// Skip our menu items
} elseif ( ! in_array( $item, $custom_menus ) ) {
$bbp_menu_order[] = $item;
}
}
// Return our custom order
return $bbp_menu_order;
}
Changelog
| Version | Description |
|---|---|
| bbPress (r2957) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.