Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( '__construct', 'custom__construct' );
- public function custom__construct( $file, $params = array() ) {
- $default_args = array(
- 'start_pos' => 0, // File pointer start.
- 'end_pos' => -1, // File pointer end.
- 'lines' => -1, // Max lines to read.
- 'mapping' => array(), // Column mapping. csv_heading => schema_heading.
- 'parse' => false, // Whether to sanitize and format data.
- 'update_existing' => false, // Whether to update existing items.
- 'delimiter' => '~', // CSV delimiter.
- 'prevent_timeouts' => true, // Check memory and time usage and abort if reaching limit.
- 'enclosure' => '"', // The character used to wrap text in the CSV.
- );
- $this->params = wp_parse_args( $params, $default_args );
- $this->file = $file;
- if ( isset( $this->params['mapping']['from'], $this->params['mapping']['to'] ) ) {
- $this->params['mapping'] = array_combine( $this->params['mapping']['from'], $this->params['mapping']['to'] );
- }
- $this->read_file();
- }
Add Comment
Please, Sign In to add comment