<?php
/**
 * Template part for displaying front page slider.
 *
 * @package Shadow Themes
 */

/// Get default  mods value.
$slider_enable = get_theme_mod( 'nuevo_blog_featured_slider_section_enable', true );

if ( false == $slider_enable ) {
    return;
}

$header_font_size = get_theme_mod( 'nuevo_blog_slider_header_font_size');
$button_font_size = get_theme_mod( 'nuevo_blog_slider_button_font_size');
$slider_speed = get_theme_mod( 'nuevo_blog_slider_speed',600);
$slider_infinite = get_theme_mod('nuevo_blog_featured_slider_infinite_enable', true);
$slider_dot = get_theme_mod('nuevo_blog_featured_slider_dot_enable', true);
$slider_autoplay = get_theme_mod('nuevo_blog_featured_slider_autoplay_enable', true);
$slider_arrow = get_theme_mod('nuevo_blog_featured_slider_arrow_enable', true);
$slider_fade = get_theme_mod('nuevo_blog_featured_slider_fade_enable', false);
$slider_content_opacity = get_theme_mod( 'nuevo_blog_slider_content_opacity',60);
$slider_background_opacity = get_theme_mod( 'nuevo_blog_slider_image_opacity',0);
$slider = get_theme_mod( 'nuevo_blog_slider_content_type', 'custom' );


$default = nuevo_blog_get_default_mods();
$slider_num = get_theme_mod( 'nuevo_blog_slider_num', 3 );
$slider_column = get_theme_mod( 'nuevo_blog_slider_column', 3 );
?>
<div id="featured-slider" class="<?php echo $slider_column==1 ? 'f-content-center': 'f-content-bottom'; ?>" data-slick='{"slidesToShow": <?php echo esc_attr($slider_column); ?>, "slidesToScroll": 1, "infinite": <?php echo $slider_infinite ? 'true': 'false'; ?>, "speed": <?php echo esc_attr($slider_speed); ?>, "dots": <?php echo $slider_dot ? 'true': 'false'; ?>, "arrows":<?php echo $slider_arrow ? 'true': 'false'; ?>, "autoplay": <?php echo $slider_autoplay ? 'true': 'false'; ?>, "draggable": true, "fade": <?php echo $slider_fade ? 'true': 'false'; ?> }'>
	<?php
        $slider_cat_id = get_theme_mod( 'nuevo_blog_slider_cat' );
        $args = array(
            'cat' => $slider_cat_id,   
            'posts_per_page' => 4,
            'ignore_sticky_posts' => true,
        );

	    $query = new WP_Query( $args );

	    $i = 1;
	    if ( $query->have_posts() ) :
	        while ( $query->have_posts() ) :
	            $query->the_post();
	            ?>
	        
	            <article style="background-image: url('<?php the_post_thumbnail_url( 'full' ); ?>');">
	                <div class="featured-content-wrapper" style=" background-color: rgba(255, 255, 255, 0.2 )">

	                    <header class="shadow-entry-header">
	                        <h2 class="shadow-entry-title" style="font-size: <?php echo esc_attr($header_font_size); ?>px; " ><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h2>
	                    </header>

	                    <?php nuevo_blog_posted_on(); ?>

	                    <?php 
	                    	$read_more = get_theme_mod( 'nuevo_blog_slider_custom_btn_' . $i, $default['nuevo_blog_slider_custom_btn'] ); 
	                    ?>
                    	<?php if ( ! empty( $read_more ) ) : ?>

		                    <a href="<?php the_permalink(); ?>" class="btn btn-fill" style="font-size: <?php echo esc_attr($button_font_size); ?>px; "><?php echo esc_html( $read_more ); ?><?php echo nuevo_blog_get_icon_svg( 'keyboard_arrow_right' ); ?>
		                    </a>
		                <?php endif; ?>
	                </div><!-- .featured-content-wrapper -->
    	        </article>
	        <?php 
	        $i++;
	    	endwhile;
	    endif;
	    wp_reset_postdata();
	?>
</div><!-- #featured-slider -->