<?php
class Edumodo_Header_hooks
{
    private static $instance;

    public static function init()
    {
        if (null === self::$instance) {
            self::$instance = new self;
        }
        return self::$instance;
    }
    public function __construct()
    {
        add_filter('get_the_archive_title', [$this, 'edumodo_modifiy_theme_archive_title']);
        add_action('edumodo-page-header-title-breadcrumb', [$this, 'page_header_title_breadcrumb']);
        add_action('edumodo-blog-header-title-breadcrumb', [$this, 'blog_header_title_breadcrumb']);
        add_action('edumodo-notice-header-title-breadcrumb', [$this, 'notice_header_title_breadcrumb']);
        add_action('edumodo-txcourse-header-title-breadcrumb', [$this, 'txcourse_header_title_breadcrumb']);
        // add_action('edumodo-teacher-header-title-breadcrumb', [$this, 'teacher_header_title_breadcrumb']);
        add_action('edumodo-learndash-header-title-breadcrumb', [$this, 'learndash_header_title_breadcrumb']);
        // add_action('edumodo-learnpress-header-title-breadcrumb', [$this, 'learnpress_header_title_breadcrumb']);
        add_action('edumodo-lifter-header-title-breadcrumb', [$this, 'lifter_header_title_breadcrumb']);
        // add_action('edumodo-tutor-header-title-breadcrumb', [$this, 'tutor_header_title_breadcrumb']);
        add_action('edumodo-event-header-title-breadcrumb', [$this, 'event_header_title_breadcrumb']);
        add_action('edumodo-sensei-header-title-breadcrumb', [$this, 'sensei_header_title_breadcrumb']);
        add_action('edumodo-woocommerce-header-title-breadcrumb', [$this, 'woocommerce_header_title_breadcrumb']);
        add_action('edumodo-bbpress-header-title-breadcrumb', [$this, 'bbpress_header_title_breadcrumb']);
        add_action('edumodo-buddypress-header-title-breadcrumb', [$this, 'buddypress_header_title_breadcrumb']);
        add_action('edumodo-top-bar-header', [$this, 'edumodo_top_bar_header_cb']);
        add_action('edumodo-main-header', [$this, 'edumodo_main_header_cb']);
    }
    public function edumodo_render_top_bar_header_contacts($phone = '', $email = '')
    {
?>
        <div class="tophead-contact">
            <div class="top-lists">
                <span>
                    <i class="glyph-icon flaticon-telephone-handle-silhouette"></i>
                    <a class="top-phone" href="tel:<?php echo esc_html($phone); ?>">
                        <?php echo esc_html($phone); ?>
                    </a>
                </span>
                <span class="topbar-seperator">|</span>
                <span>
                    <i class="glyph-icon flaticon-message-closed-envelope"></i>
                    <a class="top-email" href="mailto:<?php echo esc_html($email); ?>">
                        <?php echo esc_html($email); ?>
                    </a>
                </span>
            </div>
        </div>
    <?php
    }
    public function edumodo_render_top_bar_header_menu($slug)
    {
        wp_nav_menu([
            'menu' => $slug,
            'menu_class' => 'header-top-bar-menu ' . $slug,
            'container_class' => 'header-top-bar-menu-wrapper'
        ]);
    }
    public function edumodo_render_top_bar_header_login()
    {
        $header_top_bar_login_text = get_theme_mod('edumodo_top_bar_login_text', 'Login');
        $header_top_bar_login_url = get_theme_mod('edumodo_top_bar_login_url', '#');
        $header_top_bar_Registration_text = get_theme_mod('edumodo_top_bar_register_text', 'Registration');
        $header_top_bar_Registration_url = get_theme_mod('edumodo_top_bar_register_url', '#');
    ?>
        <a href="<?php echo $header_top_bar_login_url; ?>"><?php echo $header_top_bar_login_text; ?></a>
        <span class="topbar-seperator">|</span>
        <a href="<?php echo $header_top_bar_Registration_url; ?>"><?php echo $header_top_bar_Registration_text; ?></a>
        <?php
    }
    public function edumodo_top_bar_header__render_left_side_content_cb()
    {
        $header_top_bar_left_option = get_theme_mod('edumodo_top_bar_left_side_options', 'contacts');
        $header_top_bar_phone_left = get_theme_mod('edumodo_top_bar_contact_phone_left', '0123456789');
        $header_top_bar_email_left = get_theme_mod('edumodo_top_bar_contact_email_left', 'hello@admin.com');
        $header_top_bar_menu_left = get_theme_mod('edumodo_heade_left_menu', '');

        if ('contacts' == $header_top_bar_left_option) {
            $this->edumodo_render_top_bar_header_contacts($header_top_bar_phone_left, $header_top_bar_email_left);
        } elseif ('menu' == $header_top_bar_left_option) {
            $this->edumodo_render_top_bar_header_menu($header_top_bar_menu_left);
        } elseif ('social' == $header_top_bar_left_option) {
            apply_filters('edumodo-social', 'top-bar-social-icons');
        } else {
            return false;
        }
    }
    public function edumodo_top_bar_header__render_right_side_content_cb()
    {
        $header_top_bar_right_option = get_theme_mod('edumodo_top_bar_right_side_options', 'social');
        $header_top_bar_phone_right = get_theme_mod('edumodo_top_bar_contact_phone_right', '0123456789');
        $header_top_bar_email_right = get_theme_mod('edumodo_top_bar_contact_email_right', 'hello@admin.com');
        $header_top_bar_menu_right = get_theme_mod('edumodo_header_right_menu', '');

        if ('contacts' == $header_top_bar_right_option) {
            $this->edumodo_render_top_bar_header_contacts($header_top_bar_phone_right, $header_top_bar_email_right);
        } elseif ('menu' == $header_top_bar_right_option) {
            $this->edumodo_render_top_bar_header_menu($header_top_bar_menu_right);
        } elseif ('social' == $header_top_bar_right_option) {
            apply_filters('edumodo-social', 'top-bar-social-icons');
        } elseif ('login' == $header_top_bar_right_option) {
            $this->edumodo_render_top_bar_header_login();
        } else {
            return false;
        }
    }
    public function edumodo_top_bar_header_cb()
    {
        $edumodo_header_enable_top_bar = get_theme_mod('edumodo_header_enable_top_bar', 'no');
        if ('yes' == $edumodo_header_enable_top_bar) :
        ?>
            <div id="top-header" class="top-header" class="hidden-xs">
                <div class="container">
                    <div class="left-side tophead-left col-md-6">
                        <?php $this->edumodo_top_bar_header__render_left_side_content_cb(); ?>
                    </div>
                    <div class="right-side tophead-right col-md-6 text-right">
                        <?php $this->edumodo_top_bar_header__render_right_side_content_cb(); ?>
                        <div class="login-reg-btn">
                            <ul>
                                <li><a href="#"><i class="fa fa-user"></i> Login <small>/</small> Register</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        <?php
        endif;
    }
    public function edumodo_handle_site_logo()
    {
        $description = get_bloginfo('description', 'display');
        ?>
        <div class="logo-wrapper">
            <?php
            if (has_custom_logo()) {
                the_custom_logo();
            }

            if ($description || is_customize_preview()) : ?>
                <h2 class="site-title">
                    <a href="<?php echo esc_url(home_url('/')); ?>">
                        <?php bloginfo('name'); ?>
                    </a>
                </h2>
                <h6 class="site-description"><?php bloginfo('description'); ?></h6>
            <?php endif; ?>
        </div>
    <?php
    }

    public function edumodo_main_header_cb()
    {
         
        function edumodo_add_to_cart_fragment( $fragments ) {
           
        global $woocommerce;
            ob_start();
        
            edumodo_wc_mini_cart();
        
            $fragments['a.cart-button'] = ob_get_clean();
        
            return $fragments;
        
        }
        function edumodo_wc_mini_cart() {
            global $woocommerce;
            ?>
            <a class="mini-cart" href="<?php echo esc_attr(wc_get_cart_url());?>">
                <i class="fa fa-shopping-cart"></i>
                <span class="cart-total-number"><?php echo esc_html(WC()->cart->cart_contents_count);?></span>
            </a>
            <?php
        }

        add_filter('add_to_cart_fragments', 'edumodo_add_to_cart_fragment');

        // header custom search form 
        function edumodo_search_form( $form ) {
            $form = '
            <form role="search" method="get" id="searchform" class="searchform" action="' . home_url( '/' ) . '" >
                <div>
                    <input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="'.esc_attr__( 'Search', 'edumodo' ).'"/>
                    <button type="submit" id="searchsubmit"><i class="fa fa-search"></i></button>
                </div>
            </form>';
        
        return $form;
        }
        add_filter( 'get_search_form', 'edumodo_search_form' );

    ?>
        <div id="edumodo-mainnav" class="navbar-v1 edumodo-mainnav">
            <div class="container">
                <div class="row">
                    <div class="nav-logo-align">
                        <div class="logo">
                            <div class="navbar-header">
                                <?php
                                $this->edumodo_handle_site_logo();
                                ?>
                            </div>
                        </div>

                        <div class="menu-wrapper pull-right text-right hidden-xs hidden-sm">
                            <?php
                            wp_nav_menu(array(
                                'menu'              => 'primary',
                                'theme_location'    => 'primary',
                                'depth'             => 0,
                                'menu_class'        => 'navigation-main hidden-sm hidden-xs',
                                'fallback_cb'       => 'tx_megamenu_navwalker::fallback',
                                'walker'            => new tx_megamenu_navwalker()
                            ));
                            $this->edumodo__display_login_button();
                            ?>

                        </div>

                        <div class="pull-right text-right visible-xs visible-sm hidden-md hidden-lg">
                            <div id="mobile-menu-wrapper" class="mmenu-wrapper">
                                <div class="mmenu-icon">
                                    <a href="#mmenu" class="micon"><i class="glyph-icon flaticon-bars"></i></a>
                                </div>
                                <nav id="mmenu">
                                    <?php
                                    wp_nav_menu(array(
                                        'menu' => 'mobile_menu',
                                        'theme_location' => 'mobile_menu',
                                    ));
                                    ?>
                                </nav>
                            </div>
                        </div>
                        <div class="mini-cart-search text-right">
                            <?php if ( class_exists ( 'woocommerce' )):?>
                            <div class="mini-cart-wrap">
                                <?php edumodo_wc_mini_cart();?>
                            </div>
                            <?php endif;?>
                            <div class="header-search-wrap">
                                <div class="search-icon">
                                    <span><i class="fa fa-search"></i></span>
                                </div>
                                <div class="header-search-form">
                                    <?php  get_search_form();?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php
    }

    public function edumodo__display_login_button()
    {
        $login_button = get_theme_mod('edumodo_header_button_trigger', 'off');
        $button_text_before_login = get_theme_mod('edumodo_header_button_text', 'Login');
        $button_url_before_login = get_theme_mod('edumodo_header_button_link', wp_login_url());
        $button_text_after_login = get_theme_mod('edumodo_header_button_text_after_login_in', 'Logout');
        $button_url_after_login = get_theme_mod('edumodo_header_button_link_after_login_in', wp_logout_url());
        if ('on' === $login_button) :
        ?>
            <div class="login-wrapper">
                <?php if (is_user_logged_in()) : ?>
                    <a href="<?php echo $button_url_after_login ? $button_url_after_login : wp_logout_url(); ?>" class="logout-link">
                        <span>
                            <?php echo $button_text_after_login ? $button_text_after_login : esc_html('Logout', 'edumodo'); ?>
                        </span>
                    </a>
                <?php else : ?>
                    <a href="<?php echo $button_url_before_login ? $button_url_before_login : wp_login_url(); ?>" class="login-link">
                        <span>
                            <?php echo $button_text_before_login ? $button_text_before_login : esc_html('Login', 'edumodo'); ?>
                        </span>
                    </a>
                <?php endif; ?>
            </div>
        <?php
        endif;
    }

    public function edumodo__get_post_id()
    {
        global $wp_query;
        return $wp_query->get_queried_object_id();
    }
    public function edumodo__enable_archive_hero_area()
    {
        $enable_archive_hero_area =  get_theme_mod('edumodo_section_enable_page_title', 'on');
        return $enable_archive_hero_area === 'on';
    }
    /**
     * need to delete this function 
     */
    public function edumodo__enable_single_hero_area()
    {
        $enable_single_hero_area =  get_theme_mod('edumodo_section_enable_page_title', 'on');
        return $enable_single_hero_area === 'on';
    }
    public function edumodo__enable_breadcrumb()
    {
        $enable_breadcrumb =  get_theme_mod('edumodo_enable_breadcrumb', 'on');
        return $enable_breadcrumb === 'on';
    }
    public function edumodo__enable_archive_search()
    {
        $enable_archive_search =  get_theme_mod('edumodo_blog_archive_search', true);
        return $enable_archive_search;
    }
    public function edumodo__single_page_hero_area_active($id)
    {
        $single_page_hero_area_action =  get_post_meta($id, '_edumodo_title_enable', true);
        return $single_page_hero_area_action;
    }
    public function edumodo__get_single_post_hero_image_url($id)
    {
        $single_post_hero_image_url =  get_post_meta($id, '_edumodo_header_img', true);
        return $single_post_hero_image_url;
    }
    public function edumodo__get_single_post_hero_title($id)
    {
        $single_post_hero_title =  get_post_meta($id, '_edumodo_page_title', true);
        return $single_post_hero_title;
    }
    public function edumodo__get_theme_mod_data($key = '', $default = '')
    {
        $single_mod_data_from_customizer =  get_theme_mod($key, $default);
        return $single_mod_data_from_customizer;
    }


    public function page_header_title_breadcrumb()
    {
        if ('enable' == $this->edumodo__single_page_hero_area_active($this->edumodo__get_post_id())) {
            $bg_image_single_page = $this->edumodo__get_single_post_hero_image_url($this->edumodo__get_post_id()) ? $this->edumodo__get_single_post_hero_image_url($this->edumodo__get_post_id()) : get_theme_mod('edumodo_blog_related_page_header_image', '');
            $page_custom_title = $this->edumodo__get_single_post_hero_title($this->edumodo__get_post_id());
            $title = $page_custom_title ?: get_the_title();
            $this->render_single_title_breadcrumb_content($bg_image_single_page, $title);
        } else {
            $this->render_blank_space_after_page_hero_area();
        }
    }

    /**
     * blog 
     */
    public function blog_header_title_breadcrumb()
    {
        if (is_home() && $this->edumodo__enable_archive_hero_area()) {
            $bg_img_blog = get_theme_mod('edumodo_blog_related_page_header_image', '');
            $blog_archive_custom_title = $this->edumodo__get_theme_mod_data('edumodo_blog_archive_custom_title');
            $title = $blog_archive_custom_title ?: get_the_archive_title();
            $this->render_archive_title_breadcrumb_content($bg_img_blog, $title);
        } elseif (is_single() && $this->edumodo__enable_single_hero_area()) {
            $blog_single_custom_title = $this->edumodo__get_theme_mod_data('edumodo_blog_single_hero_area_custom_title', 'Blog');
            $title = $blog_single_custom_title ?: get_the_title();
            $bg_img_single_blog = $this->edumodo__get_theme_mod_data('edumodo_blog_related_page_header_image');
            $this->render_single_title_breadcrumb_content($bg_img_single_blog, $title);
        } elseif (is_archive() && $this->edumodo__enable_archive_hero_area()) {
            $bg_img_blog = get_theme_mod('edumodo_blog_related_page_header_image', '');
            $blog_archive_custom_title = $this->edumodo__get_theme_mod_data('edumodo_blog_archive_custom_title', 'Blog');
            $title = $blog_archive_custom_title ?: get_the_archive_title();
            $this->render_archive_title_breadcrumb_content($bg_img_blog, $title);
        } elseif (!$this->edumodo__enable_archive_hero_area()) {
            $this->render_blank_space_after_page_hero_area();
        }
    }
    /**
     * notice 
     */
    public function notice_header_title_breadcrumb()
    {
        if (is_archive() && $this->edumodo__enable_archive_hero_area()) {
            $bg_img_notice = $this->edumodo__get_theme_mod_data('edumodo_notice_page_header_image');
            $notice_archive_custom_title = $this->edumodo__get_theme_mod_data('edumodo_notice_archive_title', 'All Notices');
            $title = $notice_archive_custom_title ?: get_the_archive_title();
            $this->render_archive_title_breadcrumb_content($bg_img_notice, $title);
        } elseif (is_single() && $this->edumodo__enable_single_hero_area()) {
            $bg_img_notice = $this->edumodo__get_theme_mod_data('edumodo_notice_page_header_image');
            $common_title_single_notice = $this->edumodo__get_theme_mod_data('edumodo_notice_single_hero_area_custom_title', 'Single Notice');
            $bg_image_single_notice = $this->edumodo__get_single_post_hero_image_url($this->edumodo__get_post_id());
            $bg_image_single_notice = $bg_image_single_notice ?: $bg_img_notice;
            $custom_title_single_notice = $this->edumodo__get_single_post_hero_title($this->edumodo__get_post_id());
            $title = $custom_title_single_notice ?: $common_title_single_notice ?: get_the_title();
            $this->render_single_title_breadcrumb_content($bg_image_single_notice, $title);
        } elseif (!$this->edumodo__enable_archive_hero_area()) {
            $this->render_blank_space_after_page_hero_area();
        }
    }
    /**
     * txcourse 
     */
    public function txcourse_header_title_breadcrumb()
    {
        if (is_archive() && $this->edumodo__enable_archive_hero_area()) {
            $bg_img_txcourse = $this->edumodo__get_theme_mod_data('edumodo_txcourse_page_header_image');
            $txcourse_archive_custom_title = $this->edumodo__get_theme_mod_data('edumodo_txcourse_archive_custom_title', 'All Courses');
            $title = $txcourse_archive_custom_title ?: get_the_archive_title();
            $this->render_archive_title_breadcrumb_content($bg_img_txcourse, $title);
        } elseif (is_single() && $this->edumodo__enable_single_hero_area()) {
            $bg_img_txcourse = $this->edumodo__get_theme_mod_data('edumodo_txcourse_page_header_image');
            $common_title_single_txcourse = $this->edumodo__get_theme_mod_data('edumodo_txcourse_single_custom_title');
            $bg_image_single_txcourse = $this->edumodo__get_single_post_hero_image_url($this->edumodo__get_post_id());
            $bg_image_single_txcourse = $bg_image_single_txcourse ?: $bg_img_txcourse;
            $custom_title_single_txcourse = $this->edumodo__get_single_post_hero_title($this->edumodo__get_post_id());
            $title = $custom_title_single_txcourse ?: $common_title_single_txcourse ?: get_the_title();
            $this->render_single_title_breadcrumb_content($bg_image_single_txcourse, $title);
        } elseif (!$this->edumodo__enable_archive_hero_area()) {
            $this->render_blank_space_after_page_hero_area();
        }
    }
    /**
     * teacher 
     */
    // public function teacher_header_title_breadcrumb()
    // {
    //     if (is_archive() && $this->edumodo__enable_archive_hero_area()) {
    //         $bg_img_teacher = $this->edumodo__get_theme_mod_data('edumodo_teacher_page_header_image');
    //         $teacher_archive_custom_title = $this->edumodo__get_theme_mod_data('edumodo_teacher_archive_custom_title');
    //         $title = $teacher_archive_custom_title ?: get_the_archive_title();
    //         $this->render_archive_title_breadcrumb_content($bg_img_teacher, $title);
    //     } elseif (is_single() && $this->edumodo__enable_single_hero_area()) {
    //         $bg_img_teacher = $this->edumodo__get_theme_mod_data('edumodo_teacher_page_header_image');
    //         $commont_title_single_teacher = $this->edumodo__get_theme_mod_data('edumodo_teacher_single_hero_area_custom_title');
    //         $bg_image_single_teacher = $this->edumodo__get_single_post_hero_image_url($this->edumodo__get_post_id());
    //         $bg_image_single_teacher = $bg_image_single_teacher ?: $bg_img_teacher;
    //         $custom_title_single_teacher = $this->edumodo__get_single_post_hero_title($this->edumodo__get_post_id());
    //         $title = $custom_title_single_teacher ?: $commont_title_single_teacher ?: get_the_title();
    //         $this->render_single_title_breadcrumb_content($bg_image_single_teacher, $title);
    //     } elseif (!$this->edumodo__enable_archive_hero_area()) {
    //         $this->render_blank_space_after_page_hero_area();
    //     }
    // }
    /**
     * learndash 
     */
    public function learndash_header_title_breadcrumb()
    {
        if (is_archive()) {
            $this->render_archive_title_breadcrumb_content('', 'archive title');
        } elseif (is_single()) {
            $this->render_single_title_breadcrumb_content('', 'single title');
        } elseif (!$this->edumodo__enable_archive_hero_area()) {
            $this->render_blank_space_after_page_hero_area();
        }
    }
    /**
     * learnpress 
     */
    // public function learnpress_header_title_breadcrumb()
    // {
    //     if (is_archive() && $this->edumodo__enable_archive_hero_area()) {
    //         $bg_img_learnpress = $this->edumodo__get_theme_mod_data('edumodo_learnpress_page_header_image');
    //         $learnpress_archive_custom_title = $this->edumodo__get_theme_mod_data('edumodo_learnpress_archive_custom_title');
    //         $title = $learnpress_archive_custom_title ?: get_the_archive_title();
    //         $this->render_archive_title_breadcrumb_content($bg_img_learnpress, $title);
    //     } elseif (is_single() && $this->edumodo__enable_single_hero_area()) {
    //         $learnpress_single_custom_title = $this->edumodo__get_theme_mod_data('edumodo_learnpress_single_hero_area_custom_title');
    //         $title = $learnpress_single_custom_title ?: get_the_title();
    //         $bg_img_learnpress = $this->edumodo__get_theme_mod_data('edumodo_learnpress_single_page_header_image');
    //         $bg_image_single_learnpress = $this->edumodo__get_single_post_hero_image_url($this->edumodo__get_post_id());
    //         $bg_image_single_learnpress = $bg_image_single_learnpress ?: $bg_img_learnpress;
    //         $custom_title_single_teacher = $this->edumodo__get_single_post_hero_title($this->edumodo__get_post_id());
    //         $title = $custom_title_single_teacher ?: $title;
    //         $this->render_single_title_breadcrumb_content($bg_image_single_learnpress, $title);
    //     } elseif (!$this->edumodo__enable_archive_hero_area()) {
    //         $this->render_blank_space_after_page_hero_area();
    //     }
    // }
    /**
     * lifter 
     */
    public function lifter_header_title_breadcrumb()
    {
        if (is_archive() && $this->edumodo__enable_archive_hero_area()) {
            $bg_img_lifter = $this->edumodo__get_theme_mod_data('edumodo_lifter_related_page_header_image');
            $lifter_archive_custom_title = $this->edumodo__get_theme_mod_data('edumodo_lifter_archive_custom_title');
            $title = $lifter_archive_custom_title ?: get_the_archive_title();
            $this->render_archive_title_breadcrumb_content($bg_img_lifter, $title);
        } elseif (is_single() && $this->edumodo__enable_single_hero_area()) {
            $bg_img_lifter = $this->edumodo__get_theme_mod_data('edumodo_lifter_related_page_header_image');
            $bg_image_single_lifter = $this->edumodo__get_single_post_hero_image_url($this->edumodo__get_post_id());
            $bg_image_single_lifter = $bg_image_single_lifter ?: $bg_img_lifter;
            $all_single_course_custom_title = $this->edumodo__get_theme_mod_data('edumodo_lifter_course_single_custom_title', 'Course Single');
            // $custom_title_single_teacher = $this->edumodo__get_single_post_hero_title( $this->edumodo__get_post_id() );
            $title = $all_single_course_custom_title ?: get_the_title();
            $this->render_single_title_breadcrumb_content($bg_image_single_lifter, $title);
        } elseif (!$this->edumodo__enable_archive_hero_area()) {
            $this->render_blank_space_after_page_hero_area();
        }
    }
    /**
     * tutor 
     */
    // public function tutor_header_title_breadcrumb()
    // {
    //     if (is_archive() && $this->edumodo__enable_archive_hero_area()) {
    //         $bg_img_tutor = $this->edumodo__get_theme_mod_data('edumodo_tutorlms_page_header_image');
    //         $lifter_archive_custom_title = $this->edumodo__get_theme_mod_data('edumodo_tutor_archive_custom_title');
    //         $title = $lifter_archive_custom_title ?: get_the_archive_title();
    //         $this->render_archive_title_breadcrumb_content($bg_img_tutor, $title);
    //     } elseif (is_single() && $this->edumodo__enable_single_hero_area()) {
    //         $bg_img_tutor = $this->edumodo__get_theme_mod_data('edumodo_tutorlms_page_header_image');
    //         $common_title_for_single = $this->edumodo__get_theme_mod_data('edumodo_tutor_single_hero_area_custom_title');
    //         $bg_image_single_tutor = $this->edumodo__get_single_post_hero_image_url($this->edumodo__get_post_id());
    //         $bg_image_single_tutor = $bg_image_single_tutor ?: $bg_img_tutor;
    //         $custom_title_single_tutor_course = $this->edumodo__get_single_post_hero_title($this->edumodo__get_post_id());
    //         $title = $custom_title_single_tutor_course ?: $common_title_for_single ?: get_the_title();
    //         $this->render_single_title_breadcrumb_content($bg_image_single_tutor, $title);
    //     } elseif (!$this->edumodo__enable_archive_hero_area()) {
    //         $this->render_blank_space_after_page_hero_area();
    //     }
    // }
    /**
     * event 
     */
    public function event_header_title_breadcrumb()
    {
        if (is_archive() && $this->edumodo__enable_archive_hero_area()) {
            $bg_img_event = $this->edumodo__get_theme_mod_data('edumodo_event_page_header_image');
            $event_archive_custom_title = $this->edumodo__get_theme_mod_data('edumodo_event_archive_custom_title');
            $title = $event_archive_custom_title ?: get_the_archive_title();
            $this->render_archive_title_breadcrumb_content($bg_img_event, $title);
        } elseif (is_single() && $this->edumodo__enable_single_hero_area()) {
            $bg_img_event_archive = $this->edumodo__get_theme_mod_data('edumodo_event_page_header_image');
            $bg_image_single_event = $this->edumodo__get_single_post_hero_image_url($this->edumodo__get_post_id());
            $bg_image_single_event = $bg_image_single_event ?: $bg_img_event_archive;
            $custom_title_single_event = $this->edumodo__get_single_post_hero_title($this->edumodo__get_post_id());
            $title = $custom_title_single_event ?: get_the_title();
            $this->render_single_title_breadcrumb_content($bg_image_single_event, $title);
        } elseif (!$this->edumodo__enable_archive_hero_area()) {
            $this->render_blank_space_after_page_hero_area();
        }
    }
    /**
     * sensei 
     */
    public function sensei_header_title_breadcrumb()
    {
        if (is_archive()) {
            $this->render_archive_title_breadcrumb_content('', 'archive title');
        } elseif (is_single()) {
            $this->render_single_title_breadcrumb_content('', 'single title');
        } elseif (!$this->edumodo__enable_archive_hero_area()) {
            $this->render_blank_space_after_page_hero_area();
        }
    }
    /**
     * WooCommerce 
     */
    public function woocommerce_header_title_breadcrumb()
    {
        if (is_archive() && $this->edumodo__enable_archive_hero_area()) {
            $bg_img_woo = $this->edumodo__get_theme_mod_data('edumodo_woocommerce_page_header_image');
            $woo_archive_custom_title = $this->edumodo__get_theme_mod_data('edumodo_woocommerce_archive_custom_title', 'Products');
            $title = $woo_archive_custom_title ?: get_the_archive_title();
            $this->render_archive_title_breadcrumb_content($bg_img_woo, $title);
        } elseif (is_single() && $this->edumodo__enable_single_hero_area()) {
            $bg_img_woo = $this->edumodo__get_theme_mod_data('edumodo_woocommerce_page_header_image');
            $common_title_for_single = $this->edumodo__get_theme_mod_data('edumodo_woocommerce_single_hero_area_custom_title', 'Single Product');
            $bg_image_single_product = $bg_img_woo ?: '';
            $title = $common_title_for_single ?: get_the_title();
            $this->render_single_title_breadcrumb_content($bg_image_single_product, $title);
        } elseif (!$this->edumodo__enable_archive_hero_area()) {
            $this->render_blank_space_after_page_hero_area();
        }
    }
    /**
     * bbPress 
     */
    public function bbpress_header_title_breadcrumb()
    {
        $fallback_image = $this->edumodo__get_theme_mod_data('edumodo_blog_related_page_header_image');
        if (is_archive() && $this->edumodo__enable_archive_hero_area()) {
            $bg_img_bb = $this->edumodo__get_theme_mod_data('edumodo_forum_page_header_image');
            $bg_img_bb = $bg_img_bb ?: $fallback_image;
            $bb_archive_custom_title = $this->edumodo__get_theme_mod_data('edumodo_forum_archive_custom_title');
            $title = $bb_archive_custom_title ?: get_the_archive_title();
            $this->render_archive_title_breadcrumb_content($bg_img_bb, $title);
        } elseif (is_single() && $this->edumodo__enable_single_hero_area()) {
            $bg_img_bb = $this->edumodo__get_theme_mod_data('edumodo_forum_page_header_image');
            $bg_img_bb = $bg_img_bb ?: $fallback_image;
            $bg_image_single_product = $bg_img_bb ?: '';
            $title = get_the_title();
            $this->render_single_title_breadcrumb_content($bg_image_single_product, $title);
        } elseif (!$this->edumodo__enable_archive_hero_area()) {
            $this->render_blank_space_after_page_hero_area();
        }
    }
    /**
     * BuddyPress 
     */
    public function buddypress_header_title_breadcrumb()
    {
        $fallback_image = $this->edumodo__get_theme_mod_data('edumodo_blog_related_page_header_image');
        if (bp_is_current_component(BP_MEMBERS_SLUG) || bp_is_current_component(BP_ACTIVITY_SLUG) || bp_is_current_component(BP_GROUPS_SLUG)) {
            if (bp_is_current_component(BP_ACTIVITY_SLUG)) {
                $bg_img_bp = $this->edumodo__get_theme_mod_data('edumodo_activity_page_header_image');
                $common_title_for_bp = $this->edumodo__get_theme_mod_data('edumodo_activity_archive_custom_title');
            } elseif (bp_is_current_component(BP_MEMBERS_SLUG)) {
                $bg_img_bp = $this->edumodo__get_theme_mod_data('edumodo_member_page_header_image');
                $common_title_for_bp = $this->edumodo__get_theme_mod_data('edumodo_member_archive_custom_title');
            } elseif (bp_is_current_component(BP_GROUPS_SLUG)) {
                $bg_img_bp = $this->edumodo__get_theme_mod_data('edumodo_group_page_header_image');
                $common_title_for_bp = $this->edumodo__get_theme_mod_data('edumodo_group_archive_custom_title');
            } else {
                $bg_img_bp = $this->edumodo__get_theme_mod_data('edumodo_blog_related_page_header_image');
            }
            $bg_img_bp = $bg_img_bp ?: $fallback_image;
            $title = $common_title_for_bp ?: get_the_title();
            $is_front_page = is_front_page();
            $this->render_archive_title_breadcrumb_content($bg_img_bp, $title, $is_front_page);
        } else {
            $bg_img_bp = $this->edumodo__get_theme_mod_data('edumodo_activity_page_header_image');
            $bg_img_bp = $bg_img_bp ?: $fallback_image;
            $title = get_the_title();
            $this->render_archive_title_breadcrumb_content($bg_img_bp, $title);
        }
    }

    /**
     * archive content area 
     */
    public function render_archive_title_breadcrumb_content($img = '', $title = '', $is_front_page = false)
    {
        if (!$is_front_page) :
        ?>
            <div class="page-details" style="<?php if ($img) : ?>background-image: url(<?php echo esc_url($img); ?>); <?php else : ?><?php endif; ?>">
                <div class="container">
                    <div class="row ">
                        <div class="page-wrapper">
                            <div class="row">

                                <div class="col-lg-8">
                                    <h2 class="page-title edumodo-archive-title">
                                        <?php echo $title; ?>
                                    </h2>

                                    <?php //if ( $this->edumodo__enable_breadcrumb() ): 
                                    ?>
                                    <?php edumodo_breadcrumb(); ?>
                                    <?php //endif;
                                    ?>
                                </div>

                                <?php if ($this->edumodo__enable_archive_search()) : ?>
                                    <div class="col-lg-4">
                                        <?php $this->render_search_content(); ?>
                                    </div>
                                <?php endif; ?>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <?php
        else :
            if (!$is_front_page) :
            ?>
                <div class="page-details-blank"></div>
            <?php
            endif;
        endif;
    }
    /**
     * single header area
     */
    public function render_single_title_breadcrumb_content($img = '', $title = '', $is_front_page = false)
    {
        $enable_breadcrumb = get_theme_mod('edumodo_breadcrumb_trigger', 'on');
        if (!$is_front_page) :
            ?>
            <div class="page-details" style="<?php if ($img) : ?>background-image: url(<?php echo esc_url($img); ?>); <?php else : ?><?php endif; ?>">
                <div class="container">
                    <div class="row">
                        <div class="page-wrapper">
                            <h2 class="page-title edumodo-single-title">
                                <?php esc_html_e($title, 'edumodo'); ?>
                            </h2>
                            <?php if ($enable_breadcrumb == 'on') : ?>
                                <?php edumodo_breadcrumb(); ?>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
            </div>
        <?php
        else : ?>
            <?php if (!is_front_page()) : ?>
                <div class="page-details-blank"></div>
            <?php endif; ?>
        <?php endif;
    }
    public function render_blank_space_after_page_hero_area()
    {
        if (!is_front_page()) :
        ?>
            <div class="page-details-blank"></div>
        <?php
        endif;
    }
    /**
     * search content
     */
    public function render_search_content()
    {
        ?>
        <div>
            <div class="edumodo-top-search">
                <form role="search" method="get" class="search-form" action="<?php echo home_url('/'); ?>">
                    <label for="<?php echo esc_attr('Search') ?>">
                        <span class="screen-reader-text">
                            <?php esc_html_e('Search For', 'edumodo'); ?>
                        </span>
                        <input type="search" class="search-field" placeholder="<?php echo esc_attr('Search courses') ?>" value="<?php echo get_search_query() ?>" name="s" title="<?php echo esc_attr('Search for:') ?>" />
                    </label>
                    <input type="submit" class="search-submit" value="<?php echo esc_attr('Search') ?>" />
                </form>
            </div>
        </div>
<?php
    }
    /**
     * filter the archive title
     */
    function edumodo_modifiy_theme_archive_title($title)
    {
        $title = esc_html('Blog', 'edumodo');
        if (is_category()) {
            $title = single_cat_title('', false);
        } elseif (is_tag()) {
            $title = single_tag_title('', false);
        } elseif (is_author()) {
            $title = '<span class="vcard">' . get_the_author() . '</span>';
        } elseif (is_post_type_archive()) {
            $title = post_type_archive_title('', false);
        } elseif (is_tax()) {
            $title = single_term_title('', false);
        }

        return $title;
    }
}
?>