| Server IP : 178.63.100.251 / Your IP : 216.73.216.228 Web Server : LiteSpeed System : Linux dobby.thevpsserver.com 4.18.0-553.16.1.lve.el8.x86_64 #1 SMP Tue Aug 13 17:45:03 UTC 2024 x86_64 User : truewayi ( 1855) PHP Version : 7.4.33 Disable Function : show_source,system,shell_exec,passthru,exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/truewayi/public_html/wp-content/themes/omexo/ |
Upload File : |
<?php
/**
* Archive Template for LearnDash Courses
*/
get_header();
$omexo_option = get_option('omexo_opt');
$course_category_switcher = omexo_array_get($omexo_option, 'course-category-switcher') ? $omexo_option['course-category-switcher'] : '';
$course_enroll_text = omexo_array_get($omexo_option, 'course-enroll-text') ? $omexo_option['course-enroll-text'] : '';
$course_enroll_switcher = omexo_array_get($omexo_option, 'course-enroll-switcher') ? $omexo_option['course-enroll-switcher'] : '';
$course_duration_switcher = omexo_array_get($omexo_option, 'course-duration-switcher') ? $omexo_option['course-duration-switcher'] : '';
$course_rating_switcher = omexo_array_get($omexo_option, 'course-rating-switcher') ? $omexo_option['course-rating-switcher'] : '';
?>
<div class="container my-5">
<div class="row">
<?php if (have_posts()) : while (have_posts()) : the_post();
$course_id = get_the_ID();
// Get course meta
$course_thumbnail = get_the_post_thumbnail_url($course_id, 'medium'); // Course Thumbnail
$course_price = get_post_meta($course_id, '_ld_price', true) ?: 'Free'; // Course Price
$course_lessons = count(learndash_get_course_lessons_list($course_id)); // Number of Lessons
// Get number of enrolled students (Fixed)
$enrolled_users = learndash_get_users_for_course($course_id);
$course_students = !empty($enrolled_users) && is_array($enrolled_users) ? count($enrolled_users) : 0;
// Get instructor info
$instructor_id = get_post_field('post_author', $course_id);
$instructor_avatar = get_avatar_url($instructor_id);
$instructor_name = get_the_author_meta('display_name', $instructor_id);
$instructor_profile_link = get_author_posts_url($instructor_id);
// Get course rating (Requires LearnDash Reviews add-on)
$course_rating = get_post_meta($course_id, '_learndash_course_rating', true) ?: 0;
$max_stars = 5; // Maximum stars
$filled_stars = round($course_rating); // Round rating to nearest whole number
// Get Course Duration
$course_duration = learndash_get_setting($course_id, 'course_duration');
?>
<div class="col-md-4">
<div class="omexo-course-single style-two">
<div class="course-card course-card-<?php echo esc_url(get_the_ID()); ?>">
<div class="course-header">
<a href="<?php echo esc_attr(get_the_permalink()); ?>"><img src="<?php echo esc_url($course_thumbnail); ?>" class="card-img-top" alt="<?php the_title(); ?>"></a>
</div>
<div class="course-content">
<?php if ($course_duration_switcher == true && !empty($course_duration)): ?>
<span class="course-duration"><i class="fa-regular fa-clock"></i> <?php echo esc_html($course_duration_readable); ?></span>
<?php endif; ?>
<div class="course-title">
<h3><a href="<?php echo esc_url(get_the_permalink()); ?>"><?php the_title(); ?></a></h3>
</div>
<?php //if ($course_rating_switcher == true):
?>
<div class="course-rating">
<?php for ($i = 1; $i <= $max_stars; $i++) : ?>
<i class="fas fa-star <?php echo ($i <= $filled_stars) ? 'text-warning' : 'text-muted'; ?>"></i>
<?php endfor; ?>
<span>(<?php echo esc_html($course_rating); ?>)</span>
</div>
<? php // endif;
?>
<div class="course-content-footer">
<span class="course-price">
<?php echo esc_html($course_price); ?>
</span>
<?php //if ($course_enroll_switcher == true):
?>
<span class="course-user"><i class="fa-regular fa-user"></i> <?php echo esc_html__($course_students, 'omexo'); ?>
<?php if (!empty($course_enroll_text)): ?>
<span class="enrolled-label"><?php echo esc_html__($course_enroll_text, 'omexo') ?></span>
<?php endif; ?>
</span>
<?php //endif;
?>
</div>
</div>
</div>
</div>
</div>
<?php endwhile;
else: ?>
<p>No courses found.</p>
<?php endif; ?>
</div>
</div>
<?php get_footer(); ?>