/** * 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; } } }
/** * 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; } } }