<?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="learndash-course-resource-wrapper">
            <ul class="list-unstyled">
                <?php
                    if( get_post_meta($course_id,'_wkfe_ld_template_course_estimated_time',true) ) :
                ?>
                <li>
                    <div class="course-resource">
                        <div class="resource-title">
                            <span><i class="fas fa-clock"></i></span>
                            <span><?php echo esc_html__('Duration','widgetkit-pro'); ?></span>
                        </div>
                        <div class="resource-desc"><?php echo esc_html(get_post_meta($course_id,'_wkfe_ld_template_course_estimated_time',true)); ?></div>
                    </div>
                </li>
                <?php endif; ?>
                <?php 
                    $lessons = learndash_get_course_lessons_list( $course_id );
                    if ( ! empty( $lessons ) ) :
                ?>
    
                <li>
                    <div class="course-resource">
                        <div class="resource-title">
                            <span><i class="fas fa-file-alt"></i></span>
                            <span><?php echo esc_html__('Lessons','widgetkit-pro'); ?></span>
                        </div>
                        <div class="resource-desc"><?php echo esc_html(count($lessons)); ?></div>
                    </div>
                </li>
                <?php
                    endif;

                    $quizzes = learndash_get_course_quiz_list( 2034, $user_id );
                ?>
                <li>
                    <div class="course-resource">
                        <div class="resource-title">
                            <span><i class="fas fa-align-left"></i></span>
                            <span><?php echo esc_html__('Quizzes','widgetkit-pro'); ?></span>
                        </div>
                        <div class="resource-desc"><?php echo esc_html(count($quizzes)); ?></div>
                    </div>
                </li>

                <?php if( get_post_meta($course_id,'_wkfe_ld_template_course_difficulties_level',true) ) : ?>
                <li>
                    <div class="course-resource">
                        <div class="resource-title">
                            <span><i class="fas fa-chart-bar"></i></span>
                            <span><?php echo esc_html__('Skill Level','widgetkit-pro'); ?></span>
                        </div>
                        <div class="resource-desc"><?php echo esc_html( get_post_meta($course_id,'_wkfe_ld_template_course_difficulties_level',true) ) . esc_html__(' level','widgetkit-pro'); ?></div>
                    </div>
                </li>
                <?php endif; ?>
                    
                <?php 
                    $course_certficate_link  = learndash_get_course_certificate_link( $course_id, $user_id );

                    if ( $course_certficate_link && ! empty( $course_certficate_link ) ): ?>
                ?>
                <li>
                    <div class="course-resource">
                        <div class="resource-title">
                            <span><i class="fas fa-certificate"></i></span>
                            <span><?php echo esc_html__('Certificate of Completion','widgetkit-pro'); ?></span>
                        </div>
                        <div class="resource-desc"><?php echo esc_html__('Yes','widgetkit-pro'); ?></div>
                    </div>
                </li>
                <?php endif; ?>
            </ul>
        </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;