Skip to content

Commit 76b233e

Browse files
committed
Merge branch '4.0.0-dev' of github.com:themeum/tutor into notification-settings
2 parents a50b8d4 + aaf2770 commit 76b233e

File tree

10 files changed

+38
-486
lines changed

10 files changed

+38
-486
lines changed

assets/src/js/frontend/dashboard/header.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { type MutationState } from '@Core/ts/services/Query';
22
import { type AjaxResponse } from '@FrontendTypes/index';
3+
import { tutorConfig } from '@TutorShared/config/config';
34
import { wpAjaxInstance } from '@TutorShared/utils/api';
45
import { convertToErrorMessage } from '@TutorShared/utils/util';
56

@@ -16,7 +17,7 @@ const header = () => {
1617
onSuccess: (res: AjaxResponse) => {
1718
window.TutorCore.toast.success(res?.message);
1819
setTimeout(() => {
19-
window.location.reload();
20+
window.location.href = tutorConfig.tutor_frontend_dashboard_url;
2021
}, 1000);
2122
},
2223
onError: (error: Error) => {

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 & 100 deletions
This file was deleted.

classes/Template.php

Lines changed: 13 additions & 19 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
}
@@ -178,7 +180,6 @@ public function load_single_course_template( $template ) {
178180
}
179181

180182
return $template;
181-
182183
}
183184

184185
/**
@@ -536,32 +537,25 @@ public static function make_learning_area_sub_page_nav_items( $base_url = '' ):
536537

537538
$menu_items = array(
538539
'resources' => array(
539-
'title' => esc_html__( 'Resources', 'tutor' ),
540-
'icon' => Icon::RESOURCES,
541-
'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+
'template' => tutor_get_template( 'learning-area.subpages.resources' ),
542544
),
543545
'qna' => array(
544-
'title' => esc_html__( 'Q&A', 'tutor' ),
546+
'title' => __( 'Q&A', 'tutor' ),
545547
'icon' => Icon::QA,
546-
'url' => esc_url( add_query_arg( 'subpage', 'qna', $base_url ) ),
548+
'url' => UrlHelper::add_query_params( $base_url, array( 'subpage' => 'qna' ) ),
549+
'template' => tutor_get_template( 'learning-area.subpages.qna' ),
547550
),
548551
'course-info' => array(
549-
'title' => esc_html__( 'Course Info', 'tutor' ),
552+
'title' => __( 'Course Info', 'tutor' ),
550553
'icon' => Icon::INFO_OCTAGON,
551-
'url' => esc_url( add_query_arg( 'subpage', 'course-info', $base_url ) ),
552-
),
553-
'webinar' => array(
554-
'title' => esc_html__( 'Webinar', 'tutor' ),
555-
'icon' => Icon::VIDEO_CAMERA_2,
556-
'url' => esc_url( add_query_arg( 'subpage', 'webinar', $base_url ) ),
557-
),
558-
'certificate' => array(
559-
'title' => esc_html__( 'Certificate', 'tutor' ),
560-
'icon' => Icon::CERTIFICATE_2,
561-
'url' => esc_url( add_query_arg( 'subpage', 'certificate', $base_url ) ),
554+
'url' => UrlHelper::add_query_params( $base_url, array( 'subpage' => 'course-info' ) ),
555+
'template' => tutor_get_template( 'learning-area.subpages.course-info' ),
562556
),
563557
);
564558

565-
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 );
566560
}
567561
}

classes/User.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010

1111
namespace TUTOR;
1212

13+
defined( 'ABSPATH' ) || exit;
14+
1315
use Tutor\Helpers\HttpHelper;
1416
use Tutor\Models\UserModel;
1517
use Tutor\Traits\JsonResponse;
1618

17-
if ( ! defined( 'ABSPATH' ) ) {
18-
exit;
19-
}
20-
2119
/**
2220
* User class
2321
*
@@ -720,6 +718,7 @@ public function ajax_switch_profile() {
720718
}
721719

722720
update_user_meta( $user_id, self::VIEW_MODE_USER_META, $switch_mode );
721+
flush_rewrite_rules();
723722

724723
// translators:%s for switching mode.
725724
$this->response_success( sprintf( __( 'Profile switched to %s!', 'tutor' ), $switch_mode ) );

helpers/DateTimeHelper.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ public function sub( $number, $interval ) {
122122
return $this;
123123
}
124124

125+
/**
126+
* Get DateTime obj.
127+
*
128+
* @since 4.0.0
129+
*
130+
* @return DateTime
131+
*/
132+
public function get() {
133+
return $this->datetime;
134+
}
135+
125136
/**
126137
* Check date time is past
127138
*

templates/dashboard/components/quiz-attempt-row.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
$show_course = $show_course ?? false;
2828
$attempt_number = $attempt_number ?? null;
2929
$attempts_count = $attempts_count ?? 0;
30-
$badge = Badge::make()->label( 'Failed' )->variant( Variant::CANCELLED )->rounded();
30+
$badge = Badge::make()->label( 'Failed' )->variant( Badge::ERROR )->rounded();
3131
$kebab_button = Button::make()
3232
->icon( Icon::THREE_DOTS_VERTICAL )
3333
->attr( 'x-ref', 'trigger' )
@@ -131,12 +131,12 @@
131131
if ( QuizModel::RESULT_PASS === $attempt['result'] ) {
132132
$badge
133133
->label( __( 'Passed', 'tutor' ) )
134-
->variant( Variant::COMPLETED )
134+
->variant( Badge::SUCCESS )
135135
->render();
136136
} elseif ( QuizModel::RESULT_PENDING === $attempt['result'] ) {
137137
$badge
138138
->label( __( 'Pending', 'tutor' ) )
139-
->variant( Variant::PENDING )
139+
->variant( Badge::WARNING )
140140
->render();
141141
} else {
142142
$badge->render();

templates/learning-area/index.php

Lines changed: 6 additions & 4 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();
@@ -41,11 +43,11 @@
4143
$subpage = Input::get( 'subpage' );
4244

4345
if ( $subpage ) {
44-
$subpage_template = tutor_get_template( 'learning-area.subpages.' . $subpage );
45-
if ( file_exists( $subpage_template ) ) {
46-
tutor_load_template( 'learning-area.subpages.' . $subpage );
46+
$template = $subpages[ $subpage ]['template'] ?? '';
47+
if ( file_exists( $template ) ) {
48+
tutor_load_template_from_custom_path( $template );
4749
} else {
48-
do_action( 'tutor_single_content_' . $tutor_post_type );
50+
do_action( 'tutor_single_content_' . $tutor_current_post_type );
4951
}
5052
} else {
5153
do_action( 'tutor_single_content_' . $tutor_current_post_type, $tutor_current_post );

0 commit comments

Comments
 (0)