コード例 #1
0
 /**
  * @expectedIncorrectUsage bp_nav
  */
 public function test_should_remove_nav_item()
 {
     $bp = buddypress();
     $_bp_nav = $bp->bp_nav;
     $_bp_options_nav = $bp->bp_options_nav;
     bp_core_new_nav_item(array('name' => 'Foo', 'slug' => 'foo', 'screen_function' => 'foo'));
     $this->assertTrue(isset($bp->bp_nav['foo']));
     bp_core_remove_nav_item('foo');
     $this->assertFalse(isset($bp->bp_nav['foo']));
     $bp->bp_nav = $_bp_nav;
     $bp->bp_options_nav = $_bp_options_nav;
 }
コード例 #2
0
function bp_remove_nav_tabs()
{
    global $bp;
    if (!current_user_can('access_s2member_level1')) {
        bp_core_remove_nav_item('activity');
        bp_core_remove_nav_item('friends');
        bp_core_remove_nav_item('groups');
        bp_core_remove_nav_item('products');
        if (isset($bp->groups->current_group->slug) && $bp->groups->current_group->slug == $bp->current_item) {
            $bp->bp_options_nav[$bp->groups->current_group->slug]['home'] = false;
        }
    }
}
コード例 #3
0
ファイル: bp-custom.php プロジェクト: inetbiz/wordpress-lms
function vibe_bp_hide_tabs()
{
    $flag = 1;
    $hide = vibe_get_option('activity_tab');
    if (isset($hide)) {
        $flag = 0;
        switch ($hide) {
            case 1:
                if (is_user_logged_in()) {
                    $flag = 1;
                }
                break;
            case 2:
                if (current_user_can('edit_posts')) {
                    $flag = 1;
                }
                break;
            case 3:
                if (current_user_can('manage_options')) {
                    $flag = 1;
                }
                break;
            case 0:
                $flag = 1;
                break;
        }
    }
    if (!$flag && bp_is_active('groups') && !bp_is_my_profile()) {
        bp_core_remove_nav_item('activity');
    }
    $flag = 1;
    $hide = vibe_get_option('groups_tab');
    if (isset($hide)) {
        $flag = 0;
        switch ($hide) {
            case 1:
                if (is_user_logged_in()) {
                    $flag = 1;
                }
                break;
            case 2:
                if (current_user_can('edit_posts')) {
                    $flag = 1;
                }
                break;
            case 3:
                if (current_user_can('manage_options')) {
                    $flag = 1;
                }
                break;
            case 0:
                $flag = 1;
                break;
        }
    }
    if (!$flag && bp_is_active('groups') && !bp_is_my_profile()) {
        bp_core_remove_nav_item('groups');
    }
    $flag = 1;
    $hide = vibe_get_option('forums_tab');
    if (isset($hide)) {
        $flag = 0;
        switch ($hide) {
            case 1:
                if (is_user_logged_in()) {
                    $flag = 1;
                }
                break;
            case 2:
                if (current_user_can('edit_posts')) {
                    $flag = 1;
                }
                break;
            case 3:
                if (current_user_can('manage_options')) {
                    $flag = 1;
                }
                break;
            case 0:
                $flag = 1;
                break;
        }
    }
    if (!$flag && bp_is_active('groups') && !bp_is_my_profile()) {
        bp_core_remove_nav_item('forums');
    }
}
コード例 #4
0
ファイル: init.php プロジェクト: nikitansk/devschool
 function manage_access()
 {
     if (!bp_is_user() || bp_is_my_profile()) {
         return;
     }
     $check = $this->option('single_member_controls');
     $flag = 0;
     switch ($check) {
         case 1:
             if (!is_user_logged_in()) {
                 $flag = 1;
             }
             break;
         case 2:
             if (!current_user_can('edit_posts')) {
                 $flag = 1;
             }
             break;
         case 3:
             if (!current_user_can('manage_options')) {
                 $flag = 1;
             }
             break;
     }
     if ($flag) {
         //Disable all components
         global $bp;
         $components = $bp->loaded_components;
         unset($components['profile']);
         foreach ($components as $component => $enabled) {
             bp_core_remove_nav_item($component);
         }
         add_action('wp_footer', array($this, 'hide_bp_nav'));
     }
 }
コード例 #5
0
ファイル: functions.php プロジェクト: kosir/thatcamp-org
/**
 * Modify the user nav before it gets rendered, so we remove redundant items
 */
function thatcamp_mod_user_nav()
{
    global $bp;
    if (bp_is_active('xprofile')) {
        $bp->bp_nav['profile']['name'] = 'About';
        $bp->bp_nav['profile']['position'] = 5;
    }
    if (bp_is_active('activity')) {
        bp_core_remove_subnav_item('activity', 'mentions');
        bp_core_remove_subnav_item('activity', 'favorites');
        bp_core_remove_subnav_item('activity', 'friends');
        bp_core_remove_subnav_item('activity', 'camps');
    }
    if (bp_is_active('blogs')) {
        bp_core_remove_nav_item('blogs');
    }
    if (bp_is_active('groups')) {
        bp_core_remove_subnav_item('camps', 'invites');
    }
    /**
    	if ( bp_is_active( 'messages' ) ) {
    		bp_core_remove_nav_item( 'messages' );
    	}
    **/
    if (bp_is_active('settings') && is_user_logged_in()) {
        bp_core_remove_nav_item('settings');
    }
    // There's a baffling bug in BuddyPress that makes this necessary
    // I blame the Buddybar
    if (is_user_logged_in()) {
        $activity_base = trailingslashit(bp_displayed_user_domain() . bp_get_activity_slug());
    } else {
        $activity_base = bp_get_activity_slug() . '/';
    }
    $bp->bp_nav['blogs'] = array('name' => 'Blog Posts', 'slug' => 'blogs', 'link' => add_query_arg('a_type', 'blog_posts', $activity_base), 'css_id' => 'blogs', 'show_for_displayed_user' => true, 'position' => 70, 'screen_function' => 'bp_activity_screen_my_activity');
    $bp->bp_nav['comments'] = array('name' => 'Blog Comments', 'slug' => 'comments', 'link' => add_query_arg('a_type', 'blog_comments', $activity_base), 'css_id' => 'comments', 'show_for_displayed_user' => true, 'position' => 73, 'screen_function' => 'bp_activity_screen_my_activity');
    $bp->bp_nav['forums'] = array('name' => 'Forum Posts', 'slug' => 'forums', 'link' => add_query_arg('a_type', 'forums', $activity_base), 'css_id' => 'forums', 'show_for_displayed_user' => true, 'position' => 90, 'screen_function' => 'bp_activity_screen_my_activity');
    $bp->bp_nav['favorites'] = array('name' => 'Favorites', 'slug' => 'favorites', 'link' => add_query_arg('a_type', 'favorites', $activity_base), 'css_id' => 'favorites', 'show_for_displayed_user' => false, 'position' => 100, 'screen_function' => 'bp_activity_screen_my_activity');
    $bp->bp_nav[bp_get_groups_slug()]['name'] = str_replace('Groups', 'Camps', $bp->bp_nav[bp_get_groups_slug()]['name']);
    // Cheating: Put Camps before Friends
    if (isset($bp->bp_nav[bp_get_groups_slug()])) {
        $bp->bp_nav[bp_get_groups_slug()]['position'] = 55;
    }
    // Correct the Edit My Profile link
    if (isset($bp->bp_options_nav['profile']['edit'])) {
        remove_filter('edit_profile_url', 'bp_members_edit_profile_url', 10, 3);
        $bp->bp_options_nav['profile']['edit']['link'] = get_edit_profile_url(get_current_user_id());
        add_filter('edit_profile_url', 'bp_members_edit_profile_url', 10, 3);
    }
}
コード例 #6
-1
function bpes_remove_xprofile_tabs()
{
    global $bp;
    if (get_option('forums-tab-remove') == true) {
        bp_core_remove_nav_item('forums');
    }
    if (get_option('activity-tab-remove') == true) {
        bp_core_remove_nav_item('activity');
    }
    if (get_option('groups-tab-remove') == true) {
        bp_core_remove_nav_item('groups');
    }
    if (get_option('settings-tab-remove') == true) {
        bp_core_remove_nav_item('settings');
    }
    if (get_option('friends-tab-remove') == true) {
        bp_core_remove_nav_item('friends');
    }
    if (get_option('messages-tab-remove') == true) {
        bp_core_remove_nav_item('messages');
    }
    if (get_option('profile-tab-remove') == true) {
        bp_core_remove_nav_item('profile');
    }
    if (get_option('disable-mentions') == true) {
        bp_core_remove_subnav_item($bp->activity->slug, 'mentions');
    }
}