Created
March 23, 2017 07:25
-
-
Save ahmedeshaan/a4464a7cf9089e191b1d955294a56d95 to your computer and use it in GitHub Desktop.
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 | |
| // Disable Admin Bar for everyone but administrators | |
| if (!function_exists('df_disable_admin_bar')) { | |
| function df_disable_admin_bar() { | |
| if (!current_user_can('manage_options')) { | |
| // for the admin page | |
| remove_action('admin_footer', 'wp_admin_bar_render', 1000); | |
| // for the front-end | |
| remove_action('wp_footer', 'wp_admin_bar_render', 1000); | |
| // css override for the admin page | |
| function remove_admin_bar_style_backend() { | |
| echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>'; | |
| } | |
| add_filter('admin_head','remove_admin_bar_style_backend'); | |
| // css override for the frontend | |
| function remove_admin_bar_style_frontend() { | |
| echo '<style type="text/css" media="screen"> | |
| html { margin-top: 0px !important; } | |
| * html body { margin-top: 0px !important; } | |
| </style>'; | |
| } | |
| add_filter('wp_head','remove_admin_bar_style_frontend', 99); | |
| } | |
| } | |
| } | |
| add_action('init','df_disable_admin_bar'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment