public function hooks() { parent::hooks(); // Print JSON-LD markup on the `wp_head` add_action('wp_head', array(Tribe__Events__JSON_LD__Event::instance(), 'markup')); }
/** * puts together the actual html/json javascript block for output * @return string */ public function script_block() { return Tribe__Events__JSON_LD__Event::instance()->get_markup(); }
protected function print_jsonld_markup_for($week_days) { $days = wp_list_pluck($week_days, 'this_week_events'); $events = array(); foreach ($days as $day) { $events = array_merge($events, $day); } if (empty($events)) { return; } Tribe__Events__JSON_LD__Event::instance()->markup($events); }
*/ $month_widget_args = apply_filters('tribe_events_pro_min_calendar_widget_query_args', $month_widget_args); $event_ids = tribe_show_month($month_widget_args, 'pro/widgets/mini-calendar/grid'); $jsonld_enable = isset($args['jsonld_enable']) ? $args['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_' . $args['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 && !empty($event_ids)) { // print JSON-LD data about events contained in the mini calendar widget Tribe__Events__JSON_LD__Event::instance()->markup($event_ids); } ?> <!-- List --> <?php if (0 < $args['count']) { tribe_get_template_part('pro/widgets/mini-calendar/list', null, array('venue' => true)); } ?> </div>
/** * When dealing with a place that has multiple events, we need to pass all the events as the first param * to allow the class to echo the correct JSON-LD script * * @return void */ public function json_ld_markup() { $events = wp_list_pluck($this->events_in_month, 'ID'); Tribe__Events__JSON_LD__Event::instance()->markup($events); }
/** * 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; } } }
protected function print_jsonld_markup_for($event) { $event = get_post($event); if (empty($event)) { return; } Tribe__Events__JSON_LD__Event::instance()->markup($event); }
protected function print_jsonld_markup_for($events) { $events = $events->posts; if (empty($events)) { return; } Tribe__Events__JSON_LD__Event::instance()->markup($events); }