@@ -2922,22 +2922,127 @@ public function is_tutor_order( $order_id ) {
29222922 }
29232923 }
29242924
2925+ /**
2926+ * Separation of all menu items for providing ease of usage
2927+ *
2928+ * @since 2.0.0
2929+ *
2930+ * @since 4.0.0 Menu item updated based on student view
2931+ *
2932+ * @return array array of menu items.
2933+ */
2934+ public function default_menus (): array {
2935+ $ items = array (
2936+ 'index ' => array (
2937+ 'title ' => __ ( 'Home ' , 'tutor ' ),
2938+ 'icon ' => Icon::HOME ,
2939+ ),
2940+ 'courses ' => array (
2941+ 'title ' => __ ( 'Courses ' , 'tutor ' ),
2942+ 'icon ' => Icon::COURSES ,
2943+ ),
2944+ 'retrieve-password ' => array (
2945+ 'title ' => __ ( 'Retrieve Password ' , 'tutor ' ),
2946+ 'show_ui ' => false ,
2947+ 'login_require ' => false ,
2948+ ),
2949+ 'account ' => array (
2950+ 'label ' => __ ( 'Account ' , 'tutor ' ),
2951+ 'show_ui ' => false ,
2952+ ),
2953+ );
2954+
2955+ if ( $ this ->should_show_dicussion_menu () ) {
2956+ $ items ['discussions ' ] = array (
2957+ 'title ' => __ ( 'Discussions ' , 'tutor ' ),
2958+ 'icon ' => Icon::QA ,
2959+ );
2960+ }
2961+
2962+ return apply_filters ( 'tutor_student_dashboard_nav ' , $ items );
2963+ }
2964+
2965+ /**
2966+ * Separation of all menu items for providing ease of usage
2967+ *
2968+ * @since 2.0.0
2969+ *
2970+ * @return array array of menu items.
2971+ */
2972+ public function instructor_menus (): array {
2973+ $ menus = array (
2974+ 'index ' => array (
2975+ 'title ' => __ ( 'Home ' , 'tutor ' ),
2976+ 'icon ' => Icon::HOME ,
2977+ ),
2978+ 'my-courses ' => array (
2979+ 'title ' => __ ( 'Courses ' , 'tutor ' ),
2980+ 'auth_cap ' => tutor ()->instructor_role ,
2981+ 'icon ' => Icon::COURSES ,
2982+ ),
2983+ // Hidden menu.
2984+ 'create-course ' => array (
2985+ 'title ' => __ ( 'Create Course ' , 'tutor ' ),
2986+ 'show_ui ' => false ,
2987+ 'auth_cap ' => tutor ()->instructor_role ,
2988+ ),
2989+ 'create-bundle ' => array (
2990+ 'title ' => __ ( 'Create Bundle ' , 'tutor ' ),
2991+ 'show_ui ' => false ,
2992+ 'auth_cap ' => tutor ()->instructor_role ,
2993+ ),
2994+ );
2995+
2996+ $ menus = apply_filters ( 'tutor_after_instructor_menu_my_courses ' , $ menus );
2997+
2998+ $ other_menus = array (
2999+ 'announcements ' => array (
3000+ 'title ' => __ ( 'Announcements ' , 'tutor ' ),
3001+ 'auth_cap ' => tutor ()->instructor_role ,
3002+ 'icon ' => Icon::ANNOUNCEMENT ,
3003+ ),
3004+ 'quiz-attempts ' => array (
3005+ 'title ' => __ ( 'Quiz Attempts ' , 'tutor ' ),
3006+ 'auth_cap ' => tutor ()->instructor_role ,
3007+ 'icon ' => Icon::QUIZ ,
3008+ ),
3009+ );
3010+
3011+ if ( $ this ->should_show_dicussion_menu () ) {
3012+ $ other_menus ['discussions ' ] = array (
3013+ 'title ' => __ ( 'Discussions ' , 'tutor ' ),
3014+ 'auth_cap ' => tutor ()->instructor_role ,
3015+ 'icon ' => Icon::QA ,
3016+ );
3017+ }
3018+
3019+ $ all_menus = apply_filters ( 'tutor_instructor_dashboard_nav ' , array_merge ( $ menus , $ other_menus ) );
3020+
3021+ return $ all_menus ;
3022+ }
3023+
29253024 /**
29263025 * Tutor Dashboard Pages, supporting for the URL rewriting
29273026 *
29283027 * @since 1.0.0
29293028 *
2930- * @since 4.0.0 View mode added.
3029+ * @since 4.0.0 param $context added.
29313030 *
2932- * @return mixed
3031+ * @param string $context context.
3032+ * `view` to get pages according to role.
3033+ * `rewrite_rules` to get all page for rewrite rules.
3034+ *
3035+ * @return array
29333036 */
2934- public function tutor_dashboard_pages () {
3037+ public function tutor_dashboard_pages ( $ context = 'view ' ) {
3038+
3039+ $ nav_items = apply_filters ( 'tutor_dashboard/nav_items ' , $ this ->default_menus () );
3040+ $ instructor_nav_items = apply_filters ( 'tutor_dashboard/instructor_nav_items ' , $ this ->instructor_menus () );
29353041
2936- $ nav_items = array ();
2937- if ( User::is_instructor_view () ) {
2938- $ nav_items = apply_filters ( 'tutor_dashboard/instructor_nav_items ' , $ this ->instructor_menus () );
3042+ if ( 'rewrite_rules ' === $ context ) {
3043+ $ nav_items = array_merge ( $ nav_items , $ instructor_nav_items );
29393044 } else {
2940- $ nav_items = apply_filters ( ' tutor_dashboard/nav_items ' , $ this -> default_menus () ) ;
3045+ $ nav_items = User:: is_instructor_view () ? $ instructor_nav_items : $ nav_items ;
29413046 }
29423047
29433048 return apply_filters ( 'tutor_dashboard/nav_items_all ' , $ nav_items );
@@ -2951,21 +3056,8 @@ public function tutor_dashboard_pages() {
29513056 * @return array
29523057 */
29533058 public function tutor_dashboard_permalinks () {
2954- $ dashboard_pages = $ this ->tutor_dashboard_pages ();
2955-
2956- $ dashboard_permalinks = apply_filters (
2957- 'tutor_dashboard/permalinks ' ,
2958- array (
2959- 'retrieve-password ' => array (
2960- 'title ' => __ ( 'Retrieve Password ' , 'tutor ' ),
2961- 'login_require ' => false ,
2962- ),
2963- )
2964- );
2965-
2966- $ dashboard_pages = array_merge ( $ dashboard_pages , $ dashboard_permalinks );
2967-
2968- return $ dashboard_pages ;
3059+ $ dashboard_permalinks = apply_filters ( 'tutor_dashboard/permalinks ' , $ this ->tutor_dashboard_pages ( 'rewrite_rules ' ) );
3060+ return $ dashboard_permalinks ;
29693061 }
29703062
29713063 /**
@@ -9546,64 +9638,6 @@ public function not_found_text(): string {
95469638 }
95479639 }
95489640
9549- /**
9550- * Separation of all menu items for providing ease of usage
9551- *
9552- * @since 2.0.0
9553- *
9554- * @return array array of menu items.
9555- */
9556- public function instructor_menus (): array {
9557- $ menus = array (
9558- 'index ' => array (
9559- 'title ' => __ ( 'Home ' , 'tutor ' ),
9560- 'icon ' => Icon::HOME ,
9561- ),
9562- 'my-courses ' => array (
9563- 'title ' => __ ( 'Courses ' , 'tutor ' ),
9564- 'auth_cap ' => tutor ()->instructor_role ,
9565- 'icon ' => Icon::COURSES ,
9566- ),
9567- // Hidden menu.
9568- 'create-course ' => array (
9569- 'title ' => __ ( 'Create Course ' , 'tutor ' ),
9570- 'show_ui ' => false ,
9571- 'auth_cap ' => tutor ()->instructor_role ,
9572- ),
9573- 'create-bundle ' => array (
9574- 'title ' => __ ( 'Create Bundle ' , 'tutor ' ),
9575- 'show_ui ' => false ,
9576- 'auth_cap ' => tutor ()->instructor_role ,
9577- ),
9578- );
9579-
9580- $ menus = apply_filters ( 'tutor_after_instructor_menu_my_courses ' , $ menus );
9581-
9582- $ other_menus = array (
9583- 'announcements ' => array (
9584- 'title ' => __ ( 'Announcements ' , 'tutor ' ),
9585- 'auth_cap ' => tutor ()->instructor_role ,
9586- 'icon ' => Icon::ANNOUNCEMENT ,
9587- ),
9588- 'quiz-attempts ' => array (
9589- 'title ' => __ ( 'Quiz Attempts ' , 'tutor ' ),
9590- 'auth_cap ' => tutor ()->instructor_role ,
9591- 'icon ' => Icon::QUIZ ,
9592- ),
9593- );
9594-
9595- if ( $ this ->should_show_dicussion_menu () ) {
9596- $ other_menus ['discussions ' ] = array (
9597- 'title ' => __ ( 'Discussions ' , 'tutor ' ),
9598- 'auth_cap ' => tutor ()->instructor_role ,
9599- 'icon ' => Icon::QA ,
9600- );
9601- }
9602-
9603- $ all_menus = apply_filters ( 'tutor_instructor_dashboard_nav ' , array_merge ( $ menus , $ other_menus ) );
9604-
9605- return $ all_menus ;
9606- }
96079641
96089642 /**
96099643 * Should show the disscussion menu on the student
@@ -9620,40 +9654,6 @@ public function should_show_dicussion_menu(): bool {
96209654 return $ is_q_and_a_enabled || $ is_lesson_comment_enabled ;
96219655 }
96229656
9623- /**
9624- * Separation of all menu items for providing ease of usage
9625- *
9626- * @since 2.0.0
9627- *
9628- * @since 4.0.0 Menu item updated based on student view
9629- *
9630- * @return array array of menu items.
9631- */
9632- public function default_menus (): array {
9633- $ items = array (
9634- 'index ' => array (
9635- 'title ' => __ ( 'Home ' , 'tutor ' ),
9636- 'icon ' => Icon::HOME ,
9637- ),
9638- 'courses ' => array (
9639- 'title ' => __ ( 'Courses ' , 'tutor ' ),
9640- 'icon ' => Icon::COURSES ,
9641- ),
9642- 'account ' => array (
9643- 'label ' => __ ( 'Account ' , 'tutor ' ),
9644- 'show_ui ' => false ,
9645- ),
9646- );
9647-
9648- if ( $ this ->should_show_dicussion_menu () ) {
9649- $ items ['discussions ' ] = array (
9650- 'title ' => __ ( 'Discussions ' , 'tutor ' ),
9651- 'icon ' => Icon::QA ,
9652- );
9653- }
9654-
9655- return apply_filters ( 'tutor_student_dashboard_nav ' , $ items );
9656- }
96579657
96589658 /**
96599659 * Default config for tutor text editor
0 commit comments