Пример #1
0
 /**
  * Set up your component's navigation.
  *
  * The navigation elements created here are responsible for the main site navigation (eg
  * Profile > Activity > Mentions), as well as the navigation in the BuddyBar. WP Admin Bar
  * navigation is broken out into a separate method; see
  * BP_course_Component::setup_admin_bar().
  *
  * @global obj $bp
  */
 function setup_nav($main_nav = array(), $sub_nav = array())
 {
     $show_for_displayed_user = apply_filters('wplms_user_profile_courses', false);
     $main_nav = array('name' => sprintf(__('Courses <span>%s</span>', 'vibe'), bp_course_get_total_course_count_for_user()), 'slug' => BP_COURSE_SLUG, 'position' => 5, 'screen_function' => 'bp_course_my_courses', 'show_for_displayed_user' => $show_for_displayed_user, 'default_subnav_slug' => BP_COURSE_SLUG);
     // Add 'course' to the main navigation
     if (function_exists('vibe_get_option')) {
         $course_view = vibe_get_option('course_view');
         if (isset($course_view) && $course_view) {
             $main_nav['show_for_displayed_user'] = $show_for_displayed_user;
             //Change for admin
         }
     }
     $course_link = trailingslashit(bp_loggedin_user_domain() . BP_COURSE_SLUG);
     // 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 {
         $user_domain = false;
     }
     if (!empty($user_domain)) {
         $user_access = bp_is_my_profile();
         $user_access = apply_filters('wplms_user_profile_courses', $user_access);
         $sub_nav[] = array('name' => __('My Courses', 'vibe'), 'slug' => BP_COURSE_SLUG, 'parent_url' => $course_link, 'parent_slug' => BP_COURSE_SLUG, 'screen_function' => 'bp_course_my_courses', 'user_has_access' => $user_access, 'position' => 10);
         bp_core_new_subnav_item(array('name' => __('Results', 'vibe'), 'slug' => BP_COURSE_RESULTS_SLUG, 'parent_slug' => BP_COURSE_SLUG, 'parent_url' => $course_link, 'screen_function' => 'bp_course_my_results', 'position' => 30, 'user_has_access' => $user_access));
         bp_core_new_subnav_item(array('name' => __('Stats', 'vibe'), 'slug' => BP_COURSE_STATS_SLUG, 'parent_slug' => BP_COURSE_SLUG, 'parent_url' => $course_link, 'screen_function' => 'bp_course_stats', 'position' => 40, 'user_has_access' => $user_access));
         $sub_nav[] = array('name' => __('Instructing Courses', 'vibe'), 'slug' => BP_COURSE_INSTRUCTOR_SLUG, 'parent_url' => $course_link, 'parent_slug' => BP_COURSE_SLUG, 'screen_function' => 'bp_course_instructor_courses', 'user_has_access' => bp_is_my_profile_intructor(), 'position' => 50);
         parent::setup_nav($main_nav, $sub_nav);
     }
     // If your component needs additional navigation menus that are not handled by
     // BP_Component::setup_nav(), you can register them manually here. For course,
     // if your component needs a subsection under a user's Settings menu, add
     // it like this. See bp_course_screen_settings_menu() for more info
     /*global $bp;
     
     		$bp->is_single_item=true; // Extra comments : BuddyPress never detects a single course page
     		$bp->current_component=BP_COURSE_SLUG;  // Extra comments : BuddyPress successfully detects Course 
     		$bp->current_item=$bp->current_action='fikka-dynamics'; // Extra comments : Only Works if we force the current item variable. Never really works.
     		*/
     if (bp_is_course_component() && bp_is_single_item()) {
         // Reset sub nav
         $sub_nav = array();
         // Add 'courses' to the main navigation
         $main_nav = array('name' => __('Home', 'vibe'), 'slug' => get_current_course_slug(), 'position' => -1, 'screen_function' => 'bp_screen_course_home', 'default_subnav_slug' => $this->default_extension, 'item_css_id' => $this->id);
         /*
         			BELOW Part has to hacked to build a custom Menu system. BuddyPress never really detects MENUS properly
         
         			// Add the "Home" subnav item, as this will always be present
         			$sub_nav[] = array(
         				'name'            =>  _e( 'CURRICULUM', 'vibe' ),
         				'slug'            => 'structure',
         				'parent_url'      => $course_link,
         				'parent_slug'     => get_current_course_slug(),
         				'screen_function' => 'bp_screen_course_structure',
         				'position'        => 10,
         				'item_css_id'     => 'structure'
         			);
         
         			$sub_nav[] = array(
         				'name'            =>  _x( 'Home', 'Course home', 'vibe' ),
         				'slug'            => 'home',
         				'parent_url'      => $course_link,
         				'parent_slug'     => $this->current_group->slug,
         				'screen_function' => 'bp_screen_course_home',
         				'position'        => 10,
         				'item_css_id'     => 'home'
         			);
         /*
         			// If this is a private course, and the user is not a
         			// member and does not have an outstanding invitation,
         			// show a "Request Membership" nav item.
         			if ( is_user_logged_in() && !user_check_course_subscribe()){
         
         				$sub_nav[] = array(
         					'name'               => __( 'Subscribe Course', 'vibe' ),
         					'slug'               => 'subscribe-course',
         					'parent_url'         => bp_get_course_permalink(),
         					'parent_slug'        => get_current_course_slug(),
         					'screen_function'    => 'bp_screen_course_subscribe',
         					'position'           => 30
         				);
         			}
         
         			if ( is_user_logged_in() && user_check_course_subscribe()){
         
         				$sub_nav[] = array(
         					'name'               => __( 'Course Status', 'vibe' ),
         					'slug'               => 'course-continue',
         					'parent_url'         => bp_get_course_permalink(),
         					'parent_slug'        => get_current_course_slug(),
         					'screen_function'    => 'bp_screen_course_subscribe',
         					'position'           => 30
         				);
         			}
         
         
         			$sub_nav[] = array(
         				'name'            => sprintf( __( 'Members <span>%s</span>', 'vibe' ), number_format( $this->current_course->total_member_count ) ),
         				'slug'            => 'members',
         				'parent_url'      => bp_get_course_permalink(),
         				'parent_slug'     => get_current_course_slug(),
         				'screen_function' => 'bp_screen_course_members',
         				'position'        => 60,
         				'user_has_access' => user_check_course_subscribe(),
         				'item_css_id'     => 'members'
         			);
         
         			// If the user is a course admin, then show the course admin nav item
         			if ( bp_is_item_admin() ) {
         				$sub_nav[] = array(
         					'name'            => __( 'Admin', 'vibe' ),
         					'slug'            => 'admin',
         					'parent_url'      => bp_get_course_permalink(),
         					'parent_slug'     => get_current_course_slug(),
         					'screen_function' => 'bp_screen_course_admin',
         					'position'        => 1000,
         					'user_has_access' => true,
         					'item_css_id'     => 'admin'
         				);
         			}
         */
         parent::setup_nav($main_nav, $sub_nav);
     }
     if (isset($this->current_course->user_has_access)) {
         do_action('courses_setup_nav', $this->current_course->user_has_access);
     } else {
         do_action('courses_setup_nav');
     }
 }
Пример #2
0
 /**
  * Set up your component's navigation.
  *
  * The navigation elements created here are responsible for the main site navigation (eg
  * Profile > Activity > Mentions), as well as the navigation in the BuddyBar. WP Admin Bar
  * navigation is broken out into a separate method; see
  * BP_course_Component::setup_admin_bar().
  *
  * @global obj $bp
  */
 function setup_nav($main_nav = array(), $sub_nav = array())
 {
     $show_for_displayed_user = apply_filters('wplms_user_profile_courses', false);
     $main_nav = array('name' => sprintf(__('Courses <span>%s</span>', 'vibe'), bp_course_get_total_course_count_for_user()), 'slug' => BP_COURSE_SLUG, 'position' => 5, 'screen_function' => 'bp_course_my_courses', 'show_for_displayed_user' => $show_for_displayed_user, 'default_subnav_slug' => BP_COURSE_SLUG);
     // Add 'course' to the main navigation
     if (function_exists('vibe_get_option')) {
         $course_view = vibe_get_option('course_view');
         if (isset($course_view) && $course_view) {
             $main_nav['show_for_displayed_user'] = $show_for_displayed_user;
             //Change for admin
         }
     }
     $course_link = trailingslashit(bp_loggedin_user_domain() . BP_COURSE_SLUG);
     // 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 {
         $user_domain = false;
     }
     if (!empty($user_domain)) {
         $user_access = bp_is_my_profile();
         $user_access = apply_filters('wplms_user_profile_courses', $user_access);
         $sub_nav[] = array('name' => __('My Courses', 'vibe'), 'slug' => BP_COURSE_SLUG, 'parent_url' => $course_link, 'parent_slug' => BP_COURSE_SLUG, 'screen_function' => 'bp_course_my_courses', 'user_has_access' => $user_access, 'position' => 10);
         bp_core_new_subnav_item(array('name' => __('Results', 'vibe'), 'slug' => BP_COURSE_RESULTS_SLUG, 'parent_slug' => BP_COURSE_SLUG, 'parent_url' => $course_link, 'screen_function' => 'bp_course_my_results', 'position' => 30, 'user_has_access' => $user_access));
         bp_core_new_subnav_item(array('name' => __('Stats', 'vibe'), 'slug' => BP_COURSE_STATS_SLUG, 'parent_slug' => BP_COURSE_SLUG, 'parent_url' => $course_link, 'screen_function' => 'bp_course_stats', 'position' => 40, 'user_has_access' => $user_access));
         $sub_nav[] = array('name' => __('Instructing Courses', 'vibe'), 'slug' => BP_COURSE_INSTRUCTOR_SLUG, 'parent_slug' => BP_COURSE_SLUG, 'parent_url' => $course_link, 'screen_function' => 'bp_course_instructor_courses', 'position' => 50, 'user_has_access' => bp_is_my_profile_intructor());
         parent::setup_nav($main_nav, $sub_nav);
     }
     // If your component needs additional navigation menus that are not handled by
     if (bp_is_course_component() && bp_is_single_item()) {
         // Reset sub nav
         $sub_nav = array();
         // Add 'courses' to the main navigation
         $main_nav = array('name' => __('Home', 'vibe'), 'slug' => get_current_course_slug(), 'position' => -1, 'screen_function' => 'bp_screen_course_home', 'default_subnav_slug' => $this->default_extension, 'item_css_id' => $this->id);
         parent::setup_nav($main_nav, $sub_nav);
     }
     if (isset($this->current_course->user_has_access)) {
         do_action('courses_setup_nav', $this->current_course->user_has_access);
     } else {
         do_action('courses_setup_nav');
     }
 }