public function import_next_row($throw = false, $preview = false) { $post_id = null; $record = $this->reader->read_next_row(); $row = $this->reader->get_last_line_number_read() + 1; //Check if option to encode is active $encoding_option = Tribe__Events__Importer__Options::getOption('imported_encoding_status', array('csv' => 'encode')); if (isset($encoding_option['csv']) && 'encode' == $encoding_option['csv']) { $encoded = ForceUTF8__Encoding::toUTF8($record); $encoding_diff = array_diff($encoded, $record); if (!empty($encoding_diff)) { $this->encoding[] = $row; } $record = $encoded; } if ($preview) { return $record; } if (!$this->is_valid_record($record)) { if (!$throw) { $this->log[$row] = $this->get_skipped_row_message($row); $this->skipped[] = $row; return false; } else { throw new RuntimeException(sprintf('Missing required fields in row %d', $row)); } } try { $post_id = $this->update_or_create_post($record); } catch (Exception $e) { $this->log[$row] = sprintf(esc_html__('Failed to import record in row %d.', 'the-events-calendar'), $row); $this->skipped[] = $row; } return $post_id; }
protected function import_next_row() { $record = $this->reader->read_next_row(); $row = $this->reader->get_last_line_number_read() + 1; if (!$this->is_valid_record($record)) { $this->log[$row] = sprintf(__('Missing required fields in row %d.', 'tribe-events-calendar', $row)); $this->skipped[] = $row; return; } try { $this->update_or_create_post($record); } catch (Exception $e) { $this->log[$row] = sprintf(__('Failed to import record in row %d.', 'tribe-events-calendar'), $row); $this->skipped[] = $row; } }
public function import_next_row($throw = false) { $record = $this->reader->read_next_row(); $row = $this->reader->get_last_line_number_read() + 1; if (!$this->is_valid_record($record)) { if (!$throw) { $this->log[$row] = sprintf(esc_html__('Missing required fields in row %d.', 'the-events-calendar', $row)); $this->skipped[] = $row; return false; } else { throw new RuntimeException(sprintf('Missing required fields in row %d', $row)); } } try { $post_id = $this->update_or_create_post($record); } catch (Exception $e) { $this->log[$row] = sprintf(esc_html__('Failed to import record in row %d.', 'the-events-calendar'), $row); $this->skipped[] = $row; } return $post_id; }