606 | | $user = get_userdata( (int) $id ); |
607 | | if ( !$user ) |
608 | | return false; |
609 | | |
610 | | $blogs = $match = array(); |
611 | | $prefix_length = strlen($wpdb->base_prefix); |
612 | | foreach ( (array) $user as $key => $value ) { |
613 | | if ( $prefix_length && substr($key, 0, $prefix_length) != $wpdb->base_prefix ) |
614 | | continue; |
615 | | if ( substr($key, -12, 12) != 'capabilities' ) |
616 | | continue; |
617 | | if ( preg_match( '/^' . $wpdb->base_prefix . '((\d+)_)?capabilities$/', $key, $match ) ) { |
618 | | if ( count( $match ) > 2 ) |
619 | | $blog_id = $match[ 2 ]; |
620 | | else |
621 | | $blog_id = 1; |
622 | | $blog = get_blog_details( $blog_id ); |
623 | | if ( $blog && isset( $blog->domain ) && ( $all == true || $all == false && ( $blog->archived == 0 && $blog->spam == 0 && $blog->deleted == 0 ) ) ) { |
624 | | $blogs[ $blog_id ]->userblog_id = $blog_id; |
625 | | $blogs[ $blog_id ]->blogname = $blog->blogname; |
626 | | $blogs[ $blog_id ]->domain = $blog->domain; |
627 | | $blogs[ $blog_id ]->path = $blog->path; |
628 | | $blogs[ $blog_id ]->site_id = $blog->site_id; |
629 | | $blogs[ $blog_id ]->siteurl = $blog->siteurl; |
| 607 | $blogs = $match = array(); |
| 608 | $prefix_length = strlen($wpdb->base_prefix); |
| 609 | foreach ( (array) $user as $key => $value ) { |
| 610 | if ( $prefix_length && substr($key, 0, $prefix_length) != $wpdb->base_prefix ) |
| 611 | continue; |
| 612 | if ( substr($key, -12, 12) != 'capabilities' ) |
| 613 | continue; |
| 614 | if ( preg_match( '/^' . $wpdb->base_prefix . '((\d+)_)?capabilities$/', $key, $match ) ) { |
| 615 | if ( count( $match ) > 2 ) |
| 616 | $blogs[] = (int) $match[ 2 ]; |
| 617 | else |
| 618 | $blogs[] = 1; |
634 | | wp_cache_add( 'blogs_of_user_' . $id . $cache_suffix, $blogs, 'users', 5 ); |
635 | | return apply_filters( 'get_blogs_of_user', $blogs, $id, $all ); |
| 624 | $blog_deets = array(); |
| 625 | foreach ( (array) $blogs as $blog_id ) { |
| 626 | $blog = get_blog_details( $blog_id ); |
| 627 | if ( $blog && isset( $blog->domain ) && ( $all == true || $all == false && ( $blog->archived == 0 && $blog->spam == 0 && $blog->deleted == 0 ) ) ) { |
| 628 | $blog_deets[ $blog_id ]->userblog_id = $blog_id; |
| 629 | $blog_deets[ $blog_id ]->blogname = $blog->blogname; |
| 630 | $blog_deets[ $blog_id ]->domain = $blog->domain; |
| 631 | $blog_deets[ $blog_id ]->path = $blog->path; |
| 632 | $blog_deets[ $blog_id ]->site_id = $blog->site_id; |
| 633 | $blog_deets[ $blog_id ]->siteurl = $blog->siteurl; |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | return apply_filters( 'get_blogs_of_user', $blog_deets, $id, $all ); |