How to Make the Multisite My Sites List Scroll

How to Make the Multisite My Sites List Scroll

If you look at the number of pre-built model websites I offer, you can see why I started looking for “How to Make the Multisite My Sites List Scroll”! I find it a strange thing that the issue of the “My Sites” menu in a multisite WordPress implementation hasn’t been addressed in the WordPress core. I would have thought that this would be a problem for a lot of people who offer WordPress hosting through multisite. But it looks like I’m wrong. I have only found one place where it is seriously addressed by the core developers:

My Sites limited to 23 sites on Admin Bar

Here’s the code they suggest as a patch to fix the problem:

[php]
/**
* Make the My Sites list scroll if too many blogs
*/
function custom_my_sites() {
$user_id = get_current_user_id();
$user_blogs = get_blogs_of_user( $user_id );
if (count($user_blogs) > 12) {
echo ‘<style type="text/css">
#wp-admin-bar-my-sites-list {
max-height: 90vh;
overflow-y: auto;
overflow-x: visible;
}
#wpadminbar .menupop li.hover {
position: relative;
}
#wpadminbar .menupop li.hover > .ab-sub-wrapper {
margin-left: 337px;
margin-top: -32px;
position: fixed;
}
</style>’;
}
}
add_action(‘admin_head’, ‘custom_my_sites’);
[/php]

I implemented the code and it works although not “elegantly”. The center scroll tends to simultaneously make the background window scroll at the same time.

How to Make the Multisite My Sites List Scroll