<?php
/**
 * Template part for displaying front page imtroduction.
 *
 * @package Moral
 */


// Get the content type.
$have_missed = get_theme_mod( 'moral_magazine_have_missed', 'disable' );
$have_missed_count = 4;

// Bail if the section is disabled.
if ( 'disable' === $have_missed ) {
    return;
}

$content_detail = moral_magazine_get_section_content( 'have_missed', $have_missed, $have_missed_count );

?>
<div id="magazine_pro_you_may_have_missed_section" class="relative page-section same-background have_missed">
    <div class="wrapper">
        <?php if ( get_theme_mod( 'moral_magazine_have_missed_title', __( 'Featured News', 'moral-magazine' ) ) ): ?>
            <div class="section-header">
                <h2 class="section-title"><?php echo esc_html( get_theme_mod( 'moral_magazine_have_missed_title', __( 'You Have Missed', 'moral-magazine' ) ) ); ?></h2>
            </div>
        <?php endif ?>
        <div class="section-content col-4">
            <?php foreach ($content_detail as $content): ?>
                <article>
                    <div class="you-may-have-missed-wrapper">
                        <div class="featured-image">
                            <img src="<?php echo esc_url( get_the_post_thumbnail_url( $content['id'] ) ) ; ?>">
                            <div class="overlay"></div>
                        </div>
                        <div class="entry-container">
                            <header class="entry-header">
                                <h2 class="entry-title">
                                    <a href="<?php echo esc_url( $content['url'] ) ; ?>"><?php echo esc_html( $content['title'] ) ; ?></a>
                                </h2>
                            </header>
                            <div class="entry-meta">
                                <?php moral_magazine_posted_on( $content['id'] ) ; ?>
                                <span class="comment">
                                    <a href="<?php echo esc_url( $content['url'] ) ; ?>">
                                        <i class="fa fa-comment" aria-hidden="true"></i><?php echo esc_html( get_comments_number( $content['id'] ) ); ?>
                                    </a>
                                </span>
                                <span class="min-read"><?php echo moral_magazine_time_interval( $content['content'] ); echo esc_html__(' min read', 'moral-magazine'); ?></span>
                            </div>
                        </div>
                    </div>
                </article>
            <?php endforeach ?>
        </div>
    </div>
</div><!-- #magazine_pro_you_may_have_missed_section -->
