Tribe__Events__Aggregator__Record__CSV::queue_import( $args = array() )


Source

File: src/Tribe/Aggregator/Record/CSV.php

	public function queue_import( $args = array() ) {
		$is_previewing = (
			! empty( $_GET['action'] )
			&& (
				'tribe_aggregator_create_import' === $_GET['action']
				|| 'tribe_aggregator_preview_import' === $_GET['action']
			)
		);

		$data = $this->get_csv_data();

		$result = array(
			'status'       => 'success',
			'message_code' => 'success',
			'data'         => array(
				'import_id' => $this->id,
				'items'     => $data,
			),
		);

		$first_row = reset( $data );
		$columns   = array_keys( $first_row );

		$result['data']['columns'] = $columns;

		// store the import id
		update_post_meta( $this->id, self::$meta_key_prefix . 'import_id', $this->id );

		// only set as pending if we aren't previewing the record
		if ( ! $is_previewing ) {
			// if we get here, we're good! Set the status to pending
			$this->set_status_as_pending();
		}

		return $result;
	}