| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for displaying loop course of section. |
| 4 |
* |
| 5 |
* This template can be overridden by copying it to yourtheme/learnpress/single-course/loop-section.php. |
| 6 |
* |
| 7 |
* @author ThimPress |
| 8 |
* @package Learnpress/Templates |
| 9 |
* @version 4.0.2 |
| 10 |
*/ |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit(); |
| 13 |
|
| 14 |
/** |
| 15 |
* @var LP_Course_Section $section |
| 16 |
*/ |
| 17 |
if ( ! isset( $section ) || ! isset( $can_view_content_course ) |
| 18 |
|| ! isset( $user_course ) || ! isset( $user ) ) { |
| 19 |
return; |
| 20 |
} |
| 21 |
|
| 22 |
$course = learn_press_get_the_course(); |
| 23 |
|
| 24 |
if ( ! apply_filters( 'learn-press/section-visible', true, $section, $course ) ) { |
| 25 |
return; |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* List items of section |
| 30 |
* |
| 31 |
* @var LP_Course_Item[] |
| 32 |
*/ |
| 33 |
$items = $section->get_items(); |
| 34 |
?> |
| 35 |
|
| 36 |
<li <?php $section->main_class(); ?> |
| 37 |
id="section-<?php echo esc_attr( $section->get_slug() ); ?>" |
| 38 |
data-id="<?php echo esc_attr( $section->get_slug() ); ?>" |
| 39 |
data-section-id="<?php echo esc_attr( $section->get_id() ); ?>"> |
| 40 |
<?php do_action( 'learn-press/before-section-summary', $section, $course->get_id() ); ?> |
| 41 |
|
| 42 |
<div class="section-header"> |
| 43 |
<div class="section-left"> |
| 44 |
<h5 class="section-title"> |
| 45 |
<?php |
| 46 |
$title = $section->get_title(); |
| 47 |
echo wp_kses_post( ! $title ? _x( 'Untitled', 'template title empty', 'learnpress' ) : $title ); |
| 48 |
?> |
| 49 |
|
| 50 |
<?php $description = $section->get_description(); ?> |
| 51 |
|
| 52 |
<?php if ( $description ) : ?> |
| 53 |
<p class="section-desc"><?php echo wp_kses_post( $description ); ?></p> |
| 54 |
<?php endif; ?> |
| 55 |
</h5> |
| 56 |
|
| 57 |
<span class="section-toggle"> |
| 58 |
<i class="fas fa-caret-down"></i> |
| 59 |
<i class="fas fa-caret-up"></i> |
| 60 |
</span> |
| 61 |
</div> |
| 62 |
|
| 63 |
<?php if ( $user->has_enrolled_or_finished( $section->get_course_id() ) ) : ?> |
| 64 |
<?php $percent = $user_course->get_percent_completed_items( '', $section->get_id() ); ?> |
| 65 |
|
| 66 |
<div class="section-meta"> |
| 67 |
<div class="learn-press-progress" title="<?php echo esc_attr( sprintf( __( 'Section progress %s%%', 'learnpress' ), round( $percent, 2 ) ) ); ?>"> |
| 68 |
<div class="learn-press-progress__active" data-value="<?php echo esc_attr( $percent ); ?>"></div> |
| 69 |
</div> |
| 70 |
</div> |
| 71 |
|
| 72 |
<?php do_action( 'learnpress/single-course/section-header/after', $section ); ?> |
| 73 |
<?php endif; ?> |
| 74 |
</div> |
| 75 |
|
| 76 |
<?php do_action( 'learn-press/before-section-content', $section, $course->get_id() ); ?> |
| 77 |
|
| 78 |
<?php if ( ! $items ) : ?> |
| 79 |
<?php learn_press_display_message( __( 'No items in this section', 'learnpress' ) ); ?> |
| 80 |
<?php else : ?> |
| 81 |
|
| 82 |
<ul class="section-content"> |
| 83 |
|
| 84 |
<?php |
| 85 |
foreach ( $items as $item ) : |
| 86 |
$can_view_item = $user->can_view_item( $item->get_id(), $can_view_content_course ); |
| 87 |
?> |
| 88 |
<li class="<?php echo esc_attr( implode( ' ', $item->get_class() ) ); ?>" |
| 89 |
data-id="<?php echo esc_attr( $item->get_id() ); ?>"> |
| 90 |
|
| 91 |
<?php |
| 92 |
do_action( 'learn-press/before-section-loop-item', $item, $section, $course ); |
| 93 |
|
| 94 |
$item_link = $can_view_item->flag ? $item->get_permalink() : false; |
| 95 |
$item_link = apply_filters( 'learn-press/section-item-permalink', $item_link, $item, $section, $course ); |
| 96 |
?> |
| 97 |
|
| 98 |
<a class="section-item-link" href="<?php echo esc_url_raw( $item_link ? $item_link : 'javascript:void(0);' ); ?>"> |
| 99 |
|
| 100 |
<?php |
| 101 |
do_action( 'learn-press/before-section-loop-item-title', $item, $section, $course ); |
| 102 |
|
| 103 |
learn_press_get_template( |
| 104 |
'single-course/section/' . $item->get_template(), |
| 105 |
array( |
| 106 |
'item' => $item, |
| 107 |
'section' => $section, |
| 108 |
) |
| 109 |
); |
| 110 |
|
| 111 |
do_action( 'learn-press/after-section-loop-item-title', $item, $section, $course ); |
| 112 |
?> |
| 113 |
</a> |
| 114 |
|
| 115 |
<?php do_action( 'learn-press/after-section-loop-item', $item, $section, $course ); ?> |
| 116 |
</li> |
| 117 |
<?php endforeach; ?> |
| 118 |
</ul> |
| 119 |
<?php endif; ?> |
| 120 |
|
| 121 |
<?php do_action( 'learn-press/after-section-summary', $section, $course->get_id() ); ?> |
| 122 |
</li> |
| 123 |
|