Ticket #38741: 38741.2.diff
File 38741.2.diff, 5.5 KB (added by , 8 years ago) |
---|
-
src/wp-admin/includes/class-wp-users-list-table.php
173 173 global $role; 174 174 175 175 $wp_roles = wp_roles(); 176 $count_users = true; 176 177 178 if ( wp_is_large_site() ) { 179 $count_users = false; 180 } elseif ( is_multisite() && wp_is_large_network( 'users' ) ) { 181 $count_users = false; 182 } 183 177 184 if ( $this->is_site_users ) { 178 185 $url = 'site-users.php?id=' . $this->site_id; 179 switch_to_blog( $this->site_id ); 180 $users_of_blog = count_users(); 181 restore_current_blog(); 186 if ( $count_users ) { 187 switch_to_blog( $this->site_id ); 188 $users_of_blog = count_users(); 189 restore_current_blog(); 190 } 182 191 } else { 183 192 $url = 'users.php'; 184 $users_of_blog = count_users(); 193 if ( $count_users ) { 194 $users_of_blog = count_users(); 195 } 185 196 } 186 197 187 $total_users = $users_of_blog['total_users']; 188 $avail_roles =& $users_of_blog['avail_roles']; 189 unset($users_of_blog); 198 if ( $count_users ) { 199 $total_users = $users_of_blog['total_users']; 200 $avail_roles =& $users_of_blog['avail_roles']; 201 unset( $users_of_blog ); 202 } else { 203 $avail_roles = array(); 204 } 190 205 191 206 $class = empty($role) ? ' class="current"' : ''; 192 207 $role_links = array(); 193 $role_links['all'] = "<a href='$url'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>'; 208 209 if ( $count_users ) { 210 $role_links['all'] = "<a href='$url'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>'; 211 } else { 212 $role_links['all'] = "<a href='$url'$class>" . _x( 'All', 'users' ) . '</a>'; 213 } 214 194 215 foreach ( $wp_roles->get_names() as $this_role => $name ) { 195 if ( !isset($avail_roles[$this_role]) )216 if ( $count_users && ! isset( $avail_roles[ $this_role ] ) ) { 196 217 continue; 218 } 197 219 198 220 $class = ''; 199 221 … … 202 224 } 203 225 204 226 $name = translate_user_role( $name ); 205 /* translators: User role name with count */ 206 $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles[$this_role] ) ); 227 if ( $count_users ) { 228 /* translators: User role name with count */ 229 $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles[$this_role] ) ); 230 } 207 231 $role_links[$this_role] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$class>$name</a>"; 208 232 } 209 233 210 if ( ! empty( $avail_roles['none' ] ) ) {234 if ( ! $count_users || ! empty( $avail_roles['none' ] ) ) { 211 235 212 236 $class = ''; 213 237 … … 216 240 } 217 241 218 242 $name = __( 'No role' ); 219 /* translators: User role name with count */ 220 $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles['none' ] ) ); 243 if ( $count_users ) { 244 /* translators: User role name with count */ 245 $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles['none' ] ) ); 246 } 221 247 $role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$class>$name</a>"; 222 248 223 249 } -
src/wp-includes/functions.php
35 35 if ( 'U' == $format ) 36 36 return $i; 37 37 38 38 39 if ( $translate ) 39 40 return date_i18n( $format, $i ); 40 41 else … … 5592 5593 5593 5594 return $last_changed; 5594 5595 } 5596 5597 /** 5598 * Whether or not we have a large site. 5599 * 5600 * The default criteria for a large site is more than 10,000 users. 5601 * 5602 * @since x.x.x 5603 * 5604 * @return bool True if the site meets the criteria for large. False otherwise. 5605 */ 5606 function wp_is_large_site() { 5607 $count = wp_active_user_count(); 5608 5609 /** 5610 * Filters whether the site is considered large. 5611 * 5612 * @since x.x.x 5613 * 5614 * @param bool $is_large_site Whether the site has more than 10000 users. 5615 * @param int $count The count of items for the component. 5616 */ 5617 return apply_filters( 'wp_is_large_site', $count > 10000, $count ); 5618 } 5619 5620 /** 5621 * Update the active user count. 5622 * 5623 * @since x.x.x 5624 * 5625 * @global wpdb $wpdb WordPress database abstraction object. 5626 */ 5627 function wp_get_active_user_count() { 5628 global $wpdb; 5629 5630 $count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users" ); 5631 return $count; 5632 } 5633 5634 /** 5635 * The number of active users. 5636 * 5637 * The count is cached and updated twice daily. This is not a live count. 5638 * 5639 * @since x.x.x 5640 * 5641 * @return int 5642 */ 5643 function wp_active_user_count() { 5644 $count = get_transient( 'active_user_count' ); 5645 5646 if ( false === $count ) { 5647 $count = wp_get_active_user_count(); 5648 set_transient( 'active_user_count', $count, 12 * HOUR_IN_SECONDS ); 5649 } 5650 5651 return (int) $count; 5652 } -
src/wp-includes/update.php
78 78 $wp_install = network_site_url(); 79 79 $multisite_enabled = 1; 80 80 } else { 81 $user_count = count_users(); 82 $user_count = $user_count['total_users']; 81 $user_count = wp_get_active_user_count(); 83 82 $multisite_enabled = 0; 84 83 $num_blogs = 1; 85 84 $wp_install = home_url( '/' );