#16249 closed defect (bug) (worksforme)
Control of admin bar hiding/display
Reported by: | johnhennmacc | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.1 |
Component: | Administration | Keywords: | needs-patch |
Focuses: | Cc: |
Description
Can the assignment of space for an admin bar be controlled by the same switch that turns it on and off? At the moment, you can make the bar not appear but space still is set aside for it after ticket #16222. You need to remove the space as well as hiding the bar.
Attachments (2)
Change History (14)
#1
@
14 years ago
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
#2
@
13 years ago
- Cc justin@… added
- Keywords needs-patch added
- Resolution worksforme deleted
- Status changed from closed to reopened
The screenshot displays this error still happening, using both filter's Nacin put above. The code in the head is not being removed:
<style type="text/css" media="screen"> html { margin-top: 28px !important; } * html body { margin-top: 28px !important; } </style>
#3
@
13 years ago
adding this snippet will take care of it, but not sure that should be necessary.
show_admin_bar(false); remove_action('wp_head', '_admin_bar_bump_cb');
#4
@
13 years ago
Seems like it's too late when you call add_filter( 'show_admin_bar', '__return_false' );
.
It works for me.
#5
@
13 years ago
- Resolution set to worksforme
- Status changed from reopened to closed
function ds_hide_toolbar() { add_filter( 'show_admin_bar', '__return_false' ); } add_action( 'init', 'ds_hide_toolbar', 1 );
or
add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );
#6
@
13 years ago
Thank you for your response.. The only thing missing in my code was the "1" at the end of the add_action. With the diff that I just added, that "1" doesn't seem to be needed. Please take a look and consider it?
#7
@
13 years ago
And to be as clear as possible, this was my code that was not properly removing the space at the top of the page for the admin bar:
// Hide dashboard, admin bar, etc from subscribers add_action( 'init', 'aec_hide_admin_stuff' ); function aec_hide_admin_stuff( ) { if ( !current_user_can('edit_posts') ) { show_admin_bar(false); } }
#8
@
13 years ago
Btw: If the CSS is printed the JS files will be enqueued too, so your patch doesn't help.
#10
@
13 years ago
- Keywords has-patch added
Ok, I scoured the source code of my page after applying this patch to be sure it was removing everything that
function ds_hide_toolbar() { add_filter( 'show_admin_bar', '__return_false' ); } add_action( 'init', 'ds_hide_toolbar', 1 );
was removing, so hopefully this patch is considered for addition?
You're not disabling it properly. Use the following function or hook:
Or:
Additionally, you can change the callback that spits out the CSS, thus allowing you to adjust it for your theme if for some reason it isn't compatible.