<?php
/**
 * The Template Name: Home Page
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 * @package Classic Dentist Clinic
 */

get_header(); ?>

<div id="content" >
    <?php
        $classic_dentist_clinic_hidepageboxes = get_theme_mod('classic_dentist_clinic_slider', true);
        $classic_dentist_clinic_catData = get_theme_mod('classic_dentist_clinic_slider_cat');
        if ($classic_dentist_clinic_hidepageboxes && $classic_dentist_clinic_catData) { ?>
        <section id="slider-cat">
            <div class="slideimg">
                <div class="owl-carousel m-0">
                    <?php
                        $classic_dentist_clinic_page_query = new WP_Query(
                            array(
                                'category_name' => esc_attr($classic_dentist_clinic_catData),
                                'posts_per_page' => -1,
                            )
                        );
                        while ($classic_dentist_clinic_page_query->have_posts()) : $classic_dentist_clinic_page_query->the_post(); ?>
                            <div class="imagebox position-relative">
                                <?php if(has_post_thumbnail()){
                                    the_post_thumbnail('full', array('class' => 'post-image'));
                                } else { ?>
                                    <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/slider.png" alt="<?php echo esc_attr( 'slider', 'classic-dentist-clinic'); ?>" class="post-image"/>
                                <?php } ?>
                                <div class="slider-overlay"></div>
                                <div class="text-content text-center position-absolute wow zoomIn" data-wow-duration="2s">
                                    <h1 class="slider-title text-uppercase mb-4"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                                    <div class="sliderbtn pt-3">
                                        <?php 
                                            $classic_dentist_clinic_button_text = get_theme_mod('classic_dentist_clinic_button_text', 'MAKE AN APPOINTMENT');
                                            $classic_dentist_clinic_button_link_slider = get_theme_mod('classic_dentist_clinic_button_link_slider', ''); 
                                            if (empty($classic_dentist_clinic_button_link_slider)) {
                                                $classic_dentist_clinic_button_link_slider = esc_url(get_permalink());
                                            }
                                            if ($classic_dentist_clinic_button_text || !empty($classic_dentist_clinic_button_link_slider)) { ?>
                                            <?php if(get_theme_mod('classic_dentist_clinic_button_text', 'MAKE AN APPOINTMENT') != ''){ ?>
                                                <a href="<?php echo esc_url($classic_dentist_clinic_button_link_slider); ?>" class="post-btn text-uppercase">
                                                    <?php echo esc_html($classic_dentist_clinic_button_text); ?>
                                                    <span class="screen-reader-text"><?php echo esc_html($classic_dentist_clinic_button_text); ?></span>
                                                </a>
                                            <?php } ?>
                                        <?php } ?>
                                    </div>
                                </div>
                            </div>
                        <?php endwhile;
                        wp_reset_postdata();
                    ?>
                </div>
            </div>
        </section>
    <?php } ?>

    <!-- Services Section -->
    <?php
        $classic_dentist_clinic_hide_services_section = get_theme_mod('classic_dentist_clinic_disabled_services_section', false);
        if ($classic_dentist_clinic_hide_services_section){ ?>
        <section id="services-section" class="position-relative">
            <?php if (get_theme_mod('classic_dentist_clinic_services_img') != "") { ?>
                <div class="services-img position-relative mb-5">
                    <img src="<?php echo esc_url(get_theme_mod('classic_dentist_clinic_services_img')); ?>" alt="<?php echo esc_attr( 'service', 'classic-dentist-clinic'); ?>"/>
                    <div class="services-overlay"></div>
                </div>
            <?php } ?>
            <div class="container">
                <div class="blog-bx mb-4 text-center position-absolute pt-5">
                    <?php if (get_theme_mod('classic_dentist_clinic_services_title') != "") { ?>
                        <h2 class="services-title text-uppercase"><?php echo esc_html(get_theme_mod('classic_dentist_clinic_services_title')); ?></h2>
                        <div class="tooth-icon mt-2"><i class="fa-solid fa-tooth"></i></div>
                    <?php } ?>
                </div> 
                <div class="services-content wow zoomIn delay-3000" data-wow-duration="2s">
                    <div class="row">
                        <?php 
                            for ($classic_dentist_clinic_i = 1; $classic_dentist_clinic_i <= 4; $classic_dentist_clinic_i++) {?>
                            <div class="col-xl-3 col-lg-3 col-md-6 col-sm-6 col-12 text-center mb-5">
                                <?php if (get_theme_mod('classic_dentist_clinic_service_icon'.$classic_dentist_clinic_i) != "" || get_theme_mod('classic_dentist_clinic_services_name'.$classic_dentist_clinic_i) != "" || get_theme_mod('classic_dentist_clinic_services_text'.$classic_dentist_clinic_i) != "" || get_theme_mod('classic_dentist_clinic_services_name_url'.$classic_dentist_clinic_i) != "") { ?>
                                    <div class="services-card p-3 position-relative">
                                        <div class="service-icon my-3">
                                            <?php $classic_dentist_clinic_services_icon = get_theme_mod('classic_dentist_clinic_service_icon'.$classic_dentist_clinic_i, ''); ?><i class="<?php echo esc_attr($classic_dentist_clinic_services_icon); ?>"></i>
                                        </div>
                                        <?php if (get_theme_mod('classic_dentist_clinic_services_name'.$classic_dentist_clinic_i) != "") { ?>
                                            <h3 class="services-name mb-2 text-capitalize"><?php echo esc_html(get_theme_mod('classic_dentist_clinic_services_name'.$classic_dentist_clinic_i,)); ?></h3>
                                        <?php } ?>
                                        <?php if (get_theme_mod('classic_dentist_clinic_services_text'.$classic_dentist_clinic_i) != "") { ?>
                                            <p class="services-text mb-3 text-capitalize"><?php echo esc_html(get_theme_mod('classic_dentist_clinic_services_text'.$classic_dentist_clinic_i,)); ?></p>
                                        <?php } ?>
                                        <?php if (get_theme_mod('classic_dentist_clinic_services_name_url'.$classic_dentist_clinic_i) != "") { ?>
                                            <a target="_blank" class="card-link" href="<?php echo esc_url(get_theme_mod('classic_dentist_clinic_services_name_url'.$classic_dentist_clinic_i)); ?>"><i class="fa-solid fa-right-long"></i></a> 
                                        <?php } ?>
                                    </div>
                                <?php }?>
                            </div>
                        <?php } ?>
                    </div>
                </div>
            </div>
        </section>
    <?php } ?>
</div>
<?php get_footer(); ?>
