<?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 Dry Cleaning Services
 */

get_header(); ?>

<div id="content" >
    <?php
        $dry_cleaning_services_hidepageboxes = get_theme_mod('dry_cleaning_services_slider', true);
        $dry_cleaning_services_catData = get_theme_mod('dry_cleaning_services_slider_cat');
        if ($dry_cleaning_services_hidepageboxes && $dry_cleaning_services_catData) { ?>
        <section id="slider-cat">
            <div class="slideimg">
                <div class="container sliderbox">
                    <div class="owl-carousel m-0">
                        <?php
                            $dry_cleaning_services_page_query = new WP_Query(
                                array(
                                    'category_name' => esc_attr($dry_cleaning_services_catData),
                                    'posts_per_page' => -1, 
                                )
                            );
                            while ($dry_cleaning_services_page_query->have_posts()) : $dry_cleaning_services_page_query->the_post(); ?>
                                <div class="row">
                                    <div class="col-lg-7 col-md-6 col-12 align-self-center mb-md-0 mb-2 slider-post-content">
                                        <div class="text-content">
                                            <?php if(get_theme_mod('dry_cleaning_services_slider_subhead') != ''){ ?>
                                                <p class="slider-subhead"><?php echo esc_html(get_theme_mod ('dry_cleaning_services_slider_subhead','dry-cleaning-services')); ?></p>
                                            <?php } ?>
                                            <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                                            <?php
                                            $dry_cleaning_services_trimexcerpt  = get_the_excerpt();
                                            $dry_cleaning_services_shortexcerpt = wp_trim_words($dry_cleaning_services_trimexcerpt, $dry_cleaning_services_num_words = 25);
                                            echo '<p class="slider-content my-3">' . esc_html($dry_cleaning_services_shortexcerpt) . '</p>';
                                            ?>
                                            <div class="sliderbtn pt-4">
                                                <?php 
                                                    $dry_cleaning_services_button_text = get_theme_mod('dry_cleaning_services_button_text', 'Discover More');
                                                    $dry_cleaning_services_button_link_slider = get_theme_mod('dry_cleaning_services_button_link_slider', ''); 
                                                    if (empty($dry_cleaning_services_button_link_slider)) {
                                                        $dry_cleaning_services_button_link_slider = esc_url(get_permalink());
                                                    }
                                                    if ($dry_cleaning_services_button_text || !empty($dry_cleaning_services_button_link_slider)) { ?>
                                                    <?php if(get_theme_mod('dry_cleaning_services_button_text', 'Discover More') != ''){ ?>
                                                        <a href="<?php echo esc_url($dry_cleaning_services_button_link_slider); ?>">
                                                            <?php echo esc_html($dry_cleaning_services_button_text); ?>
                                                            <span class="screen-reader-text"><?php echo esc_html($dry_cleaning_services_button_text); ?></span>
                                                        </a>
                                                    <?php } ?>
                                                <?php } ?>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-5 col-md-6 col-12 align-self-center slider-img-col">
                                        <div class="imagebox">
                                            <?php if(has_post_thumbnail()){
                                              the_post_thumbnail('full');
                                              } else{?>
                                              <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/slider.png" alt="<?php echo esc_attr( 'slider', 'dry-cleaning-services'); ?>"/>
                                            <?php } ?>
                                        </div>
                                        <div class="discount-text">
                                            <?php if(get_theme_mod('dry_cleaning_services_discount_text') != ''){ ?>
                                                <p class="discount1 mb-0"><?php echo esc_html(get_theme_mod ('dry_cleaning_services_discount_text','dry-cleaning-services')); ?></p>
                                                <p class="discount2 mb-0"><?php echo esc_html('Discount','dry-cleaning-services'); ?></p>
                                            <?php } ?>
                                        </div>
                                    </div>
                                </div>
                            <?php endwhile;
                            wp_reset_postdata();
                        ?>
                    </div>
                </div>
            </div>
        </section>
    <?php } ?>

    <!-- Service Section -->
    <?php
        $dry_cleaning_services_hide_trending_section = get_theme_mod('dry_cleaning_services_disabled_trending_section', true);
        if ($dry_cleaning_services_hide_trending_section) {
        ?>
        <section id="service-section" class="my-5 text-left">
            <div class="container">
                <div class="blog-bx text-left">
                    <?php if (get_theme_mod('dry_cleaning_services_service_text') != "") { ?>
                        <p class="mb-2 text-uppercase text-center service-text"><?php echo esc_html(get_theme_mod('dry_cleaning_services_service_text', 'dry-cleaning-services')); ?></p>
                    <?php } ?>
                    <?php if (get_theme_mod('dry_cleaning_services_service_title') != "") { ?>
                        <h3 class="service-title mb-1 text-capitalize text-center"><?php echo esc_html(get_theme_mod('dry_cleaning_services_service_title', 'dry-cleaning-services')); ?></h3>
                    <?php } ?>
                </div> 
                <div class="row">
                    <?php
                        $dry_cleaning_services_featured_post = get_theme_mod('dry_cleaning_services_claases_number');
                        for ($dry_cleaning_services_i=1; $dry_cleaning_services_i <= $dry_cleaning_services_featured_post; $dry_cleaning_services_i++) { 
                        $dry_cleaning_services_postData=  get_theme_mod('dry_cleaning_services_select_post'.$dry_cleaning_services_i);
                        if($dry_cleaning_services_postData){ ?>
                        <?php
                            $args = array(
                                'p' => esc_html($dry_cleaning_services_postData ,'dry-cleaning-services'),
                                'posts_per_page' => 1,
                                'post_type' => 'post'
                            );
                            $query = new WP_Query( $args );
                            if ( $query->have_posts() ) :
                            while ( $query->have_posts() ) : $query->the_post(); ?>
                            <div class="col-xl-4 col-lg-4 col-md-6 col-12 p-3 offer">   
                                <div class="post-thumb">
                                    <?php if(has_post_thumbnail()){
                                      the_post_thumbnail('full');
                                      } else{?>
                                      <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/post-image.png" alt="<?php echo esc_attr( 'post-image', 'dry-cleaning-services'); ?>"/>
                                    <?php } ?>
                                </div>
                                <div class="icon">
                                    <?php if(get_theme_mod('dry_cleaning_services_services_icon'.$dry_cleaning_services_i) != ''){ ?>
                                        <i class="<?php echo esc_attr(get_theme_mod('dry_cleaning_services_services_icon'.$dry_cleaning_services_i)); ?>"></i>
                                    <?php } ?>
                                </div>
                                <div class="service-content pt-4">
                                    <h3 class="text-capitalize"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
                                    <p class="service-description">
                                        <?php
                                        $dry_cleaning_services_excerpt = get_the_excerpt();
                                        $dry_cleaning_services_short_excerpt = wp_trim_words($dry_cleaning_services_excerpt, 20, '...');
                                        echo esc_html($dry_cleaning_services_short_excerpt);
                                        ?>
                                    </p>
                                    <a class="service-btn" href="<?php echo esc_url(get_permalink($post->ID)); ?>"><i class="fa-solid fa-angle-right"></i></a>
                                </div>    
                            </div>
                        <?php endwhile;
                        wp_reset_postdata();
                        endif; ?>
                    <?php }}?>
                </div>
            </div>
        </section>
    <?php } ?>
</div>
<?php get_footer(); ?>
