Opened 14 years ago
Closed 14 years ago
#21746 closed defect (bug) (invalid)
show_admin_bar(false) still adds CSS and JS
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Toolbar | Keywords: | |
| Focuses: | Cc: |
Description
I'd expect show_admin_bar(false) to totally hide the admin toolbar. Instead it leaves fragments in the app, for example in the header it still adds:
<link rel='stylesheet' id='admin-bar-css' href='/wp-includes/css/admin-bar.css' type='text/css' media='all' />
<style type="text/css" media="print">#wpadminbar { display:none; }</style>
<style type="text/css" media="screen">
html { margin-top: 28px !important; }
* html body { margin-top: 28px !important; }
</style>
And in the footer:
<script type='text/javascript' src='/wp-includes/js/admin-bar.js'></script>
Change History (9)
#2
follow-up:
↓ 3
@
14 years ago
When should I call it? I've currently got it at the top of my header.php file, well before WP's header and footer functions.
#3
in reply to:
↑ 2
@
14 years ago
Replying to ahmednuaman:
When should I call it?
In theme's functions.php file:
http://codex.wordpress.org/Function_Reference/show_admin_bar#Notes
#4
@
14 years ago
But I want it to appear within the admin, I don't want it to appear for certain users on the front end, so I followed: http://codex.wordpress.org/Function_Reference/show_admin_bar#Examples
#6
@
14 years ago
Updated the Codex page. It suggested calling show_admin_bar() in template files before wp_footer(), which is wrong.
It should be called immediately upon plugin load, so functions.php is the appropriate place:
http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/admin-bar.php#L700
Could not reproduce. My guess is that you're calling
show_admin_bar( false );too late.Both
_wp_admin_bar_init()andwp_admin_bar_render()return early and don't include any styles or scripts if the toolbar is properly disabled.Have you tried disabling all plugins and switching to the default theme (Twenty Eleven)?
Related/duplicate: #16249