| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for displaying content of Recent Courses widget. |
| 4 |
* |
| 5 |
* This template can be overridden by copying it to yourtheme/learnpress/widgets/recent-courses/default.php. |
| 6 |
* |
| 7 |
* @author ThimPress |
| 8 |
* @category Widgets |
| 9 |
* @package Learnpress/Templates |
| 10 |
* @version 4.0.1 |
| 11 |
*/ |
| 12 |
|
| 13 |
defined( 'ABSPATH' ) || exit(); |
| 14 |
|
| 15 |
if ( ! isset( $instance ) ) { |
| 16 |
return; |
| 17 |
} |
| 18 |
|
| 19 |
if ( ! isset( $courses ) ) { |
| 20 |
esc_html_e( 'No courses', 'learnpress' ); |
| 21 |
|
| 22 |
return; |
| 23 |
} |
| 24 |
|
| 25 |
global $post; |
| 26 |
?> |
| 27 |
|
| 28 |
<div class="lp-widget-recent-courses <?php echo esc_attr( $instance['css_class'] ); ?>"> |
| 29 |
<div class="lp-widget-recent-courses__content"> |
| 30 |
<?php |
| 31 |
foreach ( $courses as $course_id ) { |
| 32 |
if ( empty( $course_id ) ) { |
| 33 |
continue; |
| 34 |
} |
| 35 |
|
| 36 |
$post = get_post( $course_id ); |
| 37 |
setup_postdata( $post ); |
| 38 |
$course = learn_press_get_course( $course_id ); |
| 39 |
?> |
| 40 |
|
| 41 |
<div class="lp-widget-course"> |
| 42 |
|
| 43 |
<!-- course thumbnail --> |
| 44 |
<?php if ( ! empty( $instance['show_thumbnail'] ) && $course->get_image( 'medium' ) ) : ?> |
| 45 |
<div class="lp-widget-course__image"> |
| 46 |
<a href="<?php echo esc_url_raw( $course->get_permalink() ); ?>"> |
| 47 |
<?php echo wp_kses_post( $course->get_image( 'medium' ) ); ?> |
| 48 |
</a> |
| 49 |
</div> |
| 50 |
<?php endif; ?> |
| 51 |
|
| 52 |
<div class="lp-widget-course__content"> |
| 53 |
<!-- course title --> |
| 54 |
<a href="<?php echo esc_url_raw( get_the_permalink( $course->get_id() ) ); ?>"> |
| 55 |
<h3 class="lp-widget-course__title"><?php echo esc_html( $course->get_title() ); ?></h3> |
| 56 |
</a> |
| 57 |
|
| 58 |
<!-- course content --> |
| 59 |
<?php if ( ! empty( $instance['desc_length'] ) && absint( $instance['desc_length'] ) > 0 ) : ?> |
| 60 |
<div class="lp-widget-course__description"> |
| 61 |
<?php echo wp_kses_post( $course->get_content( 'raw', absint( $instance['desc_length'] ), '...' ) ); ?> |
| 62 |
</div> |
| 63 |
<?php endif; ?> |
| 64 |
|
| 65 |
<div class="lp-widget-course__meta"> |
| 66 |
<!-- price --> |
| 67 |
<?php if ( ! empty( $instance['show_price'] ) ) : ?> |
| 68 |
<div class="course-price"> |
| 69 |
<div class="lp-widget-course__price"> |
| 70 |
<?php echo wp_kses_post( $course->get_course_price_html() ); ?> |
| 71 |
</div> |
| 72 |
</div> |
| 73 |
<?php endif; ?> |
| 74 |
|
| 75 |
<!-- instructor --> |
| 76 |
<?php if ( ! empty( $instance['show_teacher'] ) ) : ?> |
| 77 |
<div class="lp-widget-course__instructor"> |
| 78 |
<span class="lp-widget-course__instructor__avatar"> |
| 79 |
<?php echo wp_kses_post( $course->get_instructor()->get_profile_picture() ); ?> |
| 80 |
</span> |
| 81 |
<?php echo wp_kses_post( $course->get_instructor_html() ); ?> |
| 82 |
</div> |
| 83 |
<?php endif; ?> |
| 84 |
</div> |
| 85 |
</div> |
| 86 |
</div> |
| 87 |
<?php } ?> |
| 88 |
|
| 89 |
<?php wp_reset_postdata(); ?> |
| 90 |
</div> |
| 91 |
|
| 92 |
<div class="lp-widget-recent-courses__footer"> |
| 93 |
<?php if ( ! empty( $instance['bottom_link_text'] ) && learn_press_get_page_link( 'courses' ) ) : ?> |
| 94 |
<a class="lp-widget-recent-courses__footer__link" |
| 95 |
href="<?php echo esc_url_raw( learn_press_get_page_link( 'courses' ) ); ?>" rel="nofllow"> |
| 96 |
<?php echo wp_kses_post( $instance['bottom_link_text'] ); ?> |
| 97 |
</a> |
| 98 |
<?php endif; ?> |
| 99 |
</div> |
| 100 |
</div> |
| 101 |
|