Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How to: Modify the bp admin bar


Burt Adsit
Participant

@burtadsit

I have a special fondness for the admin bar. It was the first thing I started modifying in bp.

You’ve got to create a new function that responds to the action ‘bp_adminbar_menus’. Something like this:

function my_help_link(){
?>
<li><a href="http://someplace.org">Help</a>

<ul class="your-ul-list-css-classname">
<li><a href="http://someplace.org">Help 1</a></li>
<li class="alt"><a href="http://someplace.org">Help 2</a></li>
<li><a href="http://someplace.org">Help 3</a></li>
<li class="alt"><a href="http://someplace.org">Help 4</a></li>
<li><a href="http://someplace.org">Help 5</a></li>
</ul>

</li>
<?php
}
add_action( 'bp_adminbar_menus', 'my_help_link', 14 );

Here with formatting: http://pastie.org/451047

The call add_action() has a number at the end which is the ‘priority’. When the fn gets triggered in the great scheme of things. If you look at the code for the admin bar in /bp-core/bp-core-adminbar.php, you’ll see a bunch of calls like this at the end of the file. They setup the sequence for the menu items. Lower priority numbers get run first and the corresponding menu item shows up first.

I gave our little help item a priority of 14 so it shows up at the end of the normal menu item sequence. If you want to slide it in between menu items that have a priority of 4 and 6 then give your help add_action() call a priority of 5.

Skip to toolbar