protected function do_creations() { $exclusions = $this->current_queue->instances_to_exclude(); $instances_to_create = array_values($this->current_queue->instances_to_create()); try { $sequence = new Tribe__Events__Pro__Recurrence__Sequence($instances_to_create, $this->current_event_id); } catch (Exception $e) { $exception = new Tribe__Exception($e); $exception->handle(); return; } foreach ($sequence->get_sorted_sequence() 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[$date_duration['original_index']]); $this->processed++; continue; } if (!$this->current_queue->have_ownership_of_job()) { return; } $sequence_number = isset($date_duration['sequence']) ? $date_duration['sequence'] : 1; $instance = new Tribe__Events__Pro__Recurrence__Instance($this->current_event_id, $date_duration, 0, $sequence_number); if (!$instance->already_exists()) { $instance->save(); } unset($instances_to_create[$date_duration['original_index']]); $this->processed++; } $this->current_queue->instances_to_create($instances_to_create); }