bp_admin_menu_order

Move our custom separator above our custom post types.

Description

(array) bp_admin_menu_order( (array) $menu_order = array() ); 

Returns (array)

Modified menu order.

Parameters (1)

0. $menu_order — Optional. (array) => array()
The menu order.

Usage

  1. if ( !function_exists( 'bp_admin_menu_order' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/admin/bp-core-admin-functions.php'; 
  3.  
  4. // The menu order. 
  5. $menu_order = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_admin_menu_order($menu_order); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-core/admin/bp-core-admin-functions.php  
  1. function bp_admin_menu_order( $menu_order = array() ) { 
  2.  
  3. // Bail if user cannot see admin pages. 
  4. if ( empty( $menu_order ) || ! bp_current_user_can( 'bp_moderate' ) ) { 
  5. return $menu_order; 
  6.  
  7. // Initialize our custom order array. 
  8. $bp_menu_order = array(); 
  9.  
  10. // Menu values. 
  11. $last_sep = is_network_admin() ? 'separator1' : 'separator2'; 
  12.  
  13. /** 
  14. * Filters the custom admin menus. 
  15. * @since 1.7.0 
  16. * @param array $value Empty array. 
  17. */ 
  18. $custom_menus = (array) apply_filters( 'bp_admin_menu_order', array() ); 
  19.  
  20. // Bail if no components have top level admin pages. 
  21. if ( empty( $custom_menus ) ) { 
  22. return $menu_order; 
  23.  
  24. // Add our separator to beginning of array. 
  25. array_unshift( $custom_menus, 'separator-buddypress' ); 
  26.  
  27. // Loop through menu order and do some rearranging. 
  28. foreach ( (array) $menu_order as $item ) { 
  29.  
  30. // Position BuddyPress menus above appearance. 
  31. if ( $last_sep == $item ) { 
  32.  
  33. // Add our custom menus. 
  34. foreach( (array) $custom_menus as $custom_menu ) { 
  35. if ( array_search( $custom_menu, $menu_order ) ) { 
  36. $bp_menu_order[] = $custom_menu; 
  37.  
  38. // Add the appearance separator. 
  39. $bp_menu_order[] = $last_sep; 
  40.  
  41. // Skip our menu items. 
  42. } elseif ( ! in_array( $item, $custom_menus ) ) { 
  43. $bp_menu_order[] = $item; 
  44.  
  45. // Return our custom order. 
  46. return $bp_menu_order;