bp_admin_menu_order( array $menu_order = array() )

Move our custom separator above our custom post types.

Description

Parameters

$menu_order

(Optional) Menu Order.

Default value: array()

Return

(array) Modified menu order.

Source

File: bp-core/admin/bp-core-admin-functions.php

1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
function bp_admin_menu_order( $menu_order = array() ) {
 
    // Bail if user cannot see admin pages.
    if ( empty( $menu_order ) || ! bp_current_user_can( 'bp_moderate' ) ) {
        return $menu_order;
    }
 
    // Initialize our custom order array.
    $bp_menu_order = array();
 
    // Menu values.
    $last_sep     = is_network_admin() ? 'separator1' : 'separator2';
 
    /**
     * Filters the custom admin menus.
     *
     * @since BuddyPress 1.7.0
     *
     * @param array $value Empty array.
     */
    $custom_menus = (array) apply_filters( 'bp_admin_menu_order', array() );
 
    // Bail if no components have top level admin pages.
    if ( empty( $custom_menus ) ) {
        return $menu_order;
    }
 
    // Add our separator to beginning of array.
    array_unshift( $custom_menus, 'separator-buddypress' );
 
    // Loop through menu order and do some rearranging.
    foreach ( (array) $menu_order as $item ) {
 
        // Position BuddyPress menus above appearance.
        if ( $last_sep == $item ) {
 
            // Add our custom menus.
            foreach( (array) $custom_menus as $custom_menu ) {
                if ( array_search( $custom_menu, $menu_order ) ) {
                    $bp_menu_order[] = $custom_menu;
                }
            }
 
            // Add the appearance separator.
            $bp_menu_order[] = $last_sep;
 
        // Skip our menu items.
        } elseif ( ! in_array( $item, $custom_menus ) ) {
            $bp_menu_order[] = $item;
        }
    }
 
    // Return our custom order.
    return $bp_menu_order;
}

Changelog

Changelog
Version Description
BuddyPress 1.7.0 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.