1

So in wp-includes/admin-bar.php there is a function that adds CSS styling to the page:

    function _admin_bar_bump_cb() { ?>
    <style type="text/css" media="screen">
        html { margin-top: 28px !important; }
        * html body { margin-top: 28px !important; }
    </style>
    <?php
    }

I want to comment this out properly (either the function or the contents of the function, either one is fine) but not touch the core code. How would I do this?

5

I think you can do it like this:

function my_admin_bar_init() {
    remove_action('wp_head', '_admin_bar_bump_cb');
}
add_action('admin_bar_init', 'my_admin_bar_init');

Add this to your functions.php file. It will disable outputting of these inline styles in <head> section but the wp_admin_bar will be still available.

If you would like to disable wp_admin_bar entirely, you can do it like this:

remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
  • no you'd better use remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 ) moreover he said he want to comment out. – JMau Jun 21 '13 at 14:56
  • But he wants to disable these styles, not the admin_bar entirely... – Krzysiek Dróżdż Jun 21 '13 at 14:57
  • Hey Krzy, so admin_bar_init is what calls _admin_bar_bump_cb? And by adding the remove_action, you are removing it from the sequence of functions that admin_bar_init runs? – bigpotato Jun 21 '13 at 15:05
  • Well. It's not so easy. In class-wp-admin-bar.php file you can find: if ( empty($header_callback) ) $header_callback = '_admin_bar_bump_cb'; add_action('wp_head', $header_callback); on line 56. Then the action admin_bar_init is called. So on this hook you can remove function _admin_bar_bump_cb from this hook and disable it's output. – Krzysiek Dróżdż Jun 21 '13 at 15:08
  • Nice. Sorry this is my first time touching WP. So the point of actions/filters is so that you can customize core functions in specific places by replacing the add_action and add_filter with your own version? – bigpotato Jun 21 '13 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.