Ticket #38741: 38741.11.diff
File 38741.11.diff, 16.9 KB (added by , 6 years ago) |
---|
-
wp-admin/includes/class-wp-ms-users-list-table.php
diff --git a/wp-admin/includes/class-wp-ms-users-list-table.php b/wp-admin/includes/class-wp-ms-users-list-table.php index e3d619ae8..53b924f67 100644
a b class WP_MS_Users_List_Table extends WP_List_Table { 131 131 protected function get_views() { 132 132 global $role; 133 133 134 $total_users = get_user_count();134 $total_users = wp_get_user_count(); 135 135 $super_admins = get_super_admins(); 136 136 $total_admins = count( $super_admins ); 137 137 -
wp-admin/includes/class-wp-posts-list-table.php
diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index 717e84fb9..959e157b9 100644
a b class WP_Posts_List_Table extends WP_List_Table { 1557 1557 <?php 1558 1558 endif; // $bulk 1559 1559 1560 if ( post_type_supports( $screen->post_type, 'author' ) ) :1560 if ( post_type_supports( $screen->post_type, 'author' ) && ! wp_is_large_user_count() ) : 1561 1561 $authors_dropdown = ''; 1562 1562 1563 1563 if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) : -
wp-admin/includes/class-wp-users-list-table.php
diff --git a/wp-admin/includes/class-wp-users-list-table.php b/wp-admin/includes/class-wp-users-list-table.php index 28e197872..16889e8f6 100644
a b class WP_Users_List_Table extends WP_List_Table { 177 177 178 178 $wp_roles = wp_roles(); 179 179 180 $count_users = ! wp_is_large_user_count(); 181 180 182 if ( $this->is_site_users ) { 181 183 $url = 'site-users.php?id=' . $this->site_id; 182 switch_to_blog( $this->site_id );183 $users_of_blog = count_users( 'time', $this->site_id );184 restore_current_blog();185 184 } else { 186 $url = 'users.php'; 187 $users_of_blog = count_users(); 185 $url = 'users.php'; 188 186 } 189 187 190 $total_users = $users_of_blog['total_users']; 191 $avail_roles =& $users_of_blog['avail_roles']; 192 unset( $users_of_blog ); 188 $role_links = array(); 189 if ( $count_users ) { 190 if ( $this->is_site_users ) { 191 switch_to_blog( $this->site_id ); 192 $users_of_blog = count_users( 'time', $this->site_id ); 193 restore_current_blog(); 194 } else { 195 $users_of_blog = count_users(); 196 } 197 198 $total_users = $users_of_blog['total_users']; 199 $avail_roles =& $users_of_blog['avail_roles']; 200 unset( $users_of_blog ); 201 $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>'; 202 } else { 203 $avail_roles = array(); 204 $role_links['all'] = "<a href='$url'$current_link_attributes>" . __( 'All' ) . '</a>'; 205 } 193 206 194 207 $current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : ''; 195 208 196 $role_links = array();197 $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>';198 209 foreach ( $wp_roles->get_names() as $this_role => $name ) { 199 if ( ! isset( $avail_roles[ $this_role ] ) ) {210 if ( $count_users && ! isset( $avail_roles[ $this_role ] ) ) { 200 211 continue; 201 212 } 202 213 … … class WP_Users_List_Table extends WP_List_Table { 207 218 } 208 219 209 220 $name = translate_user_role( $name ); 210 /* translators: User role name with count */ 211 $name = sprintf( __( '%1$s <span class="count">(%2$s)</span>' ), $name, number_format_i18n( $avail_roles[ $this_role ] ) ); 221 if ( $count_users ) { 222 /* translators: User role name with count */ 223 $name = sprintf( __( '%1$s <span class="count">(%2$s)</span>' ), $name, number_format_i18n( $avail_roles[ $this_role ] ) ); 224 } 212 225 $role_links[ $this_role ] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>"; 213 226 } 214 227 -
wp-admin/includes/dashboard.php
diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index e3160bb39..efefc34c9 100644
a b function wp_network_dashboard_right_now() { 406 406 $actions['create-user'] = '<a href="' . network_admin_url( 'user-new.php' ) . '">' . __( 'Create a New User' ) . '</a>'; 407 407 } 408 408 409 $c_users = get_user_count();409 $c_users = wp_get_user_count(); 410 410 $c_blogs = get_blog_count(); 411 411 412 412 /* translators: %s: number of users on the network */ -
wp-admin/includes/schema.php
diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 20853da3e..fc55bc846 100644
a b We hope you enjoy your new site. Thanks! 1248 1248 'subdomain_install' => $subdomain_install, 1249 1249 'global_terms_enabled' => global_terms_enabled() ? '1' : '0', 1250 1250 'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0', 1251 'user_count' => get_site_option( 'user_count' ), 1251 1252 'initial_db_version' => get_option( 'initial_db_version' ), 1252 1253 'active_sitewide_plugins' => array(), 1253 1254 'WPLANG' => get_locale(), -
wp-includes/default-filters.php
diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index ecdc87cb3..afd9a6954 100644
a b add_filter( 'post_mime_type', 'sanitize_mime_type' ); 98 98 // Meta 99 99 add_filter( 'register_meta_args', '_wp_register_meta_args_whitelist', 10, 2 ); 100 100 101 // Counts 102 add_action( 'admin_init', 'wp_schedule_update_network_counts' ); 103 add_action( 'update_network_counts', 'wp_update_network_user_counts', 10, 0 ); 104 foreach ( array( 'user_register', 'deleted_user', 'wpmu_new_user', 'make_spam_user', 'make_ham_user' ) as $action ) { 105 add_action( $action, 'wp_maybe_update_network_user_counts', 10, 0 ); 106 } 107 101 108 // Post meta 102 109 add_action( 'added_post_meta', 'wp_cache_set_posts_last_changed' ); 103 110 add_action( 'updated_post_meta', 'wp_cache_set_posts_last_changed' ); -
wp-includes/functions.php
diff --git a/wp-includes/functions.php b/wp-includes/functions.php index c6542d62d..88331f1d6 100644
a b function is_wp_version_compatible( $required ) { 7165 7165 function is_php_version_compatible( $required ) { 7166 7166 return empty( $required ) || version_compare( phpversion(), $required, '>=' ); 7167 7167 } 7168 7169 7170 /** 7171 * The number of active users in your installation. 7172 * 7173 * The count is cached and updated twice daily. This is not a live count. 7174 * 7175 * @since 5.3.0 7176 * 7177 * @return int Number of active users on the network. 7178 */ 7179 function wp_get_user_count() { 7180 return get_site_option( 'user_count', -1 ); 7181 } 7182 7183 /** 7184 * Update the network-wide users count. 7185 * 7186 * If enabled through the {@see 'enable_live_network_counts'} filter, update the users count 7187 * on a network when a user is created or its status is updated. 7188 * 7189 * @since 3.7.0 7190 * @since 4.8.0 The `$network_id` parameter has been added. 7191 * @since 5.3.0 Moved to functions.php 7192 * 7193 * @param int|null $network_id ID of the network. Default is the current network. 7194 * 7195 * @return bool 7196 */ 7197 function wp_maybe_update_network_user_counts( $network_id = null ) { 7198 $is_small_network = ! wp_is_large_user_count(); 7199 7200 if ( ! is_multisite() && $network_id ) { 7201 _doing_it_wrong( __FUNCTION__, __( 'Unable to pass $nework_id if not using multisite.' ), '5.0.0' ); 7202 } 7203 7204 /** This filter is documented in wp-includes/ms-functions.php */ 7205 if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) { 7206 return; 7207 } 7208 7209 return wp_update_network_user_counts( $network_id ); 7210 } 7211 7212 /** 7213 * Update the network-wide user count. 7214 * 7215 * @since 3.7.0 7216 * @since 4.8.0 The `$network_id` parameter has been added. 7217 * @since 5.3.0 Moved to functions.php 7218 * 7219 * @global wpdb $wpdb WordPress database abstraction object. 7220 * 7221 * @param int|null $network_id ID of the network. Default is the current network. 7222 * 7223 * @return bool 7224 */ 7225 function wp_update_network_user_counts( $network_id = null ) { 7226 global $wpdb; 7227 7228 if ( ! is_multisite() && $network_id ) { 7229 _doing_it_wrong( __FUNCTION__, __( 'Unable to pass $nework_id if not using multisite.' ), '5.0.0' ); 7230 } 7231 7232 if ( is_multisite() ) { 7233 $query = "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'"; 7234 } else { 7235 $query = "SELECT COUNT(ID) as c FROM $wpdb->users"; 7236 } 7237 7238 $count = $wpdb->get_var( $query ); 7239 7240 return update_network_option( $network_id, 'user_count', $count ); 7241 } 7242 7243 /** 7244 * Schedule update of the network-wide counts for the current network. 7245 * 7246 * @since 3.1.0 7247 * @since 5.3.0 Moved to functions.php 7248 */ 7249 function wp_schedule_update_network_counts() { 7250 if ( ! is_main_site() ) { 7251 return; 7252 } 7253 7254 if ( ! wp_next_scheduled( 'update_network_counts' ) && ! wp_installing() ) { 7255 wp_schedule_event( time(), 'twicedaily', 'update_network_counts' ); 7256 } 7257 } 7258 7259 /** 7260 * @since 5.3.0 7261 * 7262 * @return boolean 7263 */ 7264 function wp_is_large_user_count() { 7265 $count = wp_get_user_count(); 7266 7267 /** 7268 * Filters whether the site is considered large, based on its number of users. 7269 * 7270 * @since x.x.x 7271 * 7272 * @param bool $is_large_user_count Whether the site has more than 10000 users. 7273 * @param int $count The count of items for the component. 7274 */ 7275 return apply_filters( 'wp_is_large_user_count', $count > 10000, $count ); 7276 } -
wp-includes/ms-default-filters.php
diff --git a/wp-includes/ms-default-filters.php b/wp-includes/ms-default-filters.php index a9658398b..50d7524da 100644
a b add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 81 81 add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 ); 82 82 83 83 // Counts 84 add_action( 'admin_init', 'wp_schedule_update_network_counts' ); 85 add_action( 'update_network_counts', 'wp_update_network_counts', 10, 0 ); 86 foreach ( array( 'user_register', 'deleted_user', 'wpmu_new_user', 'make_spam_user', 'make_ham_user' ) as $action ) { 87 add_action( $action, 'wp_maybe_update_network_user_counts', 10, 0 ); 88 } 84 add_action( 'update_network_counts', 'wp_update_network_site_counts', 10, 0 ); 89 85 foreach ( array( 'make_spam_blog', 'make_ham_blog', 'archive_blog', 'unarchive_blog', 'make_delete_blog', 'make_undelete_blog' ) as $action ) { 90 86 add_action( $action, 'wp_maybe_update_network_site_counts', 10, 0 ); 91 87 } -
wp-includes/ms-deprecated.php
diff --git a/wp-includes/ms-deprecated.php b/wp-includes/ms-deprecated.php index 6763fcb38..e820cb009 100644
a b function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) { 552 552 return isset( $current_user->$local_key ); 553 553 } 554 554 555 /** 556 * The number of active users in your installation. 557 * 558 * The count is cached and updated twice daily. This is not a live count. 559 * 560 * @since MU (3.0.0) 561 * @since 4.8.0 The `$network_id` parameter has been added. 562 * @deprecated 5.3.0 563 * 564 * @param int|null $network_id ID of the network. Default is the current network. 565 * @return int Number of active users on the network. 566 */ 567 function get_user_count( $network_id = null ) { 568 _deprecated_function( __FUNCTION__, '5.3.0', 'wp_get_user_count()' ); 569 570 return get_network_option( $network_id, 'user_count' ); 571 } 572 555 573 /** 556 574 * Store basic site info in the blogs table. 557 575 * -
wp-includes/ms-functions.php
diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index dc774a399..ed212ef50 100644
a b 17 17 function get_sitestats() { 18 18 $stats = array( 19 19 'blogs' => get_blog_count(), 20 'users' => get_user_count(),20 'users' => wp_get_user_count(), 21 21 ); 22 22 23 23 return $stats; … … function get_active_blog_for_user( $user_id ) { 95 95 } 96 96 } 97 97 98 /**99 * The number of active users in your installation.100 *101 * The count is cached and updated twice daily. This is not a live count.102 *103 * @since MU (3.0.0)104 * @since 4.8.0 The `$network_id` parameter has been added.105 *106 * @param int|null $network_id ID of the network. Default is the current network.107 * @return int Number of active users on the network.108 */109 function get_user_count( $network_id = null ) {110 return get_network_option( $network_id, 'user_count' );111 }112 113 98 /** 114 99 * The number of active sites on your installation. 115 100 * … … function filter_SSL( $url ) { 2264 2249 return $url; 2265 2250 } 2266 2251 2267 /**2268 * Schedule update of the network-wide counts for the current network.2269 *2270 * @since 3.1.02271 */2272 function wp_schedule_update_network_counts() {2273 if ( ! is_main_site() ) {2274 return;2275 }2276 2277 if ( ! wp_next_scheduled( 'update_network_counts' ) && ! wp_installing() ) {2278 wp_schedule_event( time(), 'twicedaily', 'update_network_counts' );2279 }2280 }2281 2282 2252 /** 2283 2253 * Update the network-wide counts for the current network. 2284 2254 * … … function wp_maybe_update_network_site_counts( $network_id = null ) { 2323 2293 wp_update_network_site_counts( $network_id ); 2324 2294 } 2325 2295 2326 /**2327 * Update the network-wide users count.2328 *2329 * If enabled through the {@see 'enable_live_network_counts'} filter, update the users count2330 * on a network when a user is created or its status is updated.2331 *2332 * @since 3.7.02333 * @since 4.8.0 The `$network_id` parameter has been added.2334 *2335 * @param int|null $network_id ID of the network. Default is the current network.2336 */2337 function wp_maybe_update_network_user_counts( $network_id = null ) {2338 $is_small_network = ! wp_is_large_network( 'users', $network_id );2339 2340 /** This filter is documented in wp-includes/ms-functions.php */2341 if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) {2342 return;2343 }2344 2345 wp_update_network_user_counts( $network_id );2346 }2347 2348 2296 /** 2349 2297 * Update the network-wide site count. 2350 2298 * … … function wp_update_network_site_counts( $network_id = null ) { 2373 2321 update_network_option( $network_id, 'blog_count', $count ); 2374 2322 } 2375 2323 2376 /**2377 * Update the network-wide user count.2378 *2379 * @since 3.7.02380 * @since 4.8.0 The `$network_id` parameter has been added.2381 *2382 * @global wpdb $wpdb WordPress database abstraction object.2383 *2384 * @param int|null $network_id ID of the network. Default is the current network.2385 */2386 function wp_update_network_user_counts( $network_id = null ) {2387 global $wpdb;2388 2389 $count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" );2390 update_network_option( $network_id, 'user_count', $count );2391 }2392 2393 2324 /** 2394 2325 * Returns the space used by the current blog. 2395 2326 * … … function upload_size_limit_filter( $size ) { 2507 2438 * 2508 2439 * @since 3.3.0 2509 2440 * @since 4.8.0 The `$network_id` parameter has been added. 2441 * @since 5.3.0 Deprecated `$network_id`. 2510 2442 * 2511 2443 * @param string $using 'sites or 'users'. Default is 'sites'. 2512 * @param int|null $network_idID of the network. Default is the current network.2444 * @param null $deprecated Deprecated; ID of the network. Default is the current network. 2513 2445 * @return bool True if the network meets the criteria for large. False otherwise. 2514 2446 */ 2515 function wp_is_large_network( $using = 'sites', $network_id = null ) { 2516 $network_id = (int) $network_id; 2447 function wp_is_large_network( $using = 'sites', $deprecated = null ) { 2448 2449 if ( null !== $deprecated ) { 2450 _deprecated_argument( __FUNCTION__, __( 'Unable to pass $network_id. ' ), '5.3.0' ); 2451 } 2452 2453 $network_id = (int) $deprecated; 2517 2454 if ( ! $network_id ) { 2518 2455 $network_id = get_current_network_id(); 2519 2456 } 2520 2457 2521 2458 if ( 'users' == $using ) { 2522 $count = get_user_count( $network_id ); 2459 2460 $count = wp_get_user_count( $network_id ); 2461 2462 /** This filter is documented in wp-includes/functions.php */ 2463 $is_large_network = apply_filters( 'wp_is_large_user_count', $count > 10000, $count ); 2464 2523 2465 /** 2524 2466 * Filters whether the network is considered large. 2525 2467 * … … function wp_is_large_network( $using = 'sites', $network_id = null ) { 2531 2473 * @param int $count The count of items for the component. 2532 2474 * @param int $network_id The ID of the network being checked. 2533 2475 */ 2534 return apply_filters( 'wp_is_large_network', $ count > 10000, 'users', $count, $network_id );2476 return apply_filters( 'wp_is_large_network', $is_large_network, 'users', $count, $network_id ); 2535 2477 } 2536 2478 2537 $count = get_blog_count( $network_id);2479 $count = get_blog_count(); 2538 2480 /** This filter is documented in wp-includes/ms-functions.php */ 2539 2481 return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count, $network_id ); 2540 2482 } -
wp-includes/update.php
diff --git a/wp-includes/update.php b/wp-includes/update.php index 824575099..e9314b059 100644
a b function wp_version_check( $extra_stats = array(), $force_check = false ) { 76 76 } 77 77 78 78 if ( is_multisite() ) { 79 $user_count = get_user_count();80 79 $num_blogs = get_blog_count(); 81 80 $wp_install = network_site_url(); 82 81 $multisite_enabled = 1; 83 82 } else { 84 $user_count = count_users();85 $user_count = $user_count['total_users'];86 83 $multisite_enabled = 0; 87 84 $num_blogs = 1; 88 85 $wp_install = home_url( '/' );