<?php
$enable_cat_highlight_section = blogaura_get_option('enable_cat_highlight_section');
$cat_highlight_post_title = blogaura_get_option('cat_highlight_post_title');
$cat_highlight_post_category = blogaura_get_option('cat_highlight_post_category');

$enable_cat_highlight_author_meta = blogaura_get_option('enable_cat_highlight_author_meta');
$select_cat_highlight_author_meta = blogaura_get_option('select_cat_highlight_author_meta');
$cat_highlight_author_meta_title = blogaura_get_option('cat_highlight_author_meta_title');

$enable_cat_highlight_date_meta = blogaura_get_option('enable_cat_highlight_date_meta');
$select_cat_highlight_date = blogaura_get_option('select_cat_highlight_date');
$select_cat_highlight_date_meta_title = blogaura_get_option('select_cat_highlight_date_meta_title');
$select_cat_highlight_date_format = blogaura_get_option('select_cat_highlight_date_format');

$enable_cat_highlight_category_meta = blogaura_get_option('enable_cat_highlight_category_meta');
$cat_highlight_category_label = blogaura_get_option('cat_highlight_category_label');
$select_cat_highlight_category_color = blogaura_get_option('select_cat_highlight_category_color');
$select_cat_highlight_number_of_category = blogaura_get_option('select_cat_highlight_number_of_category');
if (empty($enable_cat_highlight_section)) {
    return;
}
?>
<section class="wpi-section theme-highlight-feed">
    <div class="wrapper">

        <?php if ($cat_highlight_post_title) { ?>
            <header class="wpi-section-header">
                <h2 class="section-header-title"><?php echo esc_html($cat_highlight_post_title); ?></h2>
            </header>
        <?php } ?>

        <div class="wpi-section-content">
            <div class="row-group">
                <?php
                $cat_highlight_args_1 = array(
                    'post_type' => 'post',
                    'posts_per_page' => 6,
                    'post_status' => 'publish',
                    'no_found_rows' => 1,
                    'ignore_sticky_posts' => 1,
                );
                if (!empty($cat_highlight_post_category)) :
                    $cat_highlight_args_1['tax_query'] = array(
                        array(
                            'taxonomy' => 'category',
                            'field' => 'term_id',
                            'terms' => $cat_highlight_post_category,
                        ),
                    );
                endif;
                $count = 1;
                $right_count = 1;
                $delay = 100;
                $cat_highlight_post_1 = new WP_Query($cat_highlight_args_1);
                if ($cat_highlight_post_1->have_posts()) :
                while ($cat_highlight_post_1->have_posts()) :
                $cat_highlight_post_1->the_post(); ?>
                <?php if ($count == 1) { ?>
                <div class="column-lg-3">
                    <article id="highlight-feed-<?php the_ID(); ?>">
                        <?php if (has_post_thumbnail()) : ?>
                            <div class="entry-image entry-image-large image-hover-effect hover-effect-shine"
                                 data-aos="fade-right" data-aos-duration="1000" data-aos-delay="100">
                                <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true"
                                   tabindex="-1">
                                    <?php the_post_thumbnail('medium_large', array('alt' => the_title_attribute(array('echo' => false)))); ?>
                                </a>
                            </div>
                        <?php endif; ?>
                        <div class="entry-details">
                            <?php if ($enable_cat_highlight_category_meta) {
                                blogaura_post_category($select_cat_highlight_category_color, $cat_highlight_category_label, $select_cat_highlight_number_of_category);
                            } ?>
                            <h3 class="entry-title entry-title-medium" data-aos="fade-right" data-aos-duration="1000"
                                data-aos-delay="300">
                                <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                            </h3>
                            <div class="entry-meta-wrapper" data-aos="fade-right" data-aos-duration="1000"
                                 data-aos-delay="500">
                                <?php if ($enable_cat_highlight_date_meta) {
                                    blogaura_posted_on($select_cat_highlight_date_format, $select_cat_highlight_date_meta_title, $select_cat_highlight_date);
                                } ?>
                                <?php if ($enable_cat_highlight_author_meta) {
                                    blogaura_posted_by($select_cat_highlight_author_meta, $cat_highlight_author_meta_title);
                                } ?>
                            </div>
                        </div>
                    </article>
                </div>
                <div class="column-lg-9">
                    <div class="highlight-feed-right">
                        <?php $count++;
                        } else  { ?>
                        <article id="highlight-feed-<?php the_ID(); ?>" <?php post_class('wpi-post'); ?>
                                 data-aos="fade-up"
                                 data-aos-duration="1000" data-aos-delay="<?php echo esc_attr($delay); ?>">
                            <?php if ($right_count > 1 && has_post_thumbnail()) : ?>
                                <div class="entry-image entry-image-medium image-hover-effect hover-effect-shine">
                                    <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true"
                                       tabindex="-1">
                                        <?php the_post_thumbnail('medium_large', array('alt' => the_title_attribute(array('echo' => false)))); ?>
                                    </a>
                                </div>
                            <?php endif; ?>
                            <div class="entry-details">
                                <?php if ($enable_cat_highlight_category_meta) {
                                    blogaura_post_category($select_cat_highlight_category_color, $cat_highlight_category_label, $select_cat_highlight_number_of_category);
                                } ?>
                                <h3 class="entry-title entry-title-xsmall limit-line-3">
                                    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                                </h3>
                                <?php if ($right_count < 2) : ?>
                                    <div class="entry-content limit-line-4">
                                        <?php the_excerpt(); ?>
                                    </div>
                                <?php endif; ?>
                                <div class="entry-meta-wrapper">
                                    <?php if ($enable_cat_highlight_date_meta) {
                                        blogaura_posted_on($select_cat_highlight_date_format, $select_cat_highlight_date_meta_title, $select_cat_highlight_date);
                                    } ?>
                                    <?php if ($enable_cat_highlight_author_meta) {
                                        blogaura_posted_by($select_cat_highlight_author_meta, $cat_highlight_author_meta_title);
                                    } ?>
                                </div>
                            </div>
                        </article>
                        <?php $delay += 100; ?>
                        <?php $right_count++; ?>
                        <?php if ($cat_highlight_post_1->current_post + 1 == $cat_highlight_post_1->post_count) { ?>
                    </div>
                </div>
            </div>
        </div>
    <?php } ?>
    <?php } ?>
    <?php
    endwhile;
    wp_reset_postdata();
    endif; ?>

    </div>
</section>