<?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 Live Artist
 */

get_header(); ?>

<div id="content" >

    <?php
        $live_artist_banner = get_theme_mod('live_artist_banner', true);
        $live_artist_banner_pageboxes = get_theme_mod('live_artist_banner_pageboxes', false);

        if ($live_artist_banner && $live_artist_banner_pageboxes) { ?>
        <div id="banner-cat">
            <div class="banner-page position-relative">
                <?php
                $live_artist_querymed = new WP_Query(array(
                    'page_id' => esc_attr($live_artist_banner_pageboxes)
                ));
                while ($live_artist_querymed->have_posts()) : $live_artist_querymed->the_post(); ?>
                    <div class="banner-main">
                        <div class="container">
                            <?php
                                $live_artist_banner_icons = get_theme_mod('live_artist_show_hide_social_icons', true);
                                if ($live_artist_banner_icons) { ?>
                                <div class="social-box">
                                    <p class="social-icon-text"><?php echo esc_html__('Follow Us','live-artist'); ?></p>
                                    <div class="social-icons d-flex gap-2 mt-4">
                                        <?php if ( get_theme_mod('live_artist_facebook_link') != "") { ?>
                                            <a title="<?php echo esc_attr('facebook', 'live-artist'); ?>" target="_blank" href="<?php echo esc_url(get_theme_mod('live_artist_facebook_link')); ?>"><i class="fa-brands fa-facebook-f"></i></a> 
                                        <?php } ?>
                                        <?php if ( get_theme_mod('live_artist_instagram_link') != "") { ?> 
                                            <a title="<?php echo esc_attr('instagram', 'live-artist'); ?>" target="_blank" href="<?php echo esc_url(get_theme_mod('live_artist_instagram_link')); ?>"><i class="fa-brands fa-instagram"></i></a>
                                        <?php } ?>
                                        <?php if ( get_theme_mod('live_artist_pinterest_link') != "") { ?>
                                            <a title="<?php echo esc_attr('youtube', 'live-artist'); ?>" target="_blank" href="<?php echo esc_url(get_theme_mod('live_artist_pinterest_link')); ?>"><i class="fa-brands fa-pinterest"></i></a>
                                        <?php } ?>
                                        <?php if ( get_theme_mod('live_artist_twitter_link') != "") { ?> 
                                            <a title="<?php echo esc_attr('twitter', 'live-artist'); ?>" target="_blank" href="<?php echo esc_url(get_theme_mod('live_artist_twitter_link')); ?>"><i class="fa-brands fa-twitter"></i></a>
                                        <?php } ?>
                                        <?php if ( get_theme_mod('live_artist_dribbble_link') != "") { ?>
                                            <a title="<?php echo esc_attr('youtube', 'live-artist'); ?>" target="_blank" href="<?php echo esc_url(get_theme_mod('live_artist_dribbble_link')); ?>"><i class="fa-solid fa-basketball"></i></a>
                                        <?php } ?>
                                        <?php if ( get_theme_mod('live_artist_youtube_link') != "") { ?>
                                            <a title="<?php echo esc_attr('youtube', 'live-artist'); ?>" target="_blank" href="<?php echo esc_url(get_theme_mod('live_artist_youtube_link')); ?>"><i class="fa-brands fa-youtube"></i></a>
                                        <?php } ?>
                                    </div>
                                </div>
                            <?php } ?>
                            <div class="row">
                                <div class="col-xl-6 col-lg-6 col-md-6 col-12 align-self-center">
                                    <div class="bannerbox wow zoomInUp" data-wow-duration="2s">
                                        <?php if (get_theme_mod('live_artist_banner_small_title') != '') { ?>
                                            <i class="<?php echo esc_attr(get_theme_mod('live_artist_small_title_icon', 'fa-solid fa-microphone-lines')); ?>"></i><p class="ps-2 banner-smalltitle text-capitalize m-0"><?php echo esc_html(get_theme_mod('live_artist_banner_small_title')); ?></p>
                                        <?php } ?>
                                        <h1 class="my-3 text-capitalize banner-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                                        <?php
                                            $live_artist_trimexcerpt = get_the_excerpt();
                                            $live_artist_shortexcerpt = wp_trim_words($live_artist_trimexcerpt, 38);
                                            echo '<p class="banner-content mb-5">' . esc_html($live_artist_shortexcerpt) . '</p>';
                                        ?>
                                        <div class="bannerbtn">
                                            <?php
                                                $live_artist_button_text = get_theme_mod('live_artist_button_text', 'Explore More');
                                                $live_artist_button_link_banner = esc_url(get_theme_mod('live_artist_button_link_banner', get_permalink()));
                                                if ($live_artist_button_text || !empty($live_artist_button_link_banner)) { ?>
                                                <?php if ($live_artist_button_text != '') { ?>
                                                    <a href="<?php echo esc_url($live_artist_button_link_banner); ?>" class="button">
                                                        <?php echo esc_html($live_artist_button_text); ?>
                                                        <span class="screen-reader-text"><?php echo esc_html($live_artist_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">
                                    <div class="img-bg wow zoomIn" data-wow-duration="2s">
                                        <div class="img-box 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', 'live-artist'); ?>"/>
                                            <?php } ?>
                                        </div>
                                        <?php if (get_theme_mod('live_artist_banner_artist_name') != '') { ?>
                                            <p class="artist text-capitalize mb-0 mt-2"><?php echo esc_html(get_theme_mod('live_artist_banner_artist_name')); ?></p>
                                        <?php } ?>
                                        <?php if (get_theme_mod('live_artist_banner_artist_field') != '') { ?>
                                            <p class="designation text-capitalize m-0"><?php echo esc_html(get_theme_mod('live_artist_banner_artist_field')); ?></p>
                                        <?php } ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="banner-bg-img position-absolute">
                        <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/banner-bg.png" alt="<?php echo esc_attr( 'banner-bg', 'live-artist'); ?>"/>
                    </div>
                    <div class="music-img position-absolute">
                        <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/music-wave.png" alt="<?php echo esc_attr( 'music-wave', 'live-artist'); ?>"/>
                    </div>
                <?php endwhile;
                    wp_reset_postdata();
                ?>
            </div>
        </div>
    <?php } ?>

    <!-- Albums Section -->
    <?php 
        $live_artist_hide_album_section = get_theme_mod('live_artist_disabled_album_section', true);
        $live_artist_catData = get_theme_mod('live_artist_album_cat', '0');

        if ($live_artist_hide_album_section) { ?>
        <section id="album-section" class="py-5">
            <div class="container">
                <div class="blog-bx mb-2 text-center">
                    <?php if (get_theme_mod('live_artist_album_text')) { ?>
                        <i class="<?php echo esc_attr(get_theme_mod('live_artist_album_text_icon', 'fa-solid fa-microphone-lines')); ?>"></i>
                        <p class="album-text mb-0 ps-2 text-capitalize"><?php echo esc_html(get_theme_mod('live_artist_album_text')); ?></p>
                    <?php } ?>
                    <?php if (get_theme_mod('live_artist_album_title')) { ?>
                        <h2 class="album-title pb-3 mt-1 text-capitalize"><?php echo esc_html(get_theme_mod('live_artist_album_title')); ?></h2>
                    <?php } ?>
                </div>
                <?php
                if ($live_artist_catData !== '0') {
                    $live_artist_page_query = new WP_Query(array(
                        'category_name'  => esc_attr($live_artist_catData),
                        'posts_per_page' => 6,
                    ));
                    if ($live_artist_page_query->have_posts()) { ?>
                        <div class="swiper mySwiper m-0">
                            <div class="swiper-wrapper pb-3 pt-3">
                                <?php while ($live_artist_page_query->have_posts()) : $live_artist_page_query->the_post(); ?>
                                    <div class="swiper-slide album-content position-relative">
                                        <div class="postbg-img 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/post-img.png" alt="<?php echo esc_attr( 'post-img', 'live-artist'); ?>" class="post-image"/>
                                            <?php } ?>
                                            <div class="img-overlay"></div>
                                        </div>
                                        <div class="album-box position-absolute text-center wow zoomIn delay-1000" data-wow-duration="2s">
                                            <div class="postimg">
                                                <?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/post-img.png" alt="<?php echo esc_attr( 'post-img', 'live-artist'); ?>" class="post-image"/>
                                                <?php } ?>
                                            </div>
                                            <h3 class="album-title text-capitalize mt-3">
                                                <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                                            </h3>
                                            <p class="album-date">
                                                <?php echo esc_html(get_the_date('j M Y')); ?>
                                            </p>
                                        </div>
                                    </div>
                                <?php endwhile; ?>
                            </div>
                            <div class="swiper-button-next"></div>
                            <div class="swiper-button-prev"></div>
                        </div>
                    <?php } 
                    wp_reset_postdata();
                } ?>
            </div>
        </section>
    <?php } ?>
</div>
<?php get_footer(); ?>
