Product Import Export for WooCommerce - Version 1.7.4

Version Description

  • Security fix.
Download this release

Release Info

Developer webtoffee
Plugin Icon 128x128 Product Import Export for WooCommerce
Version 1.7.4
Comparing to
See all releases

Code changes from version 1.7.3 to 1.7.4

includes/class-wf-prodimpexpcsv-admin-screen.php CHANGED
@@ -89,9 +89,10 @@ class WF_ProdImpExpCsv_Admin_Screen {
89
90
if (strtotime(get_option('xa_pipe_plugin_installed_date')) < strtotime('-7 days')) {
91
92
- if (!current_user_can('manage_woocommerce') || !function_exists('wc_get_screen_ids')) {
93
return $header_text;
94
}
95
96
$current_screen = get_current_screen();
97
@@ -123,7 +124,7 @@ class WF_ProdImpExpCsv_Admin_Screen {
123
*/
124
public function review_rated() {
125
126
- if (!current_user_can('manage_woocommerce')) {
127
wp_die(-1);
128
}
129
update_option('xa_pipe_plugin_review_rated', 1);
89
90
if (strtotime(get_option('xa_pipe_plugin_installed_date')) < strtotime('-7 days')) {
91
92
+ if (!WF_Product_Import_Export_CSV::hf_user_permission()) {
93
return $header_text;
94
}
95
+
96
97
$current_screen = get_current_screen();
98
124
*/
125
public function review_rated() {
126
127
+ if (!WF_Product_Import_Export_CSV::hf_user_permission()) {
128
wp_die(-1);
129
}
130
update_option('xa_pipe_plugin_review_rated', 1);
includes/class-wf-prodimpexpcsv-ajax-handler.php CHANGED
@@ -17,6 +17,9 @@ class WF_ProdImpExpCsv_AJAX_Handler {
17
* Ajax event for importing a CSV
18
*/
19
public function csv_import_request() {
20
define( 'WP_LOAD_IMPORTERS', true );
21
WF_ProdImpExpCsv_Importer::product_importer();
22
}
@@ -25,6 +28,9 @@ class WF_ProdImpExpCsv_AJAX_Handler {
25
* From regenerate thumbnails plugin
26
*/
27
public function regenerate_thumbnail() {
28
@error_reporting( 0 ); // Don't break the JSON result
29
30
header( 'Content-type: application/json' );
17
* Ajax event for importing a CSV
18
*/
19
public function csv_import_request() {
20
+ if (!wp_verify_nonce($_POST['wt_nonce'],WF_PROD_IMP_EXP_ID) && !WF_Product_Import_Export_CSV::hf_user_permission()) {
21
+ wp_die(__('Access Denied', 'product-import-export-for-woo'));
22
+ }
23
define( 'WP_LOAD_IMPORTERS', true );
24
WF_ProdImpExpCsv_Importer::product_importer();
25
}
28
* From regenerate thumbnails plugin
29
*/
30
public function regenerate_thumbnail() {
31
+ if (!wp_verify_nonce($_POST['wt_nonce'], WF_PROD_IMP_EXP_ID) && !WF_Product_Import_Export_CSV::hf_user_permission() ) {
32
+ wp_die(__('Access Denied', 'product-import-export-for-woo'));
33
+ }
34
@error_reporting( 0 ); // Don't break the JSON result
35
36
header( 'Content-type: application/json' );
includes/exporter/class-wf-prodimpexpcsv-exporter.php CHANGED
@@ -15,11 +15,11 @@ class WF_ProdImpExpCsv_Exporter {
15
$limit = 100;
16
$current_offset = ! empty( $_POST['offset'] ) ? intval( $_POST['offset'] ) : 0;
17
$csv_columns = include( 'data/data-wf-post-columns.php' );
18
- $user_columns_name = ! empty( $_POST['columns_name'] ) ? $_POST['columns_name'] : $csv_columns;
19
$product_taxonomies = get_object_taxonomies( 'product', 'name' );
20
- $export_columns = ! empty( $_POST['columns'] ) ? $_POST['columns'] : '';
21
$include_hidden_meta = ! empty( $_POST['include_hidden_meta'] ) ? true : false;
22
- $product_limit = ! empty( $_POST['product_limit'] ) ? sanitize_text_field( $_POST['product_limit'] ) : '';
23
$exclude_hidden_meta_columns = include( 'data/data-wf-hidden-meta-columns.php' );
24
25
if ( $limit > $export_limit )
15
$limit = 100;
16
$current_offset = ! empty( $_POST['offset'] ) ? intval( $_POST['offset'] ) : 0;
17
$csv_columns = include( 'data/data-wf-post-columns.php' );
18
+ $user_columns_name = ! empty( $_POST['columns_name'] ) ? array_map('sanitize_text_field', $_POST['columns_name']) : $csv_columns;
19
$product_taxonomies = get_object_taxonomies( 'product', 'name' );
20
+ $export_columns = ! empty( $_POST['columns'] ) ? array_map('sanitize_text_field', $_POST['columns'] ): '';
21
$include_hidden_meta = ! empty( $_POST['include_hidden_meta'] ) ? true : false;
22
+ $product_limit = ! empty( $_POST['product_limit'] ) ? intval( $_POST['product_limit'] ) : '';
23
$exclude_hidden_meta_columns = include( 'data/data-wf-hidden-meta-columns.php' );
24
25
if ( $limit > $export_limit )
includes/importer/class-wf-csv-parser.php CHANGED
@@ -68,7 +68,6 @@ class WF_CSV_Parser {
68
69
// Put all CSV data into an associative array
70
if (( $handle = fopen($file, "r") ) !== FALSE) {
71
- $delimiter = WF_ProdImpExpCsv_Product_Import::wt_get_csv_delimiter($delimiter); //(strtolower($delimiter) == 'tab' ? "\t" : $delimiter);
72
$header = fgetcsv($handle, 0, $delimiter);
73
if ($start_pos != 0)
74
fseek($handle, $start_pos);
@@ -107,7 +106,7 @@ class WF_CSV_Parser {
107
$row[$s_heading] = ( isset($postmeta[$key]) ) ? $this->format_data_from_csv($postmeta[$key], $enc) : '';
108
109
if (!empty($eval_field[strtolower($heading)]))
110
- $row[$s_heading] = $this->evaluate_field($row[$s_heading], $eval_field[strtolower($heading)]);
111
112
// Raw Headers stores the actual column name in the CSV
113
$raw_headers[$s_heading] = $heading;
@@ -887,7 +886,7 @@ class WF_CSV_Parser {
887
public function hf_currency_formatter($price) {
888
889
$decimal_seperator = wc_get_price_decimal_separator();
890
- return preg_replace("[^0-9\\'.$decimal_seperator.']", "", $price);
891
}
892
893
public function wt_save_product_price( $post_meta) {
68
69
// Put all CSV data into an associative array
70
if (( $handle = fopen($file, "r") ) !== FALSE) {
71
$header = fgetcsv($handle, 0, $delimiter);
72
if ($start_pos != 0)
73
fseek($handle, $start_pos);
106
$row[$s_heading] = ( isset($postmeta[$key]) ) ? $this->format_data_from_csv($postmeta[$key], $enc) : '';
107
108
if (!empty($eval_field[strtolower($heading)]))
109
+ $row[$s_heading] = $this->evaluate_field($row[$s_heading], esc_attr($eval_field[strtolower($heading)]));
110
111
// Raw Headers stores the actual column name in the CSV
112
$raw_headers[$s_heading] = $heading;
886
public function hf_currency_formatter($price) {
887
888
$decimal_seperator = wc_get_price_decimal_separator();
889
+ return preg_replace("/[^0-9\'.$decimal_seperator.']/", "", $price);
890
}
891
892
public function wt_save_product_price( $post_meta) {
includes/importer/class-wf-prodimpexpcsv-product-import.php CHANGED
@@ -20,7 +20,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
20
var $merge_empty_cells;
21
22
// mappings from old information to new
23
- var $processed_terms = array();
24
var $processed_posts = array();
25
var $post_orphans = array();
26
var $attachments = array();
@@ -57,10 +57,12 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
57
global $woocommerce, $wpdb;
58
59
if ( ! empty( $_POST['delimiter'] ) ) {
60
- $this->delimiter = stripslashes( ( $_POST['delimiter'] ) );
61
}else if ( ! empty( $_GET['delimiter'] ) ) {
62
- $this->delimiter = stripslashes( ( $_GET['delimiter'] ) );
63
}
64
65
if ( ! $this->delimiter )
66
$this->delimiter = ',';
@@ -92,7 +94,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
92
if(!empty($_GET['file_url']))
93
$this->file_url = esc_attr( $_GET['file_url'] );
94
if(!empty($_GET['file_id']))
95
- $this->id = $_GET['file_id'] ;
96
97
if ( !empty($_GET['clearmapping']) || $this->handle_upload() )
98
$this->import_options();
@@ -140,7 +142,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
140
141
if ( ! window.console ) { window.console = function(){}; }
142
143
- var processed_terms = [];
144
var processed_posts = [];
145
var post_orphans = [];
146
var attachments = [];
@@ -154,13 +156,14 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
154
var data = {
155
action: 'woocommerce_csv_import_request',
156
file: '<?php echo addslashes( $file ); ?>',
157
- mapping: '<?php echo json_encode($_POST['map_from'],JSON_HEX_APOS); ?>',
158
- eval_field: '<?php echo stripslashes(json_encode(($_POST['eval_field']),JSON_HEX_APOS)) ?>',
159
delimiter: '<?php echo $this->delimiter; ?>',
160
merge_empty_cells: '<?php echo $this->merge_empty_cells; ?>',
161
merge: '<?php echo $this->merge; ?>',
162
start_pos: start_pos,
163
end_pos: end_pos,
164
};
165
data.eval_field = $.parseJSON(data.eval_field);
166
return $.ajax({
@@ -190,9 +193,9 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
190
191
} else if ( results.import_results && $( results.import_results ).size() > 0 ) {
192
193
- $.each( results.processed_terms, function( index, value ) {
194
- processed_terms.push( value );
195
- });
196
197
$.each( results.processed_posts, function( index, value ) {
198
processed_posts.push( value );
@@ -255,7 +258,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
255
256
// Get CSV positions
257
if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
258
- $csv_delimiter = self::wt_get_csv_delimiter($this->delimiter);//(strtolower($this->delimiter) == 'tab' ? "\t" : $this->delimiter);
259
while ( ( $postmeta = fgetcsv( $handle, 0, $csv_delimiter ) ) !== FALSE ) {
260
$count++;
261
@@ -318,7 +321,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
318
$.ajax({
319
type: 'POST',
320
url: ajaxurl,
321
- data: { action: "woocommerce_csv_import_regenerate_thumbnail", id: id },
322
success: function( response ) {
323
//console.log('On Success:-'+JSON.stringify(response, null, 4));
324
if ( response !== Object( response ) || ( typeof response.success === "undefined" && typeof response.error === "undefined" ) ) {
@@ -358,11 +361,12 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
358
var data = {
359
action: 'woocommerce_csv_import_request',
360
file: '<?php echo $file; ?>',
361
- processed_terms: processed_terms,
362
processed_posts: processed_posts,
363
post_orphans: post_orphans,
364
upsell_skus: upsell_skus,
365
- crosssell_skus: crosssell_skus
366
};
367
368
$.ajax({
@@ -384,10 +388,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
384
}
385
break;
386
case 3 :
387
- // Check access - cannot use nonce here as it will expire after multiple requests
388
- if ( ! current_user_can( 'manage_woocommerce' ) )
389
- die();
390
-
391
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
392
393
if ( function_exists( 'gc_enable' ) )
@@ -399,8 +400,8 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
399
$wpdb->hide_errors();
400
401
$file = stripslashes( $_POST['file'] );
402
- $mapping = json_decode( stripslashes( $_POST['mapping'] ), true );
403
- $eval_field = $_POST['eval_field'];
404
$start_pos = isset( $_POST['start_pos'] ) ? absint( $_POST['start_pos'] ) : 0;
405
$end_pos = isset( $_POST['end_pos'] ) ? absint( $_POST['end_pos'] ) : '';
406
@@ -412,7 +413,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
412
413
$results = array();
414
$results['import_results'] = $this->import_results;
415
- $results['processed_terms'] = $this->processed_terms;
416
$results['processed_posts'] = $this->processed_posts;
417
$results['post_orphans'] = $this->post_orphans;
418
$results['attachments'] = $this->attachments;
@@ -425,9 +426,6 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
425
exit;
426
break;
427
case 4 :
428
- // Check access - cannot use nonce here as it will expire after multiple requests
429
- if ( ! current_user_can( 'manage_woocommerce' ) )
430
- die();
431
432
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
433
@@ -439,11 +437,11 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
439
@flush();
440
$wpdb->hide_errors();
441
442
- $this->processed_terms = isset( $_POST['processed_terms'] ) ? $_POST['processed_terms'] : array();
443
- $this->processed_posts = isset( $_POST['processed_posts']) ? $_POST['processed_posts'] : array();
444
- $this->post_orphans = isset( $_POST['post_orphans']) ? $_POST['post_orphans'] : array();
445
- $this->crosssell_skus = isset( $_POST['crosssell_skus']) ? array_filter( (array) $_POST['crosssell_skus'] ) : array();
446
- $this->upsell_skus = isset( $_POST['upsell_skus']) ? array_filter( (array) $_POST['upsell_skus'] ) : array();
447
448
_e( 'Step 1...', 'product-import-export-for-woo' ) . ' ';
449
@@ -535,7 +533,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
535
if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
536
537
$row = $raw_headers = array();
538
- $csv_delimiter = self::wt_get_csv_delimiter($this->delimiter); //(strtolower($this->delimiter) == 'tab' ? "\t" : $this->delimiter);
539
$header = fgetcsv( $handle, 0, $csv_delimiter );
540
541
while ( ( $postmeta = fgetcsv( $handle, 0, $csv_delimiter ) ) !== FALSE ) {
@@ -683,9 +681,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
683
* @return bool False if error uploading or invalid file, true otherwise
684
*/
685
public function handle_upload() {
686
- if($this->handle_ftp()){
687
- return true;
688
- }
689
if ( empty( $_POST['file_url'] ) ) {
690
691
$file = wp_import_handle_upload();
@@ -1538,62 +1534,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
1538
1539
update_post_meta( $product_id, "_{$type}_ids", $ids );
1540
}
1541
-
1542
- private function handle_ftp(){
1543
- $enable_ftp_ie = !empty( $_POST['enable_ftp_ie'] ) ? true : false;
1544
- if($enable_ftp_ie == false) return false;
1545
-
1546
- $ftp_server = ! empty( $_POST['ftp_server'] ) ? $_POST['ftp_server'] : '';
1547
- $ftp_server_path = ! empty( $_POST['ftp_server_path'] ) ? $_POST['ftp_server_path'] : '';
1548
- $ftp_user = ! empty( $_POST['ftp_user'] ) ? $_POST['ftp_user'] : '';
1549
- $ftp_password = ! empty( $_POST['ftp_password'] ) ? $_POST['ftp_password'] : '';
1550
- $use_ftps = ! empty( $_POST['use_ftps'] ) ? true : false;
1551
-
1552
-
1553
- $settings = array();
1554
- $settings[ 'ftp_server' ] = $ftp_server;
1555
- $settings[ 'ftp_user' ] = $ftp_user;
1556
- $settings[ 'ftp_password' ] = $ftp_password;
1557
- $settings[ 'use_ftps' ] = $use_ftps;
1558
- $settings[ 'enable_ftp_ie' ] = $enable_ftp_ie;
1559
- $settings[ 'ftp_server_path' ] = $ftp_server_path;
1560
-
1561
-
1562
- $local_file = 'wp-content/plugins/product-csv-import-export-for-woocommerce/temp-import.csv';
1563
- $server_file = $ftp_server_path;
1564
-
1565
- update_option( 'wf_shipment_tracking_importer_ftp', $settings );
1566
-
1567
- $ftp_conn = $use_ftps ? ftp_ssl_connect($ftp_server) : ftp_connect($ftp_server);
1568
- $error_message = "";
1569
- $success = false;
1570
- if($ftp_conn == false){
1571
- $error_message = "There is connection problem\n";
1572
- }
1573
-
1574
- if(empty($error_message)){
1575
- if(ftp_login($ftp_conn, $ftp_user, $ftp_password) == false){
1576
- $error_message = "Not able to login \n";
1577
- }
1578
- }
1579
- if(empty($error_message)){
1580
-
1581
- if (ftp_get($ftp_conn, ABSPATH.$local_file, $server_file, FTP_BINARY)) {
1582
- $error_message = "";
1583
- $success = true;
1584
- } else {
1585
- $error_message = "There was a problem\n";
1586
- }
1587
- }
1588
1589
- ftp_close($ftp_conn);
1590
- if($success){
1591
- $this->file_url = $local_file;
1592
- }else{
1593
- die($error_message);
1594
- }
1595
- return true;
1596
- }
1597
1598
// Display import page title
1599
public function header() {
@@ -1670,7 +1611,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
1670
return $result;
1671
}
1672
1673
- public static function wt_get_csv_delimiter($delemiter=','){
1674
$delemiter = strtolower($delemiter);
1675
switch ($delemiter) {
1676
case 'tab':
@@ -1683,4 +1624,23 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
1683
}
1684
return $delemiter;
1685
}
1686
}
20
var $merge_empty_cells;
21
22
// mappings from old information to new
23
+ // var $processed_terms = array();
24
var $processed_posts = array();
25
var $post_orphans = array();
26
var $attachments = array();
57
global $woocommerce, $wpdb;
58
59
if ( ! empty( $_POST['delimiter'] ) ) {
60
+ $this->delimiter = stripslashes(( $_POST['delimiter'] ) );
61
}else if ( ! empty( $_GET['delimiter'] ) ) {
62
+ $this->delimiter = stripslashes(( $_GET['delimiter'] ) );
63
}
64
+
65
+ $this->delimiter = self::wt_get_csv_delimiter($this->delimiter);
66
67
if ( ! $this->delimiter )
68
$this->delimiter = ',';
94
if(!empty($_GET['file_url']))
95
$this->file_url = esc_attr( $_GET['file_url'] );
96
if(!empty($_GET['file_id']))
97
+ $this->id = (int)$_GET['file_id'] ;
98
99
if ( !empty($_GET['clearmapping']) || $this->handle_upload() )
100
$this->import_options();
142
143
if ( ! window.console ) { window.console = function(){}; }
144
145
+ // var processed_terms = [];
146
var processed_posts = [];
147
var post_orphans = [];
148
var attachments = [];
156
var data = {
157
action: 'woocommerce_csv_import_request',
158
file: '<?php echo addslashes( $file ); ?>',
159
+ mapping: '<?php echo json_encode(wc_clean($_POST['map_from']),JSON_HEX_APOS); ?>',
160
+ eval_field: '<?php echo stripslashes(json_encode(wc_clean($_POST['eval_field']),JSON_HEX_APOS)) ?>',
161
delimiter: '<?php echo $this->delimiter; ?>',
162
merge_empty_cells: '<?php echo $this->merge_empty_cells; ?>',
163
merge: '<?php echo $this->merge; ?>',
164
start_pos: start_pos,
165
end_pos: end_pos,
166
+ wt_nonce: '<?php echo wp_create_nonce(WF_PROD_IMP_EXP_ID) ?>'
167
};
168
data.eval_field = $.parseJSON(data.eval_field);
169
return $.ajax({
193
194
} else if ( results.import_results && $( results.import_results ).size() > 0 ) {
195
196
+ // $.each( results.processed_terms, function( index, value ) {
197
+ // processed_terms.push( value );
198
+ // });
199
200
$.each( results.processed_posts, function( index, value ) {
201
processed_posts.push( value );
258
259
// Get CSV positions
260
if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
261
+ $csv_delimiter = $this->delimiter;
262
while ( ( $postmeta = fgetcsv( $handle, 0, $csv_delimiter ) ) !== FALSE ) {
263
$count++;
264
321
$.ajax({
322
type: 'POST',
323
url: ajaxurl,
324
+ data: { action: "woocommerce_csv_import_regenerate_thumbnail", id: id ,wt_nonce: '<?php echo wp_create_nonce(WF_PROD_IMP_EXP_ID) ?>' },
325
success: function( response ) {
326
//console.log('On Success:-'+JSON.stringify(response, null, 4));
327
if ( response !== Object( response ) || ( typeof response.success === "undefined" && typeof response.error === "undefined" ) ) {
361
var data = {
362
action: 'woocommerce_csv_import_request',
363
file: '<?php echo $file; ?>',
364
+ // processed_terms: processed_terms,
365
processed_posts: processed_posts,
366
post_orphans: post_orphans,
367
upsell_skus: upsell_skus,
368
+ crosssell_skus: crosssell_skus,
369
+ wt_nonce: '<?php echo wp_create_nonce(WF_PROD_IMP_EXP_ID) ?>'
370
};
371
372
$.ajax({
388
}
389
break;
390
case 3 :
391
+
392
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
393
394
if ( function_exists( 'gc_enable' ) )
400
$wpdb->hide_errors();
401
402
$file = stripslashes( $_POST['file'] );
403
+ $mapping = json_decode( stripslashes(wc_clean( $_POST['mapping'])), true );
404
+ $eval_field = wc_clean( $_POST['eval_field']);
405
$start_pos = isset( $_POST['start_pos'] ) ? absint( $_POST['start_pos'] ) : 0;
406
$end_pos = isset( $_POST['end_pos'] ) ? absint( $_POST['end_pos'] ) : '';
407
413
414
$results = array();
415
$results['import_results'] = $this->import_results;
416
+ // $results['processed_terms'] = $this->processed_terms;
417
$results['processed_posts'] = $this->processed_posts;
418
$results['post_orphans'] = $this->post_orphans;
419
$results['attachments'] = $this->attachments;
426
exit;
427
break;
428
case 4 :
429
430
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
431
437
@flush();
438
$wpdb->hide_errors();
439
440
+ // $this->processed_terms = isset( $_POST['processed_terms'] ) ? $_POST['processed_terms'] : array();
441
+ $this->processed_posts = isset( $_POST['processed_posts']) ? array_map('intval', $_POST['processed_posts']) : array();
442
+ $this->post_orphans = isset( $_POST['post_orphans']) ? array_map('intval', $_POST['post_orphans']) : array();
443
+ $this->crosssell_skus = isset( $_POST['crosssell_skus']) ? wc_clean( $_POST['crosssell_skus']) : array();
444
+ $this->upsell_skus = isset( $_POST['upsell_skus']) ? wc_clean( $_POST['upsell_skus']) : array();
445
446
_e( 'Step 1...', 'product-import-export-for-woo' ) . ' ';
447
533
if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
534
535
$row = $raw_headers = array();
536
+ $csv_delimiter = $this->delimiter;
537
$header = fgetcsv( $handle, 0, $csv_delimiter );
538
539
while ( ( $postmeta = fgetcsv( $handle, 0, $csv_delimiter ) ) !== FALSE ) {
681
* @return bool False if error uploading or invalid file, true otherwise
682
*/
683
public function handle_upload() {
684
+
685
if ( empty( $_POST['file_url'] ) ) {
686
687
$file = wp_import_handle_upload();
1534
1535
update_post_meta( $product_id, "_{$type}_ids", $ids );
1536
}
1537
1538
1539
// Display import page title
1540
public function header() {
1611
return $result;
1612
}
1613
1614
+ public static function wt_get_csv_delimiter1($delemiter=','){
1615
$delemiter = strtolower($delemiter);
1616
switch ($delemiter) {
1617
case 'tab':
1624
}
1625
return $delemiter;
1626
}
1627
+
1628
+ public static function wt_get_csv_delimiter($delemiter = ',',$other_delimiter = ''){
1629
+ $delemiter = strtolower($delemiter);
1630
+ $delemiter_pass = $delemiter;
1631
+ switch ($delemiter) {
1632
+ case 'tab':
1633
+ $delemiter_pass = "\t";
1634
+ break;
1635
+
1636
+ case 'space':
1637
+ $delemiter_pass = " ";
1638
+ break;
1639
+
1640
+ case 'other':
1641
+ $delemiter_pass = $other_delimiter;
1642
+ break;
1643
+ }
1644
+ return $delemiter_pass;
1645
+ }
1646
}
includes/importer/views/html-wf-import-greeting.php CHANGED
@@ -57,10 +57,23 @@ if (!empty($ftp_settings)) {
57
<p><small><?php _e('Existing products are identified by their SKUs/IDs. If this option is not selected and if a product with same ID/SKU is found in the CSV, that product will not be imported.', 'product-import-export-for-woo'); ?></small></p>
58
</td>
59
60
- </tr>
61
<tr>
62
- <th><label><?php _e('Delimiter', 'product-import-export-for-woo'); ?></label><br/></th>
63
- <td><input type="text" name="delimiter" placeholder="," size="2" /></td>
64
</tr>
65
<tr>
66
<th><label><?php _e('Merge empty cells', 'product-import-export-for-woo'); ?></label><br/></th>
@@ -81,4 +94,20 @@ if (!empty($ftp_settings)) {
81
<?php include(WF_ProdImpExpCsv_BASE . 'includes/views/market.php'); ?>
82
<div class="clearfix"></div>
83
</div>
84
- </div>
57
<p><small><?php _e('Existing products are identified by their SKUs/IDs. If this option is not selected and if a product with same ID/SKU is found in the CSV, that product will not be imported.', 'product-import-export-for-woo'); ?></small></p>
58
</td>
59
60
+ </tr>
61
<tr>
62
+ <th><label><?php _e('Delimiter', 'wf_csv_import_export'); ?></label><br/></th>
63
+ <td>
64
+ <input type="radio" id="wt_prod_delimiter_comma" name="delimiter" value="," checked >
65
+ <label for="wt_prod_delimiter_comma">Comma</label>&nbsp;&nbsp;&nbsp;
66
+ <input type="radio" id="wt_prod_delimiter_tab" name="delimiter" value="tab" >
67
+ <label for="wt_prod_delimiter_tab">Tab</label>&nbsp;&nbsp;&nbsp;
68
+ <input type="radio" id="wt_prod_delimiter_semi" name="delimiter" value=";" >
69
+ <label for="wt_prod_delimiter_semi">Semicolon</label>&nbsp;&nbsp;&nbsp;
70
+ <input type="radio" id="wt_prod_delimiter_space" name="delimiter" value="space" >
71
+ <label for="wt_prod_delimiter_space">Space</label>&nbsp;&nbsp;&nbsp;
72
+ <input type="radio" id="wt_prod_delimiter_other" name="delimiter" value="" >
73
+ <label for="wt_prod_delimiter_other">Other</label>&nbsp;&nbsp;&nbsp;
74
+ <input type="text" id="wt_prod_delimiter_other_txt" placeholder="," name="delimitertxt" maxlength="1" size="2" />
75
+ <span class="description"><?php _e('<br />Select a delimiter to separate the field values with. ‘,’ is the default delimiter', 'wf_csv_import_export'); ?></span>
76
+ </td>
77
</tr>
78
<tr>
79
<th><label><?php _e('Merge empty cells', 'product-import-export-for-woo'); ?></label><br/></th>
94
<?php include(WF_ProdImpExpCsv_BASE . 'includes/views/market.php'); ?>
95
<div class="clearfix"></div>
96
</div>
97
+ </div>
98
+ <script>
99
+ jQuery("#wt_prod_delimiter_other").click(function() {
100
+ jQuery("#wt_prod_delimiter_other_txt").focus();
101
+ });
102
+
103
+ jQuery("#wt_prod_delimiter_other_txt").focus(function() {
104
+ jQuery("#wt_prod_delimiter_other").prop("checked", true);
105
+
106
+ });
107
+
108
+ jQuery("#wt_import_greet").click(function () {
109
+ var delimiter = jQuery("#wt_prod_delimiter_other_txt").val();
110
+ jQuery('#wt_prod_delimiter_other').val(delimiter);
111
+ });
112
+
113
+ </script>
product-import-export-for-woo.php CHANGED
@@ -5,7 +5,7 @@
5
Description: Import and Export Products From and To your WooCommerce Store.
6
Author: WebToffee
7
Author URI: https://www.webtoffee.com/product/product-import-export-woocommerce/
8
- Version: 1.7.3
9
WC tested up to: 3.9.2
10
License: GPLv3
11
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -18,7 +18,7 @@ if (!defined('ABSPATH') || !is_admin()) {
18
19
20
if (!defined('WF_PIPE_CURRENT_VERSION')) {
21
- define("WF_PIPE_CURRENT_VERSION", "1.7.3");
22
}
23
if (!defined('WF_PROD_IMP_EXP_ID')) {
24
define("WF_PROD_IMP_EXP_ID", "wf_prod_imp_exp");
@@ -113,7 +113,7 @@ if (!defined('WF_WOOCOMMERCE_CSV_IM_EX')) {
113
if (!empty($_GET['action']) && !empty($_GET['page']) && $_GET['page'] == 'wf_woocommerce_csv_im_ex') {
114
switch ($_GET['action']) {
115
case "export" :
116
- $user_ok = $this->hf_user_permission();
117
if ($user_ok) {
118
include_once( 'includes/exporter/class-wf-prodimpexpcsv-exporter.php' );
119
WF_ProdImpExpCsv_Exporter::do_export('product');
@@ -132,7 +132,7 @@ if (!defined('WF_WOOCOMMERCE_CSV_IM_EX')) {
132
register_importer('xa_woocommerce_csv', 'WebToffee WooCommerce Product Import (CSV)', __('Import <strong>products</strong> to your store via a csv file.', 'product-import-export-for-woo'), 'WF_ProdImpExpCsv_Importer::product_importer');
133
}
134
135
- private function hf_user_permission() {
136
// Check if user has rights to export
137
$current_user = wp_get_current_user();
138
$current_user->roles = apply_filters('hf_add_user_roles', $current_user->roles);
@@ -185,7 +185,7 @@ if (!defined('WF_WOOCOMMERCE_CSV_IM_EX')) {
185
}
186
187
public function WT_admin_footer_text($footer_text) {
188
- if (!current_user_can('manage_woocommerce') || !function_exists('wc_get_screen_ids')) {
189
return $footer_text;
190
}
191
$screen = get_current_screen();
@@ -211,13 +211,12 @@ if (!defined('WF_WOOCOMMERCE_CSV_IM_EX')) {
211
212
213
public function review_plugin(){
214
- if (!current_user_can('manage_woocommerce')) {
215
wp_die(-1);
216
}
217
update_option('pipe_wt_plugin_reviewed', 1);
218
- wp_die();
219
-
220
- }
221
222
}
223
@@ -243,7 +242,7 @@ function hf_welcome_screen_activate_basic() {
243
wp_die(__("Is everything fine? You already have the Premium version installed in your website. For any issues, kindly raise a ticket via <a target='_blank' href='https://www.webtoffee.com/support/'>support</a>", 'product-import-export-for-woo'), "", array('back_link' => 1));
244
}
245
update_option('xa_pipe_plugin_installed_date', date('Y-m-d H:i:s'));
246
- set_transient('_welcome_screen_activation_redirect', true, 30);
247
}
248
249
if (!function_exists('impexp_welcome')) {
5
Description: Import and Export Products From and To your WooCommerce Store.
6
Author: WebToffee
7
Author URI: https://www.webtoffee.com/product/product-import-export-woocommerce/
8
+ Version: 1.7.4
9
WC tested up to: 3.9.2
10
License: GPLv3
11
License URI: https://www.gnu.org/licenses/gpl-3.0.html
18
19
20
if (!defined('WF_PIPE_CURRENT_VERSION')) {
21
+ define("WF_PIPE_CURRENT_VERSION", "1.7.4");
22
}
23
if (!defined('WF_PROD_IMP_EXP_ID')) {
24
define("WF_PROD_IMP_EXP_ID", "wf_prod_imp_exp");
113
if (!empty($_GET['action']) && !empty($_GET['page']) && $_GET['page'] == 'wf_woocommerce_csv_im_ex') {
114
switch ($_GET['action']) {
115
case "export" :
116
+ $user_ok = self::hf_user_permission();
117
if ($user_ok) {
118
include_once( 'includes/exporter/class-wf-prodimpexpcsv-exporter.php' );
119
WF_ProdImpExpCsv_Exporter::do_export('product');
132
register_importer('xa_woocommerce_csv', 'WebToffee WooCommerce Product Import (CSV)', __('Import <strong>products</strong> to your store via a csv file.', 'product-import-export-for-woo'), 'WF_ProdImpExpCsv_Importer::product_importer');
133
}
134
135
+ public static function hf_user_permission() {
136
// Check if user has rights to export
137
$current_user = wp_get_current_user();
138
$current_user->roles = apply_filters('hf_add_user_roles', $current_user->roles);
185
}
186
187
public function WT_admin_footer_text($footer_text) {
188
+ if (!self::hf_user_permission()) {
189
return $footer_text;
190
}
191
$screen = get_current_screen();
211
212
213
public function review_plugin(){
214
+ if (!self::hf_user_permission()) {
215
wp_die(-1);
216
}
217
update_option('pipe_wt_plugin_reviewed', 1);
218
+ wp_die();
219
+ }
220
221
}
222
242
wp_die(__("Is everything fine? You already have the Premium version installed in your website. For any issues, kindly raise a ticket via <a target='_blank' href='https://www.webtoffee.com/support/'>support</a>", 'product-import-export-for-woo'), "", array('back_link' => 1));
243
}
244
update_option('xa_pipe_plugin_installed_date', date('Y-m-d H:i:s'));
245
+ set_transient('_welcome_screen_activation_redirect', true, 30);
246
}
247
248
if (!function_exists('impexp_welcome')) {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.webtoffee.com/plugins/
4
Tags: woocommerce product import, woocommerce import products, woocommerce export products, export woocommerce products, import products into woocommerce ,product, export, import, woocommerce ,csv
5
Requires at least: 3.0.1
6
Tested up to: 5.3.2
7
- Stable tag: 1.7.3
8
License: GPLv3 or later
9
License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
@@ -153,6 +153,9 @@ By default, admin and store manager are given access to export orders from your
153
154
== Changelog ==
155
156
= 1.7.3 =
157
* Tested OK with WC 3.9.2
158
4
Tags: woocommerce product import, woocommerce import products, woocommerce export products, export woocommerce products, import products into woocommerce ,product, export, import, woocommerce ,csv
5
Requires at least: 3.0.1
6
Tested up to: 5.3.2
7
+ Stable tag: 1.7.4
8
License: GPLv3 or later
9
License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
153
154
== Changelog ==
155
156
+ = 1.7.4 =
157
+ * Security fix.
158
+
159
= 1.7.3 =
160
* Tested OK with WC 3.9.2
161