• I am looking for a way to add a similar banner for each blog on a multisite. The blogs may be using different themes and I do not want to change the themes since it looks like a maintenance nightmare to me.

    After reading some posts about this it looks like the easiest way might be to write a plugin for this.

    Some months ago someone answered there was no such plugin. Has something happened since then? 😉

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter lborgman

    (@lborgman)

    The answer is to write your own plugin, yes.

    Add this line to a php file in “mu-plugins” to show_admin_bar:

    add_filter( 'show_admin_bar', '__return_true' );

    Then commence a tinkering away with the WP_Admin_Bar class:

    Or cheat like I do:
    http://generatewp.com/toolbar/

    Thread Starter lborgman

    (@lborgman)

    Oh, that looks very nice, David! If I had known about that I would probably not have written my plugin… 😉

    I did not want to touch the Admin Bar since I thought it was for admin purposes only. One thing that made me think so (beside the name) was the 46px height that looked hard coded. Did I misunderstand something there, or?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    It’s not the admin bar, actually, it’s the toolbar, and it’s okay to use.

    (See David’s post below “The Admin Bar is replaced with the Toolbar since WordPress Version 3.3.” Code says admin_bar, we call it toolbar, same headache as sites/blogs 😉 )

    Description
    The show_admin_bar filter toggles the display status of the Toolbar for the front side of your website (you cannot turn off the toolbar on the WordPress dashboard anymore).

    Note: The Admin Bar is replaced with the Toolbar since WordPress Version 3.3.

    Thread Starter lborgman

    (@lborgman)

    @david, i have been playing a bit more with this. At this point I am not quite sure what I want to do. The plugin I have written is a bit fragile since it uses the current state of WordPress so to say and not some rules.

    I do not need access to something in WordPress that I can think of at the moment. (Maybe I would like search etc, but I can work around that with just a link to a search page.)

    An advantage with my approach is that I can put the same banner on other places with just copy and paste.

    Here is an example of that: http://ourcomments.org/psych/zfsp.html?q=porges

    I am trying to find out what I want from WordPress to make my solution a bit more safe. The margin-top in html is a bit tricky (and I forgot to correct a detail there right now). Do you have any suggestions? Or do you perhaps just find my solution a bit stupid? 😉

    Thread Starter lborgman

    (@lborgman)

    I just added the code to GitHub – without any instructions so far. If someone would like to give some advice I would be glad. Please look here:

    https://github.com/lborgman/multisite-header-one

    Keep it simple yes. If you have a stable branding approach (especially with other php apps) go with it, you may need to dive in and jigger the banner position in WordPress on a per theme basis.

    So I offer the following snippet/guess to fix the banner vs body position (add to the functions.php of each theme)…

    function add_lb_banner_style() {
    	echo '<style type="text/css" media="all">
    	body {
    		padding-top: 30px !important;
    		}
    	</style>';
    }
    add_action('wp_head','add_lb_banner_style',99);

    As for WordPress fragility – your way may have more long term stability. You never know; the adminbar/toolbar could get moved back to a plugin. But if you keep it simple, avoid editing core files, migrating/updating will remain more of a tinkerer’s hobby than a burden.

    Thread Starter lborgman

    (@lborgman)

    Thanks, but I guess I have to go the same way as WP toolbar, i.e. modifying the html element’s margin-top. I just have to figure out how to best cooperate with the wp code.

    Thread Starter lborgman

    (@lborgman)

    I took a closer look at class-wp-admin-bar.php and the rendering. I would need a hook in the end of the rendering of the function _render. That hook would provide a way to add something at the end of the #wpadminbar div.

    And also a way to cooperate with this:

    if ( current_theme_supports( ‘admin-bar’ ) ) {

    I guess the theme must have the last say here, but then there must be a way to call back to the theme and tell that the container (aka #wpadminbar) has changed it’s height.

    How do talk to the developers about this?

    (I guess doing this gives me much less headache then trying to fix things without this.)

    If you want to, for example, override the default toolbar banner height with one specific to a theme, then put something like this in theme’s function.php I figure.

    <?php
    add_theme_support( 'admin-bar', array( 'callback' => 'add_lb_banner_style') );
    
    function add_lb_banner_style() {
    	echo '<style type="text/css" media="all">
    	body {
    		padding-top: 30px !important;
    		}
    	</style>';
    }
    ?>

    or

    html { margin-top: 28px !important; }
    * html body { margin-top: 28px !important; }";
    	}

    or whatever other fiddlings you need.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Multisite banner plugin?’ is closed to new replies.