Skip to content

Commit 2862c3a

Browse files
committed
removed webinar css and used hooks for pro template load
1 parent a1ac7d0 commit 2862c3a

File tree

4 files changed

+22
-144
lines changed

4 files changed

+22
-144
lines changed

assets/src/scss/frontend/learning-area/pages/_index.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@
55
@forward './qna';
66
@forward './quiz-intro';
77
@forward './resources';
8-
@forward './webinar';
98
@forward './quiz-summary';

assets/src/scss/frontend/learning-area/pages/_webinar.scss

Lines changed: 0 additions & 109 deletions
This file was deleted.

classes/Template.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
namespace TUTOR;
1212

13+
use Tutor\Helpers\UrlHelper;
14+
1315
if ( ! defined( 'ABSPATH' ) ) {
1416
exit;
1517
}
@@ -535,22 +537,25 @@ public static function make_learning_area_sub_page_nav_items( $base_url = '' ):
535537

536538
$menu_items = array(
537539
'resources' => array(
538-
'title' => esc_html__( 'Resources', 'tutor' ),
539-
'icon' => Icon::RESOURCES,
540-
'url' => esc_url( add_query_arg( 'subpage', 'resources', $base_url ) ),
540+
'title' => __( 'Resources', 'tutor' ),
541+
'icon' => Icon::RESOURCES,
542+
'url' => UrlHelper::add_query_params( $base_url, array( 'subpage' => 'resources' ) ),
543+
'is_pro' => false,
541544
),
542545
'qna' => array(
543-
'title' => esc_html__( 'Q&A', 'tutor' ),
544-
'icon' => Icon::QA,
545-
'url' => esc_url( add_query_arg( 'subpage', 'qna', $base_url ) ),
546+
'title' => __( 'Q&A', 'tutor' ),
547+
'icon' => Icon::QA,
548+
'url' => UrlHelper::add_query_params( $base_url, array( 'subpage' => 'qna' ) ),
549+
'is_pro' => false,
546550
),
547551
'course-info' => array(
548-
'title' => esc_html__( 'Course Info', 'tutor' ),
549-
'icon' => Icon::INFO_OCTAGON,
550-
'url' => esc_url( add_query_arg( 'subpage', 'course-info', $base_url ) ),
552+
'title' => __( 'Course Info', 'tutor' ),
553+
'icon' => Icon::INFO_OCTAGON,
554+
'url' => UrlHelper::add_query_params( $base_url, array( 'subpage' => 'course-info' ) ),
555+
'is_pro' => false,
551556
),
552557
);
553558

554-
return apply_filters( 'tutor_learning_area_sub_page_nav_item', $menu_items );
559+
return apply_filters( 'tutor_learning_area_sub_page_nav_item', $menu_items, $base_url );
555560
}
556561
}

templates/learning-area/index.php

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
use TUTOR\Course_List;
1313
use TUTOR\Icon;
1414
use TUTOR\Input;
15+
use TUTOR\Template;
1516

1617
wp_head();
1718

1819
$current_user_id = get_current_user_id();
20+
$subpages = Template::make_learning_area_sub_page_nav_items();
1921

2022
// Tutor global variable for using inside learning area.
2123
$tutor_current_post_type = get_post_type();
@@ -39,33 +41,14 @@
3941
<?php
4042
// Get requested page from query string and sanitize.
4143
$subpage = Input::get( 'subpage' );
42-
$is_pro = false;
43-
44-
// Pro subpages.
45-
$pro_subpages = array( 'webinar', 'certificate' );
46-
$is_pro = in_array( $subpage, $pro_subpages, true );
4744

4845
if ( $subpage ) {
49-
$subpage_template = tutor_get_template( 'learning-area.subpages.' . $subpage, $is_pro );
50-
if ( file_exists( $subpage_template ) ) {
51-
tutor_load_template(
52-
'learning-area.subpages.' . $subpage,
53-
array(
54-
'base_url' => esc_url( add_query_arg( array( 'subpage' => $subpage ), get_permalink( $tutor_course_id ) ) ),
55-
'tutor_current_post_type' => $tutor_current_post_type,
56-
'tutor_current_post' => $tutor_current_post,
57-
'tutor_current_content_id' => $tutor_current_content_id,
58-
'tutor_course_id' => $tutor_course_id,
59-
'tutor_course' => $tutor_course,
60-
'tutor_course_list_url' => $tutor_course_list_url,
61-
'tutor_is_enrolled' => $tutor_is_enrolled,
62-
'tutor_is_public_course' => $tutor_is_public_course,
63-
'tutor_is_course_instructor' => $tutor_is_course_instructor,
64-
),
65-
$is_pro
66-
);
46+
$is_pro = isset( $subpages[ $subpage ] ) && $subpages[ $subpage ]['is_pro'];
47+
$subpage_template = ! $is_pro ? tutor_get_template( 'learning-area.subpages.' . $subpage ) : '';
48+
if ( file_exists( $subpage_template ) && ! $is_pro ) {
49+
tutor_load_template( 'learning-area.subpages.' . $subpage );
6750
} else {
68-
do_action( 'tutor_single_content_' . $tutor_post_type );
51+
do_action( 'tutor_single_content_' . $tutor_current_post_type, $subpage );
6952
}
7053
} else {
7154
do_action( 'tutor_single_content_' . $tutor_current_post_type, $tutor_current_post );

0 commit comments

Comments
 (0)