<?php

Class Reseller_Store_My_Recent_Posts_Widget extends WP_Widget_Recent_Posts {
  function widget($reseller_store_args, $reseller_store_instance) {
      if ( ! isset( $reseller_store_args['widget_id'] ) ) {
      $reseller_store_args['widget_id'] = $this->id;
    }
    $reseller_store_reseller_store_title = ( ! empty( $reseller_store_instance['title'] ) ) ? $reseller_store_instance['title'] : __( 'Recent Posts', 'reseller-store' );
    /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    $reseller_store_reseller_store_title = apply_filters( 'widget_title', $reseller_store_reseller_store_title, $reseller_store_instance, $this->id_base );
    $reseller_store_number = ( ! empty( $reseller_store_instance['number'] ) ) ? absint( $reseller_store_instance['number'] ) : 5;
    if ( ! $reseller_store_number )
        $reseller_store_number = 5;
    $reseller_store_show_date = isset( $reseller_store_instance['show_date'] ) ? $reseller_store_instance['show_date'] : false;
    /**
     * Filter the arguments for the Recent Posts widget.
     *
     * @since 3.4.0
     *
     * @see WP_Query::get_posts()
     *
     * @param array $reseller_store_args An array of arguments used to retrieve the recent posts.
     */
    $reseller_store_r = new WP_Query( apply_filters( 'widget_posts_args', array(
        'posts_per_page'      => $reseller_store_number,
        'no_found_rows'       => true,
        'post_status'         => 'publish',
        'ignore_sticky_posts' => true
    ) ) );
    if ($reseller_store_r->have_posts()) :
    ?>
    <?php echo $reseller_store_args['before_widget']; ?>
    <?php if ( $reseller_store_reseller_store_title ) {
        echo $reseller_store_args['before_title'] . esc_html($reseller_store_reseller_store_title) . $reseller_store_args['after_title'];
    } ?>
    <ul>
      <?php while ( $reseller_store_r->have_posts() ) : $reseller_store_r->the_post(); ?>
      <li>
        <div class="recent-post-box">
          <div class="media post-thumb">
            <?php if(has_post_thumbnail()) { the_post_thumbnail(); } ?>
            <div class="media-body post-content">
              <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
              <div class="d-flex date-comment">
               <?php if ( $reseller_store_show_date ) : ?>
                <p class="post-date"><?php the_date(); ?></p>
               <?php endif; ?>
               <div class="date-comment1"><?php comments_number( __('0 Comment', 'reseller-store'), __('0 Comments', 'reseller-store'), __('% Comments', 'reseller-store') ); ?></div>
              </div>
            </div>
          </div>
        </div>
      </li>
      <?php endwhile;
      wp_reset_postdata(); ?>
    </ul>

    <?php echo $reseller_store_args['after_widget'];

    endif;
  }
}
function reseller_store_my_recent_widget_registration() {
  unregister_widget('WP_Widget_Recent_Posts');
  register_widget('Reseller_Store_My_Recent_Posts_Widget');
}
add_action('widgets_init', 'reseller_store_my_recent_widget_registration');
