public function post_editor()
 {
     global $post;
     $is_an_event = class_exists('Tribe__Events__Main') && Tribe__Events__Main::POSTTYPE === $post->post_type;
     $is_a_parent = 0 == $post->post_parent;
     if (!$is_an_event || !$is_a_parent) {
         return false;
     }
     $this->event_id = $post->ID;
     $this->queue = $this->queue ? $this->queue : new Tribe__Events__Pro__Recurrence__Queue($this->event_id);
     if ($this->queue->is_empty()) {
         return false;
     }
     return $this->init_update_loop();
 }
Ejemplo n.º 2
0
 public function ajax()
 {
     $event_id = (int) $_POST['event'];
     // Nonce check
     if (!wp_verify_nonce($_POST['check'], 'generate_recurring_instances_' . $event_id . get_current_user_id())) {
         exit(json_encode(array('html' => __('Unable to continue processing recurring event data. Please reload this page to continue/try again.', 'tribe-events-pro'), 'progress' => false, 'continue' => false, 'complete' => false)));
     }
     // Load the queue
     $queue = new Tribe__Events__Pro__Recurrence__Queue($event_id);
     if (!$queue->is_empty()) {
         Tribe__Events__Pro__Main::instance()->queue_processor->process_batch($event_id);
     }
     $done = $queue->is_empty();
     $percentage = $queue->progress_percentage();
     exit(json_encode(array('html' => false, 'progress' => $percentage, 'progressText' => sprintf(__('%d%% complete', 'tribe-events-pro'), $percentage), 'continue' => !$done, 'complete' => $done)));
 }
Ejemplo n.º 3
0
 /**
  * Returns true if a non-empty queue exists for the current event, else returns false.
  *
  * @return bool
  */
 protected function get_current_queue()
 {
     try {
         $this->current_queue = new Tribe__Events__Pro__Recurrence__Queue($this->current_event_id);
     } catch (Exception $e) {
         do_action('log', sprintf(__('Could not process queue for event %1$d: %2$s', 'tribe-events-pro'), $this->current_event_id, $e->getMessage()));
         return false;
     }
     return $this->current_queue->is_empty() ? false : true;
 }