| 1 | Index: wp-includes/ms-functions.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/ms-functions.php (revision 23693) |
|---|
| 4 | +++ wp-includes/ms-functions.php (working copy) |
|---|
| 5 | @@ -909,6 +909,8 @@ |
|---|
| 6 | delete_user_option( $user_id, 'user_level' ); |
|---|
| 7 | |
|---|
| 8 | do_action( 'wpmu_new_user', $user_id ); |
|---|
| 9 | + if ( apply_filters( 'enable_live_network_user_counts', false ) ) |
|---|
| 10 | + wp_update_network_user_counts(); // user added, update network counts |
|---|
| 11 | |
|---|
| 12 | return $user_id; |
|---|
| 13 | } |
|---|
| 14 | @@ -1138,6 +1140,8 @@ |
|---|
| 15 | populate_options(); |
|---|
| 16 | populate_roles(); |
|---|
| 17 | $wp_roles->_init(); |
|---|
| 18 | + if ( apply_filters( 'enable_live_network_blog_counts', false ) ) |
|---|
| 19 | + wp_update_network_blog_counts(); // new blog added, update network counts |
|---|
| 20 | |
|---|
| 21 | $url = untrailingslashit( $url ); |
|---|
| 22 | |
|---|
| 23 | @@ -1887,16 +1891,35 @@ |
|---|
| 24 | * @since 3.1.0 |
|---|
| 25 | */ |
|---|
| 26 | function wp_update_network_counts() { |
|---|
| 27 | + wp_update_network_user_counts(); |
|---|
| 28 | + wp_update_network_blog_counts(); |
|---|
| 29 | +} |
|---|
| 30 | + |
|---|
| 31 | +/** |
|---|
| 32 | + * Update the network-wide counts for users. |
|---|
| 33 | + * |
|---|
| 34 | + * @since 3.6.0 |
|---|
| 35 | + */ |
|---|
| 36 | +function wp_update_network_user_counts() { |
|---|
| 37 | global $wpdb; |
|---|
| 38 | |
|---|
| 39 | - $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(blog_id) as c FROM $wpdb->blogs WHERE site_id = %d AND spam = '0' AND deleted = '0' and archived = '0'", $wpdb->siteid) ); |
|---|
| 40 | - update_site_option( 'blog_count', $count ); |
|---|
| 41 | - |
|---|
| 42 | $count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" ); |
|---|
| 43 | update_site_option( 'user_count', $count ); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | /** |
|---|
| 47 | + * Update the network-wide counts for blogs. |
|---|
| 48 | + * |
|---|
| 49 | + * @since 3.6.0 |
|---|
| 50 | + */ |
|---|
| 51 | +function wp_update_network_blog_counts() { |
|---|
| 52 | + global $wpdb; |
|---|
| 53 | + |
|---|
| 54 | + $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(blog_id) as c FROM $wpdb->blogs WHERE site_id = %d AND spam = '0' AND deleted = '0' and archived = '0'", $wpdb->siteid ) ); |
|---|
| 55 | + update_site_option( 'blog_count', $count ); |
|---|
| 56 | +} |
|---|
| 57 | + |
|---|
| 58 | +/** |
|---|
| 59 | * Returns the space used by the current blog. |
|---|
| 60 | * |
|---|
| 61 | * @since 3.5.0 |
|---|
| 62 | Index: wp-admin/includes/ms.php |
|---|
| 63 | =================================================================== |
|---|
| 64 | --- wp-admin/includes/ms.php (revision 23693) |
|---|
| 65 | +++ wp-admin/includes/ms.php (working copy) |
|---|
| 66 | @@ -122,6 +122,8 @@ |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | clean_blog_cache( $blog ); |
|---|
| 70 | + if ( apply_filters( 'enable_live_network_blog_counts', false ) ) |
|---|
| 71 | + wp_update_network_blog_counts(); // blog deleted, update network counts |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | if ( $switch ) |
|---|
| 75 | @@ -171,6 +173,8 @@ |
|---|
| 76 | $wpdb->delete( $wpdb->users, array( 'ID' => $id ) ); |
|---|
| 77 | |
|---|
| 78 | clean_user_cache( $user ); |
|---|
| 79 | + if ( apply_filters( 'enable_live_network_user_counts', false ) ) |
|---|
| 80 | + wp_update_network_user_counts(); // user deleted, update network counts |
|---|
| 81 | |
|---|
| 82 | // allow for commit transaction |
|---|
| 83 | do_action( 'deleted_user', $id ); |
|---|