Make WordPress Core

Ticket #26416: patch.diff

File patch.diff, 1.6 KB (added by codix, 11 years ago)
  • wp-includes/admin-bar.php

    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 ) { 
    332332 * @param WP_Admin_Bar $wp_admin_bar
    333333 */
    334334function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
     335        global $current_user;
     336
    335337        // Don't show for logged out users or single site mode.
    336338        if ( ! is_user_logged_in() || ! is_multisite() )
    337339                return;
    function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { 
    400402                ),
    401403        ) );
    402404
     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
    403416        foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
     417                if ($_my_blog_count == 14)
     418                        break;
     419
    404420                switch_to_blog( $blog->userblog_id );
    405421
    406422                $blavatar = '<div class="blavatar"></div>';
    function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { 
    448464                ) );
    449465
    450466                restore_current_blog();
     467
     468                $_my_blog_count++;
    451469        }
    452470}
    453471