[buddypress-trac] [BuddyPress] #3419: bp_core_remove_nav_item() support WP admin bar as well?

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Thu Aug 18 08:51:47 UTC 2011

#3419: bp_core_remove_nav_item() support WP admin bar as well?
 Reporter:  r-a-y        |       Owner:
     Type:  enhancement  |      Status:  reopened
 Priority:  normal       |   Milestone:  1.5.1
Component:  Core         |     Version:  1.5
 Severity:  normal       |  Resolution:
 Keywords:  needs-patch  |

Comment (by r-a-y):

 What I believed to be "quite simple" turned out to be a complete headache

 Not as simple as I thought.

 At the end of bp_core_remove_subnav_item(), I had something like this:

         if ( bp_use_wp_admin_bar() ) {
                 $bp->temp_slug = $slug;
                 add_action( 'wp_before_admin_bar_render', create_function(
 '', 'global $bp, $wp_admin_bar; $wp_admin_bar->remove_menu( $bp->temp_slug
 );' ) );

 Which works for the very first instance you use
 bp_core_remove_subnav_item(), but if you use the function more than once,
 it will use the last instance of it because $bp->temp_slug is overriden
 each time and because the WP Admin Bar is only rendered at the very end of
 the page.

 Hopefully this gives you superior beings some fodder!


 Might be easier to tell plugin devs to just use WP's built-in functions
 for the adminbar:


 function ray_remove_mentions_subnav_item() {
         global $wp_admin_bar;
         $wp_admin_bar->remove_menu( 'mentions' );
 add_action( 'wp_before_admin_bar_render',
 'ray_remove_mentions_subnav_item' );

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/3419#comment:5>
BuddyPress <http://buddypress.org/>

More information about the buddypress-trac mailing list