Version Description
- Tested OK with WC 5.6.
Download this release
Release Info
Developer | webtoffee |
Plugin | Product Import Export for WooCommerce |
Version | 2.0.6 |
Comparing to | |
See all releases |
Code changes from version 2.0.5 to 2.0.6
- admin/class-wt-import-export-for-woo-admin.php +33 -1
- admin/js/wt-import-export-for-woo-admin.js +45 -0
- admin/modules/export/assets/js/main.js +11 -1
- admin/modules/export/export.php +2 -2
- admin/modules/history/history.php +1 -1
- admin/modules/history/views/_history_list.php +8 -1
- admin/modules/import/assets/js/main.js +10 -2
- admin/modules/import/import.php +12 -10
- admin/modules/product_review/data/data-product-review-columns.php +30 -0
- admin/modules/product_review/data/data/data-wf-reserved-fields-pair.php +28 -0
- admin/modules/product_review/export/export.php +227 -0
- admin/modules/product_review/import/import.php +575 -0
- admin/modules/product_review/product_review.php +601 -0
- admin/views/admin-settings-advanced.php +3 -0
- admin/views/admin-settings-pre-saved-templates.php +70 -0
- admin/views/market.php +1 -1
- includes/class-wt-import-export-for-woo.php +2 -1
- product-import-export-for-woo.php +4 -4
- readme.txt +7 -5
admin/class-wt-import-export-for-woo-admin.php
CHANGED
@@ -113,6 +113,8 @@ class Wt_Import_Export_For_Woo_Admin_Basic {
|
|
113 |
'settings_success'=>__('Settings updated.'),
|
114 |
'all_fields_mandatory'=>__('All fields are mandatory'),
|
115 |
'settings_error'=>__('Unable to update Settings.'),
|
|
|
|
|
116 |
'value_empty'=>__('Value is empty.'),
|
117 |
'error'=>sprintf(__('An unknown error has occurred! Refer to our %stroubleshooting guide%s for assistance.'), '<a href="'.WT_IEW_DEBUG_BASIC_TROUBLESHOOT.'" target="_blank">', '</a>'),
|
118 |
'success'=>__('Success.'),
|
@@ -237,6 +239,34 @@ class Wt_Import_Export_For_Woo_Admin_Basic {
|
|
237 |
exit();
|
238 |
}
|
239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
/**
|
241 |
Registers modules: admin
|
242 |
*/
|
@@ -275,6 +305,7 @@ class Wt_Import_Export_For_Woo_Admin_Basic {
|
|
275 |
$out[$k]=$m;
|
276 |
}
|
277 |
}
|
|
|
278 |
update_option('wt_iew_admin_modules',$out);
|
279 |
|
280 |
|
@@ -301,6 +332,7 @@ class Wt_Import_Export_For_Woo_Admin_Basic {
|
|
301 |
'order'=>'order-import-export-for-woocommerce',
|
302 |
'coupon'=>'order-import-export-for-woocommerce',
|
303 |
'product'=>'product-import-export-for-woo',
|
|
|
304 |
'user'=>'users-customers-import-export-for-wp-woocommerce',
|
305 |
);
|
306 |
foreach ($addon_modules_basic as $module_key => $module_path)
|
@@ -314,7 +346,7 @@ class Wt_Import_Export_For_Woo_Admin_Basic {
|
|
314 |
require_once $module_file;
|
315 |
}
|
316 |
}
|
317 |
-
}
|
318 |
|
319 |
}
|
320 |
|
113 |
'settings_success'=>__('Settings updated.'),
|
114 |
'all_fields_mandatory'=>__('All fields are mandatory'),
|
115 |
'settings_error'=>__('Unable to update Settings.'),
|
116 |
+
'template_del_error'=>__('Unable to delete template'),
|
117 |
+
'template_del_loader'=>__('Deleting template...'),
|
118 |
'value_empty'=>__('Value is empty.'),
|
119 |
'error'=>sprintf(__('An unknown error has occurred! Refer to our %stroubleshooting guide%s for assistance.'), '<a href="'.WT_IEW_DEBUG_BASIC_TROUBLESHOOT.'" target="_blank">', '</a>'),
|
120 |
'success'=>__('Success.'),
|
239 |
exit();
|
240 |
}
|
241 |
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Delete pre-saved temaplates entry from DB - ajax hook
|
245 |
+
*/
|
246 |
+
public function delete_template() {
|
247 |
+
$out = array(
|
248 |
+
'status' => false,
|
249 |
+
'msg' => __('Error'),
|
250 |
+
);
|
251 |
+
|
252 |
+
if (Wt_Iew_Sh::check_write_access(WT_IEW_PLUGIN_ID_BASIC)) {
|
253 |
+
if (isset($_POST['template_id'])) {
|
254 |
+
|
255 |
+
global $wpdb;
|
256 |
+
$template_id = absint($_POST['template_id']);
|
257 |
+
$tb = $wpdb->prefix . Wt_Import_Export_For_Woo_Basic::$template_tb;
|
258 |
+
$where = "=%d";
|
259 |
+
$where_data = array($template_id);
|
260 |
+
$wpdb->query($wpdb->prepare("DELETE FROM $tb WHERE id" . $where, $where_data));
|
261 |
+
$out['status'] = true;
|
262 |
+
$out['msg'] = __('Template deleted successfully');
|
263 |
+
$out['template_id'] = $template_id;
|
264 |
+
}
|
265 |
+
}
|
266 |
+
wp_send_json($out);
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
/**
|
271 |
Registers modules: admin
|
272 |
*/
|
305 |
$out[$k]=$m;
|
306 |
}
|
307 |
}
|
308 |
+
|
309 |
update_option('wt_iew_admin_modules',$out);
|
310 |
|
311 |
|
332 |
'order'=>'order-import-export-for-woocommerce',
|
333 |
'coupon'=>'order-import-export-for-woocommerce',
|
334 |
'product'=>'product-import-export-for-woo',
|
335 |
+
'product_review'=>'product-import-export-for-woo',
|
336 |
'user'=>'users-customers-import-export-for-wp-woocommerce',
|
337 |
);
|
338 |
foreach ($addon_modules_basic as $module_key => $module_path)
|
346 |
require_once $module_file;
|
347 |
}
|
348 |
}
|
349 |
+
}
|
350 |
|
351 |
}
|
352 |
|
admin/js/wt-import-export-for-woo-admin.js
CHANGED
@@ -123,6 +123,50 @@ var wt_iew_settings_form_basic=
|
|
123 |
});
|
124 |
}
|
125 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
var wt_drp_menu=
|
127 |
{
|
128 |
Set:function()
|
@@ -735,4 +779,5 @@ jQuery(document).ready(function(){
|
|
735 |
wt_iew_file_attacher.Set();
|
736 |
wt_iew_form_toggler.Set();
|
737 |
wt_field_group.Set();
|
|
|
738 |
});
|
123 |
});
|
124 |
}
|
125 |
}
|
126 |
+
|
127 |
+
|
128 |
+
var wt_saved_templates = {
|
129 |
+
Set: function()
|
130 |
+
{
|
131 |
+
jQuery('.wt_ier_delete_template').unbind('click').click(function (e) {
|
132 |
+
e.preventDefault();
|
133 |
+
if(confirm(wt_iew_basic_params.msgs.sure)){
|
134 |
+
|
135 |
+
var template_id = jQuery(this).attr('data-id');
|
136 |
+
|
137 |
+
var data = {
|
138 |
+
_wpnonce: wt_iew_basic_params.nonces.main,
|
139 |
+
action: 'wt_iew_delete_template',
|
140 |
+
template_id: template_id,
|
141 |
+
};
|
142 |
+
jQuery('tr[data-row-id='+data.template_id+']').html('<td colspan="5">'+wt_iew_basic_params.msgs.template_del_loader+'</td>');
|
143 |
+
jQuery.ajax({
|
144 |
+
url: wt_iew_basic_params.ajax_url,
|
145 |
+
type: 'POST',
|
146 |
+
dataType: 'json',
|
147 |
+
data: data,
|
148 |
+
success: function (data)
|
149 |
+
{
|
150 |
+
if (data.status == true)
|
151 |
+
{
|
152 |
+
wt_iew_notify_msg.success(data.msg, true);
|
153 |
+
jQuery('tr[data-row-id='+data.template_id+']').remove();
|
154 |
+
} else
|
155 |
+
{
|
156 |
+
wt_iew_notify_msg.error(data.msg, true);
|
157 |
+
}
|
158 |
+
},
|
159 |
+
error: function ()
|
160 |
+
{
|
161 |
+
wt_iew_notify_msg.error(wt_iew_basic_params.msgs.template_del_error);
|
162 |
+
}
|
163 |
+
});
|
164 |
+
}
|
165 |
+
});
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
|
170 |
var wt_drp_menu=
|
171 |
{
|
172 |
Set:function()
|
779 |
wt_iew_file_attacher.Set();
|
780 |
wt_iew_form_toggler.Set();
|
781 |
wt_field_group.Set();
|
782 |
+
wt_saved_templates.Set();
|
783 |
});
|
admin/modules/export/assets/js/main.js
CHANGED
@@ -695,17 +695,20 @@ var wt_iew_basic_export=(function( $ ) {
|
|
695 |
wt_iew_basic_export.load_pending_steps();
|
696 |
}
|
697 |
});
|
|
|
698 |
}
|
699 |
else if(step=='filter') /* filter page */
|
700 |
{
|
701 |
$('.wc-enhanced-select').select2();
|
702 |
$( document.body ).trigger( 'wc-enhanced-select-init' );
|
|
|
703 |
}
|
704 |
else if(step=='mapping') /* mapping page */
|
705 |
{
|
706 |
this.enable_sortable();
|
707 |
this.mapping_box_accordian();
|
708 |
this.reg_mapping_field_bulk_action();
|
|
|
709 |
}
|
710 |
else if(step=='advanced')
|
711 |
{
|
@@ -759,6 +762,7 @@ var wt_iew_basic_export=(function( $ ) {
|
|
759 |
$('[name="wt_iew_file_as"]').unbind('change').change(function(){
|
760 |
$('.wt_iew_file_ext_info').html('.'+$(this).val());
|
761 |
});
|
|
|
762 |
}
|
763 |
|
764 |
/* common events */
|
@@ -894,7 +898,13 @@ var wt_iew_basic_export=(function( $ ) {
|
|
894 |
'data_type': data_type,
|
895 |
'export_method': this.export_method,
|
896 |
};
|
897 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
898 |
}
|
899 |
return wt_iew_basic_export;
|
900 |
|
695 |
wt_iew_basic_export.load_pending_steps();
|
696 |
}
|
697 |
});
|
698 |
+
wt_iew_basic_export.warn_on_refresh();
|
699 |
}
|
700 |
else if(step=='filter') /* filter page */
|
701 |
{
|
702 |
$('.wc-enhanced-select').select2();
|
703 |
$( document.body ).trigger( 'wc-enhanced-select-init' );
|
704 |
+
wt_iew_basic_export.warn_on_refresh();
|
705 |
}
|
706 |
else if(step=='mapping') /* mapping page */
|
707 |
{
|
708 |
this.enable_sortable();
|
709 |
this.mapping_box_accordian();
|
710 |
this.reg_mapping_field_bulk_action();
|
711 |
+
wt_iew_basic_export.warn_on_refresh();
|
712 |
}
|
713 |
else if(step=='advanced')
|
714 |
{
|
762 |
$('[name="wt_iew_file_as"]').unbind('change').change(function(){
|
763 |
$('.wt_iew_file_ext_info').html('.'+$(this).val());
|
764 |
});
|
765 |
+
wt_iew_basic_export.warn_on_refresh();
|
766 |
}
|
767 |
|
768 |
/* common events */
|
898 |
'data_type': data_type,
|
899 |
'export_method': this.export_method,
|
900 |
};
|
901 |
+
},
|
902 |
+
warn_on_refresh: function () {
|
903 |
+
window.onbeforeunload = function (event)
|
904 |
+
{
|
905 |
+
return confirm("Changes that you made may not be saved.");
|
906 |
+
};
|
907 |
+
}
|
908 |
}
|
909 |
return wt_iew_basic_export;
|
910 |
|
admin/modules/export/export.php
CHANGED
@@ -86,7 +86,7 @@ class Wt_Import_Export_For_Woo_Basic_Export
|
|
86 |
);
|
87 |
|
88 |
/* advanced plugin settings */
|
89 |
-
add_filter('wt_iew_advanced_setting_fields_basic', array($this, 'advanced_setting_fields'));
|
90 |
|
91 |
/* setting default values, this method must be below of advanced setting filter */
|
92 |
$this->get_defaults();
|
@@ -276,7 +276,7 @@ class Wt_Import_Export_For_Woo_Basic_Export
|
|
276 |
'type'=>'text',
|
277 |
'value'=>$this->default_batch_count,
|
278 |
'field_name'=>'batch_count',
|
279 |
-
'help_text'=>sprintf(__('The number of records that the server will process for every iteration within the configured timeout interval. If the export fails due to timeout you can lower this number accordingly and try again. Defaulted to %d records.'),
|
280 |
'validation_rule'=>array('type'=>'absint'),
|
281 |
)
|
282 |
);
|
86 |
);
|
87 |
|
88 |
/* advanced plugin settings */
|
89 |
+
add_filter('wt_iew_advanced_setting_fields_basic', array($this, 'advanced_setting_fields'), 11);
|
90 |
|
91 |
/* setting default values, this method must be below of advanced setting filter */
|
92 |
$this->get_defaults();
|
276 |
'type'=>'text',
|
277 |
'value'=>$this->default_batch_count,
|
278 |
'field_name'=>'batch_count',
|
279 |
+
'help_text'=>sprintf(__('The number of records that the server will process for every iteration within the configured timeout interval. If the export fails due to timeout you can lower this number accordingly and try again. Defaulted to %d records.'), 30),
|
280 |
'validation_rule'=>array('type'=>'absint'),
|
281 |
)
|
282 |
);
|
admin/modules/history/history.php
CHANGED
@@ -47,7 +47,7 @@ class Wt_Import_Export_For_Woo_Basic_History
|
|
47 |
add_filter('wt_iew_admin_menu_basic', array($this, 'add_admin_pages'), 10, 1);
|
48 |
|
49 |
/* advanced plugin settings */
|
50 |
-
add_filter('wt_iew_advanced_setting_fields_basic', array($this, 'advanced_setting_fields'),
|
51 |
|
52 |
/* main ajax hook. The callback function will decide which action is to execute. */
|
53 |
add_action('wp_ajax_iew_history_ajax_basic', array($this, 'ajax_main'), 11);
|
47 |
add_filter('wt_iew_admin_menu_basic', array($this, 'add_admin_pages'), 10, 1);
|
48 |
|
49 |
/* advanced plugin settings */
|
50 |
+
add_filter('wt_iew_advanced_setting_fields_basic', array($this, 'advanced_setting_fields'), 12);
|
51 |
|
52 |
/* main ajax hook. The callback function will decide which action is to execute. */
|
53 |
add_action('wp_ajax_iew_history_ajax_basic', array($this, 'ajax_main'), 11);
|
admin/modules/history/views/_history_list.php
CHANGED
@@ -105,7 +105,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
105 |
<input type="checkbox" name="" class="wt_iew_history_checkbox_main">
|
106 |
<?php _e("No."); ?>
|
107 |
</th>
|
108 |
-
<th><?php _e("Id"); ?></th>
|
109 |
<th><?php _e("Action type"); ?></th>
|
110 |
<th><?php _e("Post type"); ?></th>
|
111 |
<th><?php _e("Started at"); ?></th>
|
@@ -178,6 +178,13 @@ if ( ! defined( 'WPINC' ) ) {
|
|
178 |
<?php
|
179 |
}
|
180 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
?>
|
182 |
</td>
|
183 |
</tr>
|
105 |
<input type="checkbox" name="" class="wt_iew_history_checkbox_main">
|
106 |
<?php _e("No."); ?>
|
107 |
</th>
|
108 |
+
<th width="50"><?php _e("Id"); ?></th>
|
109 |
<th><?php _e("Action type"); ?></th>
|
110 |
<th><?php _e("Post type"); ?></th>
|
111 |
<th><?php _e("Started at"); ?></th>
|
178 |
<?php
|
179 |
}
|
180 |
}
|
181 |
+
if($action_type=='export' && Wt_Import_Export_For_Woo_Admin_Basic::module_exists($action_type))
|
182 |
+
{
|
183 |
+
$export_download_url=wp_nonce_url(admin_url('admin.php?wt_iew_export_download=true&file='.$history_item['file_name']), WT_IEW_PLUGIN_ID_BASIC);
|
184 |
+
?>
|
185 |
+
| <a class="wt_iew_export_download_btn" target="_blank" href="<?php echo $export_download_url;?>"><?php _e('Download');?></a>
|
186 |
+
<?php
|
187 |
+
}
|
188 |
?>
|
189 |
</td>
|
190 |
</tr>
|
admin/modules/import/assets/js/main.js
CHANGED
@@ -869,6 +869,7 @@ var wt_iew_basic_import=(function( $ ) {
|
|
869 |
wt_iew_dropzone.init('wt_iew_local_file_dropzone');
|
870 |
/* Auto populate template file. */
|
871 |
wt_iew_dropzone.auto_populate();
|
|
|
872 |
}
|
873 |
else if(step=='mapping') /* mapping page */
|
874 |
{
|
@@ -876,10 +877,11 @@ var wt_iew_basic_import=(function( $ ) {
|
|
876 |
this.mapping_box_accordian();
|
877 |
this.reg_mapping_field_bulk_action();
|
878 |
wt_iew_popover.Set();
|
|
|
879 |
}
|
880 |
else if(step=='advanced')
|
881 |
{
|
882 |
-
|
883 |
}
|
884 |
|
885 |
/* common events */
|
@@ -1040,7 +1042,13 @@ var wt_iew_basic_import=(function( $ ) {
|
|
1040 |
is_object:function(obj)
|
1041 |
{
|
1042 |
return obj !== undefined && obj !== null && obj.constructor == Object;
|
1043 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1044 |
}
|
1045 |
|
1046 |
var mapping_field_editor=
|
869 |
wt_iew_dropzone.init('wt_iew_local_file_dropzone');
|
870 |
/* Auto populate template file. */
|
871 |
wt_iew_dropzone.auto_populate();
|
872 |
+
wt_iew_basic_import.warn_on_refresh();
|
873 |
}
|
874 |
else if(step=='mapping') /* mapping page */
|
875 |
{
|
877 |
this.mapping_box_accordian();
|
878 |
this.reg_mapping_field_bulk_action();
|
879 |
wt_iew_popover.Set();
|
880 |
+
wt_iew_basic_import.warn_on_refresh();
|
881 |
}
|
882 |
else if(step=='advanced')
|
883 |
{
|
884 |
+
wt_iew_basic_import.warn_on_refresh();
|
885 |
}
|
886 |
|
887 |
/* common events */
|
1042 |
is_object:function(obj)
|
1043 |
{
|
1044 |
return obj !== undefined && obj !== null && obj.constructor == Object;
|
1045 |
+
},
|
1046 |
+
warn_on_refresh: function () {
|
1047 |
+
window.onbeforeunload = function (event)
|
1048 |
+
{
|
1049 |
+
return confirm("Changes that you made may not be saved.");
|
1050 |
+
};
|
1051 |
+
}
|
1052 |
}
|
1053 |
|
1054 |
var mapping_field_editor=
|
admin/modules/import/import.php
CHANGED
@@ -105,7 +105,17 @@ class Wt_Import_Export_For_Woo_Basic_Import
|
|
105 |
*/
|
106 |
public function advanced_setting_fields($fields)
|
107 |
{
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
'label'=>__("Generate Import log"),
|
110 |
'type'=>'radio',
|
111 |
'radio_fields'=>array(
|
@@ -137,15 +147,7 @@ class Wt_Import_Export_For_Woo_Basic_Import
|
|
137 |
'validation_rule'=>array('type'=>'absint'),
|
138 |
);
|
139 |
|
140 |
-
|
141 |
-
'label' => __("Maximum execution time"),
|
142 |
-
'type' => 'number',
|
143 |
-
'value' => ini_get('max_execution_time'), /* Default max_execution_time settings value */
|
144 |
-
'field_name' => 'maximum_execution_time',
|
145 |
-
'field_group' => 'advanced_field',
|
146 |
-
'help_text' => __('The maximum execution time, in seconds(eg:- 300, 600, 1800, 3600). If set to zero, no time limit is imposed. Increasing this will reduce the chance of export/import timeouts.'),
|
147 |
-
'validation_rule' => array('type' => 'int'),
|
148 |
-
);
|
149 |
|
150 |
return $fields;
|
151 |
}
|
105 |
*/
|
106 |
public function advanced_setting_fields($fields)
|
107 |
{
|
108 |
+
|
109 |
+
$fields['maximum_execution_time'] = array(
|
110 |
+
'label' => __("Maximum execution time"),
|
111 |
+
'type' => 'number',
|
112 |
+
'value' => ini_get('max_execution_time'), /* Default max_execution_time settings value */
|
113 |
+
'field_name' => 'maximum_execution_time',
|
114 |
+
'field_group' => 'advanced_field',
|
115 |
+
'help_text' => __('The maximum execution time, in seconds(eg:- 300, 600, 1800, 3600). If set to zero, no time limit is imposed. Increasing this will reduce the chance of export/import timeouts.'),
|
116 |
+
'validation_rule' => array('type' => 'int'),
|
117 |
+
);
|
118 |
+
$fields['enable_import_log']=array(
|
119 |
'label'=>__("Generate Import log"),
|
120 |
'type'=>'radio',
|
121 |
'radio_fields'=>array(
|
147 |
'validation_rule'=>array('type'=>'absint'),
|
148 |
);
|
149 |
|
150 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
return $fields;
|
153 |
}
|
admin/modules/product_review/data/data-product-review-columns.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('WPINC')) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
return apply_filters('product_reviews_csv_product_post_columns', array(
|
8 |
+
'comment_ID' => 'comment_ID',
|
9 |
+
'comment_post_ID' => 'comment_post_ID',
|
10 |
+
'comment_author' => 'comment_author',
|
11 |
+
'comment_author_email' => 'comment_author_email',
|
12 |
+
'comment_author_url' => 'comment_author_url',
|
13 |
+
'comment_author_IP' => 'comment_author_IP',
|
14 |
+
'comment_date' => 'comment_date',
|
15 |
+
'comment_date_gmt' => 'comment_date_gmt',
|
16 |
+
'comment_content' => 'comment_content',
|
17 |
+
//'comment_karma' => 'comment_karma',
|
18 |
+
'comment_approved' => 'comment_approved',
|
19 |
+
'comment_parent' => 'comment_parent',
|
20 |
+
'user_id' => 'user_id',
|
21 |
+
//Meta
|
22 |
+
'rating' => 'rating',
|
23 |
+
'verified' => 'verified',
|
24 |
+
'title' => 'title',
|
25 |
+
//Product SKU associated with the comment
|
26 |
+
'product_SKU' => 'product_SKU', //comment_post_ID must be exported to export Product SKU
|
27 |
+
'product_title' => 'product_title', //comment_post_ID must be exported to export Product Title
|
28 |
+
'comment_alter_id' => 'comment_alter_id',
|
29 |
+
// 'meta'=>'meta',
|
30 |
+
));
|
admin/modules/product_review/data/data/data-wf-reserved-fields-pair.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Reserved column names
|
4 |
+
return apply_filters('woocommerce_csv_product_review_import_reserved_fields_pair', array(
|
5 |
+
|
6 |
+
'comment_ID' => array('title'=>'Comments ID','description'=>'ID of the comments'),
|
7 |
+
'product_SKU' => array('title'=>'Product SKU','description'=>'Product SKU'),
|
8 |
+
'comment_post_ID' => array('title'=>'Comment Post ID','description'=>'ID of the product, on which the comment is done'),
|
9 |
+
'comment_author' => array('title'=>'Comments Author Name','description'=>'The author name, who made comments'),
|
10 |
+
'comment_author_url' => array('title'=>'Comments Author URL','description'=>'The author URL, who made comments'),
|
11 |
+
'comment_author_email' => array('title'=>'Comments Author Email','description'=>'The author email, who made comments'),
|
12 |
+
'comment_author_IP' => array('title'=>'Comments Author IP','description'=>'The author IP, who made comments'),
|
13 |
+
'comment_date' => array('title'=>'Comments Date','description'=>'The date, when comments is done', 'type' => 'date'),
|
14 |
+
'comment_date_gmt' => array('title'=>'Comments Date(GMT)','description'=>'The date, when comments is done', 'type' => 'date'),
|
15 |
+
'comment_content' => array('title'=>'Comments Content','description'=>'The content of the comments'),
|
16 |
+
//'comment_karma' => array('title'=>'comment_karma',
|
17 |
+
'comment_approved' => array('title'=>'Comments Approved or Not?','description'=>'1, for YES and 0, for NO'),
|
18 |
+
'comment_parent' => array('title'=>'Comments Parent','description'=>'The parent comments id'),
|
19 |
+
'user_id' => array('title'=>'User ID','description'=>'The user id who comments, if the user is GUEST USER then it is 0'),
|
20 |
+
|
21 |
+
//Meta
|
22 |
+
|
23 |
+
'rating' => array('title'=>'Rating','description'=>'1: for 1 star, 2: for 2 star,...'),
|
24 |
+
'verified' => array('title'=>'Verified or Not?','description'=>'1: for verified, 0: for non-verified'),
|
25 |
+
'title' => array('title'=>'Review title','description'=>' Review title'),
|
26 |
+
'comment_alter_id' => array('title'=>'Comment Alteration ID','description'=>'System generated'),
|
27 |
+
|
28 |
+
));
|
admin/modules/product_review/export/export.php
ADDED
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('WPINC')) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
class Wt_Import_Export_For_Woo_Basic_Product_Review_Export {
|
8 |
+
|
9 |
+
public $parent_module = null;
|
10 |
+
|
11 |
+
public function __construct($parent_object) {
|
12 |
+
|
13 |
+
$this->parent_module = $parent_object;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function prepare_header() {
|
17 |
+
|
18 |
+
$export_columns = $this->parent_module->get_selected_column_names();
|
19 |
+
|
20 |
+
return apply_filters('wt_alter_product_reviews_export_csv_columns', $export_columns);
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Prepare data that will be exported.
|
25 |
+
*/
|
26 |
+
public function prepare_data_to_export($form_data, $batch_offset) {
|
27 |
+
if (!function_exists('get_current_screen')) {
|
28 |
+
require_once(ABSPATH . 'wp-admin/includes/screen.php');
|
29 |
+
}
|
30 |
+
|
31 |
+
$export_reply = !empty($form_data['filter_form_data']['reply']) ? '1' : '';
|
32 |
+
$stars = !empty($form_data['filter_form_data']['wt_iew_stars']) ? $form_data['filter_form_data']['wt_iew_stars'] : '';
|
33 |
+
$owner = !empty($form_data['filter_form_data']['wt_iew_owner']) ? $form_data['filter_form_data']['wt_iew_owner'] : '';
|
34 |
+
$products = !empty($form_data['filter_form_data']['wt_iew_product']) ? $form_data['filter_form_data']['wt_iew_product'] : '';
|
35 |
+
$pr_rev_date_from = !empty($form_data['filter_form_data']['wt_iew_date_from']) ? $form_data['filter_form_data']['wt_iew_date_from'] : date('Y-m-d 00:00', 0);
|
36 |
+
$pr_rev_date_to = !empty($form_data['filter_form_data']['wt_iew_date_to']) ? $form_data['filter_form_data']['wt_iew_date_to'] : date('Y-m-d 23:59', current_time('timestamp'));
|
37 |
+
$pr_rev_status = !empty($form_data['filter_form_data']['wt_iew_status']) ? $form_data['filter_form_data']['wt_iew_status'] : '';
|
38 |
+
$sortcolumn = !empty($form_data['filter_form_data']['wt_iew_sort_columns']) ? $form_data['filter_form_data']['wt_iew_sort_columns'] : 'comment_ID';
|
39 |
+
$export_sort_order = !empty($form_data['filter_form_data']['wt_iew_order_by']) ? $form_data['filter_form_data']['wt_iew_order_by'] : 'ASC';
|
40 |
+
|
41 |
+
$export_limit = !empty($form_data['filter_form_data']['wt_iew_limit']) ? intval($form_data['filter_form_data']['wt_iew_limit']) : 999999999; //user limit
|
42 |
+
$current_offset = !empty($form_data['filter_form_data']['wt_iew_offset']) ? intval($form_data['filter_form_data']['wt_iew_offset']) : 0; //user offset
|
43 |
+
$batch_count = !empty($form_data['advanced_form_data']['wt_iew_batch_count']) ? $form_data['advanced_form_data']['wt_iew_batch_count'] : Wt_Import_Export_For_Woo_Common_Helper::get_advanced_settings('default_export_batch');
|
44 |
+
|
45 |
+
|
46 |
+
$real_offset = ($current_offset + $batch_offset);
|
47 |
+
|
48 |
+
if($batch_count<=$export_limit)
|
49 |
+
{
|
50 |
+
if(($batch_offset+$batch_count)>$export_limit) //last offset
|
51 |
+
{
|
52 |
+
$limit=$export_limit-$batch_offset;
|
53 |
+
}else
|
54 |
+
{
|
55 |
+
$limit=$batch_count;
|
56 |
+
}
|
57 |
+
}else
|
58 |
+
{
|
59 |
+
$limit=$export_limit;
|
60 |
+
}
|
61 |
+
|
62 |
+
$data_array = array();
|
63 |
+
if ($batch_offset < $export_limit)
|
64 |
+
{
|
65 |
+
|
66 |
+
$args = array(
|
67 |
+
'orderby' => $sortcolumn,
|
68 |
+
'order' => $export_sort_order,
|
69 |
+
'post_type' => 'product',
|
70 |
+
'date_query' => array(
|
71 |
+
array(
|
72 |
+
'before' => $pr_rev_date_to,
|
73 |
+
'after' => $pr_rev_date_from,
|
74 |
+
'inclusive' => true,
|
75 |
+
),
|
76 |
+
),
|
77 |
+
);
|
78 |
+
if($pr_rev_status){
|
79 |
+
$args['post_status'] = $pr_rev_status;
|
80 |
+
}
|
81 |
+
|
82 |
+
// if($export_reply == ''){
|
83 |
+
// $args['hierarchical'] = 'threaded'; // threaded flat
|
84 |
+
// }
|
85 |
+
|
86 |
+
// if (!empty($selected_pr_rev_ids)) {
|
87 |
+
// $args['comment__in'] = $selected_pr_rev_ids;
|
88 |
+
// }
|
89 |
+
if (!empty($products)) {
|
90 |
+
$args['post__in'] = implode(',', $products);
|
91 |
+
}
|
92 |
+
|
93 |
+
if (!empty($stars)) {
|
94 |
+
$args['meta_query'][] = array('key' => 'rating', 'value' => $stars);
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
if (!empty($owner)) {
|
99 |
+
if ($owner == 'verified') {
|
100 |
+
$args['author__not_in'] = array(0);
|
101 |
+
}
|
102 |
+
if ($owner == 'non-verified') {
|
103 |
+
$args['user_id'] = 0;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
$args = apply_filters('product_reviews_csv_product_export_args', $args);
|
108 |
+
$args['offset'] = $real_offset;
|
109 |
+
$args['number'] = $limit;
|
110 |
+
|
111 |
+
$args['hierarchical'] = 'threaded';
|
112 |
+
|
113 |
+
$comments_query = new WP_Comment_Query;
|
114 |
+
$comments = $comments_query->query($args);
|
115 |
+
|
116 |
+
foreach ($comments as $comment) {
|
117 |
+
$data_array[] = $this->hf_import_to_csv($comment, $comments);
|
118 |
+
|
119 |
+
if ($export_reply === '1') {
|
120 |
+
$sub_reply = get_comments(array('parent' => $comment->comment_ID));
|
121 |
+
if (!empty($sub_reply)) {
|
122 |
+
foreach ($sub_reply as $reply) {
|
123 |
+
$data_array[] = $this->hf_import_to_csv($reply,$sub_reply);
|
124 |
+
}
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
/**
|
129 |
+
* taking total records
|
130 |
+
*/
|
131 |
+
$total_records=0;
|
132 |
+
if($batch_offset==0) //first batch
|
133 |
+
{
|
134 |
+
$total_item_args=$args;
|
135 |
+
$total_item_args['number']=$export_limit; //user given limit
|
136 |
+
$total_item_args['offset']=$current_offset; //user given offset
|
137 |
+
$comments_query = new WP_Comment_Query;
|
138 |
+
$items_found = $comments_query->query($total_item_args);
|
139 |
+
$total_records = count($items_found);
|
140 |
+
}
|
141 |
+
|
142 |
+
$return['total'] = $total_records;
|
143 |
+
$return['data'] = $data_array;
|
144 |
+
return $return;
|
145 |
+
}
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
public function hf_import_to_csv($comment, $comments) {
|
150 |
+
$row = array();
|
151 |
+
|
152 |
+
$csv_columns = $this->parent_module->get_selected_column_names();
|
153 |
+
$found_review_meta = $this->parent_module->wt_get_found_product_meta();
|
154 |
+
|
155 |
+
$comment_ID = $comment->comment_ID;
|
156 |
+
|
157 |
+
$comment->meta = new stdClass;
|
158 |
+
$comment->meta->rating = get_comment_meta($comment_ID, 'rating', true);
|
159 |
+
$comment->meta->verified = get_comment_meta($comment_ID, 'verified', true);
|
160 |
+
$comment->meta->title = get_comment_meta($comment_ID, 'title', true);
|
161 |
+
|
162 |
+
if (!empty($found_review_meta)) {
|
163 |
+
foreach ($found_review_meta as $comment_metas) {
|
164 |
+
$comment->meta->{$comment_metas} = get_comment_meta($comment_ID, $comment_metas, true);
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
foreach ($csv_columns as $column => $value) {
|
169 |
+
|
170 |
+
if ($column === 'comment_alter_id') {
|
171 |
+
$row[$column] = $comment_ID;
|
172 |
+
continue;
|
173 |
+
}
|
174 |
+
|
175 |
+
if ('meta' == $column) {
|
176 |
+
foreach ($found_review_meta as $commentmeta) {
|
177 |
+
if (isset($comment->meta->$commentmeta)) {
|
178 |
+
$row[$column] = ($comment->meta->$commentmeta);
|
179 |
+
} else {
|
180 |
+
$row[$column] = '';
|
181 |
+
}
|
182 |
+
}
|
183 |
+
continue;
|
184 |
+
}
|
185 |
+
if (isset($comment->meta->$column)) {
|
186 |
+
$row[$column] = ($comment->meta->$column);
|
187 |
+
continue;
|
188 |
+
}
|
189 |
+
|
190 |
+
if (isset($comment->$column) && !is_array($comment->$column)) {
|
191 |
+
if ($column === 'comment_post_ID') {
|
192 |
+
$temp_product_id = sanitize_text_field($comment->$column);
|
193 |
+
// continue;
|
194 |
+
}
|
195 |
+
if ($column === 'user_id') {
|
196 |
+
if (($comment->user_id == 0)) {
|
197 |
+
$user_details = get_user_by('email', $comment->comment_author_email);
|
198 |
+
$row[$column] = is_object($user_details) ? $user_details->ID : 0;
|
199 |
+
continue;
|
200 |
+
} else {
|
201 |
+
$row[$column] = $comment->$column;
|
202 |
+
continue;
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
$row[$column] = ($comment->$column);
|
207 |
+
continue;
|
208 |
+
}
|
209 |
+
if ($column == 'product_title' && !empty($temp_product_id)) {
|
210 |
+
$temp_product_object = ( isset($temp_product_id) && WC()->version >= '3.0') ? wc_get_product($temp_product_id) : get_product($temp_product_id);
|
211 |
+
$row[$column] = $temp_product_object->get_title();
|
212 |
+
continue;
|
213 |
+
}
|
214 |
+
|
215 |
+
if ($column === 'product_SKU' && !empty($temp_product_id)) {
|
216 |
+
$row[$column] = (string) get_post_meta($temp_product_id, '_sku', true);
|
217 |
+
continue;
|
218 |
+
}
|
219 |
+
|
220 |
+
}
|
221 |
+
|
222 |
+
$row = apply_filters('wt_alter_product_reviews_export_csv_data', $row, $comment->ID,$csv_columns);
|
223 |
+
return $row;
|
224 |
+
|
225 |
+
}
|
226 |
+
|
227 |
+
}
|
admin/modules/product_review/import/import.php
ADDED
@@ -0,0 +1,575 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('WPINC')) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
class Wt_Import_Export_For_Woo_Basic_Product_Review_Import {
|
8 |
+
|
9 |
+
public $parent_module = null;
|
10 |
+
public $parsed_data = array();
|
11 |
+
|
12 |
+
var $merge;
|
13 |
+
var $skip_new;
|
14 |
+
var $use_sku;
|
15 |
+
var $cmd_type;
|
16 |
+
var $merge_empty_cells;
|
17 |
+
var $delete_existing;
|
18 |
+
var $new_id = array();
|
19 |
+
var $parent_data = '';
|
20 |
+
var $csv_last_start = '';
|
21 |
+
|
22 |
+
var $processed_posts = array();
|
23 |
+
// Results
|
24 |
+
var $import_results = array();
|
25 |
+
|
26 |
+
public $is_comment_exist = false;
|
27 |
+
|
28 |
+
var $row;
|
29 |
+
var $post_defaults; // Default post data
|
30 |
+
var $postmeta_defaults; // default post meta
|
31 |
+
var $postmeta_allowed; // post meta validation
|
32 |
+
|
33 |
+
public function __construct($parent_object) {
|
34 |
+
|
35 |
+
$this->parent_module = $parent_object;
|
36 |
+
|
37 |
+
// if (WC()->version < '2.7.0') {
|
38 |
+
// $this->log = new WC_Logger();
|
39 |
+
// } else {
|
40 |
+
// $this->log = wc_get_logger();
|
41 |
+
// }
|
42 |
+
|
43 |
+
$this->post_defaults = apply_filters('alter_review_export_fields', array(
|
44 |
+
'comment_ID' => '',
|
45 |
+
'comment_post_ID' => '',
|
46 |
+
'comment_author' => '',
|
47 |
+
'comment_author_url' => '',
|
48 |
+
'comment_author_email' => '',
|
49 |
+
'comment_author_IP' => '',
|
50 |
+
'comment_date' => '',
|
51 |
+
'comment_date_gmt' => '',
|
52 |
+
'comment_content' => '',
|
53 |
+
'comment_approved' => '',
|
54 |
+
'comment_parent' => '',
|
55 |
+
'user_id' => '',
|
56 |
+
'comment_alter_id' => '',
|
57 |
+
'rating' => '',
|
58 |
+
));
|
59 |
+
$this->postmeta_defaults = apply_filters( 'product_reviews_csv_product_postmeta_defaults', array(
|
60 |
+
'rating' => '',
|
61 |
+
'verified' => '',
|
62 |
+
'title' => ''
|
63 |
+
) );
|
64 |
+
$this->postmeta_allowed = apply_filters( 'product_reviews_csv_product_postmeta_allowed',array(
|
65 |
+
'rating' => array(1,2,3,4,5),
|
66 |
+
'verified' => array(0,1)
|
67 |
+
));
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
public function hf_log_data_change($content = 'review-csv-import', $data = '') {
|
72 |
+
// $content = 'wt-revamp-review-csv-import';
|
73 |
+
// if (WC()->version < '2.7.0') {
|
74 |
+
// $this->log->add($content, $data);
|
75 |
+
// } else {
|
76 |
+
// $context = array('source' => $content);
|
77 |
+
// $this->log->log("debug", $data, $context);
|
78 |
+
// }
|
79 |
+
|
80 |
+
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', $data);
|
81 |
+
}
|
82 |
+
|
83 |
+
public function prepare_data_to_import($import_data,$form_data,$batch_offset,$is_last_batch){
|
84 |
+
|
85 |
+
$this->merge = isset($form_data['advanced_form_data']['wt_iew_merge']) ? $form_data['advanced_form_data']['wt_iew_merge'] : 0;
|
86 |
+
$this->skip_new = isset($form_data['advanced_form_data']['wt_iew_skip_new']) ? $form_data['advanced_form_data']['wt_iew_skip_new'] : 0;
|
87 |
+
$this->merge_empty_cells = isset($form_data['advanced_form_data']['wt_iew_merge_empty_cells']) ? $form_data['advanced_form_data']['wt_iew_merge_empty_cells'] : 0;
|
88 |
+
// $this->delete_existing = !empty($form_data['advanced_form_data']['wt_iew_delete_existing']) ? 1 : 0;
|
89 |
+
$this->use_sku = isset($form_data['advanced_form_data']['wt_iew_use_sku']) ? $form_data['advanced_form_data']['wt_iew_use_sku'] : 0;
|
90 |
+
|
91 |
+
wp_defer_term_counting(true);
|
92 |
+
wp_defer_comment_counting(true);
|
93 |
+
wp_suspend_cache_invalidation(true);
|
94 |
+
|
95 |
+
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Preparing for import.");
|
96 |
+
|
97 |
+
$success = 0;
|
98 |
+
$failed = 0;
|
99 |
+
$msg = 'Product Review imported successfully.';
|
100 |
+
foreach ($import_data as $key => $data) {
|
101 |
+
$row = $batch_offset+$key+1;
|
102 |
+
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - Parsing item.");
|
103 |
+
$parsed_data = $this->parse_product_review($data, $this->merge);
|
104 |
+
if (!is_wp_error($parsed_data)){
|
105 |
+
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - Processing item.");
|
106 |
+
$result = $this->process_product_reviews($parsed_data);
|
107 |
+
if(!is_wp_error($result)){
|
108 |
+
if($this->is_comment_exist){
|
109 |
+
$msg = 'Product Review updated successfully.';
|
110 |
+
}
|
111 |
+
$this->import_results[$row] = array('row'=>$row, 'message'=>$msg, 'status'=>true, 'post_id'=>$result['id']);
|
112 |
+
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - ".$msg);
|
113 |
+
$success++;
|
114 |
+
}else{
|
115 |
+
$this->import_results[$row] = array('row'=>$row, 'message'=>$result->get_error_message(), 'status'=>false, 'post_id'=>'');
|
116 |
+
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - Prosessing failed. Reason: ".$result->get_error_message());
|
117 |
+
$failed++;
|
118 |
+
}
|
119 |
+
}else{
|
120 |
+
$this->import_results[$row] = array('row'=>$row, 'message'=>$parsed_data->get_error_message(), 'status'=>false, 'post_id'=>'');
|
121 |
+
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - Parsing failed. Reason: ".$parsed_data->get_error_message());
|
122 |
+
$failed++;
|
123 |
+
}
|
124 |
+
unset($data, $parsed_data);
|
125 |
+
}
|
126 |
+
|
127 |
+
$this->clean_after_import();
|
128 |
+
|
129 |
+
$import_response=array(
|
130 |
+
'total_success'=>$success,
|
131 |
+
'total_failed'=>$failed,
|
132 |
+
'log_data'=>$this->import_results,
|
133 |
+
);
|
134 |
+
|
135 |
+
return $import_response;
|
136 |
+
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Parse product review
|
141 |
+
* @param array $item
|
142 |
+
* @param integer $merge_empty_cells
|
143 |
+
* @return array
|
144 |
+
*/
|
145 |
+
public function parse_product_review( $data, $merge ) {
|
146 |
+
try {
|
147 |
+
$data = apply_filters('wt_woocommerce_product_review_importer_pre_parse_data', $data);
|
148 |
+
$item = $data['mapping_fields'];
|
149 |
+
foreach ($data['meta_mapping_fields'] as $value) {
|
150 |
+
$item = array_merge($item,$value);
|
151 |
+
}
|
152 |
+
|
153 |
+
global $wpdb;
|
154 |
+
$this->row++;
|
155 |
+
$postmeta = $product_review = array();
|
156 |
+
$post_id = ( ! empty( $item['comment_ID'] ) ) ? $item['comment_ID'] : 0;
|
157 |
+
|
158 |
+
// Check if post exists when importing
|
159 |
+
$found_review_id = $this->product_review_exists($post_id);
|
160 |
+
|
161 |
+
if ( $merge ) {
|
162 |
+
$product_review['merging'] = true;
|
163 |
+
$this->hf_log_data_change( 'review-csv-import', sprintf('> Row %s - preparing for merge.', $this->row ) );
|
164 |
+
|
165 |
+
// Required fields
|
166 |
+
if ( ! $found_review_id )
|
167 |
+
{
|
168 |
+
$this->hf_log_data_change( 'review-csv-import', '> > Cannot merge without id. Importing instead.' );
|
169 |
+
$merge = false;
|
170 |
+
}
|
171 |
+
else
|
172 |
+
{
|
173 |
+
|
174 |
+
if ( ! $found_review_id )
|
175 |
+
{
|
176 |
+
if($this->skip_new){
|
177 |
+
$this->hf_log_data_change( 'review-csv-import', '> > Skipping new item.' );
|
178 |
+
return new WP_Error( 'parse-error', 'Skipping new item on merge.' );
|
179 |
+
}
|
180 |
+
$this->hf_log_data_change( 'review-csv-import', sprintf('> > Skipped. Cannot find product reviews with ID %s. Importing instead.', $item['comment_ID']) );
|
181 |
+
$merge = false;
|
182 |
+
|
183 |
+
}
|
184 |
+
else
|
185 |
+
{
|
186 |
+
$this->is_comment_exist = true;
|
187 |
+
$post_id = $found_review_id;
|
188 |
+
$this->hf_log_data_change( 'review-csv-import', sprintf('> > Found product reviews with ID %s.', $post_id) );
|
189 |
+
}
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
if ( ! $merge ) {
|
194 |
+
|
195 |
+
$product_review['merging'] = false;
|
196 |
+
$this->hf_log_data_change( 'review-csv-import', sprintf('> Row %s - preparing for import.', $this->row ) );
|
197 |
+
|
198 |
+
|
199 |
+
if ($found_review_id) {
|
200 |
+
$usr_msg = "Product review skipped. Review with $found_review_id is alredy exists";
|
201 |
+
$this->hf_log_data_change('review-csv-import', sprintf('> “%s”' . $usr_msg, esc_html($found_review_id)), true);
|
202 |
+
return new WP_Error( 'parse-error', sprintf('> “%s”' . $usr_msg, esc_html($found_review_id)) );
|
203 |
+
}
|
204 |
+
|
205 |
+
|
206 |
+
// Required fields
|
207 |
+
if ( !isset($item['comment_content']) || $item['comment_content'] === '')
|
208 |
+
{
|
209 |
+
$this->hf_log_data_change( 'review-csv-import', '> > Skipped. No comment content set for new product reviews.' );
|
210 |
+
return new WP_Error( 'parse-error', 'No comment content set for new product reviews.' );
|
211 |
+
}
|
212 |
+
|
213 |
+
if($this->use_sku == 1 && (!isset($item['product_SKU']) || $item['product_SKU'] === ''))
|
214 |
+
{
|
215 |
+
$this->hf_log_data_change( 'review-csv-import', '> > Skipped. No Product SKU given, for which new comment is to be imported');
|
216 |
+
return new WP_Error( 'parse-error', __( 'Product SKU is empty, Skipped the review.', 'wf_csv_import_export' ) );
|
217 |
+
}
|
218 |
+
elseif ( $this->use_sku == 0 && ( !isset($item['comment_post_ID']) || $item['comment_post_ID'] === '') )
|
219 |
+
{
|
220 |
+
$this->hf_log_data_change( 'review-csv-import','> > Skipped. No post(product) id found, for which new comment is to be imported' );
|
221 |
+
return new WP_Error( 'parse-error', 'No product id found, Skipped the review.', 'wf_csv_import_export' );
|
222 |
+
}
|
223 |
+
|
224 |
+
if($this->skip_new){
|
225 |
+
$this->hf_log_data_change( 'review-csv-import', '> > Skipping new item.' );
|
226 |
+
return new WP_Error( 'parse-error', 'Skipping new item import.' );
|
227 |
+
}
|
228 |
+
}
|
229 |
+
|
230 |
+
if($this->use_sku == 1 && $item['product_SKU'])
|
231 |
+
{
|
232 |
+
$temp_product_id = wc_get_product_id_by_sku( $item['product_SKU'] );
|
233 |
+
if(! $temp_product_id)
|
234 |
+
{
|
235 |
+
$this->hf_log_data_change( 'review-csv-import', '> > Skipped. No Product found for given SKU, for which new comment is to be imported');
|
236 |
+
return new WP_Error( 'parse-error', 'No Product found for given SKU, Skipped the review.');
|
237 |
+
}
|
238 |
+
}
|
239 |
+
elseif($item['comment_post_ID'] )
|
240 |
+
{
|
241 |
+
$temp_post = get_post( $item['comment_post_ID'] );
|
242 |
+
if(! $temp_post || $temp_post->post_type != 'product')
|
243 |
+
{
|
244 |
+
$this->hf_log_data_change( 'review-csv-import', '> > Skipped. No product found for given product id, for which new comment is to be imported');
|
245 |
+
return new WP_Error( 'parse-error', 'Post is not a product, Skipped the review.' );
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
$product_review['post_id'] = $post_id;
|
250 |
+
|
251 |
+
// Get post fields
|
252 |
+
foreach ( $this->post_defaults as $column => $default ) {
|
253 |
+
if ( isset( $item[ $column ] ) )
|
254 |
+
$product_review[ $column ] = $item[ $column ];
|
255 |
+
if($column == 'comment_post_ID' && $this->use_sku == 1)
|
256 |
+
$product_review[ $column ] = !empty($temp_product_id) ? $temp_product_id : null;
|
257 |
+
}
|
258 |
+
|
259 |
+
|
260 |
+
// Get custom fields
|
261 |
+
foreach ( $this->postmeta_defaults as $column => $default ) {
|
262 |
+
|
263 |
+
if ( isset( $item[$column] ) )
|
264 |
+
$postmeta[$column] = (string) $item[$column];
|
265 |
+
elseif ( isset( $item[$column] ) )
|
266 |
+
$postmeta[$column] = (string) $item[$column];
|
267 |
+
|
268 |
+
// Check custom fields are valid
|
269 |
+
if ( isset( $postmeta[$column] ) && isset( $this->postmeta_allowed[$column] ) && ! in_array( $postmeta[$column], $this->postmeta_allowed[$column] ) ) {
|
270 |
+
$postmeta[$column] = $this->postmeta_defaults[$column];
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
if ( ! $merge ) {
|
275 |
+
// Merge post meta with defaults
|
276 |
+
$product_review = wp_parse_args( $product_review, $this->post_defaults );
|
277 |
+
$postmeta = wp_parse_args( $postmeta, $this->postmeta_defaults );
|
278 |
+
}
|
279 |
+
|
280 |
+
// Put set core product postmeta into product array
|
281 |
+
foreach ( $postmeta as $key => $value ) {
|
282 |
+
$product_review['postmeta'][] = array( 'key' => esc_attr($key), 'value' => $value );
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Handle other columns
|
287 |
+
*/
|
288 |
+
foreach ( $item as $key => $value )
|
289 |
+
{
|
290 |
+
|
291 |
+
if ( empty($item['post_parent']) && $value == "" )
|
292 |
+
continue;
|
293 |
+
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Handle meta: columns - import as custom fields
|
297 |
+
*/
|
298 |
+
elseif ( strstr( $key, 'meta:' ) ) {
|
299 |
+
|
300 |
+
// Get meta key name
|
301 |
+
// $meta_key = ( isset( $WF_CSV_Product_Review_Import->raw_headers[$key] ) ) ? $WF_CSV_Product_Review_Import->raw_headers[$key] : $key;
|
302 |
+
$meta_key = trim( str_replace( 'meta:', '', $meta_key ) );
|
303 |
+
if (is_object(json_decode($value))) //PIEPFW-512
|
304 |
+
{
|
305 |
+
$value=json_decode($value,TRUE);
|
306 |
+
}
|
307 |
+
// Add to postmeta array
|
308 |
+
$product_review['postmeta'][] = array(
|
309 |
+
'key' => esc_attr( $meta_key ),
|
310 |
+
'value' => $value
|
311 |
+
);
|
312 |
+
}
|
313 |
+
|
314 |
+
}
|
315 |
+
|
316 |
+
$product_review['comment_content'] = ( ! empty( $item['comment_content'] ) ) ? $item['comment_content'] : '';
|
317 |
+
unset( $item, $postmeta );
|
318 |
+
|
319 |
+
return $product_review;
|
320 |
+
} catch (Exception $e) {
|
321 |
+
return new WP_Error('woocommerce_product_importer_error', $e->getMessage(), array('status' => $e->getCode()));
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Create new posts based on import information
|
328 |
+
*/
|
329 |
+
public function process_product_reviews($post) {
|
330 |
+
try {
|
331 |
+
|
332 |
+
$processing_product_id = absint($post['comment_ID']);
|
333 |
+
$merge = !empty($post['merging']);
|
334 |
+
|
335 |
+
$processing_product_title = $processing_product_id;
|
336 |
+
|
337 |
+
if (!empty($processing_product_id) && isset($this->processed_posts[$processing_product_id])) {
|
338 |
+
// $this->add_import_result('skipped', __('Product review already processed', 'wf_csv_import_export'), $processing_product_id);
|
339 |
+
$this->hf_log_data_change('review-csv-import', '> Post ID already processed. Skipping.', true);
|
340 |
+
unset($post);
|
341 |
+
return new WP_Error( 'parse-error', '> Product review already processed. Skipping.' );
|
342 |
+
}
|
343 |
+
|
344 |
+
if (!empty($post['post_status']) && $post['post_status'] == 'auto-draft') {
|
345 |
+
// $this->add_import_result('skipped', __('Skipping auto-draft', 'wf_csv_import_export'), $processing_product_id);
|
346 |
+
$this->hf_log_data_change('review-csv-import', '> Skipping auto-draft.', true);
|
347 |
+
unset($post);
|
348 |
+
return new WP_Error( 'parse-error', '> Skipping auto-draft.' );
|
349 |
+
}
|
350 |
+
|
351 |
+
$this->cmd_type = 'review';
|
352 |
+
|
353 |
+
|
354 |
+
if ($merge && !empty($processing_product_id)) {
|
355 |
+
|
356 |
+
// Only merge fields which are set
|
357 |
+
$post_id = $processing_product_id;
|
358 |
+
|
359 |
+
$this->hf_log_data_change('review-csv-import', sprintf('> Merging post ID %s.', $post_id), true);
|
360 |
+
|
361 |
+
if (!empty($post['comment_post_ID']) || $this->merge_empty_cells) {
|
362 |
+
$postdata['comment_post_ID'] = $post['comment_post_ID'];
|
363 |
+
}
|
364 |
+
|
365 |
+
if (!empty($post['comment_author']) || $this->merge_empty_cells) {
|
366 |
+
$postdata['comment_author'] = $post['comment_author'];
|
367 |
+
}
|
368 |
+
if (!empty($post['comment_author_url']) || $this->merge_empty_cells) {
|
369 |
+
$postdata['comment_author_url'] = $post['comment_author_url'];
|
370 |
+
}
|
371 |
+
if (!empty($post['comment_date']) || $this->merge_empty_cells) {
|
372 |
+
$postdata['comment_date'] = date("Y-m-d H:i:s", strtotime($post['comment_date']));
|
373 |
+
}
|
374 |
+
if (!empty($post['comment_date_gmt']) || $this->merge_empty_cells) {
|
375 |
+
$postdata['comment_date_gmt'] = date("Y-m-d H:i:s", strtotime($post['comment_date_gmt']));
|
376 |
+
}
|
377 |
+
if (!empty($post['comment_author_email']) || $this->merge_empty_cells) {
|
378 |
+
$postdata['comment_author_email'] = $post['comment_author_email'];
|
379 |
+
}
|
380 |
+
if (!empty($post['comment_author_IP']) || $this->merge_empty_cells) {
|
381 |
+
$postdata['comment_author_IP'] = $post['comment_author_IP'];
|
382 |
+
}
|
383 |
+
if (!empty($post['comment_content']) || $this->merge_empty_cells) {
|
384 |
+
$postdata['comment_content'] = $post['comment_content'];
|
385 |
+
}
|
386 |
+
if (!empty($post['comment_approved']) || $this->merge_empty_cells) {
|
387 |
+
$postdata['comment_approved'] = $post['comment_approved'];
|
388 |
+
}
|
389 |
+
$postdata['comment_type'] = 'review';
|
390 |
+
|
391 |
+
if (!empty($post['comment_parent']) || $this->merge_empty_cells) {
|
392 |
+
$postdata['comment_parent'] = $post['comment_parent'];
|
393 |
+
}
|
394 |
+
if (!empty($post['user_id']) || $this->merge_empty_cells) {
|
395 |
+
$postdata['user_id'] = $post['user_id'];
|
396 |
+
}
|
397 |
+
|
398 |
+
// Update product review
|
399 |
+
if (sizeof($postdata) > 1) {
|
400 |
+
global $wpdb;
|
401 |
+
$result = $wpdb->update('wp_comments', $postdata, array('comment_ID' => $post_id));
|
402 |
+
if(!$result){
|
403 |
+
if (!empty($post_id)) {
|
404 |
+
$postdata['comment_ID'] = $post_id;
|
405 |
+
}
|
406 |
+
$result = wp_update_comment($postdata);
|
407 |
+
}
|
408 |
+
if (!empty($post['rating']) || $this->merge_empty_cells)
|
409 |
+
update_comment_meta($post_id, 'rating', $post['rating']);
|
410 |
+
}
|
411 |
+
} else {
|
412 |
+
if ($this->csv_last_start === '') {
|
413 |
+
$last_cmt_id = $this->get_last_comment_id();
|
414 |
+
update_option('xa_rev_im_ex_last_import_csv_start_col', $last_cmt_id);
|
415 |
+
$this->csv_last_start = $last_cmt_id;
|
416 |
+
}
|
417 |
+
|
418 |
+
// Insert product review
|
419 |
+
$this->hf_log_data_change('review-csv-import', sprintf('> Inserting %s', esc_html($processing_product_id)), true);
|
420 |
+
|
421 |
+
|
422 |
+
$review_parent = $post['comment_parent'];
|
423 |
+
$comment_parent_session= unserialize( get_option( 'wf_prod_review_alter_id'));
|
424 |
+
if ($post['comment_parent']!= 0 && $post['comment_parent']!= '') {
|
425 |
+
$arr_index = $post['comment_parent'];
|
426 |
+
if (isset($comment_parent_session['wt_review_basic']) && array_key_exists($arr_index, $comment_parent_session['wt_review_basic'])) {
|
427 |
+
$review_parent = $comment_parent_session['wt_review_basic'][$arr_index];
|
428 |
+
}
|
429 |
+
|
430 |
+
}
|
431 |
+
|
432 |
+
|
433 |
+
|
434 |
+
|
435 |
+
|
436 |
+
// if(isset($post['comment_parent']) && $post['comment_parent']!='' ){
|
437 |
+
// if ($post['comment_parent'] == '0') {
|
438 |
+
// $this->parent_data = $post['comment_parent'];
|
439 |
+
// $_SESSION['new_id'][$post['comment_alter_id']] = $this->get_last_comment_id();
|
440 |
+
// } else {
|
441 |
+
// if (!empty($_SESSION['new_id'][$post['comment_parent']])) {
|
442 |
+
// $this->parent_data = $_SESSION['new_id'][$post['comment_parent']];
|
443 |
+
// } else {
|
444 |
+
// $this->parent_data = $post['comment_parent'];
|
445 |
+
// }
|
446 |
+
// $_SESSION['new_id'][$post['comment_alter_id']] = $this->get_last_comment_id();
|
447 |
+
//
|
448 |
+
// }
|
449 |
+
//
|
450 |
+
//
|
451 |
+
//
|
452 |
+
//
|
453 |
+
//// if ($post['comment_parent'] === '0') {
|
454 |
+
//// $this->cmd_type = 'review';
|
455 |
+
//// } else {
|
456 |
+
//// $this->cmd_type = '';
|
457 |
+
//// }
|
458 |
+
// } else {
|
459 |
+
// $this->parent_data = $post['comment_parent'];
|
460 |
+
// $this->cmd_type = 'review';
|
461 |
+
// }
|
462 |
+
$comment_approved = isset( $post['comment_approved'] ) ? wc_string_to_bool($post['comment_approved']) : 0;
|
463 |
+
|
464 |
+
$postdata = array(
|
465 |
+
// 'comment_ID' => $processing_product_id, // this will not work for wp_insert_comment
|
466 |
+
'comment_post_ID' => $post['comment_post_ID'],
|
467 |
+
'comment_date' => ( $post['comment_date'] ) ? date('Y-m-d H:i:s', strtotime($post['comment_date'])) : current_time( 'mysql' ),
|
468 |
+
'comment_date_gmt' => ( $post['comment_date_gmt'] ) ? date('Y-m-d H:i:s', strtotime($post['comment_date_gmt'])) : get_gmt_from_date( current_time( 'mysql' ) ),
|
469 |
+
'comment_author' => $post['comment_author'],
|
470 |
+
'comment_author_url' => $post['comment_author_url'],
|
471 |
+
'comment_author_email' => $post['comment_author_email'],
|
472 |
+
'comment_author_IP' => $post['comment_author_IP'],
|
473 |
+
'comment_content' => ( $post['comment_content'] ) ? $post['comment_content'] : '',
|
474 |
+
'comment_approved' => $comment_approved ? 1 : 0,
|
475 |
+
'comment_type' => $this->cmd_type,
|
476 |
+
'comment_parent' => $review_parent,
|
477 |
+
'user_id' => $post['user_id'],
|
478 |
+
);
|
479 |
+
|
480 |
+
$post_id = wp_insert_comment($postdata, true);
|
481 |
+
|
482 |
+
$comment_parent_session['wt_review_basic'][$post['comment_alter_id']] = $post_id;
|
483 |
+
update_option('wf_prod_review_alter_id', serialize($comment_parent_session));
|
484 |
+
unset($comment_parent_session);
|
485 |
+
|
486 |
+
|
487 |
+
if (is_wp_error($post_id)) {
|
488 |
+
|
489 |
+
// $this->add_import_result('failed', __('Failed to import product review', 'wf_csv_import_export'), $processing_product_id);
|
490 |
+
$this->hf_log_data_change('review-csv-import', sprintf('Failed to import product review “%s”', esc_html($processing_product_title)));
|
491 |
+
unset($post);
|
492 |
+
return new WP_Error( 'parse-error', sprintf('Failed to import product review “%s”', esc_html($processing_product_title)) );
|
493 |
+
} else {
|
494 |
+
|
495 |
+
$this->hf_log_data_change('review-csv-import', sprintf('> Inserted - post ID is %s.', $post_id));
|
496 |
+
}
|
497 |
+
}
|
498 |
+
unset($postdata);
|
499 |
+
// map pre-import ID to local ID
|
500 |
+
if (empty($processing_product_id)) {
|
501 |
+
$processing_product_id = (int) $post_id;
|
502 |
+
}
|
503 |
+
$this->processed_posts[intval($processing_product_id)] = (int) $post_id;
|
504 |
+
|
505 |
+
if (!empty($post['postmeta']) && is_array($post['postmeta'])) {
|
506 |
+
if ($this->cmd_type === '') {
|
507 |
+
update_comment_meta($post_id, 'verified', $post['postmeta'][1]['value']);
|
508 |
+
} else {
|
509 |
+
// update_comment_meta($post_id, 'verified', $post['postmeta'][1]['value']);
|
510 |
+
// update_comment_meta($post_id, 'rating', $post['postmeta'][0]['value']);
|
511 |
+
// update_comment_meta($post_id, 'title', $post['postmeta'][2]['value']);
|
512 |
+
foreach ($post['postmeta'] as $meta) {
|
513 |
+
if('' == $meta['value'] && !$this->merge_empty_cells)
|
514 |
+
continue;
|
515 |
+
update_comment_meta($post_id, $meta['key'], $meta['value']);
|
516 |
+
}
|
517 |
+
}
|
518 |
+
}
|
519 |
+
|
520 |
+
// update_option('xa_rev_im_ex_last_import_csv_end_col', $post_id);
|
521 |
+
|
522 |
+
if ($merge) {
|
523 |
+
// $this->add_import_result('merged', 'Merge successful', $post_id);
|
524 |
+
$this->hf_log_data_change('review-csv-import', sprintf('> Finished merging post ID %s.', $post_id));
|
525 |
+
} else {
|
526 |
+
// $this->add_import_result('imported', 'Import successful', $post_id);
|
527 |
+
$this->hf_log_data_change('review-csv-import', sprintf('> Finished importing post ID %s.', $post_id));
|
528 |
+
}
|
529 |
+
unset($post);
|
530 |
+
|
531 |
+
return array('id'=>$post_id);
|
532 |
+
|
533 |
+
} catch (Exception $e) {
|
534 |
+
return new WP_Error('woocommerce_product_importer_error', $e->getMessage(), array('status' => $e->getCode()));
|
535 |
+
}
|
536 |
+
}
|
537 |
+
|
538 |
+
|
539 |
+
public function product_review_exists($id) {
|
540 |
+
global $wpdb;
|
541 |
+
$posts_that_exist = $wpdb->get_var($wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_ID = %d AND comment_approved != 'trash'", $id));
|
542 |
+
if ($posts_that_exist) {
|
543 |
+
return $posts_that_exist;
|
544 |
+
}
|
545 |
+
return false;
|
546 |
+
// // Check product to merge exists
|
547 |
+
// $db_query = $wpdb->prepare("
|
548 |
+
// SELECT comment_ID
|
549 |
+
// FROM $wpdb->comments
|
550 |
+
// WHERE comment_ID = %d",$post_id);
|
551 |
+
// $found_review_id = $wpdb->get_var($db_query);
|
552 |
+
}
|
553 |
+
|
554 |
+
public function get_last_comment_id() {
|
555 |
+
global $wpdb;
|
556 |
+
// $query = "SELECT MAX(comment_ID) FROM $wpdb->comments";
|
557 |
+
// $results = $wpdb->get_var($query);
|
558 |
+
// return $results + 1;
|
559 |
+
|
560 |
+
$get_id = $wpdb->get_row("SHOW TABLE STATUS LIKE '".$wpdb->prefix."comments'");
|
561 |
+
$last_id = $get_id->Auto_increment;
|
562 |
+
return $last_id;
|
563 |
+
}
|
564 |
+
|
565 |
+
public function clean_after_import() {
|
566 |
+
wp_suspend_cache_invalidation(false);
|
567 |
+
wp_defer_term_counting(false);
|
568 |
+
wp_defer_comment_counting(false);
|
569 |
+
global $wpdb;
|
570 |
+
if(class_exists('WC_Product_Reviews_Pro')){
|
571 |
+
$wpdb->query("DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('%_transient_wc_product_reviews_pro_review_count_%')");
|
572 |
+
}
|
573 |
+
}
|
574 |
+
|
575 |
+
}
|
admin/modules/product_review/product_review.php
ADDED
@@ -0,0 +1,601 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product section of the plugin
|
4 |
+
*
|
5 |
+
* @link
|
6 |
+
*
|
7 |
+
* @package Wt_Import_Export_For_Woo
|
8 |
+
*/
|
9 |
+
if (!defined('ABSPATH')) {
|
10 |
+
exit;
|
11 |
+
}
|
12 |
+
|
13 |
+
if(!class_exists('Wt_Import_Export_For_Woo_Basic_Product_Review')){
|
14 |
+
class Wt_Import_Export_For_Woo_Basic_Product_Review {
|
15 |
+
|
16 |
+
public $module_id = '';
|
17 |
+
public static $module_id_static = '';
|
18 |
+
public $module_base = 'product_review';
|
19 |
+
public $module_name = 'Product review Import Export for WooCommerce';
|
20 |
+
public $min_base_version= '1.0.0'; /* Minimum `Import export plugin` required to run this add on plugin */
|
21 |
+
|
22 |
+
private $all_meta_keys = array();
|
23 |
+
private $found_product_meta = array();
|
24 |
+
private $selected_column_names = null;
|
25 |
+
|
26 |
+
public function __construct()
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Checking the minimum required version of `Import export plugin` plugin available
|
30 |
+
*/
|
31 |
+
if(!Wt_Import_Export_For_Woo_Basic_Common_Helper::check_base_version($this->module_base, $this->module_name, $this->min_base_version))
|
32 |
+
{
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
if(!function_exists('is_plugin_active'))
|
36 |
+
{
|
37 |
+
include_once(ABSPATH.'wp-admin/includes/plugin.php');
|
38 |
+
}
|
39 |
+
if(!is_plugin_active('woocommerce/woocommerce.php'))
|
40 |
+
{
|
41 |
+
return;
|
42 |
+
}
|
43 |
+
|
44 |
+
$this->module_id = Wt_Import_Export_For_Woo_basic::get_module_id($this->module_base);
|
45 |
+
|
46 |
+
self::$module_id_static = $this->module_id;
|
47 |
+
|
48 |
+
add_filter('wt_iew_exporter_post_types_basic', array($this, 'wt_iew_exporter_post_types'), 10, 1);
|
49 |
+
add_filter('wt_iew_importer_post_types_basic', array($this, 'wt_iew_exporter_post_types'), 10, 1);
|
50 |
+
|
51 |
+
add_filter('wt_iew_exporter_alter_filter_fields_basic', array($this, 'exporter_alter_filter_fields'), 10, 3);
|
52 |
+
|
53 |
+
add_filter('wt_iew_exporter_alter_mapping_fields_basic', array($this, 'exporter_alter_mapping_fields'), 10, 3);
|
54 |
+
add_filter('wt_iew_importer_alter_mapping_fields_basic', array($this, 'get_importer_post_columns'), 10, 3);
|
55 |
+
|
56 |
+
add_filter('wt_iew_exporter_alter_advanced_fields_basic', array($this, 'exporter_alter_advanced_fields'), 10, 3);
|
57 |
+
add_filter('wt_iew_importer_alter_advanced_fields_basic', array($this, 'importer_alter_advanced_fields'), 10, 3);
|
58 |
+
|
59 |
+
add_filter('wt_iew_exporter_alter_meta_mapping_fields_basic', array($this, 'exporter_alter_meta_mapping_fields'), 10, 3);
|
60 |
+
add_filter('wt_iew_importer_alter_meta_mapping_fields_basic', array($this, 'importer_alter_meta_mapping_fields'), 10, 3);
|
61 |
+
|
62 |
+
add_filter('wt_iew_exporter_alter_mapping_enabled_fields_basic', array($this, 'exporter_alter_mapping_enabled_fields'), 10, 3);
|
63 |
+
add_filter('wt_iew_importer_alter_mapping_enabled_fields_basic', array($this, 'exporter_alter_mapping_enabled_fields'), 10, 3);
|
64 |
+
|
65 |
+
add_filter('wt_iew_exporter_do_export_basic', array($this, 'exporter_do_export'), 10, 7);
|
66 |
+
add_filter('wt_iew_importer_do_import_basic', array($this, 'importer_do_import'), 10, 8);
|
67 |
+
|
68 |
+
add_filter('wt_iew_importer_steps_basic', array($this, 'importer_steps'), 10, 2);
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Altering advanced step description
|
74 |
+
*/
|
75 |
+
public function importer_steps($steps, $base)
|
76 |
+
{
|
77 |
+
if($this->module_base==$base)
|
78 |
+
{
|
79 |
+
$steps['advanced']['description']=__('Use advanced options from below to decide updates to existing reviews, batch import count or schedule an import. You can also save the template file for future imports.');
|
80 |
+
}
|
81 |
+
return $steps;
|
82 |
+
}
|
83 |
+
|
84 |
+
public function importer_do_import($import_data, $base, $step, $form_data, $selected_template_data, $method_import, $batch_offset, $is_last_batch) {
|
85 |
+
if ($this->module_base != $base) {
|
86 |
+
return $import_data;
|
87 |
+
}
|
88 |
+
|
89 |
+
if(0 == $batch_offset){
|
90 |
+
$memory = size_format(wt_let_to_num(ini_get('memory_limit')));
|
91 |
+
$wp_memory = size_format(wt_let_to_num(WP_MEMORY_LIMIT));
|
92 |
+
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->module_base, 'import', '---[ New import started at '.date('Y-m-d H:i:s').' ] PHP Memory: ' . $memory . ', WP Memory: ' . $wp_memory);
|
93 |
+
}
|
94 |
+
|
95 |
+
include plugin_dir_path(__FILE__) . 'import/import.php';
|
96 |
+
$import = new Wt_Import_Export_For_Woo_Basic_Product_Review_Import($this);
|
97 |
+
|
98 |
+
$response = $import->prepare_data_to_import($import_data,$form_data,$batch_offset,$is_last_batch);
|
99 |
+
|
100 |
+
if($is_last_batch){
|
101 |
+
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->module_base, 'import', '---[ Import ended at '.date('Y-m-d H:i:s').']---');
|
102 |
+
}
|
103 |
+
|
104 |
+
return $response;
|
105 |
+
}
|
106 |
+
|
107 |
+
public function exporter_do_export($export_data, $base, $step, $form_data, $selected_template_data, $method_export, $batch_offset) {
|
108 |
+
if ($this->module_base != $base) {
|
109 |
+
return $export_data;
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
switch ($method_export) {
|
114 |
+
case 'quick':
|
115 |
+
$this->set_export_columns_for_quick_export($form_data);
|
116 |
+
break;
|
117 |
+
|
118 |
+
case 'template':
|
119 |
+
case 'new':
|
120 |
+
$this->set_selected_column_names($form_data);
|
121 |
+
break;
|
122 |
+
|
123 |
+
default:
|
124 |
+
break;
|
125 |
+
}
|
126 |
+
|
127 |
+
include plugin_dir_path(__FILE__) . 'export/export.php';
|
128 |
+
$export = new Wt_Import_Export_For_Woo_Basic_Product_Review_Export($this);
|
129 |
+
|
130 |
+
$header_row = $export->prepare_header();
|
131 |
+
|
132 |
+
$data_row = $export->prepare_data_to_export($form_data, $batch_offset);
|
133 |
+
|
134 |
+
$export_data = array(
|
135 |
+
'head_data' => $header_row,
|
136 |
+
'body_data' => $data_row['data'],
|
137 |
+
);
|
138 |
+
|
139 |
+
if(isset($data_row['total']) && !empty($data_row['total'])){
|
140 |
+
$export_data['total'] = $data_row['total'];
|
141 |
+
}
|
142 |
+
|
143 |
+
return $export_data;
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Adding current post type to export list
|
148 |
+
*
|
149 |
+
*/
|
150 |
+
public function wt_iew_exporter_post_types($arr) {
|
151 |
+
$arr['product_review'] = __('Product Review');
|
152 |
+
return $arr;
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
|
157 |
+
/*
|
158 |
+
* Setting default export columns for quick export
|
159 |
+
*/
|
160 |
+
|
161 |
+
public function set_export_columns_for_quick_export($form_data) {
|
162 |
+
|
163 |
+
$post_columns = self::get_product_review_post_columns();
|
164 |
+
|
165 |
+
$this->selected_column_names = array_combine(array_keys($post_columns), array_keys($post_columns));
|
166 |
+
|
167 |
+
if (isset($form_data['method_export_form_data']['mapping_enabled_fields']) && !empty($form_data['method_export_form_data']['mapping_enabled_fields'])) {
|
168 |
+
foreach ($form_data['method_export_form_data']['mapping_enabled_fields'] as $value) {
|
169 |
+
$additional_quick_export_fields[$value] = array('fields' => array());
|
170 |
+
}
|
171 |
+
|
172 |
+
$export_additional_columns = $this->exporter_alter_meta_mapping_fields($additional_quick_export_fields, $this->module_base, array());
|
173 |
+
foreach ($export_additional_columns as $value) {
|
174 |
+
$this->selected_column_names = array_merge($this->selected_column_names, $value['fields']);
|
175 |
+
}
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
|
180 |
+
public static function get_product_review_statuses() {
|
181 |
+
$product_statuses = array('publish', 'private', 'draft', 'pending', 'future');
|
182 |
+
return apply_filters('wt_iew_allowed_product_review_statuses', array_combine($product_statuses, $product_statuses));
|
183 |
+
}
|
184 |
+
|
185 |
+
public static function get_product_review_sort_columns() {
|
186 |
+
$sort_columns = array('comment_ID', 'comment_parent', 'comment_post_ID',
|
187 |
+
'comment_date', 'comment_date_gmt', 'comment_author_email',
|
188 |
+
'comment_type', 'comment_agent', 'comment_approved',
|
189 |
+
'comment_author', 'comment_content', 'user_id');
|
190 |
+
return apply_filters('wt_iew_allowed_product_review_sort_columns', array_combine($sort_columns, $sort_columns));
|
191 |
+
}
|
192 |
+
|
193 |
+
public static function get_product_review_post_columns() {
|
194 |
+
return include plugin_dir_path(__FILE__) . 'data/data-product-review-columns.php';
|
195 |
+
}
|
196 |
+
|
197 |
+
public function get_importer_post_columns($fields, $base, $step_page_form_data) {
|
198 |
+
if ($base != $this->module_base) {
|
199 |
+
return $fields;
|
200 |
+
}
|
201 |
+
$colunm = include plugin_dir_path(__FILE__) . 'data/data/data-wf-reserved-fields-pair.php';
|
202 |
+
// $colunm = array_map(function($vl){ return array('title'=>$vl, 'description'=>$vl); }, $arr);
|
203 |
+
return $colunm;
|
204 |
+
}
|
205 |
+
|
206 |
+
public function exporter_alter_mapping_enabled_fields($mapping_enabled_fields, $base, $form_data_mapping_enabled_fields) {
|
207 |
+
if ($base != $this->module_base) {
|
208 |
+
return $mapping_enabled_fields;
|
209 |
+
}
|
210 |
+
/*
|
211 |
+
$mapping_enabled_fields = array();
|
212 |
+
$mapping_enabled_fields['meta'] = array(__('Meta (custom fields)'), 0);
|
213 |
+
*
|
214 |
+
*/
|
215 |
+
|
216 |
+
return $mapping_enabled_fields;
|
217 |
+
}
|
218 |
+
|
219 |
+
public function exporter_alter_meta_mapping_fields($fields, $base, $step_page_form_data) {
|
220 |
+
if ($base != $this->module_base) {
|
221 |
+
return $fields;
|
222 |
+
}
|
223 |
+
|
224 |
+
/*
|
225 |
+
foreach ($fields as $key => $value) {
|
226 |
+
switch ($key) {
|
227 |
+
case 'meta':
|
228 |
+
$meta_attributes = array();
|
229 |
+
$found_product_meta = $this->wt_get_found_product_meta();
|
230 |
+
|
231 |
+
foreach ($found_product_meta as $product_meta) {
|
232 |
+
$fields[$key]['fields']['meta:' . $product_meta] = 'meta:' . $product_meta;
|
233 |
+
}
|
234 |
+
break;
|
235 |
+
|
236 |
+
default:
|
237 |
+
break;
|
238 |
+
}
|
239 |
+
}
|
240 |
+
*
|
241 |
+
*/
|
242 |
+
|
243 |
+
return $fields;
|
244 |
+
}
|
245 |
+
|
246 |
+
public function importer_alter_meta_mapping_fields($fields, $base, $step_page_form_data) {
|
247 |
+
if ($base != $this->module_base) {
|
248 |
+
return $fields;
|
249 |
+
}
|
250 |
+
$fields=$this->exporter_alter_meta_mapping_fields($fields, $base, $step_page_form_data);
|
251 |
+
$out=array();
|
252 |
+
foreach ($fields as $key => $value)
|
253 |
+
{
|
254 |
+
$value['fields']=array_map(function($vl){ return array('title'=>$vl, 'description'=>$vl); }, $value['fields']);
|
255 |
+
$out[$key]=$value;
|
256 |
+
}
|
257 |
+
return $out;
|
258 |
+
}
|
259 |
+
|
260 |
+
public function wt_get_found_product_meta() {
|
261 |
+
|
262 |
+
if (!empty($this->found_product_meta)) {
|
263 |
+
return $this->found_product_meta;
|
264 |
+
}
|
265 |
+
|
266 |
+
// Loop products and load meta data
|
267 |
+
$found_product_meta = array();
|
268 |
+
// Some of the values may not be usable (e.g. arrays of arrays) but the worse
|
269 |
+
// that can happen is we get an empty column.
|
270 |
+
|
271 |
+
$all_meta_keys = $this->wt_get_all_meta_keys();
|
272 |
+
|
273 |
+
$csv_columns = self::get_product_review_post_columns();
|
274 |
+
|
275 |
+
foreach ($all_meta_keys as $meta) {
|
276 |
+
|
277 |
+
if (!$meta || (substr((string) $meta, 0, 1) == '_') || in_array($meta, array_keys($csv_columns)) || in_array('meta:' . $meta, array_keys($csv_columns)))
|
278 |
+
continue;
|
279 |
+
|
280 |
+
$found_product_meta[] = $meta;
|
281 |
+
}
|
282 |
+
|
283 |
+
$found_product_meta = array_diff($found_product_meta, array_keys($csv_columns));
|
284 |
+
|
285 |
+
$this->found_product_meta = $found_product_meta;
|
286 |
+
return $this->found_product_meta;
|
287 |
+
}
|
288 |
+
|
289 |
+
|
290 |
+
|
291 |
+
public function wt_get_all_meta_keys() {
|
292 |
+
|
293 |
+
if (!empty($this->all_meta_keys)) {
|
294 |
+
return $this->all_meta_keys;
|
295 |
+
}
|
296 |
+
|
297 |
+
$all_meta_pkeys = self::get_all_metakeys();
|
298 |
+
|
299 |
+
$this->all_meta_keys = $all_meta_pkeys;
|
300 |
+
|
301 |
+
return $this->all_meta_keys;
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Get a list of all the meta keys for a post type. This includes all public, private,
|
306 |
+
* used, no-longer used etc. They will be sorted once fetched.
|
307 |
+
*/
|
308 |
+
public static function get_all_metakeys() {
|
309 |
+
global $wpdb;
|
310 |
+
|
311 |
+
$meta = $wpdb->get_col(
|
312 |
+
"SELECT DISTINCT cm.meta_key
|
313 |
+
FROM {$wpdb->commentmeta} AS cm
|
314 |
+
LEFT JOIN {$wpdb->comments} AS c ON c.comment_ID = cm.comment_id
|
315 |
+
WHERE c.comment_type = 'review'"
|
316 |
+
);
|
317 |
+
sort($meta);
|
318 |
+
return $meta;
|
319 |
+
}
|
320 |
+
|
321 |
+
public function set_selected_column_names($full_form_data) {
|
322 |
+
|
323 |
+
if (is_null($this->selected_column_names)) {
|
324 |
+
if (isset($full_form_data['mapping_form_data']['mapping_selected_fields']) && !empty($full_form_data['mapping_form_data']['mapping_selected_fields'])) {
|
325 |
+
$this->selected_column_names = $full_form_data['mapping_form_data']['mapping_selected_fields'];
|
326 |
+
}
|
327 |
+
if (isset($full_form_data['meta_step_form_data']['mapping_selected_fields']) && !empty($full_form_data['meta_step_form_data']['mapping_selected_fields'])) {
|
328 |
+
$export_additional_columns = $full_form_data['meta_step_form_data']['mapping_selected_fields'];
|
329 |
+
foreach ($export_additional_columns as $value) {
|
330 |
+
$this->selected_column_names = array_merge($this->selected_column_names, $value);
|
331 |
+
}
|
332 |
+
}
|
333 |
+
}
|
334 |
+
|
335 |
+
return $full_form_data;
|
336 |
+
}
|
337 |
+
|
338 |
+
public function get_selected_column_names() {
|
339 |
+
return $this->selected_column_names;
|
340 |
+
}
|
341 |
+
|
342 |
+
public function exporter_alter_mapping_fields($fields, $base, $mapping_form_data) {
|
343 |
+
if ($base != $this->module_base) {
|
344 |
+
return $fields;
|
345 |
+
}
|
346 |
+
|
347 |
+
$fields = self::get_product_review_post_columns();
|
348 |
+
return $fields;
|
349 |
+
}
|
350 |
+
|
351 |
+
|
352 |
+
/**
|
353 |
+
* Customize the items in filter export page
|
354 |
+
*/
|
355 |
+
public function exporter_alter_filter_fields($fields, $base, $filter_form_data) {
|
356 |
+
if ($this->module_base != $base) {
|
357 |
+
return $fields;
|
358 |
+
}
|
359 |
+
|
360 |
+
/* altering help text of default fields */
|
361 |
+
$fields['limit']['label']=__('Total number of reviews to export');
|
362 |
+
$fields['limit']['help_text']=__('Exports specified number of reviews. e.g. Entering 500 with a skip count of 10 will export reviews from 11th to 510th position.');
|
363 |
+
$fields['offset']['label']=__('Skip first <i>n</i> reviews');
|
364 |
+
$fields['offset']['help_text']=__('Skips specified number of reviews from the beginning. e.g. Enter 10 to skip first 10 reviews from export.');
|
365 |
+
|
366 |
+
$fields['date_from'] = array(
|
367 |
+
'label' => __('Date From'),
|
368 |
+
'placeholder' => __('Date'),
|
369 |
+
'field_name' => 'date_from',
|
370 |
+
'sele_vals' => '',
|
371 |
+
'help_text' => __('Date on which the review was received. Export products reviews received on and after the specified date.'),
|
372 |
+
'type' => 'text',
|
373 |
+
'css_class' => 'wt_iew_datepicker',
|
374 |
+
// 'type' => 'field_html',
|
375 |
+
// 'field_html' => '<input type="text" name="date_from" placeholder="'.__('From date').'" class="wt_iew_datepicker input-text" />',
|
376 |
+
);
|
377 |
+
|
378 |
+
$fields['date_to'] = array(
|
379 |
+
'label' => __('Date To'),
|
380 |
+
'placeholder' => __('Date'),
|
381 |
+
'field_name' => 'date_to',
|
382 |
+
'sele_vals' => '',
|
383 |
+
'help_text' => __('Date on which the review was received. Export products reviews received upto the specified date.'),
|
384 |
+
'type' => 'text',
|
385 |
+
'css_class' => 'wt_iew_datepicker',
|
386 |
+
// 'type' => 'field_html',
|
387 |
+
// 'field_html' => '<input type="text" name="date_to" placeholder="'. __('To date').'" class="wt_iew_datepicker input-text" />',
|
388 |
+
);
|
389 |
+
|
390 |
+
|
391 |
+
$fields['product'] = array(
|
392 |
+
'label' => __('Products'),
|
393 |
+
'placeholder' => __('All product'),
|
394 |
+
'field_name' => 'product',
|
395 |
+
'sele_vals' => array(),
|
396 |
+
'help_text' => __('Input the product name to export respective reviews.'),
|
397 |
+
'type' => 'multi_select',
|
398 |
+
'css_class' => 'wc-product-search',
|
399 |
+
'validation_rule' => array('type'=>'text_arr')
|
400 |
+
);
|
401 |
+
|
402 |
+
$fields['stars'] = array(
|
403 |
+
'label' => __('Stars'),
|
404 |
+
'placeholder' => __('All'),
|
405 |
+
'field_name' => 'stars',
|
406 |
+
'sele_vals' => array(1=>1,2=>2,3=>3,4=>4,5=>5),
|
407 |
+
'help_text' => __('Export reviews of a specific star rating.'),
|
408 |
+
'type' => 'multi_select',
|
409 |
+
'css_class' => 'wc-enhanced-select',
|
410 |
+
'validation_rule' => array('type'=>'text_arr')
|
411 |
+
);
|
412 |
+
|
413 |
+
$fields['owner'] = array(
|
414 |
+
'label' => __('Customer/Guest Review'),
|
415 |
+
'placeholder' => __('All'),
|
416 |
+
'field_name' => 'owner',
|
417 |
+
'sele_vals' => array(''=>'All Reviews','verified'=>'Customer','non-verified'=>'Guest'),
|
418 |
+
'help_text' => __('Export reviews by customer or guest or both.'),
|
419 |
+
'type' => 'select',
|
420 |
+
'css_class' => '',
|
421 |
+
'validation_rule' => array('type'=>'text_arr')
|
422 |
+
);
|
423 |
+
|
424 |
+
|
425 |
+
|
426 |
+
$fields['reply'] = array(
|
427 |
+
'label' => __('Review with replies'),
|
428 |
+
// 'placeholder' => __('Any tag'),
|
429 |
+
'field_name' => 'reply',
|
430 |
+
'sele_vals' => '',
|
431 |
+
'help_text' => __('Enable to include the replies along with the respective reviews.'),
|
432 |
+
'type' => 'field_html',
|
433 |
+
'field_html' => '<input type="checkbox" name="reply" value="1" id="v_replycolumn" class="input-text" />',
|
434 |
+
'css_class' => '',
|
435 |
+
);
|
436 |
+
|
437 |
+
$fields['status'] = array(
|
438 |
+
'label' => __('Status'),
|
439 |
+
'placeholder' => __('All status'),
|
440 |
+
'field_name' => 'status',
|
441 |
+
'sele_vals' => self::get_product_review_statuses(),
|
442 |
+
'help_text' => __('Export reviews by specific post status.'),
|
443 |
+
'type' => 'multi_select',
|
444 |
+
'css_class' => 'wc-enhanced-select',
|
445 |
+
'validation_rule' => array('type'=>'text_arr')
|
446 |
+
);
|
447 |
+
|
448 |
+
$sort_columns = self::get_product_review_sort_columns();
|
449 |
+
$fields['sort_columns'] = array(
|
450 |
+
'label' => __('Sort Columns'),
|
451 |
+
'placeholder' => __('comment_ID'),
|
452 |
+
'field_name' => 'sort_columns',
|
453 |
+
'sele_vals' => $sort_columns,
|
454 |
+
'help_text' => __('Sort the exported data based on the selected column in the order specified. Defaulted to ascending order.'),
|
455 |
+
'type' => 'select',
|
456 |
+
);
|
457 |
+
|
458 |
+
$fields['order_by'] = array(
|
459 |
+
'label' => __('Sort By'),
|
460 |
+
'placeholder' => __('ASC'),
|
461 |
+
'field_name' => 'order_by',
|
462 |
+
'sele_vals' => array('ASC' => 'Ascending', 'DESC' => 'Descending'),
|
463 |
+
'help_text' => __('Defaulted to Ascending. Applicable to above selected columns in the order specified.'),
|
464 |
+
'type' => 'select',
|
465 |
+
'css_class' => '',
|
466 |
+
);
|
467 |
+
|
468 |
+
return $fields;
|
469 |
+
}
|
470 |
+
|
471 |
+
|
472 |
+
public function exporter_alter_advanced_fields($fields, $base, $advanced_form_data) {
|
473 |
+
if ($this->module_base != $base) {
|
474 |
+
return $fields;
|
475 |
+
}
|
476 |
+
unset($fields['export_shortcode_tohtml']);
|
477 |
+
|
478 |
+
return $fields;
|
479 |
+
}
|
480 |
+
|
481 |
+
public function importer_alter_advanced_fields($fields, $base, $advanced_form_data) {
|
482 |
+
if ($this->module_base != $base) {
|
483 |
+
return $fields;
|
484 |
+
}
|
485 |
+
$out = array();
|
486 |
+
|
487 |
+
$out['skip_new'] = array(
|
488 |
+
'label' => __("Update Only"),
|
489 |
+
'type' => 'radio',
|
490 |
+
'radio_fields' => array(
|
491 |
+
'1' => __('Yes'),
|
492 |
+
'0' => __('No')
|
493 |
+
),
|
494 |
+
'value' => '0',
|
495 |
+
'field_name' => 'skip_new',
|
496 |
+
'help_text_conditional'=>array(
|
497 |
+
array(
|
498 |
+
'help_text'=> sprintf(__('The store is updated with the data from the input file only for matching/existing records from the file. In case of a conflict with %sIDs of other existing post types%s the reviews will not be imported.'), '<b>', '</b>'),
|
499 |
+
'condition'=>array(
|
500 |
+
array('field'=>'wt_iew_skip_new', 'value'=>1)
|
501 |
+
)
|
502 |
+
),
|
503 |
+
array(
|
504 |
+
'help_text'=> __('The entire data from the input file is processed for an update or insert as the case maybe.'),
|
505 |
+
'condition'=>array(
|
506 |
+
array('field'=>'wt_iew_skip_new', 'value'=>0)
|
507 |
+
)
|
508 |
+
)
|
509 |
+
),
|
510 |
+
'form_toggler'=>array(
|
511 |
+
'type'=>'parent',
|
512 |
+
'target'=>'wt_iew_skip_new',
|
513 |
+
)
|
514 |
+
);
|
515 |
+
|
516 |
+
$out['merge'] = array(
|
517 |
+
'label' => __("If the review exists in the store"),
|
518 |
+
'type' => 'radio',
|
519 |
+
'radio_fields' => array(
|
520 |
+
'0' => __('Skip'),
|
521 |
+
'1' => __('Update')
|
522 |
+
),
|
523 |
+
'value' => '0',
|
524 |
+
'field_name' => 'merge',
|
525 |
+
'help_text' => __('Reviews are matched by their IDs.'),
|
526 |
+
'help_text_conditional'=>array(
|
527 |
+
array(
|
528 |
+
'help_text'=> __('Retains the order in the store as is and skips the matching order from the input file.'),
|
529 |
+
'condition'=>array(
|
530 |
+
array('field'=>'wt_iew_merge', 'value'=>0)
|
531 |
+
)
|
532 |
+
),
|
533 |
+
array(
|
534 |
+
'help_text'=> __('Update order as per data from the input file'),
|
535 |
+
'condition'=>array(
|
536 |
+
array('field'=>'wt_iew_merge', 'value'=>1)
|
537 |
+
)
|
538 |
+
)
|
539 |
+
),
|
540 |
+
'form_toggler'=>array(
|
541 |
+
'type'=>'parent',
|
542 |
+
'target'=>'wt_iew_found_action'
|
543 |
+
)
|
544 |
+
);
|
545 |
+
|
546 |
+
$out['merge_empty_cells'] = array(
|
547 |
+
'label' => __("Update even if empty values"),
|
548 |
+
'type' => 'radio',
|
549 |
+
'radio_fields' => array(
|
550 |
+
'1' => __('Yes'),
|
551 |
+
'0' => __('No')
|
552 |
+
),
|
553 |
+
'value' => '0',
|
554 |
+
'field_name' => 'merge_empty_cells',
|
555 |
+
'help_text' => __('Updates the order data respectively even if some of the columns in the input file contains empty value.'),
|
556 |
+
'form_toggler'=>array(
|
557 |
+
'type'=>'child',
|
558 |
+
'id'=>'wt_iew_found_action',
|
559 |
+
'val'=>'1',
|
560 |
+
)
|
561 |
+
);
|
562 |
+
|
563 |
+
$out['use_sku'] = array(
|
564 |
+
'label' => __("Associate product reviews by SKU"),
|
565 |
+
'type' => 'radio',
|
566 |
+
'radio_fields' => array(
|
567 |
+
'1' => __('Yes'),
|
568 |
+
'0' => __('No')
|
569 |
+
),
|
570 |
+
'value' => '0',
|
571 |
+
'field_name' => 'use_sku',
|
572 |
+
'help_text_conditional'=>array(
|
573 |
+
array(
|
574 |
+
'help_text'=> __('Link the products reviews being imported with the respective products by their SKU.'),
|
575 |
+
'condition'=>array(
|
576 |
+
array('field'=>'wt_iew_use_sku', 'value'=>1)
|
577 |
+
)
|
578 |
+
),
|
579 |
+
array(
|
580 |
+
'help_text'=> sprintf(__(' Link the products reviews being imported with the respective products by their product ID. In case of a conflict with %sIDs of other existing post types%s the reviews will not be imported.'), '<b>', '</b>'),
|
581 |
+
'condition'=>array(
|
582 |
+
array('field'=>'wt_iew_use_sku', 'value'=>0)
|
583 |
+
)
|
584 |
+
)
|
585 |
+
),
|
586 |
+
);
|
587 |
+
|
588 |
+
foreach ($fields as $fieldk => $fieldv) {
|
589 |
+
$out[$fieldk] = $fieldv;
|
590 |
+
}
|
591 |
+
return $out;
|
592 |
+
}
|
593 |
+
|
594 |
+
public function get_item_by_id($id) {
|
595 |
+
$post['edit_url']=get_edit_comment_link($id);
|
596 |
+
$post['title'] = get_comment_excerpt($id);
|
597 |
+
return $post;
|
598 |
+
}
|
599 |
+
}
|
600 |
+
}
|
601 |
+
new Wt_Import_Export_For_Woo_Basic_Product_Review();
|
admin/views/admin-settings-advanced.php
CHANGED
@@ -14,6 +14,9 @@ if ( ! defined( 'WPINC' ) ) {
|
|
14 |
Wt_Import_Export_For_Woo_Basic_Common_Helper::field_generator($fields, $advanced_settings);
|
15 |
?>
|
16 |
</table>
|
|
|
|
|
|
|
17 |
<?php
|
18 |
include "admin-settings-save-button.php";
|
19 |
?>
|
14 |
Wt_Import_Export_For_Woo_Basic_Common_Helper::field_generator($fields, $advanced_settings);
|
15 |
?>
|
16 |
</table>
|
17 |
+
<?php
|
18 |
+
include "admin-settings-pre-saved-templates.php";
|
19 |
+
?>
|
20 |
<?php
|
21 |
include "admin-settings-save-button.php";
|
22 |
?>
|
admin/views/admin-settings-pre-saved-templates.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if (!defined('WPINC')) {
|
3 |
+
die;
|
4 |
+
}
|
5 |
+
|
6 |
+
global $wpdb;
|
7 |
+
$tb = $wpdb->prefix . Wt_Import_Export_For_Woo_Basic::$template_tb;
|
8 |
+
$val = $wpdb->get_results("SELECT * FROM $tb ORDER BY id DESC", ARRAY_A);
|
9 |
+
$pre_saved_templates = ($val ? $val : array());
|
10 |
+
if (!empty($pre_saved_templates)):
|
11 |
+
?>
|
12 |
+
|
13 |
+
|
14 |
+
<style>
|
15 |
+
.wt_ier_template_list_table {
|
16 |
+
width: 50%;
|
17 |
+
border-spacing: 0px;
|
18 |
+
border-collapse: collapse;
|
19 |
+
margin-top: 15px;
|
20 |
+
}
|
21 |
+
.wt_ier_template_list_table th {
|
22 |
+
padding: 5px 5px;
|
23 |
+
background: #f9f9f9;
|
24 |
+
color: #333;
|
25 |
+
text-align: center;
|
26 |
+
border: solid 1px #e1e1e1;
|
27 |
+
font-weight: bold;
|
28 |
+
}
|
29 |
+
.wt_ier_template_list_table td {
|
30 |
+
padding: 5px 5px;
|
31 |
+
background: #fff;
|
32 |
+
color: #000;
|
33 |
+
text-align: center;
|
34 |
+
border: solid 1px #e1e1e1;
|
35 |
+
}
|
36 |
+
</style>
|
37 |
+
<div class="wt-ier-import-export-templates">
|
38 |
+
<h3><?php _e('Import export pre-saved templates'); ?></h3>
|
39 |
+
<div class="wt_ier_template_list_table_data">
|
40 |
+
<table class="wt_ier_template_list_table">
|
41 |
+
<thead>
|
42 |
+
<tr>
|
43 |
+
<th style="width:50px;">#</th>
|
44 |
+
<th><?php _e('Name'); ?></th>
|
45 |
+
<th><?php _e('Item'); ?></th>
|
46 |
+
<th><?php _e('Type'); ?></th>
|
47 |
+
<th><?php _e('Action'); ?></th>
|
48 |
+
</tr>
|
49 |
+
</thead>
|
50 |
+
<tbody>
|
51 |
+
<?php
|
52 |
+
$num = 1;
|
53 |
+
foreach ($pre_saved_templates as $key => $value):
|
54 |
+
?>
|
55 |
+
<tr data-row-id="<?php echo absint($value['id']); ?>">
|
56 |
+
<td><?php echo $num; ?></td>
|
57 |
+
<td><?php echo $value['name']; ?></td>
|
58 |
+
<td><?php echo $value['item_type']; ?></td>
|
59 |
+
<td><?php echo $value['template_type']; ?></td>
|
60 |
+
<td><button data-id="<?php echo absint($value['id']); ?>" title="<?php _e('Delete'); ?>" class="button button-secondary wt_ier_delete_template"><span><?php _e('Delete'); ?></span></button></td>
|
61 |
+
</tr>
|
62 |
+
<?php
|
63 |
+
$num++;
|
64 |
+
endforeach;
|
65 |
+
?>
|
66 |
+
</tbody>
|
67 |
+
</table>
|
68 |
+
</div>
|
69 |
+
</div>
|
70 |
+
<?php endif; ?>
|
admin/views/market.php
CHANGED
@@ -8,7 +8,7 @@ if (!defined('ABSPATH')) {
|
|
8 |
<div class="ier-premium-upgrade">
|
9 |
<div class="wt-ier-sidebar-wrapper wt-ier-p-5">
|
10 |
<img src="<?php echo WT_P_IEW_PLUGIN_URL; ?>assets/images/upgrade/crown.svg" class="wt-ier-sidebar-img">
|
11 |
-
<h3 class="wt-ier-sidebar-title wt-ier-center"><?php _e('
|
12 |
<div class="wt-ier-row">
|
13 |
<div class="wt-ier-col-12 wt-ier-col-md-6 wt-ier-border-md-right">
|
14 |
<div class="wt-ier-flex wt-ier-v-center ">
|
8 |
<div class="ier-premium-upgrade">
|
9 |
<div class="wt-ier-sidebar-wrapper wt-ier-p-5">
|
10 |
<img src="<?php echo WT_P_IEW_PLUGIN_URL; ?>assets/images/upgrade/crown.svg" class="wt-ier-sidebar-img">
|
11 |
+
<h3 class="wt-ier-sidebar-title wt-ier-center"><?php _e('Migrate all your WooCommerce data in a go!<br>Upgrade to pro.');?></h3>
|
12 |
<div class="wt-ier-row">
|
13 |
<div class="wt-ier-col-12 wt-ier-col-md-6 wt-ier-border-md-right">
|
14 |
<div class="wt-ier-flex wt-ier-v-center ">
|
includes/class-wt-import-export-for-woo.php
CHANGED
@@ -80,7 +80,7 @@ class Wt_Import_Export_For_Woo_Basic {
|
|
80 |
if ( defined( 'WT_P_IEW_VERSION' ) ) {
|
81 |
$this->version = WT_P_IEW_VERSION;
|
82 |
} else {
|
83 |
-
$this->version = '2.0.
|
84 |
}
|
85 |
$this->plugin_name = 'wt-import-export-for-woo-basic';
|
86 |
|
@@ -193,6 +193,7 @@ class Wt_Import_Export_For_Woo_Basic {
|
|
193 |
{
|
194 |
//ajax hook for saving settings, Includes plugin main settings and settings from module
|
195 |
$this->loader->add_action('wp_ajax_wt_iew_save_settings_basic',$this->plugin_admin,'save_settings');
|
|
|
196 |
|
197 |
/* Loading admin modules */
|
198 |
$this->plugin_admin->admin_modules();
|
80 |
if ( defined( 'WT_P_IEW_VERSION' ) ) {
|
81 |
$this->version = WT_P_IEW_VERSION;
|
82 |
} else {
|
83 |
+
$this->version = '2.0.6';
|
84 |
}
|
85 |
$this->plugin_name = 'wt-import-export-for-woo-basic';
|
86 |
|
193 |
{
|
194 |
//ajax hook for saving settings, Includes plugin main settings and settings from module
|
195 |
$this->loader->add_action('wp_ajax_wt_iew_save_settings_basic',$this->plugin_admin,'save_settings');
|
196 |
+
$this->loader->add_action('wp_ajax_wt_iew_delete_template',$this->plugin_admin,'delete_template');
|
197 |
|
198 |
/* Loading admin modules */
|
199 |
$this->plugin_admin->admin_modules();
|
product-import-export-for-woo.php
CHANGED
@@ -5,8 +5,8 @@
|
|
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: 2.0.
|
9 |
-
WC tested up to: 5.
|
10 |
License: GPLv3
|
11 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
12 |
Text Domain: product-import-export-for-woo
|
@@ -43,7 +43,7 @@ if ( !defined( 'WT_IEW_DEBUG_BASIC_TROUBLESHOOT' ) ) {
|
|
43 |
* Start at version 1.0.0 and use SemVer - https://semver.org
|
44 |
* Rename this for your plugin and update it as you release new versions.
|
45 |
*/
|
46 |
-
define( 'WT_P_IEW_VERSION', '2.0.
|
47 |
|
48 |
/**
|
49 |
* The code that runs during plugin activation.
|
@@ -157,7 +157,7 @@ function wt_piew_plugin_action_links_basic_product( $links ) {
|
|
157 |
'<a href="' . admin_url( 'admin.php?page=wt_import_export_for_woo_basic' ) . '">' . __( 'Settings' ) . '</a>',
|
158 |
'<a href="https://www.webtoffee.com/product-import-export-plugin-woocommerce-user-guide/" target="_blank">' . __( 'Documentation' ) . '</a>',
|
159 |
'<a href="https://wordpress.org/support/plugin/product-import-export-for-woo/" target="_blank">' . __( 'Support' ) . '</a>',
|
160 |
-
'<a href="https://www.webtoffee.com/product/product-import-export-woocommerce
|
161 |
);
|
162 |
if ( array_key_exists( 'deactivate', $links ) ) {
|
163 |
$links[ 'deactivate' ] = str_replace( '<a', '<a class="pipe-deactivate-link"', $links[ 'deactivate' ] );
|
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: 2.0.6
|
9 |
+
WC tested up to: 5.6
|
10 |
License: GPLv3
|
11 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
12 |
Text Domain: product-import-export-for-woo
|
43 |
* Start at version 1.0.0 and use SemVer - https://semver.org
|
44 |
* Rename this for your plugin and update it as you release new versions.
|
45 |
*/
|
46 |
+
define( 'WT_P_IEW_VERSION', '2.0.6' );
|
47 |
|
48 |
/**
|
49 |
* The code that runs during plugin activation.
|
157 |
'<a href="' . admin_url( 'admin.php?page=wt_import_export_for_woo_basic' ) . '">' . __( 'Settings' ) . '</a>',
|
158 |
'<a href="https://www.webtoffee.com/product-import-export-plugin-woocommerce-user-guide/" target="_blank">' . __( 'Documentation' ) . '</a>',
|
159 |
'<a href="https://wordpress.org/support/plugin/product-import-export-for-woo/" target="_blank">' . __( 'Support' ) . '</a>',
|
160 |
+
'<a href="https://www.webtoffee.com/product/product-import-export-woocommerce/?utm_source=free_plugin_listing&utm_medium=product_imp_exp_basic&utm_campaign=Product_Import_Export&utm_content=' . WT_P_IEW_VERSION . '" style="color:#3db634;">' . __('Premium Upgrade') . '</a>',
|
161 |
);
|
162 |
if ( array_key_exists( 'deactivate', $links ) ) {
|
163 |
$links[ 'deactivate' ] = str_replace( '<a', '<a class="pipe-deactivate-link"', $links[ 'deactivate' ] );
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: product export, product import, CSV import export, woocommerce, CSV, produ
|
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 5.8
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 2.0.
|
9 |
License: GPLv3 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
@@ -35,7 +35,7 @@ The Product Import Export for WooCommerce plugin exports and imports WooCommerce
|
|
35 |
* Import/export using <strong>pre-saved configurations</strong>
|
36 |
* View <strong>import-export history</strong>
|
37 |
* View <strong>import log</strong> for easy debugging
|
38 |
-
* Tested OK with WooCommerce 5.
|
39 |
|
40 |
|
41 |
###Setup Guide - Product Import Export for WooCommerce###
|
@@ -174,6 +174,9 @@ Yes. You can import grouped, affiliate/external products in addition to simple p
|
|
174 |
|
175 |
== Changelog ==
|
176 |
|
|
|
|
|
|
|
177 |
= 2.0.5 =
|
178 |
* Tested OK with WP 5.8.
|
179 |
* Bug fix: Product attribute update issue.
|
@@ -478,6 +481,5 @@ Yes. You can import grouped, affiliate/external products in addition to simple p
|
|
478 |
|
479 |
== Upgrade Notice ==
|
480 |
|
481 |
-
= 2.0.
|
482 |
-
* Tested OK with
|
483 |
-
* Bug fix: Product attribute update issue.
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 5.8
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 2.0.6
|
9 |
License: GPLv3 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
35 |
* Import/export using <strong>pre-saved configurations</strong>
|
36 |
* View <strong>import-export history</strong>
|
37 |
* View <strong>import log</strong> for easy debugging
|
38 |
+
* Tested OK with WooCommerce 5.6
|
39 |
|
40 |
|
41 |
###Setup Guide - Product Import Export for WooCommerce###
|
174 |
|
175 |
== Changelog ==
|
176 |
|
177 |
+
= 2.0.6 =
|
178 |
+
* Tested OK with WC 5.6.
|
179 |
+
|
180 |
= 2.0.5 =
|
181 |
* Tested OK with WP 5.8.
|
182 |
* Bug fix: Product attribute update issue.
|
481 |
|
482 |
== Upgrade Notice ==
|
483 |
|
484 |
+
= 2.0.6 =
|
485 |
+
* Tested OK with WC 5.6.
|
|