<?php 
/**
 * Template part for displaying Featured Classes Section
 *
 * @package Multi Blogger
 */

$multi_blogger_classes      = get_theme_mod( 'multi_blogger_classes_setting', false );
$multi_blogger_service_title = get_theme_mod( 'multi_blogger_service_title' );
$multi_blogger_service_button_url  = get_theme_mod( 'multi_blogger_service_btn_url' );
$multi_blogger_service_button_text = get_theme_mod( 'multi_blogger_service_button_text', __( 'See More Stories', 'multi-blogger' ) );
?>
<?php if ( $multi_blogger_classes ) : ?>
    <div class="our-classes">
        <div class="container">
            <div class="side-border row">
                <div class="col-xl-4 col-lg-5 col-md-12 col-12 service-title">
                    <?php if ( $multi_blogger_service_title ) : ?>
                        <h3 class="mb-3"><?php echo esc_html( $multi_blogger_service_title ); ?></h3>
                    <?php endif; ?>
                </div>
                <div class="col-xl-8 col-lg-7 col-md-12 col-12 service-button">             
                    <?php if ( $multi_blogger_service_button_url && $multi_blogger_service_button_text ) : ?>
                        <a href="<?php echo esc_url( $multi_blogger_service_button_url ); ?>">
                            <?php echo esc_html( $multi_blogger_service_button_text ); ?>
                            <i class="fas fa-arrow-right"></i>
                        </a>
                    <?php endif; ?>
                </div>
            </div>

            <div class="owl-carousel">
                <?php 
                $multi_blogger_catergory_name = get_theme_mod( 'multi_blogger_blog_args_' );
                $args = array(
                    'post_type'           => 'post',
                    'category_name'       => $multi_blogger_catergory_name,
                    'orderby'             => 'post__in',
                    'ignore_sticky_posts' => true,
                );

                $multi_blogger_loop = new WP_Query( $args );
                if ( $multi_blogger_loop->have_posts() ) :
                    while ( $multi_blogger_loop->have_posts() ) : $multi_blogger_loop->the_post(); ?>
                        <div class="box wow zoomInUp delay-1000" data-wow-duration="2s">
                            <?php
                                if ( has_post_thumbnail() ) : ?>
                                <div class="image-blog">
                                    <?php the_post_thumbnail();?>
                                </div>
                                <?php else:
                                    ?>
                                    <div class="image-blog">
                                        <img src="<?php echo get_stylesheet_directory_uri() . '/images/default-header.png'; ?>">
                                    </div>
                                    <?php
                                endif;
                            ?>
                            <div class="box-content">
                                <div class="post-date">
                                    <span class="badges">
                                        <?php esc_html_e( 'Posted By', 'multi-blogger' ); ?>
                                        <?php the_author(); ?> 
                                        <span class="date"><?php echo get_the_date( 'd' ); ?></span>
                                        <span class="date-month"><?php echo get_the_date( 'M' ); ?></span>
                                    </span>
                                </div>
                                <h4 class="title my-2">
                                    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                                </h4>
                                <p class="mb-0 content-para"><?php echo wp_trim_words( get_the_content(), 15 ); ?></p>
                                <p class="sign-in-area">
                                    <a href="<?php echo esc_url(get_permalink($post->ID)); ?>"><?php esc_html_e('READ FULL STORY', 'multi-blogger'); ?>
                                    </a>
                                </p>
                            </div>
                        </div>
                    <?php 
                    endwhile;
                endif;
                ?>
            </div>
        </div>
    </div>
<?php endif; ?>