Make WordPress Core

Ticket #22917: 22917.3.diff

File 22917.3.diff, 2.6 KB (added by SergeyBiryukov, 12 years ago)

Same as 22917-2.diff, with minor formatting fixes

  • wp-admin/includes/ms.php

     
    122122                }
    123123
    124124                clean_blog_cache( $blog );
     125                if ( apply_filters( 'enable_live_network_blog_counts', false ) )
     126                        wp_update_network_blog_counts(); // blog deleted, update network counts
    125127        }
    126128
    127129        if ( $switch )
     
    171173        $wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
    172174
    173175        clean_user_cache( $user );
     176        if ( apply_filters( 'enable_live_network_user_counts', false ) )
     177                wp_update_network_user_counts(); // user deleted, update network counts
    174178
    175179        // allow for commit transaction
    176180        do_action( 'deleted_user', $id );
  • wp-includes/ms-functions.php

     
    914914        delete_user_option( $user_id, 'user_level' );
    915915
    916916        do_action( 'wpmu_new_user', $user_id );
     917        if ( apply_filters( 'enable_live_network_user_counts', false ) )
     918                wp_update_network_user_counts(); // user added, update network counts
    917919
    918920        return $user_id;
    919921}
     
    11421144        populate_options();
    11431145        populate_roles();
    11441146        $wp_roles->_init();
     1147        if ( apply_filters( 'enable_live_network_blog_counts', false ) )
     1148                wp_update_network_blog_counts(); // new blog added, update network counts
    11451149
    11461150        $url = untrailingslashit( $url );
    11471151
     
    18871891 *  @since 3.1.0
    18881892 */
    18891893function wp_update_network_counts() {
     1894        wp_update_network_user_counts();
     1895        wp_update_network_blog_counts();
     1896}
     1897
     1898/**
     1899 * Update the network-wide counts for users.
     1900 *
     1901 * @since 3.6.0
     1902 */
     1903function wp_update_network_user_counts() {
    18901904        global $wpdb;
    18911905
    1892         $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) );
    1893         update_site_option( 'blog_count', $count );
    1894 
    18951906        $count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" );
    18961907        update_site_option( 'user_count', $count );
    18971908}
    18981909
    18991910/**
     1911 * Update the network-wide counts for blogs.
     1912 *
     1913 * @since 3.6.0
     1914 */
     1915function wp_update_network_blog_counts() {
     1916        global $wpdb;
     1917
     1918        $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 ) );
     1919        update_site_option( 'blog_count', $count );
     1920}
     1921
     1922/**
    19001923 * Returns the space used by the current blog.
    19011924 *
    19021925 * @since 3.5.0