WordPress.org

Ready to get started?Download WordPress

Forums

WP Admin No Show
[resolved] Remove 28px white space in front end (6 posts)

  1. Max Bond
    Member
    Posted 1 year ago #

    Hi!
    There is one problem with your plugin. When the admin bar is gone, on its place there is a 28px of white space.

    Here is the code to fix it:

    Add one new fucntion:

    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 a hook to wp_admin_no_show_admin_bar_disable():

    ...
    if ( false !== $disable ) {
        add_filter( 'show_admin_bar', '__return_false' );
        remove_action( 'personal_options', '_admin_bar_preferences' );
        add_filter('wp_head','remove_admin_bar_style_frontend', 99);
    }

    http://wordpress.org/extend/plugins/wp-admin-no-show/

  2. Samuel Aguilera
    Member
    Posted 1 year ago #

    To fix that it's better to remove the action responsible of that style printing instead of printing more CSS ;)

    Just add this line

    remove_action('wp_head', '_admin_bar_bump_cb');

    Leave the code like this:

    if ( false !== $disable ) {
            add_filter( 'show_admin_bar', '__return_false' );
            remove_action( 'personal_options', '_admin_bar_preferences' );
            remove_action('wp_head', '_admin_bar_bump_cb');
    
        }
  3. Max Bond
    Member
    Posted 1 year ago #

    Samuel!
    Thanks, your method is the best!

  4. Scriptrunner (Doug Sparling)
    Member
    Plugin Author

    Posted 1 year ago #

    Max, good catch. Samuel, thanks for the fix. I'll try and get the plugin updated shortly. Much appreciated!

  5. Scriptrunner (Doug Sparling)
    Member
    Plugin Author

    Posted 1 year ago #

    Fix has been committed. Thanks much!

  6. Samuel Aguilera
    Member
    Posted 1 year ago #

    You're welcome Max.

    Thanks to you for giving us the plugin @scriptrunner ;)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.