WordPress.org

Make WordPress Core

Changeset 41753


Ignore:
Timestamp:
10/04/2017 10:16:21 PM (3 years ago)
Author:
johnbillion
Message:

Users: Revert [41613], [41614], and [41623] as this feature needs some more work.

See #38741

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-users-list-table.php

    r41683 r41753  
    167167
    168168        $wp_roles = wp_roles();
    169         $count_users = true;
    170 
    171         if ( wp_is_large_user_count() ) {
    172             $count_users = false;
    173         } elseif ( is_multisite() && wp_is_large_network( 'users' ) ) {
    174             $count_users = false;
    175         }
    176169
    177170        if ( $this->is_site_users ) {
    178171            $url = 'site-users.php?id=' . $this->site_id;
    179             if ( $count_users ) {
    180                 switch_to_blog( $this->site_id );
    181                 $users_of_blog = count_users( 'time', $this->site_id );
    182                 restore_current_blog();
    183             }
     172            switch_to_blog( $this->site_id );
     173            $users_of_blog = count_users( 'time', $this->site_id );
     174            restore_current_blog();
    184175        } else {
    185176            $url = 'users.php';
    186             if ( $count_users ) {
    187                 $users_of_blog = count_users();
    188             }
    189         }
    190 
    191         if ( $count_users ) {
    192             $total_users = $users_of_blog['total_users'];
    193             $avail_roles =& $users_of_blog['avail_roles'];
    194             unset($users_of_blog);
    195         } else {
    196             $avail_roles = array();
    197         }
     177            $users_of_blog = count_users();
     178        }
     179
     180        $total_users = $users_of_blog['total_users'];
     181        $avail_roles =& $users_of_blog['avail_roles'];
     182        unset($users_of_blog);
    198183
    199184        $current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : '';
    200185
    201186        $role_links = array();
    202 
    203         if ( $count_users ) {
    204             $role_links['all'] = "<a href='$url'$current_link_attributes>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
    205         } else {
    206             $role_links['all'] = "<a href='$url'$current_link_attributes>" . _x( 'All', 'users' ) . '</a>';
    207         }
     187        $role_links['all'] = "<a href='$url'$current_link_attributes>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
    208188        foreach ( $wp_roles->get_names() as $this_role => $name ) {
    209             if ( $count_users && !isset($avail_roles[$this_role]) ) {
     189            if ( !isset($avail_roles[$this_role]) )
    210190                continue;
    211             }
    212191
    213192            $current_link_attributes = '';
     
    218197
    219198            $name = translate_user_role( $name );
    220             if ( $count_users ) {
    221                 /* translators: User role name with count */
    222                 $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles[$this_role] ) );
    223             }
     199            /* translators: User role name with count */
     200            $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles[$this_role] ) );
    224201            $role_links[$this_role] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>";
    225202        }
    226203
    227         if ( ! $count_users || ! empty( $avail_roles['none' ] ) ) {
     204        if ( ! empty( $avail_roles['none' ] ) ) {
    228205
    229206            $current_link_attributes = '';
     
    234211
    235212            $name = __( 'No role' );
    236             if ( $count_users ) {
    237                 /* translators: User role name with count */
    238                 $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles['none' ] ) );
    239             }
     213            /* translators: User role name with count */
     214            $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles['none' ] ) );
    240215            $role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$current_link_attributes>$name</a>";
    241216
  • trunk/src/wp-includes/default-filters.php

    r41613 r41753  
    467467add_action( 'init', 'wp_widgets_init', 1 );
    468468
    469 // User counts
    470 foreach ( array( 'user_register', 'deleted_user' ) as $action ){
    471     add_action( $action, 'wp_update_active_user_count' );
    472 }
    473 
    474469// Admin Bar
    475470// Don't remove. Wrong way to disable.
  • trunk/src/wp-includes/functions.php

    r41692 r41753  
    58385838    ), $email_change_email['message'], $email_change_email['headers'] );
    58395839}
    5840 
    5841 /**
    5842  * Whether or not we have a large site, based on its number of users.
    5843  *
    5844  * The default criteria for a large site is more than 10,000 users.
    5845  *
    5846  * @since 4.9.0
    5847  *
    5848  * @return bool True if the site meets the criteria for large. False otherwise.
    5849  */
    5850 function wp_is_large_user_count() {
    5851     $count = wp_get_active_user_count();
    5852 
    5853     /**
    5854      * Filters whether the site is considered large, based on its number of users.
    5855      *
    5856      * The default criteria for a large site is more than 10,000 users.
    5857      *
    5858      * @since 4.9.0
    5859      *
    5860      * @param bool $is_large_user_count Whether the site is considered large.
    5861      * @param int  $count               The number of users on the site.
    5862      */
    5863     return apply_filters( 'wp_is_large_user_count', $count > 10000, $count );
    5864 }
    5865 
    5866 /**
    5867  * Update the active user count.
    5868  *
    5869  * @since 4.9.0
    5870  * @global wpdb $wpdb WordPress database abstraction object.
    5871  *
    5872  * @return int The active user count.
    5873  */
    5874 function wp_update_active_user_count() {
    5875     global $wpdb;
    5876 
    5877     $count = $wpdb->get_var( "
    5878         SELECT COUNT(ID) as c
    5879         FROM {$wpdb->users}
    5880     " );
    5881     update_option( 'active_user_count', $count );
    5882 
    5883     return (int) $count;
    5884 }
    5885 
    5886 /**
    5887  * The number of active users.
    5888  *
    5889  * @since 4.9.0
    5890  *
    5891  * @return int The active user count.
    5892  */
    5893 function wp_get_active_user_count() {
    5894     $count = get_option( 'active_user_count', false );
    5895 
    5896     if ( false === $count ) {
    5897         $count = wp_update_active_user_count();
    5898     }
    5899     return (int) $count;
    5900 }
  • trunk/src/wp-includes/ms-functions.php

    r41738 r41753  
    25302530    if ( 'users' == $using ) {
    25312531        $count = get_user_count( $network_id );
    2532         $is_large = ( $count > 10000 );
    2533 
    2534         /** This filter is documented in wp-includes/functions.php */
    2535         $is_large = apply_filters( 'wp_is_large_user_count', $is_large, $count );
    2536 
    25372532        /**
    25382533         * Filters whether the network is considered large.
     
    25462541         * @param int    $network_id       The ID of the network being checked.
    25472542         */
    2548         return apply_filters( 'wp_is_large_network', $is_large, 'users', $count, $network_id );
     2543        return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count, $network_id );
    25492544    }
    25502545
  • trunk/src/wp-includes/update.php

    r41613 r41753  
    7979        $multisite_enabled = 1;
    8080    } else {
    81         $user_count = wp_get_active_user_count();
     81        $user_count = count_users();
     82        $user_count = $user_count['total_users'];
    8283        $multisite_enabled = 0;
    8384        $num_blogs = 1;
Note: See TracChangeset for help on using the changeset viewer.