I was trying to customize the admin bar a bit by adding an extra logo, and showing the bar to all users(even non registered ones).
Here's the code from my plugin.
add_filter( 'show_admin_bar', '__return_true' );
add_action( 'admin_bar_menu', 'remove_wp_logo', 999 );
add_action( 'admin_bar_menu', 'social_links',11 );
function remove_wp_logo( $wp_admin_bar ) {
$wp_admin_bar->remove_node( 'wp-logo' );
$wp_admin_bar->remove_node('view-site');
if (! current_user_can('administrator')) $wp_admin_bar->remove_node('my-account');
}
function social_links( $wp_admin_bar){
$Tlogo = "<img src='http://localhost/wp/wp-content/mu-plugins/d.png'>";
$wp_admin_bar->add_node([
'id' => 'ds',
'title' => $Tlogo,
'href' => 'https://www.twitter.com/',
'meta' => [
'target' => 'sitepoint'
]
]);
}
So far I'm able to add the links I need but it only appears on desktop, when I resize the window, everything I added disappears from the responsive menu! Even the search bar.
Is there a way to add my icons to the responsive menu too (with the search button as well, if possible)
Thanks in advance.
$wp_admin_bar
as global. That's the parameter of the hook- So add them to your functionsocial_links($wp_admin_bar)
. That's more solid.