the_title();
            ?>
</a></h3>
                    <div class="ratings-wrapper"><?php 
            do_action('accesspress_mag_post_review');
            ?>
</div>
                    <div class="block-poston"><?php 
            do_action('accesspress_mag_home_posted_on');
            ?>
</div>
                    <?php 
            if ($b4_counter != 1) {
                ?>
                        <div class="post-content"><?php 
                accesspress_mag_homepage_excerpt();
                ?>
</div>
                    <?php 
            }
            ?>
                </div>
                
        </div>
    <?php 
            if ($b4_counter == $b4_total_posts) {
                echo '</div>';
            }
        }
    }
    ?>
        /**
         * Front-end display of widget.
         *
         * @see WP_Widget::widget()
         *
         * @param array $args     Widget arguments.
         * @param array $instance Saved values from database.
         */
        public function widget($args, $instance)
        {
            extract($args);
            $featured_category_title = $instance['featured_category_title'];
            $featured_category = $instance['featured_category'];
            $featured_category_posts_count = $instance['featured_category_posts_count'];
            $featured_category_view_all_show = $instance['featured_category_view_all_show'];
            echo $before_widget;
            ?>
        <div class="featured-category-wrapper">
            <h1 class="widget-title"><span><?php 
            echo esc_attr($featured_category_title);
            ?>
</span></h1>
            <div class="content-wrapper">
                <?php 
            if (!empty($featured_category)) {
                $featured_cat_args = array('cat' => $featured_category, 'post_status' => 'pubish', 'posts_per_page' => $featured_category_posts_count, 'order' => 'DESC');
                $featured_cat_query = new WP_Query($featured_cat_args);
                $e_counter = 0;
                $total_posts_editor = $featured_cat_query->found_posts;
                $cat_link = get_category_link($featured_category);
                if ($featured_cat_query->have_posts()) {
                    while ($featured_cat_query->have_posts()) {
                        $e_counter++;
                        $featured_cat_query->the_post();
                        $featured_cat_image_id = get_post_thumbnail_id();
                        $featured_cat_big_image_path = wp_get_attachment_image_src($featured_cat_image_id, 'accesspress-mag-block-big-thumb', true);
                        $featured_cat_small_image_path = wp_get_attachment_image_src($featured_cat_image_id, 'accesspress-mag-block-small-thumb', true);
                        $featured_cat_image_alt = get_post_meta($featured_cat_image_id, '_wp_attachment_image_alt', true);
                        $fallback_image_option = of_get_option('fallback_image_option', '1');
                        $fallback_image = of_get_option('fallback_image', get_template_directory_uri() . '/images/no-image.jpg');
                        $apmag_overlay_icon = of_get_option('apmag_overlay_icon', 'fa-external-link');
                        $post_format = get_post_format(get_the_ID());
                        if ($post_format == 'video') {
                            $post_format_icon = 'fa-video-camera';
                            $show_icon = 'on';
                        } elseif ($post_format == 'audio') {
                            $post_format_icon = 'fa-music';
                            $show_icon = 'on';
                        } elseif ($post_format == 'gallery') {
                            $post_format_icon = 'fa-picture-o';
                            $show_icon = 'on';
                        } else {
                            $show_icon = 'off';
                        }
                        ?>
                    <div class="single_post clearfix <?php 
                        if ($e_counter == 1) {
                            echo 'first-post non-zoomin';
                        }
                        ?>
">
                        
                            <div class="post-image">
                                <a href="<?php 
                        the_permalink();
                        ?>
" title="<?php 
                        the_title();
                        ?>
">
                                    <?php 
                        if (has_post_thumbnail()) {
                            ?>
                                        <img src="<?php 
                            if ($e_counter == 1) {
                                echo esc_url($featured_cat_big_image_path[0]);
                            } else {
                                echo esc_url($featured_cat_small_image_path[0]);
                            }
                            ?>
" alt="<?php 
                            echo esc_attr($featured_cat_image_alt);
                            ?>
" />
                                    <?php 
                        } else {
                            if ($fallback_image_option == 1 && !empty($fallback_image)) {
                                ?>
                                        <img src="<?php 
                                echo esc_url($fallback_image);
                                ?>
" alt="Fallback Image" />
                                    <?php 
                            }
                        }
                        ?>
                                </a>
                                <?php 
                        if ($e_counter == 1) {
                            ?>
 <a class="big-image-overlay" href="<?php 
                            the_permalink();
                            ?>
" title="<?php 
                            the_title();
                            ?>
"><i class="fa <?php 
                            echo esc_attr($apmag_overlay_icon);
                            ?>
"></i></a><?php 
                        }
                        ?>
                                <?php 
                        if ($show_icon == 'on') {
                            ?>
<span class="format_icon <?php 
                            if ($e_counter > 2) {
                                echo 'small';
                            }
                            ?>
"><i class="fa <?php 
                            echo esc_attr($post_format_icon);
                            ?>
"></i></span><?php 
                        }
                        ?>
                            </div>                                
                        <?php 
                        if ($e_counter > 1) {
                            echo '<div class="post-desc-wrapper">';
                        }
                        ?>
                            <h4 class="post-title"><a href="<?php 
                        the_permalink();
                        ?>
"><?php 
                        the_title();
                        ?>
</a></h4>
                            <div class="block-poston"><?php 
                        do_action('accesspress_mag_home_posted_on');
                        ?>
</div>
                            <div class="ratings-wrapper"><?php 
                        do_action('accesspress_mag_post_review');
                        ?>
</div>
                            <?php 
                        if ($e_counter > 1) {
                            echo '</div>';
                        }
                        if ($e_counter == 1) {
                            ?>
<div class="post-content"><?php 
                            accesspress_mag_homepage_excerpt();
                            ?>
</div><?php 
                        }
                        ?>
                    </div>
                <?php 
                    }
                    if (!empty($featured_category_view_all_show) && $featured_category_view_all_show == 1) {
                        echo '<a href="' . esc_url($cat_link) . '" class="cat-link view-all-button">' . __('View all posts', 'accesspress-mag') . '</a>';
                    }
                }
            }
            ?>
    
                </div>
        </div>
<?php 
            echo $after_widget;
        }
    function accesspress_mag_popular_block_callback()
    {
        $popular_block_title = of_get_option('popular_block_name', 'Popular Articles');
        $popular_block_category = of_get_option('popular_block_category', 'all');
        $popular_posts_per_page = of_get_option('popular_posts_count', '5');
        $apmag_overlay_icon = of_get_option('apmag_overlay_icon', 'fa-external-link');
        $pbc_args = array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $popular_posts_per_page, 'meta_key' => 'post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC');
        if (!empty($popular_block_category) && $popular_block_category != 'all') {
            $pbc_args['category_name'] = $popular_block_category;
        }
        $pbc_query = new WP_Query($pbc_args);
        ?>
        <div class="popular-block-wrapper">
            <h2 class="block-cat-name"><span><?php 
        echo esc_attr($popular_block_title);
        ?>
</span></h2>            
            <?php 
        $p_total_posts = $pbc_query->post_count;
        $p_counter = 0;
        if ($pbc_query->have_posts()) {
            while ($pbc_query->have_posts()) {
                $p_counter++;
                $pbc_query->the_post();
                if ($p_counter == 1) {
                    $p_image_size = 'accesspress-mag-singlepost-default';
                } else {
                    $p_image_size = 'accesspress-mag-block-big-thumb';
                }
                $p_image_id = get_post_thumbnail_id();
                $p_image_path = wp_get_attachment_image_src($p_image_id, $p_image_size, true);
                $p_image_alt = get_post_meta($p_image_id, '_wp_attachment_image_alt', true);
                $post_format = get_post_format(get_the_ID());
                if ($post_format == 'video') {
                    $post_format_icon = 'fa-video-camera';
                    $show_icon = 'on';
                } elseif ($post_format == 'audio') {
                    $post_format_icon = 'fa-music';
                    $show_icon = 'on';
                } elseif ($post_format == 'gallery') {
                    $post_format_icon = 'fa-picture-o';
                    $show_icon = 'on';
                } else {
                    $show_icon = 'off';
                }
                if ($p_counter > 1 && $p_counter == 2) {
                    echo '<div class="posts-grid-wrapper">';
                }
                ?>
                        <div class="single_post clearfix <?php 
                if ($p_counter == 1) {
                    echo 'first-post';
                }
                ?>
 non-zoomin">
                            <?php 
                if (has_post_thumbnail()) {
                    ?>
   
                                <div class="post-image"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
"><img src="<?php 
                    echo esc_url($p_image_path[0]);
                    ?>
" alt="<?php 
                    echo esc_attr($p_image_alt);
                    ?>
" /></a>
                                    <a class="big-image-overlay" href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
"><i class="fa <?php 
                    echo esc_attr($apmag_overlay_icon);
                    ?>
"></i></a>
                                    <?php 
                    if ($show_icon == 'on') {
                        ?>
<span class="format_icon"><i class="fa <?php 
                        echo esc_attr($post_format_icon);
                        ?>
"></i></span><?php 
                    }
                    ?>
    
                                </div>                                    
                            <?php 
                }
                ?>
                                <div class="post-desc-wrapper">
                                    <h3 class="post-title"><a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a></h3>
                                    <div class="block-poston"><?php 
                do_action('accesspress_mag_home_posted_on');
                ?>
</div>
                                    <div class="ratings-wrapper"><?php 
                do_action('accesspress_mag_post_review');
                ?>
</div>
                                </div>
                                <?php 
                if ($p_counter > 1) {
                    ?>
<div class="post-content"><?php 
                    accesspress_mag_homepage_excerpt();
                    ?>
</div><?php 
                }
                ?>
                        </div>
            <?php 
                if ($p_counter == $p_total_posts) {
                    echo '</div>';
                }
            }
        }
        ?>
        </div>
<?php 
    }