buddypress/bp-friends/bp-friends-cache.php
John James Jacoby 48a148af40 Refactor Friends component's approach to Notifications integration:
* Relocate `friends_clear_friendship_notifications()` out of `bp-friends-cache.php` and into `bp-friends-notifications.php`
* Introduce helper functions for handling the adding/marking/deleting of notifications. Hook these new functions into their respective actions rather than have them hardcoded and interspersed amongst the first-class code.
* See #5266. Hat-tip r-a-y.

git-svn-id: https://buddypress.svn.wordpress.org/trunk@7619 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
2013-11-30 03:47:27 +00:00

38 lines
1.3 KiB
PHP

<?php
/**
* BuddyPress Friends Caching.
*
* Caching functions handle the clearing of cached objects and pages on specific
* actions throughout BuddyPress.
*
* @package BuddyPress
* @subpackage FriendsCaching
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Clear friends-related cache for members of a specific friendship.
*
* @param int $friendship_id ID of the friendship whose two members should
* have their friends cache busted.
*/
function friends_clear_friend_object_cache( $friendship_id ) {
if ( !$friendship = new BP_Friends_Friendship( $friendship_id ) )
return false;
wp_cache_delete( 'friends_friend_ids_' . $friendship->initiator_user_id, 'bp' );
wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id, 'bp' );
}
// List actions to clear object caches on
add_action( 'friends_friendship_accepted', 'friends_clear_friend_object_cache' );
add_action( 'friends_friendship_deleted', 'friends_clear_friend_object_cache' );
// List actions to clear super cached pages on, if super cache is installed
add_action( 'friends_friendship_rejected', 'bp_core_clear_cache' );
add_action( 'friends_friendship_accepted', 'bp_core_clear_cache' );
add_action( 'friends_friendship_deleted', 'bp_core_clear_cache' );
add_action( 'friends_friendship_requested', 'bp_core_clear_cache' );