public function display_created_recurrences_notice() { $pending = get_post_meta(get_the_ID(), '_EventNextPendingRecurrence', true); if (!$pending) { return; } $start_dates = tribe_get_recurrence_start_dates(get_the_ID()); $count = count($start_dates); $last = end($start_dates); $pending_message = __('%d instances of this event have been created through %s. <a href="%s">Learn more.</a>', 'tribe-events-calendar-pro'); $pending_message = sprintf($pending_message, $count, date_i18n(tribe_get_date_format(true), strtotime($last)), 'http://m.tri.be/lq'); $this->notice->render($pending_message, 'updated'); }
function tribe_is_recurring_event($postId = null) { if (is_object($postId)) { $postId = $postId->ID; } $postId = $postId ? $postId : get_the_ID(); if (get_post_type($postId) != TribeEvents::POSTTYPE) { return false; } $instances = tribe_get_recurrence_start_dates($postId); $recurring = count($instances) > 1; if (!$recurring && get_post_meta($postId, '_EventNextPendingRecurrence', true)) { $recurring = true; } return apply_filters('tribe_is_recurring_event', $recurring, $postId); }
/** * An event can have one or more start dates. This gives * the earliest of those. * * @param int $post_id * * @return string The date string for the earliest occurrence of the event */ public static function get_series_start_date($post_id) { if (function_exists('tribe_get_recurrence_start_dates')) { $start_dates = tribe_get_recurrence_start_dates($post_id); return reset($start_dates); } else { return get_post_meta($post_id, '_EventStartDate', true); } }
/** * Placed here for compatibility reasons. This can be removed * when Events Calendar 3.2 or greater is released * * @todo Remove this method * * @param int $post_id * * @return string * @see Tribe__Events__Main::get_series_start_date() */ private static function get_series_start_date($post_id) { if (method_exists('Tribe__Events__Main', 'get_series_start_date')) { return Tribe__Events__Main::get_series_start_date($post_id); } $start_dates = tribe_get_recurrence_start_dates($post_id); return reset($start_dates); }
/** * @param int $master_parent_event_id */ private function get_master_series_ids_and_start_dates($master_parent_event_id) { if (empty($this->master_series_ids_and_start_dates_cache[$master_parent_event_id])) { $master_series_recurrence_dates = implode("','", tribe_get_recurrence_start_dates($master_parent_event_id)); /** @var \wpdb $wpdb */ global $wpdb; $wpml_translations_table = $wpdb->prefix . 'icl_translations'; $post_type = Tribe__Events__Main::POSTTYPE; $results = $wpdb->get_results("SELECT p.ID AS 'event_id', pm.meta_value AS 'start_date', wpml.trid as 'trid'\n\t\t\t\t\tFROM {$wpdb->posts} p\n\t\t\t\t\tLEFT JOIN {$wpdb->postmeta} pm \n\t\t\t\t\tON p.ID = pm.post_id \n\t\t\t\t\tLEFT JOIN {$wpml_translations_table} wpml \n\t\t\t\t\tON wpml.element_id = p.ID\n\t\t\t\t\tWHERE pm.meta_key = '_EventStartDate' \n\t\t\t\t\tAND pm.meta_value IN ('{$master_series_recurrence_dates}')\n\t\t\t\t\tAND wpml.element_type = 'post_{$post_type}'\n\t\t\t\t\tAND wpml.element_id IN (SELECT ID FROM {$wpdb->posts} WHERE ID = {$master_parent_event_id} OR post_parent = {$master_parent_event_id}) \n\t\t\t\t\tAND wpml.trid IS NOT NULL\n\t\t\t\t\tAND p.post_type = '{$post_type}'"); $this->master_series_ids_and_start_dates_cache[$master_parent_event_id] = !empty($results) ? array_combine(wp_list_pluck($results, 'start_date'), $results) : array(); } return $this->master_series_ids_and_start_dates_cache[$master_parent_event_id]; }
public static function display_post_editor_recurring_notice() { $message = __('You are currently editing all events in a recurring series.', 'tribe-events-calendar-pro'); printf('<div class="updated"><p>%s</p></div>', $message); $pending = get_post_meta(get_the_ID(), '_EventNextPendingRecurrence', true); if ($pending) { $start_dates = tribe_get_recurrence_start_dates(get_the_ID()); $count = count($start_dates); $last = end($start_dates); $pending_message = __('%d instances of this event have been created through %s. <a href="%s">Learn more.</a>', 'tribe-events-calendar-pro'); $pending_message = sprintf($pending_message, $count, date_i18n(tribe_get_date_format(true), strtotime($last)), 'http://m.tri.be/lq'); printf('<div class="updated"><p>%s</p></div>', $pending_message); } }
function tribe_is_recurring_event($postId = null) { $instances = tribe_get_recurrence_start_dates($postId); $recurring = count($instances) > 1; return apply_filters('tribe_is_recurring_event', $recurring, $postId); }