<?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 Charity NGO
 */

get_header(); ?>

<div id="content" >

  <?php
    $classic_charity_ngo_hidepageboxes = get_theme_mod('classic_charity_ngo_slider', false);
    $classic_charity_ngo_catData = get_theme_mod('classic_charity_ngo_slider_cat');
    if ($classic_charity_ngo_hidepageboxes && $classic_charity_ngo_catData) { ?>
    <section id="slider-cat">
        <div class="slideimg">
            <div class="container sliderbox">
                <div class="owl-carousel m-0">
                    <?php
                    $classic_charity_ngo_page_query = new WP_Query(
                        array(
                            'category_name' => esc_attr($classic_charity_ngo_catData),
                            'posts_per_page' => -1, 
                        )
                    );
                    while ($classic_charity_ngo_page_query->have_posts()) : $classic_charity_ngo_page_query->the_post(); ?>
                        <div class="row mb-md-5">
                            <div class="col-lg-7 col-md-6 col-12 align-self-center mb-md-0 mb-2">
                                <div class="text-content">
                                    <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                                    <?php if(get_theme_mod('classic_charity_ngo_slider_subhead') != ''){ ?>
                                        <p class="slider-subhead"><?php echo esc_html(get_theme_mod ('classic_charity_ngo_slider_subhead','classic-charity-ngo')); ?></p>
                                    <?php } ?>
                                    <?php
                                    $classic_charity_ngo_trimexcerpt  = get_the_excerpt();
                                    $classic_charity_ngo_shortexcerpt = wp_trim_words($classic_charity_ngo_trimexcerpt, $num_words = 25);
                                    echo '<p class="slider-content">' . esc_html($classic_charity_ngo_shortexcerpt) . '</p>';
                                    ?>
                                    <div class="sliderbtn mt-md-5 mt-3">
                                        <?php 
                                        $classic_charity_ngo_button_text = get_theme_mod('classic_charity_ngo_button_text', 'Discover More');
                                        $classic_charity_ngo_button_link_slider = get_theme_mod('classic_charity_ngo_button_link_slider', ''); 
                                        if (empty($classic_charity_ngo_button_link_slider)) {
                                            $classic_charity_ngo_button_link_slider = get_permalink();
                                        }
                                        if ($classic_charity_ngo_button_text || !empty($classic_charity_ngo_button_link_slider)) { ?>
                                          <?php if(get_theme_mod('classic_charity_ngo_button_text', 'Discover More') != ''){ ?>
                                            <div class="slide-btn mb-2 me-2">
                                                <a href="<?php echo esc_url($classic_charity_ngo_button_link_slider); ?>" class="button redmor me-3">
                                                  <?php echo esc_html($classic_charity_ngo_button_text); ?>
                                                    <span class="screen-reader-text"><?php echo esc_html($classic_charity_ngo_button_text); ?></span>
                                                </a>
                                            </div>
                                          <?php } ?>
                                        <?php } ?>
                                        <?php if(get_theme_mod('classic_charity_ngo_button_text2', 'Donate Now') != '' && get_theme_mod('classic_charity_ngo_button_link_slider2',) != ''){ ?>
                                            <?php 
                                            $classic_charity_ngo_button_text2 = get_theme_mod('classic_charity_ngo_button_text2', 'Donate Now');
                                            $classic_charity_ngo_button_link_slider2 = get_theme_mod('classic_charity_ngo_button_link_slider2', ''); ?>
                                            <div class="slide-btn second mb-2">
                                                <a href="<?php echo esc_url($classic_charity_ngo_button_link_slider2); ?>" class="button redmor second">
                                                  <?php echo esc_html($classic_charity_ngo_button_text2); ?>
                                                    <span class="screen-reader-text"><?php echo esc_html($classic_charity_ngo_button_text2); ?></span>
                                                </a>
                                            </div>
                                        <?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', 'classic-charity-ngo'); ?>"/>
                                    <?php } ?>
                                </div>
                            </div>
                        </div>
                    <?php endwhile;
                    wp_reset_postdata();
                    ?>
                </div>
            </div>
        </div>
    </section>
  <?php } ?>

   <?php $classic_charity_ngo_hidepageboxes = get_theme_mod('classic_charity_ngo_disabled_pgboxes', false); ?>
    <?php if ($classic_charity_ngo_hidepageboxes != ''): ?>
        <section id="services" class="my-5">
            <div class="container">
                <div class="row">
                    <?php 
                    $classic_charity_ngo_services = get_theme_mod('classic_charity_ngo_services_number', '4');
                    for ($classic_charity_ngo_i = 1; $classic_charity_ngo_i <= $classic_charity_ngo_services; $classic_charity_ngo_i++) { 
                    ?>
                        <div class="col-lg-3 col-md-3">
                            <div class="service-content mb-3 text-center">
                                <?php if (get_theme_mod('classic_charity_ngo_services_icon'.$classic_charity_ngo_i) != '') { ?>
                                    <div class="icon">
                                        <i class=" position-relative mb-0 <?php echo esc_attr(get_theme_mod('classic_charity_ngo_services_icon'.$classic_charity_ngo_i, '')); ?> main-icon <?php echo 'bg-color-' . ($classic_charity_ngo_i % 4); ?>">
                                        <i class="heart-icon first fas fa-heart <?php echo 'heart-color-' . ($classic_charity_ngo_i % 4); ?>"></i>
                                        <i class="heart-icon second fas fa-heart <?php echo 'heart-color-' . ($classic_charity_ngo_i % 4); ?>"></i>  
                                        </i>
                                    </div>
                                <?php } ?>
                                <?php if (get_theme_mod('classic_charity_ngo_services_counter'.$classic_charity_ngo_i) != '') { ?>
                                    <h2 class="my-3 serv-counter"><?php echo esc_html(get_theme_mod('classic_charity_ngo_services_counter'.$classic_charity_ngo_i, '')); ?></h2>
                                <?php } ?>
                                <?php if (get_theme_mod('classic_charity_ngo_services_title'.$classic_charity_ngo_i) != '') { ?>
                                    <p class="serv-title"><?php echo esc_html(get_theme_mod('classic_charity_ngo_services_title'.$classic_charity_ngo_i, '')); ?></p>
                                <?php } ?>
                            </div>
                        </div>
                    <?php } ?>
                </div>
            </div>
        </section>
    <?php endif; ?>

</div>
<?php get_footer(); ?>