PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.3.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.3.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 4.2.1 All 138 releases
learnpress / templates / content-lesson / button-complete.php

button-complete.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.3.8, at templates/content-lesson/button-complete.php

76 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Template for displaying complete button in content lesson.
4 *
5 * This template can be overridden by copying it to yourtheme/learnpress/content-lesson/button-complete.php.
6 *
7 * @author ThimPress
8 * @package Learnpress/Templates
9 * @version 4.0.5
10 */
11
12 defined( 'ABSPATH' ) || exit();
13
14 if ( ! isset( $item ) || ! isset( $user ) || ! isset( $course ) ) {
15 return;
16 }
17
18 if ( $item->is_preview() && ! $user->has_enrolled_course( $course->get_id() ) ) {
19 return;
20 }
21
22 $message_confirm_complete_item = sprintf(
23 '%s "%s"?',
24 __( 'Do you want to complete the lesson', 'learnpress' ),
25 $item->get_title()
26 );
27 $completed = $user->has_completed_item( $item->get_id(), $course->get_id() );
28
29 if ( $completed ) :
30 $user_item_data = $user->get_item_data( $item->get_id(), $course->get_id() );
31 if ( empty( $user_item_data ) ) {
32 return;
33 }
34 ?>
35 <div class="learn-press-message success">
36 <?php
37 echo sprintf(
38 '%s %s',
39 esc_html__( 'You have completed this lesson at ', 'learnpress' ),
40 $user_item_data->get_end_time()->format( LP_Datetime::I18N_FORMAT_HAS_TIME )
41 )
42 ?>
43 </div>
44 <button class="lp-button completed" disabled>
45 <i class="lp-icon-check"></i><?php esc_html_e( 'Completed', 'learnpress' ); ?>
46 </button>
47 <?php
48 else :
49 $item_id_next = $course->get_next_item();
50 /**
51 * @use LessonAjax::user_complete_lesson
52 */
53 ?>
54 <form method="post" name="learn-press-form-complete-lesson"
55 action="<?php echo add_query_arg( [ 'complete-lesson' => '' ], LP_Settings::url_handle_lp_ajax() ); ?>"
56 class="learn-press-form form-button <?php echo esc_attr( $completed ) ? 'completed' : ''; ?>"
57 data-title="<?php echo esc_attr( __( 'Complete lesson', 'learnpress' ) ); ?>"
58 data-confirm="<?php echo esc_attr( $message_confirm_complete_item ); ?>">
59
60 <?php do_action( 'learn-press/lesson/before-complete-button' ); ?>
61
62 <input type="hidden" name="lesson_id" value="<?php echo esc_attr( $item->get_id() ); ?>"/>
63 <input type="hidden" name="course_id" value="<?php echo esc_attr( $course->get_id() ); ?>"/>
64 <input type="hidden" name="nonce"
65 value="<?php echo wp_create_nonce( 'wp_rest' ); ?>"/>
66 <input type="hidden" name="lp-load-ajax" value="user_complete_lesson"/>
67 <button class="lp-button button-complete-lesson lp-btn-complete-item"
68 type="submit">
69 <?php echo esc_html__( 'Complete', 'learnpress' ); ?>
70 </button>
71
72 <?php do_action( 'learn-press/lesson/after-complete-button' ); ?>
73
74 </form>
75 <?php endif; ?>
76