<?php
/**
 * @package Jungle Eco Tours
 */

/**
 * Footer
 */
if (! function_exists( 'jungle_eco_tours_footer_copyrights' ) ):
    function jungle_eco_tours_footer_copyrights() {
        ?>
            <div class="row">
                <div class="copyrights">
                    <p>
                        <?php
                            if("" != esc_html(get_theme_mod( 'jungle_eco_tours_footer_copyright_text'))) :
                                echo esc_html(get_theme_mod( 'jungle_eco_tours_footer_copyright_text'));
                                if(get_theme_mod('jungle_eco_tours_en_footer_credits',true)) :
                                    ?> 
                                    <span class="copyrg-link"><a href="<?php echo esc_url(JUNGLE_ECO_TOURS_AUT); ?>" target="_blank" rel="nofollow noopener"><?php esc_html_e(' | Jungle Eco Tours WordPress Theme','jungle-eco-tours') ?></a><?php esc_html_e(' by Legacy Themes','jungle-eco-tours') ?></span>
                                    <?php   
                                endif;
                            else :
                                echo date_i18n(
                                    /* translators: Copyright date format, see https://secure.php.net/date */
                                    _x( 'Y', 'copyright date format', 'jungle-eco-tours' )
                                );
                                ?>
                                    <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a>
                                    <span class="copyrg-link"><a href="<?php echo esc_url(JUNGLE_ECO_TOURS_AUT); ?>" target="_blank" rel="nofollow noopener"><?php esc_html_e(' | Jungle Eco Tours WordPress Theme','jungle-eco-tours') ?></a><?php esc_html_e(' by Legacy Themes','jungle-eco-tours') ?></span>
                                <?php
                            endif;
                        ?>
                    </p>
                </div>
            </div>
        <?php    
    }
endif;
add_action( 'jungle_eco_tours_action_footer', 'jungle_eco_tours_footer_copyrights' );


/**
 * Page Title Settings
 */
if ( ! function_exists( 'jungle_eco_tours_show_page_title' ) ) :
    function jungle_eco_tours_show_page_title() {
        if ( ! is_front_page() ) {
            ?>
            <div class="page-title"> 
                <div class="content-section img-overlay">
                    <div class="container">
                        <div class="row text-center">
                            <div class="col-md-12">
                                <div class="section-title"> 
                                    <?php
                                    // WooCommerce Pages
                                    if ( function_exists( 'is_shop' ) && is_shop() ) {
                                        // Shop Page
                                        echo '<h1 class="main-title">' . esc_html__( 'Shop Page', 'jungle-eco-tours' ) . '</h1>';

                                    } elseif ( function_exists( 'is_product' ) && is_product() ) {
                                        // Single Product Page
                                        echo '<h1 class="main-title">' . esc_html__( 'Single Product Page', 'jungle-eco-tours' ) . '</h1>';

                                    } elseif ( function_exists( 'is_checkout' ) && is_checkout() ) {
                                        // Checkout Page
                                        echo '<h1 class="main-title">' . esc_html__( 'Checkout', 'jungle-eco-tours' ) . '</h1>';

                                    } elseif ( function_exists( 'is_account_page' ) && is_account_page() ) {
                                        // My Account Page
                                        echo '<h1 class="main-title">' . esc_html__( 'My Account', 'jungle-eco-tours' ) . '</h1>';

                                    } elseif ( is_home() ) {
                                        // Blog Index Page
                                        echo '<h1 class="main-title">' . esc_html__( 'Blog Page', 'jungle-eco-tours' ) . '</h1>';

                                    } elseif ( is_singular( 'post' ) ) {
                                        // Single Blog Post
                                        echo '<h1 class="main-title">' . esc_html( get_the_title() ) . '</h1>';

                                    } elseif ( is_category() ) {
                                        echo '<h1 class="main-title">' . esc_html( single_cat_title( '', false ) ) . '</h1>';

                                    } elseif ( is_tag() ) {
                                        echo '<h1 class="main-title">' . esc_html( single_tag_title( '', false ) ) . '</h1>';

                                    } elseif ( is_author() ) {
                                        echo '<h1 class="main-title">' . esc_html( get_the_author() ) . '</h1>';

                                    } elseif ( is_archive() ) {
                                        echo '<h1 class="main-title">' . wp_kses_post( get_the_archive_title() ) . '</h1>';

                                    } elseif ( is_search() ) {
                                        echo '<h1 class="main-title">' . esc_html__( 'Search Results', 'jungle-eco-tours' ) . '</h1>';

                                    } elseif ( is_404() ) {
                                        echo '<h1 class="main-title">' . esc_html__( 'Page Not Found', 'jungle-eco-tours' ) . '</h1>';

                                    } else {
                                        // Default for all other pages
                                        echo '<h1 class="main-title">' . esc_html( get_the_title() ) . '</h1>';
                                    }
                                    ?>
                                </div>                      
                            </div>
                        </div>
                    </div>  
                </div>
            </div>  <!-- End page-title --> 
            <?php
        }
    }
endif;

// Register page title action globally
add_action( 'jungle_eco_tours_get_page_title', 'jungle_eco_tours_show_page_title' );

/**
 * Home Banner Section
 */
if (! function_exists( 'jungle_eco_tours_home_banner_section' ) ):
    function jungle_eco_tours_home_banner_section() {
        ?>
        <section id="main-banner-wrap">
            <div class="slider-sec">
                <div class="owl-carousel">
                    <?php $jungle_eco_tours_banner_count = get_theme_mod("jungle_eco_tours_slider_increase");
                    for ($i = 1; $i <= $jungle_eco_tours_banner_count; $i++) { ?>
                        <?php
                        $jungle_eco_tours_banner_image = get_theme_mod( 'jungle_eco_tours_banner_image'.$i, '' );
                        if ( ! empty( $jungle_eco_tours_banner_image ) ) { ?>
                            <div class="banner-side-margin position-relative">
                                <div class="overlay-slider"></div>
                                <div class="main-banner-inner-box">
                                    <img src="<?php echo esc_url( $jungle_eco_tours_banner_image ); ?>">
                                </div>
                                <?php
                                $jungle_eco_tours_alignment_class = get_theme_mod( 'jungle_eco_tours_slider_content_alignment', 'left' );
                                ?>
                                <div class="main-banner-content-box content-<?php echo esc_attr( $jungle_eco_tours_alignment_class ); ?>">
                                    <?php
                                        $jungle_eco_tours_banner_small_head = get_theme_mod( 'jungle_eco_tours_banner_small_head'.$i, '' );
                                        if ( ! empty( $jungle_eco_tours_banner_small_head ) ) { ?>                                 
                                            <h6 class="bnr-sm-hd p-0 mb-5"><?php echo esc_html(jungle_eco_tours_get_text_excerpt( $jungle_eco_tours_banner_small_head,7 )); ?></h6>
                                    <?php } ?>
                                    <?php
                                        $jungle_eco_tours_banner_heading = get_theme_mod( 'jungle_eco_tours_banner_heading'.$i, '' );
                                        if ( ! empty( $jungle_eco_tours_banner_heading ) ) { ?>
                                            <h2 class="bnr-heading p-0 mb-lg-4"><?php echo esc_html(jungle_eco_tours_get_text_excerpt( $jungle_eco_tours_banner_heading,4 )); ?></h2>
                                    <?php } ?>                             
                                   <div class="btn-box-slid py-3">
                                        <?php
                                        $jungle_eco_tours_banner_button_link = get_theme_mod( 'jungle_eco_tours_banner_button_link'.$i, '' );
                                            if ( ! empty( $jungle_eco_tours_banner_button_link ) ) { ?>
                                            <a class="btn-slid btn" href="<?php echo esc_url( $jungle_eco_tours_banner_button_link ); ?>"><?php echo esc_html('Discover More','jungle-eco-tours'); ?></a>
                                        <?php } ?>
                                    </div>
                                </div>    
                            </div>
                        <?php } ?>
                    <?php } ?>
                </div>
            </div>
        </section>
        <?php
    }
endif;
add_action( 'jungle_eco_tours_action_home_banner', 'jungle_eco_tours_home_banner_section' );


/**
 * Home about Section
 */
if (! function_exists( 'jungle_eco_tours_home_about_section' ) ):
    function jungle_eco_tours_home_about_section() {
    ?>
    <section id="about-wrap" class="py-5">
        <div class="container">
            <div class="row inner-wrap">
                <div class="col-lg-7 col-md-12 col-12 align-self-center">
                    <div class="serv-img-box text-center mb-0 mb-md-2 mb-lg-0">
                        <div class="row">
                            <div class="col-lg-5 col-md-5 col-12 align-self-end">
                                <?php
                                $jungle_eco_tours_about_left_image = get_theme_mod( 'jungle_eco_tours_about_left_image', '' );
                                if ( ! empty( $jungle_eco_tours_about_left_image ) ) { ?>
                                    <div class="abt-left-imgs">
                                        <img src="<?php echo esc_url( $jungle_eco_tours_about_left_image ); ?>">
                                    </div>
                                <?php } ?>
                            </div>
                            <div class="col-lg-7 col-md-7 col-12">
                               <?php
                                $jungle_eco_tours_about_right_image = get_theme_mod( 'jungle_eco_tours_about_right_image', '' );
                                if ( ! empty( $jungle_eco_tours_about_right_image ) ) { ?>
                                    <div class="abt-right-imgs">
                                        <img src="<?php echo esc_url( $jungle_eco_tours_about_right_image ); ?>">
                                    </div>
                                <?php } ?>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-5 col-md-12 col-12">
                    <div class="about-head-box ps-lg-4">
                        <?php
                        $jungle_eco_tours_about_small_heading = get_theme_mod( 'jungle_eco_tours_about_small_heading', '' );
                        if ( ! empty( $jungle_eco_tours_about_small_heading ) ) { ?>
                        <h6 class="abt-sm-hd p-0 mb-0"><?php echo esc_html( $jungle_eco_tours_about_small_heading ); ?></h6>
                        <?php } ?>
                        <?php
                        $jungle_eco_tours_about_main_heading = get_theme_mod( 'jungle_eco_tours_about_main_heading', '' );
                        if ( ! empty( $jungle_eco_tours_about_main_heading ) ) { ?>
                        <h3 class="abt-main-hd py-3 mb-0"><?php echo esc_html(jungle_eco_tours_get_text_excerpt( $jungle_eco_tours_about_main_heading,6 )); ?></h3>
                        <?php } ?>
                        <?php
                        $jungle_eco_tours_about_text1 = get_theme_mod( 'jungle_eco_tours_about_text1', '' );
                        if ( ! empty( $jungle_eco_tours_about_text1 ) ) { ?>
                        <p class="abt-txt1"><?php echo esc_html( $jungle_eco_tours_about_text1 ); ?></p>
                        <?php } ?>
                        <?php
                        $jungle_eco_tours_about_text2 = get_theme_mod( 'jungle_eco_tours_about_text2', '' );
                        if ( ! empty( $jungle_eco_tours_about_text2 ) ) { ?>
                        <p class="abt-txt2"><?php echo esc_html( $jungle_eco_tours_about_text2 ); ?></p>
                        <?php } ?>
                        <div class="btn-box-about">
                            <?php
                            $jungle_eco_tours_about_button_link = get_theme_mod( 'jungle_eco_tours_about_button_link', '#' );
                                if ( ! empty( $jungle_eco_tours_about_button_link ) ) { ?>
                                <a class="btn-abt btn" href="<?php echo esc_url( $jungle_eco_tours_about_button_link ); ?>"><?php echo esc_html('Learn More','jungle-eco-tours'); ?></a>
                            <?php } ?>
                        </div>
                    </div>
                </div>
            </div>                
        </div>
    </section>
    <?php    
    }
endif;
add_action( 'jungle_eco_tours_action_home_about', 'jungle_eco_tours_home_about_section' );

/**
 * Home page another adding Section
 */
if (! function_exists( 'jungle_eco_tours_home_extra_section' ) ):
    function jungle_eco_tours_home_extra_section() {
        ?>
        <div id="custom-home-extra-content" class="py-3">
            <div class="container">
              <?php while ( have_posts() ) : the_post(); ?>
                <?php the_content(); ?>
              <?php endwhile; ?>
            </div>
        </div>
        <?php    
    }
endif;
add_action( 'jungle_eco_tours_action_home_extra', 'jungle_eco_tours_home_extra_section' );