Changeset 8105
- Timestamp:
- 03/10/2014 08:36:19 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-friends/bp-friends-cache.php
r7619 r8105 32 32 add_action( 'friends_friendship_deleted', 'friends_clear_friend_object_cache' ); 33 33 34 /** 35 * Clear the friend request cache for the user not initiating the friendship. 36 * 37 * @since BuddyPress (2.0.0) 38 * 39 * @param int $friend_user_id The user ID not initiating the friendship 40 */ 41 function bp_friends_clear_request_cache( $friend_user_id ) { 42 wp_cache_delete( $friend_user_id, 'bp_friends_requests' ); 43 } 44 45 /** 46 * Clear the friend request cache when a friendship is saved. 47 * 48 * A friendship is deemed saved when a friendship is requested or accepted. 49 * 50 * @since BuddyPress (2.0.0) 51 * 52 * @param int $friendship_id The friendship ID 53 * @param int $initiator_user_id The user ID initiating the friendship 54 * @param int $friend_user_id The user ID not initiating the friendship 55 */ 56 function bp_friends_clear_request_cache_on_save( $friendship_id, $initiator_user_id, $friend_user_id ) { 57 bp_friends_clear_request_cache( $friend_user_id ); 58 } 59 add_action( 'friends_friendship_requested', 'bp_friends_clear_request_cache_on_save', 10, 3 ); 60 add_action( 'friends_friendship_accepted', 'bp_friends_clear_request_cache_on_save', 10, 3 ); 61 62 /** 63 * Clear the friend request cache when a friendship is removed. 64 * 65 * A friendship is deemed removed when a friendship is withdrawn or rejected. 66 * 67 * @since BuddyPress (2.0.0) 68 * 69 * @param int $friendship_id The friendship ID 70 * @param BP_Friends_Friendship $friendship 71 */ 72 function bp_friends_clear_request_cache_on_remove( $friendship_id, BP_Friends_Friendship $friendship ) { 73 bp_friends_clear_request_cache( $friendship->friend_user_id ); 74 } 75 add_action( 'friends_friendship_withdrawn', 'bp_friends_clear_request_cache_on_remove', 10, 2 ); 76 add_action( 'friends_friendship_rejected', 'bp_friends_clear_request_cache_on_remove', 10, 2 ); 77 34 78 // List actions to clear super cached pages on, if super cache is installed 35 79 add_action( 'friends_friendship_rejected', 'bp_core_clear_cache' ); -
trunk/bp-friends/bp-friends-classes.php
r7860 r8105 227 227 */ 228 228 public static function get_friendship_request_user_ids( $user_id ) { 229 global $wpdb, $bp; 230 231 return $wpdb->get_col( $wpdb->prepare( "SELECT initiator_user_id FROM {$bp->friends->table_name} WHERE friend_user_id = %d AND is_confirmed = 0", $user_id ) ); 229 $friend_requests = wp_cache_get( $user_id, 'bp_friends_requests' ); 230 231 if ( false === $friend_requests ) { 232 global $wpdb, $bp; 233 234 $friend_requests = $wpdb->get_col( $wpdb->prepare( "SELECT initiator_user_id FROM {$bp->friends->table_name} WHERE friend_user_id = %d AND is_confirmed = 0", $user_id ) ); 235 236 wp_cache_set( $user_id, $friend_requests, 'bp_friends_requests' ); 237 } 238 239 return $friend_requests; 232 240 } 233 241
Note: See TracChangeset
for help on using the changeset viewer.