Removing admin bar from wordpress dashboard

I’m using wordpress multiste 3.3.1
I’m not gonna update it in the future. So I disabled all upgrade functions.

I want to remove the wordpress admin bar from both frontend as well as dashboard.

Read More

I can remove it from frontend using this code.

add_action( 'init', 'disable_admin_bar', 1 );
function disable_admin_bar() {
    add_filter( 'show_admin_bar', '__return_false' );
}

But i couldn’t find any solution to remove it from dashboard.

I don’t want to use css solution to hide admin bar
and I’m ready to edit the core files to remove it

Can anyone help me to remove it completely?. Thanks

Related posts

Leave a Reply

4 comments

  1. if (!function_exists('disableAdminBar')) {
    
        function disableAdminBar(){
    
        remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 );
    
        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');
    
      }
    
    }
    
    add_filter('admin_head','remove_admin_bar_style_backend');
    

    Source: http://wp.tutsplus.com/tutorials/how-to-disable-the-admin-bar-in-wordpress-3-3/

    OR, for both front and back end…

    if (!function_exists('disableAdminBar')) {
    
        function disableAdminBar(){
    
        remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); // for the admin page
        remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); // for the front end
    
        function remove_admin_bar_style_backend() {  // css override for the admin page
          echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';
        }
    
        add_filter('admin_head','remove_admin_bar_style_backend');
    
        function remove_admin_bar_style_frontend() { // css override for the 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_filter('admin_head','remove_admin_bar_style_backend'); // Original version
    add_action('init','disableAdminBar'); // New version
    

    THat looks like it should do it…. May I go on record as saying that planning to never update WordPress is a terrible idea. If nothing else, for security reasons.

    Some CSS is required in there, or else you end up with a big gap where the bar used to be. NOTE: I’ve not tested this, as I have no need. But that source is normally quite reliable.

  2. Use this small plugin, also available on Gist: https://gist.github.com/1503172
    Works fine and is also a part of the plugin free “Adminimize”.

    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>';"
                )
            );
        }
    }
    
  3. Update for WordPress 5.*

    ..and WORKS FINE!!

    There are two new lines for remove_admin_bar_style_backend() function and a new function to remove backend footer

    /* 
    * Removes WordPress framework dashboard horizontal banners (adminbar & footer)
    */
    if (!function_exists('disable_framework_banners'))
    {
        function disable_framework_banners()
        {
            function remove_admin_bar_style_frontend() 
            {
                // CSS override for the 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);
            
            function remove_wpadminbar_backend()
            {
                // CSS override for the admin page
                echo '<style>html.wp-toolbar { padding-top:0!important; }</style>';
                echo '<style>#wpadminbar { display:none!important }</style>';
            }
            add_filter('admin_head','remove_wpadminbar_backend');
    
            function remove_wpfooter_backend()
            {
                // CSS override for the admin page
                echo '<style>#wpfooter { display:none!important }</style>';
            }
            add_filter('admin_head','remove_wpfooter_backend');
        }
    }
    add_action('init','disable_framework_banners');