The MU forums have moved to WordPress.org

Help with Wordpress Admin Bar !!!!! Please!!!!! (22 posts)

  1. pitttih
    Member
    Posted 16 years ago #

    Hi people,
    I just enabled viper007bond's Wordpress Admin Bar on my Wpmu Site ..
    It works perfectly on User's (own) Blog but:
    how can we show WP Admin Bar on other Blogs too ?! Like Wordpress.com's bar ..

    The php Code looks like this:

    <?php /*
    
    **************************************************************************
    
    Plugin Name:  WordPress Admin Bar
    Plugin URI:   http://www.viper007bond.com/wordpress-plugins/wordpress-admin-bar/
    Version:      2.0.2
    Description:  Creates an admin bar inspired by the one at <a href="http://wordpress.com/">WordPress.com</a>. Credits for the look of this plugin go to them.
    Author:       Viper007Bond
    Author URI:   http://www.viper007bond.com/
    
    **************************************************************************/
    
    class WPAdminBar {
    	var $version = '2.0.2';
    	var $folder = '/wp-content/mu-plugins/';
    	var $breakat;
    	var $adminurl;
    	var $menu = array();
    	var $submenu = array();
    
    	// Plugin initialization
    	function WPAdminBar() {
    		// This plugin only supports WP 2.0+ (learn to upgrade please!)
    		if ( !function_exists('current_user_can') ) return;
    
    		// Only users that can "read" should be able to see the admin bar
    		if ( !current_user_can('read') ) return;
    
    		add_action( 'wp_head', array(&$this, 'LoadCSSandJS') );
    		add_action( 'wp_footer', array(&$this, 'OutputMenu') );
    
    		// Uncomment these next 2 lines to use this plugin in your admin area
    		//add_action( 'admin_head', array(&$this, 'LoadCSSandJS') );
    		//add_action( 'admin_footer', array(&$this, 'OutputMenu') );
    
    		 // Add a link to the "Manage" menu when viewing a post or page
    		add_filter( 'wpabar_submenuitems', array(&$this, 'AddSingleEditLink') );
    	}
    
    	// Output the needed CSS and JS for the plugin
    	function LoadCSSandJS() { ?>
    	<link rel="stylesheet" href="<?php echo get_bloginfo('wpurl') . $this->folder; ?>/wordpress-admin-bar.css?ver=<?php echo $this->version; ?>" type="text/css" />
    	<!--[if lt IE 7]><style type="text/css">#wpabar { position: absolute; } #wpabar .wpabar-menupop li a { width: 100%; }</style><![endif]-->
    <?php
    	}
    
    	// Generate and output the HTML for the admin menu
    	function OutputMenu() {
    		global $wpdb, $menu, $submenu, $_wp_submenu_nopriv;
    
    		if ( file_exists( ABSPATH . 'wp-admin/includes/admin.php' ) )
    			include_once( ABSPATH . 'wp-admin/includes/admin.php' ); // WP 2.3+
    		else
    			include_once( ABSPATH . 'wp-admin/admin-functions.php' );
    
    		include_once( ABSPATH . 'wp-admin/menu.php' );
    
    		$this->adminurl = get_bloginfo('wpurl') . '/wp-admin/';
    
    		$this->menu = apply_filters( 'wpabar_menuitems', $menu );
    		$this->submenu = apply_filters( 'wpabar_submenuitems', $submenu );
    
    		$this->breakat = apply_filters( 'wpabar_breakat', 23 ); // This variable says when to split from left to right
    
    		// Sort them incase any menus were added via filters
    		ksort($this->menu);
    		foreach ( $this->submenu as $id => $submenus ) {
    			ksort($submenus);
    			$this->submenu[$id] = $submenus;
    		}
    ?>
    
    <!-- Start WordPress Admin Bar -->
    <script type="text/javascript" src="<?php echo get_bloginfo('wpurl') . $this->folder; ?>/wordpress-admin-bar.js?ver=<?php echo $this->version; ?>"></script>
    <div id="wpabar">
    	<div id="wpabar-leftside">
    		<ul>
    <?php
    
    foreach( $this->menu as $id => $menuitem ) {
    	if ( $id > $this->breakat ) break;
    
    	$this->OutputMenuItem( $menuitem );
    }
    
    ?>
    		</ul>
    	</div>
    	<div id="wpabar-rightside">
    		<ul>
    <?php
    
    foreach( $this->menu as $id => $menuitem ) {
    	if ( $id <= $this->breakat ) continue;
    
    	$this->OutputMenuItem( $menuitem );
    }
    
    ?>
    			<li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=logout"><?php _e('Sign Out'); ?></a></li>
    		</ul>
    	</div>
    </div>
    
    <?php
    	}
    
    	// Output a menu item and it's children
    	function OutputMenuItem( $menuitem ) {
    		if ( is_array( $this->submenu[$menuitem[2]] ) ) : ?>
    			<li class="wpabar-menupop" onmouseover="showNav(this)" onmouseout="hideNav(this)">
    				<a href="<?php
    					echo $this->adminurl;
    					if ( !empty($menuitem[3]) ) {
    						echo 'admin.php?page=';
    						$customtoplevel = TRUE;
    					}
    					echo $menuitem[2];
    				?>"><span class="wpabar-dropdown"><?php echo $menuitem[0]; ?></span></a>
    				<ul>
    <?php
    					foreach( $this->submenu[$menuitem[2]] as $submenuitem ) {
    						$toplevelpage = ( TRUE == $customtoplevel ) ? 'admin.php' : $menuitem[2];
    						$url = ( !empty($submenuitem[3]) ) ? $toplevelpage . '?page=' . $submenuitem[2] : $submenuitem[2];
    						echo '					<li><a href="' . $this->adminurl . $url . '">' . $submenuitem[0] . "</a></li>\n";
    					}
    ?>
    				</ul>
    			</li>
    <?php else : ?>
    			<li><a href="<?php echo $this->adminurl . $menuitem[2]; ?>"><?php echo $menuitem[0]; ?></a></li>
    <?php
    		endif;
    	}
    
    	// If viewing a single post or page, filter in a link to edit it
    	function AddSingleEditLink( $submenu ) {
    		global $post;
    
    		if ( function_exists('get_edit_post_link') )
    			$editlink = str_replace( get_bloginfo('wpurl') . '/wp-admin/', '', get_edit_post_link( $post->ID ) );
    		else
    			$editlink = 'post.php?action=edit&post=' . $post->ID;
    
    		if ( is_single() && current_user_can( 'edit_post', $post->ID ) )
    			$submenu['edit.php'][2] = array( __('Edit This'), 'edit_posts', $editlink );
    
    		elseif ( is_page() && current_user_can( 'edit_page', $post->ID ) )
    			$submenu['edit.php'][2] = array( __('Edit This'), 'edit_pages', $editlink );
    
    		return $submenu;
    	}
    }
    
    // Start this plugin once all other files and plugins are fully loaded
    add_action( 'plugins_loaded', create_function( '', 'global $WPAdminBar; $WPAdminBar = new WPAdminBar();' ) );
    
    ?>

    hope you understand me ..
    Many thanks

  2. RCB-IT-Solutions
    Member
    Posted 16 years ago #

    Did you put it in the "plugins" or "mu-plugins" directory?

    If it's in the "plugins" directory it needs to be activated on that blog to be shown.

  3. andrea_r
    Moderator
    Posted 16 years ago #

    Please, please do not paste large chunks of code in the forums. use pastebin, make it a text file, whatever, and link to that instead.

  4. pitttih
    Member
    Posted 16 years ago #

    @RCB-IT-Solution Yes i put it in mu-plugins..
    @andrea Sorry!

    Can someone help me now? :(

  5. RCB-IT-Solutions
    Member
    Posted 16 years ago #

    Do you have <?php wp_footer(); ?> in the footer.php of all your themes?

  6. pitttih
    Member
    Posted 16 years ago #

    RCB thank you for helping me..
    Yes i have <?php wp_footer(); ?> in the footer.php of my themes .. but dosen't work
    i testet it on wp default theme..
    works on user's (own) blog .. but not on other blogs with the same theme :( !

  7. RCB-IT-Solutions
    Member
    Posted 16 years ago #

    Now i'm not sure what they mean by a user being able to "read" but the only thing I see right away that may have an effect is this

    if ( !current_user_can('read') ) return;

    I'd try commenting that out and see if it works, if not remove the comment because it must serve another purpose.

  8. pitttih
    Member
    Posted 16 years ago #

    i tried it before .. and dosen't work! damn it ..

    if ( !current_user_can('read') ) return;
    It means only logged in users can see admin bar,
    if i comment out this line .. admin bar is visible for everyone.. i think the problem is somewhere else ..
    Anyone?

  9. RCB-IT-Solutions
    Member
    Posted 16 years ago #

    hmm well I'll look at in more in-depth when I get the chance, if someone else hasn't already found the problem for you.

  10. pitttih
    Member
    Posted 16 years ago #

    Thank you , I'm waitnig ..

  11. pitttih
    Member
    Posted 16 years ago #

    Anyone?!

  12. webdesignandseoblog
    Member
    Posted 16 years ago #

    Is this really a WPMU related question ? If this is not a MU compatible plugin then it will not work with WPMU. Please explain in detail what you want to do...

  13. andrea_r
    Moderator
    Posted 16 years ago #

    There's an admin bar plguin for MU already -
    http://wpmudevorg.wordpress.com/project/MU-Admin-Bar

  14. Viper007Bond
    Member
    Posted 16 years ago #

    Just incase anyone stumbles across this thread later on:

    Just install the plugin normally, but put wordpress-admin-bar.php in your mu-plugins folder. Works perfectly fine for me on my client's WPMU install.

  15. suleiman
    Member
    Posted 16 years ago #

    Thanks for the tip Viper, I've used that trick to get many plugins to install on MU.

    I've actually spent some time hacking away at your plugin to get it to display some important MU controls when the site admin is live, and also to allow users the option to turn it on and off. I plan on releasing the whole kit and kaboodle once I've migrated my site to 1.5.1 and made sure it works fine. Do please let me know if you have any objections!

    Thanks for the great work on an excellent plugin.

  16. Viper007Bond
    Member
    Posted 16 years ago #

    I'm actually in the process of recoding it from scratch as we speak (multiple themes of it, disable/enable certain items, etc.).

    I'd be happy to add any features you've added directly into it (already planned on the option to enable/disable it). That'd be much better IMO than branching off your own copy since I haven't ceased development on it. ;)

  17. Klark0
    Member
    Posted 16 years ago #

    Hey suleiman,

    Is your hacked version available yet? We can work together and mu-tise it.

    From first glance ..it looks we need to remove the Site Admin for normal users, make it show across all blogs for a logged in user, and personally I would like to take away control of the options page from users.

  18. Ovidiu
    Member
    Posted 16 years ago #

    Are you sure you don't want it displayed for logged out users? The old plugin: http://wpmudevorg.wordpress.com/project/MU-Admin-Bar was always displayed and we hacked it so it uses a link to jump to random blogs if a user clicks on next blog ;-)

    I would vote for an option to decide how one wants it displayed always or just for logged in users.

    Any particular reason why you want it displayed only for logged in users?

  19. Klark0
    Member
    Posted 16 years ago #

    I just prefer it that way, but it's not important :)

  20. mbchandar
    Member
    Posted 16 years ago #

    I have done some customization in two plugins
    1. wordpress-admin-bar.php
    2. combined matt's random post redirect and Patrick's random blog redirect.

    check out http://ulagam.net

  21. Klark0
    Member
    Posted 16 years ago #

    Sharing ?

  22. boonika
    Member
    Posted 15 years ago #

    Sharing? Sharing?

About this Topic