WordPress.org

Ready to get started?Download WordPress

Forums

MP6
[resolved] override WP's default toolbar top margin (5 posts)

  1. jloft
    Member
    Posted 1 year ago #

    MP6.php contains the following action:

    add_action( 'wp_head', 'mp6_override_toolbar_margin', 11 );
    function mp6_override_toolbar_margin() { ?>
    <style type="text/css" media="screen">
    	html { margin-top: 32px !important; }
    	* html body { margin-top: 32px !important; }
    </style>
    <?php
    }

    That action is adding inline styling for admin bar to the <head> even when viewing the WordPress site without logging in. Thus, a blank gap of 32 px appears at the top of the site. The function needs some sort of conditional.

    http://wordpress.org/extend/plugins/mp6/

  2. Till Krüss
    Member
    Plugin Author

    Posted 1 year ago #

  3. jloft
    Member
    Posted 1 year ago #

    In the WordPress Codex, I found the is_admin_bar_showing(); function.
    http://codex.wordpress.org/Function_Reference/is_admin_bar_showing

    Adding it as a conditional to the mp6_override_toolbar_margin function seems to fix the issue I reported.

    add_action( 'wp_head', 'mp6_override_toolbar_margin', 11 );
    function mp6_override_toolbar_margin() {
    	if ( is_admin_bar_showing() ) { ?>
    		<style type="text/css" media="screen">
    			html { margin-top: 32px !important; }
    			* html body { margin-top: 32px !important; }
    		</style>
    	<?php }
    }

    If what I've done is correct, then I recommend including this edit to the function in MP6 6.0 this Friday.

  4. jloft
    Member
    Posted 1 year ago #

    Interesting. It seems you solved the issue a different way.

  5. Till Krüss
    Member
    Plugin Author

    Posted 1 year ago #

    I like is_admin_bar_showing() much better. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic