<?php
/**
 * Template part for displaying front page introduction.
 *
 * @package Ostrich Magazine
 */

// Get the content type.
$gallery_post = get_theme_mod( 'ostrich_magazine_gallery_post', 'cat' );
// Bail if the section is disabled.
if ( get_theme_mod( 'ostrich_magazine_gallery_post_enable', 0 ) == 0 ) {
	return;
}

$get_content = ostrich_magazine_get_section_content( 'gallery_post', $gallery_post, get_theme_mod( 'ostrich_magazine_gallery_post_count', 3 )  );

?>
 <div id="gallery-posts">
    <div class="container">
       <div class="gallery-left-post">
           <?php foreach ( ostrich_magazine_get_section_content( 'gallery_post_left', 'post', 2 ) as $content): ?>
               <article >
                    <div class="featured-image" style="background-image:url('<?php echo esc_url( get_the_post_thumbnail_url( $content['id'] ) ) ; ?>');">
                        <div class="overlay"></div>
                        <div class="entry-meta">
                            <span class="cat-links">
                                <?php the_category( ' ', ' ', $content['id'] ); ?>
                            </span>
                        </div><!-- .entry-meta -->

                        <div class="post-wrapper">
                            <div class="entry-container">
                                <header class="entry-header">
                                    <h2 class="entry-title"><a href="<?php echo esc_url( $content['url'] ); ?>" tabindex="0"><?php echo esc_html( $content['title'] ); ?></a></h2>
                                </header>
                            </div><!-- .entry-container -->
                        </div><!-- .post-wrapper -->
                    </div><!-- .featured-image -->
                </article>
           <?php endforeach ?>
       </div><!-- .gallery-left-post -->

        <div class="gallery-mid-post">
            <div class="regular" data-slick='{"slidesToShow": 1, "slidesToScroll": 1, "infinite": true, "speed": 1000, "dots": false, "arrows":true, "autoplay": true, "draggable": true, "fade": false }'>
                <?php foreach ($get_content as $content): ?>
                    <article >
                        <div class="featured-image" style="background-image:url('<?php echo esc_url( get_the_post_thumbnail_url( $content['id'] ) ) ; ?>');">
                            <div class="overlay"></div>
                            <div class="entry-meta">
                                <span class="cat-links">
                                    <?php the_category( ' ', ' ', $content['id'] ); ?>
                                </span>
                            </div><!-- .entry-meta -->

                            <div class="post-wrapper">
                                <div class="entry-container">
                                    <header class="entry-header">
                                       <h2 class="entry-title"><a href="<?php echo esc_url( $content['url'] ); ?>" tabindex="0"><?php echo esc_html( $content['title'] ); ?></a></h2>
                                    </header>

                                    <div class="entry-content">
                                        <div class="footer-meta">
                                            <div class="admin-image">
                                                <a href="#"><img src="<?php echo get_avatar_url($content['author_id'], ['size' => '70']); ?>" alt="admin"></a>
                                            </div>
                                            <div class="admin-container">

                                                <?php 
                                                    ostrich_magazine_post_author();
                                                    ostrich_magazine_posted_on( $content['id'] );

                                                ?>
                                            </div>
                                        </div><!-- .entry-meta -->
                                    </div>
                                </div><!-- .entry-container -->
                            </div><!-- .post-wrapper -->
                        </div><!-- .featured-image -->
                    </article>  
                <?php endforeach ?>
                
            </div>
       </div><!-- .gallery-mid-post -->

        <div class="gallery-right-post">
            <?php foreach ( ostrich_magazine_get_section_content( 'gallery_post_right', 'post', 2 ) as $content): ?>
                <article >
                    <div class="featured-image" style="background-image:url('<?php echo esc_url( get_the_post_thumbnail_url( $content['id'] ) ) ; ?>');">
                        <div class="overlay"></div>
                        <div class="entry-meta">
                            <span class="cat-links">
                                <?php the_category( ' ', ' ', $content['id'] ); ?>
                            </span>
                        </div><!-- .entry-meta -->

                        <div class="post-wrapper">
                            <div class="entry-container">
                                <header class="entry-header">
                                    <h2 class="entry-title"><a href="<?php echo esc_url( $content['url'] ); ?>" tabindex="0"><?php echo esc_html( $content['title'] ); ?></a></h2>
                                </header>
                            </div><!-- .entry-container -->
                        </div><!-- .post-wrapper -->
                    </div><!-- .featured-image -->
                </article>
           <?php endforeach ?>
       </div><!-- .gallery-right-post -->


    </div><!-- .container -->
</div><!-- .gallery-post -->
