Changeset 5987
- Timestamp:
- 04/13/2012 04:31:51 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-cache.php
r5986 r5987 44 44 wp_cache_delete( 'bp_user_' . $user_id, 'bp' ); 45 45 } 46 47 /** 48 * Clears member count caches and transients 49 */ 50 function bp_core_clear_member_count_caches() { 51 wp_cache_delete( 'bp_total_member_count', 'bp' ); 52 delete_transient( 'bp_active_member_count' ); 53 } 54 add_action( 'bp_core_activated_user', 'bp_core_clear_member_count_caches' ); 55 add_action( 'bp_core_process_spammer_status', 'bp_core_clear_member_count_caches' ); 56 add_action( 'bp_core_deleted_account', 'bp_core_clear_member_count_caches' ); 46 57 47 58 /** -
trunk/bp-core/bp-core-template.php
r5942 r5987 503 503 add_filter( 'bp_create_excerpt', 'force_balance_tags' ); 504 504 505 /** 506 * Echoes the output of bp_get_total_member_count() 507 */ 505 508 function bp_total_member_count() { 506 509 echo bp_get_total_member_count(); 507 510 } 511 /** 512 * Returns the total member count in your BP instance 513 * 514 * Since BuddyPress 1.6, this function has used bp_core_get_active_member_count(), which 515 * counts non-spam, non-deleted users who have last_activity. This value will correctly 516 * match the total member count number used for pagination on member directories. 517 * 518 * Before BuddyPress 1.6, this function used bp_core_get_total_member_count(), which did 519 * not take into account last_activity, and thus often resulted in higher counts than 520 * shown by member directory pagination. 521 */ 508 522 function bp_get_total_member_count() { 509 return apply_filters( 'bp_get_total_member_count', bp_core_get_ total_member_count() );523 return apply_filters( 'bp_get_total_member_count', bp_core_get_active_member_count() ); 510 524 } 511 525 add_filter( 'bp_get_total_member_count', 'bp_core_number_format' ); -
trunk/bp-members/bp-members-functions.php
r5986 r5987 487 487 488 488 /** 489 * Returns the total number of members, limited to those members with last_activity 490 * 491 * @return int The number of active members 492 */ 493 function bp_core_get_active_member_count() { 494 global $wpdb; 495 496 if ( !$count = get_transient( 'bp_active_member_count' ) ) { 497 // Avoid a costly join by splitting the lookup 498 if ( is_multisite() ) { 499 $sql = $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE (user_status != 0 OR deleted != 0 OR user_status != 0)" ); 500 } else { 501 $sql = $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_status != 0" ); 502 } 503 504 $exclude_users = $wpdb->get_col( $sql ); 505 $exclude_users_sql = !empty( $exclude_users ) ? $wpdb->prepare( "AND user_id NOT IN (" . implode( ',', wp_parse_id_list( $exclude_users ) ) . ")" ) : ''; 506 507 $count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(user_id) FROM $wpdb->usermeta WHERE meta_key = 'last_activity' {$exclude_users_sql}" ) ); 508 set_transient( 'bp_active_member_count', $count ); 509 } 510 511 return apply_filters( 'bp_core_get_active_member_count', $count ); 512 } 513 514 /** 489 515 * Processes a spammed or unspammed user 490 516 * … … 768 794 return false; 769 795 796 do_action( 'bp_core_pre_delete_account', $user_id ); 797 770 798 // Specifically handle multi-site environment 771 799 if ( is_multisite() ) { … … 773 801 require( ABSPATH . '/wp-admin/includes/user.php' ); 774 802 775 returnwpmu_delete_user( $user_id );803 $retval = wpmu_delete_user( $user_id ); 776 804 777 805 // Single site user deletion 778 806 } else { 779 807 require( ABSPATH . '/wp-admin/includes/user.php' ); 780 return wp_delete_user( $user_id ); 781 } 808 $retval = wp_delete_user( $user_id ); 809 } 810 811 do_action( 'bp_core_deleted_account', $user_id ); 812 813 return $retval; 782 814 } 783 815 … … 1149 1181 $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->users SET user_pass = %s WHERE ID = %d", $user['meta']['password'], $user_id ) ); 1150 1182 1151 // Delete the total member cache1152 wp_cache_delete( 'bp_total_member_count', 'bp' );1153 1154 1183 do_action( 'bp_core_activated_user', $user_id, $key, $user ); 1155 1184 -
trunk/bp-themes/bp-default/activity/index.php
r5819 r5987 37 37 <?php do_action( 'bp_before_activity_type_tab_all' ); ?> 38 38 39 <li class="selected" id="activity-all"><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_slug() ); ?>" title="<?php _e( 'The public activity for everyone on this site.', 'buddypress' ); ?>"><?php printf( __( 'All Members <span>%s</span>', 'buddypress' ), bp_get_total_ site_member_count() ); ?></a></li>39 <li class="selected" id="activity-all"><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_slug() ); ?>" title="<?php _e( 'The public activity for everyone on this site.', 'buddypress' ); ?>"><?php printf( __( 'All Members <span>%s</span>', 'buddypress' ), bp_get_total_member_count() ); ?></a></li> 40 40 41 41 <?php if ( is_user_logged_in() ) : ?> … … 90 90 91 91 <li id="activity-filter-select" class="last"> 92 <label for="activity-filter-by"><?php _e( 'Show:', 'buddypress' ); ?></label> 92 <label for="activity-filter-by"><?php _e( 'Show:', 'buddypress' ); ?></label> 93 93 <select id="activity-filter-by"> 94 94 <option value="-1"><?php _e( 'Everything', 'buddypress' ); ?></option>
Note: See TracChangeset
for help on using the changeset viewer.