public function profile_tab_gifts() { global $bp; bp_core_new_nav_item(array('parent_url' => bp_loggedin_user_domain() . '/gifts/', 'parent_slug' => $bp->profile->slug, 'default_subnav_slug' => 'send_gift', 'show_for_displayed_user' => false, 'name' => 'Gifts', 'slug' => 'gifts', 'screen_function' => array($this, 'send_gift_posts'), 'position' => 40)); bp_core_new_subnav_item(array('name' => 'Send Gift', 'slug' => 'send_gift', 'show_for_displayed_user' => false, 'parent_url' => bp_loggedin_user_domain() . '/gifts/', 'parent_slug' => $bp->bp_nav['gifts']['slug'], 'position' => 10, 'screen_function' => array($this, 'send_gift_posts'))); bp_core_new_subnav_item(array('name' => 'Received Gift', 'slug' => 'received_gift', 'parent_url' => bp_loggedin_user_domain() . '/gifts/', 'parent_slug' => $bp->bp_nav['gifts']['slug'], 'position' => 10, 'screen_function' => array($this, 'received_gifts_posts'))); }
function bfox_bp_bible_study_setup_nav() { global $bp; $slug = BFOX_BIBLE_SLUG; $link = (!empty($bp->displayed_user->domain) ? $bp->displayed_user->domain : $bp->loggedin_user->domain) . $slug . '/'; bp_core_new_nav_item(array('name' => __('Bible Study', 'bfox'), 'slug' => $slug, 'position' => 21, 'show_for_displayed_user' => true, 'screen_function' => 'bfox_bp_bible_study_calendar_screen_view', 'default_subnav_slug' => 'calendar')); bp_core_new_subnav_item(array('name' => __('Calendar', 'bfox'), 'slug' => 'calendar', 'parent_slug' => $slug, 'parent_url' => $link, 'screen_function' => 'bfox_bp_bible_study_calendar_screen_view', 'position' => 130)); bp_core_new_subnav_item(array('name' => __('Scheduled Plans', 'bfox'), 'slug' => 'schedules', 'parent_slug' => $slug, 'parent_url' => $link, 'screen_function' => 'bfox_bp_bible_study_schedules_screen_view', 'position' => 130)); if ($slug == $bp->current_component && ('schedule' == $bp->current_action || 'delete-schedule' == $bp->current_action)) { $schedule = bfox_bp_schedule(BfoxReadingSchedule::schedule($bp->action_variables[0])); if ($schedule->id) { if ($schedule->is_user_member($bp->displayed_user->id)) { if ('schedule' == $bp->current_action) { bfox_bp_plans_reading_redirect($schedule, $bp->action_variables[1], $bp->action_variables[2]); $bp->current_action = "schedule/{$schedule->id}"; bp_core_new_subnav_item(array('name' => __('View Schedule', 'bfox'), 'slug' => $bp->current_action, 'parent_slug' => $slug, 'parent_url' => $link, 'screen_function' => 'bfox_bp_bible_study_edit_schedule_screen_view', 'position' => 130)); } elseif ('delete-schedule' == $bp->current_action) { $bp->current_action = "delete-schedule/{$schedule->id}"; bp_core_new_subnav_item(array('name' => __('Delete Schedule', 'bfox'), 'slug' => $bp->current_action, 'parent_slug' => $slug, 'parent_url' => $link, 'screen_function' => 'bfox_bp_bible_study_edit_schedule_screen_view', 'position' => 130)); } } else { bp_core_redirect($schedule->url()); } } else { bp_core_redirect($link); } } do_action('bfox_bp_bible_study_setup_nav', $slug, $link); }
/** * Setup profile / BuddyBar navigation. * * This function was moved from {@link BP_Follow_Component} in v1.3.0 due * to the users module being toggleable. * * @since 1.3.0 */ function bp_follow_user_setup_nav($main_nav = array(), $sub_nav = array()) { global $bp; // If we're in the admin area and we're using the WP toolbar, we don't need // to run the rest of this method if (defined('WP_NETWORK_ADMIN') && bp_use_wp_admin_bar()) { return; } // Need to change the user ID, so if we're not on a member page, $counts variable is still calculated $user_id = bp_is_user() ? bp_displayed_user_id() : bp_loggedin_user_id(); $counts = bp_follow_total_follow_counts(array('user_id' => $user_id)); // BuddyBar compatibility $domain = bp_displayed_user_domain() ? bp_displayed_user_domain() : bp_loggedin_user_domain(); /** FOLLOWERS NAV ************************************************/ bp_core_new_nav_item(array('name' => sprintf(__('Following <span>%d</span>', 'bp-follow'), $counts['following']), 'slug' => $bp->follow->following->slug, 'position' => $bp->follow->params['adminbar_myaccount_order'], 'screen_function' => 'bp_follow_screen_following', 'default_subnav_slug' => 'following', 'item_css_id' => 'members-following')); /** FOLLOWING NAV ************************************************/ bp_core_new_nav_item(array('name' => sprintf(__('Followers <span>%d</span>', 'bp-follow'), $counts['followers']), 'slug' => $bp->follow->followers->slug, 'position' => apply_filters('bp_follow_followers_nav_position', 62), 'screen_function' => 'bp_follow_screen_followers', 'default_subnav_slug' => 'followers', 'item_css_id' => 'members-followers')); /** ACTIVITY SUBNAV **********************************************/ // Add activity sub nav item if (bp_is_active('activity') && apply_filters('bp_follow_show_activity_subnav', true)) { bp_core_new_subnav_item(array('name' => _x('Following', 'Activity subnav tab', 'bp-follow'), 'slug' => constant('BP_FOLLOWING_SLUG'), 'parent_url' => trailingslashit($domain . bp_get_activity_slug()), 'parent_slug' => bp_get_activity_slug(), 'screen_function' => 'bp_follow_screen_activity_following', 'position' => 21, 'item_css_id' => 'activity-following')); } // BuddyBar compatibility add_action('bp_adminbar_menus', 'bp_follow_group_buddybar_items'); }
/** * bp_em_setup_nav() * * Sets up the user profile navigation items for the component. This adds the top level nav * item and all the sub level nav items to the navigation array. This is then * rendered in the template. */ function bp_em_setup_nav() { global $bp; $count = 0; /* Add 'Events' to the main user profile navigation */ bp_core_new_nav_item(array('name' => __('Events', 'bp-em'), 'slug' => $bp->events->slug, 'position' => 80, 'screen_function' => bp_is_my_profile() ? 'bp_em_my_events' : 'bp_em_events', 'default_subnav_slug' => bp_is_my_profile() ? 'my-events' : '')); $em_link = $bp->loggedin_user->domain . $bp->events->slug . '/'; /* Create two sub nav items for this component */ bp_core_new_subnav_item(array('name' => __('My Profile', 'dbem'), 'slug' => 'profile', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_events', 'position' => 10, 'user_has_access' => bp_is_my_profile())); bp_core_new_subnav_item(array('name' => __('Events I\'m Attending', 'dbem'), 'slug' => 'attending', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_attending', 'position' => 20, 'user_has_access' => bp_is_my_profile())); bp_core_new_subnav_item(array('name' => __('My Events', 'dbem'), 'slug' => 'my-events', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_events', 'position' => 30, 'user_has_access' => bp_is_my_profile())); bp_core_new_subnav_item(array('name' => __('My Locations', 'dbem'), 'slug' => 'my-locations', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_locations', 'position' => 40, 'user_has_access' => bp_is_my_profile())); bp_core_new_subnav_item(array('name' => __('My Event Bookings', 'dbem'), 'slug' => 'my-bookings', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_bookings', 'position' => 50, 'user_has_access' => bp_is_my_profile())); /* Add a nav item for this component under the settings nav item. */ bp_core_new_subnav_item(array('name' => __('Events', 'dbem'), 'slug' => 'group-events', 'parent_slug' => $bp->groups->slug, 'parent_url' => $bp->loggedin_user->domain . $bp->groups->slug . '/', 'screen_function' => 'bp_em_my_group_events', 'position' => 60, 'user_has_access' => bp_is_my_profile())); /* Add a nav item for this component under the settings nav item. */ bp_core_new_subnav_item(array('name' => __('Events', 'dbem'), 'slug' => 'events-settings', 'parent_slug' => $bp->settings->slug, 'parent_url' => $bp->loggedin_user->domain . $bp->settings->slug . '/', 'screen_function' => 'bp_em_screen_settings_menu', 'position' => 40, 'user_has_access' => bp_is_my_profile())); /* Create two sub nav items for this component */ $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/'; if ($bp->current_component == 'groups') { $count = EM_Events::count(array('group' => $bp->groups->current_group->id)); if (empty($count)) { $count = 0; } } bp_core_new_subnav_item(array('name' => sprintf(__('Events (%s)', 'dbem'), $count), 'slug' => 'events', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'bp_em_group_events', 'position' => 50, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'forums')); }
/** * Load Custom tabs on BuddyPress * * @global object $bp global BuddyPress object */ function custom_media_nav_tab() { global $bp; if (!function_exists("bp_core_new_nav_item")) { return; } if (bp_is_blog_page() || !bp_is_group() && !(isset($bp->displayed_user) && isset($bp->displayed_user->id)) || apply_filters('rtmedia_render_bp_nav', false)) { return; } global $rtmedia; if (function_exists("bp_is_group") && !bp_is_group()) { if (isset($bp->displayed_user) && isset($bp->displayed_user->id)) { $profile_counts = $this->actual_counts($bp->displayed_user->id); } $tab_position = apply_filters('rtmedia_media_tab_position', 99); if ($rtmedia->options["buddypress_enableOnProfile"] != 0) { bp_core_new_nav_item(array('name' => RTMEDIA_MEDIA_LABEL . '<span>' . $profile_counts['total']['all'] . '</span>', 'slug' => apply_filters('rtmedia_media_tab_slug', RTMEDIA_MEDIA_SLUG), 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all', 'position' => $tab_position)); } } if (bp_is_group() && $rtmedia->options["buddypress_enableOnGroup"] != 0) { global $bp; $media_enabled = true; //filter for rtMedia PRO for PER GROUP MEDIA enable/disable functionality $media_enabled = apply_filters('rtmedia_media_enabled_for_current_group', $media_enabled); // check if current user can view this group $current_group = groups_get_current_group(); $is_visible_to_current_user = $current_group->is_visible; if ($media_enabled && $is_visible_to_current_user) { $group_counts = $this->actual_counts($bp->groups->current_group->id, "group"); $bp->bp_options_nav[bp_get_current_group_slug()]['media'] = array('name' => RTMEDIA_MEDIA_LABEL . '<span>' . $group_counts['total']['all'] . '</span>', 'link' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/') . RTMEDIA_MEDIA_SLUG, 'slug' => RTMEDIA_MEDIA_SLUG, 'user_has_access' => true, 'css_id' => 'rtmedia-media-nav', 'position' => 99, 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all'); } } }
function bp_content_setup_nav() { global $bp; bp_core_new_nav_item(array('name' => __('My Posts', 'buddypress'), 'slug' => 'my-posts', 'screen_function' => 'my_posts_screen_link', 'position' => 40, 'default_subnav_slug' => 'my-posts-subnav')); bp_core_new_subnav_item(array('name' => __('', 'buddypress'), 'slug' => 'my-posts', 'parent_url' => trailingslashit(bp_loggedin_user_domain() . 'main-tab'), 'parent_slug' => 'my-posts', 'screen_function' => 'my_posts_screen_link', 'position' => 10)); do_action('bp_content_setup_nav'); }
public function test_should_trailingslash_link_when_link_is_autogenerated_not_using_slug() { bp_core_new_nav_item(array('name' => 'foo', 'slug' => 'foo-parent', 'link' => bp_get_root_domain() . 'foo-parent/', 'default_subnav_slug' => 'bar', 'screen_function' => 'foo')); bp_core_new_subnav_item(array('name' => 'bar', 'slug' => 'bar', 'parent_slug' => 'foo-parent', 'parent_url' => bp_get_root_domain() . 'foo-parent/', 'screen_function' => 'bar')); $expected = bp_get_root_domain() . 'foo-parent/'; $this->assertSame($expected, buddypress()->bp_options_nav['foo-parent']['bar']['link']); }
public function test_show_for_displayed_user_false_should_force_function_to_return_false_when_bp_user_has_access_is_also_false() { $args = array('name' => 'Foo', 'slug' => 'foo', 'show_for_displayed_user' => false); add_filter('bp_user_has_access', '__return_false'); $retval = bp_core_new_nav_item($args); remove_filter('bp_user_has_access', '__return_false'); $this->assertFalse($retval); }
function ec_bp_setup_nav() { global $bp; $events_link = $bp->displayed_user->domain . 'eventos/'; bp_core_new_nav_item(array('name' => 'Eventos', 'slug' => 'eventos', 'screen_function' => 'ec_show_events_list', 'position' => 0)); bp_core_new_subnav_item(array('name' => 'Eventos', 'slug' => 'mis-eventos', 'parent_url' => $events_link, 'parent_slug' => 'eventos', 'screen_function' => 'ec_show_events_list', 'position' => 10)); bp_core_new_subnav_item(array('name' => 'Calendario', 'slug' => 'mi-calendario', 'parent_url' => $events_link, 'parent_slug' => 'eventos', 'screen_function' => 'ec_show_events_calendar', 'position' => 20)); bp_core_new_subnav_item(array('name' => 'Crear Evento', 'slug' => 'evento_nuevo', 'parent_url' => $events_link, 'parent_slug' => 'eventos', 'screen_function' => 'ec_show_events_editor', 'user_has_access' => bp_is_my_profile(), 'position' => 30)); }
public function content_setup_nav() { global $bp; if (!ap_opt('disable_reputation')) { bp_core_new_nav_item(array('name' => __('Reputation', 'anspress-question-answer'), 'slug' => 'reputation', 'screen_function' => array($this, 'reputation_screen_link'), 'position' => 30, 'default_subnav_slug' => 'my-posts-subnav')); } bp_core_new_nav_item(array('name' => sprintf(__('Questions %s', 'anspress-question-answer'), '<span class="count">' . count_user_posts(bp_displayed_user_id(), 'question') . '</span>'), 'slug' => 'questions', 'screen_function' => array($this, 'questions_screen_link'), 'position' => 40, 'default_subnav_slug' => 'my-posts-subnav')); bp_core_new_nav_item(array('name' => sprintf(__('Answers %s', 'anspress-question-answer'), '<span class="count">' . count_user_posts(bp_displayed_user_id(), 'answer') . '</span>'), 'slug' => 'answers', 'screen_function' => array($this, 'answers_screen_link'), 'position' => 40, 'default_subnav_slug' => 'my-posts-subnav')); }
function setup_nav() { global $bp; $access = 0; if (function_exists('bp_is_my_profile')) { $access = apply_filters('wplms_student_dashboard_access', bp_is_my_profile()); } bp_core_new_nav_item(array('name' => __('Dashboard', 'wplms-dashboard'), 'slug' => WPLMS_DASHBOARD_SLUG, 'position' => 4, 'screen_function' => 'wplms_dashboard_template', 'show_for_displayed_user' => $access)); }
function my_bp_nav_adder() { global $bp; if (get_theme_mod('show-playlist')) { bp_core_new_nav_item(array('name' => __('Paylists', 'musik'), 'slug' => 'playlists', 'position' => 1, 'screen_function' => 'Playlistsdisplay', 'default_subnav_slug' => 'playlists', 'parent_url' => $bp->loggedin_user->domain . $bp->slug . '/', 'parent_slug' => $bp->slug)); } if (get_theme_mod('show-likes')) { bp_core_new_nav_item(array('name' => __('Likes', 'musik'), 'slug' => 'likes', 'position' => 1, 'screen_function' => 'Likesdisplay', 'default_subnav_slug' => 'likes', 'parent_url' => $bp->loggedin_user->domain . $bp->slug . '/', 'parent_slug' => $bp->slug)); } }
/** * Add albums page for network albums (grouped) */ function buddystream_profile_navigation() { global $bp; if (get_site_option('buddystream_social_albums') == "on") { if (get_site_option('buddystream_social_albums_profile_navigation') == "on") { bp_core_new_subnav_item(array('name' => __('Social albums', 'buddystream_lang'), 'slug' => 'social-album', 'parent_url' => $bp->displayed_user->domain . $bp->profile->slug . '/', 'parent_slug' => $bp->profile->slug, 'screen_function' => 'buddystream_default_album', 'position' => 80)); } else { bp_core_new_nav_item(array('name' => __('Social albums', 'buddystream_lang'), 'slug' => 'social-album', 'position' => 12, 'default_subnav_slug' => 'albums', 'screen_function' => 'buddystream_default_album')); } } }
function add_bp_profile_entry() { global $bp; bp_core_new_nav_item(array('name' => __('Events', Eab_EventsHub::TEXT_DOMAIN), 'slug' => 'my-events', 'show_for_displayed_user' => true, 'default_subnav_slug' => $this->_check_permissions() ? 'organized' : 'attending', 'screen_function' => '__return_false')); if ($this->_check_permissions()) { bp_core_new_subnav_item(array('name' => __('Organized', Eab_EventsHub::TEXT_DOMAIN), 'slug' => 'organized', 'parent_url' => $bp->displayed_user->domain . 'my-events' . '/', 'parent_slug' => 'my-events', 'screen_function' => array($this, 'bind_bp_organized_page'))); } bp_core_new_subnav_item(array('name' => __('Attending', Eab_EventsHub::TEXT_DOMAIN), 'slug' => 'attending', 'parent_url' => $bp->displayed_user->domain . 'my-events' . '/', 'parent_slug' => 'my-events', 'screen_function' => array($this, 'bind_bp_attending_page'))); bp_core_new_subnav_item(array('name' => __('Maybe', Eab_EventsHub::TEXT_DOMAIN), 'slug' => 'mabe', 'parent_url' => $bp->displayed_user->domain . 'my-events' . '/', 'parent_slug' => 'my-events', 'screen_function' => array($this, 'bind_bp_maybe_page'))); bp_core_new_subnav_item(array('name' => __('Not Attending', Eab_EventsHub::TEXT_DOMAIN), 'slug' => 'not-attending', 'parent_url' => $bp->displayed_user->domain . 'my-events' . '/', 'parent_slug' => 'my-events', 'screen_function' => array($this, 'bind_bp_not_attending_page'))); do_action('eab-events-my_events-set_up_navigation'); }
/** * bp_media_galleries_setup_nav() * * Sets up the user profile navigation items for the component. This adds the top level nav * item and all the sub level nav items to the navigation array. This is then * rendered in the template. */ function bp_media_galleries_setup_nav() { global $bp; /* Add 'Example' to the main user profile navigation */ bp_core_new_nav_item(array('name' => __('Media Galleries', 'bp-media-galleries'), 'slug' => $bp->media_galleries->slug, 'position' => 80, 'screen_function' => 'bp_media_galleries_view', 'default_subnav_slug' => 'view')); $media_galleries_link = $bp->loggedin_user->domain . $bp->media_galleries->slug . '/'; bp_core_new_subnav_item(array('name' => __('Create Gallery', 'bp-media-galleries'), 'slug' => 'create', 'parent_slug' => $bp->media_galleries->slug, 'parent_url' => $media_galleries_link, 'screen_function' => 'bp_media_galleries_create', 'position' => 10, 'user_has_access' => bp_is_home())); bp_core_new_subnav_item(array('name' => __('Upload Audio', 'bp-media-galleries'), 'slug' => 'upload-audio', 'parent_slug' => $bp->media_galleries->slug, 'parent_url' => $media_galleries_link, 'screen_function' => 'bp_media_galleries_upload_audio', 'position' => 20, 'user_has_access' => bp_is_home())); bp_core_new_subnav_item(array('name' => __('Upload Images', 'bp-media-galleries'), 'slug' => 'upload-images', 'parent_slug' => $bp->media_galleries->slug, 'parent_url' => $media_galleries_link, 'screen_function' => 'bp_media_galleries_upload_images', 'position' => 30, 'user_has_access' => bp_is_home())); bp_core_new_subnav_item(array('name' => __('Upload Videos', 'bp-media-galleries'), 'slug' => 'upload-video', 'parent_slug' => $bp->media_galleries->slug, 'parent_url' => $media_galleries_link, 'screen_function' => 'bp_media_galleries_upload_video', 'position' => 40, 'user_has_access' => bp_is_home())); /* Add a nav item for this component under the settings nav item. See bp_example_screen_settings_menu() for more info */ bp_core_new_subnav_item(array('name' => __('Media Galleries', 'bp-media-galleries'), 'slug' => 'media-galleries-admin', 'parent_slug' => $bp->settings->slug, 'parent_url' => $bp->loggedin_user->domain . $bp->settings->slug . '/', 'screen_function' => 'bp_media_galleries_screen_settings_menu', 'position' => 40, 'user_has_access' => bp_is_my_profile())); }
/** * @expectedIncorrectUsage bp_nav */ public function test_should_fail_on_incorrect_parent() { $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')); bp_core_new_subnav_item(array('name' => 'Bar', 'slug' => 'bar', 'parent_slug' => 'foo', 'parent_url' => 'foo', 'screen_function' => 'bar')); $this->assertTrue(isset($bp->bp_options_nav['foo']['bar'])); bp_core_remove_subnav_item('bad-parent', 'bar'); $this->assertTrue(isset($bp->bp_options_nav['foo']['bar'])); $bp->bp_nav = $_bp_nav; $bp->bp_options_nav = $_bp_options_nav; }
/** * Load Custom tabs on BuddyPress * * @global object $bp global BuddyPress object */ function custom_media_nav_tab() { $bp = buddypress(); if (!function_exists('bp_core_new_nav_item')) { return; } if (bp_is_blog_page() || !bp_is_group() && !(isset($bp->displayed_user) && isset($bp->displayed_user->id)) || apply_filters('rtmedia_render_bp_nav', false)) { return; } global $rtmedia; if (function_exists('bp_is_group') && !bp_is_group()) { if (isset($bp->displayed_user) && isset($bp->displayed_user->id)) { $profile_counts = $this->actual_counts($bp->displayed_user->id); } $tab_position = apply_filters('rtmedia_media_tab_position', 99); if (0 !== intval($rtmedia->options['buddypress_enableOnProfile'])) { bp_core_new_nav_item(array('name' => RTMEDIA_MEDIA_LABEL . ' <span>' . $profile_counts['total']['all'] . '</span>', 'slug' => apply_filters('rtmedia_media_tab_slug', RTMEDIA_MEDIA_SLUG), 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all', 'position' => $tab_position)); } } if (bp_is_group() && 0 !== intval($rtmedia->options['buddypress_enableOnGroup'])) { $media_enabled = true; //filter for rtMedia PRO for PER GROUP MEDIA enable/disable functionality $media_enabled = apply_filters('rtmedia_media_enabled_for_current_group', $media_enabled); // check if current user can view this group $current_group = groups_get_current_group(); /** * remove `$current_group->is_visible` and add `bp_group_is_visible( $current_group )` * reason : In Buddypress 2.7 `is_visible` return false so we can't display `media` tab on group * issue id : http://git.rtcamp.com/rtmedia/rtMedia/issues/119 */ // $is_visible_to_current_user = $current_group->is_visible; $is_visible_to_current_user = bp_group_is_visible($current_group); if ($media_enabled && $is_visible_to_current_user) { $group_counts = $this->actual_counts($bp->groups->current_group->id, 'group'); $slug = apply_filters('rtmedia_group_media_tab_slug', RTMEDIA_MEDIA_SLUG); if (isset($bp->version) && $bp->version > '2.5.3') { /* * As from BuddyPress 2.6, you can't access $bp->bp_options_nav directly. * Use `bp_core_new_subnav_item` to add subnav item. * * Check https://buddypress.trac.wordpress.org/ticket/6534 and https://buddypress.trac.wordpress.org/changeset/10745 * for more details */ bp_core_new_subnav_item(array('name' => RTMEDIA_MEDIA_LABEL . ' <span>' . $group_counts['total']['all'] . '</span>', 'link' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/') . $slug, 'slug' => $slug, 'parent_slug' => bp_get_current_group_slug(), 'parent_url' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/'), 'user_has_access' => true, 'css_id' => 'rtmedia-media-nav', 'position' => 99, 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all')); } else { $bp->bp_options_nav[bp_get_current_group_slug()]['media'] = array('name' => RTMEDIA_MEDIA_LABEL . ' <span>' . $group_counts['total']['all'] . '</span>', 'link' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/') . $slug, 'slug' => $slug, 'user_has_access' => true, 'css_id' => 'rtmedia-media-nav', 'position' => 99, 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all'); } } } }
/** * @ticket BP7203 */ public function test_remove_subnav_item_array_as_screen_function() { $bp = buddypress(); add_filter('bp_is_active', array($this, 'foo_is_active'), 10, 2); $bp->foo = new stdClass(); $bp->foo->nav = new BP_Core_Nav(0); $expected = array('foo', 'bar'); bp_core_new_nav_item(array('name' => 'Foo', 'slug' => 'foo', 'screen_function' => $expected), 'foo'); bp_core_new_subnav_item(array('name' => 'Bar', 'slug' => 'bar', 'parent_slug' => 'foo', 'parent_url' => 'foo', 'screen_function' => $expected), 'foo'); remove_filter('bp_is_active', array($this, 'foo_is_active'), 10); $this->assertNotEmpty($bp->foo->nav->get_primary(array('slug' => 'foo'), false)); $tested = $bp->foo->nav->delete_nav('foo'); $this->assertSame($expected, reset($tested)); $this->assertEmpty($bp->foo->nav->get_primary(array('slug' => 'foo'), false)); }
/** * @group bp_core_sort_nav_items */ public function test_bp_core_sort_nav_items() { $bp_nav = buddypress()->bp_nav; $u = $this->factory->user->create(); $old_current_user = get_current_user_id(); $this->set_current_user($u); $this->go_to(bp_core_get_user_domain($u)); bp_core_new_nav_item(array('name' => 'Foo', 'slug' => 'foo', 'position' => 25, 'screen_function' => 'foo_screen_function', 'default_subnav_slug' => 'foo-sub')); $expected = array('name' => 'Foo', 'slug' => 'foo', 'link' => trailingslashit(bp_core_get_user_domain($u) . 'foo'), 'css_id' => 'foo', 'show_for_displayed_user' => true, 'position' => 25, 'screen_function' => 'foo_screen_function', 'default_subnav_slug' => 'foo-sub'); bp_core_sort_nav_items(); $this->assertSame(buddypress()->bp_nav[25], $expected); // Clean up buddypress()->bp_nav = $bp_nav; $this->set_current_user($old_current_user); }
function bebop_setup_user_nav() { global $bp; $should_users_verify_content = bebop_tables::get_option_value('bebop_content_user_verification'); //Shows in the profile all the time. bp_core_new_nav_item(array('name' => __('Resources', 'bebop'), 'slug' => 'bebop', 'position' => 30, 'show_for_displayed_user' => true, 'screen_function' => 'bebop_user_settings', 'default_subnav_slug' => 'bebop-content')); bp_core_new_subnav_item(array('name' => __('Content', 'bebop'), 'slug' => 'bebop-content', 'parent_url' => bp_displayed_user_domain() . 'bebop/', 'parent_slug' => 'bebop', 'screen_function' => 'bebop_user_settings', 'position' => 10)); //only show if current user is the owner of the profile. if (bp_is_my_profile()) { if ($should_users_verify_content != 'no') { bp_core_new_subnav_item(array('name' => __('Content Manager', 'bebop'), 'slug' => 'bebop-manager', 'parent_url' => $bp->loggedin_user->domain . 'bebop/', 'parent_slug' => 'bebop', 'screen_function' => 'bebop_user_settings', 'position' => 20)); } bp_core_new_subnav_item(array('name' => __('Accounts', 'bebop'), 'slug' => 'bebop-accounts', 'parent_url' => $bp->loggedin_user->domain . 'bebop/', 'parent_slug' => 'bebop', 'screen_function' => 'bebop_user_settings', 'position' => 20)); } }
/** * Create a tab on member profile pages */ public function profile_tab() { // Determine user to use if (bp_displayed_user_domain()) { $user_domain = bp_displayed_user_domain(); } elseif (bp_loggedin_user_domain()) { $user_domain = bp_loggedin_user_domain(); } else { return; } $parent_url = trailingslashit($user_domain . $this->slug); $nav_text = __('Papers', 'social-paper'); // create primary nav bp_core_new_nav_item(array('name' => $nav_text, 'slug' => $this->slug, 'item_css_id' => 'user-papers', 'show_for_displayed_user' => true, 'site_admin_only' => false, 'position' => $this->position, 'screen_function' => 'cacsp_profile_screen', 'default_subnav_slug' => $this->published_slug)); // create subnav items bp_core_new_subnav_item(array('name' => __('Published', 'social-paper'), 'slug' => $this->published_slug, 'parent_url' => $parent_url, 'parent_slug' => $this->slug, 'screen_function' => 'cacsp_profile_screen_published', 'position' => 10)); bp_core_new_subnav_item(array('name' => __('Drafts', 'social-paper'), 'slug' => $this->drafts_slug, 'parent_url' => $parent_url, 'parent_slug' => $this->slug, 'screen_function' => 'cacsp_profile_screen_draft', 'position' => 10, 'user_has_access' => bp_core_can_edit_settings())); }
function mtc_setup_nav() { global $bp; /* Add 'My Content' to the main user profile navigation */ bp_core_new_nav_item(array('name' => __('My Content', 'bp-mtc'), 'slug' => $bp->mtc->slug, 'position' => 80, 'screen_function' => 'bp_mtc_screen_one', 'default_subnav_slug' => 'Content')); $mtc_link = $bp->loggedin_user->domain . $bp->mtc->slug . '/'; /* Create two sub nav items for this component */ bp_core_new_subnav_item(array('name' => __('Content', 'bp-mtc'), 'slug' => 'my-content', 'parent_slug' => $bp->mtc->slug, 'parent_url' => $mtc_link, 'screen_function' => 'bp_mtc_screen_one', 'position' => 10)); bp_core_new_subnav_item(array('name' => __('Select Tags', 'bp-mtc'), 'slug' => 'select-tags', 'parent_slug' => $bp->mtc->slug, 'parent_url' => $mtc_link, 'screen_function' => 'bp_mtc_screen_two', 'position' => 20, 'user_has_access' => bp_is_my_profile())); /* Add a nav item for this component under the settings nav item. See bp_example_screen_settings_menu() for more info */ /* bp_core_new_subnav_item( array( 'name' => __( 'Example', 'mtc' ), 'slug' => 'example-admin', 'parent_slug' => $bp->settings->slug, 'parent_url' => $bp->loggedin_user->domain . $bp->settings->slug . '/', 'screen_function' => 'bp_example_screen_settings_menu', 'position' => 40, 'user_has_access' => bp_is_my_profile() // Only the logged in user can access this on his/her profile ) );*/ }
public function test_user_has_access_false_user_logged_in_others_profile_default_component_not_accessible() { $u1 = $this->factory->user->create(); $u2 = $this->factory->user->create(); $old_current_user = get_current_user_id(); $this->set_current_user($u1); $this->go_to(bp_core_get_user_domain($u2)); $old_bp_nav = buddypress()->bp_nav; $old_default_component = buddypress()->default_component; buddypress()->default_component = 'foo'; bp_core_new_nav_item(array('slug' => 'foo', 'name' => 'Foo', 'screen_function' => 'foo', 'default_subnav_item' => 'bar', 'show_for_displayed_user' => false)); $subnav_item = array('user_has_access' => false); // Just test relevant info $found = bp_core_maybe_hook_new_subnav_screen_function($subnav_item); // Clean up $this->set_current_user($old_current_user); buddypress()->default_component = $old_default_component; buddypress()->bp_nav = $old_bp_nav; $this->assertSame('failure', $found['status']); $this->assertSame(bp_core_get_user_domain($u2) . bp_get_activity_slug() . '/', $found['redirect_args']['root']); }
function bp_core_add_settings_nav() { global $bp; /* Set up settings as a sudo-component for identification and nav selection */ $bp->settings->id = 'settings'; $bp->settings->slug = BP_SETTINGS_SLUG; /* Register this in the active components array */ $bp->active_components[$bp->settings->slug] = $bp->settings->id; /* Add the settings navigation item */ bp_core_new_nav_item( array( 'name' => __('Settings', 'buddypress'), 'slug' => $bp->settings->slug, 'position' => 100, 'show_for_displayed_user' => false, 'screen_function' => 'bp_core_screen_general_settings', 'default_subnav_slug' => 'general' ) ); $settings_link = $bp->loggedin_user->domain . $bp->settings->slug . '/'; bp_core_new_subnav_item( array( 'name' => __( 'General', 'buddypress' ), 'slug' => 'general', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_general_settings', 'position' => 10, 'user_has_access' => bp_is_my_profile() ) ); bp_core_new_subnav_item( array( 'name' => __( 'Notifications', 'buddypress' ), 'slug' => 'notifications', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_notification_settings', 'position' => 20, 'user_has_access' => bp_is_my_profile() ) ); if ( !is_super_admin() && !(int) $bp->site_options['bp-disable-account-deletion'] ) bp_core_new_subnav_item( array( 'name' => __( 'Delete Account', 'buddypress' ), 'slug' => 'delete-account', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_delete_account', 'position' => 90, 'user_has_access' => bp_is_my_profile() ) ); }
function intention_profile_menu() { global $wpdb, $bp; $displayed_user_id = $bp->displayed_user->id; $posts_table = $wpdb->prefix . "posts"; $intentions_table = $wpdb->prefix . "intentions"; $sql = "SELECT COUNT(*) as intention_count FROM {$posts_table} WHERE post_author = %d AND post_status='publish' AND post_type='post'"; $sql = $wpdb->prepare($sql, $displayed_user_id); $intentions_cnt = $wpdb->get_var($sql); $meditonsql = "SELECT {$posts_table}.* \r\n FROM {$posts_table} LEFT JOIN {$intentions_table} ON {$posts_table}.ID={$intentions_table}.intention_id \r\n WHERE {$intentions_table}.meditater_id = %d AND {$posts_table}.post_status='publish' AND {$posts_table}.post_type='post' \r\n GROUP BY {$posts_table}.ID ORDER BY {$posts_table}.post_date DESC"; $meditonsql = $wpdb->prepare($meditonsql, $displayed_user_id); $wpdb->get_results($meditonsql); $mediton_cnt = $wpdb->num_rows; $meditotalsql = "SELECT SUM(total_mins) FROM {$intentions_table} WHERE meditater_id = %d"; $meditotalsql = $wpdb->prepare($meditotalsql, $displayed_user_id); $meditime_sum = secns_to_human($wpdb->get_var($meditotalsql)); bp_core_new_nav_item(array('name' => sprintf('Intentions <span>%d</span>', $intentions_cnt), 'slug' => 'intentions', 'position' => 40, 'screen_function' => 'intentions_user_grid', 'default_subnav_slug' => 'summary')); $parent_url = $bp->displayed_user->domain . 'intentions/'; bp_core_new_subnav_item(array('name' => 'Summary', 'slug' => 'summary', 'parent_slug' => 'intentions', 'parent_url' => $parent_url, 'screen_function' => 'intentions_user_grid', 'position' => 10)); bp_core_new_subnav_item(array('name' => sprintf('Intentions Set <span class="cnt">%d</span>', $intentions_cnt), 'slug' => 'wishes', 'parent_slug' => 'intentions', 'parent_url' => $parent_url, 'screen_function' => 'intentions_user_grid', 'position' => 20)); bp_core_new_subnav_item(array('name' => sprintf('Intentions Meditated On <span class="cnt">%d</span>', $mediton_cnt), 'slug' => 'mediton', 'parent_slug' => 'intentions', 'parent_url' => $parent_url, 'screen_function' => 'intentions_user_grid', 'position' => 30)); }
/** * Add BuddyPress navigation. * * @return void **/ function add_navigation() { global $bp; /* Set up directory as a sudo-component for identification and nav selection */ $directory_page = get_page($this->directory_page_id); if (!@is_object($bp->directory)) { $bp->directory = new stdClass(); } $bp->directory->slug = $directory_page->post_name; /* Construct URL to the BuddyPress profile URL */ $user_domain = !empty($bp->displayed_user->domain) ? $bp->displayed_user->domain : $bp->loggedin_user->domain; $parent_url = $user_domain . $bp->directory->slug . '/'; /* Add the settings navigation item */ if (0 < $directory_page->ID) { $nav_title = $directory_page->post_title; } else { $nav_title = 'Directory'; } bp_core_new_nav_item(array('name' => __($nav_title, $this->text_domain), 'slug' => $bp->directory->slug, 'position' => 100, 'show_for_displayed_user' => true, 'screen_function' => array(&$this, 'load_template'))); if (bp_is_my_profile()) { $directory_page = get_page($this->my_listings_page_id); if (0 < $directory_page->ID) { $nav_title = $directory_page->post_title; } else { $nav_title = 'My Directory'; } bp_core_new_subnav_item(array('name' => __($nav_title, $this->text_domain), 'slug' => $directory_page->post_name, 'parent_url' => $parent_url, 'parent_slug' => $bp->directory->slug, 'screen_function' => array(&$this, 'load_template'), 'position' => 10, 'user_has_access' => true)); if ($this->use_credits && !$this->is_full_access()) { bp_core_new_subnav_item(array('name' => __('My Credits', $this->text_domain), 'slug' => 'my-credits', 'parent_url' => $parent_url, 'parent_slug' => $bp->directory->slug, 'screen_function' => array(&$this, 'load_template'), 'position' => 10, 'user_has_access' => true)); } if (current_user_can('create_listings')) { bp_core_new_subnav_item(array('name' => __('Add Listing', $this->text_domain), 'slug' => 'add-listing', 'parent_url' => $parent_url, 'parent_slug' => $bp->directory->slug, 'screen_function' => array(&$this, 'load_template'), 'position' => 10, 'user_has_access' => true)); } } else { //display author classifids page bp_core_new_subnav_item(array('name' => __('All', $this->text_domain), 'slug' => 'all', 'parent_url' => $parent_url, 'parent_slug' => $bp->directory->slug, 'screen_function' => array(&$this, 'load_template'), 'position' => 10, 'user_has_access' => true)); } }
function friends_setup_nav() { global $bp; /* Add 'Friends' to the main navigation */ bp_core_new_nav_item( array( 'name' => sprintf( __( 'Friends <span>(%d)</span>', 'buddypress' ), friends_get_total_friend_count() ), 'slug' => $bp->friends->slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $bp->friends->id ) ); $friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/'; /* Add the subnav items to the friends nav item */ bp_core_new_subnav_item( array( 'name' => __( 'My Friends', 'buddypress' ), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id' => 'friends-my-friends' ) ); bp_core_new_subnav_item( array( 'name' => __( 'Requests', 'buddypress' ), 'slug' => 'requests', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_requests', 'position' => 20, 'user_has_access' => bp_is_my_profile() ) ); if ( $bp->current_component == $bp->friends->slug ) { if ( bp_is_my_profile() ) { $bp->bp_options_title = __( 'My Friends', 'buddypress' ); } else { $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; } } do_action( 'friends_setup_nav' ); }
/** * Setup Navigation * @since 0.1 * @version 1.3.2 */ public function setup_nav() { global $bp; $user_id = bp_displayed_user_id(); // User is excluded if ($this->core->exclude_user($user_id) || $this->buddypress['history_location'] == '') { return; } // If visibility is not set for visitors if (!is_user_logged_in() && !$this->buddypress['visibility']['history']) { return; } // Admins always see the token history if (!$this->core->can_edit_plugin() && $this->buddypress['history_location'] != 'top') { return; } // Show admins if ($this->core->can_edit_plugin()) { $show = true; } else { $show = $this->buddypress['visibility']['history']; } // Top Level Nav Item $me = str_replace('%label%', $this->point_types[$this->selected_type], $this->buddypress['history_menu_title']['me']); $others = str_replace('%label%', $this->point_types[$this->selected_type], $this->buddypress['history_menu_title']['others']); $top_name = bp_word_or_name($me, $others, false, false); bp_core_new_nav_item(array('name' => $this->core->template_tags_general($top_name), 'slug' => $this->buddypress['history_url'], 'parent_url' => $bp->displayed_user->domain, 'default_subnav_slug' => $this->buddypress['history_url'], 'screen_function' => array($this, 'my_history'), 'show_for_displayed_user' => $show, 'position' => $this->buddypress['history_menu_pos'])); // Date Sorting $date_sorting = apply_filters('mycred_sort_by_time', array('' => __('All', 'mycred'), 'today' => __('Today', 'mycred'), 'yesterday' => __('Yesterday', 'mycred'), 'thisweek' => __('This Week', 'mycred'), 'thismonth' => __('This Month', 'mycred'))); $ctype = '/'; if ($this->selected_type != 'mycred_default') { $ctype .= esc_url(add_query_arg(array('show-ctype' => $this->selected_type))); } // "All" is default bp_core_new_subnav_item(array('name' => __('All', 'mycred'), 'slug' => $this->buddypress['history_url'], 'parent_url' => $bp->displayed_user->domain . $this->buddypress['history_url'] . $ctype, 'parent_slug' => $this->buddypress['history_url'], 'screen_function' => array($this, 'my_history'))); // Loop though and add each filter option as a sub menu item if (!empty($date_sorting)) { foreach ($date_sorting as $sorting_id => $sorting_name) { if (empty($sorting_id)) { continue; } bp_core_new_subnav_item(array('name' => $sorting_name, 'slug' => $sorting_id, 'parent_url' => $bp->displayed_user->domain . $this->buddypress['history_url'] . $ctype, 'parent_slug' => $this->buddypress['history_url'], 'screen_function' => array($this, 'my_history'))); } } }
function messages_setup_nav() { global $bp; if ( $count = messages_get_unread_count() ) $name = sprintf( __('Messages <strong>(%s)</strong>', 'buddypress'), $count ); else $name = __('Messages <strong></strong>', 'buddypress'); /* Add 'Messages' to the main navigation */ bp_core_new_nav_item( array( 'name' => $name, 'slug' => $bp->messages->slug, 'position' => 50, 'show_for_displayed_user' => false, 'screen_function' => 'messages_screen_inbox', 'default_subnav_slug' => 'inbox', 'item_css_id' => $bp->messages->id ) ); $messages_link = $bp->loggedin_user->domain . $bp->messages->slug . '/'; /* Add the subnav items to the profile */ bp_core_new_subnav_item( array( 'name' => __( 'Inbox', 'buddypress' ) . $count_indicator, 'slug' => 'inbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_inbox', 'position' => 10, 'user_has_access' => bp_is_my_profile() ) ); bp_core_new_subnav_item( array( 'name' => __( 'Sent Messages', 'buddypress' ), 'slug' => 'sentbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_sentbox', 'position' => 20, 'user_has_access' => bp_is_my_profile() ) ); bp_core_new_subnav_item( array( 'name' => __( 'Compose', 'buddypress' ), 'slug' => 'compose', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_compose', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) ); if ( is_super_admin() ) bp_core_new_subnav_item( array( 'name' => __( 'Notices', 'buddypress' ), 'slug' => 'notices', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_notices', 'position' => 90, 'user_has_access' => is_super_admin() ) ); if ( $bp->current_component == $bp->messages->slug ) { if ( bp_is_my_profile() ) { $bp->bp_options_title = __( 'My Messages', 'buddypress' ); } else { $bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); $bp->bp_options_title = $bp->displayed_user->fullname; } } do_action( 'messages_setup_nav' ); }
function bp_setup_nav() { global $bp; $recipes_slug = 'recipes'; $my_recipes_slug = 'recipes/my-recipes'; $recipes_link = $bp->displayed_user->domain . $recipes_slug . '/'; $count = 0; $class = ''; if (isset($bp->displayed_user) && isset($bp->displayed_user->id) && $bp->displayed_user->id > 0) { global $sc_recipes_post_type; $user_recipe_results = $sc_recipes_post_type->list_recipes(0, -1, '', '', array(), array(), array(), array(), array(), false, $bp->displayed_user->id); if (count($user_recipe_results) > 0 && $user_recipe_results['total'] > 0) { $count = (int) $user_recipe_results['total']; } $class = 0 === $count ? 'no-count' : 'count'; } bp_core_new_nav_item(array('name' => sprintf(__('Recipes <span class="%s">%s</span>', 'socialchef'), esc_attr($class), number_format_i18n($count)), 'slug' => $my_recipes_slug, 'position' => 55, 'screen_function' => array($this, 'bp_recipes_tab_screen'), 'parent_url' => $bp->displayed_user->domain, 'default_subnav_slug' => 'my-recipes')); bp_core_new_subnav_item(array('name' => __('My Recipes', 'socialchef'), 'slug' => 'my-recipes', 'parent_slug' => $recipes_slug, 'parent_url' => $recipes_link, 'screen_function' => array($this, 'bp_my_recipes_tab_screen'), 'position' => 20, 'user_has_access' => true)); bp_core_new_subnav_item(array('name' => __('Favorite Recipes', 'socialchef'), 'slug' => 'favorite-recipes', 'parent_slug' => $recipes_slug, 'parent_url' => $recipes_link, 'screen_function' => array($this, 'bp_favorite_recipes_tab_screen'), 'position' => 30, 'user_has_access' => true)); }