Exemplo n.º 1
0
function bp_get_link_avatar($args = '', $link = null)
{
    global $links_template;
    if (!$link) {
        $link = $links_template->link;
    }
    $defaults = array('item_id' => $link->id);
    $new_args = wp_parse_args($args, $defaults);
    return apply_filters('bp_get_link_avatar', bp_links_fetch_avatar($new_args, $link));
}
Exemplo n.º 2
0
function bp_links_setup_nav()
{
    global $bp;
    // is links component?
    if (bp_is_links_component()) {
        // set some component defaults
        $bp->is_item_admin = false;
        $bp->is_single_item = false;
        $bp->links->current_link = false;
        // try to get link id of current action
        $link_id = BP_Links_Link::link_exists($bp->current_action);
        // have a link id?
        if ($link_id) {
            // this is a single link page.
            $bp->is_single_item = true;
            $bp->links->current_link = new BP_Links_Link($link_id, true);
            // determine if item admin
            if (bp_links_is_admin()) {
                $bp->is_item_admin = true;
            } else {
                $bp->is_item_admin = $bp->loggedin_user->id == $bp->links->current_link->user_id ? true : false;
            }
        }
    }
    /* Add 'Links' to the main navigation */
    $nav_item_name = sprintf(apply_filters('bp_links_nav_item_name', __('Links', 'buddypress-links') . '  <span>%d</span>'), bp_links_total_links_for_user());
    bp_core_new_nav_item(array('name' => $nav_item_name, 'slug' => bp_links_slug(), 'position' => BP_LINKS_NAV_POSITION, 'screen_function' => 'bp_links_screen_personal_links', 'default_subnav_slug' => 'my-links', 'item_css_id' => bp_links_id()));
    $links_link = $bp->loggedin_user->domain . bp_links_slug() . '/';
    /* Add the subnav items to the links nav item */
    $subnav_name_mylinks = apply_filters('bp_links_subnav_item_name_mylinks', __('My Links', 'buddypress-links'));
    bp_core_new_subnav_item(array('name' => $subnav_name_mylinks, 'slug' => 'my-links', 'parent_url' => $links_link, 'parent_slug' => bp_links_slug(), 'screen_function' => 'bp_links_screen_personal_links', 'position' => 10, 'item_css_id' => 'links-my-links'));
    if (bp_is_links_component()) {
        if (bp_is_my_profile() && !$bp->is_single_item) {
            $bp->bp_options_title = __('My Links', 'buddypress-links');
            $subnav_name_create = apply_filters('bp_links_subnav_item_name_create', __('Create', 'buddypress-links'));
            bp_core_new_subnav_item(array('name' => $subnav_name_create, 'slug' => 'create', 'parent_url' => $links_link, 'parent_slug' => bp_links_slug(), 'screen_function' => 'bp_links_screen_personal_links', 'position' => 20, 'item_css_id' => 'links-create'));
        } else {
            if (!bp_is_my_profile() && !$bp->is_single_item) {
                $bp->bp_options_avatar = bp_core_fetch_avatar(array('item_id' => $bp->displayed_user->id, 'type' => 'thumb'));
                $bp->bp_options_title = $bp->displayed_user->fullname;
            } else {
                if ($bp->is_single_item) {
                    // We are viewing a single link, so set up the
                    // link navigation menu using the $bp->links->current_link global.
                    /* When in a single link, the first action is bumped down one because of the
                       link name, so we need to adjust this and set the link name to current_item. */
                    $bp->current_item = bp_current_action();
                    $bp->current_action = bp_action_variable(0);
                    array_shift($bp->action_variables);
                    $bp->bp_options_title = $bp->links->current_link->name;
                    $bp->bp_options_avatar = bp_links_fetch_avatar(array('type' => 'thumb'), $bp->links->current_link);
                    $link_link = bp_get_link_permalink($bp->links->current_link) . '/';
                    $link_slug = bp_get_link_permalink_slug($bp->links->current_link);
                    /* New HIDDEN nav item */
                    $nav_name_single = apply_filters('bp_links_nav_item_name_single', __('Links', 'buddypress-links'));
                    bp_core_new_nav_item(array('name' => $nav_name_single, 'slug' => $link_slug, 'position' => -1, 'screen_function' => 'bp_links_screen_link_home', 'default_subnav_slug' => 'home', 'item_css_id' => bp_links_id()));
                    /* Add the "Home" subnav item, as this will always be present */
                    $subnav_name_home = apply_filters('bp_links_subnav_item_name_home', __('Home', 'buddypress-links'));
                    bp_core_new_subnav_item(array('name' => $subnav_name_home, 'slug' => 'home', 'parent_url' => $link_link, 'parent_slug' => $link_slug, 'screen_function' => 'bp_links_screen_link_home', 'position' => 10, 'item_css_id' => 'link-home'));
                    /* If the user is a link mod or more, then show the link admin nav item */
                    if ($bp->is_item_admin) {
                        $subnav_name_admin = apply_filters('bp_links_subnav_item_name_admin', __('Admin', 'buddypress-links'));
                        bp_core_new_subnav_item(array('name' => $subnav_name_admin, 'slug' => 'admin', 'parent_url' => $link_link, 'parent_slug' => $link_slug, 'screen_function' => 'bp_links_screen_link_admin', 'position' => 20, 'user_has_access' => $bp->is_item_admin, 'item_css_id' => 'link-admin'));
                    }
                }
            }
        }
    }
}