bb_admin_menu

The BuddyPress bb admin menu function.

Description

bb_admin_menu(); 

Usage

  1. if ( !function_exists( 'bb_admin_menu' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-admin/includes/functions.bb-admin.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bb_admin_menu(); 
  7.  

Defined (1)

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

/bp-forums/bbpress/bb-admin/includes/functions.bb-admin.php  
  1. function bb_admin_menu() 
  2. global $bb_menu, $bb_submenu, $bb_current_menu, $bb_current_submenu; 
  3.  
  4. if ( !is_array( $bb_menu ) || !count( $bb_menu ) ) { 
  5. return ''; 
  6.  
  7. $r = "\t\t\t" . '<ul id="bbAdminMenu">' . "\n"; 
  8.  
  9. foreach ( $bb_menu as $key => $m ) { 
  10. if ( !bb_current_user_can( $m[1] ) ) { 
  11. continue; 
  12. $class = 'bb-menu'; 
  13. if ( isset( $m[3] ) ) { 
  14. $class .= ' ' . $m[3]; 
  15. $id = ''; 
  16. if ( isset( $m[4] ) ) { 
  17. $id .= ' id="' . $m[4] . '"'; 
  18. $m[0] = esc_html( $m[0] ); 
  19. if ( $m[2] === 'separator' ) { 
  20. if ( 'f' == bb_get_user_setting( 'fm' ) ) { 
  21. $href = '?foldmenu=0'; 
  22. } else { 
  23. $href = '?foldmenu=1'; 
  24. $m[0] = '<br />'; 
  25. $class .= ' bb-menu-separator'; 
  26. } elseif ( strpos( $m[2], 'http://' ) === 0 || strpos( $m[2], 'https://' ) === 0 ) { 
  27. $href = esc_url( $m[2] ); 
  28. $class .= ' bb-menu-external'; 
  29. } else { 
  30. $href = esc_url( bb_get_option( 'path' ) . 'bb-admin/' . bb_get_admin_tab_link( $m[2] ) ); 
  31. if ( $m[2] == $bb_current_menu[2] ) { 
  32. $class .= ' bb-menu-current'; 
  33.  
  34. $sr = ''; 
  35. if ( $m[2] !== 'separator' && isset( $bb_submenu[$m[2]] ) && is_array( $bb_submenu[$m[2]] ) && count( $bb_submenu[$m[2]] ) ) { 
  36. $sr .= "\t\t\t\t\t" . '<div class="bb-menu-sub-wrap"><span>' . $m[0] . '</span>' . "\n"; 
  37. $sr .= "\t\t\t\t\t\t" . '<ul>' . "\n"; 
  38. $sc = 0; 
  39. foreach ( $bb_submenu[$m[2]] as $skey => $sm ) { 
  40. if ( !bb_current_user_can( $sm[1] ) ) { 
  41. continue; 
  42. if ( $sc === 0 && $sm[2] === $m[2] ) { 
  43. $no_submenu = true; 
  44. if ( $sc > 0 ) { 
  45. $no_submenu = false; 
  46. $sc++; 
  47. $sclass = 'bb-menu-sub'; 
  48. if ( isset( $sm[3] ) ) { 
  49. $sclass .= ' ' . $sm[3]; 
  50. if ( strpos( $sm[2], 'http://' ) === 0 || strpos( $sm[2], 'https://' ) === 0 ) { 
  51. $shref = $sm[2]; 
  52. $sclass .= ' bb-menu-external'; 
  53. } else { 
  54. $shref = bb_get_option( 'path' ) . 'bb-admin/' . bb_get_admin_tab_link( $sm[2] ); 
  55. if ( $sm[2] == $bb_current_submenu[2] ) { 
  56. $sclass .= ' bb-menu-sub-current'; 
  57. $sr .= "\t\t\t\t\t\t\t" . '<li class="' . esc_attr( trim( $sclass ) ) . '"><a href="' . esc_url( $shref ) . '">' . esc_html( $sm[0] ) . '</a></li>' . "\n"; 
  58. $sr .= "\t\t\t\t\t\t" . '</ul>' . "\n"; 
  59. $sr .= "\t\t\t\t\t" . '</div>' . "\n"; 
  60.  
  61. if ( $sr && !$no_submenu ) { 
  62. $class .= ' bb-menu-has-submenu'; 
  63. if ( $m[2] == $bb_current_menu[2] ) { 
  64. $class .= ' bb-menu-open'; 
  65.  
  66. $r .= "\t\t\t\t" . '<li' . $id . ' class="' . esc_attr( trim( $class ) ) . '"><a href="' . $href . '">'; 
  67.  
  68. if ( $m[2] !== 'separator' ) { 
  69. $r .= '<div class="bb-menu-icon"></div>'; 
  70.  
  71. $r .= '<span>' . $m[0] . '</span></a>' . "\n"; 
  72.  
  73. if ( $sr && !$no_submenu ) { 
  74. $r .= '<div class="bb-menu-toggle"></div>'; 
  75. $r .= $sr; 
  76.  
  77. $r .= "\t\t\t\t" . '</li>' . "\n"; 
  78.  
  79. $r .= "\t\t\t" . '</ul>' . "\n"; 
  80.  
  81. echo $r;