<?php
/**
 * @package Legacy Medical Appointment
 */

/**
 * Footer
 */
if (! function_exists( 'legacy_medical_appointment_footer_copyrights' ) ):
    function legacy_medical_appointment_footer_copyrights() {
        ?>
            <div class="row">
                <div class="copyrights">
                    <p>
                        <?php
                            if("" != esc_html(get_theme_mod( 'legacy_medical_appointment_footer_copyright_text'))) :
                                echo esc_html(get_theme_mod( 'legacy_medical_appointment_footer_copyright_text'));
                                if(get_theme_mod('legacy_medical_appointment_en_footer_credits',true)) :
                                    ?> 
                                    <span class="copyrg-link"><a href="<?php echo esc_url(LEGACY_MEDICAL_APPOINTMENT_AUT); ?>" target="_blank" rel="nofollow noopener"><?php esc_html_e(' | Medical Appointment WordPress Theme','legacy-medical-appointment') ?></a><?php esc_html_e(' by Legacy Themes','legacy-medical-appointment') ?></span>
                                    <?php   
                                endif;
                            else :
                                echo date_i18n(
                                    /* translators: Copyright date format, see https://secure.php.net/date */
                                    _x( 'Y', 'copyright date format', 'legacy-medical-appointment' )
                                );
                                ?>
                                    <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a>
                                    <span class="copyrg-link"><a href="<?php echo esc_url(LEGACY_MEDICAL_APPOINTMENT_AUT); ?>" target="_blank" rel="nofollow noopener"><?php esc_html_e(' | Medical Appointment WordPress Theme','legacy-medical-appointment') ?></a><?php esc_html_e(' by Legacy Themes','legacy-medical-appointment') ?></span>
                                <?php
                            endif;
                        ?>
                    </p>
                </div>
            </div>
        <?php    
    }
endif;
add_action( 'legacy_medical_appointment_action_footer', 'legacy_medical_appointment_footer_copyrights' );

/**
 * Page Title Settings
 */
if (!function_exists('legacy_medical_appointment_show_page_title')) :
    function legacy_medical_appointment_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
                                    if (is_singular('post')) {
                                        // Single blog post
                                        echo '<h1 class="main-title">' . get_the_title() . '</h1>';
                                    } elseif (is_category()) {
                                        echo '<h1 class="main-title">' . single_cat_title('', false) . '</h1>';
                                    } elseif (is_tag()) {
                                        echo '<h1 class="main-title">' . single_tag_title('', false) . '</h1>';
                                    } elseif (is_author()) {
                                        echo '<h1 class="main-title">' . get_the_author() . '</h1>';
                                    } elseif (is_archive()) {
                                        echo '<h1 class="main-title">' . get_the_archive_title() . '</h1>';
                                    } elseif (is_search()) {
                                        echo '<h1 class="main-title">' . esc_html__('Search Results', 'legacy-medical-appointment') . '</h1>';
                                    } elseif (is_404()) {
                                        echo '<h1 class="main-title">' . esc_html__('Page Not Found', 'legacy-medical-appointment') . '</h1>';
                                    } else {
                                        echo '<h1 class="main-title">' . get_the_title() . '</h1>';
                                    }
                                    ?>
                                </div>                      
                            </div>
                        </div>
                    </div>  
                </div>
            </div>  <!-- End page-title --> 
            <?php
        }
    }
endif;

/**
 * Home Banner Section
 */
if (! function_exists( 'legacy_medical_appointment_home_banner_section' ) ):
    function legacy_medical_appointment_home_banner_section() {
        ?>
        <section id="main-banner-wrap">
            <?php
                $legacy_medical_appointment_banner_image = get_theme_mod( 'legacy_medical_appointment_banner_image', '' );
                if ( ! empty( $legacy_medical_appointment_banner_image ) ) { ?>
            <div class="banner-side-margin position-relative">
                <div class="main-banner-inner-box">                   
                    <img src="<?php echo esc_url( $legacy_medical_appointment_banner_image ); ?>">
                </div>
                <?php
                $legacy_medical_appointment_alignment_class = get_theme_mod( 'legacy_medical_appointment_slider_content_alignment', 'left' );
                ?>
                <div class="main-banner-content-box content-<?php echo esc_attr( $legacy_medical_appointment_alignment_class ); ?>">
                    <?php
                        $legacy_medical_appointment_banner_small_head = get_theme_mod( 'legacy_medical_appointment_banner_small_head', '' );
                        if ( ! empty( $legacy_medical_appointment_banner_small_head ) ) { ?>
                        <h6 class="bnnr-sm-hd m-0 p-0"><?php echo esc_html( $legacy_medical_appointment_banner_small_head ); ?></h6>
                    <?php } ?>
                    <?php
                        $legacy_medical_appointment_banner_heading = get_theme_mod( 'legacy_medical_appointment_banner_heading', '' );                        
                        if ( ! empty( $legacy_medical_appointment_banner_heading ) ) { ?>
                            <h2 class="bnr-hd1 pt-2"><?php echo esc_html( $legacy_medical_appointment_banner_heading ); ?></h2>
                    <?php } ?>
                    <?php
                        $legacy_medical_appointment_banner_text = get_theme_mod( 'legacy_medical_appointment_banner_text', '' );                        
                        if ( ! empty( $legacy_medical_appointment_banner_text ) ) { ?>
                            <p class="bnr-txt mt-1 mb-3 me-lg-5 pe-lg-5"><?php echo esc_html( $legacy_medical_appointment_banner_text ); ?></p>
                    <?php } ?>
                    <div class="btn-box-slid">
                        <span>
                            <?php
                            $legacy_medical_appointment_banner_button_link = get_theme_mod( 'legacy_medical_appointment_banner_button_link', '' );
                                if ( ! empty( $legacy_medical_appointment_banner_button_link ) ) { ?>
                                <a class="btn-1-slid px-2 py-1 me-2" href="<?php echo esc_url( $legacy_medical_appointment_banner_button_link ); ?>"><?php echo esc_html('Book Online','legacy-medical-appointment'); ?></a>
                            <?php } ?>
                        </span>
                        <span>
                            <?php
                            $legacy_medical_appointment_banner_button_link2 = get_theme_mod( 'legacy_medical_appointment_banner_button_link2', '' );
                                if ( ! empty( $legacy_medical_appointment_banner_button_link2 ) ) { ?>
                                <a class="btn-2-slid px-3 py-1" href="<?php echo esc_url( $legacy_medical_appointment_banner_button_link2 ); ?>"><?php echo esc_html('More Info','legacy-medical-appointment'); ?></a>
                            <?php } ?>
                        </span>
                    </div>
                    <?php
                        $legacy_medical_appointment_banner_scedule_day = get_theme_mod( 'legacy_medical_appointment_banner_scedule_day', '' );
                        $legacy_medical_appointment_banner_schedule_time = get_theme_mod( 'legacy_medical_appointment_banner_schedule_time', '' );
                        if ( ! empty( $legacy_medical_appointment_banner_scedule_day) ||  ! empty( $legacy_medical_appointment_banner_schedule_time) ) { ?>
                        <div class="scedule-box mt-3 py-2">
                            <div class="row">
                                <div class="col-lg-3 col-md-3 col-3 align-self-center text-end">
                                    <i class="bi bi-clock-fill clck-icon"></i>
                                </div>
                                <div class="col-lg-9 col-md-9 col-9 align-self-center ps-lg-0">
                                    <h6 class="scdul-day p-0 m-0"><?php echo esc_html( $legacy_medical_appointment_banner_scedule_day ); ?></h6>
                                    <h6 class="schdl-time p-0 m-0"><?php echo esc_html( $legacy_medical_appointment_banner_schedule_time ); ?></h6>
                                </div>
                            </div>
                        </div>
                    <?php } ?> 
                </div>
                <?php
                    $legacy_medical_appointment_banner_offer_head = get_theme_mod( 'legacy_medical_appointment_banner_offer_head', '' );
                    $legacy_medical_appointment_banner_offer_text = get_theme_mod( 'legacy_medical_appointment_banner_offer_text', '' );
                    if ( ! empty( $legacy_medical_appointment_banner_offer_head) ||  ! empty( $legacy_medical_appointment_banner_offer_text) ) { ?>
                    <div class="offer-box text-center">
                        <p id="offer-heading" class="offer-hd p-0 m-0"><?php echo esc_html( $legacy_medical_appointment_banner_offer_head ); ?></p>
                        <p class="offer-txt p-0 m-0"><?php echo esc_html( $legacy_medical_appointment_banner_offer_text ); ?></p>
                    </div>
                <?php } ?>    
            </div>
            <?php } ?>
        </section>
        <?php
    }
endif;
add_action( 'legacy_medical_appointment_action_home_banner', 'legacy_medical_appointment_home_banner_section' );

/**
 * Home Blog Section
 */
if (! function_exists( 'legacy_medical_appointment_home_blog_section' ) ):
    function legacy_medical_appointment_home_blog_section() {
        ?>
        <section id="lat-news-wrap" class="py-3">
            <div class="container">
                <div class="inner-wrap">
                    <div class="lat-news-head text-center">
                        <?php
                            $legacy_medical_appointment_latest_news_small_heading = get_theme_mod( 'legacy_medical_appointment_latest_news_small_heading', '' );
                            if ( ! empty( $legacy_medical_appointment_latest_news_small_heading ) ) { ?>
                            <h6 class="news-sm-hd py-2 m-auto"><?php echo esc_html( $legacy_medical_appointment_latest_news_small_heading ); ?></h6>
                        <?php } ?>
                        <?php
                            $legacy_medical_appointment_latest_news_main_heading = get_theme_mod( 'legacy_medical_appointment_latest_news_main_heading', '' );
                            if ( ! empty( $legacy_medical_appointment_latest_news_main_heading ) ) { ?>
                            <h3 class="news-main-hd py-2 mb-0"><?php echo esc_html( $legacy_medical_appointment_latest_news_main_heading ); ?></h3>
                        <?php } ?>
                    </div>
                    <div class="lat-news-box">
                        <div class="owl-carousel">
                            <?php
                            $legacy_medical_appointment_post_category = get_theme_mod('legacy_medical_appointment_selected_category', '');                               
                            $legacy_medical_appointment_latest_news_number = get_theme_mod('legacy_medical_appointment_latest_news_number', 4);  
                                if($legacy_medical_appointment_post_category){               
                                $args = array(
                                    'post_type'      => 'post',
                                    'posts_per_page' => $legacy_medical_appointment_latest_news_number,
                                    'order'          => 'ASC',
                                    'category_name' => esc_html($legacy_medical_appointment_post_category ,'legacy-medical-appointment'),    
                                );                                
                                $legacy_medical_appointment_loop = new WP_Query( $args );
                                while ( $legacy_medical_appointment_loop->have_posts() ) : $legacy_medical_appointment_loop->the_post();
                            ?>
                            <div class="lat-news-inn">
                                <?php if(has_post_thumbnail()){ ?>
                                    <img src="<?php the_post_thumbnail_url('full'); ?>" class="blog-image">
                                <?php } ?>
                                <div class="news-content py-3 px-4 text-center text-lg-start text-md-start">
                                    <h6 class="news-inner-head pt-0"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h6>                                
                                    <div class="blog-btn">
                                        <a class="news-btn" href="<?php the_permalink(); ?>"><?php echo esc_html('Read More','legacy-medical-appointment'); ?></a>
                                    </div>
                                    <p class="news-date mb-0 pt-2"><i class="bi bi-calendar3 news-icon"></i> <?php the_time(get_option('date_format')) ?></p>
                                </div>                                  
                            </div>                                                       
                             <?php endwhile; wp_reset_postdata(); }?>
                        </div>
                    </div>
                </div>                
            </div>
        </section>
        <?php    
    }
endif;
add_action( 'legacy_medical_appointment_action_home_blog', 'legacy_medical_appointment_home_blog_section' );

/**
 * Home page another adding Section
 */
if (! function_exists( 'legacy_medical_appointment_home_extra_section' ) ):
    function legacy_medical_appointment_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( 'legacy_medical_appointment_action_home_extra', 'legacy_medical_appointment_home_extra_section' );