PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
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 4.2.0 All 139 releases
← All changes | inc/TemplateHooks/Course/SingleCourseModernLayout.php +75 -42 4.3.74.4.8 View file →
@@ -15,8 +15,9 @@
15 15 use LearnPress\Models\UserItems\UserItemModel;
16 16 use LearnPress\TemplateHooks\UserItem\UserCourseTemplate;
17 17 use LearnPress\Models\UserModel;
18 18 use LearnPress\TemplateHooks\Instructor\SingleInstructorTemplate;
19 +use LP_Datetime;
19 20
20 21 class SingleCourseModernLayout {
21 22 use Singleton;
22 23
@@ -24,9 +25,9 @@
24 25 * @var SingleCourseTemplate
25 26 */
26 27 public $singleCourseTemplate;
27 28
28 - public function init() {
29 + public function init(): void {
29 30 $this->singleCourseTemplate = SingleCourseTemplate::instance();
30 31
31 32 add_action(
32 33 'learn-press/single-course/layout',
@@ -52,13 +53,8 @@
52 53 ob_start();
53 54 do_action( 'learn-press/single-course/courses-related/layout', $course, 4 );
54 55 $html_courses_related = ob_get_clean();
55 56
56 - // Global message
57 - ob_start();
58 - learn_press_show_message();
59 - $global_message = ob_get_clean();
60 -
61 57 $sections = apply_filters(
62 58 'learn-press/single-course/modern/sections',
63 59 [
64 60 'wrapper' => '<div class="lp-single-course">',
@@ -64,9 +60,8 @@
64 60 'wrapper' => '<div class="lp-single-course">',
65 61 'section_header' => $this->header_sections( $course, $user ),
66 62 'wrapper_container' => '<div class="lp-content-area">',
67 63 'wrapper_main' => '<div class="lp-single-course-main">',
68 - 'global_message' => $global_message,
69 64 'section_left' => $this->section_left( $course, $user ),
70 65 'section_right' => $this->section_right( $course, $user ),
71 66 'wrapper_main_end' => '</div>',
72 67 'related_courses' => $html_courses_related,
@@ -90,9 +85,9 @@
90 85 $html_categories = $this->singleCourseTemplate->html_categories( $course );
91 86 if ( ! empty( $html_categories ) ) {
92 87 $html_categories = sprintf(
93 88 '<div>%s %s</div>',
94 - sprintf( '<label>%s</label>', __( 'in', 'learnpress' ) ),
89 + sprintf( '<label>%s</label>', esc_html__( 'in', 'learnpress' ) ),
95 90 $html_categories
96 91 );
97 92 }
98 93
@@ -122,9 +117,9 @@
122 117 }
123 118
124 119 $html_instructor = sprintf(
125 120 '<div>%s %s</div>',
126 - sprintf( '<label>%s</label>', __( 'by', 'learnpress' ) ),
121 + sprintf( '<label>%s</label>', esc_html__( 'by', 'learnpress' ) ),
127 122 $this->singleCourseTemplate->html_instructor( $course )
128 123 );
129 124
130 125 $header_sections = apply_filters(
@@ -157,12 +152,18 @@
157 152 *
158 153 * @return string
159 154 */
160 155 public function section_left( $course, $user ): string {
156 + // Global message
157 + ob_start();
158 + learn_press_show_message();
159 + $global_message = ob_get_clean();
160 +
161 161 $section = apply_filters(
162 162 'learn-press/single-course/modern/section_left',
163 163 [
164 164 'wrapper' => '<div class="lp-single-course-main__left">',
165 + 'global_message' => $global_message,
165 166 'description' => $this->singleCourseTemplate->html_description( $course ),
166 167 'features' => $this->singleCourseTemplate->html_features( $course ),
167 168 'target' => $this->singleCourseTemplate->html_target( $course ),
168 169 'requirements' => $this->singleCourseTemplate->html_requirements( $course ),
@@ -198,25 +199,25 @@
198 199 $userCourseModel = UserCourseModel::find( $user_id, $course->get_id(), true );
199 200
200 201 $data_info_meta = [
201 202 'student' => [
202 - 'label' => sprintf( '<i class="lp-icon-user-graduate"></i>%s:', __( 'Student', 'learnpress' ) ),
203 + 'label' => sprintf( '<i class="lp-icon-user-graduate"></i>%s:', esc_html__( 'Student', 'learnpress' ) ),
203 204 'value' => $this->singleCourseTemplate->html_count_student( $course ),
204 205 ],
205 206 'lesson' => [
206 - 'label' => sprintf( '<i class="lp-icon-file-o"></i>%s:', __( 'Lesson', 'learnpress' ) ),
207 + 'label' => sprintf( '<i class="lp-icon-file-o"></i>%s:', esc_html__( 'Lesson', 'learnpress' ) ),
207 208 'value' => $this->singleCourseTemplate->html_count_item( $course, LP_LESSON_CPT ),
208 209 ],
209 210 'duration' => [
210 - 'label' => sprintf( '<i class="lp-icon-clock-o"></i>%s:', __( 'Duration', 'learnpress' ) ),
211 + 'label' => sprintf( '<i class="lp-icon-clock-o"></i>%s:', esc_html__( 'Duration', 'learnpress' ) ),
211 212 'value' => $this->singleCourseTemplate->html_duration( $course ),
212 213 ],
213 214 'quiz' => [
214 - 'label' => sprintf( '<i class="lp-icon-puzzle-piece"></i>%s:', __( 'Quiz', 'learnpress' ) ),
215 + 'label' => sprintf( '<i class="lp-icon-puzzle-piece"></i>%s:', esc_html__( 'Quiz', 'learnpress' ) ),
215 216 'value' => $this->singleCourseTemplate->html_count_item( $course, LP_QUIZ_CPT ),
216 217 ],
217 218 'level' => [
218 - 'label' => sprintf( '<i class="lp-icon-signal"></i>%s:', __( 'Level', 'learnpress' ) ),
219 + 'label' => sprintf( '<i class="lp-icon-signal"></i>%s:', esc_html__( 'Level', 'learnpress' ) ),
219 220 'value' => $this->singleCourseTemplate->html_level( $course ),
220 221 ],
221 222 ];
222 223
@@ -340,12 +341,12 @@
340 341 $html_social .= sprintf(
341 342 '<li>
342 343 <a target="_blank" href="%s" title="%s">%s<span>%s</span></a>
343 344 </li>',
344 - $social['url'],
345 - $social['label'],
346 - $social['icon'],
347 - $social['label']
345 + esc_url_raw( $social['url'] ?? '' ),
346 + esc_attr( $social['label'] ?? '' ),
347 + Template::sanitize_html_content( $social['icon'] ?? '' ),
348 + esc_html( $social['label'] ?? '' )
348 349 );
349 350 }
350 351 } else {
351 352 return '';
@@ -361,12 +362,15 @@
361 362 );
362 363
363 364 $clipboard = [
364 365 'wrapper' => '<div class="clipboard-post">',
365 - 'input' => sprintf( '<input class="clipboard-value" type="text" value="%s">', $courseModel->get_permalink() ),
366 + 'input' => sprintf(
367 + '<input class="clipboard-value" type="text" value="%s">',
368 + esc_url( $courseModel->get_permalink() )
369 + ),
366 370 'button' => sprintf(
367 371 '<button class="btn-clipboard" data-copied="%s">%s<span class="tooltip">%s</span></button>',
368 - esc_html__( 'Copied!', 'learnpress' ),
372 + esc_attr__( 'Copied!', 'learnpress' ),
369 373 esc_html__( 'Copy', 'learnpress' ),
370 374 esc_html__( 'Copy to Clipboard', 'learnpress' )
371 375 ),
372 376 'wrapper_end' => '</div>',
@@ -376,9 +380,13 @@
376 380 'learn-press/single-course/social-share/sections',
377 381 [
378 382 'wrapper' => '<div class="social-swapper social-share-toggle">',
379 383 'toggle' => '<div class="share-toggle-icon">',
380 - 'toggle_icon' => sprintf( '<i class="lp-icon-share-alt"></i><label class="share-label">%s</label>', __( 'Share', 'learnpress' ) ),
384 + 'toggle_icon' => sprintf(
385 + '<i class="lp-icon-share-alt"></i>
386 + <label class="share-label">%s</label>',
387 + esc_html__( 'Share', 'learnpress' )
388 + ),
381 389 'toggle_end' => '</div>',
382 390 'wrapper_content' => '<div class="wrapper-content-widget">',
383 391 'wrapper_content_inner' => '<div class="content-widget-social-share">',
384 392 'clipboard' => Template::combine_components( $clipboard ),
@@ -414,10 +422,10 @@
414 422 }
415 423
416 424 $html_instructor_image = sprintf(
417 425 '<a href="%s" title="%s">%s</a>',
418 - $author->get_url_instructor(),
419 - $author->get_display_name(),
426 + esc_url( $author->get_url_instructor() ),
427 + esc_attr( $author->get_display_name() ),
420 428 $singleInstructorTemplate->html_avatar( $author )
421 429 );
422 430 $section_instructor_meta = [
423 431 'wrapper' => '<div class="lp-instructor-meta">',
@@ -436,9 +444,9 @@
436 444 [
437 445 'wrapper' => '<div class="lp-section-instructor">',
438 446 'name' => sprintf(
439 447 '<a href="%s">%s</a>',
440 - $author->get_url_instructor(),
448 + esc_url( $author->get_url_instructor() ),
441 449 $singleInstructorTemplate->html_display_name( $author )
442 450 ),
443 451 'meta' => Template::combine_components( $section_instructor_meta ),
444 452 'description' => $singleInstructorTemplate->html_description( $author ),
@@ -451,9 +459,12 @@
451 459 $section_instructor = apply_filters(
452 460 'learn-press/single-course/modern/section-instructor',
453 461 [
454 462 'wrapper' => '<div class="lp-section-instructor">',
455 - 'header' => sprintf( '<h3 class="section-title">%s</h3>', __( 'Instructor', 'learnpress' ) ),
463 + 'header' => sprintf(
464 + '<h3 class="section-title">%s</h3>',
465 + esc_html__( 'Instructor', 'learnpress' )
466 + ),
456 467 'wrapper_info' => '<div class="lp-instructor-info">',
457 468 'image' => $html_instructor_image,
458 469 'instructor_right' => Template::combine_components( $section_instructor_right ),
459 470 'wrapper_info_end' => '</div>',
@@ -464,9 +475,14 @@
464 475 );
465 476
466 477 if ( ! has_filter( 'learn-press/single-course/modern/section-instructor' ) ) {
467 478 // Do not use this hook, this hook only for handle hook without update from Addon, when handle on Addon, will remove this hook
468 - $section_instructor = apply_filters( 'learn-press/single-course/offline/section-instructor', $section_instructor, $course, $user );
479 + $section_instructor = apply_filters(
480 + 'learn-press/single-course/offline/section-instructor',
481 + $section_instructor,
482 + $course,
483 + $user
484 + );
469 485 }
470 486
471 487 return Template::combine_components( $section_instructor );
472 488 }
@@ -478,9 +494,9 @@
478 494 * @param UserModel|false $user
479 495 *
480 496 * @return string
481 497 * @since 4.2.8.3
482 - * @version 1.0.1
498 + * @version 1.0.2
483 499 */
484 500 public function html_info_learning( CourseModel $course, $user = false ): string {
485 501 $html_info_learning = '';
486 502 $user_id = 0;
@@ -496,32 +512,49 @@
496 512 && $userCourseModel->get_status() !== UserCourseModel::STATUS_PURCHASED ) {
497 513 $userCourseTemplate = UserCourseTemplate::instance();
498 514 $html_end_date = '';
499 515 $html_graduation = '';
516 + $html_will_end_date = '';
500 517
501 518 if ( $userCourseModel->has_finished() ) {
502 519 $html_end_date = sprintf(
503 520 '<div class="end-date">%s: %s</div>',
504 - __( 'End date', 'learnpress' ),
521 + esc_html__( 'End date', 'learnpress' ),
505 522 $userCourseTemplate->html_end_date_time( $userCourseModel, false )
506 523 );
507 524 $html_graduation = $userCourseTemplate->html_graduation( $userCourseModel );
525 + } else {
526 + $started_date = $userCourseModel->get_start_time();
527 + $duration = $course->get_duration();
528 + $will_end_date = new LP_Datetime( strtotime( "+ $duration", strtotime( $started_date ) ) );
529 + $will_end_date = $will_end_date->format( LP_Datetime::I18N_FORMAT );
530 + $html_will_end_date = sprintf(
531 + '<div class="will-end-date">%s: %s</div>',
532 + esc_html__( 'Expiry date', 'learnpress' ),
533 + $will_end_date
534 + );
508 535 }
509 536
510 - $section_info_learning = [
511 - 'wrapper' => '<div class="info-learning">',
512 - 'message_lock' => $userCourseTemplate->html_message_lock( $userCourseModel ),
513 - 'graduation' => $html_graduation,
514 - 'progress' => $userCourseTemplate->html_progress( $userCourseModel ),
515 - 'start_date' => sprintf(
516 - '<div class="start-date">%s: %s</div>',
517 - __( 'Start date', 'learnpress' ),
518 - $userCourseTemplate->html_start_date_time( $userCourseModel, false )
519 - ),
520 - 'end_date' => $html_end_date,
521 - 'count_items_completed' => $userCourseTemplate->html_count_items_completed( $userCourseModel ),
522 - 'wrapper_end' => '</div>',
523 - ];
537 + $section_info_learning = apply_filters(
538 + 'learn-press/single-course/modern/section-info-learning',
539 + [
540 + 'wrapper' => '<div class="info-learning">',
541 + 'message_lock' => $userCourseTemplate->html_message_lock( $userCourseModel ),
542 + 'graduation' => $html_graduation,
543 + 'progress' => $userCourseTemplate->html_progress( $userCourseModel ),
544 + 'start_date' => sprintf(
545 + '<div class="start-date">%s: %s</div>',
546 + esc_html__( 'Start date', 'learnpress' ),
547 + $userCourseTemplate->html_start_date_time( $userCourseModel, false )
548 + ),
549 + 'will_end_date' => $html_will_end_date,
550 + 'end_date' => $html_end_date,
551 + 'count_items_completed' => $userCourseTemplate->html_count_items_completed( $userCourseModel ),
552 + 'wrapper_end' => '</div>',
553 + ],
554 + $course,
555 + $user
556 + );
524 557
525 558 $html_info_learning = Template::combine_components( $section_info_learning );
526 559 }
527 560