/** * The main widget output function (called by the class's widget() function). * * @param array $args * @param array $instance * @param string $template_name The template name. * @param string $subfolder The subfolder where the template can be found. * @param string $namespace The namespace for the widget template stuff. * @param string $pluginPath The pluginpath so we can locate the template stuff. */ public function widget_output($args, $instance, $template_name = 'widgets/list-widget') { global $wp_query, $tribe_ecp, $post; $instance = wp_parse_args($instance, array('limit' => self::$limit, 'title' => '')); /** * @var $after_title * @var $after_widget * @var $before_title * @var $before_widget * @var $limit * @var $no_upcoming_events * @var $title */ extract($args, EXTR_SKIP); extract($instance, EXTR_SKIP); // Temporarily unset the tribe bar params so they don't apply $hold_tribe_bar_args = array(); foreach ($_REQUEST as $key => $value) { if ($value && strpos($key, 'tribe-bar-') === 0) { $hold_tribe_bar_args[$key] = $value; unset($_REQUEST[$key]); } } $title = apply_filters('widget_title', $title); self::$limit = absint($limit); if (!function_exists('tribe_get_events')) { return; } self::$posts = tribe_get_events(apply_filters('tribe_events_list_widget_query_args', array('eventDisplay' => 'list', 'posts_per_page' => self::$limit, 'tribe_render_context' => 'widget'))); // If no posts, and the don't show if no posts checked, let's bail if (empty(self::$posts) && $no_upcoming_events) { return; } echo $before_widget; do_action('tribe_events_before_list_widget'); if ($title) { do_action('tribe_events_list_widget_before_the_title'); echo $before_title . $title . $after_title; do_action('tribe_events_list_widget_after_the_title'); } // Include template file include Tribe__Events__Templates::getTemplateHierarchy($template_name); do_action('tribe_events_after_list_widget'); echo $after_widget; wp_reset_query(); // Reinstate the tribe bar params if (!empty($hold_tribe_bar_args)) { foreach ($hold_tribe_bar_args as $key => $value) { $_REQUEST[$key] = $value; } } }
public function update($new_instance, $old_instance) { $instance = parent::update($new_instance, $old_instance); $new_instance = $this->default_instance_args($new_instance, true); $instance['venue'] = $new_instance['venue']; $instance['country'] = $new_instance['country']; $instance['address'] = $new_instance['address']; $instance['city'] = $new_instance['city']; $instance['region'] = $new_instance['region']; $instance['zip'] = $new_instance['zip']; $instance['phone'] = $new_instance['phone']; $instance['cost'] = $new_instance['cost']; $instance['organizer'] = $new_instance['organizer']; $instance['operand'] = strip_tags($new_instance['operand']); $instance['filters'] = maybe_unserialize($new_instance['filters']); // @todo remove after 3.7 (added for continuity when users transition from 3.5.x or earlier to this release) if (isset($old_instance['category'])) { $this->include_cat_id($instance['filters'], $old_instance['category']); unset($instance['category']); } return $instance; }
/** * Allows widgets extending this one to pass through their own unique name, ID base etc. * * @param string $id_base * @param string $name * @param array $widget_options * @param array $control_options */ public function __construct($id_base = 'tg-tribe-events-list-widget', $name = 'TG: Events Slider', $widget_options = array('classname' => 'tg-tribe-events-list-widget', 'description' => 'A Slider Widget that displays events from The Event Calendar Plugin'), $control_options = array('id_base' => 'tg-tribe-events-list-widget')) { parent::__construct($id_base, $name, $widget_options, $control_options); }
/** * The main widget output function (called by the class's widget() function). * * @param array $args * @param array $instance * @param string $template_name The template name. * @param string $subfolder The subfolder where the template can be found. * @param string $namespace The namespace for the widget template stuff. * @param string $pluginPath The pluginpath so we can locate the template stuff. */ public function widget_output($args, $instance, $template_name = 'widgets/list-widget') { global $wp_query, $tribe_ecp, $post; $instance = wp_parse_args($instance, array('limit' => self::$limit, 'title' => '')); /** * @var $after_title * @var $after_widget * @var $before_title * @var $before_widget * @var $limit * @var $no_upcoming_events * @var $title */ extract($args, EXTR_SKIP); extract($instance, EXTR_SKIP); // Temporarily unset the tribe bar params so they don't apply $hold_tribe_bar_args = array(); foreach ($_REQUEST as $key => $value) { if ($value && strpos($key, 'tribe-bar-') === 0) { $hold_tribe_bar_args[$key] = $value; unset($_REQUEST[$key]); } } $title = apply_filters('widget_title', $title); self::$limit = absint($limit); if (!function_exists('tribe_get_events')) { return; } self::$posts = tribe_get_events(apply_filters('tribe_events_list_widget_query_args', array('eventDisplay' => 'list', 'posts_per_page' => self::$limit, 'tribe_render_context' => 'widget'))); // If no posts, and the don't show if no posts checked, let's bail if (empty(self::$posts) && $no_upcoming_events) { return; } echo $before_widget; do_action('tribe_events_before_list_widget'); if ($title) { do_action('tribe_events_list_widget_before_the_title'); echo $before_title . $title . $after_title; do_action('tribe_events_list_widget_after_the_title'); } // Include template file include Tribe__Events__Templates::getTemplateHierarchy($template_name); do_action('tribe_events_after_list_widget'); echo $after_widget; wp_reset_query(); $jsonld_enable = isset($jsonld_enable) ? $jsonld_enable : true; /** * Filters whether JSON LD information should be printed to the page or not for this widget type. * * @param bool $jsonld_enable Whether JSON-LD should be printed to the page or not; default `true`. */ $jsonld_enable = apply_filters('tribe_events_' . $this->id_base . '_jsonld_enabled', $jsonld_enable); /** * Filters whether JSON LD information should be printed to the page for any widget type. * * @param bool $jsonld_enable Whether JSON-LD should be printed to the page or not; default `true`. */ $jsonld_enable = apply_filters('tribe_events_widget_jsonld_enabled', $jsonld_enable); if ($jsonld_enable) { Tribe__Events__JSON_LD__Event::instance()->markup(self::$posts); } // Reinstate the tribe bar params if (!empty($hold_tribe_bar_args)) { foreach ($hold_tribe_bar_args as $key => $value) { $_REQUEST[$key] = $value; } } }