PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
← All changes | inc/templates/class-lp-template-course.php +210 -217 4.1.7.2 → 4.4.9 View file →
@@ -1,6 +1,14 @@
1 1 <?php
2 2
3 +use LearnPress\Helpers\Template;
4 +use LearnPress\Models\CourseModel;
5 +use LearnPress\Models\UserItems\UserCourseModel;
6 +use LearnPress\Models\UserModel;
7 +use LearnPress\TemplateHooks\Course\SingleCourseModernLayout;
8 +use LearnPress\TemplateHooks\Course\SingleCourseTemplate;
9 +use LearnPress\TemplateHooks\UserItem\UserCourseTemplate;
10 +
3 11 /**
4 12 * Class LP_Course_Template
5 13 *
6 14 * Groups templates related course and items
@@ -18,9 +26,9 @@
18 26 */
19 27 public function __construct() {
20 28 parent::__construct();
21 29
22 - add_action( 'the_post', array( $this, 'get_course' ), 1000 );
30 + add_action( 'the_post', array( $this, 'get_course' ) );
23 31 }
24 32
25 33 public function get_course() {
26 34 // global $post;
@@ -32,8 +40,10 @@
32 40 learn_press_get_template( 'single-course/sidebar/preview' );
33 41 }
34 42
35 43 public function course_buttons() {
44 + global $lp_user;
45 + $lp_user = learn_press_get_current_user();
36 46 learn_press_get_template( 'single-course/buttons' );
37 47 }
38 48
39 49 public function course_graduation() {
@@ -57,9 +67,12 @@
57 67 * Show button retry course
58 68 *
59 69 * @throws Exception
60 70 */
61 - public function button_retry( $course ) {
71 + public function button_retry( $course = null ) {
72 + _deprecated_function( __METHOD__, '4.3.2.4', 'UserCourseTemplate::html_btn_retake' );
73 + return;
74 +
62 75 $user = learn_press_get_current_user();
63 76 if ( empty( $course ) ) {
64 77 $course = learn_press_get_course();
65 78 }
@@ -93,20 +106,12 @@
93 106 * @param LP_Quiz $item
94 107 */
95 108 public function quiz_meta_questions( $item ) {
96 109 $count = $item->count_questions();
97 - echo '<span class="item-meta count-questions">' . sprintf(
98 - $count ? _n(
99 - '%d question',
100 - '%d questions',
101 - $count,
102 - 'learnpress'
103 - ) : __(
104 - '%d question',
105 - 'learnpress'
106 - ),
107 - $count
108 - ) . '</span>';
110 + printf(
111 + '<span class="item-meta count-questions">%s</span>',
112 + sprintf( _n( '%1$d question', '%1$d questions', $count, 'learnpress' ), $count )
113 + );
109 114 }
110 115
111 116 /**
112 117 * @param LP_Quiz|LP_Lesson $item
@@ -124,9 +129,10 @@
124 129 */
125 130 public function quiz_meta_final( $item ) {
126 131 $course = $item->get_course();
127 132
128 - if ( ! $course || ! $course->is_final_quiz( $item->get_id() ) ) {
133 + if ( ! $course || ! $course->is_final_quiz( $item->get_id() )
134 + || $course->get_evaluation_type() != 'evaluate_final_quiz' ) {
129 135 return;
130 136 }
131 137
132 138 echo '<span class="item-meta final-quiz">' . esc_html__( 'Final', 'learnpress' ) . '</span>';
@@ -143,30 +149,33 @@
143 149 public function courses_top_bar() {
144 150 learn_press_get_template( 'courses-top-bar' );
145 151 }
146 152
153 + /**
154 + * Display price or free of course, not button, it is label.
155 + *
156 + * @return void
157 + * @since 4.0.0
158 + * @version 1.0.3
159 + */
147 160 public function course_pricing() {
148 - $can_show = true;
149 - $course = learn_press_get_course();
150 - $user = learn_press_get_current_user();
151 - $price_html = '';
161 + $course = learn_press_get_course();
162 + $user = learn_press_get_current_user();
152 163
153 - try {
154 - if ( $user && $user->has_enrolled_course( get_the_ID() ) ) {
155 - throw new Exception( 'User has enrolled course' );
164 + $courseModel = CourseModel::find( $course->get_id(), true );
165 + $can_purchase = $courseModel->can_purchase( UserModel::find( $user->get_id(), true ) );
166 + $userCourseModel = UserCourseModel::find( $user->get_id(), $course->get_id(), true );
167 + if ( get_current_user_id() ) {
168 + if ( $userCourseModel ) {
169 + if ( $userCourseModel->has_enrolled() ) {
170 + return;
171 + } elseif ( $can_purchase instanceof WP_Error ) {
172 + return;
173 + }
156 174 }
157 -
158 - $price_html = $course->get_course_price_html();
159 - } catch ( Throwable $e ) {
160 - $can_show = false;
161 175 }
162 176
163 - $can_show = apply_filters( 'learnpress/course/template/price/can-show', $can_show, $user, $course );
164 -
165 - if ( ! $can_show ) {
166 - return;
167 - }
168 -
177 + $price_html = $course->get_course_price_html();
169 178 learn_press_get_template( 'single-course/price', compact( 'course', 'user', 'price_html' ) );
170 179 }
171 180
172 181 /**
@@ -174,52 +183,18 @@
174 183 *
175 184 * @editor tungnx
176 185 * @modify 4.1.3.1
177 186 * @throws Exception
178 - * @version 4.0.1
187 + * @version 4.0.2
179 188 */
180 - public function course_purchase_button( $course ) {
181 - $can_show = true;
182 - if ( empty( $course ) ) {
183 - $course = learn_press_get_course();
184 - }
185 - $user = learn_press_get_current_user();
189 + public function course_purchase_button( $course = null ) {
190 + _deprecated_function( __METHOD__, '4.3.2', 'SingleCourseTemplate::html_btn_purchase_course' );
191 + return;
186 192
187 - try {
188 - if ( ! $user || ! $course ) {
189 - throw new Exception( 'User or Course is not exists' );
190 - }
191 -
192 - if ( ! $user->can_purchase_course( $course->get_id() ) ) {
193 - throw new Exception( 'You can not purchase course' );
194 - }
195 - } catch ( Throwable $e ) {
196 - $can_show = false;
197 - }
198 -
199 - $can_show = apply_filters( 'learnpress/course/template/button-purchase/can-show', $can_show, $user, $course );
200 -
201 - if ( ! $can_show ) {
202 - return;
203 - }
204 -
205 - $args_load_tmpl = array(
206 - 'template_name' => 'single-course/buttons/purchase.php',
207 - 'template_path' => '',
208 - 'default_path' => '',
209 - );
210 -
211 - $args_load_tmpl = apply_filters( 'learn-press/tmpl-button-purchase-course', $args_load_tmpl, $course );
212 -
213 - learn_press_get_template(
214 - $args_load_tmpl['template_name'],
215 - array(
216 - 'user' => $user,
217 - 'course' => $course,
218 - ),
219 - $args_load_tmpl['template_path'],
220 - $args_load_tmpl['default_path']
221 - );
193 + $singleCourseTemplate = SingleCourseTemplate::instance();
194 + $course = CourseModel::find( get_the_ID(), true );
195 + $user = UserModel::find( get_current_user_id(), true );
196 + echo $singleCourseTemplate->html_btn_purchase_course( $course, $user );
222 197 }
223 198
224 199 /**
225 200 * Show button enroll course
@@ -226,16 +201,26 @@
226 201 *
227 202 * @editor tungnx
228 203 * @modify 4.1.3.1
229 204 * @throws Exception
230 - * @version 4.0.2
205 + * @version 4.0.3
231 206 */
232 - public function course_enroll_button( $course ) {
207 + public function course_enroll_button( $course = null ) {
208 + _deprecated_function( __METHOD__, '4.3.2.4', 'SingleCourseTemplate::html_btn_enroll_course' );
209 + return;
210 +
211 + $singleCourseTemplate = SingleCourseTemplate::instance();
212 + $course = CourseModel::find( get_the_ID(), true );
213 + $user = UserModel::find( get_current_user_id(), true );
214 + echo $singleCourseTemplate->html_btn_enroll_course( $course, $user );
215 + return;
216 +
233 217 $can_show = true;
234 218 $user = learn_press_get_current_user();
235 219 if ( empty( $course ) ) {
236 220 $course = learn_press_get_course();
237 221 }
222 + $error_code = '';
238 223
239 224 try {
240 225 if ( ! $course || ! $user ) {
241 226 throw new Exception( 'User or Course is not exists' );
@@ -241,22 +226,28 @@
241 226 throw new Exception( 'User or Course is not exists' );
242 227 }
243 228
244 229 // User can not enroll course.
245 - if ( ! $user->can_enroll_course( $course->get_id() ) ) {
246 - throw new Exception( 'You can not enroll course' );
230 + $can_enroll_course = $user->can_enroll_course( $course->get_id(), false );
231 + if ( ! $can_enroll_course->check ) {
232 + $error_code = $can_enroll_course->code;
233 + throw new Exception( $can_enroll_course->message );
247 234 }
248 235
249 236 if ( $user->has_finished_course( $course->get_id() ) ) {
250 - throw new Exception( 'Course is finished' );
251 -
237 + $error_code = 'course_is_finished';
238 + throw new Exception( __( 'Course is finished', 'learnpress' ) );
252 239 }
253 240 } catch ( Throwable $e ) {
241 + if ( ! in_array( $error_code, [ 'course_is_enrolled', 'course_can_retry' ] ) ) {
242 + if ( $course && $course->is_free() ) {
243 + Template::print_message( $e->getMessage(), 'warning' );
244 + }
245 + }
254 246 $can_show = false;
255 247 }
256 248
257 249 $can_show = apply_filters( 'learnpress/course/template/button-enroll/can-show', $can_show, $user, $course );
258 -
259 250 if ( ! $can_show ) {
260 251 return;
261 252 }
262 253
@@ -269,8 +260,11 @@
269 260 }
270 261
271 262 public function course_extra_requirements( $course_id ) {
272 263 $course = LP_Course::get_course( $course_id );
264 + if ( ! $course ) {
265 + return;
266 + }
273 267
274 268 $requirements = apply_filters(
275 269 'learn-press/course-extra-requirements',
276 270 $course->get_extra_info( 'requirements' ),
@@ -292,8 +286,11 @@
292 286 }
293 287
294 288 public function course_extra_key_features( $course_id ) {
295 289 $course = LP_Course::get_course( $course_id );
290 + if ( ! $course ) {
291 + return;
292 + }
296 293
297 294 $key_features = apply_filters(
298 295 'learn-press/course-extra-key-features',
299 296 $course->get_extra_info( 'key_features' ),
@@ -315,8 +312,11 @@
315 312 }
316 313
317 314 public function course_extra_target_audiences( $course_id ) {
318 315 $course = LP_Course::get_course( $course_id );
316 + if ( ! $course ) {
317 + return;
318 + }
319 319
320 320 $target_audiences = apply_filters(
321 321 'learn-press/course-extra-target-audiences',
322 322 $course->get_extra_info( 'target_audiences' ),
@@ -340,61 +340,61 @@
340 340 /**
341 341 * Show template "continue" button con single course
342 342 *
343 343 * @throws Exception
344 - * @editor tungnx
345 344 * @modify 4.1.3.1
346 - * @version 4.0.2
345 + * @version 4.0.4
347 346 * @since 4.0.0
348 347 */
349 - public function course_continue_button( $course ) {
350 - $can_show = true;
351 - $user = learn_press_get_current_user();
352 - if ( empty( $course ) ) {
353 - $course = learn_press_get_course();
354 - }
348 + public static function course_continue_button( $args = [] ) {
349 + _deprecated_function( __METHOD__, '4.3.2.4', 'UserCourseTemplate::html_btn_continue' );
350 + return;
355 351
352 + $course_id_param = $args['course-id'] ?? 0;
353 + $course_id = ! empty( $course_id_param ) ? $course_id_param : get_the_ID();
354 + $courseModel = CourseModel::find( $course_id, true );
355 + $user_id = get_current_user_id();
356 +
356 357 try {
357 - if ( ! $user || ! $course ) {
358 + if ( ! $user_id || ! $courseModel ) {
358 359 throw new Exception( 'User or Course not exists!' );
359 360 }
360 361
361 - if ( ! $user->has_enrolled_course( $course->get_id() ) ) {
362 - throw new Exception( 'User has not enrolled course' );
362 + $userCourseModel = UserCourseModel::find( $user_id, $courseModel->get_id(), true );
363 + if ( ! $userCourseModel || ! $userCourseModel->has_enrolled() ) {
364 + throw new Exception( 'User not enrolled course' );
363 365 }
364 366
365 - if ( $user->has_finished_course( $course->get_id() ) ) {
367 + if ( $userCourseModel->has_finished() ) {
366 368 throw new Exception( 'User has finished course' );
367 369 }
368 370
369 371 // Course has no items
370 - if ( empty( $course->count_items() ) ) {
372 + if ( empty( $courseModel->get_total_items() ) ) {
371 373 throw new Exception( 'Course no any item' );
372 374 }
373 375
374 376 // Do not display continue button if course is block duration
375 - if ( $user->can_view_content_course( $course->get_id() )->key === LP_BLOCK_COURSE_DURATION_EXPIRE ) {
377 + if ( $userCourseModel->timestamp_remaining_duration() === 0 ) {
376 378 throw new Exception( 'Course is blocked' );
377 379 }
380 +
381 + $section = [
382 + 'start' => '<div>',
383 + 'link' => UserCourseTemplate::instance()->html_btn_continue( $userCourseModel ),
384 + 'end' => '</div>',
385 + ];
386 +
387 + echo Template::combine_components( $section );
378 388 } catch ( Throwable $e ) {
379 - $can_show = false;
380 - }
381 389
382 - $can_show = apply_filters( 'learnpress/course/template/button-continue/can-show', $can_show, $user, $course );
383 -
384 - if ( ! $can_show ) {
385 - return;
386 390 }
391 + }
387 392
388 - $args = array(
389 - 'user' => $user,
390 - 'course' => $course,
391 - );
393 + public function course_finish_button( $course = null ) {
394 + _deprecated_function( __METHOD__, '4.3.2.4', 'UserCourseTemplate::html_btn_finish' );
395 + return;
392 396
393 - learn_press_get_template( 'single-course/buttons/continue.php', $args );
394 - }
395 -
396 - public function course_finish_button( $course ) {
397 397 $user = learn_press_get_current_user();
398 398 if ( empty( $course ) ) {
399 399 $course = learn_press_get_course();
400 400 }
@@ -429,9 +429,12 @@
429 429 * @throws Exception
430 430 * @editor tungnx
431 431 * @modify 4.1.3
432 432 */
433 - public function course_external_button( $course ) {
433 + public function course_external_button( $course = null ) {
434 + _deprecated_function( __METHOD__, '4.3.2.4', 'SingleCourseTemplate::html_btn_external' );
435 + return;
436 +
434 437 if ( empty( $course ) ) {
435 438 $course = learn_press_get_course();
436 439 }
437 440
@@ -449,10 +452,11 @@
449 452 $user = learn_press_get_current_user();
450 453
451 454 if ( $user && ! $user->has_enrolled_or_finished( $course->get_id() ) ) {
452 455 // Remove all another buttons
453 - learn_press_remove_course_buttons();
456 + // learn_press_remove_course_buttons();
454 457 learn_press_get_template( 'single-course/buttons/external-link.php' );
458 +
455 459 // Add back other buttons for other courses
456 460 add_action( 'learn-press/after-course-buttons', 'learn_press_add_course_buttons' );
457 461 }
458 462 }
@@ -469,9 +473,9 @@
469 473 $total_items = 0;
470 474 $completed_items = 0;
471 475 $course_data = $user->get_course_data( $course->get_id() );
472 476
473 - if ( $course_data && ! $course->is_no_required_enroll() ) {
477 + if ( $course_data && ! empty( $course_data->get_user_id() ) && ! $course->is_no_required_enroll() ) {
474 478 $course_results = $course_data->get_result();
475 479 $completed_items = $course_results['completed_items'];
476 480 $total_items = $course_results['count_items'];
477 481 $percentage = $course_results['count_items'] ? absint( $course_results['completed_items'] / $course_results['count_items'] * 100 ) : 0;
@@ -533,35 +537,62 @@
533 537 )
534 538 );
535 539 }
536 540
541 + /**
542 + * Display course curriculum.
543 + *
544 + * @since 4.1.6
545 + * @since 4.2.5.5 remove code load old template user for course curriculum load page instead of via AJAX.
546 + * @version 1.0.2
547 + * @depreacted 4.2.8.7.1
548 + */
537 549 public function course_curriculum() {
538 - if ( ! learn_press_override_templates() || ( learn_press_override_templates() && has_filter( 'lp/template-course/course_curriculum/skeleton' ) ) ) {
539 - $course_item = LP_Global::course_item();
550 + /**
551 + * @var CourseModel $lpCourseModel
552 + */
553 + global $lpCourseModel;
554 + $courseModel = CourseModel::find( get_the_ID(), true );
555 + if ( $lpCourseModel instanceof CourseModel ) {
556 + $courseModel = $lpCourseModel;
557 + }
540 558
541 - if ( $course_item ) { // Check if current item is viewable
542 - $item_id = $course_item->get_id();
543 - $section_id = LP_Section_DB::getInstance()->get_section_id_by_item_id( absint( $item_id ) );
559 + $course_item = LP_Global::course_item();
560 + $userModel = UserModel::find( get_current_user_id(), true );
561 +
562 + $singleCourseTemplate = SingleCourseTemplate::instance();
563 + echo $singleCourseTemplate->html_curriculum( $courseModel, $userModel );
564 + }
565 +
566 + /**
567 + * Display course curriculum.
568 + *
569 + * @since 4.1.6
570 + * @since 4.2.5.5 remove code load old template user for course curriculum load page instead of via AJAX.
571 + * @version 1.0.2
572 + */
573 + public function course_curriculum_bk() {
574 + /**
575 + * @var CourseModel $lpCourseModel
576 + */
577 + global $lpCourseModel;
578 + $course_item = LP_Global::course_item();
579 +
580 + if ( $course_item ) { // Check if current item is viewable
581 + $course_id = 0;
582 + if ( $lpCourseModel ) {
583 + $course_id = $lpCourseModel->get_id();
544 584 }
545 - ?>
546 - <div class="learnpress-course-curriculum" data-section="<?php echo esc_attr( $section_id ?? '' ); ?>"
547 - data-id="<?php echo esc_attr( $item_id ?? '' ); ?>">
548 - <ul class="lp-skeleton-animation">
549 - <li style="width: 100%; height: 50px"></li>
550 - <li style="width: 100%; height: 20px"></li>
551 - <li style="width: 100%; height: 20px"></li>
552 - <li style="width: 100%; height: 20px"></li>
553 585
554 - <li style="width: 100%; height: 50px; margin-top: 40px;"></li>
555 - <li style="width: 100%; height: 20px"></li>
556 - <li style="width: 100%; height: 20px"></li>
557 - <li style="width: 100%; height: 20px"></li>
558 - </ul>
559 - </div>
560 - <?php
561 - } else {
562 - learn_press_get_template( 'single-course/tabs/curriculum' );
586 + $item_id = (int) $course_item->get_id();
587 + $section_id = LP_Section_DB::getInstance()->get_section_id_by_item_id( $item_id, $course_id );
563 588 }
589 + ?>
590 + <div class="learnpress-course-curriculum" data-section="<?php echo esc_attr( $section_id ?? '' ); ?>"
591 + data-id="<?php echo esc_attr( $item_id ?? '' ); ?>">
592 + <?php lp_skeleton_animation_html( 10 ); ?>
593 + </div>
594 + <?php
564 595 }
565 596
566 597 /**
567 598 * Get template content item's course
@@ -618,9 +649,9 @@
618 649 $shortcodes_custom_css = get_post_meta( $item->get_id(), '_wpb_shortcodes_custom_css', true );
619 650
620 651 if ( ! empty( $shortcodes_custom_css ) ) {
621 652 $shortcodes_custom_css = strip_tags( $shortcodes_custom_css );
622 - echo '<style type="text/css" data-type="vc_shortcodes-custom-css">';
653 + echo '<style data-type="vc_shortcodes-custom-css">';
623 654 echo wp_kses_post( $shortcodes_custom_css );
624 655 echo '</style>';
625 656 }
626 657 // End
@@ -664,30 +695,12 @@
664 695 return;
665 696 }
666 697 do_action( 'learn-press/lesson-start', $item );
667 698
668 - learn_press_get_template( 'content-lesson/content.php', array( 'lesson' => $item ) );
699 + Template::instance()->get_frontend_template( 'content-lesson/content.php', array( 'lesson' => $item ) );
669 700 }
670 701
671 702 /**
672 - * @depecated 4.1.7.2
673 - */
674 - public function item_quiz_content() {
675 - $item = LP_Global::course_item();
676 -
677 - learn_press_get_template( 'content-quiz/js.php' );
678 - }
679 -
680 - /**
681 - * @depecated 4.1.7.2
682 - */
683 - public function item_lesson_content_blocked() {
684 - $item = LP_Global::course_item();
685 -
686 - learn_press_get_template( 'global/block-content.php' );
687 - }
688 -
689 - /**
690 703 * Get template button complete lesson
691 704 */
692 705 public function item_lesson_complete_button() {
693 706 $user = learn_press_get_current_user();
@@ -719,43 +732,25 @@
719 732 error_log( $e->getMessage() );
720 733 }
721 734 }
722 735
723 - /**
724 - * @depecated 4.1.6.9
725 - */
726 - /*public function lesson_comment_form() {
727 - $course = learn_press_get_course();
728 - if ( ! $course ) {
729 - return;
736 + public function item_lesson_material() {
737 + try {
738 + do_action( 'learn-press/course-material/layout', [] );
739 + } catch ( Throwable $e ) {
740 + error_log( $e->getMessage() );
730 741 }
742 + }
731 743
732 - $lesson = LP_Global::course_item();
733 - if ( ! $lesson ) {
734 - return;
735 - }
736 -
737 - if ( $lesson->setup_postdata() ) {
738 -
739 - if ( comments_open() || get_comments_number() ) {
740 - add_filter( 'deprecated_file_trigger_error', '__return_false' );
741 - comments_template();
742 - remove_filter( 'deprecated_file_trigger_error', '__return_false' );
743 - }
744 - $lesson->reset_postdata();
745 - }
746 - }*/
747 -
748 744 /**
749 745 * Template show count items
750 746 *
751 747 * @since 4.0.0
752 - * @version 1.0.1
748 + * @version 1.0.2
753 749 * @editor tungnx
754 750 */
755 751 public function count_object() {
756 - $course = learn_press_get_course();
757 -
752 + $course = CourseModel::find( get_the_ID(), true );
758 753 if ( ! $course ) {
759 754 return;
760 755 }
761 756
@@ -794,9 +789,13 @@
794 789 }
795 790
796 791 public function course_extra_boxes() {
797 792 $course = LP_Course::get_course( get_the_ID() );
798 - $boxes = apply_filters(
793 + if ( ! $course ) {
794 + return;
795 + }
796 +
797 + $boxes = apply_filters(
799 798 'learn-press/course-extra-boxes-data',
800 799 array(
801 800 array(
802 801 'title' => __( 'Requirements', 'learnpress' ),
@@ -826,10 +825,13 @@
826 825 }
827 826
828 827 learn_press_get_template( 'single-course/extra-info', $box );
829 828 }
829 + }
830 830
831 - }
831 + /*public function metarials() {
832 + echo wp_kses_post( do_shortcode( '[learn_press_course_materials]' ) );
833 + }*/
832 834
833 835 public function faqs() {
834 836 $course = LP_Course::get_course( get_the_ID() );
835 837 $faqs = $course->get_faqs();
@@ -841,9 +843,10 @@
841 843 learn_press_get_template( 'single-course/tabs/faqs', $faq );
842 844 }
843 845 }
844 846
845 - public function sidebar() { }
847 + public function sidebar() {
848 + }
846 849
847 850 public function course_featured_review() {
848 851 $review_content = get_post_meta( $this->course->get_id(), '_lp_featured_review', true );
849 852
@@ -869,20 +872,8 @@
869 872 )
870 873 );
871 874 }
872 875
873 - /**
874 - * @depecated 4.1.7.2
875 - */
876 - /*public function instructor_socials() {
877 - $instructor = $this->course->get_instructor();
878 - $socials = $instructor->get_profile_socials( $instructor->get_id() );
879 -
880 - foreach ( $socials as $social ) {
881 - echo wp_kses_post( $social );
882 - }
883 - }*/
884 -
885 876 public function has_sidebar() {
886 877 $actions = array(
887 878 'learn-press/before-course-summary-sidebar',
888 879 'learn-press/course-summary-sidebar',
@@ -918,14 +909,15 @@
918 909 if ( ! $item ) {
919 910 return;
920 911 }
921 912
922 - $user = learn_press_get_current_user();
913 + $user = learn_press_get_current_user();
914 + $user_can_view_course = $user->can_view_content_course( $course->get_id() );
915 + $user_can_view_item = $user->can_view_item( $item->get_id(), $user_can_view_course );
916 + if ( ! $user_can_view_item->flag ) {
917 + return;
918 + }
923 919
924 - // if ( ! $user->is_admin() && ! $user->has_course_status( $course->get_id(), array( 'enrolled', 'finished' ) ) ) {
925 - // return;
926 - // }
927 -
928 920 if ( $item->setup_postdata() ) {
929 921
930 922 if ( comments_open() || get_comments_number() ) {
931 923 learn_press_get_template( 'single-course/item-comments' );
@@ -933,11 +925,10 @@
933 925 $item->reset_postdata();
934 926 }
935 927 }
936 928
929 +
937 930 public function course_comment_template() {
938 - global $post;
939 -
940 931 if ( comments_open() || get_comments_number() ) {
941 932 add_filter( 'deprecated_file_trigger_error', '__return_false' );
942 933 comments_template();
943 934 remove_filter( 'deprecated_file_trigger_error', '__return_false' );
@@ -947,10 +938,13 @@
947 938 /**
948 939 * Show info time handle of user
949 940 *
950 941 * @throws Exception
942 + * @deprecated 4.4.0
951 943 */
952 944 public function user_time() {
945 + _deprecated_function( __METHOD__, '4.4.0' );
946 + return;
953 947 $user = learn_press_get_current_user();
954 948
955 949 if ( ! $user ) {
956 950 return;
@@ -972,12 +966,18 @@
972 966 $status = $user_course->get_status();
973 967 $start_time = $user_course->get_start_time();
974 968 $end_time = $user_course->get_end_time();
975 969 $expiration_time = $user_course->get_expiration_time();
970 + $data = [
971 + 'status' => $status,
972 + 'start_time' => $start_time,
973 + 'end_time' => $end_time,
974 + 'expiration_time' => $expiration_time,
975 + ];
976 976
977 977 learn_press_get_template(
978 978 'single-course/sidebar/user-time',
979 - compact( 'status', 'start_time', 'end_time', 'expiration_time' )
979 + compact( 'data' )
980 980 );
981 981 }
982 982
983 983 /**
@@ -988,26 +988,19 @@
988 988 * @throws Exception
989 989 * @author Nhamdv.
990 990 */
991 991 public function user_progress() {
992 - if ( ! is_user_logged_in() ) {
992 + $courseModel = CourseModel::find( get_the_ID(), true );
993 + if ( ! $courseModel ) {
993 994 return;
994 995 }
995 996
996 - $course = learn_press_get_course();
997 - $user = learn_press_get_current_user();
997 + $userModel = UserModel::find( get_current_user_id(), true );
998 + echo SingleCourseModernLayout::instance()->html_info_learning( $courseModel, $userModel );
998 999
999 - if ( ! $course ) {
1000 - return;
1001 - }
1002 -
1003 - if ( ! $user->has_enrolled_or_finished( $course->get_id() ) ) {
1004 - return;
1005 - }
1006 -
1007 - if ( LP_LAZY_LOAD_ANIMATION ) {
1000 + /*if ( LP_LAZY_LOAD_ANIMATION ) {
1008 1001 echo '<div class="lp-course-progress-wrapper">';
1009 - echo lp_skeleton_animation_html( 3 );
1002 + lp_skeleton_animation_html();
1010 1003 echo '</div>';
1011 1004 } else {
1012 1005 $course_data = $user->get_course_data( $course->get_id() );
1013 1006 if ( ! $course_data ) {
@@ -1019,9 +1012,9 @@
1019 1012 learn_press_get_template(
1020 1013 'single-course/sidebar/user-progress',
1021 1014 compact( 'user', 'course', 'course_data', 'course_results' )
1022 1015 );
1023 - }
1016 + }*/
1024 1017 }
1025 1018
1026 1019 public function course_extra_boxes_position_control() {
1027 1020 $course = LP_Course::get_course( get_the_ID() );