From 8fba126815351fdfd55f2e6e090a6a86c99da4aa Mon Sep 17 00:00:00 2001
From: S H Mohanjith <moha@mohanjith.net>
Date: Wed, 4 Dec 2013 23:58:31 +0200
Subject: [PATCH] Don't load million blogs in my sites menu, you can't click
on ones that are outside of the view port
---
wp-includes/admin-bar.php | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php
index c11a1f3..9acc685 100644
a
|
b
|
function wp_admin_bar_site_menu( $wp_admin_bar ) { |
332 | 332 | * @param WP_Admin_Bar $wp_admin_bar |
333 | 333 | */ |
334 | 334 | function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { |
| 335 | global $current_user; |
| 336 | |
335 | 337 | // Don't show for logged out users or single site mode. |
336 | 338 | if ( ! is_user_logged_in() || ! is_multisite() ) |
337 | 339 | return; |
… |
… |
function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { |
400 | 402 | ), |
401 | 403 | ) ); |
402 | 404 | |
| 405 | if ( count( $wp_admin_bar->user->blogs ) > 15 ) { |
| 406 | $wp_admin_bar->add_menu( array( |
| 407 | 'parent' => 'my-sites-list', |
| 408 | 'id' => 'my-sites-list-all', |
| 409 | 'title' => __( 'See All' ), |
| 410 | 'href' => get_admin_url( get_user_meta($current_user->ID, 'primary_blog', true), 'my-sites.php' ), |
| 411 | ) ); |
| 412 | } |
| 413 | |
| 414 | $_my_blog_count = 0; |
| 415 | |
403 | 416 | foreach ( (array) $wp_admin_bar->user->blogs as $blog ) { |
| 417 | if ($_my_blog_count == 14) |
| 418 | break; |
| 419 | |
404 | 420 | switch_to_blog( $blog->userblog_id ); |
405 | 421 | |
406 | 422 | $blavatar = '<div class="blavatar"></div>'; |
… |
… |
function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { |
448 | 464 | ) ); |
449 | 465 | |
450 | 466 | restore_current_blog(); |
| 467 | |
| 468 | $_my_blog_count++; |
451 | 469 | } |
452 | 470 | } |
453 | 471 | |