Ejemplo n.º 1
0
function bp_get_add_friend_button($potential_friend_id = 0, $friend_status = false)
{
    global $bp, $friends_template;
    if (empty($potential_friend_id)) {
        $potential_friend_id = bp_get_potential_friend_id($potential_friend_id);
    }
    $is_friend = bp_is_friend($potential_friend_id);
    if (empty($is_friend)) {
        return false;
    }
    switch ($is_friend) {
        case 'pending':
            $button = array('id' => 'pending', 'component' => 'friends', 'must_be_logged_in' => true, 'block_self' => true, 'wrapper_class' => 'friendship-button pending', 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 'link_href' => trailingslashit($bp->loggedin_user->domain . bp_get_friends_slug() . '/requests'), 'link_text' => __('Friendship Requested', 'buddypress'), 'link_title' => __('Friendship Requested', 'buddypress'), 'link_class' => 'friendship-button pending requested');
            break;
        case 'is_friend':
            $button = array('id' => 'is_friend', 'component' => 'friends', 'must_be_logged_in' => true, 'block_self' => false, 'wrapper_class' => 'friendship-button is_friend', 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 'link_href' => nxt_nonce_url($bp->loggedin_user->domain . bp_get_friends_slug() . '/remove-friend/' . $potential_friend_id . '/', 'friends_remove_friend'), 'link_text' => __('Cancel Friendship', 'buddypress'), 'link_title' => __('Cancel Friendship', 'buddypress'), 'link_id' => 'friend-' . $potential_friend_id, 'link_rel' => 'remove', 'link_class' => 'friendship-button is_friend remove');
            break;
        default:
            $button = array('id' => 'not_friends', 'component' => 'friends', 'must_be_logged_in' => true, 'block_self' => true, 'wrapper_class' => 'friendship-button not_friends', 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 'link_href' => nxt_nonce_url($bp->loggedin_user->domain . bp_get_friends_slug() . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend'), 'link_text' => __('Add Friend', 'buddypress'), 'link_title' => __('Add Friend', 'buddypress'), 'link_id' => 'friend-' . $potential_friend_id, 'link_rel' => 'add', 'link_class' => 'friendship-button not_friends add');
            break;
    }
    // Filter and return the HTML button
    return bp_get_button(apply_filters('bp_get_add_friend_button', $button));
}
Ejemplo n.º 2
0
/**
 * Create the Add Friend button.
 *
 * @param int  $potential_friend_id ID of the user to whom the button
 *                                  applies. Default: value of {@link bp_get_potential_friend_id()}.
 * @param bool $friend_status       Not currently used.
 * @return string HTML for the Add Friend button.
 */
function bp_get_add_friend_button($potential_friend_id = 0, $friend_status = false)
{
    if (empty($potential_friend_id)) {
        $potential_friend_id = bp_get_potential_friend_id($potential_friend_id);
    }
    $is_friend = bp_is_friend($potential_friend_id);
    if (empty($is_friend)) {
        return false;
    }
    switch ($is_friend) {
        case 'pending':
            $button = array('id' => 'pending', 'component' => 'friends', 'must_be_logged_in' => true, 'block_self' => true, 'wrapper_class' => 'friendship-button pending_friend', 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 'link_href' => wp_nonce_url(bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/cancel/' . $potential_friend_id . '/', 'friends_withdraw_friendship'), 'link_text' => __('Cancel Friendship Request', 'buddypress'), 'link_title' => __('Cancel Friendship Requested', 'buddypress'), 'link_id' => 'friend-' . $potential_friend_id, 'link_rel' => 'remove', 'link_class' => 'friendship-button pending_friend requested');
            break;
        case 'awaiting_response':
            $button = array('id' => 'awaiting_response', 'component' => 'friends', 'must_be_logged_in' => true, 'block_self' => true, 'wrapper_class' => 'friendship-button awaiting_response_friend', 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 'link_href' => bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/', 'link_text' => __('Friendship Requested', 'buddypress'), 'link_title' => __('Friendship Requested', 'buddypress'), 'link_id' => 'friend-' . $potential_friend_id, 'link_rel' => 'remove', 'link_class' => 'friendship-button awaiting_response_friend requested');
            break;
        case 'is_friend':
            $button = array('id' => 'is_friend', 'component' => 'friends', 'must_be_logged_in' => true, 'block_self' => false, 'wrapper_class' => 'friendship-button is_friend', 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 'link_href' => wp_nonce_url(bp_loggedin_user_domain() . bp_get_friends_slug() . '/remove-friend/' . $potential_friend_id . '/', 'friends_remove_friend'), 'link_text' => __('Cancel Friendship', 'buddypress'), 'link_title' => __('Cancel Friendship', 'buddypress'), 'link_id' => 'friend-' . $potential_friend_id, 'link_rel' => 'remove', 'link_class' => 'friendship-button is_friend remove');
            break;
        default:
            $button = array('id' => 'not_friends', 'component' => 'friends', 'must_be_logged_in' => true, 'block_self' => true, 'wrapper_class' => 'friendship-button not_friends', 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 'link_href' => wp_nonce_url(bp_loggedin_user_domain() . bp_get_friends_slug() . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend'), 'link_text' => __('Add Friend', 'buddypress'), 'link_title' => __('Add Friend', 'buddypress'), 'link_id' => 'friend-' . $potential_friend_id, 'link_rel' => 'add', 'link_class' => 'friendship-button not_friends add');
            break;
    }
    /**
     * Filters the HTML for the add friend button.
     *
     * @since 1.1.0
     *
     * @param string $button HTML markup for add friend button.
     */
    return bp_get_button(apply_filters('bp_get_add_friend_button', $button));
}
do_action('bp_member_header_actions');
$action_output = ob_get_contents();
ob_end_clean();
?>

                        <div id="main-button" class="<?php 
if (!empty($action_output)) {
    echo 'primary-btn';
}
?>
">
                        <?php 
if ($showing == "follows") {
    bp_follow_add_follow_button();
} elseif ($showing == "friends") {
    if (!bp_is_friend(bp_displayed_user_id())) {
        bp_add_friend_button();
    } elseif (bp_is_active('messages')) {
        bp_send_private_message_button();
    } else {
        bp_send_public_message_button();
    }
} else {
    bp_send_public_message_button();
}
?>
                        </div>
			
                        <?php 
if (!empty($action_output)) {
    //only show if output exists