    <?php
        use Elementor\Group_Control_Image_Size;

        $settings = $this->get_settings();
        $c_desktop = $settings['posts_column'];
        $word_count_switch = $settings['word_count_switch'];
        $excerpt_word_count = $settings['excerpt_word_count'];
        $show_course_price = $settings['show_course_price'];
        $show_enrolled_student = $settings['show_enrolled_student'];
        $show_course_duration = $settings['show_course_duration'];
        $cat_multi_slug = widgetkit_pro_array_get($settings, 'cat_dynamic_multiple_id');
        $post_num_to_show = widgetkit_pro_array_get($settings, 'post_num_to_show');
        $thumb_size = widgetkit_pro_array_get($settings, 'image_size');
    ?>

    <?php if (class_exists('LifterLMS')) : // Check LearnDash LMS plugin active?>
        <div class="widgetkit-lifter-courses widgetkit-lifter-courses-list-element">
            <div class="column-grid column-desktop-<?php echo $c_desktop; ?> column-tablet-<?php echo $c_tablet; ?> column-mobile-<?php echo $c_mobile; ?>">
                <?php
                /**
                 * Query for the post
                 * custom post type
                 * post type : course
                 * category taxonomy : course_cat
                 */
                $count = 0;
                /**
                * if select any category for drop down
                * then assign that value to the $first_cat_id
                * if not then set it to null
                */
                if (isset($first_cat_ID)) {
                    $first_cat_ID = $first_cat_ID;
                } else {
                    $first_cat_ID = '';
                }
                if ($cat_multi_slug) :
                    $course = array(
                        'post_type' => 'course',
                        'posts_per_page' => $post_num_to_show,
                        'orderby' => $settings['orderby'],
                        'order' => $settings['order'],
                        'tax_query' => array(
                            array(
                                'taxonomy' => 'course_cat',
                                'field'    => 'slug',
                                'terms' => $cat_multi_slug,
                            ),
                        ),
                    );

                else :
                    $course = array(
                        'post_type' => 'course',
                        'posts_per_page' => $post_num_to_show,
                        'orderby' => $settings['orderby'],
                        'order' => $settings['order'],
                    );  
                endif;
                

                $course_query = new WP_Query($course);
                if ($course_query->have_posts()):
                    while ($course_query->have_posts()):
                        $course_query->the_post();
                        $course_meta = get_post_meta(get_the_ID());
                        ?>

                        <div class="lifter_course_grid">
                            <article id="post-<?php the_ID();?>" <?php post_class('lifter-single-course');?>>
                                
                                <?php if (has_post_thumbnail()): ?>
                                    <a class="course-featured-image" href="<?php the_permalink();?>">
                                        <img src="<?php echo Group_Control_Image_Size::get_attachment_image_src(get_post_thumbnail_id(), 'image', $settings );?>" alt="<?php the_title(); ?>">
                                    </a>
                                <?php endif;?>

                                <div class="course-content">
                                    <?php 
                                    if($show_course_price):
                                    if( array_key_exists('course_options_price', $course_meta) ):?>
                                    <p class="course-price">
                                        <?php echo $course_meta['course_options_price'][0];?>
                                    </p>
                                    <?php endif; endif; ?>
                                    <div class="course-title">
                                        <a href="<?php the_permalink();?>">
                                            <?php the_title(); ?>
                                        </a>
                                    </div>
                                    <div class="course-excerpt">
                                        <?php echo wp_trim_words(get_the_excerpt(), $excerpt_word_count, ''); ?>
                                    </div>
                                    <div class="course-meta">
                                        
                                        <?php 
                                        if($show_enrolled_student):
                                        if( array_key_exists('course_options_total_enrolled_student', $course_meta) ):
                                        ?>
                                        <p class="enrolled-student">
                                            <span class="icon"><i class="fa fa-user"></i></span>
                                            <?php echo $course_meta['course_options_total_enrolled_student'][0];?>
                                        </p>
                                        <?php endif; endif;?>

                                        <?php 
                                        if($show_course_duration):
                                        if( array_key_exists('_llms_length', $course_meta) ):
                                        ?>
                                        <p class="total-time">
                                            <span class="icon"><i class="far fa-clock"></i></span>
                                            <?php echo $course_meta['_llms_length'][0];?>
                                        </p>
                                        <?php endif; endif; ?>
                                    </div>
                                </div><!-- .entry-header -->
                            </article><!-- #post-## -->

                        </div>

                    <?php 
                    endwhile; 
                    wp_reset_postdata(); 
                    wp_reset_query(); 
                endif;?>
            </div>
        </div>

    <?php else:  ?>
        <div class="plugin-active-massage">
            <h3><?php esc_html_e('Please activate Lifter LMS plugin first', 'widgetkit-pro');?></h3>
        </div>
    <?php endif;  ?>
