| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for displaying list courses shortcode. |
| 4 |
* |
| 5 |
* @author ThimPress |
| 6 |
* @package LearnPress/Templates |
| 7 |
* @version 4.0.2 |
| 8 |
*/ |
| 9 |
|
| 10 |
use LearnPress\Models\CourseModel; |
| 11 |
use LearnPress\TemplateHooks\Course\ListCoursesTemplate; |
| 12 |
|
| 13 |
defined( 'ABSPATH' ) || exit; |
| 14 |
|
| 15 |
if ( ! isset( $query ) ) { |
| 16 |
return; |
| 17 |
} |
| 18 |
|
| 19 |
?> |
| 20 |
<div class="lp-archive-courses"> |
| 21 |
<div class="lp-content-area"> |
| 22 |
<?php if ( ! empty( $title ) ) : ?> |
| 23 |
<header class="learn-press-courses-header"> |
| 24 |
<h1><?php echo esc_html( $title ); ?></h1> |
| 25 |
</header> |
| 26 |
<?php endif; ?> |
| 27 |
|
| 28 |
<?php |
| 29 |
$posts = $query->posts; |
| 30 |
if ( count( $posts ) > 0 ) : |
| 31 |
echo '<ul class="learn-press-courses" data-layout="grid">'; |
| 32 |
|
| 33 |
foreach ( $posts as $post ) { |
| 34 |
$course = CourseModel::find( $post->ID, true ); |
| 35 |
if ( ! $course ) { |
| 36 |
continue; |
| 37 |
} |
| 38 |
|
| 39 |
echo ListCoursesTemplate::render_course( $course ); |
| 40 |
} |
| 41 |
|
| 42 |
echo '</ul>'; |
| 43 |
else : |
| 44 |
_e( 'No courses', 'learnpress' ); |
| 45 |
endif; |
| 46 |
?> |
| 47 |
</div> |
| 48 |
</div> |
| 49 |
|
| 50 |
|