/** * Compile the schema.org event data into an array */ public function get_data($post = null, $args = array()) { if (!$post instanceof WP_Post) { $post = Tribe__Main::post_id_helper($post); } $post = get_post($post); if (!$post instanceof WP_Post) { return array(); } $data = (object) array(); // We may need to prevent the context to be triggered if (!isset($args['context']) || false !== $args['context']) { $data->{'@context'} = 'http://schema.org'; } $data->{'@type'} = $this->type; $data->name = esc_js(get_the_title($post)); $data->description = esc_js(tribe_events_get_the_excerpt($post)); if (has_post_thumbnail($post)) { $data->image = wp_get_attachment_url(get_post_thumbnail_id($post)); } $data->url = esc_url_raw(get_permalink($post)); // Index by ID: this will allow filter code to identify the actual event being referred to // without injecting an additional property return array($post->ID => $data); }
/** * Helper function for getting Post Id. Accepts null or a post id. If no $post object exists, returns false to avoid a PHP NOTICE * * @param int $postId (optional) * * @return int post ID */ public static function postIdHelper($postId = null) { return Tribe__Main::post_id_helper($postId); }
$time_range_separator = tribe_get_option('timeRangeSeparator', ' - '); $start_datetime = tribe_get_start_date(); $start_date = tribe_get_start_date(null, false); $start_time = tribe_get_start_date(null, false, $time_format); $start_ts = tribe_get_start_date(null, false, Tribe__Date_Utils::DBDATEFORMAT); $end_datetime = tribe_get_end_date(); $end_date = tribe_get_display_end_date(null, false); $end_time = tribe_get_end_date(null, false, $time_format); $end_ts = tribe_get_end_date(null, false, Tribe__Date_Utils::DBDATEFORMAT); $time_formatted = null; if ($start_time == $end_time) { $time_formatted = esc_html($start_time); } else { $time_formatted = esc_html($start_time . $time_range_separator . $end_time); } $event_id = Tribe__Main::post_id_helper(); /** * Returns a formatted time for a single event * * @var string Formatted time string * @var int Event post id */ $time_formatted = apply_filters('tribe_events_single_event_time_formatted', $time_formatted, $event_id); /** * Returns the title of the "Time" section of event details * * @var string Time title * @var int Event post id */ $time_title = apply_filters('tribe_events_single_event_time_title', __('Time:', 'the-events-calendar'), $event_id); $cost = tribe_get_formatted_cost();
/** * Receives a float and formats it with a currency symbol * * @category Cost * @param string $cost pricing to format * @param null|int $post_id * @param null|string $currency_symbol * @param null|bool $reverse_position * * @return string */ function tribe_format_currency($cost, $post_id = null, $currency_symbol = null, $reverse_position = null) { $post_id = Tribe__Main::post_id_helper($post_id); $currency_symbol = apply_filters('tribe_currency_symbol', $currency_symbol, $post_id); // if no currency symbol was passed, or we're not looking at a particular event, // let's get the default currency symbol if (!$post_id || !$currency_symbol) { $currency_symbol = tribe_get_option('defaultCurrencySymbol', '$'); } $reverse_position = apply_filters('tribe_reverse_currency_position', $reverse_position, $post_id); if (!$reverse_position || !$post_id) { $reverse_position = tribe_get_option('reverseCurrencyPosition', false); } $cost = $reverse_position ? $cost . $currency_symbol : $currency_symbol . $cost; return $cost; }
/** * Filters the permalink generated for a recurring event "all" view to remove aberrations. * * @param string $event_url * @param int $event_id * * @return string */ public function filter_tribe_events_pro_get_all_link($event_url, $event_id) { $post = get_post(Tribe__Main::post_id_helper($event_id)); if (!tribe_is_event($post) || $post->post_parent != 0) { return $event_url; } $post_name = $post->post_name; // WPML might replace the post name with `<post_name>/<date>`; we undo that here. $event_url = preg_replace('~' . preg_quote($post_name) . '\\/\\d{4}-\\d{2}-\\d{2}~', $post_name, $event_url); return $event_url; }
/** * Remove an Post from the Indexed list * * @param int|WP_Post $post The Post Object or ID * * @return bool */ public function remove($post) { $id = Tribe__Main::post_id_helper($post); if (!$this->exists($id)) { return false; } unset(self::$posts[$id]); return true; }
/** * Gets venue details for use in some single-event templates. * * @param null $post_id * * @return array The venue name and venue address. */ function tribe_get_venue_details($post_id = null) { $post_id = Tribe__Main::post_id_helper($post_id); if (!$post_id) { return array(); } $venue_details = array(); if ($venue_link = tribe_get_venue_link($post_id)) { $venue_details['linked_name'] = $venue_link; } if ($venue_address = tribe_get_full_address($post_id)) { $venue_details['address'] = $venue_address; } return apply_filters('tribe_get_venue_details', $venue_details); }