bbp_admin_menu_order

Move our custom separator above our custom post types.

Description

(array) bbp_admin_menu_order( (array) $menu_order ); 

Returns (array)

Modified menu order

Parameters (1)

0. $menu_order (array)
The menu order.

Usage

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

Defined (1)

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

/includes/admin/functions.php  
  1. function bbp_admin_menu_order( $menu_order ) { 
  2.  
  3. // Bail if user cannot see any top level bbPress menus 
  4. if ( empty( $menu_order ) || ( false ===bbpress)->admin->show_separator ) ) 
  5. return $menu_order; 
  6.  
  7. // Initialize our custom order array 
  8. $bbp_menu_order = array(); 
  9.  
  10. // Menu values 
  11. $second_sep = 'separator2'; 
  12. $custom_menus = array( 
  13. 'separator-bbpress', // Separator 
  14. 'edit.php?post_type=' . bbp_get_forum_post_type(), // Forums 
  15. 'edit.php?post_type=' . bbp_get_topic_post_type(), // Topics 
  16. 'edit.php?post_type=' . bbp_get_reply_post_type() // Replies 
  17. ); 
  18.  
  19. // Loop through menu order and do some rearranging 
  20. foreach ( $menu_order as $item ) { 
  21.  
  22. // Position bbPress menus above appearance 
  23. if ( $second_sep == $item ) { 
  24.  
  25. // Add our custom menus 
  26. foreach ( $custom_menus as $custom_menu ) { 
  27. if ( array_search( $custom_menu, $menu_order ) ) { 
  28. $bbp_menu_order[] = $custom_menu; 
  29.  
  30. // Add the appearance separator 
  31. $bbp_menu_order[] = $second_sep; 
  32.  
  33. // Skip our menu items 
  34. } elseif ( ! in_array( $item, $custom_menus ) ) { 
  35. $bbp_menu_order[] = $item; 
  36.  
  37. // Return our custom order 
  38. return $bbp_menu_order;