How to convert and prepare code for functions.php

Questions & AnswersCategory: WordPressHow to convert and prepare code for functions.php
D asked 8 years ago

I found this tut online for Buddypress Message Alert, Friend Request, and Notifications. The problem is the code is only set for header.php. I would like an add action or filter function for functions.php, to set this on the WP Admin bar. {$wp_admin_bar->add_node( $args );}.
Also I’m pretty sure the coding for Alert Notification should be different from the rest, needing some sort of filter to override that annoying Bubble. Awesome code it’s just a matter of that admin bar issue.
Here is the code:

<a href="user_login . '/notifications/'; ?>"> 

0 ) {
echo ''; echo $count; echo ''; 
} else {
}
?>

<a href="user_login . '/friends/requests/'; ?>">
0 ) {
echo ''; echo $count_requests; echo '';
} else {
}
?>

<a href="user_login . '/messages/'; ?>">
0 ) {
echo ''; echo $count_messages; echo '';
} else {
}
?>

 

Thanks in advance.

1 Answers
Rohit Tripathi Staff answered 8 years ago

Hello,
I am not sure what you are trying to accomplish here. But as far as hooks for admin bar are considered. Here is an example of it.

function my_tweaked_admin_bar() { global $wp_admin_bar; //Do stuff }
add_action( 'wp_before_admin_bar_render', 'my_tweaked_admin_bar' );

Some other hooks you may use are:

  • admin_bar_init – This hook is called at the end of initialization.
  • add_admin_bar_menus – This hook is called at the end of the public add_menus() function.