<?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 Educational University
 */

get_header(); ?>

<div id="content" >
    <?php
    $educational_university_banner = get_theme_mod('educational_university_banner', true);
    $educational_university_banner_pageboxes = get_theme_mod('educational_university_banner_pageboxes', false);

    if ($educational_university_banner && $educational_university_banner_pageboxes) { ?>
        <div id="banner-cat">
            <div class="banner-page position-relative">
                <?php
                $educational_university_querymed = new WP_Query(array(
                    'page_id' => esc_attr($educational_university_banner_pageboxes)
                ));
                while ($educational_university_querymed->have_posts()) : $educational_university_querymed->the_post(); ?>
                    <div class="imagebox position-relative">
                        <?php if (has_post_thumbnail()) {
                            the_post_thumbnail('full');
                        } else { ?>
                            <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/banner.png" alt="<?php echo esc_attr( 'banner', 'educational-university'); ?>"/>
                        <?php } ?>
                        <div class="banner-overlay position-absolute"></div>
                        <div class="banner-main">
                            <div class="container">
                                <div class="row">
                                    <div class="col-xl-6 col-lg-6 col-md-6 col-12 align-self-center">
                                        <div class="bannerbox position-absolute wow zoomIn" data-wow-duration="2s">
                                            <?php if (get_theme_mod('educational_university_banner_small_title') != '') { ?>
                                                <i class="<?php echo esc_attr(get_theme_mod('educational_university_small_title_icon', 'fa-solid fa-graduation-cap')); ?>"></i><p class="ps-2 banner-smalltitle text-capitalize m-0"><?php echo esc_html(get_theme_mod('educational_university_banner_small_title')); ?></p>
                                            <?php } ?>
                                            <h1 class="my-3 text-capitalize banner-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                                            <?php
                                                $educational_university_trimexcerpt = get_the_excerpt();
                                                $educational_university_shortexcerpt = wp_trim_words($educational_university_trimexcerpt, 38);
                                                echo '<p class="banner-content mb-5">' . esc_html($educational_university_shortexcerpt) . '</p>';
                                            ?>
                                            <div class="bannerbtn">
                                                <?php
                                                $educational_university_button_text = get_theme_mod('educational_university_button_text', 'Get Started');
                                                $educational_university_button_link_banner = esc_url(get_theme_mod('educational_university_button_link_banner', get_permalink()));
                                                if ($educational_university_button_text || !empty($educational_university_button_link_banner)) { ?>
                                                    <?php if ($educational_university_button_text != '') { ?>
                                                        <a href="<?php echo esc_url($educational_university_button_link_banner); ?>" class="button">
                                                            <?php echo esc_html($educational_university_button_text); ?>
                                                            <span class="screen-reader-text"><?php echo esc_html($educational_university_button_text); ?></span>
                                                        </a>
                                                    <?php } ?>
                                                <?php } ?>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-xl-6 col-lg-6 col-md-6 col-12 align-self-center text-center">
                                        <?php if (get_theme_mod('educational_university_banner_right_img') != "") { ?>
                                            <div class="banner-img position-absolute">
                                                <img src="<?php echo esc_url(get_theme_mod('educational_university_banner_right_img')); ?>" alt="<?php echo esc_attr( 'banner', 'educational-university'); ?>"/>
                                            </div>
                                        <?php } ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="banner-bottom position-absolute">
                        <?php if (get_theme_mod('educational_university_banner_bottom_img')) { ?>
                            <img src="<?php echo esc_url(get_theme_mod('educational_university_banner_bottom_img')); ?>" alt="<?php echo esc_attr( 'banner', 'educational-university'); ?>"/> 
                        <?php } else { ?>
                            <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/banner-bg.png" alt="<?php echo esc_attr( 'banner', 'educational-university'); ?>"/>
                        <?php } ?>
                    </div>
                    <div class="banner-wave position-absolute">
                        <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/banner-wave.png" alt="<?php echo esc_attr( 'banner', 'educational-university'); ?>"/>
                    </div>
                <?php endwhile;
                wp_reset_postdata();
                ?>
            </div>
        </div>
    <?php } ?>

    <!-- Degree & Courses Section -->
    <?php
        $educational_university_hide_degree_section = get_theme_mod('educational_university_disabled_degree_section', true);
        if ($educational_university_hide_degree_section){ ?>
        <section id="degree-section" class="py-5">
            <div class="container">
                <div class="blog-bx mb-2 text-center">
                    <?php if (get_theme_mod('educational_university_degree_text') != "") { ?>
                        <i class="<?php echo esc_attr(get_theme_mod('educational_university_courses_title_icon', 'fa-solid fa-graduation-cap')); ?>"></i><p class="degree-text mb-2 text-capitalize ps-2"><?php echo esc_html(get_theme_mod('educational_university_degree_text')); ?></p>
                    <?php } ?>
                    <?php if (get_theme_mod('educational_university_degree_title') != "") { ?>
                        <h2 class="degree-title pb-3 text-capitalize"><?php echo esc_html(get_theme_mod('educational_university_degree_title')); ?></h2>
                    <?php } ?>
                </div> 
                <div class="row">
                    <?php
                        $educational_university_featured_post = get_theme_mod('educational_university_claases_number');
                        for ($educational_university_i=1; $educational_university_i <= $educational_university_featured_post; $educational_university_i++) { 
                        $educational_university_postData=  get_theme_mod('educational_university_select_post'.$educational_university_i);
                        if($educational_university_postData){ ?>
                        <?php
                            $educational_university_args = array(
                                'p' => esc_html($educational_university_postData ,'educational-university'),
                                'posts_per_page' => 1,
                                'post_type' => 'post'
                            );
                            $educational_university_query = new WP_Query( $educational_university_args );
                            if ( $educational_university_query->have_posts() ) :
                            while ( $educational_university_query->have_posts() ) : $educational_university_query->the_post(); ?>
                            <div class="col-xxl-3 col-xl-3 col-lg-4 col-md-6 col-12">  
                                <div class="degree wow zoomIn delay-1000" data-wow-duration="2s">
                                    <div class="post-thumb m-0 position-relative">
                                        <?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', 'educational-university'); ?>"/>
                                        <?php } ?>
                                        <div class="post-overlay"></div>
                                        <?php if (class_exists('cbxwpbookmark')) { ?>
                                            <div class="bookmark">
                                                <?php echo do_shortcode('[cbxwpbookmarkbtn]','educational-university'); ?>
                                            </div>
                                        <?php } ?>
                                    </div>
                                    <h3 class="text-capitalize my-3 post-heading"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
                                    <?php if (get_theme_mod('educational_university_add_students_count'.$educational_university_i) != "" || get_theme_mod('educational_university_add_time'.$educational_university_i) != "" || get_theme_mod('educational_university_add_price'.$educational_university_i) != "" || get_theme_mod('educational_university_add_level'.$educational_university_i) != "") { ?>
                                        <div class="service-content pt-3">
                                            <div class="row">
                                                <div class="col-xl-6 col-lg-6 col-md-6 col-6">
                                                    <?php if (get_theme_mod('educational_university_add_students_count'.$educational_university_i) != "") { ?>
                                                        <p class="student-count mb-2"><?php echo esc_html__('Students : ', 'educational-university'); ?><?php echo esc_html(get_theme_mod('educational_university_add_students_count'.$educational_university_i)); ?></p>
                                                    <?php } ?>
                                                </div>
                                                <div class="col-xl-6 col-lg-6 col-md-6 col-6 text-end">
                                                    <?php if (get_theme_mod('educational_university_add_time'.$educational_university_i) != "") { ?>
                                                        <p class="add-time mb-2"><?php echo esc_html__('Time : ', 'educational-university'); ?><?php echo esc_html(get_theme_mod('educational_university_add_time'.$educational_university_i)); ?></p>
                                                    <?php } ?>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-xl-6 col-lg-6 col-md-6 col-6">
                                                    <?php if (get_theme_mod('educational_university_add_price'.$educational_university_i) != "") { ?>
                                                        <p class="post-price mb-0"><?php echo esc_html(get_theme_mod('educational_university_add_price'.$educational_university_i)); ?></p>
                                                    <?php } ?>
                                                </div>
                                                <div class="col-xl-6 col-lg-6 col-md-6 col-6 text-end">
                                                    <?php if (get_theme_mod('educational_university_add_level'.$educational_university_i) != "") { ?>
                                                        <p class="expert-text mb-0 text-capitalize"><?php echo esc_html(get_theme_mod('educational_university_add_level'.$educational_university_i)); ?></p>
                                                    <?php } ?>
                                                </div>
                                            </div>
                                        </div> 
                                    <?php }?>   
                                </div> 
                            </div>
                        <?php endwhile;
                        wp_reset_postdata();
                        endif; ?>
                    <?php }}?>
                </div>
            </div>
        </section>
    <?php } ?>
</div>
<?php get_footer(); ?>
