Step #1:
Modify wp-admin/wp-admin.css and find the bit for 'wphead h1 span'
- Change the span to #viewsite and add in margin-left: 10px;
- Add in the following:
#switchermenu a {
font-size: 20px;
padding: 0 1.5em 0 10px;
display: block;
color: #c3def1;
}
#switchermenu a:hover {
background: #1a70b4;
color: #fff;
}
#switchermenu li {
margin: 0;
padding: 0;
}
#switchermenu {
list-style: none;
margin: 0;
padding: 0;
overflow: hidden;
border-top: 1px solid #1a70b4;
border-left: 1px solid #1a70b4;
position: absolute;
left: 0;
top: 1em;
background: #14568a;
z-index: 1;
}
Step #2:
Grab a copy of the drop down menu arrow thing:
http://s.wordpress.com/i/bullet_arrow_down.gif
And upload it to your wp-admin/images directory.
Make note of the URL for later.
Step #3:
Open up wp-admin/admin-header.php and place the following code in right before the closing head line. Note the URL that needs to be places for the drop down arrow.
(Let's see if it works)
<script type="text/javascript">
jQuery( function($) {
var switchTime;
var w = false;
var h = $( '#blog-title' )
.css({
background: 'transparent url(URL to the arrow image here) no-repeat scroll 100% .2em;',
padding: '0 25px 2px 5px',
cursor: 'pointer',
border: '1px solid #14568a'
})
.parent().css( { position: 'relative' }).end()
.append( $('#switchermenu') )
.hover( function() {
$(this).css({ border: '1px solid #1a70b4'});
switchTime = window.setTimeout( function() {
$('#switchermenu').fadeIn('fast').css( 'top', h ).find('a').width( w = w ? w : $('#switchermenu').width() );
}, 300 );
}, function() {
window.clearTimeout( switchTime );
$(this).css({ border: '1px solid #14568a' }) ;
$('#switchermenu').hide();
})
.height() - 3;
});
</script>
Step #4:
Drop down a couple of lines to the h1 bit where it lists the title of the blog and replace it with the following:
<h1><span id="blog-title"><?php echo wptexturize(get_bloginfo(('name'))); ?></span>
<span id="viewsite">(<a href="<?php echo get_option('home') . '/'; ?>"><?php _e('View site »') ?></a>)</span>
</h1>
Step #5:
Here's the code. Add it in after the closing h1 from Step #4Let me post it and then I'll explain it:
<ul id="switchermenu" style="display: none;">
<?php
$blogs = get_blogs_of_user($current_user->ID);
if ( ! empty($blogs) ) foreach ( $blogs as $blog ) {
$tmpblogname = $blog->domain . $blog->path;
$tmpblogname = str_replace("Replace Me", "", $tmpblogname);
echo "<li><a href='http://" . $blog->domain . $blog->path . "wp-admin/'>" . $tmpblogname . "</a></li>n";
}
?>
See that "Replace Me" in there? Without it and the line before it, the code would just display the entire URL of your blog. You need to put in there bit from the URL that every blog has. It depends on though if you're using subdomains or sundirectories though.
Using my domain as an example:
For subdomains, replace it with the following:
.daria.be/
For subdomains, replace it with the following:
daria.be/
Hope this helps,
-drmike
Found a small issue. The menu doesn't appear on all pages. WPMu doesn't load the jQuery javascripts every page. Just got to figure out where the hook is for this. Hold on...
really cool. cant wait to get home and try it.
frozonecold
Member
Posted 17 years ago #
Hey Dr.Mike could you post some screenshots? Some of us would like to see it before they install it.
It's the same as wp.com but I will in a second.
The fix for teh issue I had above is to open up wp-admin/admin-header.php and place the following right above the get_admin_page_title(); line
wp_enqueue_script('interface');
frozonecold
Member
Posted 17 years ago #
Thank you Dr.Mike. I didn't realize that it was an exact copy. You know what would be a good idea though.... Making the sub-pages on the admin have drop down menu's as well.
It's not an exact copy to my knowledge. While the CSS is, the coding from step #5 is my own. (In theory at least.)
hempsworth
Member
Posted 17 years ago #
This is great, thanks!
But there is a typo in the code you posted:
echo "<li><a href='http://" . $blog->domain . $blog->path . "wp-admin/'>" . $tmpblogname . "</a></li>n";
There is an n after
</a></li>
Also, how could I make it display the blog name rather than the path?
hrm.. nothing happened. no error messge. nothing is broken. checked in IE7 and FF. i'm missing something and i cant figure out what it is. ok. be back!
There's supposed to be a slash in there before the n
\ n
It's a line feed in the outputted html.
Sorry about that. I had forgotten that the forum software strips it out.
hempsworth
Member
Posted 17 years ago #
Sorted!
Any luck on getting it to display the name of the blog in the list instead of "path/" ?
hempsworth
Member
Posted 17 years ago #
It's working great for me, but I'm not sure what the \n is for to be honest, it seemed to work the same without it.
Hemp, that's an advanced feature ;)
You probably could. I only went this far as it's what wp.com does. If there was someway to get get_blogs_of_user($current_user->ID) to return the blog_id and then used that to pull the name out of the db, you could probably do it.
My concern is these folks with mile long blog names.
All the \n does is make a line break in the outputted code. Else everything runs into a single line.
still unsure why its not working. *grumble* only thing thats chaged in the size od the words 'viewsite'
wphead h1 #viewsite
Sorry about that.
hempsworth
Member
Posted 17 years ago #
Where is
$blog->domain
comming from? An obvious idea would be
$blog->name
or something similar. Though I'm sure you though of that already :P
Could be parsed somehow, adding "..." to the end so you get "Somereallylong..."? Shouldn't be hard to do, I'v seen it done in many recent comments widgets and things like that.
hempsworth - can i get a look at your admin-header.php. i've gone over this again and again, it just aint working.
$blog->domain comes out of the get_current_blogs_of_users function.
I can submit a patch to trac if needbe. It'll be tomorrow though. It's on the to-do list
http://www.rememberthemilk.com/home/mike.wendell/1157760/
hempsworth
Member
Posted 17 years ago #
I think it would certainly improve it. Sounds like a good idea.
demonicume - Mine is modified so probably not the best example! If you post yours we can find out what is going wrong :) Did you make the css change that drmike posted by any chance?
wphead h1 #viewsite
frozonecold
Member
Posted 17 years ago #
Hey doc why don't you do the same for the admin sub-categories?
Not a clue as to what you're talking about. There's nothing here about categories. Are you sure you've got the right thread?
frozonecold
Member
Posted 17 years ago #
Im on the right thread... I just cant word anything right. What I am trying to say is that you should use the drop down menu for other parts of the admin interface such as the admin pages (post, manage, presentation...). Is it clear now