<?php
$menuButtonColor = get_field('menu_button_color', 'option');

$twitterUrl = get_field('twitter', 'option');
$fbUrl = get_field('facebook', 'option');
$instagramUrl =  get_field('instagram', 'option');
$googleUrl = get_field('google_plus', 'option');
?>

<?php get_header(); ?>
    <button style="<?= $menuButtonColor ? 'background : '. $menuButtonColor : ''; ?>;" class="c-hamburger c-hamburger--htx"><span>toggle menu</span></button>

    <div class="sidemenu">
        <div class="sidemenu-inner">
            <?= wp_nav_menu(array('theme_location' => 'main')) ?>
        </div>
        <?php if ($twitterUrl || $fbUrl || $instagramUrl || $googleUrl): ?>
        <div class="simple-socials">
            <?php if ($twitterUrl): ?>
            <a target="_blank" title="" href="<?= $twitterUrl; ?>"><i class="fa fa-twitter"></i></a>
        <?php endif; ?>
            <?php if ($fbUrl): ?>
            <a target="_blank" title="" href="<?= $fbUrl; ?>"><i
                    class="fa fa-facebook"></i></a>
        <?php endif; ?>
            <?php if ($instagramUrl): ?>
            <a target="_blank" title="" href="<?= $instagramUrl; ?>"><i class="fa fa-instagram"></i></a>
        <?php endif; ?>
            <?php if ($googleUrl): ?>
            <a target="_blank" title="" href="<?= $googleUrl; ?>"><i
                    class="fa fa-google-plus"></i></a>
        <?php endif; ?>
        </div>
        <?php endif; ?>
    </div>

<?php $postFields = get_fields(); ?>

    <div class="page-title style3">
        <img src="<?= $postFields['title_image']['url']; ?>" alt="<?= $postFields['title_image']['alt']; ?>" title="<?= $postFields['title_image']['title']; ?>" />

        <div class="container">
            <h1><?= $post->post_title; ?></h1>
        </div>
    </div>

    <section>
        <div class="block less-spacing">
            <div class="container">
                <div class="row">
                    <div class="col s12 m12 l12 column">
                        <div class="big-title">
                            <div class="row">
                                <div class="col s12 m12 l5"><h2><?= $post->post_title; ?>
                                        <span><?= $postFields['category_name'] ?></span></h2></div>
                                <div class="col s12 m12 l7">
                                    <?= $post->post_content; ?>
                                </div>
                            </div>
                        </div>

                        <div class="single-portfolio-grids magnific-gallery">
                            <div class="row">
                                <div class="col s12 m12 l12">
                                    <div class="portfolio-img big">
                                        <img class="materialboxed desktop"
                                             data-caption="A picture of some deer and tons of trees"
                                             src="<?= $postFields['big_image']['url']; ?>"
                                             title="<?= $postFields['big_image']['title']; ?>"
                                             alt="<?= $postFields['big_image']['alt']; ?>"/>
                                        <a href="<?= $postFields['big_image']['url']; ?>" title=""><i class="fa fa-plus"></i></a>

                                        <?php if ($postFields['big_image_mobile']): ?>
                                        <img class="materialboxed mobile"
                                             data-caption="A picture of some deer and tons of trees"
                                             src="<?= $postFields['big_image_mobile']['url']; ?>"
                                             title="<?= $postFields['big_image_mobile']['title']; ?>"
                                             alt="<?= $postFields['big_image_mobile']['alt']; ?>"/>
                                        <a href="<?= $postFields['big_image_mobile']['url']; ?>" title=""><i class="fa fa-plus"></i></a>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <?php foreach ($postFields['small_images'] as $img): ?>
                                    <div class="col s12 m6 l4">
                                        <div class="portfolio-img">
                                            <img class="materialboxed"
                                                 data-caption="A picture of some deer and tons of trees"
                                                 src="<?= $img['url']; ?>" alt="<?= $img['alt']; ?>" title="<?= $img['title']; ?>"/>
                                            <a href="<?= $img['url']; ?>"><i class="fa fa-plus"></i></a>
                                        </div>
                                    </div>
                                <?php endforeach; ?>
                            </div>
                        </div>


                        <?php

                        $prevPostLink = is_object(get_previous_post()) ? get_permalink(get_previous_post()->ID) : '';
                        $nextPostLink = is_object(get_next_post()) ? get_permalink(get_next_post()->ID) : '';

                        if ($nextPostLink === '') {
                            $nextPostLink = get_permalink(lot_get_first_portfolio()->ID);
                        }

                        if ($prevPostLink === '') {
                            $prevPostLink = get_permalink(lot_get_last_portfolio()->ID);
                        }

                        //print_r(lot_get_last_portfolio()); exit;
                        //print_r(lot_get_first_portfolio()); exit;

                        ?>

                        <div class="portfolio-nav">
                            <div class="post-pagi prev">
                                <a class="<?= $prevPostLink ? '' : 'disabled'; ?>" href="<?= $prevPostLink; ?>"><i
                                        class="fa fa-long-arrow-left"></i> POPRZEDNIA REALIZACJA </a>
                            </div>
                            <div class="post-pagi next">
                                <a class="<?= $nextPostLink ? '' : 'disabled'; ?>" href="<?= $nextPostLink; ?>"> NASTĘPNA
                                    REALIZACJA <i class="fa fa-long-arrow-right"></i></a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--</div>-->
    </section>

    <div class="bottom-line style2">
        <div class="container">
            <a class="logo-f" href="<?= get_home_url(); ?>" title=""><img
                    src="<?= get_template_directory_uri(); ?>/images/logo-footer.png" titel="footer-logo" alt="footer-logo"/></a>
        </div>
    </div>

    </div>


<?php get_footer(); ?>