<?php /* Template Name: Page Photo Slider */ ?>
<?php get_header(); ?>
    <?php if (function_exists('rwmb_meta')): ?>
        <?php while ( have_posts() ) : the_post(); ?>
            <!-- INTRO -->
            <?php $revslider = get_post_meta( $post->ID, '_muziq_jellythemes_revslider', true ); ?>
            <?php if (!empty($revslider)): ?>
                <?php echo do_shortcode($revslider); ?>
            <?php else : ?>
                <section class="intro full-width jIntro" id="<?php echo esc_attr($post->post_name); ?>">
                    <div class="container">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="slider-intro">
                                    <div id="slides">
                                        <div class="overlay"></div>
                                        <div class="slides-container">
                                            <?php $images = rwmb_meta('_muziq_jellythemes_slider_images', 'type=image', $post->ID ); ?>
                                            <?php foreach ($images as $image) : ?>
                                                <img src="<?php echo esc_url($image['full_url']); ?>" alt="slide-<?php echo esc_html($image['ID']); ?>">
                                            <?php endforeach; ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="vcenter text-center text-overlay">
                            <?php $logos = rwmb_meta('_muziq_jellythemes_slider_logo', 'type=image', $post->ID ); ?>
                            <?php foreach ($logos as $logo) : ?>
                                <div class="logo-intro"><img src="<?php echo esc_url($logo['full_url']); ?>" alt="<?php echo get_post_meta( $post->ID, '_muziq_jellythemes_slider_content', true ); ?>"></div>
                            <?php endforeach; ?>
                            <?php $texts =  get_post_meta( $post->ID, '_muziq_jellythemes_slider_text', true ); ?>
                            <div id="owl-main-text" class="owl-carousel">
                                <?php foreach ($texts as $i => $text) : ?>
                                    <div class="item">
                                        <h1 class="primary-title"><?php echo esc_html($text); ?></h1>
                                    </div>
                                <?php endforeach; ?>
                            </div>
                            <h2 class="subtitle-text"><?php echo get_post_meta( $post->ID, '_muziq_jellythemes_slider_content', true ); ?></h2>
                            <div class="voffset50"></div>
                            <a href="<?php echo esc_url(get_post_meta( $post->ID, '_muziq_jellythemes_slider_button_link_1', true )); ?>" class="btn btn-invert"><?php echo get_post_meta( $post->ID, '_muziq_jellythemes_slider_button_1', true ); ?></a>
                        </div>
                    </div>
                </section>
            <?php endif ?>

            <!-- PLAYER -->
            <?php $tracks = rwmb_meta('_muziq_jellythemes_slider_mp3', 'type=file', $post->ID ); ?>
            <?php $autoplay = get_post_meta( $post->ID, '_muziq_jellythemes_autoplay', true ); ?>
            <?php if (!empty($tracks)): ?>
                <div class="player horizontal">
                    <div class="container">
                        <div class="info-album-player">
                            <?php $albums = rwmb_meta('_muziq_jellythemes_slider_album_cover', 'type=image', $post->ID ); ?>
                            <?php foreach ($albums as $album) : ?>
                                <div class="album-cover" id="bg-image3" style="background-image:url(<?php echo esc_url($album['full_url']); ?>)"></div>
                            <?php endforeach; ?>

                            <p class="album-title"><?php echo get_post_meta( $post->ID, '_muziq_jellythemes_slider_album_title', true ); ?></p>
                            <p class="artist-name"><?php echo get_post_meta( $post->ID, '_muziq_jellythemes_slider_album_artist', true ); ?></p>
                        </div>
                        <div class="player-content">
                            <audio preload></audio>
                            <ol class="playlist <?php echo empty($autoplay) || wp_is_mobile() ? '' : 'autoplay' ?>">
                                <?php foreach ($tracks as $i => $track) : ?>
                                    <li><a href="#" data-src="<?php echo esc_url($track['url']); ?>"><?php echo esc_html($track['title']); ?></a></li>
                                <?php endforeach; ?>
                            </ol>
                            <div class="nextprev">
                                <span class="prev">prev</span>
                                <span class="next">next</span>
                            </div>
                            <span class="btnloop">loop</span>
                        </div>
                    </div>
                </div>
            <?php endif ?>
        <?php endwhile; ?>


        <?php $back = $post //backup post data?>
        <?php $child_sections = new WP_Query(array('post_type' => 'page', 'post_parent' => $post->ID, 'orderby' => 'menu_order', 'order' =>'ASC', 'posts_per_page' => -1)); ?>
        <?php while ($child_sections->have_posts() ) : $child_sections->the_post(); ?>
            <?php $bg = rwmb_meta( '_muziq_jellythemes_section_bg', 'type=image', get_the_ID() );   foreach ($bg as $bg_image) :
                    $bg_url = $bg_image['full_url']; endforeach; ?>
                    <?php $pattern = get_post_meta( $post->ID, '_muziq_jellythemes_pattern', true ); ?>
                <section id="<?php echo esc_attr($post->post_name); ?>"
                    class="section
                            <?php echo get_post_meta( $post->ID, '_muziq_jellythemes_section_color', true ); ?>
                            <?php echo get_post_meta( $post->ID, '_muziq_jellythemes_section_type', true ); ?>
                            <?php echo get_post_meta( $post->ID, '_muziq_jellythemes_section_width', true ); ?>
                            <?php echo ($pattern ? 'pattern' : ''); ?>"
                    <?php echo (!empty($bg_url) ? 'data-parallax-image="' . $bg_url . '"'  : ''); ?>
                    style="background-color:<?php echo get_post_meta( $post->ID, '_muziq_jellythemes_bg_color', true ); ?>;
                    <?php echo (!empty($bg_url) ? 'background-image: url(' . $bg_url . ')' : ''); ?>">
                        <div class="container">
                            <?php the_content(); ?>
                        </div>
                        <?php if (get_post_meta( $post->ID, '_muziq_jellythemes_section_type', true )=='discography'): ?>
                            <div id="project-show"></div>
                            <div class="section <?php echo get_post_meta( $post->ID, '_muziq_jellythemes_section_color', true ); ?>  player-album project-window">
                                <div class="project-content"></div><!-- AJAX Dinamic Content -->
                            </div>
                        <?php endif ?>
                </section>
            <?php $bg_url=''; ?>
        <?php endwhile; ?>
        <?php $post = $back //restore post data ?>
    <?php endif ?>
<?php get_footer(); ?>
