<?php
/**
 * Partial template for banner slider layout.
 *
 * @package PureNote
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

$purenote_banner_args = array();

if ( isset( $args ) && is_array( $args ) && isset( $args['slider_args'] ) ) {
    $purenote_banner_args = $args;
} else {

    $purenote_banner_args = get_query_var( 'purenote_banner_args', array() );
}

$slider_args = isset( $purenote_banner_args['slider_args'] ) && is_array( $purenote_banner_args['slider_args'] ) ? $purenote_banner_args['slider_args'] : array();

if ( empty( $slider_args ) ) {
    $slider_args = array(
        'posts_per_page'      => 5,
        'orderby'             => 'date',
        'order'               => 'DESC',
        'ignore_sticky_posts' => true,
    );
}

?>
<div class="slider-wrapper" data-auto="true">
    <?php
        $slider_query = new WP_Query( $slider_args );
        if ( $slider_query->have_posts() ) {
            while ( $slider_query->have_posts() ) {
                $slider_query->the_post();
                $slide_img = has_post_thumbnail() ? 'has-image' : 'no-image';
    ?>
                <div class="single-slide-wrap <?php echo esc_attr( $slide_img ); ?>">

                    <div class="post-thumbnail-wrap">
                        <?php if ( function_exists( 'purenote_post_thumbnail' ) ) { purenote_post_thumbnail( 'purenote-banner' ); } ?>
                    </div> <!--post-thumbnail-wrap -->
                    
                    <div class="slide-content-wrap">
                        <div class="post-cats-wrap">
                             <?php if ( function_exists( 'purenote_the_post_categories_list' ) ) { purenote_the_post_categories_list( get_the_ID(), 1 ); } ?>
                         </div><!-- .post-cats-wrap -->
                        <div class="slide-title-wrap">
                            <h2 class="slide-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                        </div><!-- .slide-title-wrap -->

                        <div class=" post-meta-wrap purenote-flex">                            
                            <?php purenote_posted_by(get_the_ID(), 3 ); ?>
                        <?php if ( function_exists( 'purenote_posted_on' ) ) { purenote_posted_on(); } ?>                            
                        </div><!-- . post-meta-wrap-->
                        
                        <div class="post-excerpt">
                            <?php echo esc_html( wp_trim_words( wp_strip_all_tags( get_the_excerpt() ), 20 ) ); ?>
                        </div><!-- .post-excerpt -->

                    </div><!-- .slide-content-wrap -->
                </div><!-- .single-slide-wrap -->
    <?php
            }
            wp_reset_postdata();
        } else {
           
        }
    ?>
</div><!-- .slider-wrapper -->
