Changeset 41753
- Timestamp:
- 10/04/2017 10:16:21 PM (6 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-users-list-table.php
r41683 r41753 167 167 168 168 $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 }176 169 177 170 if ( $this->is_site_users ) { 178 171 $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(); 184 175 } else { 185 176 $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); 198 183 199 184 $current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : ''; 200 185 201 186 $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>'; 208 188 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]) ) 210 190 continue; 211 }212 191 213 192 $current_link_attributes = ''; … … 218 197 219 198 $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] ) ); 224 201 $role_links[$this_role] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>"; 225 202 } 226 203 227 if ( ! $count_users || !empty( $avail_roles['none' ] ) ) {204 if ( ! empty( $avail_roles['none' ] ) ) { 228 205 229 206 $current_link_attributes = ''; … … 234 211 235 212 $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' ] ) ); 240 215 $role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$current_link_attributes>$name</a>"; 241 216 -
trunk/src/wp-includes/default-filters.php
r41613 r41753 467 467 add_action( 'init', 'wp_widgets_init', 1 ); 468 468 469 // User counts470 foreach ( array( 'user_register', 'deleted_user' ) as $action ){471 add_action( $action, 'wp_update_active_user_count' );472 }473 474 469 // Admin Bar 475 470 // Don't remove. Wrong way to disable. -
trunk/src/wp-includes/functions.php
r41692 r41753 5838 5838 ), $email_change_email['message'], $email_change_email['headers'] ); 5839 5839 } 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.05847 *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.05859 *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.05870 * @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 c5879 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.05890 *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 2530 2530 if ( 'users' == $using ) { 2531 2531 $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 2537 2532 /** 2538 2533 * Filters whether the network is considered large. … … 2546 2541 * @param int $network_id The ID of the network being checked. 2547 2542 */ 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 ); 2549 2544 } 2550 2545 -
trunk/src/wp-includes/update.php
r41613 r41753 79 79 $multisite_enabled = 1; 80 80 } else { 81 $user_count = wp_get_active_user_count(); 81 $user_count = count_users(); 82 $user_count = $user_count['total_users']; 82 83 $multisite_enabled = 0; 83 84 $num_blogs = 1;
Note: See TracChangeset
for help on using the changeset viewer.