<?php 
    class Edumodo_Lifter_hooks{
        private static $instance; 

        public static function init(){
            if( null === self::$instance ){
                self::$instance = new self;
            }
            return self::$instance;
        }
        public function __construct(){
            add_action('lifter_archive_override', [$this, 'edumodo_lifter_course_archive_override']);
        }
        /**
         * Liter archive override
         */
        function edumodo_lifter_course_archive_override(){
            $course_meta = get_post_meta(get_the_ID());
            $lifter__archive_excerpt_length = get_theme_mod('edumodo__lifter_archive_excerpt_length', '15');
            $edumodo__lifter_archive_meta_price = get_theme_mod('edumodo__lifter_archive_meta_price', true);
            $edumodo__lifter_archive_meta_enrolled_student = get_theme_mod('edumodo__lifter_archive_meta_enrolled_student', true);
            $edumodo__lifter_archive_meta_course_duration = get_theme_mod('edumodo__lifter_archive_meta_course_duration', true);
            ?>
            <div class="lifter-archive-card">
                
                <?php 
                if($edumodo__lifter_archive_meta_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; ?>
                <a href="<?php echo the_permalink(); ?>" class="course-title">
                    <?php echo the_title(); ?>
                </a>
                <div class="course-excerpt">
                    <?php echo wp_trim_words(get_the_excerpt(), $lifter__archive_excerpt_length, ''); ?>
                </div>
                <div class="course-meta">
                    <?php 
                    if($edumodo__lifter_archive_meta_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($edumodo__lifter_archive_meta_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>
            <?php
        }

        
        
    }
?>