bp_adminbar_blogs_menu

Add a Sites menu to the BuddyBar.

Description

(bool|null) bp_adminbar_blogs_menu(); 

Returns (bool|null)

Returns false on failure. Otherwise echoes the menu item.


Usage

  1. if ( !function_exists( 'bp_adminbar_blogs_menu' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/deprecated/2.1.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_adminbar_blogs_menu(); 
  7.  

Defined (1)

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

/bp-core/deprecated/2.1.php  
  1. function bp_adminbar_blogs_menu() { 
  2.  
  3. if ( ! is_user_logged_in() || ! bp_is_active( 'blogs' ) ) { 
  4. return false; 
  5.  
  6. if ( ! is_multisite() ) { 
  7. return false; 
  8.  
  9. $blogs = wp_cache_get( 'bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', 'bp' ); 
  10. if ( empty( $blogs ) ) { 
  11. wp_cache_set( 'bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', $blogs, 'bp' ); 
  12.  
  13. $counter = 0; 
  14. if ( is_array( $blogs['blogs'] ) && (int) $blogs['count'] ) { 
  15.  
  16. echo '<li id="bp-adminbar-blogs-menu"><a href="' . trailingslashit( bp_loggedin_user_domain() . bp_get_blogs_slug() ) . '">'; 
  17.  
  18. _e( 'My Sites', buddypress ); 
  19.  
  20. echo '</a>'; 
  21. echo '<ul>'; 
  22.  
  23. foreach ( (array) $blogs['blogs'] as $blog ) { 
  24. $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; 
  25. $site_url = esc_attr( $blog->siteurl ); 
  26.  
  27. echo '<li' . $alt . '>'; 
  28. echo '<a href="' . $site_url . '">' . esc_html( $blog->name ) . '</a>'; 
  29. echo '<ul>'; 
  30. echo '<li class="alt"><a href="' . $site_url . 'wp-admin/">' . __( 'Dashboard', buddypress ) . '</a></li>'; 
  31. echo '<li><a href="' . $site_url . 'wp-admin/post-new.php">' . __( 'New Post', buddypress ) . '</a></li>'; 
  32. echo '<li class="alt"><a href="' . $site_url . 'wp-admin/edit.php">' . __( 'Manage Posts', buddypress ) . '</a></li>'; 
  33. echo '<li><a href="' . $site_url . 'wp-admin/edit-comments.php">' . __( 'Manage Comments', buddypress ) . '</a></li>'; 
  34. echo '</ul>'; 
  35.  
  36.  
  37. echo '</li>'; 
  38. $counter++; 
  39.  
  40. $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; 
  41.  
  42. echo '<li' . $alt . '>'; 
  43. echo '<a href="' . trailingslashit( bp_get_blogs_directory_permalink() . 'create' ) . '">' . __( 'Create a Site!', buddypress ) . '</a>'; 
  44. echo '</li>'; 
  45.  
  46. echo '</ul>'; 
  47. echo '</li>';