Changeset 15875
- Timestamp:
- 10/20/2010 08:22:14 PM (14 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/ms-default-filters.php
r15678 r15875 40 40 add_action( 'publish_phone', 'wpmu_update_blogs_date' ); 41 41 add_action( 'publish_post', 'wpmu_update_blogs_date' ); 42 add_action( 'admin_init', 'wp_schedule_update_network_counts'); 43 add_action( 'update_network_counts', 'wp_update_network_counts'); 42 44 43 45 // Files … … 58 60 add_filter( 'force_filtered_html_on_import', '__return_true' ); 59 61 60 61 62 // WP_HOME and WP_SITEURL should not have any effect in MS 62 63 remove_filter( 'option_siteurl', '_config_wp_siteurl' ); -
trunk/wp-includes/ms-functions.php
r15843 r15875 149 149 * The number of active users in your installation. 150 150 * 151 * This function also saves the count as a site option, 152 * which speeds up future lookups. 151 * The count is cached and updated twice daily. This is not a live count. 153 152 * 154 153 * @since MU 2.7 … … 158 157 */ 159 158 function get_user_count() { 160 global $wpdb; 161 162 $count_ts = get_site_option( 'user_count_ts' ); 163 if ( time() - $count_ts > 3600 ) { 164 $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'") ); 165 update_site_option( 'user_count', $count ); 166 update_site_option( 'user_count_ts', time() ); 167 } 168 169 $count = get_site_option( 'user_count' ); 170 171 return $count; 159 return get_site_option( 'user_count' ); 172 160 } 173 161 … … 175 163 * The number of active sites on your installation. 176 164 * 177 * This function also saves the count as a site option, 178 * which speeds up future lookups. 165 * The count is cached and updated twice daily. This is not a live count. 179 166 * 180 167 * @since MU 1.0 … … 185 172 */ 186 173 function get_blog_count( $id = 0 ) { 187 global $wpdb; 188 189 if ( $id == 0 ) 190 $id = $wpdb->siteid; 191 192 $count_ts = get_site_option( 'blog_count_ts' ); 193 if ( time() - $count_ts > 3600 ) { 194 $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'", $id) ); 195 update_site_option( 'blog_count', $count ); 196 update_site_option( 'blog_count_ts', time() ); 197 } 198 199 $count = get_site_option( 'blog_count' ); 200 201 return $count; 174 return get_site_option( 'blog_count' ); 202 175 } 203 176 … … 1534 1507 } 1535 1508 1509 /** 1510 * Schedule update of the network-wide counts for the current network. 1511 * 1512 * @since 3.1.0 1513 */ 1514 function wp_schedule_update_network_counts() { 1515 if ( !is_main_site() ) 1516 return; 1517 1518 if ( !wp_next_scheduled('update_network_counts') && !defined('WP_INSTALLING') ) 1519 wp_schedule_event(time(), 'twicedaily', 'update_network_counts'); 1520 } 1521 1522 /** 1523 * Update the network-wide counts for the current network. 1524 * 1525 * @since 3.1.0 1526 */ 1527 function wp_update_network_counts() { 1528 global $wpdb; 1529 1530 $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) ); 1531 update_site_option( 'blog_count', $count ); 1532 1533 $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'") ); 1534 update_site_option( 'user_count', $count ); 1535 } 1536 1536 1537 ?>
Note: See TracChangeset
for help on using the changeset viewer.