<?php

$settings = $this->get_settings_for_display();
$course_cat = $settings['cat_dynamic_multiple_id'] ? implode(",",$settings['cat_dynamic_multiple_id']) : '';

    $args = array(
        'post_type' => 'courses',
        'posts_per_page' =>  $settings['post_num_to_show'],
        'orderby'  => $settings['orderby'],
        'order' => $settings['order']
    );

    if( !empty( $settings['cat_dynamic_multiple_id'] ) ) {
        $args['tax_query'] = array(
            array(
                'taxonomy' => 'course-category',
                'field'    => 'term_id',
                'terms'    => $settings['cat_dynamic_multiple_id']
            )    
        );
    }
    if(is_plugin_active('tutor/tutor.php')):
    $courses = new WP_Query($args);
    ?>
    <div class="row justify-content-center tutor-course-list">
        <?php
            if( $courses->have_posts() ) {
                while( $courses->have_posts() ) {
                    $courses->the_post();
                    ?>
                    <div class="col-lg-<?php echo esc_attr($settings['posts_column']); ?> mb-4 pb-2 col-sm-6">
                        <div class="tutor-course tutor-course-loop tutor-course-loop-<?php echo esc_attr(get_the_ID()); ?>">
                        <?php
                            tutor_load_template('loop.course');
                        ?>
                        </div>
                    </div>
                <?php
                }
                wp_reset_postdata();
            }
        ?>
    </div>
    <?php 
    else:
        ?>
        <h4 style="border:solid 2px black; padding:10px 30px; margin:0px; text-align:center;"><?php esc_html_e('Please active TutorLMS for proper view', 'widgetkit-pro'); ?></h4>
        <?php
    endif;