/**
  * @param $args
  * @param $instance
  */
 public function widget($args, $instance)
 {
     // Initialize defaults. When the widget is added via the Customizer, the widget is rendered
     // prior to being saved and the instance is empty. This ensures that $instance holds the
     // defaults so the behavior is expected and doesn't throw notices.
     $instance = $this->instance_defaults($instance);
     //Disable Tooltips
     $ecp = Tribe__Events__Pro__Main::instance();
     $tooltip_status = $ecp->recurring_info_tooltip_status();
     $ecp->disable_recurring_info_tooltip();
     //Check If a Taxonomy is set
     if (!empty($instance['raw_filters']) || isset($instance['filters'])) {
         $filters = isset($instance['raw_filters']) ? $instance['raw_filters'] : json_decode($instance['filters']);
     } else {
         $filters = null;
     }
     //Prepare Categories for Query
     $tax_query = Tribe__Events__Pro__Widgets::form_tax_query($filters, $instance['operand']);
     //Use Date to find start of week if provided in shortcode
     $start_date = isset($instance['start_date']) ? $instance['start_date'] : null;
     //Use Date to find start of week if provided in shortcode
     $week_offset = isset($instance['week_offset']) ? $instance['week_offset'] : null;
     //Array of Variables to use for Data Attributes and
     $this_week_query_vars['start_date'] = tribe_get_this_week_first_week_day($start_date, $week_offset);
     $this_week_query_vars['end_date'] = tribe_get_this_week_last_week_day($this_week_query_vars['start_date']);
     $this_week_query_vars['count'] = $instance['count'];
     $this_week_query_vars['layout'] = $instance['layout'];
     $this_week_query_vars['tax_query'] = $tax_query;
     $this_week_query_vars['hide_weekends'] = isset($instance['hide_weekends']) ? $instance['hide_weekends'] : false;
     //Setup Variables for Template
     $this_week_template_vars = Tribe__Events__Pro__This_Week::this_week_template_vars($this_week_query_vars);
     //Setup Attributes for Ajax
     $this_week_data_attrs = Tribe__Events__Pro__This_Week::this_week_data_attr($this_week_query_vars);
     //Setups This Week Object for Each Day
     $week_days = Tribe__Events__Pro__This_Week::this_week_query($this_week_query_vars);
     echo $args['before_widget'];
     do_action('tribe_events_this_week_widget_before_the_title');
     echo !empty($instance['title']) ? $args['before_title'] . $instance['title'] . $args['after_title'] : '';
     do_action('tribe_events_this_week_widget_after_the_title');
     include Tribe__Events__Templates::getTemplateHierarchy('pro/widgets/this-week-widget.php');
     echo $args['after_widget'];
     // Re-enable recurring event info
     if ($tooltip_status) {
         $ecp->enable_recurring_info_tooltip();
     }
     wp_reset_postdata();
 }
/**
 * This Week Widget - Get the last day of the week from a provided date
 *
 * @param string|int $date a given date of the week
 *
 * @return DateTime
 */
function tribe_get_this_week_last_week_day($date)
{
    return date(Tribe__Date_Utils::DBDATEFORMAT, strtotime(tribe_get_this_week_first_week_day($date) . ' +7 days'));
}