is_admin_bar_showing()
Checks whether the "Admin bar" (toolbar) will be shown (or has already been shown). That is, whether the admin panel will be displayed for the current user. Conditional tag.
Uses: _get_admin_bar_pref()
Hooks from the function
Returns
true|false. Boolean true or false. Returns false in cases:
-
if the user is not logged in;
-
if the display of the "Admin Bar" is disabled;
-
if the display of the admin bar is not provided (on the wp-login.php page)
-
if the "Admin Bar" is disabled in the code: add_filter('show_admin_bar', '__return_false');
- if this is a request (constants are defined): XMLRPC_REQUEST or DOING_AJAX or IFRAME_REQUEST
In other cases, it returns true. In the admin area, it always returns true.
Usage
if( is_admin_bar_showing() ){
// admin bar is displayed
}
Examples
#1 Check if there is an admin bar and do something
if( is_admin_bar_showing() ) {
// code if there is a panel
}
else {
// code if there is no panel
}
Notes
- Global. true|false.
$show_admin_bar - Global. String.
$pagenowThe filename of the current screen.
Changelog
| Since 3.1.0 | Introduced. |