Core::setup_nav()
Add Course tab in profile menu
Description
Source
File: bp-integrations/learndash/core/Core.php
public function setup_nav() { $this->course_name = \LearnDash_Custom_Label::get_label( 'courses' ); $this->my_courses_name = sprintf( __( 'My %s', 'buddyboss' ), $this->course_name ); $this->create_courses_name = sprintf( __( 'Create a %s', 'buddyboss' ), $this->course_name ); $this->create_courses_slug = apply_filters( 'bp_learndash_profile_create_courses_slug', 'create-courses' ); $this->course_slug = apply_filters( 'bp_learndash_profile_courses_slug', \LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Section_Permalinks', 'courses' ) ); $this->my_courses_slug = apply_filters( 'bp_learndash_profile_courses_slug', 'my-courses' ); $this->course_access = bp_core_can_edit_settings(); $this->certificates_enables = bp_core_learndash_certificates_enables(); $this->my_certificates_tab_name = apply_filters( 'bp_learndash_profile_certificates_tab_name', __( 'My Certificates', 'buddyboss' ) ); $this->certificates_tab_name = apply_filters( 'bp_learndash_profile_certificates_tab_name', __( 'Certificates', 'buddyboss' ) ); $this->certificates_tab_slug = apply_filters( 'bp_learndash_profile_certificates_slug', 'certificates' ); $this->bp_displayed_user_id = bp_displayed_user_id(); $this->bp_loggedin_user_id = bp_loggedin_user_id(); $this->user_same = ( $this->bp_displayed_user_id == $this->bp_loggedin_user_id ? true : false ); $atts = apply_filters( 'bp_learndash_user_courses_atts', array() ); $user_courses = apply_filters( 'bp_learndash_user_courses', ld_get_mycourses( $this->bp_displayed_user_id, $atts ) ); $user_courses_count = is_array( $user_courses ) ? count( $user_courses ) : 0; // Only grab count if we're on a user page. if ( bp_is_user() ) { $class = ( 0 === $user_courses_count ) ? 'no-count' : 'count'; $nav_name = sprintf( /* translators: %s: Group count for the current user */ __( '%s %s', 'buddyboss' ), $this->course_name, sprintf( '<span class="%s">%s</span>', esc_attr( $class ), $user_courses_count ) ); } else { $nav_name = $this->course_name; } bp_core_new_nav_item( array( 'name' => $nav_name, 'slug' => $this->course_slug, 'screen_function' => array( $this, 'course_page' ), 'position' => 75, 'default_subnav_slug' => $this->my_courses_slug, 'show_for_displayed_user' => $this->course_access, ) ); $all_subnav_items = array( array( 'name' => empty( $this->user_same ) ? $this->course_name : $this->my_courses_name, 'slug' => $this->my_courses_slug, 'parent_url' => $this->get_nav_link( $this->course_slug ), 'parent_slug' => $this->course_slug, 'screen_function' => array( $this, 'course_page' ), 'position' => 75, 'user_has_access' => $this->course_access, ), ); if ( $this->certificates_enables ) { $all_subnav_items[] = array( 'name' => empty( $this->user_same ) ? $this->certificates_tab_name : $this->my_certificates_tab_name, 'slug' => $this->certificates_tab_slug, 'parent_url' => $this->get_nav_link( $this->course_slug ), 'parent_slug' => $this->course_slug, 'screen_function' => array( $this, 'certificates_page' ), 'user_has_access' => $this->course_access, ); } foreach ( $all_subnav_items as $all_subnav_item ) { bp_core_new_subnav_item( $all_subnav_item ); } }
Changelog
Version | Description |
---|---|
BuddyBoss 1.2.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.