<?php 
    class Edumodo_Footer_hooks{
        private static $instance; 

        public static function init(){
            if( null === self::$instance ){
                self::$instance = new self;
            }
            return self::$instance;
        }
        public function __construct(){
            add_filter( 'edumodo-social', [$this, 'render_edumodo_social_icons'], 10, 1 );
            add_filter( 'edumodo-copyright', [$this, 'render_copyright'], 10, 1 );
            add_filter( 'edumodo-credit', [$this, 'render_credit'], 10, 2 );

            add_action('edumodo-social', [$this, 'render_edumodo_social_icons']);
            add_action('edumodo-copyright', [$this, 'render_copyright']);
            add_action('edumodo-credit', [$this, 'render_credit']);
        }
        

        /**
         * blog 
         */
        public function edumodo__social(){
            $edumodo_social = [
                'facebook' => edumodo_get_theme_mod('edumodo_social_facebook_url', '#'),
                'twitter' => edumodo_get_theme_mod('edumodo_social_twitter_url', '#'),
                'instagram' => edumodo_get_theme_mod('edumodo_social_instagram_url', '#'),
                'linkedin' => edumodo_get_theme_mod('edumodo_social_linkedin_url', '#'),
                'whatsapp' => edumodo_get_theme_mod('edumodo_social_whatsapp_url', '#'),
                'youtube' => edumodo_get_theme_mod('edumodo_social_youtube_url', '#'),
                'skype' => edumodo_get_theme_mod('edumodo_social_skype_url', '#'),
                'snapchat' => edumodo_get_theme_mod('edumodo_social_snapchat_url', '#')
            ];
            return $edumodo_social;
        }
        
        /**
         * single header area
         */
        public function render_edumodo_social_icons($classnames = 'social-icon text-right'){
            $social_link = $this->edumodo__social();
            ?>
            <div class="<?php echo $classnames; ?>">
                <?php if ($social_link['facebook']):?>
                    <a target="_blank" href="<?php echo esc_url($social_link['facebook']); ?>">
                        <i class="glyph-icon flaticon-facebook-logo"></i>
                    </a>
                <?php endif; ?>

                <?php if ($social_link['twitter']):?>
                    <a target="_blank" href="<?php echo esc_url($social_link['twitter']); ?>">
                        <i class="glyph-icon flaticon-twitter"></i>
                    </a>
                <?php endif; ?>
                    
                <?php if ($social_link['instagram']):?>
                    <a target="_blank" href="<?php echo esc_url($social_link['instagram']); ?>">
                        <i class="glyph-icon flaticon-instagram-1"></i>
                    </a>
                <?php endif; ?>

                <?php if ($social_link['linkedin']):?>
                    <a target="_blank" href="<?php echo esc_url($social_link['linkedin']); ?>">
                        <i class="glyph-icon flaticon-linkedin-logo"></i>
                    </a>
                <?php endif; ?>

                <?php if ($social_link['youtube']):?>
                    <a target="_blank" href="<?php echo esc_url($social_link['youtube']); ?>">
                        <i class="glyph-icon flaticon-youtube-logo"></i>
                    </a>
                <?php endif; ?>                                                                                 

                <?php if ($social_link['skype']):?>
                    <a target="_blank" href="<?php echo esc_url($social_link['skype']); ?>">
                        <i class="glyph-icon flaticon-skype-logo"></i>
                    </a>
                <?php endif; ?>
            </div>
            <?php
            
        }
        /**
         * copyright
         */
        public function render_copyright($copyright_str=''){
            $copyright_str = $copyright_str ?: 'Edumodo &copy; 2021';
            ?>
            <div class="copyright-info">
                <?php 
                    echo sprintf(
                        esc_html__("%s", 'edumodo'), 
                        $copyright_str
                    );
                ?>
            </div>
            <?php
        }
        /**
         * credit
         */
        public function render_credit($credit_text='', $credit_url=''){
            $credit_text = $credit_text ?: 'Themesgrove';
            $credit_url = $credit_url ?: 'https://themesgrove.com/';
            ?>
            <div class="user-credit">
                <a href="<?php echo $credit_url; ?>">
                    <?php echo $credit_text; ?>
                </a>
            </div>
            <?php
        }
        
    }
?>