Version Description
- Enhancement: Improved parsing.
- Updates: Tested OK with WP 4.9.5 and WC 3.3.5
- Fixed warnings.
Download this release
Release Info
Developer | mujeebur |
Plugin | Product Import Export for WooCommerce |
Version | 1.4.4 |
Comparing to | |
See all releases |
Code changes from version 1.4.3 to 1.4.4
- includes/importer/class-wf-csv-parser.php +21 -43
- includes/importer/class-wf-prodimpexpcsv-product-import.php +51 -75
- product-csv-import-export.php +416 -416
- readme.txt +11 -7
includes/importer/class-wf-csv-parser.php
CHANGED
@@ -229,7 +229,7 @@ class WF_CSV_Parser {
|
|
229 |
|
230 |
}
|
231 |
}
|
232 |
-
|
233 |
}
|
234 |
}
|
235 |
|
@@ -279,52 +279,30 @@ class WF_CSV_Parser {
|
|
279 |
}
|
280 |
|
281 |
// Handle special meta fields
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
if ( ! isset( $postmeta['regular_price'] ) )
|
287 |
-
$postmeta['regular_price'] = get_post_meta( $post_id, '_regular_price', true );
|
288 |
-
$postmeta['regular_price'] = $this->hf_currency_formatter($postmeta['regular_price']);
|
289 |
-
if ( ! isset( $postmeta['sale_price'] ) )
|
290 |
-
$postmeta['sale_price'] = get_post_meta( $post_id, '_sale_price', true );
|
291 |
-
$postmeta['sale_price'] = $this->hf_currency_formatter($postmeta['sale_price']);
|
292 |
-
}
|
293 |
-
|
294 |
-
if ( isset( $postmeta['regular_price'] ) && isset( $postmeta['sale_price'] ) && $postmeta['sale_price'] !== '' ) {
|
295 |
-
$postmeta['sale_price'] = $this->hf_currency_formatter($postmeta['sale_price']);
|
296 |
$postmeta['regular_price'] = $this->hf_currency_formatter($postmeta['regular_price']);
|
297 |
-
|
298 |
-
$postmeta['
|
299 |
-
} elseif ( isset( $postmeta['regular_price'] ) ) {
|
300 |
-
$postmeta['price'] = $this->hf_currency_formatter($postmeta['regular_price']);
|
301 |
-
}
|
302 |
-
|
303 |
-
} else {
|
304 |
-
|
305 |
-
// price
|
306 |
-
if ( $merging ) {
|
307 |
-
if ( ! isset( $postmeta['regular_price'] ) )
|
308 |
-
$postmeta['regular_price'] = get_post_meta( $post_id, '_regular_price', true );
|
309 |
-
$postmeta['regular_price'] = $this->hf_currency_formatter($postmeta['regular_price']);
|
310 |
-
if ( ! isset( $postmeta['sale_price'] ) )
|
311 |
-
$postmeta['sale_price'] = get_post_meta( $post_id, '_sale_price', true );
|
312 |
-
$postmeta['sale_price'] = $this->hf_currency_formatter($postmeta['sale_price']);
|
313 |
-
}
|
314 |
-
|
315 |
-
if ( isset( $postmeta['regular_price'] ) && isset( $postmeta['sale_price'] ) && $postmeta['sale_price'] !== '' ) {
|
316 |
$postmeta['sale_price'] = $this->hf_currency_formatter($postmeta['sale_price']);
|
317 |
-
|
318 |
-
$price = min( $postmeta['sale_price'], $postmeta['regular_price']);
|
319 |
-
$postmeta['price'] = $price;
|
320 |
-
} elseif ( isset( $postmeta['regular_price'] ) ) {
|
321 |
-
$postmeta['price'] = $this->hf_currency_formatter($postmeta['regular_price']);
|
322 |
-
}
|
323 |
|
324 |
-
|
325 |
-
|
|
|
|
|
|
|
|
|
|
|
326 |
}
|
327 |
|
|
|
|
|
|
|
|
|
|
|
328 |
// upsells
|
329 |
if ( isset( $postmeta['upsell_ids'] ) && ! is_array( $postmeta['upsell_ids'] ) ) {
|
330 |
$ids = array_filter( array_map( 'trim', explode( '|', $postmeta['upsell_ids'] ) ) );
|
@@ -864,7 +842,7 @@ class WF_CSV_Parser {
|
|
864 |
$product['sku'] = ( ! empty( $item['sku'] ) ) ? $item['sku'] : '';
|
865 |
$product['post_title'] = ( ! empty( $item['post_title'] ) ) ? $item['post_title'] : '';
|
866 |
$product['post_type'] = $this->post_type;
|
867 |
-
unset( $item, $terms_array, $postmeta, $attributes, $gpf_data, $images );
|
868 |
return $product;
|
869 |
}
|
870 |
public function hf_currency_formatter($price){
|
229 |
|
230 |
}
|
231 |
}
|
232 |
+
|
233 |
}
|
234 |
}
|
235 |
|
279 |
}
|
280 |
|
281 |
// Handle special meta fields
|
282 |
+
// price
|
283 |
+
if ( $merging ) {
|
284 |
+
if ( ! isset( $postmeta['regular_price'] ) )
|
285 |
+
$postmeta['regular_price'] = get_post_meta( $post_id, '_regular_price', true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
$postmeta['regular_price'] = $this->hf_currency_formatter($postmeta['regular_price']);
|
287 |
+
if ( ! isset( $postmeta['sale_price'] ) )
|
288 |
+
$postmeta['sale_price'] = get_post_meta( $post_id, '_sale_price', true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
$postmeta['sale_price'] = $this->hf_currency_formatter($postmeta['sale_price']);
|
290 |
+
}
|
|
|
|
|
|
|
|
|
|
|
291 |
|
292 |
+
if ( isset( $postmeta['regular_price'] ) && isset( $postmeta['sale_price'] ) && $postmeta['sale_price'] !== '' ) {
|
293 |
+
$postmeta['sale_price'] = $this->hf_currency_formatter($postmeta['sale_price']);
|
294 |
+
$postmeta['regular_price'] = $this->hf_currency_formatter($postmeta['regular_price']);
|
295 |
+
$price = min( $postmeta['sale_price'], $postmeta['regular_price']);
|
296 |
+
$postmeta['price'] = $price;
|
297 |
+
} elseif ( isset( $postmeta['regular_price'] ) ) {
|
298 |
+
$postmeta['price'] = $this->hf_currency_formatter($postmeta['regular_price']);
|
299 |
}
|
300 |
|
301 |
+
// Reset dynamically generated meta
|
302 |
+
if ( !isset($item['post_parent']) ) {
|
303 |
+
$postmeta['min_variation_price'] = $postmeta['max_variation_price'] = $postmeta['min_variation_regular_price'] =$postmeta['max_variation_regular_price'] = $postmeta['min_variation_sale_price'] = $postmeta['max_variation_sale_price'] = '';
|
304 |
+
}
|
305 |
+
|
306 |
// upsells
|
307 |
if ( isset( $postmeta['upsell_ids'] ) && ! is_array( $postmeta['upsell_ids'] ) ) {
|
308 |
$ids = array_filter( array_map( 'trim', explode( '|', $postmeta['upsell_ids'] ) ) );
|
842 |
$product['sku'] = ( ! empty( $item['sku'] ) ) ? $item['sku'] : '';
|
843 |
$product['post_title'] = ( ! empty( $item['post_title'] ) ) ? $item['post_title'] : '';
|
844 |
$product['post_type'] = $this->post_type;
|
845 |
+
unset( $item, $terms_array, $postmeta, $attributes, $gpf_data, $images );
|
846 |
return $product;
|
847 |
}
|
848 |
public function hf_currency_formatter($price){
|
includes/importer/class-wf-prodimpexpcsv-product-import.php
CHANGED
@@ -168,7 +168,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
168 |
data: data,
|
169 |
type: 'POST',
|
170 |
success: function( response ) {
|
171 |
-
console.log( response );
|
172 |
if ( response ) {
|
173 |
|
174 |
try {
|
@@ -256,15 +256,15 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
256 |
while ( ( $postmeta = fgetcsv( $handle, 0, $this->delimiter ) ) !== FALSE ) {
|
257 |
$count++;
|
258 |
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
}
|
269 |
|
270 |
// Remainder
|
@@ -273,8 +273,8 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
273 |
$import_count ++;
|
274 |
}
|
275 |
|
276 |
-
|
277 |
-
|
278 |
?>
|
279 |
|
280 |
var data = rows.shift();
|
@@ -680,48 +680,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
680 |
}
|
681 |
|
682 |
public function product_exists( $title, $sku = '', $post_name = '' ) {
|
683 |
-
global $wpdb;
|
684 |
-
|
685 |
-
// Post Title Check
|
686 |
-
$post_title = stripslashes( sanitize_post_field( 'post_title', $title, 0, 'db' ) );
|
687 |
-
|
688 |
-
$query = "SELECT ID FROM $wpdb->posts WHERE post_type = 'product' AND post_status IN ( 'publish', 'private', 'draft', 'pending', 'future' )";
|
689 |
-
$args = array();
|
690 |
-
|
691 |
-
/*
|
692 |
-
* removed title check
|
693 |
-
if ( ! empty ( $title ) ) {
|
694 |
-
$query .= ' AND post_title = %s';
|
695 |
-
$args[] = $post_title;
|
696 |
-
}
|
697 |
-
|
698 |
-
|
699 |
-
if ( ! empty ( $post_name ) ) {
|
700 |
-
$query .= ' AND post_name = %s';
|
701 |
-
$args[] = $post_name;
|
702 |
-
}
|
703 |
-
|
704 |
-
*/
|
705 |
-
|
706 |
-
if ( ! empty ( $args ) ) {
|
707 |
-
$posts_that_exist = $wpdb->get_col( $wpdb->prepare( $query, $args ) );
|
708 |
-
|
709 |
-
if ( $posts_that_exist ) {
|
710 |
-
|
711 |
-
foreach( $posts_that_exist as $post_exists ) {
|
712 |
-
|
713 |
-
// Check unique SKU
|
714 |
-
$post_exists_sku = get_post_meta( $post_exists, '_sku', true );
|
715 |
-
|
716 |
-
if ( $sku == $post_exists_sku ) {
|
717 |
-
return true;
|
718 |
-
}
|
719 |
-
|
720 |
-
}
|
721 |
-
|
722 |
-
}
|
723 |
-
}
|
724 |
-
|
725 |
// Sku Check
|
726 |
if ( $sku ) {
|
727 |
|
@@ -740,6 +699,28 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
740 |
|
741 |
return false;
|
742 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
743 |
|
744 |
/**
|
745 |
* Create new posts based on import information
|
@@ -775,15 +756,10 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
775 |
}
|
776 |
// Check if post exists when importing
|
777 |
if ( ! $merging ) {
|
778 |
-
if ( $this->
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
}else{
|
783 |
-
$usr_msg = 'Product already exists.';
|
784 |
-
}
|
785 |
-
$this->add_import_result( 'skipped', __( $usr_msg, 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
786 |
-
$this->hf_log_data_change( 'csv-import', sprintf( __('> “%s”'.$usr_msg, 'wf_csv_import_export'), esc_html($processing_product_title) ), true );
|
787 |
unset( $post );
|
788 |
return;
|
789 |
}
|
@@ -797,7 +773,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
797 |
}
|
798 |
// Check post type to avoid conflicts with IDs
|
799 |
$is_post_exist_in_db = get_post_type( $processing_product_id );
|
800 |
-
if ( $merging && $processing_product_id && !empty($is_post_exist_in_db) && (
|
801 |
$this->add_import_result( 'skipped', __( 'Post is not a product', 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
802 |
$this->hf_log_data_change( 'csv-import', sprintf( __('> “%s” is not a product.', 'wf_csv_import_export'), esc_html($processing_product_id) ), true );
|
803 |
unset( $post );
|
@@ -884,7 +860,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
884 |
} else {
|
885 |
$merging = FALSE;
|
886 |
// Get parent
|
887 |
-
$post_parent = $post['post_parent'];
|
888 |
|
889 |
if ( $post_parent !== "" ) {
|
890 |
$post_parent = absint( $post_parent );
|
@@ -910,19 +886,19 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
910 |
|
911 |
$postdata = array(
|
912 |
'import_id' => $processing_product_id,
|
913 |
-
'post_author' => $post['post_author'] ? absint( $post['post_author'] ) : get_current_user_id(),
|
914 |
-
'post_date' => ( $post['post_date'] ) ? date( 'Y-m-d H:i:s', strtotime( $post['post_date'] )) : '',
|
915 |
-
'post_date_gmt' => ( $post['post_date_gmt'] ) ? date( 'Y-m-d H:i:s', strtotime( $post['post_date_gmt'] )) : '',
|
916 |
-
'post_content' => $post['post_content'],
|
917 |
-
'post_excerpt' => $post['post_excerpt'],
|
918 |
'post_title' => $processing_product_title,
|
919 |
-
'post_name' => ( $post['post_name'] ) ? $post['post_name'] : sanitize_title( $processing_product_title ),
|
920 |
-
'post_status' => ( $post['post_status'] ) ? $post['post_status'] : 'publish',
|
921 |
'post_parent' => $post_parent,
|
922 |
-
'menu_order' => $post['menu_order'],
|
923 |
-
'post_type' => $post['post_type'],
|
924 |
-
'post_password' => $post['post_password'],
|
925 |
-
'comment_status' => $post['comment_status'],
|
926 |
);
|
927 |
$post_id = wp_insert_post( $postdata, true );
|
928 |
|
168 |
data: data,
|
169 |
type: 'POST',
|
170 |
success: function( response ) {
|
171 |
+
//console.log( response );
|
172 |
if ( response ) {
|
173 |
|
174 |
try {
|
256 |
while ( ( $postmeta = fgetcsv( $handle, 0, $this->delimiter ) ) !== FALSE ) {
|
257 |
$count++;
|
258 |
|
259 |
+
if ( $count >= $limit ) {
|
260 |
+
$previous_position = $position;
|
261 |
+
$position = ftell( $handle );
|
262 |
+
$count = 0;
|
263 |
+
$import_count ++;
|
264 |
|
265 |
+
// Import rows between $previous_position $position
|
266 |
+
?>rows.push( [ <?php echo $previous_position; ?>, <?php echo $position; ?> ] ); <?php
|
267 |
+
}
|
268 |
}
|
269 |
|
270 |
// Remainder
|
273 |
$import_count ++;
|
274 |
}
|
275 |
|
276 |
+
fclose( $handle );
|
277 |
+
}
|
278 |
?>
|
279 |
|
280 |
var data = rows.shift();
|
680 |
}
|
681 |
|
682 |
public function product_exists( $title, $sku = '', $post_name = '' ) {
|
683 |
+
global $wpdb;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
684 |
// Sku Check
|
685 |
if ( $sku ) {
|
686 |
|
699 |
|
700 |
return false;
|
701 |
}
|
702 |
+
|
703 |
+
|
704 |
+
public function wf_get_product_id_by_sku( $sku ) {
|
705 |
+
global $wpdb;
|
706 |
+
|
707 |
+
// phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery
|
708 |
+
$id = $wpdb->get_var(
|
709 |
+
$wpdb->prepare(
|
710 |
+
"SELECT posts.ID
|
711 |
+
FROM $wpdb->posts AS posts
|
712 |
+
LEFT JOIN $wpdb->postmeta AS postmeta ON ( posts.ID = postmeta.post_id )
|
713 |
+
WHERE posts.post_type IN ( 'product', 'product_variation' )
|
714 |
+
AND posts.post_status != 'trash'
|
715 |
+
AND postmeta.meta_key = '_sku'
|
716 |
+
AND postmeta.meta_value = %s
|
717 |
+
LIMIT 1",
|
718 |
+
$sku
|
719 |
+
)
|
720 |
+
);
|
721 |
+
|
722 |
+
return (int) apply_filters( 'wf_get_product_id_by_sku', $id, $sku );
|
723 |
+
}
|
724 |
|
725 |
/**
|
726 |
* Create new posts based on import information
|
756 |
}
|
757 |
// Check if post exists when importing
|
758 |
if ( ! $merging ) {
|
759 |
+
if ( $this->wf_get_product_id_by_sku( $processing_product_sku ) ) {
|
760 |
+
$usr_msg = __( 'Product already exists.', 'wf_csv_import_export' );
|
761 |
+
$this->add_import_result( 'skipped',$usr_msg, $processing_product_id, $processing_product_title, $processing_product_sku );
|
762 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> “%s” Product already exists.', 'wf_csv_import_export'), esc_html($processing_product_title) ), true );
|
|
|
|
|
|
|
|
|
|
|
763 |
unset( $post );
|
764 |
return;
|
765 |
}
|
773 |
}
|
774 |
// Check post type to avoid conflicts with IDs
|
775 |
$is_post_exist_in_db = get_post_type( $processing_product_id );
|
776 |
+
if ( $merging && $processing_product_id && !empty($is_post_exist_in_db) && ($is_post_exist_in_db !== $post['post_type'] )) {
|
777 |
$this->add_import_result( 'skipped', __( 'Post is not a product', 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
778 |
$this->hf_log_data_change( 'csv-import', sprintf( __('> “%s” is not a product.', 'wf_csv_import_export'), esc_html($processing_product_id) ), true );
|
779 |
unset( $post );
|
860 |
} else {
|
861 |
$merging = FALSE;
|
862 |
// Get parent
|
863 |
+
$post_parent = (isset($post['post_parent'])?$post['post_parent']:'');
|
864 |
|
865 |
if ( $post_parent !== "" ) {
|
866 |
$post_parent = absint( $post_parent );
|
886 |
|
887 |
$postdata = array(
|
888 |
'import_id' => $processing_product_id,
|
889 |
+
'post_author' => isset($post['post_author']) ? absint( $post['post_author'] ) : get_current_user_id(),
|
890 |
+
'post_date' => isset( $post['post_date'] ) ? date( 'Y-m-d H:i:s', strtotime( $post['post_date'] )) : '',
|
891 |
+
'post_date_gmt' => isset( $post['post_date_gmt'] ) ? date( 'Y-m-d H:i:s', strtotime( $post['post_date_gmt'] )) : '',
|
892 |
+
'post_content' => isset($post['post_content'])?$post['post_content']:"",
|
893 |
+
'post_excerpt' => isset($post['post_excerpt'])?$post['post_excerpt']:'',
|
894 |
'post_title' => $processing_product_title,
|
895 |
+
'post_name' => isset( $post['post_name'] ) ? $post['post_name'] : sanitize_title( $processing_product_title ),
|
896 |
+
'post_status' => isset( $post['post_status'] ) ? $post['post_status'] : 'publish',
|
897 |
'post_parent' => $post_parent,
|
898 |
+
'menu_order' => isset($post['menu_order'])?$post['menu_order']:'',
|
899 |
+
'post_type' => isset($post['post_type'])?$post['post_type']:"",
|
900 |
+
'post_password' => isset($post['post_password'])?$post['post_password']:'',
|
901 |
+
'comment_status' => isset($post['comment_status'])?$post['comment_status']:'',
|
902 |
);
|
903 |
$post_id = wp_insert_post( $postdata, true );
|
904 |
|
product-csv-import-export.php
CHANGED
@@ -1,417 +1,417 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Product CSV Import Export (BASIC)
|
4 |
-
Plugin URI: https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/
|
5 |
-
Description: Import and Export Products From and To your WooCommerce Store.
|
6 |
-
Author: XAdapter
|
7 |
-
Author URI: https://www.xadapter.com/shop
|
8 |
-
Version: 1.4.
|
9 |
-
WC tested up to: 3.
|
10 |
-
Text Domain: wf_csv_import_export
|
11 |
-
*/
|
12 |
-
|
13 |
-
if (!defined('ABSPATH') || !is_admin()) {
|
14 |
-
return;
|
15 |
-
}
|
16 |
-
|
17 |
-
|
18 |
-
if (!defined('WF_PIPE_CURRENT_VERSION')) {
|
19 |
-
define("WF_PIPE_CURRENT_VERSION", "1.4.
|
20 |
-
}
|
21 |
-
if (!defined('WF_PROD_IMP_EXP_ID')) {
|
22 |
-
define("WF_PROD_IMP_EXP_ID", "wf_prod_imp_exp");
|
23 |
-
}
|
24 |
-
if (!defined('WF_WOOCOMMERCE_CSV_IM_EX')) {
|
25 |
-
define("WF_WOOCOMMERCE_CSV_IM_EX", "wf_woocommerce_csv_im_ex");
|
26 |
-
}
|
27 |
-
/**
|
28 |
-
* Check if WooCommerce is active
|
29 |
-
*/
|
30 |
-
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
|
31 |
-
|
32 |
-
if (!class_exists('WF_Product_Import_Export_CSV')) :
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Main CSV Import class
|
36 |
-
*/
|
37 |
-
class WF_Product_Import_Export_CSV {
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Constructor
|
41 |
-
*/
|
42 |
-
public function __construct() {
|
43 |
-
if (!defined('WF_ProdImpExpCsv_FILE')) {
|
44 |
-
define('WF_ProdImpExpCsv_FILE', __FILE__);
|
45 |
-
}
|
46 |
-
|
47 |
-
if (!defined('WF_ProdImpExpCsv_BASE')) {
|
48 |
-
define('WF_ProdImpExpCsv_BASE', plugin_dir_path(__FILE__));
|
49 |
-
}
|
50 |
-
|
51 |
-
add_filter('woocommerce_screen_ids', array($this, 'woocommerce_screen_ids'));
|
52 |
-
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'wf_plugin_action_links'));
|
53 |
-
add_action('init', array($this, 'load_plugin_textdomain'));
|
54 |
-
add_action('init', array($this, 'catch_export_request'), 20);
|
55 |
-
add_action('admin_init', array($this, 'register_importers'));
|
56 |
-
|
57 |
-
add_action('admin_footer', array($this, 'deactivate_scripts'));
|
58 |
-
add_action('wp_ajax_pipe_submit_uninstall_reason', array($this, "send_uninstall_reason"));
|
59 |
-
|
60 |
-
include_once( 'includes/class-wf-prodimpexpcsv-system-status-tools.php' );
|
61 |
-
include_once( 'includes/class-wf-prodimpexpcsv-admin-screen.php' );
|
62 |
-
include_once( 'includes/importer/class-wf-prodimpexpcsv-importer.php' );
|
63 |
-
|
64 |
-
if (defined('DOING_AJAX')) {
|
65 |
-
include_once( 'includes/class-wf-prodimpexpcsv-ajax-handler.php' );
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
public function wf_plugin_action_links($links) {
|
70 |
-
$plugin_links = array(
|
71 |
-
'<a href="' . admin_url('admin.php?page=wf_woocommerce_csv_im_ex&tab=export') . '">' . __('Import Export', 'wf_csv_import_export') . '</a>',
|
72 |
-
'<a target="_blank" href="https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/" target="_blank">' . __('Premium Upgrade', 'wf_csv_import_export') . '</a>',
|
73 |
-
'<a target="_blank" href="https://wordpress.org/support/plugin/product-import-export-for-woo/">' . __('Support', 'wf_csv_import_export') . '</a>',
|
74 |
-
'<a target="_blank" href="https://wordpress.org/support/plugin/product-import-export-for-woo/reviews/">' . __('Review', 'wf_csv_import_export') . '</a>',
|
75 |
-
);
|
76 |
-
if (array_key_exists('deactivate', $links)) {
|
77 |
-
$links['deactivate'] = str_replace('<a', '<a class="pipe-deactivate-link"', $links['deactivate']);
|
78 |
-
}
|
79 |
-
return array_merge($plugin_links, $links);
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Add screen ID
|
84 |
-
*/
|
85 |
-
public function woocommerce_screen_ids($ids) {
|
86 |
-
$ids[] = 'admin'; // For import screen
|
87 |
-
return $ids;
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Handle localization
|
92 |
-
*/
|
93 |
-
public function load_plugin_textdomain() {
|
94 |
-
load_plugin_textdomain('wf_csv_import_export', false, dirname(plugin_basename(__FILE__)) . '/lang/');
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Catches an export request and exports the data. This class is only loaded in admin.
|
99 |
-
*/
|
100 |
-
public function catch_export_request() {
|
101 |
-
|
102 |
-
if (!empty($_GET['action']) && !empty($_GET['page']) && $_GET['page'] == 'wf_woocommerce_csv_im_ex') {
|
103 |
-
switch ($_GET['action']) {
|
104 |
-
case "export" :
|
105 |
-
$user_ok = $this->hf_user_permission();
|
106 |
-
if ($user_ok) {
|
107 |
-
include_once( 'includes/exporter/class-wf-prodimpexpcsv-exporter.php' );
|
108 |
-
WF_ProdImpExpCsv_Exporter::do_export('product');
|
109 |
-
} else {
|
110 |
-
wp_redirect(wp_login_url());
|
111 |
-
}
|
112 |
-
break;
|
113 |
-
}
|
114 |
-
}
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Register importers for use
|
119 |
-
*/
|
120 |
-
public function register_importers() {
|
121 |
-
register_importer('xa_woocommerce_csv', 'XAdapter WooCommerce Product Import (CSV)', __('Import <strong>products</strong> to your store via a csv file.', 'wf_csv_import_export'), 'WF_ProdImpExpCsv_Importer::product_importer');
|
122 |
-
}
|
123 |
-
|
124 |
-
private function hf_user_permission() {
|
125 |
-
// Check if user has rights to export
|
126 |
-
$current_user = wp_get_current_user();
|
127 |
-
$user_ok = false;
|
128 |
-
$wf_roles = apply_filters('hf_user_permission_roles', array('administrator', 'shop_manager'));
|
129 |
-
if ($current_user instanceof WP_User) {
|
130 |
-
$can_users = array_intersect($wf_roles, $current_user->roles);
|
131 |
-
if (!empty($can_users)) {
|
132 |
-
$user_ok = true;
|
133 |
-
}
|
134 |
-
}
|
135 |
-
return $user_ok;
|
136 |
-
}
|
137 |
-
|
138 |
-
private function get_uninstall_reasons() {
|
139 |
-
|
140 |
-
$reasons = array(
|
141 |
-
array(
|
142 |
-
'id' => 'used-it',
|
143 |
-
'text' => __('Used it successfully. Don\'t need anymore.', 'wf_csv_import_export'),
|
144 |
-
'type' => 'reviewhtml',
|
145 |
-
'placeholder' => __('Have used it successfully and aint in need of it anymore', 'wf_csv_import_export')
|
146 |
-
),
|
147 |
-
array(
|
148 |
-
'id' => 'could-not-understand',
|
149 |
-
'text' => __('I couldn\'t understand how to make it work', 'wf_csv_import_export'),
|
150 |
-
'type' => 'textarea',
|
151 |
-
'placeholder' => __('Would you like us to assist you?', 'wf_csv_import_export')
|
152 |
-
),
|
153 |
-
array(
|
154 |
-
'id' => 'found-better-plugin',
|
155 |
-
'text' => __('I found a better plugin', 'wf_csv_import_export'),
|
156 |
-
'type' => 'text',
|
157 |
-
'placeholder' => __('Which plugin?', 'wf_csv_import_export')
|
158 |
-
),
|
159 |
-
array(
|
160 |
-
'id' => 'not-have-that-feature',
|
161 |
-
'text' => __('The plugin is great, but I need specific feature that you don\'t support', 'wf_csv_import_export'),
|
162 |
-
'type' => 'textarea',
|
163 |
-
'placeholder' => __('Could you tell us more about that feature?', 'wf_csv_import_export')
|
164 |
-
),
|
165 |
-
array(
|
166 |
-
'id' => 'is-not-working',
|
167 |
-
'text' => __('The plugin is not working', 'wf_csv_import_export'),
|
168 |
-
'type' => 'textarea',
|
169 |
-
'placeholder' => __('Could you tell us a bit more whats not working?', 'wf_csv_import_export')
|
170 |
-
),
|
171 |
-
array(
|
172 |
-
'id' => 'looking-for-other',
|
173 |
-
'text' => __('It\'s not what I was looking for', 'wf_csv_import_export'),
|
174 |
-
'type' => 'textarea',
|
175 |
-
'placeholder' => __('Could you tell us a bit more?', 'wf_csv_import_export')
|
176 |
-
),
|
177 |
-
array(
|
178 |
-
'id' => 'did-not-work-as-expected',
|
179 |
-
'text' => __('The plugin didn\'t work as expected', 'wf_csv_import_export'),
|
180 |
-
'type' => 'textarea',
|
181 |
-
'placeholder' => __('What did you expect?', 'wf_csv_import_export')
|
182 |
-
),
|
183 |
-
array(
|
184 |
-
'id' => 'other',
|
185 |
-
'text' => __('Other', 'wf_csv_import_export'),
|
186 |
-
'type' => 'textarea',
|
187 |
-
'placeholder' => __('Could you tell us a bit more?', 'wf_csv_import_export')
|
188 |
-
),
|
189 |
-
);
|
190 |
-
|
191 |
-
return $reasons;
|
192 |
-
}
|
193 |
-
|
194 |
-
public function deactivate_scripts() {
|
195 |
-
|
196 |
-
global $pagenow;
|
197 |
-
if ('plugins.php' != $pagenow) {
|
198 |
-
return;
|
199 |
-
}
|
200 |
-
$reasons = $this->get_uninstall_reasons();
|
201 |
-
?>
|
202 |
-
<div class="pipe-modal" id="pipe-pipe-modal">
|
203 |
-
<div class="pipe-modal-wrap">
|
204 |
-
<div class="pipe-modal-header">
|
205 |
-
<h3><?php _e('If you have a moment, please let us know why you are deactivating:', 'wf_csv_import_export'); ?></h3>
|
206 |
-
</div>
|
207 |
-
<div class="pipe-modal-body">
|
208 |
-
<ul class="reasons">
|
209 |
-
<?php foreach ($reasons as $reason) { ?>
|
210 |
-
<li data-type="<?php echo esc_attr($reason['type']); ?>" data-placeholder="<?php echo esc_attr($reason['placeholder']); ?>">
|
211 |
-
<label><input type="radio" name="selected-reason" value="<?php echo $reason['id']; ?>"> <?php echo $reason['text']; ?></label>
|
212 |
-
</li>
|
213 |
-
<?php } ?>
|
214 |
-
</ul>
|
215 |
-
</div>
|
216 |
-
<div class="pipe-modal-footer">
|
217 |
-
<a href="#" class="dont-bother-me"><?php _e('I rather wouldn\'t say', 'wf_csv_import_export'); ?></a>
|
218 |
-
<button class="button-primary pipe-model-submit"><?php _e('Submit & Deactivate', 'wf_csv_import_export'); ?></button>
|
219 |
-
<button class="button-secondary pipe-model-cancel"><?php _e('Cancel', 'wf_csv_import_export'); ?></button>
|
220 |
-
</div>
|
221 |
-
</div>
|
222 |
-
</div>
|
223 |
-
|
224 |
-
<style type="text/css">
|
225 |
-
.pipe-modal {
|
226 |
-
position: fixed;
|
227 |
-
z-index: 99999;
|
228 |
-
top: 0;
|
229 |
-
right: 0;
|
230 |
-
bottom: 0;
|
231 |
-
left: 0;
|
232 |
-
background: rgba(0,0,0,0.5);
|
233 |
-
display: none;
|
234 |
-
}
|
235 |
-
.pipe-modal.modal-active {display: block;}
|
236 |
-
.pipe-modal-wrap {
|
237 |
-
width: 50%;
|
238 |
-
position: relative;
|
239 |
-
margin: 10% auto;
|
240 |
-
background: #fff;
|
241 |
-
}
|
242 |
-
.pipe-modal-header {
|
243 |
-
border-bottom: 1px solid #eee;
|
244 |
-
padding: 8px 20px;
|
245 |
-
}
|
246 |
-
.pipe-modal-header h3 {
|
247 |
-
line-height: 150%;
|
248 |
-
margin: 0;
|
249 |
-
}
|
250 |
-
.pipe-modal-body {padding: 5px 20px 20px 20px;}
|
251 |
-
.pipe-modal-body .input-text,.pipe-modal-body textarea {width:75%;}
|
252 |
-
.pipe-modal-body .reason-input {
|
253 |
-
margin-top: 5px;
|
254 |
-
margin-left: 20px;
|
255 |
-
}
|
256 |
-
.pipe-modal-footer {
|
257 |
-
border-top: 1px solid #eee;
|
258 |
-
padding: 12px 20px;
|
259 |
-
text-align: right;
|
260 |
-
}
|
261 |
-
.reviewlink{
|
262 |
-
padding:10px 0px 0px 35px !important;
|
263 |
-
font-size: 15px;
|
264 |
-
}
|
265 |
-
.review-and-deactivate{
|
266 |
-
padding:5px;
|
267 |
-
}
|
268 |
-
</style>
|
269 |
-
<script type="text/javascript">
|
270 |
-
(function ($) {
|
271 |
-
$(function () {
|
272 |
-
var modal = $('#pipe-pipe-modal');
|
273 |
-
var deactivateLink = '';
|
274 |
-
|
275 |
-
|
276 |
-
$('#the-list').on('click', 'a.pipe-deactivate-link', function (e) {
|
277 |
-
e.preventDefault();
|
278 |
-
modal.addClass('modal-active');
|
279 |
-
deactivateLink = $(this).attr('href');
|
280 |
-
modal.find('a.dont-bother-me').attr('href', deactivateLink).css('float', 'left');
|
281 |
-
});
|
282 |
-
|
283 |
-
$('#pipe-pipe-modal').on('click', 'a.review-and-deactivate', function (e) {
|
284 |
-
e.preventDefault();
|
285 |
-
window.open("https://wordpress.org/support/plugin/product-import-export-for-woo/reviews/#new-post");
|
286 |
-
window.location.href = deactivateLink;
|
287 |
-
});
|
288 |
-
modal.on('click', 'button.pipe-model-cancel', function (e) {
|
289 |
-
e.preventDefault();
|
290 |
-
modal.removeClass('modal-active');
|
291 |
-
});
|
292 |
-
modal.on('click', 'input[type="radio"]', function () {
|
293 |
-
var parent = $(this).parents('li:first');
|
294 |
-
modal.find('.reason-input').remove();
|
295 |
-
var inputType = parent.data('type'),
|
296 |
-
inputPlaceholder = parent.data('placeholder');
|
297 |
-
if('reviewhtml' === inputType) {
|
298 |
-
var reasonInputHtml = '<div class="reviewlink"><a href="#" target="_blank" class="review-and-deactivate"><?php _e('Deactivate and leave a review', 'wf_csv_import_export'); ?> <span class="xa-pipe-rating-link"> ★★★★★ </span></a></div>';
|
299 |
-
}else{
|
300 |
-
var reasonInputHtml = '<div class="reason-input">' + (('text' === inputType) ? '<input type="text" class="input-text" size="40" />' : '<textarea rows="5" cols="45"></textarea>') + '</div>';
|
301 |
-
}
|
302 |
-
if (inputType !== '') {
|
303 |
-
parent.append($(reasonInputHtml));
|
304 |
-
parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus();
|
305 |
-
}
|
306 |
-
});
|
307 |
-
|
308 |
-
modal.on('click', 'button.pipe-model-submit', function (e) {
|
309 |
-
e.preventDefault();
|
310 |
-
var button = $(this);
|
311 |
-
if (button.hasClass('disabled')) {
|
312 |
-
return;
|
313 |
-
}
|
314 |
-
var $radio = $('input[type="radio"]:checked', modal);
|
315 |
-
var $selected_reason = $radio.parents('li:first'),
|
316 |
-
$input = $selected_reason.find('textarea, input[type="text"]');
|
317 |
-
|
318 |
-
$.ajax({
|
319 |
-
url: ajaxurl,
|
320 |
-
type: 'POST',
|
321 |
-
data: {
|
322 |
-
action: 'pipe_submit_uninstall_reason',
|
323 |
-
reason_id: (0 === $radio.length) ? 'none' : $radio.val(),
|
324 |
-
reason_info: (0 !== $input.length) ? $input.val().trim() : ''
|
325 |
-
},
|
326 |
-
beforeSend: function () {
|
327 |
-
button.addClass('disabled');
|
328 |
-
button.text('Processing...');
|
329 |
-
},
|
330 |
-
complete: function () {
|
331 |
-
window.location.href = deactivateLink;
|
332 |
-
}
|
333 |
-
});
|
334 |
-
});
|
335 |
-
});
|
336 |
-
}(jQuery));
|
337 |
-
</script>
|
338 |
-
<?php
|
339 |
-
}
|
340 |
-
|
341 |
-
public function send_uninstall_reason() {
|
342 |
-
|
343 |
-
global $wpdb;
|
344 |
-
|
345 |
-
if (!isset($_POST['reason_id'])) {
|
346 |
-
wp_send_json_error();
|
347 |
-
}
|
348 |
-
|
349 |
-
//$current_user = wp_get_current_user();
|
350 |
-
|
351 |
-
$data = array(
|
352 |
-
'reason_id' => sanitize_text_field($_POST['reason_id']),
|
353 |
-
'plugin' => "productimportexort",
|
354 |
-
'auth' => 'wfpipe_uninstall_1234#',
|
355 |
-
'date' => gmdate("M d, Y h:i:s A"),
|
356 |
-
'url' => home_url(),
|
357 |
-
'user_email' => '',//$current_user->user_email,
|
358 |
-
'reason_info' => isset($_REQUEST['reason_info']) ? trim(stripslashes($_REQUEST['reason_info'])) : '',
|
359 |
-
'software' => $_SERVER['SERVER_SOFTWARE'],
|
360 |
-
'php_version' => phpversion(),
|
361 |
-
'mysql_version' => $wpdb->db_version(),
|
362 |
-
'wp_version' => get_bloginfo('version'),
|
363 |
-
'wc_version' => (!defined('WC_VERSION')) ? '' : WC_VERSION,
|
364 |
-
'locale' => get_locale(),
|
365 |
-
'multisite' => is_multisite() ? 'Yes' : 'No',
|
366 |
-
'wfpipe_version' => WF_PIPE_CURRENT_VERSION
|
367 |
-
);
|
368 |
-
// Write an action/hook here in webtoffe to recieve the data
|
369 |
-
$resp = wp_remote_post('http://feedback.webtoffee.com/wp-json/wfpipe/v1/uninstall', array(
|
370 |
-
'method' => 'POST',
|
371 |
-
'timeout' => 45,
|
372 |
-
'redirection' => 5,
|
373 |
-
'httpversion' => '1.0',
|
374 |
-
'blocking' => false,
|
375 |
-
'headers' => array('user-agent' => 'pipe/' . md5(esc_url(home_url())) . ';'),
|
376 |
-
'body' => $data,
|
377 |
-
'cookies' => array()
|
378 |
-
)
|
379 |
-
);
|
380 |
-
|
381 |
-
wp_send_json_success();
|
382 |
-
}
|
383 |
-
|
384 |
-
}
|
385 |
-
|
386 |
-
endif;
|
387 |
-
|
388 |
-
new WF_Product_Import_Export_CSV();
|
389 |
-
}
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
// Welcome screen tutorial video --> Move this function to inside the class
|
394 |
-
add_action('admin_init', 'impexp_welcome');
|
395 |
-
|
396 |
-
register_activation_hook(__FILE__, 'hf_welcome_screen_activate_basic');
|
397 |
-
|
398 |
-
function hf_welcome_screen_activate_basic() {
|
399 |
-
if (is_plugin_active('product-csv-import-export-for-woocommerce/product-csv-import-export.php')) {
|
400 |
-
deactivate_plugins(basename(__FILE__));
|
401 |
-
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='//support.xadapter.com/'>support.xadapter.com</a>", "wf_csv_import_export"), "", array('back_link' => 1));
|
402 |
-
}
|
403 |
-
update_option('xa_pipe_plugin_installed_date', date('Y-m-d H:i:s'));
|
404 |
-
set_transient('_welcome_screen_activation_redirect', true, 30);
|
405 |
-
}
|
406 |
-
|
407 |
-
if (!function_exists('impexp_welcome')) {
|
408 |
-
|
409 |
-
function impexp_welcome() {
|
410 |
-
if (!get_transient('_welcome_screen_activation_redirect')) {
|
411 |
-
return;
|
412 |
-
}
|
413 |
-
delete_transient('_welcome_screen_activation_redirect');
|
414 |
-
wp_safe_redirect(add_query_arg(array('page' => 'wf_woocommerce_csv_im_ex'), admin_url('admin.php')));
|
415 |
-
}
|
416 |
-
|
417 |
}
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Product CSV Import Export (BASIC)
|
4 |
+
Plugin URI: https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/
|
5 |
+
Description: Import and Export Products From and To your WooCommerce Store.
|
6 |
+
Author: XAdapter
|
7 |
+
Author URI: https://www.xadapter.com/shop
|
8 |
+
Version: 1.4.4
|
9 |
+
WC tested up to: 3.4.0
|
10 |
+
Text Domain: wf_csv_import_export
|
11 |
+
*/
|
12 |
+
|
13 |
+
if (!defined('ABSPATH') || !is_admin()) {
|
14 |
+
return;
|
15 |
+
}
|
16 |
+
|
17 |
+
|
18 |
+
if (!defined('WF_PIPE_CURRENT_VERSION')) {
|
19 |
+
define("WF_PIPE_CURRENT_VERSION", "1.4.4");
|
20 |
+
}
|
21 |
+
if (!defined('WF_PROD_IMP_EXP_ID')) {
|
22 |
+
define("WF_PROD_IMP_EXP_ID", "wf_prod_imp_exp");
|
23 |
+
}
|
24 |
+
if (!defined('WF_WOOCOMMERCE_CSV_IM_EX')) {
|
25 |
+
define("WF_WOOCOMMERCE_CSV_IM_EX", "wf_woocommerce_csv_im_ex");
|
26 |
+
}
|
27 |
+
/**
|
28 |
+
* Check if WooCommerce is active
|
29 |
+
*/
|
30 |
+
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
|
31 |
+
|
32 |
+
if (!class_exists('WF_Product_Import_Export_CSV')) :
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Main CSV Import class
|
36 |
+
*/
|
37 |
+
class WF_Product_Import_Export_CSV {
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Constructor
|
41 |
+
*/
|
42 |
+
public function __construct() {
|
43 |
+
if (!defined('WF_ProdImpExpCsv_FILE')) {
|
44 |
+
define('WF_ProdImpExpCsv_FILE', __FILE__);
|
45 |
+
}
|
46 |
+
|
47 |
+
if (!defined('WF_ProdImpExpCsv_BASE')) {
|
48 |
+
define('WF_ProdImpExpCsv_BASE', plugin_dir_path(__FILE__));
|
49 |
+
}
|
50 |
+
|
51 |
+
add_filter('woocommerce_screen_ids', array($this, 'woocommerce_screen_ids'));
|
52 |
+
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'wf_plugin_action_links'));
|
53 |
+
add_action('init', array($this, 'load_plugin_textdomain'));
|
54 |
+
add_action('init', array($this, 'catch_export_request'), 20);
|
55 |
+
add_action('admin_init', array($this, 'register_importers'));
|
56 |
+
|
57 |
+
add_action('admin_footer', array($this, 'deactivate_scripts'));
|
58 |
+
add_action('wp_ajax_pipe_submit_uninstall_reason', array($this, "send_uninstall_reason"));
|
59 |
+
|
60 |
+
include_once( 'includes/class-wf-prodimpexpcsv-system-status-tools.php' );
|
61 |
+
include_once( 'includes/class-wf-prodimpexpcsv-admin-screen.php' );
|
62 |
+
include_once( 'includes/importer/class-wf-prodimpexpcsv-importer.php' );
|
63 |
+
|
64 |
+
if (defined('DOING_AJAX')) {
|
65 |
+
include_once( 'includes/class-wf-prodimpexpcsv-ajax-handler.php' );
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
public function wf_plugin_action_links($links) {
|
70 |
+
$plugin_links = array(
|
71 |
+
'<a href="' . admin_url('admin.php?page=wf_woocommerce_csv_im_ex&tab=export') . '">' . __('Import Export', 'wf_csv_import_export') . '</a>',
|
72 |
+
'<a target="_blank" href="https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/" target="_blank">' . __('Premium Upgrade', 'wf_csv_import_export') . '</a>',
|
73 |
+
'<a target="_blank" href="https://wordpress.org/support/plugin/product-import-export-for-woo/">' . __('Support', 'wf_csv_import_export') . '</a>',
|
74 |
+
'<a target="_blank" href="https://wordpress.org/support/plugin/product-import-export-for-woo/reviews/">' . __('Review', 'wf_csv_import_export') . '</a>',
|
75 |
+
);
|
76 |
+
if (array_key_exists('deactivate', $links)) {
|
77 |
+
$links['deactivate'] = str_replace('<a', '<a class="pipe-deactivate-link"', $links['deactivate']);
|
78 |
+
}
|
79 |
+
return array_merge($plugin_links, $links);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Add screen ID
|
84 |
+
*/
|
85 |
+
public function woocommerce_screen_ids($ids) {
|
86 |
+
$ids[] = 'admin'; // For import screen
|
87 |
+
return $ids;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Handle localization
|
92 |
+
*/
|
93 |
+
public function load_plugin_textdomain() {
|
94 |
+
load_plugin_textdomain('wf_csv_import_export', false, dirname(plugin_basename(__FILE__)) . '/lang/');
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Catches an export request and exports the data. This class is only loaded in admin.
|
99 |
+
*/
|
100 |
+
public function catch_export_request() {
|
101 |
+
|
102 |
+
if (!empty($_GET['action']) && !empty($_GET['page']) && $_GET['page'] == 'wf_woocommerce_csv_im_ex') {
|
103 |
+
switch ($_GET['action']) {
|
104 |
+
case "export" :
|
105 |
+
$user_ok = $this->hf_user_permission();
|
106 |
+
if ($user_ok) {
|
107 |
+
include_once( 'includes/exporter/class-wf-prodimpexpcsv-exporter.php' );
|
108 |
+
WF_ProdImpExpCsv_Exporter::do_export('product');
|
109 |
+
} else {
|
110 |
+
wp_redirect(wp_login_url());
|
111 |
+
}
|
112 |
+
break;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Register importers for use
|
119 |
+
*/
|
120 |
+
public function register_importers() {
|
121 |
+
register_importer('xa_woocommerce_csv', 'XAdapter WooCommerce Product Import (CSV)', __('Import <strong>products</strong> to your store via a csv file.', 'wf_csv_import_export'), 'WF_ProdImpExpCsv_Importer::product_importer');
|
122 |
+
}
|
123 |
+
|
124 |
+
private function hf_user_permission() {
|
125 |
+
// Check if user has rights to export
|
126 |
+
$current_user = wp_get_current_user();
|
127 |
+
$user_ok = false;
|
128 |
+
$wf_roles = apply_filters('hf_user_permission_roles', array('administrator', 'shop_manager'));
|
129 |
+
if ($current_user instanceof WP_User) {
|
130 |
+
$can_users = array_intersect($wf_roles, $current_user->roles);
|
131 |
+
if (!empty($can_users)) {
|
132 |
+
$user_ok = true;
|
133 |
+
}
|
134 |
+
}
|
135 |
+
return $user_ok;
|
136 |
+
}
|
137 |
+
|
138 |
+
private function get_uninstall_reasons() {
|
139 |
+
|
140 |
+
$reasons = array(
|
141 |
+
array(
|
142 |
+
'id' => 'used-it',
|
143 |
+
'text' => __('Used it successfully. Don\'t need anymore.', 'wf_csv_import_export'),
|
144 |
+
'type' => 'reviewhtml',
|
145 |
+
'placeholder' => __('Have used it successfully and aint in need of it anymore', 'wf_csv_import_export')
|
146 |
+
),
|
147 |
+
array(
|
148 |
+
'id' => 'could-not-understand',
|
149 |
+
'text' => __('I couldn\'t understand how to make it work', 'wf_csv_import_export'),
|
150 |
+
'type' => 'textarea',
|
151 |
+
'placeholder' => __('Would you like us to assist you?', 'wf_csv_import_export')
|
152 |
+
),
|
153 |
+
array(
|
154 |
+
'id' => 'found-better-plugin',
|
155 |
+
'text' => __('I found a better plugin', 'wf_csv_import_export'),
|
156 |
+
'type' => 'text',
|
157 |
+
'placeholder' => __('Which plugin?', 'wf_csv_import_export')
|
158 |
+
),
|
159 |
+
array(
|
160 |
+
'id' => 'not-have-that-feature',
|
161 |
+
'text' => __('The plugin is great, but I need specific feature that you don\'t support', 'wf_csv_import_export'),
|
162 |
+
'type' => 'textarea',
|
163 |
+
'placeholder' => __('Could you tell us more about that feature?', 'wf_csv_import_export')
|
164 |
+
),
|
165 |
+
array(
|
166 |
+
'id' => 'is-not-working',
|
167 |
+
'text' => __('The plugin is not working', 'wf_csv_import_export'),
|
168 |
+
'type' => 'textarea',
|
169 |
+
'placeholder' => __('Could you tell us a bit more whats not working?', 'wf_csv_import_export')
|
170 |
+
),
|
171 |
+
array(
|
172 |
+
'id' => 'looking-for-other',
|
173 |
+
'text' => __('It\'s not what I was looking for', 'wf_csv_import_export'),
|
174 |
+
'type' => 'textarea',
|
175 |
+
'placeholder' => __('Could you tell us a bit more?', 'wf_csv_import_export')
|
176 |
+
),
|
177 |
+
array(
|
178 |
+
'id' => 'did-not-work-as-expected',
|
179 |
+
'text' => __('The plugin didn\'t work as expected', 'wf_csv_import_export'),
|
180 |
+
'type' => 'textarea',
|
181 |
+
'placeholder' => __('What did you expect?', 'wf_csv_import_export')
|
182 |
+
),
|
183 |
+
array(
|
184 |
+
'id' => 'other',
|
185 |
+
'text' => __('Other', 'wf_csv_import_export'),
|
186 |
+
'type' => 'textarea',
|
187 |
+
'placeholder' => __('Could you tell us a bit more?', 'wf_csv_import_export')
|
188 |
+
),
|
189 |
+
);
|
190 |
+
|
191 |
+
return $reasons;
|
192 |
+
}
|
193 |
+
|
194 |
+
public function deactivate_scripts() {
|
195 |
+
|
196 |
+
global $pagenow;
|
197 |
+
if ('plugins.php' != $pagenow) {
|
198 |
+
return;
|
199 |
+
}
|
200 |
+
$reasons = $this->get_uninstall_reasons();
|
201 |
+
?>
|
202 |
+
<div class="pipe-modal" id="pipe-pipe-modal">
|
203 |
+
<div class="pipe-modal-wrap">
|
204 |
+
<div class="pipe-modal-header">
|
205 |
+
<h3><?php _e('If you have a moment, please let us know why you are deactivating:', 'wf_csv_import_export'); ?></h3>
|
206 |
+
</div>
|
207 |
+
<div class="pipe-modal-body">
|
208 |
+
<ul class="reasons">
|
209 |
+
<?php foreach ($reasons as $reason) { ?>
|
210 |
+
<li data-type="<?php echo esc_attr($reason['type']); ?>" data-placeholder="<?php echo esc_attr($reason['placeholder']); ?>">
|
211 |
+
<label><input type="radio" name="selected-reason" value="<?php echo $reason['id']; ?>"> <?php echo $reason['text']; ?></label>
|
212 |
+
</li>
|
213 |
+
<?php } ?>
|
214 |
+
</ul>
|
215 |
+
</div>
|
216 |
+
<div class="pipe-modal-footer">
|
217 |
+
<a href="#" class="dont-bother-me"><?php _e('I rather wouldn\'t say', 'wf_csv_import_export'); ?></a>
|
218 |
+
<button class="button-primary pipe-model-submit"><?php _e('Submit & Deactivate', 'wf_csv_import_export'); ?></button>
|
219 |
+
<button class="button-secondary pipe-model-cancel"><?php _e('Cancel', 'wf_csv_import_export'); ?></button>
|
220 |
+
</div>
|
221 |
+
</div>
|
222 |
+
</div>
|
223 |
+
|
224 |
+
<style type="text/css">
|
225 |
+
.pipe-modal {
|
226 |
+
position: fixed;
|
227 |
+
z-index: 99999;
|
228 |
+
top: 0;
|
229 |
+
right: 0;
|
230 |
+
bottom: 0;
|
231 |
+
left: 0;
|
232 |
+
background: rgba(0,0,0,0.5);
|
233 |
+
display: none;
|
234 |
+
}
|
235 |
+
.pipe-modal.modal-active {display: block;}
|
236 |
+
.pipe-modal-wrap {
|
237 |
+
width: 50%;
|
238 |
+
position: relative;
|
239 |
+
margin: 10% auto;
|
240 |
+
background: #fff;
|
241 |
+
}
|
242 |
+
.pipe-modal-header {
|
243 |
+
border-bottom: 1px solid #eee;
|
244 |
+
padding: 8px 20px;
|
245 |
+
}
|
246 |
+
.pipe-modal-header h3 {
|
247 |
+
line-height: 150%;
|
248 |
+
margin: 0;
|
249 |
+
}
|
250 |
+
.pipe-modal-body {padding: 5px 20px 20px 20px;}
|
251 |
+
.pipe-modal-body .input-text,.pipe-modal-body textarea {width:75%;}
|
252 |
+
.pipe-modal-body .reason-input {
|
253 |
+
margin-top: 5px;
|
254 |
+
margin-left: 20px;
|
255 |
+
}
|
256 |
+
.pipe-modal-footer {
|
257 |
+
border-top: 1px solid #eee;
|
258 |
+
padding: 12px 20px;
|
259 |
+
text-align: right;
|
260 |
+
}
|
261 |
+
.reviewlink{
|
262 |
+
padding:10px 0px 0px 35px !important;
|
263 |
+
font-size: 15px;
|
264 |
+
}
|
265 |
+
.review-and-deactivate{
|
266 |
+
padding:5px;
|
267 |
+
}
|
268 |
+
</style>
|
269 |
+
<script type="text/javascript">
|
270 |
+
(function ($) {
|
271 |
+
$(function () {
|
272 |
+
var modal = $('#pipe-pipe-modal');
|
273 |
+
var deactivateLink = '';
|
274 |
+
|
275 |
+
|
276 |
+
$('#the-list').on('click', 'a.pipe-deactivate-link', function (e) {
|
277 |
+
e.preventDefault();
|
278 |
+
modal.addClass('modal-active');
|
279 |
+
deactivateLink = $(this).attr('href');
|
280 |
+
modal.find('a.dont-bother-me').attr('href', deactivateLink).css('float', 'left');
|
281 |
+
});
|
282 |
+
|
283 |
+
$('#pipe-pipe-modal').on('click', 'a.review-and-deactivate', function (e) {
|
284 |
+
e.preventDefault();
|
285 |
+
window.open("https://wordpress.org/support/plugin/product-import-export-for-woo/reviews/#new-post");
|
286 |
+
window.location.href = deactivateLink;
|
287 |
+
});
|
288 |
+
modal.on('click', 'button.pipe-model-cancel', function (e) {
|
289 |
+
e.preventDefault();
|
290 |
+
modal.removeClass('modal-active');
|
291 |
+
});
|
292 |
+
modal.on('click', 'input[type="radio"]', function () {
|
293 |
+
var parent = $(this).parents('li:first');
|
294 |
+
modal.find('.reason-input').remove();
|
295 |
+
var inputType = parent.data('type'),
|
296 |
+
inputPlaceholder = parent.data('placeholder');
|
297 |
+
if('reviewhtml' === inputType) {
|
298 |
+
var reasonInputHtml = '<div class="reviewlink"><a href="#" target="_blank" class="review-and-deactivate"><?php _e('Deactivate and leave a review', 'wf_csv_import_export'); ?> <span class="xa-pipe-rating-link"> ★★★★★ </span></a></div>';
|
299 |
+
}else{
|
300 |
+
var reasonInputHtml = '<div class="reason-input">' + (('text' === inputType) ? '<input type="text" class="input-text" size="40" />' : '<textarea rows="5" cols="45"></textarea>') + '</div>';
|
301 |
+
}
|
302 |
+
if (inputType !== '') {
|
303 |
+
parent.append($(reasonInputHtml));
|
304 |
+
parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus();
|
305 |
+
}
|
306 |
+
});
|
307 |
+
|
308 |
+
modal.on('click', 'button.pipe-model-submit', function (e) {
|
309 |
+
e.preventDefault();
|
310 |
+
var button = $(this);
|
311 |
+
if (button.hasClass('disabled')) {
|
312 |
+
return;
|
313 |
+
}
|
314 |
+
var $radio = $('input[type="radio"]:checked', modal);
|
315 |
+
var $selected_reason = $radio.parents('li:first'),
|
316 |
+
$input = $selected_reason.find('textarea, input[type="text"]');
|
317 |
+
|
318 |
+
$.ajax({
|
319 |
+
url: ajaxurl,
|
320 |
+
type: 'POST',
|
321 |
+
data: {
|
322 |
+
action: 'pipe_submit_uninstall_reason',
|
323 |
+
reason_id: (0 === $radio.length) ? 'none' : $radio.val(),
|
324 |
+
reason_info: (0 !== $input.length) ? $input.val().trim() : ''
|
325 |
+
},
|
326 |
+
beforeSend: function () {
|
327 |
+
button.addClass('disabled');
|
328 |
+
button.text('Processing...');
|
329 |
+
},
|
330 |
+
complete: function () {
|
331 |
+
window.location.href = deactivateLink;
|
332 |
+
}
|
333 |
+
});
|
334 |
+
});
|
335 |
+
});
|
336 |
+
}(jQuery));
|
337 |
+
</script>
|
338 |
+
<?php
|
339 |
+
}
|
340 |
+
|
341 |
+
public function send_uninstall_reason() {
|
342 |
+
|
343 |
+
global $wpdb;
|
344 |
+
|
345 |
+
if (!isset($_POST['reason_id'])) {
|
346 |
+
wp_send_json_error();
|
347 |
+
}
|
348 |
+
|
349 |
+
//$current_user = wp_get_current_user();
|
350 |
+
|
351 |
+
$data = array(
|
352 |
+
'reason_id' => sanitize_text_field($_POST['reason_id']),
|
353 |
+
'plugin' => "productimportexort",
|
354 |
+
'auth' => 'wfpipe_uninstall_1234#',
|
355 |
+
'date' => gmdate("M d, Y h:i:s A"),
|
356 |
+
'url' => home_url(),
|
357 |
+
'user_email' => '',//$current_user->user_email,
|
358 |
+
'reason_info' => isset($_REQUEST['reason_info']) ? trim(stripslashes($_REQUEST['reason_info'])) : '',
|
359 |
+
'software' => $_SERVER['SERVER_SOFTWARE'],
|
360 |
+
'php_version' => phpversion(),
|
361 |
+
'mysql_version' => $wpdb->db_version(),
|
362 |
+
'wp_version' => get_bloginfo('version'),
|
363 |
+
'wc_version' => (!defined('WC_VERSION')) ? '' : WC_VERSION,
|
364 |
+
'locale' => get_locale(),
|
365 |
+
'multisite' => is_multisite() ? 'Yes' : 'No',
|
366 |
+
'wfpipe_version' => WF_PIPE_CURRENT_VERSION
|
367 |
+
);
|
368 |
+
// Write an action/hook here in webtoffe to recieve the data
|
369 |
+
$resp = wp_remote_post('http://feedback.webtoffee.com/wp-json/wfpipe/v1/uninstall', array(
|
370 |
+
'method' => 'POST',
|
371 |
+
'timeout' => 45,
|
372 |
+
'redirection' => 5,
|
373 |
+
'httpversion' => '1.0',
|
374 |
+
'blocking' => false,
|
375 |
+
'headers' => array('user-agent' => 'pipe/' . md5(esc_url(home_url())) . ';'),
|
376 |
+
'body' => $data,
|
377 |
+
'cookies' => array()
|
378 |
+
)
|
379 |
+
);
|
380 |
+
|
381 |
+
wp_send_json_success();
|
382 |
+
}
|
383 |
+
|
384 |
+
}
|
385 |
+
|
386 |
+
endif;
|
387 |
+
|
388 |
+
new WF_Product_Import_Export_CSV();
|
389 |
+
}
|
390 |
+
|
391 |
+
|
392 |
+
|
393 |
+
// Welcome screen tutorial video --> Move this function to inside the class
|
394 |
+
add_action('admin_init', 'impexp_welcome');
|
395 |
+
|
396 |
+
register_activation_hook(__FILE__, 'hf_welcome_screen_activate_basic');
|
397 |
+
|
398 |
+
function hf_welcome_screen_activate_basic() {
|
399 |
+
if (is_plugin_active('product-csv-import-export-for-woocommerce/product-csv-import-export.php')) {
|
400 |
+
deactivate_plugins(basename(__FILE__));
|
401 |
+
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='//support.xadapter.com/'>support.xadapter.com</a>", "wf_csv_import_export"), "", array('back_link' => 1));
|
402 |
+
}
|
403 |
+
update_option('xa_pipe_plugin_installed_date', date('Y-m-d H:i:s'));
|
404 |
+
set_transient('_welcome_screen_activation_redirect', true, 30);
|
405 |
+
}
|
406 |
+
|
407 |
+
if (!function_exists('impexp_welcome')) {
|
408 |
+
|
409 |
+
function impexp_welcome() {
|
410 |
+
if (!get_transient('_welcome_screen_activation_redirect')) {
|
411 |
+
return;
|
412 |
+
}
|
413 |
+
delete_transient('_welcome_screen_activation_redirect');
|
414 |
+
wp_safe_redirect(add_query_arg(array('page' => 'wf_woocommerce_csv_im_ex'), admin_url('admin.php')));
|
415 |
+
}
|
416 |
+
|
417 |
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: xadapter, mujeebur, webtoffee
|
|
3 |
Donate link:
|
4 |
Tags: woocommerce product import, woocommerce import products, woocommerce export products, export woocommerce products, import products into woocommerce
|
5 |
Requires at least: 3.0.1
|
6 |
-
Tested up to: 4.9.
|
7 |
-
Stable tag: 1.4.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -104,7 +104,7 @@ Export Products by Category: You can even choose desired product categories from
|
|
104 |
Export Products by Type: You can selectively export products belonging to specific product types. All you need to do is choose the required product types from the plugin settings page while exporting.
|
105 |
Merge Products: This feature is useful for adding more information to existing products, for example when your existing products get modified. To get the modified product details into your online store, you can update the current product by importing modified product CSV file.
|
106 |
|
107 |
-
Map and Transform: You can map the fields ( WooCommerce fields ) with column headings ( CSV file header ). To map, select the required field under “Map to Column
|
108 |
|
109 |
Cron Job / Scheduled Import Export: WooCommerce Product Import and Export plugin facilitates to schedule the Import and Export of the products. You can auto import the products at regular intervals from CSV which is present on FTP Server by providing starting time and intervals between import. There is an option to skip new products in scheduled import too. You can also auto export the products to FTP in a CSV file at regular intervals. There is also option to use saved mapping files for auto export.
|
110 |
|
@@ -140,7 +140,10 @@ Yes. You can import or export product images along with other details
|
|
140 |
3. Premium Export Settings Screen
|
141 |
|
142 |
== Changelog ==
|
143 |
-
|
|
|
|
|
|
|
144 |
= 1.4.3 =
|
145 |
* Updates: Interface updated.
|
146 |
* Updates: Tested OK with WC 3.3.3
|
@@ -228,6 +231,7 @@ Yes. You can import or export product images along with other details
|
|
228 |
|
229 |
== Upgrade Notice ==
|
230 |
|
231 |
-
= 1.4.
|
232 |
-
*
|
233 |
-
* Updates: Tested OK with WC 3.3.
|
|
3 |
Donate link:
|
4 |
Tags: woocommerce product import, woocommerce import products, woocommerce export products, export woocommerce products, import products into woocommerce
|
5 |
Requires at least: 3.0.1
|
6 |
+
Tested up to: 4.9.6
|
7 |
+
Stable tag: 1.4.4
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
104 |
Export Products by Type: You can selectively export products belonging to specific product types. All you need to do is choose the required product types from the plugin settings page while exporting.
|
105 |
Merge Products: This feature is useful for adding more information to existing products, for example when your existing products get modified. To get the modified product details into your online store, you can update the current product by importing modified product CSV file.
|
106 |
|
107 |
+
Map and Transform: You can map the fields ( WooCommerce fields ) with column headings ( CSV file header ). To map, select the required field under “Map to Column�? by using drop-down list for a particular column heading. An Evaluation field is used to fix/update the required value for the particular field.
|
108 |
|
109 |
Cron Job / Scheduled Import Export: WooCommerce Product Import and Export plugin facilitates to schedule the Import and Export of the products. You can auto import the products at regular intervals from CSV which is present on FTP Server by providing starting time and intervals between import. There is an option to skip new products in scheduled import too. You can also auto export the products to FTP in a CSV file at regular intervals. There is also option to use saved mapping files for auto export.
|
110 |
|
140 |
3. Premium Export Settings Screen
|
141 |
|
142 |
== Changelog ==
|
143 |
+
= 1.4.4 =
|
144 |
+
* Enhancement: Improved parsing.
|
145 |
+
* Updates: Tested OK with WP 4.9.5 and WC 3.3.5
|
146 |
+
* Fixed warnings.
|
147 |
= 1.4.3 =
|
148 |
* Updates: Interface updated.
|
149 |
* Updates: Tested OK with WC 3.3.3
|
231 |
|
232 |
== Upgrade Notice ==
|
233 |
|
234 |
+
= 1.4.4 =
|
235 |
+
* Enhancement: Improved parsing.
|
236 |
+
* Updates: Tested OK with WP 4.9.6 and WC 3.3.5
|
237 |
+
* Fixed warnings.
|