diff --git a/includes/admin/importers/class-wc-product-csv-importer-controller.php b/includes/admin/importers/class-wc-product-csv-importer-controller.php index b42230425b8..23a4ac1e3bc 100644 --- a/includes/admin/importers/class-wc-product-csv-importer-controller.php +++ b/includes/admin/importers/class-wc-product-csv-importer-controller.php @@ -68,6 +68,7 @@ class WC_Product_CSV_Importer_Controller { */ public static function get_importer( $file, $args = array() ) { $importer_class = apply_filters( 'woocommerce_product_csv_importer_class', 'WC_Product_CSV_Importer' ); + $args = apply_filters( 'woocommerce_product_csv_importer_args', $args, $importer_class ); return new $importer_class( $file, $args ); } diff --git a/includes/import/class-wc-product-csv-importer.php b/includes/import/class-wc-product-csv-importer.php index 29938f4310e..8f70b0a3516 100644 --- a/includes/import/class-wc-product-csv-importer.php +++ b/includes/import/class-wc-product-csv-importer.php @@ -39,6 +39,8 @@ class WC_Product_CSV_Importer extends WC_Product_Importer { '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. + 'escape' => '\\', ); $this->params = wp_parse_args( $params, $default_args ); @@ -58,7 +60,7 @@ class WC_Product_CSV_Importer extends WC_Product_Importer { */ protected function read_file() { if ( false !== ( $handle = fopen( $this->file, 'r' ) ) ) { - $this->raw_keys = fgetcsv( $handle, 0, $this->params['delimiter'] ); + $this->raw_keys = fgetcsv( $handle, 0, $this->params['delimiter'], $this->params['enclosure'], $this->params['escape'] ); // Remove BOM signature from the first item. if ( isset( $this->raw_keys[0] ) ) { @@ -69,7 +71,7 @@ class WC_Product_CSV_Importer extends WC_Product_Importer { fseek( $handle, (int) $this->params['start_pos'] ); } - while ( false !== ( $row = fgetcsv( $handle, 0, $this->params['delimiter'] ) ) ) { + while ( false !== ( $row = fgetcsv( $handle, 0, $this->params['delimiter'], $this->params['enclosure'], $this->params['escape'] ) ) ) { $this->raw_data[] = $row; $this->file_positions[ count( $this->raw_data ) ] = ftell( $handle );