<?php
// Silence is golden.

	$settings = $this->get_settings_for_display();
    $id = $this->get_id();
    
    if( class_exists('SFWD_LMS') ) :
        $elementor_editor = \Elementor\Plugin::instance()->editor->is_edit_mode();
        if( $elementor_editor ) {
            $course_id = learndash_post_arr()[0];
        } else {
            $course_id = learndash_get_course_id();
        }
        
        if( is_user_logged_in() ) {
            $user_id = get_current_user_id();
        } else {
            $user_id = 0;
        }
        ?>
        <div class="wkld-course-meta-info">
            <?php if( get_post_meta($course_id,'_wkfe_ld_template_course_difficulties_level',true) ) : ?>
                <div class="ld-course-difficulties <?php echo esc_attr( get_post_meta($course_id,'_wkfe_ld_template_course_difficulties_level',true) ); ?>-level">
                    <div class="bars">
                        <span></span>
                        <span></span>
                        <span></span>
                    </div>
                    <p class="meta-desc"><?php echo esc_html( get_post_meta($course_id,'_wkfe_ld_template_course_difficulties_level',true) ) . esc_html__(' level','widgetkit-pro'); ?></p>
                </div>
            <?php endif; ?>

            <?php
                if( get_post_meta($course_id,'_wkfe_ld_template_course_estimated_time',true) ) :
            ?>    
            <div class="wkld-course-meta">
                <span class="meta-title">
                    <?php esc_html_e('Estimated time','widgetkit-pro'); ?>
                </span>
                <?php
                    if( get_post_meta($course_id,'_wkfe_ld_template_course_estimated_time',true) ) :
                ?>
                <h4><?php echo get_post_meta($course_id,'_wkfe_ld_template_course_estimated_time',true); ?></h4>
                <?php endif; ?>
                
                <?php
                    if( get_post_meta($course_id,'_wkfe_ld_template_course_estimated_time_per_week',true) ) :
                ?>
                <p class="meta-desc"><?php echo get_post_meta($course_id,'_wkfe_ld_template_course_estimated_time_per_week',true); ?></p>
                <?php endif; ?>

            </div>
            <?php endif; ?>
            
            <div class="wkld-course-meta">
                <span class="meta-title"><?php esc_html_e('Students','widgetkit-pro'); ?></span>
                <h4>
                    <?php  
                        $userquery = learndash_get_users_for_course($course_id,array(),false);
                        if ( ( $userquery instanceof WP_User_Query ) && ( property_exists( $userquery, 'results' ) ) && ( ! empty( $userquery->results ) ) ) {
                            $user_ids = $userquery->get_results();
                            echo esc_html( count( $user_ids ) );
                        } else {
                            echo esc_html__( '0','widgetkit-pro' );
                        }
                    ?>
                </h4>
                <p class="meta-desc"><?php esc_html_e('Enrolled in this course','widgetkit-pro'); ?></p>
            </div>
        </div>
    <?php
    else :
    ?>
        <div class="plugin-active-massage">
            <h3><?php esc_html_e('Please activate LearnDash LMS plugin first', 'widgetkit-pro');?></h3>
        </div>
    <?php
    endif;