mirror of
https://gh.wpcy.net/https://github.com/buddypress/buddypress.git
synced 2026-05-31 05:04:29 +08:00
git-svn-id: https://buddypress.svn.wordpress.org/trunk@1133 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
41 lines
No EOL
1.5 KiB
PHP
41 lines
No EOL
1.5 KiB
PHP
<?php
|
|
|
|
function friends_ajax_friends_search() {
|
|
global $bp;
|
|
|
|
check_ajax_referer( 'friends_search' );
|
|
|
|
load_template( get_template_directory() . '/friends/friends-loop.php' );
|
|
}
|
|
add_action( 'wp_ajax_friends_search', 'friends_ajax_friends_search' );
|
|
|
|
function friends_ajax_addremove_friend() {
|
|
global $bp;
|
|
|
|
if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) {
|
|
|
|
check_ajax_referer('friends_remove_friend');
|
|
|
|
if ( !friends_remove_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) {
|
|
echo __("Friendship could not be canceled.", 'buddypress');
|
|
} else {
|
|
echo '<a id="friend-' . $_POST['fid'] . '" class="add" rel="add" title="' . __( 'Add Friend', 'buddypress' ) . '" href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $_POST['fid'], 'friends_add_friend' ) . '">' . __( 'Add Friend', 'buddypress' ) . '</a>';
|
|
}
|
|
} else if ( 'not_friends' == BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) {
|
|
|
|
check_ajax_referer('friends_add_friend');
|
|
|
|
if ( !friends_add_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) {
|
|
echo __("Friendship could not be requested.", 'buddypress');
|
|
} else {
|
|
echo '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '" class="requested">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';
|
|
}
|
|
} else {
|
|
echo __( 'Request Pending', 'buddypress' );
|
|
}
|
|
|
|
return false;
|
|
}
|
|
add_action( 'wp_ajax_addremove_friend', 'friends_ajax_addremove_friend' );
|
|
|
|
?>
|