Last active
September 28, 2015 22:08
-
-
Save bueltge/1503172 to your computer and use it in GitHub Desktop.
Remove Admin Bar in WordPress 3.3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Remove Admin Bar in WordPress 3.3 | |
* Plugin URI: http://wordpress.stackexchange.com/questions/40983/removing-admin-bar-from-wordpress-dashboard | |
* Description: Remove Admin Bar | |
* Version: 1.0.0 | |
* Author: Frank Bültge | |
* Author URI: http://bueltge.de | |
* License: GPLv3 | |
*/ | |
// This file is not called from WordPress. We don't like that. | |
! defined( 'ABSPATH' ) and exit; | |
add_action( 'init', 'fb_remove_admin_bar', 0 ); | |
function fb_remove_admin_bar() { | |
wp_deregister_script( 'admin-bar' ); | |
wp_deregister_style( 'admin-bar' ); | |
remove_action( 'init', '_wp_admin_bar_init' ); | |
remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); | |
remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); | |
// maybe also: 'wp_head' | |
foreach ( array( 'wp_head', 'admin_head' ) as $hook ) { | |
add_action( | |
$hook, | |
create_function( | |
'', | |
"echo '<style>body.admin-bar, body.admin-bar #wpcontent, body.admin-bar #adminmenu { | |
padding-top: 0px !important; | |
} | |
html.wp-toolbar { | |
padding-top: 0px !important; | |
}</style>';" | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment