<?php
/**
 * Article Widget Style
 *
 * @package Vintuna
 */
if (!function_exists('vintuna_post_widget')) :
    /**
     * Load widgets.
     *
     * @since 1.0.0
     */
    function vintuna_post_widget()
    {
        register_widget('Vintuna_Post_Widget');
    }
endif;
add_action('widgets_init', 'vintuna_post_widget');
// Article Widget Layout 1
if (!class_exists('Vintuna_Post_Widget')) :
    /**
     * Article Widget Layout 1
     *
     * @since 1.0.0
     */
    class Vintuna_Post_Widget extends Vintuna_Widget_Base
    {
        /**
         * Sets up a new widget instance.
         *
         * @since 1.0.0
         */
        function __construct()
        {
            $opts = array(
                'classname' => 'vintuna_post_widget',
                'description' => esc_html__('Displays posts from selected category in different featured layouts.', 'vintuna'),
                'customize_selective_refresh' => true,
            );
            $fields = array(
                'title' => array(
                    'label' => esc_html__('Section Title:', 'vintuna'),
                    'type' => 'text',
                    'class' => 'widefat',
                ),
                'post_category' => array(
                    'label' => esc_html__('Select Category:', 'vintuna'),
                    'type' => 'dropdown-taxonomies',
                    'show_option_all' => esc_html__('All Categories', 'vintuna'),
                ),
                'display_orientation' => array(
                    'label' => esc_html__('Display Layout:', 'vintuna'),
                    'type' => 'select',
                    'default' => 'layout-1',
                    'options' => array(
                        'layout-1' => esc_html__('Layout - 1 ', 'vintuna'),
                        'layout-2' => esc_html__('Layout - 2', 'vintuna'),
                        'layout-3' => esc_html__('Layout - 3', 'vintuna'),
                        'layout-4' => esc_html__('Layout - 4', 'vintuna'),
                        'layout-5' => esc_html__('Layout - 5', 'vintuna'),
                    ),
                ),
                'post_offset' => array(
                    'label' => esc_html__('Posts offset:', 'vintuna'),
                    'type' => 'number',
                    'default' => 0,
                    'css' => 'max-width:60px;',
                    'min' => 0,
                    'max' => 12,
                ),
                'enable_meta' => array(
                    'label' => esc_html__('Enable Categories:', 'vintuna'),
                    'type' => 'checkbox',
                    'default' => true,
                ),
                'enable_meta_1' => array(
                    'label' => esc_html__('Enable Date & Author:', 'vintuna'),
                    'type' => 'checkbox',
                    'default' => true,
                ),
                'button_text' => array(
                    'label' => esc_html__('Button Text:', 'vintuna'),
                    'type' => 'text',
                    'default' => 'View more',
                    'class' => 'widefat',
                ),
            );
            parent::__construct('vintuna-widget-style-1', esc_html__('Vintuna: Featured Blocks', 'vintuna'), $opts, array(), $fields);
        }

        /**
         * Outputs the content for the current widget instance.
         *
         * @param array $args Display arguments.
         * @param array $instance Settings for the current widget instance.
         * @since 1.0.0
         *
         */
        function widget($args, $instance)
        {
            $params = $this->get_params($instance);
            $post_offset = $params['post_offset'];
            echo $args['before_widget'];
            if ($params['display_orientation'] == 'layout-1') {
                $post_number = 2;
            } elseif ($params['display_orientation'] == 'layout-2') {
                $post_number = 6;
            } elseif ($params['display_orientation'] == 'layout-4') {
                $post_number = 5;
            } elseif ($params['display_orientation'] == 'layout-5') {
                $post_number = 9;
            } else {
                $post_number = 5;
            }
            $qargs = array(
                'post_type' => 'post',
                'offset' => $post_offset,
                'posts_per_page' => $post_number,
                'post__not_in' => get_option("sticky_posts"),
            );
            $cat_link = "";
            if (absint($params['post_category']) > 0) {
                $qargs['cat'] = absint($params['post_category']);
                $cat_link = get_category_link($params['post_category']);
            }
            $style_1_posts_query = new WP_Query($qargs);
            if ($style_1_posts_query->have_posts()) : ?>
                <?php $display_orientation = esc_attr($params['display_orientation']);
                if ($display_orientation == 'layout-1') { ?>
                    <div class="widget-layout widget-layout-1">
                        <?php if (!empty($params['title'])) { ?>
                            <header class="theme-widget-header">
                                <h2 class="widget-title">
                                    <?php echo $params['title'] ?>
                                </h2>
                                <span class="block-title-dash"></span>

                                <?php if (!empty($params['button_text']) && !empty($cat_link)) { ?>
                                    <a href="<?php echo esc_url($cat_link); ?>"
                                       class="theme-btn theme-primary-btn title-view-more">
                                        <?php echo esc_html($params['button_text']); ?><?php vintuna_theme_svg('arrow-right'); ?>
                                    </a>
                                <?php } ?>

                            </header>
                        <?php } ?>
                        <div class="theme-widget-content">
                            <?php
                            $i = 1;
                            while ($style_1_posts_query->have_posts()) :
                                $style_1_posts_query->the_post(); ?>
                                <div class="theme-widget-panel widget-panel-<?php echo $i; ?>">
                                    <div class="widget-story">
                                        <article
                                                id="theme-post-<?php the_ID(); ?>" <?php post_class('news-article news-article-default'); ?>>
                                            <?php
                                            $fallback_image_url = vintuna_get_fallback_image_url();
                                            if (has_post_thumbnail() || $fallback_image_url) : ?>
                                                <div class="entry-image entry-image-big image-hover-effect hover-effect-shine">
                                                    <a class="post-thumbnail" href="<?php the_permalink(); ?>"
                                                       aria-hidden="true" tabindex="-1">
                                                        <?php
                                                        if (has_post_thumbnail()) {
                                                            the_post_thumbnail('medium_large', [
                                                                'alt' => the_title_attribute(['echo' => false]),
                                                            ]);
                                                        } else {
                                                            echo '<img src="' . esc_url($fallback_image_url) . '" alt="' . esc_attr(get_the_title()) . '" />';
                                                        }
                                                        ?>
                                                    </a>
                                                </div>
                                            <?php endif; ?>

                                            <div class="article-content">
                                                <?php if ($params['enable_meta'] == 'yes') { ?>
                                                    <div class="entry-meta">
                                                        <?php vintuna_entry_footer($cats = true, $tags = false, $edits = false, $text = false, $icon = false); ?>
                                                    </div>
                                                <?php } ?>
                                                <h3 class="entry-title entry-title-medium">
                                                    <a href="<?php the_permalink(); ?>" rel="bookmark">
                                                        <?php the_title(); ?>
                                                    </a>
                                                </h3>
                                                <?php if ($params['enable_meta_1'] == 'yes') { ?>
                                                    <div class="entry-meta">
                                                        <?php vintuna_posted_by(); ?>
                                                    </div>
                                                <?php } ?>
                                                <div class="entry-content entry-content-muted">
                                                    <?php
                                                    if (has_excerpt()) {
                                                        the_excerpt();
                                                    } else {
                                                        echo '<p>';
                                                        echo esc_html(wp_trim_words(get_the_content(), 20, '...'));
                                                        echo '</p>';
                                                    } ?>
                                                </div>
                                            </div>
                                        </article>
                                    </div>
                                </div>
                                <?php $i++;
                                wp_reset_postdata(); endwhile; ?>
                        </div>
                    </div>
                <?php } elseif ($display_orientation == 'layout-2') { ?>
                    <div class="widget-layout widget-layout-2">
                    <?php if (!empty($params['title'])) { ?>
                        <header class="theme-widget-header">
                            <h2 class="widget-title">
                                <?php echo $params['title'] ?>
                            </h2>
                            <span class="block-title-dash"></span>
                            <?php if (!empty($cat_link)) { ?>
                                <a href="<?php echo esc_url($cat_link); ?>"
                                   class="theme-btn theme-primary-btn title-view-more">
                                    <?php echo esc_html($params['button_text']); ?>
                                    <?php vintuna_theme_svg('arrow-right'); ?>
                                </a>
                            <?php } ?>
                        </header>
                    <?php } ?>
                    <div class="theme-widget-content">
                        <?php
                        $i = 1;
                        while ($style_1_posts_query->have_posts()) :
                        $style_1_posts_query->the_post(); ?>
                        <?php switch ($i) {
                        case ($i == 1): ?>
                        <div class="theme-widget-panel widget-panel-1">
                            <div class="widget-story">
                                <article
                                        id="theme-post-<?php the_ID(); ?>" <?php post_class('news-article news-article-default'); ?>>
                                    <?php
                                    $fallback_image_url = vintuna_get_fallback_image_url();
                                    if (has_post_thumbnail() || $fallback_image_url) : ?>
                                        <div class="entry-image entry-image-large image-hover-effect hover-effect-shine">
                                            <a class="post-thumbnail" href="<?php the_permalink(); ?>"
                                               aria-hidden="true" tabindex="-1">
                                                <?php
                                                if (has_post_thumbnail()) {
                                                    the_post_thumbnail('large', [
                                                        'alt' => the_title_attribute(['echo' => false]),
                                                    ]);
                                                } else {
                                                    echo '<img src="' . esc_url($fallback_image_url) . '" alt="' . esc_attr(get_the_title()) . '" />';
                                                }
                                                ?>
                                            </a>
                                        </div>
                                    <?php endif; ?>

                                    <div class="article-content mt-20">
                                        <?php if ($params['enable_meta'] == 'yes') { ?>
                                            <div class="entry-meta mb-10">
                                                <?php vintuna_entry_footer($cats = true, $tags = false, $edits = false, $text = false, $icon = false); ?>
                                            </div>
                                        <?php } ?>
                                        <h3 class="entry-title entry-title-medium">
                                            <a href="<?php the_permalink(); ?>" rel="bookmark">
                                                <?php the_title(); ?>
                                            </a>
                                        </h3>
                                        <?php if ($params['enable_meta_1'] == 'yes') { ?>
                                            <div class="entry-meta">
                                                <?php vintuna_posted_by(); ?>
                                            </div>
                                        <?php } ?>
                                        <div class="entry-content entry-content-muted content-muted-medium">
                                            <?php
                                            if (has_excerpt()) {
                                                the_excerpt();
                                            } else {
                                                echo '<p>';
                                                echo esc_html(wp_trim_words(get_the_content(), 20, '...'));
                                                echo '</p>';
                                            } ?>
                                        </div>
                                    </div>
                                </article>
                            </div>
                        </div>
                        <div class="theme-widget-panel theme-svg-seperator">
                            <?php vintuna_theme_svg('seperator'); ?>
                        </div>
                        <div class="theme-widget-panel widget-panel-2">
                            <?php break;
                            default: ?>
                                <div class="widget-story-list">
                                    <article
                                            id="theme-post-<?php the_ID(); ?>" <?php post_class('news-article news-article-list'); ?>>
                                        <?php
                                        $fallback_image_url = vintuna_get_fallback_image_url();
                                        if (has_post_thumbnail() || $fallback_image_url) : ?>
                                            <div class="entry-image entry-image-thumbnail image-hover-effect hover-effect-shine">
                                                <a class="post-thumbnail" href="<?php the_permalink(); ?>"
                                                   aria-hidden="true" tabindex="-1">
                                                    <?php
                                                    if (has_post_thumbnail()) {
                                                        the_post_thumbnail('medium', [
                                                            'alt' => the_title_attribute(['echo' => false]),
                                                        ]);
                                                    } else {
                                                        echo '<img src="' . esc_url($fallback_image_url) . '" alt="' . esc_attr(get_the_title()) . '" />';
                                                    }
                                                    ?>
                                                </a>
                                            </div>
                                        <?php endif; ?>

                                        <div class="article-content">
                                            <h3 class="entry-title entry-title-small line-clamp-3">
                                                <a href="<?php the_permalink(); ?>" rel="bookmark">
                                                    <?php the_title(); ?>
                                                </a>
                                            </h3>
                                            <?php if ($params['enable_meta_1'] == 'yes') { ?>
                                                <div class="entry-meta">
                                                    <?php vintuna_posted_by(); ?>
                                                </div>
                                            <?php } ?>
                                        </div>
                                    </article>
                                </div>
                                <?php if ($style_1_posts_query->current_post + 1 == $style_1_posts_query->post_count) {
                                    echo '</div>';
                                } ?>
                                <?php
                                break;
                            }
                            $i++; ?>
                            <?php wp_reset_postdata();
                            endwhile; ?>
                        </div>

                    </div>
                <?php } elseif ($display_orientation == 'layout-3') { ?>
                    <div class="widget-layout widget-layout-3">
                    <?php if (!empty($params['title'])) { ?>
                        <header class="theme-widget-header">
                            <h2 class="widget-title">
                                <?php echo $params['title'] ?>
                            </h2>
                            <span class="block-title-dash"></span>
                            <?php if (!empty($cat_link)) { ?>
                                <a href="<?php echo esc_url($cat_link); ?>"
                                   class="theme-btn theme-primary-btn title-view-more">
                                    <?php echo esc_html($params['button_text']); ?>
                                    <?php vintuna_theme_svg('arrow-right'); ?>
                                </a>
                            <?php } ?>
                        </header>
                    <?php } ?>
                    <div class="theme-widget-content">
                        <?php
                        $i = 1;
                        while ($style_1_posts_query->have_posts()) :
                        $style_1_posts_query->the_post(); ?>
                        <?php if ($i == 1) { ?>
                        <div class="theme-widget-panel widget-panel-1 mb-30">
                            <div class="widget-story-jumbotron ">
                                <article
                                        id="theme-post-<?php the_ID(); ?>" <?php post_class('news-article news-article-default'); ?>>
                                    <?php
                                    $fallback_image_url = vintuna_get_fallback_image_url();
                                    if (has_post_thumbnail() || $fallback_image_url) : ?>
                                        <div class="entry-image entry-image-large image-hover-effect hover-effect-shine">
                                            <a class="post-thumbnail" href="<?php the_permalink(); ?>"
                                               aria-hidden="true" tabindex="-1">
                                                <?php
                                                if (has_post_thumbnail()) {
                                                    the_post_thumbnail('large', [
                                                        'alt' => the_title_attribute(['echo' => false]),
                                                    ]);
                                                } else {
                                                    echo '<img src="' . esc_url($fallback_image_url) . '" alt="' . esc_attr(get_the_title()) . '" />';
                                                }
                                                ?>
                                            </a>
                                        </div>
                                    <?php endif; ?>

                                    <div class="article-content mt-sm-15">
                                        <?php if ($params['enable_meta'] == 'yes') { ?>
                                            <div class="entry-meta">
                                                <?php vintuna_entry_footer($cats = true, $tags = false, $edits = false, $text = false, $icon = false); ?>
                                            </div>
                                        <?php } ?>
                                        <h3 class="entry-title entry-title-large">
                                            <a href="<?php the_permalink(); ?>" rel="bookmark">
                                                <?php the_title(); ?>
                                            </a>
                                        </h3>
                                        <?php if ($params['enable_meta_1'] == 'yes') { ?>
                                            <div class="entry-meta">
                                                <?php vintuna_posted_by(); ?>
                                            </div>
                                        <?php } ?>
                                        <div class="entry-content entry-content-muted">
                                            <?php
                                            if (has_excerpt()) {
                                                the_excerpt();
                                            } else {
                                                echo '<p>';
                                                echo esc_html(wp_trim_words(get_the_content(), 20, '...'));
                                                echo '</p>';
                                            } ?>
                                        </div>
                                    </div>
                                </article>
                            </div>
                        </div>
                        <div class="theme-widget-panel widget-panel-2">
                            <?php $i++;
                            } else { ?>

                                <article
                                        id="theme-post-<?php the_ID(); ?>" <?php post_class('news-article news-article-default'); ?>>
                                    <?php
                                    $fallback_image_url = vintuna_get_fallback_image_url();
                                    if (has_post_thumbnail() || $fallback_image_url) : ?>
                                        <div class="entry-image entry-image-small image-hover-effect hover-effect-shine">
                                            <a class="post-thumbnail" href="<?php the_permalink(); ?>"
                                               aria-hidden="true" tabindex="-1">
                                                <?php
                                                if (has_post_thumbnail()) {
                                                    the_post_thumbnail('medium', [
                                                        'alt' => the_title_attribute(['echo' => false]),
                                                    ]);
                                                } else {
                                                    echo '<img src="' . esc_url($fallback_image_url) . '" alt="' . esc_attr(get_the_title()) . '" />';
                                                }
                                                ?>
                                            </a>
                                        </div>
                                    <?php endif; ?>

                                    <div class="article-content">
                                        <?php if ($params['enable_meta'] == 'yes') { ?>
                                            <div class="entry-meta">
                                                <?php vintuna_entry_footer($cats = true, $tags = false, $edits = false, $text = false, $icon = false); ?>
                                            </div>
                                        <?php } ?>
                                        <h3 class="entry-title entry-title-medium line-clamp-2">
                                            <a href="<?php the_permalink(); ?>" rel="bookmark">
                                                <?php the_title(); ?>
                                            </a>
                                        </h3>
                                        <?php if ($params['enable_meta_1'] == 'yes') { ?>
                                            <div class="entry-meta">
                                                <?php vintuna_posted_by(); ?>
                                            </div>
                                        <?php } ?>
                                    </div>
                                </article>

                                <?php if ($style_1_posts_query->current_post + 1 == $style_1_posts_query->post_count) {
                                    echo '</div>';
                                } ?>
                            <?php } ?>
                            <?php wp_reset_postdata();
                            endwhile; ?>
                        </div>

                    </div>
                <?php } elseif ($display_orientation == 'layout-4') { ?>
                    <div class="widget-layout widget-layout-4">
                        <?php if (!empty($params['title'])) { ?>
                            <header class="theme-widget-header">
                                <h2 class="widget-title">
                                    <?php echo $params['title']; ?>
                                </h2>
                                <span class="block-title-dash"></span>
                                <?php if (!empty($cat_link)) { ?>
                                    <a href="<?php echo esc_url($cat_link); ?>"
                                       class="theme-btn theme-primary-btn title-view-more">
                                        <?php echo esc_html($params['button_text']); ?>
                                        <?php vintuna_theme_svg('arrow-right'); ?>
                                    </a>
                                <?php } ?>
                            </header>
                        <?php } ?>

                        <div class="theme-widget-content">
                            <?php
                            $i = 1;
                            while ($style_1_posts_query->have_posts()) :
                                $style_1_posts_query->the_post();

                                if ($i == 1) {
                                    echo '<div class="theme-widget-panel widget-panel-1">';
                                }
                                if ($i <= 2) { ?>
                                    <article id="theme-post-<?php the_ID(); ?>" <?php post_class('news-article news-article-default mb-30'); ?>>
                                        <?php
                                        $fallback_image_url = vintuna_get_fallback_image_url();
                                        if (has_post_thumbnail() || $fallback_image_url) : ?>
                                            <div class="entry-image entry-image-small image-hover-effect hover-effect-shine">
                                                <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
                                                    <?php
                                                    if (has_post_thumbnail()) {
                                                        the_post_thumbnail('medium', [
                                                            'alt' => the_title_attribute(['echo' => false]),
                                                        ]);
                                                    } else {
                                                        echo '<img src="' . esc_url($fallback_image_url) . '" alt="' . esc_attr(get_the_title()) . '" />';
                                                    }
                                                    ?>
                                                </a>
                                            </div>
                                        <?php endif; ?>

                                        <div class="article-content">
                                            <h3 class="entry-title entry-title-small line-clamp-3">
                                                <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
                                            </h3>
                                            <?php if ($params['enable_meta_1'] == 'yes') : ?>
                                                <div class="entry-meta">
                                                    <?php vintuna_posted_by(); ?>
                                                </div>
                                            <?php endif; ?>
                                        </div>
                                    </article>
                                <?php }

                                if ($i == 2) {
                                    echo '</div>';
                                }

                                if ($i == 3) {
                                    echo '<div class="theme-widget-panel widget-panel-2">';
                                    ?>
                                    <article id="theme-post-<?php the_ID(); ?>" <?php post_class('news-article news-article-default'); ?>>
                                        <?php
                                        $fallback_image_url = vintuna_get_fallback_image_url();
                                        if (has_post_thumbnail() || $fallback_image_url) : ?>
                                            <div class="entry-image entry-image-large image-hover-effect hover-effect-shine">
                                                <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
                                                    <?php
                                                    if (has_post_thumbnail()) {
                                                        the_post_thumbnail('large', [
                                                            'alt' => the_title_attribute(['echo' => false]),
                                                        ]);
                                                    } else {
                                                        echo '<img src="' . esc_url($fallback_image_url) . '" alt="' . esc_attr(get_the_title()) . '" />';
                                                    }
                                                    ?>
                                                </a>
                                            </div>
                                        <?php endif; ?>

                                        <div class="article-content">
                                            <h3 class="entry-title entry-title-small line-clamp-3">
                                                <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
                                            </h3>
                                            <?php if ($params['enable_meta_1'] == 'yes') : ?>
                                                <div class="entry-meta">
                                                    <?php vintuna_posted_by(); ?>
                                                </div>
                                            <?php endif; ?>
                                        </div>
                                    </article>
                                    <?php
                                    echo '</div>';
                                }

                                if ($i == 4) {
                                    echo '<div class="theme-widget-panel widget-panel-3">';
                                }

                                if ($i == 4 || $i == 5) { ?>
                                    <div class="widget-story">
                                        <article id="theme-post-<?php the_ID(); ?>" <?php post_class('news-article news-article-default mb-30'); ?>>
                                            <?php
                                            $fallback_image_url = vintuna_get_fallback_image_url();
                                            if (has_post_thumbnail() || $fallback_image_url) : ?>
                                                <div class="entry-image entry-image-small image-hover-effect hover-effect-shine">
                                                    <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
                                                        <?php
                                                        if (has_post_thumbnail()) {
                                                            the_post_thumbnail('medium', [
                                                                'alt' => the_title_attribute(['echo' => false]),
                                                            ]);
                                                        } else {
                                                            echo '<img src="' . esc_url($fallback_image_url) . '" alt="' . esc_attr(get_the_title()) . '" />';
                                                        }
                                                        ?>
                                                    </a>
                                                </div>
                                            <?php endif; ?>

                                            <div class="article-content">
                                                <h3 class="entry-title entry-title-small line-clamp-3">
                                                    <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
                                                </h3>
                                                <?php if ($params['enable_meta_1'] == 'yes') : ?>
                                                    <div class="entry-meta">
                                                        <?php vintuna_posted_by(); ?>
                                                    </div>
                                                <?php endif; ?>
                                            </div>
                                        </article>
                                    </div>
                                <?php }

                                if ($i == 5) {
                                    echo '</div>';
                                }

                                if ($style_1_posts_query->current_post + 1 == $style_1_posts_query->post_count) {
                                    if ($i == 1) {
                                        echo '</div>';
                                    }
                                    if ($i == 3) {
                                        echo '</div>';
                                    }
                                    if ($i == 4) {
                                        echo '</div>';
                                    }
                                }
                                $i++;
                            endwhile;

                            wp_reset_postdata();
                            ?>
                        </div> 
                    </div>

                <?php } elseif ($display_orientation == 'layout-5') { ?>
                    <div class="widget-layout widget-layout-5">
                    <?php if (!empty($params['title'])) { ?>
                        <header class="theme-widget-header">
                            <h2 class="widget-title">
                                <?php echo $params['title'] ?>
                            </h2>
                            <span class="block-title-dash"></span>
                            <?php if (!empty($cat_link)) { ?>
                                <a href="<?php echo esc_url($cat_link); ?>"
                                   class="theme-btn theme-primary-btn title-view-more">
                                    <?php echo esc_html($params['button_text']); ?>
                                    <?php vintuna_theme_svg('arrow-right'); ?>
                                </a>
                            <?php } ?>
                        </header>
                    <?php } ?>
                    <div class="theme-widget-content">
                        <div class="theme-widget-panel widget-panel-1">
                            <?php
                            $i = 1;
                            while ($style_1_posts_query->have_posts()) :
                            $style_1_posts_query->the_post(); ?>
                            <?php if ($i <= 6) { ?>
                            <div class="widget-story">

                                <article id="theme-post-<?php the_ID(); ?>" <?php post_class('news-article news-article-default'); ?>>

                                    <?php
                                    $fallback_image_url = vintuna_get_fallback_image_url();
                                    if (has_post_thumbnail() || $fallback_image_url) : ?>
                                        <div class="entry-image entry-image-small image-hover-effect hover-effect-shine">
                                            <a class="post-thumbnail" href="<?php the_permalink(); ?>"
                                               aria-hidden="true" tabindex="-1">
                                                <?php
                                                if (has_post_thumbnail()) {
                                                    the_post_thumbnail('medium', [
                                                        'alt' => the_title_attribute(['echo' => false]),
                                                    ]);
                                                } else {
                                                    echo '<img src="' . esc_url($fallback_image_url) . '" alt="' . esc_attr(get_the_title()) . '" />';
                                                }
                                                ?>
                                            </a>
                                        </div>
                                    <?php endif; ?>

                                    <div class="article-content">
                                        <h3 class="entry-title entry-title-small line-clamp-3">
                                            <a href="<?php the_permalink(); ?>" rel="bookmark">
                                                <?php the_title(); ?>
                                            </a>
                                        </h3>
                                        <?php if ($params['enable_meta_1'] == 'yes') { ?>
                                            <div class="entry-meta">
                                                <?php vintuna_posted_by(); ?>
                                            </div>
                                        <?php } ?>
                                    </div>
                                </article>
                            </div>
                            <?php if ($i == 6) { ?>
                        </div>
                        <div class="theme-widget-panel widget-panel-2">
                            <?php } ?>
                            <?php $i++;
                            } else { ?>
                                <div class="widget-story">

                                    <article id="theme-post-<?php the_ID(); ?>" <?php post_class('news-article news-article-default'); ?>>
                                        <div class="img-hover-panel">

                                            <?php
                                            $fallback_image_url = vintuna_get_fallback_image_url();
                                            if (has_post_thumbnail() || $fallback_image_url) : ?>
                                                <div class="entry-image entry-image-big image-hover-effect hover-effect-shine">
                                                    <a class="post-thumbnail" href="<?php the_permalink(); ?>"
                                                       aria-hidden="true" tabindex="-1">
                                                        <?php
                                                        if (has_post_thumbnail()) {
                                                            the_post_thumbnail('large', [
                                                                'alt' => the_title_attribute(['echo' => false]),
                                                            ]);
                                                        } else {
                                                            echo '<img src="' . esc_url($fallback_image_url) . '" alt="' . esc_attr(get_the_title()) . '" />';
                                                        }
                                                        ?>
                                                    </a>
                                                </div>
                                            <?php endif; ?>

                                            <?php if ($params['enable_meta'] == 'yes') { ?>
                                                <div class="article-content">
                                                    <div class="entry-meta">
                                                        <?php vintuna_entry_footer($cats = true, $tags = false, $edits = false, $text = false, $icon = false); ?>
                                                    </div>
                                                </div>
                                            <?php } ?>
                                        </div>
                                        <div class="article-content">
                                            <h3 class="entry-title entry-title-big line-clamp-3">
                                                <a href="<?php the_permalink(); ?>" rel="bookmark">
                                                    <?php the_title(); ?>
                                                </a>
                                            </h3>
                                            <?php if ($params['enable_meta_1'] == 'yes') { ?>
                                                <div class="entry-meta">
                                                    <?php vintuna_posted_by(); ?>
                                                </div>
                                            <?php } ?>

                                            <div class="entry-content hidden-xs-element entry-content-muted">
                                                <?php
                                                if (has_excerpt()) {
                                                    the_excerpt();
                                                } else {
                                                    echo '<p>';
                                                    echo esc_html(wp_trim_words(get_the_content(), 25, '...'));
                                                    echo '</p>';
                                                } ?>
                                            </div>
                                        </div>
                                    </article>
                                </div>
                                <?php if ($style_1_posts_query->current_post + 1 == $style_1_posts_query->post_count) {
                                    echo '</div>';
                                } ?>
                            <?php } ?>
                            <?php wp_reset_postdata();
                            endwhile; ?>
                        </div>

                    </div>
                <?php } ?>
            <?php endif;
            echo $args['after_widget'];
        }
    }
endif;