Exemple #1
0
 public function __construct($attributes)
 {
     $this->arguments = shortcode_atts($this->default_args, $attributes);
     $this->taxonomy_filters();
     Tribe__Events__Pro__Widgets::enqueue_calendar_widget_styles();
     ob_start();
     the_widget('Tribe__Events__Pro__Advanced_List_Widget', $this->arguments, $this->arguments);
     $this->output = ob_get_clean();
 }
 public function taxonomy_filters($query)
 {
     if (empty($this->instance)) {
         return $query;
     }
     $filters = isset($this->instance['raw_filters']) ? $this->instance['raw_filters'] : json_decode($this->instance['filters']);
     $tax_query = Tribe__Events__Pro__Widgets::form_tax_query($filters, $this->instance['operand']);
     if (isset($query['tax_query'])) {
         $query['tax_query'] = array_merge($query['tax_query'], $tax_query);
     } else {
         $query['tax_query'] = $tax_query;
     }
     return $query;
 }
 /**
  * @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();
 }
 public function widget($args, $instance)
 {
     $ecp = Tribe__Events__Pro__Main::instance();
     $tooltip_status = $ecp->recurring_info_tooltip_status();
     $ecp->disable_recurring_info_tooltip();
     add_filter('tribe_events_list_show_ical_link', '__return_false');
     echo $args['before_widget'];
     $defaults = array('title' => __('Events Calendar', 'tribe-events-calendar-pro'), 'count' => 5, 'filters' => null, 'operand' => 'OR');
     $instance = wp_parse_args((array) $instance, $defaults);
     $filters = isset($instance['raw_filters']) ? $instance['raw_filters'] : json_decode($instance['filters']);
     $tax_query = Tribe__Events__Pro__Widgets::form_tax_query($filters, $instance['operand']);
     do_action('tribe_events_mini_cal_before_the_title');
     echo $instance['title'] ? $args['before_title'] . $instance['title'] . $args['after_title'] : '';
     do_action('tribe_events_mini_cal_after_the_title');
     $instance['tax_query'] = $tax_query;
     Tribe__Events__Pro__Mini_Calendar::instance()->do_calendar($instance);
     echo $args['after_widget'];
     remove_filter('tribe_events_list_show_ical_link', '__return_false');
     if ($tooltip_status) {
         $ecp->enable_recurring_info_tooltip();
     }
 }
 /**
  * @todo revise so that our stylesheet is enqueued in time for the link to be included within the head element
  */
 protected function styles_and_scripts()
 {
     wp_enqueue_script('tribe-mini-calendar', tribe_events_pro_resource_url('widget-calendar.js'), array('jquery'), apply_filters('tribe_events_pro_js_version', Tribe__Events__Pro__Main::VERSION));
     Tribe__Events__Pro__Widgets::enqueue_calendar_widget_styles();
     // Tribe Events CSS filename
     $event_file = 'widget-calendar.css';
     $stylesheet_option = tribe_get_option('stylesheetOption', 'tribe');
     // What Option was selected
     switch ($stylesheet_option) {
         case 'skeleton':
             $event_file_option = 'widget-calendar-' . $stylesheet_option . '.css';
             break;
         case 'full':
             $event_file_option = 'widget-calendar-' . $stylesheet_option . '.css';
             break;
         default:
             $event_file_option = 'widget-calendar-theme.css';
             break;
     }
     $styleUrl = tribe_events_pro_resource_url($event_file_option);
     $styleUrl = apply_filters('tribe_events_pro_widget_calendar_stylesheet_url', $styleUrl);
     $styleOverrideUrl = Tribe__Events__Templates::locate_stylesheet('tribe-events/pro/' . $event_file, $styleUrl);
     // Load up stylesheet from theme or plugin
     if ($styleUrl && $stylesheet_option == 'tribe') {
         wp_enqueue_style('widget-calendar-pro-style', tribe_events_pro_resource_url('widget-calendar-full.css'), array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION));
         wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '-widget-calendar-pro-style', $styleUrl, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION));
     } else {
         wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '-widget-calendar-pro-style', $styleUrl, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION));
     }
     if ($styleOverrideUrl) {
         wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '--widget-calendar-pro-override-style', $styleOverrideUrl, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION));
     }
     $widget_data = array('ajaxurl' => admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http'));
     wp_localize_script('tribe-mini-calendar', 'TribeMiniCalendar', $widget_data);
 }