Skip to content

Commit 17919bc

Browse files
committed
fix: learning area globals not accessable to filter hook
1 parent b988393 commit 17919bc

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

classes/Template.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,7 @@ public function load_single_course_template( $template ) {
166166
global $wp_query;
167167
if ( $wp_query->is_single && ! empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] === $this->course_post_type ) {
168168
// Check if the slug contains subpage of learning area.
169-
$learning_area_subpages = self::make_learning_area_sub_page_nav_items();
170-
$subpage = Input::get( 'subpage' );
171-
$subpage_slugs = array_keys( $learning_area_subpages );
172-
173-
if ( in_array( $subpage, $subpage_slugs, true ) ) {
169+
if ( Input::has( 'subpage' ) ) {
174170
$template = tutor_get_template( 'learning-area.index' );
175171
} else {
176172
do_action( 'single_course_template_before_load', get_the_ID() );
@@ -537,15 +533,15 @@ public static function make_learning_area_sub_page_nav_items( $base_url = '' ):
537533

538534
$menu_items = array(
539535
'qna' => array(
540-
'title' => __( 'Q&A', 'tutor' ),
541-
'icon' => Icon::QA,
542-
'url' => UrlHelper::add_query_params( $base_url, array( 'subpage' => 'qna' ) ),
536+
'title' => __( 'Q&A', 'tutor' ),
537+
'icon' => Icon::QA,
538+
'url' => UrlHelper::add_query_params( $base_url, array( 'subpage' => 'qna' ) ),
543539
'template' => tutor_get_template( 'learning-area.subpages.qna' ),
544540
),
545541
'course-info' => array(
546-
'title' => __( 'Course Info', 'tutor' ),
547-
'icon' => Icon::INFO_OCTAGON,
548-
'url' => UrlHelper::add_query_params( $base_url, array( 'subpage' => 'course-info' ) ),
542+
'title' => __( 'Course Info', 'tutor' ),
543+
'icon' => Icon::INFO_OCTAGON,
544+
'url' => UrlHelper::add_query_params( $base_url, array( 'subpage' => 'course-info' ) ),
549545
'template' => tutor_get_template( 'learning-area.subpages.course-info' ),
550546
),
551547
);

classes/Utils.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5619,11 +5619,8 @@ public function is_learning_area(): bool {
56195619
if ( is_single() && ! empty( $current_post_type ) ) {
56205620
if ( in_array( $current_post_type, $post_types, true ) ) {
56215621
return true;
5622-
} elseif ( tutor()->course_post_type === $current_post_type ) {
5623-
// Check if the subpage is belongs to learning area.
5624-
$learning_subpage = Input::get( 'subpage' );
5625-
$allowed_subpages = array_keys( Template::make_learning_area_sub_page_nav_items() );
5626-
return in_array( $learning_subpage, $allowed_subpages, true );
5622+
} elseif ( tutor()->course_post_type === $current_post_type && Input::has( 'subpage' ) ) {
5623+
return true;
56275624
}
56285625
}
56295626

@@ -8542,7 +8539,7 @@ public function is_tutor_dashboard( $subpage = null ) {
85428539
*
85438540
* @since 1.9.4
85448541
* @since 4.0.0 Subpage check support added.
8545-
* Example: assignments/submitted
8542+
* Example: assignments/submitted
85468543
*
85478544
* @param string $subpage subpage.
85488545
*
@@ -9521,7 +9518,7 @@ public function not_found_text(): string {
95219518
*/
95229519
public function instructor_menus(): array {
95239520
$menus = array(
9524-
'index' => array(
9521+
'index' => array(
95259522
'title' => __( 'Home', 'tutor' ),
95269523
'icon' => Icon::HOME,
95279524
),
@@ -9558,9 +9555,8 @@ public function instructor_menus(): array {
95589555
),
95599556
);
95609557

9561-
95629558
if ( $this->should_show_dicussion_menu() ) {
9563-
$other_menus['discussions'] = array (
9559+
$other_menus['discussions'] = array(
95649560
'title' => __( 'Discussions', 'tutor' ),
95659561
'auth_cap' => tutor()->instructor_role,
95669562
'icon' => Icon::QA,
@@ -9606,10 +9602,10 @@ public function default_menus(): array {
96069602
'title' => __( 'Courses', 'tutor' ),
96079603
'icon' => Icon::COURSES,
96089604
),
9609-
'account' => array(
9610-
'label' => __( 'Account', 'tutor' ),
9611-
'show_ui' => false
9612-
)
9605+
'account' => array(
9606+
'label' => __( 'Account', 'tutor' ),
9607+
'show_ui' => false,
9608+
),
96139609
);
96149610

96159611
if ( $this->should_show_dicussion_menu() ) {

0 commit comments

Comments
 (0)