673 | | // Try priming the new cache from the old cache |
674 | | if ( false === $blogs ) { |
675 | | $cache_suffix = $all ? '_all' : '_short'; |
676 | | $blogs = wp_cache_get( 'blogs_of_user_' . $id . $cache_suffix, 'users' ); |
677 | | if ( is_array( $blogs ) ) { |
678 | | $blogs = array_keys( $blogs ); |
679 | | if ( $all ) |
680 | | wp_cache_set( 'blogs_of_user-' . $id, $blogs, 'users' ); |
| 676 | $blogs = array(); |
| 677 | foreach ( $userkeys as $key ) { |
| 678 | if ( $key === $wpdb->base_prefix . 'capabilities' ) { |
| 679 | $blogs[] = 1; |
| 680 | continue; |
684 | | if ( false === $blogs ) { |
685 | | $userkeys = get_user_meta( (int) $id ); |
686 | | if ( empty( $userkeys ) ) |
687 | | return false; |
688 | | $userkeys = array_keys( $userkeys ); |
689 | | |
690 | | $blogs = $match = array(); |
691 | | $prefix_length = strlen( $wpdb->base_prefix ); |
692 | | foreach ( $userkeys as $key ) { |
693 | | if ( $prefix_length && substr($key, 0, $prefix_length) != $wpdb->base_prefix ) |
694 | | continue; |
695 | | if ( substr($key, -12, 12) != 'capabilities' ) |
696 | | continue; |
697 | | if ( preg_match( '/^' . $wpdb->base_prefix . '((\d+)_)?capabilities$/', $key, $match ) ) { |
698 | | if ( count( $match ) > 2 ) |
699 | | $blogs[] = (int) $match[ 2 ]; |
700 | | else |
701 | | $blogs[] = 1; |
702 | | } |
703 | | } |
704 | | wp_cache_set( 'blogs_of_user-' . $id, $blogs, 'users' ); |
705 | | } |
706 | | |