WordPress.org

Make WordPress Core

Ticket #22917: 22917.2.diff

File 22917.2.diff, 2.6 KB (added by adamsilverstein, 5 years ago)

refresh named properly

  • wp-includes/ms-functions.php

     
    909909        delete_user_option( $user_id, 'user_level' );
    910910
    911911        do_action( 'wpmu_new_user', $user_id );
     912        if ( apply_filters( 'enable_live_network_user_counts', false ) )
     913                wp_update_network_user_counts(); // user added, update network counts
    912914
    913915        return $user_id;
    914916}
     
    11381140        populate_options();
    11391141        populate_roles();
    11401142        $wp_roles->_init();
     1143        if ( apply_filters( 'enable_live_network_blog_counts', false ) )
     1144                wp_update_network_blog_counts(); // new blog added, update network counts
    11411145
    11421146        $url = untrailingslashit( $url );
    11431147
     
    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
  • 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 );