I'm trying to display a link in the WordPress admin bar as long as the currently logged in user has a specific capability.
This is what I've put into functions.php but nothing seems to be appearing in the admin bar.
function add_admin_bar_link() {
global $wp_admin_bar;
if ( current_user_can( 'manage_options' ) )
return;
$wp_admin_bar->add_menu( array(
'id' => 'whatever_link',
'title' => __( 'Link to whatever' ),
'href' => __( 'https://linktowhatever.com' ),
) );
}
add_action( 'admin_bar_menu', 'add_admin_bar_link', 25 );
Where am I going wrong?