public function schedule_future_recurring_events() { /** @var wpdb $wpdb */ global $wpdb; $post_ids = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT m.post_id FROM {$wpdb->postmeta} m INNER JOIN {$wpdb->posts} p ON m.post_id=p.ID WHERE m.meta_key='_EventNextPendingRecurrence' AND m.meta_value < %s AND p.post_parent = 0", $this->latest_date)); foreach ($post_ids as $post_id) { TribeEventsRecurrenceMeta::save_pending_events($post_id); } }
/** * Responsible for displaying a user's custom recurrence pattern description. * * @deprecated since 3.6 * @param string $meta_id The meta group this is in. * @return string The custom description. * @author Timothy Wood * @since 3.0 */ public static function custom_recurrence_description($meta_id) { global $_tribe_meta_factory; $post_id = get_the_ID(); $recurrence_meta = TribeEventsRecurrenceMeta::getRecurrenceMeta($post_id); $recurrence_description = !empty($recurrence_meta['recCustomRecurrenceDescription']) ? $recurrence_meta['recCustomRecurrenceDescription'] : tribe_get_recurrence_text($post_id); $html = tribe_is_recurring_event($post_id) ? Tribe_Meta_Factory::template($_tribe_meta_factory->meta[$meta_id]['label'], $recurrence_description, $meta_id) : ''; return apply_filters('tribe_event_pro_meta_custom_recurrence_description', $html); }
function tribe_get_recurrence_text($postId = null) { $postId = TribeEvents::postIdHelper($postId); $tribe_ecp = TribeEvents::instance(); return apply_filters('tribe_get_recurrence_text', TribeEventsRecurrenceMeta::recurrenceToTextByPost($postId)); }
/** * The class init function. * * @return void * @since 2.0 */ public function init() { // if pro rewrite rules have not been generated yet, flush them. (This can happen on reactivations.) if (is_array(get_option('rewrite_rules')) && !array_key_exists(trailingslashit(TribeEvents::instance()->rewriteSlug) . $this->weekSlug . '/?$', get_option('rewrite_rules'))) { TribeEvents::flushRewriteRules(); } TribeEventsMiniCalendar::instance(); TribeEventsCustomMeta::init(); TribeEventsRecurrenceMeta::init(); TribeEventsGeoLoc::instance(); $this->displayMetaboxCustomFields(); }
/** * The class init function. * * @return void * @since 2.0 */ public function init() { TribeEventsMiniCalendar::instance(); TribeEventsCustomMeta::init(); TribeEventsRecurrenceMeta::init(); TribeEventsGeoLoc::instance(); $this->displayMetaboxCustomFields(); }
/** * Add custom query modification to the pre_get_posts hook as necessary for PRO. * * @param WP_Query $query The current query object. * @return WP_Query The modified query object. * @author Timothy Wood * @since 3.0 */ public function pre_get_posts($query) { if ($query->is_single() && $query->get('eventDate')) { $this->set_post_id_for_recurring_event_query($query); } if (!empty($query->tribe_is_event_pro_query)) { switch ($query->query_vars['eventDisplay']) { case 'week': $week = tribe_get_first_week_day($query->get('eventDate')); $query->set('eventDate', $week); $query->set('start_date', $week); $query->set('end_date', tribe_get_last_week_day($week)); $query->set('posts_per_page', -1); // show ALL week posts $query->set('hide_upcoming', false); break; case 'photo': $query->set('hide_upcoming', false); break; case 'all': $slug = $query->get('name'); if (empty($slug)) { break; // we shouldn't be here } unset($query->query_vars['name']); unset($query->query_vars['tribe_events']); $all_ids = TribeEventsRecurrenceMeta::get_events_by_slug($slug); if (empty($all_ids)) { $query->set('p', -1); } else { $query->set('post__in', $all_ids); $query->set('post_status', 'publish'); } break; } apply_filters('tribe_events_pro_pre_get_posts', $query); } }
/** * Convert the event recurrence meta into a human readable string * @param array $postId The recurring event * @return The human readable string */ public static function recurrenceToText($postId = null) { $text = ""; $custom_text = ""; $occurrence_text = ""; if ($postId == null) { global $post; $postId = $post->ID; } extract(TribeEventsRecurrenceMeta::getRecurrenceMeta($postId)); if ($recType == "Every Day") { $text = __("Every day", 'tribe-events-calendar-pro'); $occurrence_text = sprintf(_n(" for %d day", " for %d days", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); $custom_text = ""; } else { if ($recType == "Every Week") { $text = __("Every week", 'tribe-events-calendar-pro'); $occurrence_text = sprintf(_n(" for %d week", " for %d weeks", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); } else { if ($recType == "Every Month") { $text = __("Every month", 'tribe-events-calendar-pro'); $occurrence_text = sprintf(_n(" for %d month", " for %d months", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); } else { if ($recType == "Every Year") { $text = __("Every year", 'tribe-events-calendar-pro'); $occurrence_text = sprintf(_n(" for %d year", " for %d years", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); } else { if ($recType == "Custom") { if ($recCustomType == "Daily") { $text = $recCustomInterval == 1 ? __("Every day", 'tribe-events-calendar-pro') : sprintf(__("Every %d days", 'tribe-events-calendar-pro'), $recCustomInterval); $occurrence_text = sprintf(_n(", recurring %d time", ", recurring %d times", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); } else { if ($recCustomType == "Weekly") { $text = $recCustomInterval == 1 ? __("Every week", 'tribe-events-calendar-pro') : sprintf(__("Every %d weeks", 'tribe-events-calendar-pro'), $recCustomInterval); $custom_text = sprintf(__(" on %s", 'tribe-events-calendar-pro'), self::daysToText($recCustomWeekDay)); $occurrence_text = sprintf(_n(", recurring %d time", ", recurring %d times", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); } else { if ($recCustomType == "Monthly") { $text = $recCustomInterval == 1 ? __("Every month", 'tribe-events-calendar-pro') : sprintf(__("Every %d months", 'tribe-events-calendar-pro'), $recCustomInterval); $number_display = is_numeric($recCustomMonthNumber) ? TribeDateUtils::numberToOrdinal($recCustomMonthNumber) : strtolower($recCustomMonthNumber); $custom_text = sprintf(__(" on the %s %s", 'tribe-events-calendar-pro'), $number_display, is_numeric($recCustomMonthNumber) ? __("day", 'tribe-events-calendar-pro') : self::daysToText($recCustomMonthDay)); $occurrence_text = sprintf(_n(", recurring %d time", ", recurring %d times", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); } else { if ($recCustomType == "Yearly") { $text = $recCustomInterval == 1 ? __("Every year", 'tribe-events-calendar-pro') : sprintf(__("Every %d years", 'tribe-events-calendar-pro'), $recCustomInterval); $customYearNumber = $recCustomYearMonthNumber != -1 ? TribeDateUtils::numberToOrdinal($recCustomYearMonthNumber) : __("last", 'tribe-events-calendar-pro'); $day = $recCustomYearFilter ? $customYearNumber : TribeDateUtils::numberToOrdinal(date('j', strtotime(TribeEvents::getRealStartDate($postId)))); $of_week = $recCustomYearFilter ? self::daysToText($recCustomYearMonthDay) : ""; $months = self::monthsToText($recCustomYearMonth); $custom_text = sprintf(__(" on the %s %s of %s", 'tribe-events-calendar-pro'), $day, $of_week, $months); $occurrence_text = sprintf(_n(", recurring %d time", ", recurring %d times", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); } } } } } } } } } // end text if ($recEndType == "On") { $endText = ' ' . sprintf(__(" until %s", 'tribe-events-calendar-pro'), date_i18n(get_option('date_format'), strtotime($recEnd))); } else { $endText = $occurrence_text; } return sprintf(__('%s%s%s', 'tribe-events-calendar-pro'), $text, $custom_text, $endText); }
/** * @return void */ public static function reset_scheduler() { require_once dirname(__FILE__) . '/tribe-recurrence-scheduler.php'; if (!empty(self::$scheduler)) { self::$scheduler->remove_hooks(); } self::$scheduler = new TribeEventsRecurrenceScheduler(tribe_get_option('recurrenceMaxMonthsBefore', 24), tribe_get_option('recurrenceMaxMonthsAfter', 24)); self::$scheduler->add_hooks(); }
* Override this template in your own theme by creating a file at * [your-theme]/tribe-events/community/modules/recurrence.php * * @package TribeCommunityEvents * @since 2.1 * @author Modern Tribe Inc. * */ if (!defined('ABSPATH')) { die('-1'); } global $post; $post_id = isset($post->ID) ? $post->ID : null; if ($post_id) { // convert array to variables that can be used in the view extract(TribeEventsRecurrenceMeta::getRecurrenceMeta($post_id)); } else { // create variables that can be used in the view $recType = 'None'; $recEndType = ''; $recEnd = ''; $recEndCount = ''; $recCustomType = ''; $recCustomInterval = ''; $recCustomTypeText = ''; $recOccurrenceCountText = ''; $recCustomWeekDay = array(); //array $recCustomMonthNumber = ''; $recCustomMonthDay = 1; $recCustomYearFilter = '';
/** * Checks the recurrence amount and adds a filter to display an errir if it is not correct. * * @since 3.0 * @author Paul Hughes * * @param int $post_id The post id. * @return void */ public function checkRecurrenceAmount($post_id) { $is_success = true; if (get_post_type($post_id) == TribeEvents::POSTTYPE && get_post_meta($post_id, '_EventRecurrence')) { extract(TribeEventsRecurrenceMeta::getRecurrenceMeta($post_id)); $rules = TribeEventsRecurrenceMeta::getSeriesRules($post_id); // use the recurrence start meta if necessary because we can't guarantee which order the start date will come back in $recStart = strtotime(get_post_meta($post_id, '_EventStartDate', true)); $eventEnd = strtotime(get_post_meta($post_id, '_EventEndDate', true)); $duration = $eventEnd - $recStart; $recEnd = $recEndType == "On" ? strtotime(TribeDateUtils::endOfDay($recEnd)) : $recEndCount - 1; // subtract one because event is first occurrence $old_start_dates = get_post_meta($post_id, '_EventStartDate'); if ($recType != "None") { $recurrence = new TribeRecurrence($recStart, $recEnd, $rules, $recEndType == "After", get_post($post_id)); $dates = (array) $recurrence->getDates(true, $old_start_dates); $max_recurrences = apply_filters('tribe_events_max_recurrences', 199); if (count($dates) > $max_recurrences) { add_filter('redirect_post_location', array(__CLASS__, 'tooManyRecurrencesError')); $is_success = false; } } } return $is_success; }
public function init() { TribeEventsCustomMeta::init(); TribeEventsRecurrenceMeta::init(); $this->displayMetaboxCustomFields(); }