Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Ipstenu

By: a guest on Apr 25th, 2010  |  syntax: PHP  |  size: 2.41 KB  |  views: 231  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # Customize My Blogs
  2.  
  3. // *** "My Blogs" Menu ********
  4. function my_adminbar_blogs_menu() {
  5.         global $bp, $wpdb;
  6.  
  7.         if ( !is_user_logged_in() || !function_exists('bp_blogs_install') )
  8.                 return false;
  9.  
  10.         if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', 'bp' ) ) {
  11.                 $blogs = bp_blogs_get_blogs_for_user( $bp->loggedin_user->id, true );
  12.                 wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', $blogs, 'bp' );
  13.         }
  14.  
  15.         echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/my-blogs">';
  16.  
  17.         _e( 'My Blogs', 'buddypress' );
  18.  
  19.         echo '</a>';
  20.         echo '<ul>';
  21.         if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {
  22.                 $counter = 0;
  23.                 foreach ( (array)$blogs['blogs'] as $blog ) {
  24.                         $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
  25.                         $site_url = esc_attr( $blog->siteurl );
  26.                         $blog_id = (int)$blog->id;
  27.                        
  28.                         $site_id = $wpdb->get_var("SELECT blog_id FROM wp_bp_user_blogs WHERE id = '$blog_id'");
  29.                        
  30.                         $site_id = 'wp_' .$site_id. '_comments';
  31.                                                
  32.                         $numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $site_id WHERE comment_approved = '0'");
  33.                                 if (0 < $numcomms) $numcomms = number_format($numcomms);
  34.  
  35.                        
  36.                         echo '<li' . $alt . '>';
  37.                         echo '<a href="' . $site_url . '">' . esc_html( $blog->name ) . '</a>';
  38.  
  39.                         echo '<ul>';
  40.                         echo '<li class="alt"><a href="' . $site_url . 'wp-admin/">' . __( 'Dashboard', 'buddypress' ) . '</a></li>';
  41.                         echo '<li><a href="' . $site_url . 'wp-admin/post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
  42.                         echo '<li class="alt"><a href="' . $site_url . 'wp-admin/edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
  43.                         echo '<li><a href="' . $site_url . 'wp-admin/edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . ' (' . $numcomms . ')</a>';
  44.                         echo '</li>';
  45.  
  46.                         echo '</ul>';
  47.  
  48.                         echo '</li>';
  49.                         $counter++;
  50.                 }
  51.         }
  52.  
  53.         $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
  54.  
  55.         if ( bp_blog_signup_enabled() ) {
  56.                 echo '<li' . $alt . '>';
  57.                 echo '<a href="' . $bp->root_domain . '/' . $bp->blogs->slug . '/create/">' . __( 'Create a Blog!', 'buddypress' ) . '</a>';
  58.                 echo '</li>';
  59.         }
  60.  
  61.         echo '</ul>';
  62.         echo '</li>';
  63. }
  64.  
  65. function my_alter_blogs_menu(){
  66.         remove_action('bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6);
  67.         add_action('bp_adminbar_menus', 'my_adminbar_blogs_menu', 6);
  68.         }
  69. add_action('wp_footer','my_alter_blogs_menu',1);