private function convert_recurring_event_to_child_posts($event_id)
 {
     $start_dates = get_post_meta($event_id, '_EventStartDate', false);
     if (!is_array($start_dates)) {
         return;
     }
     sort($start_dates);
     $original = array_shift($start_dates);
     $start_dates = array_map('strtotime', $start_dates);
     foreach ($start_dates as $date) {
         if (!empty($date)) {
             set_time_limit(30);
             $instance = new Tribe__Events__Pro__Recurrence_Instance($event_id, $date);
             $instance->save();
             delete_post_meta($event_id, '_EventStartDate', date('Y-m-d H:i:s', $date));
         }
     }
     delete_post_meta($event_id, '_EventStartDate');
     update_post_meta($event_id, '_EventStartDate', $original);
 }
コード例 #2
0
 public static function save_pending_events($event_id)
 {
     if (wp_get_post_parent_id($event_id) != 0) {
         return;
     }
     $next_pending = get_post_meta($event_id, '_EventNextPendingRecurrence', true);
     if (empty($next_pending)) {
         return;
     }
     $latest_date = strtotime(self::$scheduler->get_latest_date());
     $recurrences = self::get_recurrence_for_event($event_id);
     foreach ($recurrences['rules'] as &$recurrence) {
         $recurrence->setMinDate(strtotime($next_pending));
         $recurrence->setMaxDate($latest_date);
         $dates = (array) $recurrence->getDates();
         if (empty($dates)) {
             return;
             // nothing to add right now. try again later
         }
         delete_post_meta($event_id, '_EventNextPendingRecurrence');
         if ($recurrence->constrainedByMaxDate() !== false) {
             update_post_meta($event_id, '_EventNextPendingRecurrence', date(Tribe__Events__Pro__Date_Series_Rules__Rules_Interface::DATE_FORMAT, $recurrence->constrainedByMaxDate()));
         }
         $excluded = array_map('strtotime', self::get_excluded_dates($event_id));
         foreach ($dates as $date_duration) {
             if (!in_array($date_duration, $excluded)) {
                 $instance = new Tribe__Events__Pro__Recurrence_Instance($event_id, $date_duration);
                 $instance->save();
             }
         }
     }
 }
コード例 #3
0
 protected function do_creations()
 {
     $exclusions = $this->current_queue->instances_to_exclude();
     $instances_to_create = $this->current_queue->instances_to_create();
     foreach ($instances_to_create as $key => $date_duration) {
         // Don't process more than the current batch size allows
         if ($this->batch_complete()) {
             break;
         }
         // Some instances may deliberately have been removed - let's remove
         // them from the list of events to create and move on
         if (in_array($date_duration, $exclusions)) {
             unset($instances_to_create[$key]);
             $this->processed++;
             continue;
         }
         $instance = new Tribe__Events__Pro__Recurrence_Instance($this->current_event_id, $date_duration);
         $instance->save();
         unset($instances_to_create[$key]);
         $this->processed++;
     }
     $this->current_queue->instances_to_create($instances_to_create);
 }