<?php

    if ( newsweek_setting('newsweek_enable_featured_posts', true) == true ) :

        $featured_posts_enabled = newsweek_setting('newsweek_enable_featured_posts_only_first_page_pagination', true);

        if (
            (
                $featured_posts_enabled == true && 
                get_query_var('paged') <= 1
            ) ||
            $featured_posts_enabled == false
        ) :

        $featured_posts_additional_css = ( newsweek_setting('newsweek_featured_posts_truncate_post_titles') == true ) ? ' featured-posts-truncate-post-titles' : '';

    ?>

        <section class="featured-posts-section">

            <div class="container">
                
                <div class="row">
                    
                    <div class="col-md-12">

                        <div class="featured-posts-grid <?php echo esc_attr($featured_posts_additional_css);?>">

                            <div class="featured-posts-main-column" >
                                
                                <?php

                                    $section_title = newsweek_setting('newsweek_main_column_label', esc_html__( 'Recent', 'newsweek' ));
                                    $slider_transition = newsweek_setting('newsweek_main_column_slider_transition', 'fade');

                                    $col_cx = array(
                                        'post_type' => 'post',
                                        'posts_per_page' => intval(newsweek_setting('newsweek_main_column_posts_limit', 5)),
                                        'ignore_sticky_posts' => true,
                                        'orderby' => newsweek_setting('newsweek_main_column_posts_orderby', 'date'),
                                        'order' => newsweek_setting('newsweek_main_column_posts_sort_order', 'desc'),
                                    );

                                    if ( is_numeric(newsweek_setting('newsweek_main_column_posts_category')) ) :
                                        $col_cx['cat'] = newsweek_setting('newsweek_main_column_posts_category');
                                    endif;
                            
                                    newsweek_horizontal_featured_posts_slideshow($col_cx, $section_title, $slider_transition);
                                
                                ?>

                            </div>

                            <div class="featured-posts-secondary-column">

                                <?php

                                    $section_title = newsweek_setting('newsweek_secondary_column_label', esc_html__( 'Oldest post', 'newsweek' ));

                                    $col_sx = array(
                                        'post_type' => 'post',
                                        'posts_per_page' => intval(newsweek_setting('newsweek_secondary_column_posts_limit', 8)),
                                        'ignore_sticky_posts' => true,
                                        'orderby' => newsweek_setting('newsweek_secondary_column_posts_orderby', 'date'),
                                        'order' => newsweek_setting('newsweek_secondary_column_posts_sort_order', 'asc'),
                                    );

                                    if ( is_numeric(newsweek_setting('newsweek_secondary_column_posts_category')) ) :
                                        $col_sx['cat'] = newsweek_setting('newsweek_secondary_column_posts_category');
                                    endif;
                                
                                    newsweek_vertical_featured_posts_slideshow($col_sx, $section_title);

                                ?>

                            </div>

                            <div class="featured-posts-side-column">

                                <?php

                                    $section_title = newsweek_setting('newsweek_side_column_label', esc_html__( 'Popular', 'newsweek' ));

                                    $col_dx = array(
                                        'post_type' => 'post',
                                        'posts_per_page' => intval(newsweek_setting('newsweek_side_column_posts_limit', 8)),
                                        'ignore_sticky_posts' => true,
                                        'orderby' => newsweek_setting('newsweek_side_column_posts_orderby', 'comment_count'),
                                        'order' => newsweek_setting('newsweek_side_column_posts_sort_order', 'desc'),
                                    );

                                    if ( is_numeric(newsweek_setting('newsweek_side_column_posts_category')) ) :
                                        $col_dx['cat'] = newsweek_setting('newsweek_side_column_posts_category');
                                    endif;
                                
                                    newsweek_vertical_list_featured_posts_slideshow($col_dx, $section_title);

                                ?>

                            </div>

                        </div>
                    
                    </div>

                </div>

            </div>

        </section>

<?php

        endif;


    endif;

?>