[buddypress-trac] [BuddyPress] #2168: Add an action hook to bp_adminbar_blogs_menu()

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Thu Mar 11 00:01:54 UTC 2010


#2168: Add an action hook to bp_adminbar_blogs_menu()
--------------------------+-------------------------------------------------
Reporter:  travel-junkie  |       Owner:       
    Type:  enhancement    |      Status:  new  
Priority:  minor          |   Milestone:  1.2.2
Keywords:                 |  
--------------------------+-------------------------------------------------
 In case we want to integrate a plugin into the blogs menu on the buddybar
 an action inside the list would make things far easier.

 Below you find the adjusted function:
 {{{
 // *** "My Blogs" Menu ********
 function bp_adminbar_blogs_menu() {
         global $bp;

         if ( !is_user_logged_in() || !function_exists('bp_blogs_install')
 )
                 return false;

         if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' .
 $bp->loggedin_user->id . '_inc_hidden', 'bp' ) ) {
                 $blogs = bp_blogs_get_blogs_for_user(
 $bp->loggedin_user->id, true );
                 wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id
 . '_inc_hidden', $blogs, 'bp' );
         }

         echo '<li id="bp-adminbar-blogs-menu"><a href="' .
 $bp->loggedin_user->domain . $bp->blogs->slug . '/my-blogs">';

         _e( 'My Blogs', 'buddypress' );

         echo '</a>';
         echo '<ul>';

         if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {
                 $counter = 0;
                 foreach ( (array)$blogs['blogs'] as $blog ) {
                         $alt = ( 0 == $counter % 2 ) ? ' class="alt"' :
 '';
                         $site_url = esc_attr( $blog->siteurl );

                         echo '<li' . $alt . '>';
                         echo '<a href="' . $site_url . '">' . esc_html(
 $blog->name ) . '</a>';

                         echo '<ul>';
                         echo '<li class="alt"><a href="' . $site_url .
 'wp-admin/">' . __( 'Dashboard', 'buddypress' ) . '</a></li>';
                         echo '<li><a href="' . $site_url . 'wp-admin/post-
 new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
                         echo '<li class="alt"><a href="' . $site_url .
 'wp-admin/edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
                         echo '<li><a href="' . $site_url . 'wp-admin/edit-
 comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';

                         do_action( 'bp_custom_blog_items', $blog );

                         echo '</ul>';

                         echo '</li>';
                         $counter++;
                 }
         }

         $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';

         if ( bp_blog_signup_enabled() ) {
                 echo '<li' . $alt . '>';
                 echo '<a href="' . $bp->root_domain . '/' .
 $bp->blogs->slug . '/create/">' . __( 'Create a Blog!', 'buddypress' ) .
 '</a>';
                 echo '</li>';
         }

         echo '</ul>';
         echo '</li>';
 }
 }}}

-- 
Ticket URL: <http://trac.buddypress.org/ticket/2168>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list