Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buddypress 1.2.6 adds extra padding-top

  • … even if “Hide admin bar for logged out users” is set “Yes”.

    To fix this, add 2 lines

    if ( (int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
    return false;

    at bp_core_add_admin_bar_css function (in wp-content/plugins/buddypress/bp-core/bp-core-cssjs.php) before line 16

    It will be wonderful if this could be fixed in the next release.
    Thanks in advance

Viewing 19 replies - 1 through 19 (of 19 total)
  • Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    @clojel

    You shouldn’t really mod the core files, as they’ll be overwritten if you upgrade. Is there any filter you can hook on to instead as an interim solution?

    Certainly though, this should be added to the trac as a potential bug to be looked at.

    We have the same problem with child themes in secondary sites – we’ve turned off the admin bar, we don’t have any admin bar css being included in our child theme, but still it pulls in admin bar css code from bp-default and inserts the unwanted padding.

    [As an aside: does anyone know where the code is that's injecting the admin bar css include into the header of child themes? Is it a hook on wp-footer?]

    Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    p.s. we have the problem in 1.2.5.2 as well

    Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

    Hi Roger,
    the admin bar is constructed in bp-core/bp-core-adminbar.php
    the css file for this is in bp-themesbp-default_inccssadminbar.css

    notepad++ is my friend

    Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    @chouf1 – yes, I know where the adminbar.css file is. Coda is my friend :)

    The question was, why is adminbar.css being included in other themes (even none child ones) on a multisite network? What’s injecting it, and how do we turn it off.

    e.g. My theme doesn’t explicitly link to adminbar.css, here’s the snippet from the header.php:

    `

    <link rel="stylesheet" type="text/css" media="all" href="” />
    <link rel="pingback" href="” />
    <?php
    if ( is_singular() && get_option( ‘thread_comments’ ) )
    wp_enqueue_script( ‘comment-reply’ );

    wp_head();
    `

    No explicit inclusion of adminbar.css!

    But, here’s what actually gets rendered in the browser:

    `

    `

    The unwanted link to adminbar.css has been injected.

    I assume it must be something in wp-head() doing it – is there a hook to turn it off?

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    /buddypress/bp-core/bp-core-cssjs.php

    Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    follow up – it’s actually being added in the function:

    bp_core_add_admin_bar_css()

    in bp-core-cssjs.php

    I can’t help but think this should be in the default theme, not in the core files.

    Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    @hnla – posting simultaneously !

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    It should be in the theme not in core files but it needs to load at ‘init’ ? or does it? is it that it must load before theme loads

    Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    ok… two solutions:

    1. the nasty hacky – adding define (‘BP_DISABLE_ADMIN_BAR’, TRUE) in our theme’s functions.php

    Why nasty hacky: well it inserts inline CSS into our footer to hide the adminbar and remove the padding; that’s nastiest enough in itself, but it also uses !important to override anything we actually want to do – even nastier.

    2. the cleaner – adding remove_action( ‘init’, ‘bp_core_add_admin_bar_css’); in our theme’s functions.php

    That does the job!

    Unfortunately, we have to add that in the functions.php of any additional theme we want to use. Let’s get all this presentation stuff in the default theme where it belongs (not in the core)… I’ve said this a lot recently.

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    @rogercoathup

    That nasty hack shouldn’t be an issue and it is not so much nasty as plain illegal to place style tags as children of ‘body’

    This is the ticket I raised ages ago, well I and another but wasn’t aware it was a duplicate, the style rules never were required as the adminbar was removed and didn’t require any styles to help it along, the ticket was moved here there and everywhere, but I forced the issue by moving it back from 1.3 to 1.2.6 and requested that it be dealt with as it was a simple fix so in 1.2.6 those style tags don’t exist. previously I was having to use

    remove_action(‘wp_footer’, ‘bp_core_override_adminbar_css’);

    If I was hiding the adminbar for logged out view.

    none of the solutions provided here solves the problem , not even editing the bp-core file as mentioned in the first post

    any ideas ?

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    Possibly because there are is a mix of issues, if you referring to the remaining padding-top then that is a property being declared in default.css on the #header ruleset and will be there regardless of the state of the adminbar:

    I have only time to suggest a quick fix for that in lieu of a new ticket raised on the overall issue for 1.3

    You can try dropping this into a function.php file in a child theme (you will need to add opening php tag as your file structure dictates)
    `
    function cancel_header_padding_for_no_adminbar() {
    if(defined( ‘BP_DISABLE_ADMIN_BAR’ ) || $bp->doing_admin_bar = false) ?>

    /**/
    <?php
    }
    add_action( ‘wp_head’, ‘cancel_header_padding_for_no_adminbar’ );
    `
    It would also probably work in bp-custom.php to ensure it was picked up for all possible bp themes.

    Note: I do not suggest this as an answer it’s a hack to get around the issue, but not a good approach all in all

    I don’t know may be I’m doing something wrong , this above solution is also not working for me .

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    Then you’re doing something wrong! Without actual detail on what you have done or tried to do it leaves it to us to have to makes guesses which generally is wasteful of time and resources.

    Rather than simply state it didn’t work describe what you tried to do with the above code, also we have little detail on what setup you are running i.e custom theme etc

    Doesn’t work for me neither.

    Prior to upgrading to 1.2.6
    I had followed wpmu.org website recommendation to ad this line to wp-config.php file:

    define( ‘BP_DISABLE_ADMIN_BAR’, true );

    And that had worked, no 25px padding on top…

    Then I uploaded and tried everything you guys said and it didn´t work.
    I even changed define( ‘BP_DISABLE_ADMIN_BAR’, true ); to functions.php file…

    any ideas?

    How stupid am I?

    Just changed
    body {
    padding-top: 25px;
    }

    to
    body {
    padding-top: 0px;
    }

    at adminbar.css

    =)
    der!

    @hnla
    Thank for your help
    I’m using wp 3.0.1 and bp 1.2.6 , with theme named “Blogs-mu”
    I’m tried putting the code snippet provided by you in the function.php of the theme file which didn’t worked,
    and also tried putting the code in bp-custom.php in plugins directory , which too didn’t helped
    actually it happen nothing , no errors also , so it seems to me I’m pasting the code correctly !

    @abarro – disablng the 25px top padding from admibar.css will cause some overlapping if the theme header have some thing else at that near top position, but for your case its ok because you have disabled the adminbar completely.

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    @anindyaray I still don’t really get what your actual issue is looking at your site as a logged out /anonymous user shows the adminbar but beside that , and obviously as you state above, you are using a custom theme so no my fix won’t work for you I and most of the others can only provide solutions based on default BP theme or core actions we or this forum can’t really support custom themes especially premium custom themes you must take issue with those themes to the original authors.

    However the padding in you case is on the body so perhaps you need to revise the code I wrote for you and substitute ‘body’ for ‘#header’ and see if that works?

    @hnla – Yet Thanks for trying to help !

Viewing 19 replies - 1 through 19 (of 19 total)

The topic ‘Buddypress 1.2.6 adds extra padding-top’ is closed to new replies.