public function render_update_message() { if (!Tribe__Events__Aggregator__Page::instance()->is_screen()) { return; } $processor = Tribe__Events__Aggregator::instance()->queue_processor; if (!($this->record_id = $processor->next_waiting_record(true))) { return false; } $this->queue = $this->queue ? $this->queue : new Tribe__Events__Aggregator__Record__Queue($this->record_id); if ($this->queue->is_empty()) { return false; } $this->update_loop_vars(); ob_start(); $percent = $this->sanitize_progress($this->queue->progress_percentage()); $spinner = '<img src="' . get_admin_url(null, '/images/spinner.gif') . '">'; ?> <div class="tribe-message"> <p> <?php esc_html_e('Your import is currently in progress. Don\'t worry, you can safely navigate away–the import will continue in the background.', 'the-events-calendar'); ?> </p> </div> <ul class="tracker"> <li class="tracked-item track-created"><strong><?php esc_html_e('Created:', 'the-events-calendar'); ?> </strong> <span class="value"></span></li> <li class="tracked-item track-updated"><strong><?php esc_html_e('Updated:', 'the-events-calendar'); ?> </strong> <span class="value"></span></li> <li class="tracked-item track-skipped"><strong><?php esc_html_e('Skipped:', 'the-events-calendar'); ?> </strong> <span class="value"></span></li> </ul> <div class="progress-container"> <div class="progress" title="<?php echo esc_html(sprintf(__('%d%% complete', 'the-events-calendar'), $percent)); ?> "> <div class="bar"></div> </div> <img src="<?php echo esc_url(get_admin_url(null, '/images/spinner.gif')); ?> "> </div> <?php $html = ob_get_clean(); return Tribe__Admin__Notices::instance()->render('aggregator-update-msg', $html); }
/** * Returns true if a non-empty queue exists for the current record, else returns false. * * @return bool */ protected function get_current_queue() { try { $this->current_queue = new Tribe__Events__Aggregator__Record__Queue($this->current_record_id); } catch (Exception $e) { do_action('log', sprintf(__('Could not process queue for Import Record %1$d: %2$s', 'the-events-calendar'), $this->current_record_id, $e->getMessage())); return false; } return $this->current_queue->is_empty() ? false : true; }
/** * Queues events, venues, and organizers for insertion * * @param array $data Import data * * @return array|WP_Error */ public function process_posts($data = array()) { if ('csv' !== $data['origin'] || empty($data['csv']['content_type'])) { return tribe_error('core:aggregator:invalid-csv-parameters'); } if ($this->has_queue()) { $queue = new Tribe__Events__Aggregator__Record__Queue($this->post->ID); return $queue->process(); } $importer = $this->prep_import_data($data); $queue = new Tribe__Events__Aggregator__Record__Queue($this->post->ID, $importer); return $queue->process(); }
/** * Queues events, venues, and organizers for insertion * * @param array $data Import data * * @return array|WP_Error */ public function process_posts($data = array()) { if ($this->has_queue()) { $queue = new Tribe__Events__Aggregator__Record__Queue($this); return $queue->process(); } $items = $this->prep_import_data($data); if (is_wp_error($items)) { $this->set_status_as_failed($items); return $items; } $queue = new Tribe__Events__Aggregator__Record__Queue($this, $items); return $queue->process(); }