WooCommerce – Store Exporter - Version 1.9.1.1

Version Description

  • Fixed: Visibility field empty for default value
Download this release

Release Info

Developer visser
Plugin Icon 128x128 WooCommerce – Store Exporter
Version 1.9.1.1
Comparing to
See all releases

Version 1.9.1.1

Files changed (91) hide show
  1. common/common.php +95 -0
  2. exporter.php +574 -0
  3. includes/admin.php +569 -0
  4. includes/admin/brand.php +33 -0
  5. includes/admin/category.php +33 -0
  6. includes/admin/commission.php +83 -0
  7. includes/admin/coupon.php +33 -0
  8. includes/admin/customer.php +124 -0
  9. includes/admin/order.php +663 -0
  10. includes/admin/product.php +390 -0
  11. includes/admin/shipping_class.php +33 -0
  12. includes/admin/subscription.php +73 -0
  13. includes/admin/tag.php +33 -0
  14. includes/admin/user.php +91 -0
  15. includes/brand.php +153 -0
  16. includes/category.php +203 -0
  17. includes/commission.php +252 -0
  18. includes/common-dashboard_widgets.php +60 -0
  19. includes/common.php +77 -0
  20. includes/coupon.php +206 -0
  21. includes/customer.php +248 -0
  22. includes/export-csv.php +51 -0
  23. includes/formatting.php +445 -0
  24. includes/functions.php +2029 -0
  25. includes/install.php +42 -0
  26. includes/legacy.php +10 -0
  27. includes/order-extend.php +423 -0
  28. includes/order.php +675 -0
  29. includes/product-extend.php +1029 -0
  30. includes/product.php +1367 -0
  31. includes/product_vendor.php +173 -0
  32. includes/settings.php +588 -0
  33. includes/shipping_class.php +91 -0
  34. includes/subscription.php +264 -0
  35. includes/tag.php +163 -0
  36. includes/user-extend.php +102 -0
  37. includes/user.php +275 -0
  38. js/chosen.jquery.js +988 -0
  39. js/jquery-ui.js +48 -0
  40. js/jquery.chosen.js +988 -0
  41. js/jquery.csvToTable.js +154 -0
  42. js/jquery.timepicker.js +2245 -0
  43. js/ui-datepicker.js +84 -0
  44. languages/woo_ce-en_GB.mo +0 -0
  45. languages/woo_ce-en_GB.po +97 -0
  46. languages/woocommerce-exporter-en_GB.mo +0 -0
  47. languages/woocommerce-exporter-en_GB.po +97 -0
  48. license.txt +281 -0
  49. readme.txt +647 -0
  50. templates/admin/chosen-sprite.png +0 -0
  51. templates/admin/chosen.css +397 -0
  52. templates/admin/export.css +113 -0
  53. templates/admin/export.js +535 -0
  54. templates/admin/images/animated-overlay.gif +0 -0
  55. templates/admin/images/progress.gif +0 -0
  56. templates/admin/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  57. templates/admin/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  58. templates/admin/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  59. templates/admin/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  60. templates/admin/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  61. templates/admin/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  62. templates/admin/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  63. templates/admin/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  64. templates/admin/images/ui-icons_222222_256x240.png +0 -0
  65. templates/admin/images/ui-icons_2e83ff_256x240.png +0 -0
  66. templates/admin/images/ui-icons_454545_256x240.png +0 -0
  67. templates/admin/images/ui-icons_888888_256x240.png +0 -0
  68. templates/admin/images/ui-icons_cd0a0a_256x240.png +0 -0
  69. templates/admin/jquery-csvtable.css +40 -0
  70. templates/admin/jquery-ui-datepicker.css +347 -0
  71. templates/admin/jquery-ui-timepicker.css +12 -0
  72. templates/admin/media-csv_file.php +13 -0
  73. templates/admin/media-export_details.php +41 -0
  74. templates/admin/tabs-archive.php +80 -0
  75. templates/admin/tabs-export.php +964 -0
  76. templates/admin/tabs-fields.php +29 -0
  77. templates/admin/tabs-overview.php +135 -0
  78. templates/admin/tabs-settings.php +192 -0
  79. templates/admin/tabs-tools.php +96 -0
  80. templates/admin/tabs.php +15 -0
  81. templates/admin/woo-admin_ce-export.css +76 -0
  82. templates/admin/woo-admin_ce-export.js +179 -0
  83. templates/admin/woo-admin_ce-export.php +13 -0
  84. templates/admin/woo-admin_ce-export_archive.php +65 -0
  85. templates/admin/woo-admin_ce-export_export.php +511 -0
  86. templates/admin/woo-admin_ce-export_overview.php +85 -0
  87. templates/admin/woo-admin_ce-export_settings.php +153 -0
  88. templates/admin/woo-admin_ce-export_tools.php +22 -0
  89. templates/admin/woo-admin_ce-media_csv_file.php +12 -0
  90. templates/admin/woo-admin_ce-media_export_details.php +54 -0
  91. templates/admin/woocommerce-admin_dashboard_vm-plugins.css +52 -0
common/common.php ADDED
@@ -0,0 +1,95 @@
1
+ <?php
2
+ /**
3
+ *
4
+ * Filename: common.php
5
+ * Description: common.php loads commonly accessed functions across the Visser Labs suite.
6
+ *
7
+ * Free
8
+ * - woo_get_action
9
+ * - woo_is_wpsc_activated
10
+ * - woo_is_woo_activated
11
+ * - woo_is_jigo_activated
12
+ * - woo_is_exchange_activated
13
+ * - woo_get_woo_version
14
+ *
15
+ */
16
+
17
+ if( is_admin() ) {
18
+
19
+ /* Start of: WordPress Administration */
20
+
21
+ // Load Dashboard widgets
22
+ include_once( WOO_CE_PATH . 'includes/common-dashboard_widgets.php' );
23
+
24
+ /* End of: WordPress Administration */
25
+
26
+ }
27
+
28
+ if( !function_exists( 'woo_get_action' ) ) {
29
+ function woo_get_action( $prefer_get = false ) {
30
+
31
+ if ( isset( $_GET['action'] ) && $prefer_get )
32
+ return sanitize_text_field( $_GET['action'] );
33
+
34
+ if ( isset( $_POST['action'] ) )
35
+ return sanitize_text_field( $_POST['action'] );
36
+
37
+ if ( isset( $_GET['action'] ) )
38
+ return sanitize_text_field( $_GET['action'] );
39
+
40
+ return false;
41
+
42
+ }
43
+ }
44
+
45
+ if( !function_exists( 'woo_is_wpsc_activated' ) ) {
46
+ function woo_is_wpsc_activated() {
47
+
48
+ if( class_exists( 'WP_eCommerce' ) || defined( 'WPSC_VERSION' ) )
49
+ return true;
50
+
51
+ }
52
+ }
53
+
54
+ if( !function_exists( 'woo_is_woo_activated' ) ) {
55
+ function woo_is_woo_activated() {
56
+
57
+ if( class_exists( 'Woocommerce' ) )
58
+ return true;
59
+
60
+ }
61
+ }
62
+
63
+ if( !function_exists( 'woo_is_jigo_activated' ) ) {
64
+ function woo_is_jigo_activated() {
65
+
66
+ if( function_exists( 'jigoshop_init' ) )
67
+ return true;
68
+
69
+ }
70
+ }
71
+
72
+ if( !function_exists( 'woo_is_exchange_activated' ) ) {
73
+ function woo_is_exchange_activated() {
74
+
75
+ if( function_exists( 'IT_Exchange' ) )
76
+ return true;
77
+
78
+ }
79
+ }
80
+
81
+ if( !function_exists( 'woo_get_woo_version' ) ) {
82
+ function woo_get_woo_version() {
83
+
84
+ $version = false;
85
+ if( defined( 'WC_VERSION' ) ) {
86
+ $version = WC_VERSION;
87
+ // Backwards compatibility
88
+ } else if( defined( 'WOOCOMMERCE_VERSION' ) ) {
89
+ $version = WOOCOMMERCE_VERSION;
90
+ }
91
+ return $version;
92
+
93
+ }
94
+ }
95
+ ?>
exporter.php ADDED
@@ -0,0 +1,574 @@
1
+ <?php
2
+ /*
3
+ Plugin Name: WooCommerce - Store Exporter
4
+ Plugin URI: http://www.visser.com.au/woocommerce/plugins/exporter/
5
+ Description: Export store details out of WooCommerce into simple formatted files (e.g. CSV, XML, Excel formats including XLS and XLSX, etc.)
6
+ Version: 1.9.1.1
7
+ Author: Visser Labs
8
+ Author URI: http://www.visser.com.au/about/
9
+ Text Domain: woocommerce-exporter
10
+ License: GPL2
11
+
12
+ Text Domain: woocommerce-exporter
13
+ Domain Path: /languages/
14
+ */
15
+
16
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
17
+
18
+ define( 'WOO_CE_DIRNAME', basename( dirname( __FILE__ ) ) );
19
+ define( 'WOO_CE_RELPATH', basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ) );
20
+ define( 'WOO_CE_PATH', plugin_dir_path( __FILE__ ) );
21
+ define( 'WOO_CE_PREFIX', 'woo_ce' );
22
+
23
+ // Turn this on to enable additional debugging options at export time
24
+ if( !defined( 'WOO_CE_DEBUG' ) )
25
+ define( 'WOO_CE_DEBUG', false );
26
+
27
+ // Avoid conflicts if Store Exporter Deluxe is activated
28
+ include_once( WOO_CE_PATH . 'common/common.php' );
29
+ if( defined( 'WOO_CD_PREFIX' ) == false )
30
+ include_once( WOO_CE_PATH . 'includes/functions.php' );
31
+
32
+ // Plugin language support
33
+ function woo_ce_i18n() {
34
+
35
+ $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-exporter' );
36
+ load_textdomain( 'woocommerce-exporter', WP_LANG_DIR . '/woocommerce-exporter/woocommerce-exporter-' . $locale . '.mo' );
37
+ load_plugin_textdomain( 'woocommerce-exporter', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
38
+
39
+ }
40
+ add_action( 'init', 'woo_ce_i18n', 11 );
41
+
42
+ if( is_admin() ) {
43
+
44
+ /* Start of: WordPress Administration */
45
+
46
+ // Register our install script for first time install
47
+ include_once( WOO_CE_PATH . 'includes/install.php' );
48
+ register_activation_hook( __FILE__, 'woo_ce_install' );
49
+
50
+ // Initial scripts and export process
51
+ function woo_ce_admin_init() {
52
+
53
+ global $export, $wp_roles;
54
+
55
+ $action = ( function_exists( 'woo_get_action' ) ? woo_get_action() : false );
56
+
57
+ // Now is the time to de-activate Store Exporter if Store Exporter Deluxe is activated
58
+ if( defined( 'WOO_CD_PREFIX' ) ) {
59
+ include_once( WOO_CE_PATH . 'includes/install.php' );
60
+ woo_ce_deactivate_ce();
61
+ return;
62
+ }
63
+
64
+ // An effort to reduce the memory load at export time
65
+ if( $action <> 'export' ) {
66
+
67
+ $troubleshooting_url = 'https://www.visser.com.au/documentation/store-exporter-deluxe/troubleshooting/';
68
+
69
+ // Check the User has the activate_plugins capability
70
+ $user_capability = 'activate_plugins';
71
+ if( current_user_can( $user_capability ) ) {
72
+
73
+ // Detect if another e-Commerce platform is activated
74
+ if( !woo_is_woo_activated() && ( woo_is_jigo_activated() || woo_is_wpsc_activated() ) ) {
75
+ $message = __( 'We have detected another e-Commerce Plugin than WooCommerce activated, please check that you are using Store Exporter for the correct platform.', 'woocommerce-exporter' );
76
+ $message .= sprintf( ' <a href="%s" target="_blank">%s</a>', $troubleshooting_url, __( 'Need help?', 'woocommerce-exporter' ) );
77
+ woo_ce_admin_notice( $message, 'error', 'plugins.php' );
78
+ } else if( !woo_is_woo_activated() ) {
79
+ $message = __( 'We have been unable to detect the WooCommerce Plugin activated on this WordPress site, please check that you are using Store Exporter for the correct platform.', 'woocommerce-exporter' );
80
+ $message .= sprintf( ' <a href="%s" target="_blank">%s</a>', $troubleshooting_url, __( 'Need help?', 'woocommerce-exporter' ) );
81
+ woo_ce_admin_notice( $message, 'error', 'plugins.php' );
82
+ }
83
+
84
+ // Detect if any known conflict Plugins are activated
85
+
86
+ // WooCommerce Subscriptions Exporter - http://codecanyon.net/item/woocommerce-subscription-exporter/6569668
87
+ if( function_exists( 'wc_subs_exporter_admin_init' ) ) {
88
+ $message = __( 'We have detected an activated Plugin for WooCommerce that is known to conflict with Store Exporter, please de-activate WooCommerce Subscriptions Exporter to resolve export issues within Store Exporter.', 'woocommerce-exporter' );
89
+ $message .= sprintf( '<a href="%s" target="_blank">%s</a>', $troubleshooting_url, __( 'Need help?', 'woocommerce-exporter' ) );
90
+ woo_ce_admin_notice( $message, 'error', array( 'plugins.php', 'admin.php' ) );
91
+ }
92
+
93
+ // WP Easy Events Professional - https://emdplugins.com/plugins/wp-easy-events-professional/
94
+ if( class_exists( 'WP_Easy_Events_Professional' ) ) {
95
+ $message = __( 'We have detected an activated Plugin that is known to conflict with Store Exporter Deluxe, please de-activate WP Easy Events Professional to resolve export issues within Store Exporter Deluxe.', 'woocommerce-exporter' );
96
+ $message .= sprintf( '<a href="%s" target="_blank">%s</a>', $troubleshooting_url, __( 'Need help?', 'woocommerce-exporter' ) );
97
+ woo_ce_admin_notice( $message, 'error', array( 'plugins.php', 'admin.php' ) );
98
+ }
99
+
100
+ // Plugin row notices for the Plugins screen
101
+ add_action( 'after_plugin_row_' . WOO_CE_RELPATH, 'woo_ce_admin_plugin_row' );
102
+
103
+ }
104
+
105
+ // Check the User has the view_woocommerce_reports capability
106
+ $user_capability = apply_filters( 'woo_ce_admin_user_capability', 'view_woocommerce_reports' );
107
+ if( current_user_can( $user_capability ) == false )
108
+ return;
109
+
110
+ // Check that we are on the Store Exporter screen
111
+ $page = ( isset($_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : false );
112
+ if( $page != strtolower( WOO_CE_PREFIX ) )
113
+ return;
114
+
115
+ // Add memory usage to screen footer
116
+ add_filter( 'admin_footer_text', 'woo_ce_admin_footer_text' );
117
+
118
+ }
119
+
120
+ // Process any pre-export notice confirmations
121
+ switch( $action ) {
122
+
123
+ // This is where the magic happens
124
+ case 'export':
125
+
126
+ // Make sure we play nice with other WooCommerce and WordPress exporters
127
+ if( !isset( $_POST['woo_ce_export'] ) )
128
+ return;
129
+
130
+ check_admin_referer( 'manual_export', 'woo_ce_export' );
131
+
132
+ // Hide error logging during the export process
133
+ if( function_exists( 'ini_set' ) )
134
+ @ini_set( 'display_errors', 0 );
135
+
136
+ // Welcome in the age of GZIP compression and Object caching
137
+ if( !defined( 'DONOTCACHEPAGE' ) )
138
+ define( 'DONOTCACHEPAGE', true );
139
+ if( !defined( 'DONOTCACHCEOBJECT' ) )
140
+ define( 'DONOTCACHCEOBJECT', true );
141
+
142
+ // Set artificially high because we are building this export in memory
143
+ if( function_exists( 'wp_raise_memory_limit' ) ) {
144
+ add_filter( 'export_memory_limit', 'woo_ce_raise_export_memory_limit' );
145
+ wp_raise_memory_limit( 'export' );
146
+ }
147
+
148
+ $timeout = woo_ce_get_option( 'timeout', 0 );
149
+ $safe_mode = ( function_exists( 'safe_mode' ) ? ini_get( 'safe_mode' ) : false );
150
+ if( !$safe_mode ) {
151
+ if( function_exists( 'set_time_limit' ) )
152
+ @set_time_limit( $timeout );
153
+ if( function_exists( 'ini_set' ) )
154
+ @ini_set( 'max_execution_time', $timeout );
155
+ }
156
+ if( function_exists( 'ini_set' ) )
157
+ @ini_set( 'memory_limit', WP_MAX_MEMORY_LIMIT );
158
+
159
+ // Set up the basic export options
160
+ $export = new stdClass();
161
+ $export->cron = 0;
162
+ $export->scheduled_export = 0;
163
+ $export->start_time = time();
164
+ $export->idle_memory_start = woo_ce_current_memory_usage();
165
+ $export->encoding = woo_ce_get_option( 'encoding', get_option( 'blog_charset', 'UTF-8' ) );
166
+ // Reset the Encoding if corrupted
167
+ if( $export->encoding == '' || $export->encoding == false || $export->encoding == 'System default' ) {
168
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Encoding export option was corrupted, defaulted to UTF-8', 'woocommerce-exporter' ) ) );
169
+ $export->encoding = 'UTF-8';
170
+ woo_ce_update_option( 'encoding', 'UTF-8' );
171
+ }
172
+ $export->delimiter = woo_ce_get_option( 'delimiter', ',' );
173
+ // Reset the Delimiter if corrupted
174
+ if( $export->delimiter == '' || $export->delimiter == false ) {
175
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Delimiter export option was corrupted, defaulted to ,', 'woocommerce-exporter' ) ) );
176
+ $export->delimiter = ',';
177
+ woo_ce_update_option( 'delimiter', ',' );
178
+ }
179
+ $export->category_separator = woo_ce_get_option( 'category_separator', '|' );
180
+ // Reset the Category Separator if corrupted
181
+ if( $export->category_separator == '' || $export->category_separator == false ) {
182
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Category Separator export option was corrupted, defaulted to |', 'woocommerce-exporter' ) ) );
183
+ $export->category_separator = '|';
184
+ woo_ce_update_option( 'category_separator', '|' );
185
+ }
186
+ $export->bom = woo_ce_get_option( 'bom', 1 );
187
+ $export->escape_formatting = woo_ce_get_option( 'escape_formatting', 'all' );
188
+ // Reset the Escape Formatting if corrupted
189
+ if( $export->escape_formatting == '' || $export->escape_formatting == false ) {
190
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Escape Formatting export option was corrupted, defaulted to all.', 'woocommerce-exporter' ) ) );
191
+ $export->escape_formatting = 'all';
192
+ woo_ce_update_option( 'escape_formatting', 'all' );
193
+ }
194
+ $date_format = woo_ce_get_option( 'date_format', 'd/m/Y' );
195
+ // Reset the Date Format if corrupted
196
+ if( $date_format == '1' || $date_format == '' || $date_format == false ) {
197
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Date Format export option was corrupted, defaulted to d/m/Y', 'woocommerce-exporter' ) ) );
198
+ $date_format = 'd/m/Y';
199
+ woo_ce_update_option( 'date_format', $date_format );
200
+ }
201
+
202
+ // Save export option changes made on the Export screen
203
+ $export->limit_volume = ( isset( $_POST['limit_volume'] ) ? sanitize_text_field( $_POST['limit_volume'] ) : '' );
204
+ woo_ce_update_option( 'limit_volume', $export->limit_volume );
205
+ if( in_array( $export->limit_volume, array( '', '0', '-1' ) ) ) {
206
+ woo_ce_update_option( 'limit_volume', '' );
207
+ $export->limit_volume = -1;
208
+ }
209
+ $export->offset = ( isset( $_POST['offset'] ) ? sanitize_text_field( $_POST['offset'] ) : '' );
210
+ woo_ce_update_option( 'offset', $export->offset );
211
+ if( in_array( $export->offset, array( '', '0' ) ) ) {
212
+ woo_ce_update_option( 'offset', '' );
213
+ $export->offset = 0;
214
+ }
215
+ $export->type = ( isset( $_POST['dataset'] ) ? sanitize_text_field( $_POST['dataset'] ) : false );
216
+
217
+ // Set default values for all export options to be later passed onto the export process
218
+ $export->fields = array();
219
+ $export->fields_order = false;
220
+ $export->export_format = 'csv';
221
+
222
+ // Product sorting
223
+ $export->product_categories = false;
224
+ $export->product_tags = false;
225
+ $export->product_status = false;
226
+ $export->product_type = false;
227
+ $export->product_orderby = false;
228
+ $export->product_order = false;
229
+ $export->gallery_formatting = false;
230
+ $export->upsell_formatting = false;
231
+ $export->crosssell_formatting = false;
232
+
233
+ // Category sorting
234
+ $export->category_orderby = false;
235
+ $export->category_order = false;
236
+
237
+ // Tag sorting
238
+ $export->tag_orderby = false;
239
+ $export->tag_order = false;
240
+
241
+ // User sorting
242
+ $export->user_orderby = false;
243
+ $export->user_order = false;
244
+
245
+ if( !empty( $export->type ) ) {
246
+ $export->fields = ( isset( $_POST[$export->type . '_fields'] ) ? array_map( 'sanitize_text_field', $_POST[$export->type . '_fields'] ) : false );
247
+ $export->fields_order = ( isset( $_POST[$export->type . '_fields_order'] ) ? array_map( 'absint', $_POST[$export->type . '_fields_order'] ) : false );
248
+ woo_ce_update_option( 'last_export', $export->type );
249
+ }
250
+
251
+ woo_ce_load_export_types();
252
+
253
+ switch( $export->type ) {
254
+
255
+ case 'product':
256
+ // Set up dataset specific options
257
+ $export->product_categories = ( isset( $_POST['product_filter_category'] ) ? woo_ce_format_product_filters( array_map( 'absint', $_POST['product_filter_category'] ) ) : false );
258
+ $export->product_tags = ( isset( $_POST['product_filter_tag'] ) ? woo_ce_format_product_filters( array_map( 'absint', $_POST['product_filter_tag'] ) ) : false );
259
+ $export->product_status = ( isset( $_POST['product_filter_status'] ) ? woo_ce_format_product_filters( array_map( 'sanitize_text_field', $_POST['product_filter_status'] ) ) : false );
260
+ $export->product_type = ( isset( $_POST['product_filter_type'] ) ? woo_ce_format_product_filters( array_map( 'sanitize_text_field', $_POST['product_filter_type'] ) ) : false );
261
+ $export->product_orderby = ( isset( $_POST['product_orderby'] ) ? sanitize_text_field( $_POST['product_orderby'] ) : false );
262
+ $export->product_order = ( isset( $_POST['product_order'] ) ? sanitize_text_field( $_POST['product_order'] ) : false );
263
+ $export->gallery_formatting = ( isset( $_POST['product_gallery_formatting'] ) ? absint( $_POST['product_gallery_formatting'] ) : false );
264
+ $export->upsell_formatting = ( isset( $_POST['product_upsell_formatting'] ) ? absint( $_POST['product_upsell_formatting'] ) : false );
265
+ $export->crosssell_formatting = ( isset( $_POST['product_crosssell_formatting'] ) ? absint( $_POST['product_crosssell_formatting'] ) : false );
266
+
267
+ // Save dataset export specific options
268
+ if( $export->product_orderby <> woo_ce_get_option( 'product_orderby' ) )
269
+ woo_ce_update_option( 'product_orderby', $export->product_orderby );
270
+ if( $export->product_order <> woo_ce_get_option( 'product_order' ) )
271
+ woo_ce_update_option( 'product_order', $export->product_order );
272
+ if( $export->upsell_formatting <> woo_ce_get_option( 'upsell_formatting' ) )
273
+ woo_ce_update_option( 'upsell_formatting', $export->upsell_formatting );
274
+ if( $export->crosssell_formatting <> woo_ce_get_option( 'crosssell_formatting' ) )
275
+ woo_ce_update_option( 'crosssell_formatting', $export->crosssell_formatting );
276
+ break;
277
+
278
+ case 'category':
279
+ // Set up dataset specific options
280
+ $export->category_orderby = ( isset( $_POST['category_orderby'] ) ? sanitize_text_field( $_POST['category_orderby'] ) : false );
281
+ $export->category_order = ( isset( $_POST['category_order'] ) ? sanitize_text_field( $_POST['category_order'] ) : false );
282
+
283
+ // Save dataset export specific options
284
+ if( $export->category_orderby <> woo_ce_get_option( 'category_orderby' ) )
285
+ woo_ce_update_option( 'category_orderby', $export->category_orderby );
286
+ if( $export->category_order <> woo_ce_get_option( 'category_order' ) )
287
+ woo_ce_update_option( 'category_order', $export->category_order );
288
+ break;
289
+
290
+ case 'tag':
291
+ // Set up dataset specific options
292
+ $export->tag_orderby = ( isset( $_POST['tag_orderby'] ) ? sanitize_text_field( $_POST['tag_orderby'] ) : false );
293
+ $export->tag_order = ( isset( $_POST['tag_order'] ) ? sanitize_text_field( $_POST['tag_order'] ) : false );
294
+
295
+ // Save dataset export specific options
296
+ if( $export->tag_orderby <> woo_ce_get_option( 'tag_orderby' ) )
297
+ woo_ce_update_option( 'tag_orderby', $export->tag_orderby );
298
+ if( $export->tag_order <> woo_ce_get_option( 'tag_order' ) )
299
+ woo_ce_update_option( 'tag_order', $export->tag_order );
300
+ break;
301
+
302
+ case 'user':
303
+ // Set up dataset specific options
304
+ $export->user_orderby = ( isset( $_POST['user_orderby'] ) ? sanitize_text_field( $_POST['user_orderby'] ) : false );
305
+ $export->user_order = ( isset( $_POST['user_order'] ) ? sanitize_text_field( $_POST['user_order'] ) : false );
306
+
307
+ // Save dataset export specific options
308
+ if( $export->user_orderby <> woo_ce_get_option( 'user_orderby' ) )
309
+ woo_ce_update_option( 'user_orderby', $export->user_orderby );
310
+ if( $export->user_order <> woo_ce_get_option( 'user_order' ) )
311
+ woo_ce_update_option( 'user_order', $export->user_order );
312
+ break;
313
+
314
+ }
315
+ if( $export->type ) {
316
+
317
+ $timeout = 600;
318
+ if( isset( $_POST['timeout'] ) ) {
319
+ $timeout = absint( $_POST['timeout'] );
320
+ if( $timeout <> woo_ce_get_option( 'timeout' ) )
321
+ woo_ce_update_option( 'timeout', $timeout );
322
+ }
323
+ if( !ini_get( 'safe_mode' ) ) {
324
+ @set_time_limit( $timeout );
325
+ @ini_set( 'max_execution_time', $timeout );
326
+ }
327
+
328
+ @ini_set( 'memory_limit', WP_MAX_MEMORY_LIMIT );
329
+
330
+ $export->args = array(
331
+ 'limit_volume' => $export->limit_volume,
332
+ 'offset' => $export->offset,
333
+ 'encoding' => $export->encoding,
334
+ 'date_format' => $date_format,
335
+ 'product_categories' => $export->product_categories,
336
+ 'product_tags' => $export->product_tags,
337
+ 'product_status' => $export->product_status,
338
+ 'product_type' => $export->product_type,
339
+ 'product_orderby' => $export->product_orderby,
340
+ 'product_order' => $export->product_order,
341
+ 'category_orderby' => $export->category_orderby,
342
+ 'category_order' => $export->category_order,
343
+ 'tag_orderby' => $export->tag_orderby,
344
+ 'tag_order' => $export->tag_order,
345
+ 'user_orderby' => $export->user_orderby,
346
+ 'user_order' => $export->user_order
347
+ );
348
+ if( empty( $export->fields ) ) {
349
+ $message = __( 'No export fields were selected, please try again with at least a single export field.', 'woocommerce-exporter' );
350
+ woo_ce_admin_notice( $message, 'error' );
351
+ return;
352
+ }
353
+ woo_ce_save_fields( $export->type, $export->fields, $export->fields_order );
354
+
355
+ if( $export->export_format == 'csv' ) {
356
+ $export->filename = woo_ce_generate_csv_filename( $export->type );
357
+ }
358
+
359
+ // Print file contents to debug export screen
360
+ if( WOO_CE_DEBUG ) {
361
+
362
+ if( in_array( $export->export_format, array( 'csv' ) ) ) {
363
+ woo_ce_export_dataset( $export->type );
364
+ }
365
+ $export->idle_memory_end = woo_ce_current_memory_usage();
366
+ $export->end_time = time();
367
+
368
+ // Print file contents to browser
369
+ } else {
370
+ if( in_array( $export->export_format, array( 'csv' ) ) ) {
371
+
372
+ // Generate CSV contents
373
+ $bits = woo_ce_export_dataset( $export->type );
374
+ unset( $export->fields );
375
+ if( empty( $bits ) ) {
376
+ $message = __( 'No export entries were found, please try again with different export filters.', 'woocommerce-exporter' );
377
+ woo_ce_admin_notice( $message, 'error' );
378
+ return;
379
+ }
380
+ if( woo_ce_get_option( 'delete_file', 1 ) ) {
381
+
382
+ // Print directly to browser
383
+ if( $export->export_format == 'csv' )
384
+ woo_ce_generate_csv_header( $export->type );
385
+ echo $bits;
386
+ exit();
387
+
388
+ } else {
389
+
390
+ // Save to file and insert to WordPress Media
391
+ if( $export->filename && $bits ) {
392
+ if( $export->export_format == 'csv' )
393
+ $post_ID = woo_ce_save_file_attachment( $export->filename, 'text/csv' );
394
+ $upload = wp_upload_bits( $export->filename, null, $bits );
395
+ if( ( $post_ID == false ) || $upload['error'] ) {
396
+ wp_delete_attachment( $post_ID, true );
397
+ if( isset( $upload['error'] ) )
398
+ wp_redirect( esc_url( add_query_arg( array( 'failed' => true, 'message' => urlencode( $upload['error'] ) ) ) ) );
399
+ else
400
+ wp_redirect( esc_url( add_query_arg( array( 'failed' => true ) ) ) );
401
+ return;
402
+ }
403
+ $attach_data = wp_generate_attachment_metadata( $post_ID, $upload['file'] );
404
+ wp_update_attachment_metadata( $post_ID, $attach_data );
405
+ update_attached_file( $post_ID, $upload['file'] );
406
+ if( $post_ID ) {
407
+ woo_ce_save_file_guid( $post_ID, $export->type, $upload['url'] );
408
+ woo_ce_save_file_details( $post_ID );
409
+ }
410
+ $export_type = $export->type;
411
+ unset( $export );
412
+
413
+ // The end memory usage and time is collected at the very last opportunity prior to the CSV header being rendered to the screen
414
+ woo_ce_update_file_detail( $post_ID, '_woo_idle_memory_end', woo_ce_current_memory_usage() );
415
+ woo_ce_update_file_detail( $post_ID, '_woo_end_time', time() );
416
+
417
+ // Generate CSV header
418
+ woo_ce_generate_csv_header( $export_type );
419
+ unset( $export_type );
420
+
421
+ // Print file contents to screen
422
+ if( $upload['file'] ) {
423
+ readfile( $upload['file'] );
424
+ } else {
425
+ $url = add_query_arg( 'failed', true );
426
+ wp_redirect( $url );
427
+ }
428
+ unset( $upload );
429
+ } else {
430
+ $url = add_query_arg( 'failed', true );
431
+ wp_redirect( $url );
432
+ }
433
+
434
+ }
435
+
436
+ }
437
+ exit();
438
+ }
439
+ }
440
+ break;
441
+
442
+ // Save changes on Settings screen
443
+ case 'save-settings':
444
+ // We need to verify the nonce.
445
+ if( !empty( $_POST ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'woo_ce_save_settings' ) ) {
446
+ if( check_admin_referer( 'woo_ce_save_settings' ) )
447
+ woo_ce_export_settings_save();
448
+ }
449
+ break;
450
+
451
+ // Save changes on Field Editor screen
452
+ case 'save-fields':
453
+ // We need to verify the nonce.
454
+ if( !empty( $_POST ) && check_admin_referer( 'save_fields', 'woo_ce_save_fields' ) ) {
455
+ $fields = ( isset( $_POST['fields'] ) ? array_filter( $_POST['fields'] ) : array() );
456
+ $export_type = ( isset( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : '' );
457
+ $export_types = array_keys( woo_ce_get_export_types() );
458
+ // Check we are saving against a valid export type
459
+ if( in_array( $export_type, $export_types ) ) {
460
+ woo_ce_update_option( $export_type . '_labels', $fields );
461
+ $message = __( 'Field labels have been saved.', 'woocommerce-exporter' );
462
+ woo_ce_admin_notice( $message );
463
+ } else {
464
+ $message = __( 'Changes could not be saved as we could not detect a valid export type. Raise this as a Premium Support issue and include what export type you were editing.', 'woocommerce-exporter' );
465
+ woo_ce_admin_notice( $message, 'error' );
466
+ }
467
+ }
468
+ break;
469
+
470
+ }
471
+
472
+ }
473
+ add_action( 'admin_init', 'woo_ce_admin_init', 11 );
474
+
475
+ // HTML templates and form processor for Store Exporter screen
476
+ function woo_ce_html_page() {
477
+
478
+ // Check the User has the view_woocommerce_reports capability
479
+ $user_capability = apply_filters( 'woo_ce_admin_user_capability', 'view_woocommerce_reports' );
480
+ if( current_user_can( $user_capability ) == false )
481
+ return;
482
+
483
+ global $wpdb, $export;
484
+
485
+ $title = apply_filters( 'woo_ce_template_header', __( 'Store Exporter', 'woocommerce-exporter' ) );
486
+ woo_ce_template_header( $title );
487
+ woo_ce_support_donate();
488
+ $action = ( function_exists( 'woo_get_action' ) ? woo_get_action() : false );
489
+ switch( $action ) {
490
+
491
+ case 'export':
492
+ if( WOO_CE_DEBUG ) {
493
+ if( false === ( $export_log = get_transient( WOO_CE_PREFIX . '_debug_log' ) ) ) {
494
+ $export_log = __( 'No export entries were found within the debug Transient, please try again with different export filters.', 'woocommerce-exporter' );
495
+ } else {
496
+ // We take the contents of our WordPress Transient and de-base64 it back to CSV format
497
+ $export_log = base64_decode( $export_log );
498
+ }
499
+ delete_transient( WOO_CE_PREFIX . '_debug_log' );
500
+ $output = '
501
+ <h3>' . sprintf( __( 'Export Details: %s', 'woocommerce-exporter' ), esc_attr( $export->filename ) ) . '</h3>
502
+ <p>' . __( 'This prints the $export global that contains the different export options and filters to help reproduce this on another instance of WordPress. Very useful for debugging blank or unexpected exports.', 'woocommerce-exporter' ) . '</p>
503
+ <textarea id="export_log">' . esc_textarea( print_r( $export, true ) ) . '</textarea>
504
+ <hr />';
505
+ if( in_array( $export->export_format, array( 'csv' ) ) ) {
506
+ $output .= '
507
+ <script type="text/javascript">
508
+ $j(function() {
509
+ $j(\'#export_sheet\').CSVToTable(\'\', {
510
+ startLine: 0
511
+ });
512
+ });
513
+ </script>
514
+ <h3>' . __( 'Export', 'woocommerce-exporter' ) . '</h3>
515
+ <p>' . __( 'We use the <a href="http://code.google.com/p/jquerycsvtotable/" target="_blank"><em>CSV to Table plugin</em></a> to see first hand formatting errors or unexpected values within the export file.', 'woocommerce-exporter' ) . '</p>
516
+ <div id="export_sheet">' . esc_textarea( $export_log ) . '</div>
517
+ <p class="description">' . __( 'This jQuery plugin can fail with <code>\'Item count (#) does not match header count\'</code> notices which simply mean the number of headers detected does not match the number of cell contents.', 'woocommerce-exporter' ) . '</p>
518
+ <hr />';
519
+ }
520
+ $output .= '
521
+ <h3>' . __( 'Export Log', 'woocommerce-exporter' ) . '</h3>
522
+ <p>' . __( 'This prints the raw export contents and is helpful when the jQuery plugin above fails due to major formatting errors.', 'woocommerce-exporter' ) . '</p>
523
+ <textarea id="export_log" wrap="off">' . esc_textarea( $export_log ) . '</textarea>
524
+ <hr />
525
+ ';
526
+ echo $output;
527
+ }
528
+
529
+ woo_ce_manage_form();
530
+ break;
531
+
532
+ case 'update':
533
+ woo_ce_admin_custom_fields_save();
534
+
535
+ $message = __( 'Custom Fields saved. You can now select those additional fields from the Export Fields list.', 'woocommerce-exporter' );
536
+ woo_ce_admin_notice_html( $message );
537
+ woo_ce_manage_form();
538
+ break;
539
+
540
+ default:
541
+ woo_ce_manage_form();
542
+ break;
543
+
544
+ }
545
+ woo_ce_template_footer();
546
+
547
+ }
548
+
549
+ // HTML template for Export screen
550
+ function woo_ce_manage_form() {
551
+
552
+ $tab = ( isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : false );
553
+ // If Skip Overview is set then jump to Export screen
554
+ if( $tab == false && woo_ce_get_option( 'skip_overview', false ) )
555
+ $tab = 'export';
556
+
557
+ // Check that WC() is available
558
+ if( !function_exists( 'WC' ) ) {
559
+ $message = __( 'We couldn\'t load the WooCommerce resource WC(), check that WooCommerce is installed and active. If this persists get in touch with us.', 'woocommerce-exporter' );
560
+ woo_cd_admin_notice_html( $message, 'error' );
561
+ return;
562
+ }
563
+
564
+ woo_ce_load_export_types();
565
+ woo_ce_admin_fail_notices();
566
+
567
+ include_once( WOO_CE_PATH . 'templates/admin/tabs.php' );
568
+
569
+ }
570
+
571
+ /* End of: WordPress Administration */
572
+
573
+ }
574
+ ?>
includes/admin.php ADDED
@@ -0,0 +1,569 @@
1
+ <?php
2
+ // Display admin notice on screen load
3
+ function woo_ce_admin_notice( $message = '', $priority = 'updated', $screen = '' ) {
4
+
5
+ if( $priority == false || $priority == '' )
6
+ $priority = 'updated';
7
+ if( $message <> '' ) {
8
+ ob_start();
9
+ woo_ce_admin_notice_html( $message, $priority, $screen );
10
+ $output = ob_get_contents();
11
+ ob_end_clean();
12
+ // Check if an existing notice is already in queue
13
+ $existing_notice = get_transient( WOO_CE_PREFIX . '_notice' );
14
+ if( $existing_notice !== false ) {
15
+ $existing_notice = base64_decode( $existing_notice );
16
+ $output = $existing_notice . $output;
17
+ }
18
+ $response = set_transient( WOO_CE_PREFIX . '_notice', base64_encode( $output ), DAY_IN_SECONDS );
19
+ // Check if the Transient was saved
20
+ if( $response !== false )
21
+ add_action( 'admin_notices', 'woo_ce_admin_notice_print' );
22
+ }
23
+
24
+ }
25
+
26
+ // HTML template for admin notice
27
+ function woo_ce_admin_notice_html( $message = '', $priority = 'updated', $screen = '', $id = '' ) {
28
+
29
+ // Default priority to updated
30
+ if( empty( $priority ) )
31
+ $priority = 'updated';
32
+ // Display admin notice on specific screen
33
+ if( !empty( $screen ) ) {
34
+
35
+ global $pagenow;
36
+
37
+ if( is_array( $screen ) ) {
38
+ if( in_array( $pagenow, $screen ) == false )
39
+ return;
40
+ } else {
41
+ if( $pagenow <> $screen )
42
+ return;
43
+ }
44
+
45
+ }
46
+ // Override for WooCommerce notice styling
47
+ if( $priority == 'notice' )
48
+ $priority = 'updated woocommerce-message'; ?>
49
+ <div id="<?php echo ( !empty( $id ) ? sprintf( 'message-%s', $id ) : 'message' ); ?>" class="<?php echo $priority; ?>">
50
+ <p><?php echo $message; ?></p>
51
+ </div>
52
+ <?php
53
+
54
+ }
55
+
56
+ // Grabs the WordPress transient that holds the admin notice and prints it
57
+ function woo_ce_admin_notice_print() {
58
+
59
+ $output = get_transient( WOO_CE_PREFIX . '_notice' );
60
+ if( $output !== false ) {
61
+ delete_transient( WOO_CE_PREFIX . '_notice' );
62
+ $output = base64_decode( $output );
63
+ echo $output;
64
+ }
65
+
66
+ }
67
+
68
+ // HTML template header on Store Exporter screen
69
+ function woo_ce_template_header( $title = '', $icon = 'woocommerce' ) {
70
+
71
+ if( $title )
72
+ $output = $title;
73
+ else
74
+ $output = __( 'Store Export', 'woocommerce-exporter' ); ?>
75
+ <div id="woo-ce" class="wrap">
76
+ <div id="icon-<?php echo $icon; ?>" class="icon32 icon32-woocommerce-importer"><br /></div>
77
+ <h2>
78
+ <?php echo $output; ?>
79
+ </h2>
80
+ <?php
81
+
82
+ }
83
+
84
+ // HTML template footer on Store Exporter screen
85
+ function woo_ce_template_footer() { ?>
86
+ </div>
87
+ <!-- .wrap -->
88
+ <?php
89
+
90
+ }
91
+
92
+ function woo_ce_export_options_export_format() {
93
+
94
+ $woo_cd_url = 'https://www.visser.com.au/plugins/store-exporter-deluxe/?platform=wc';
95
+ $woo_cd_link = sprintf( '<a href="%s" target="_blank">' . __( 'Store Exporter Deluxe', 'woocommerce-exporter' ) . '</a>', $woo_cd_url );
96
+
97
+ ob_start(); ?>
98
+ <tr>
99
+ <th>
100
+ <label><?php _e( 'Export format', 'woocommerce-exporter' ); ?></label>
101
+ </th>
102
+ <td>
103
+ <label><input type="radio" name="export_format" value="csv"<?php checked( 'csv', 'csv' ); ?> /> <?php _e( 'CSV', 'woocommerce-exporter' ); ?> <span class="description"><?php _e( '(Comma Separated Values)', 'woocommerce-exporter' ); ?></span></label><br />
104
+ <label><input type="radio" name="export_format" value="xls" disabled="disabled" /> <?php _e( 'Excel (XLS)', 'woocommerce-exporter' ); ?> <span class="description"><?php _e( '(Excel 97-2003)', 'woocommerce-exporter' ); ?> - <?php printf( __( 'available in %s', 'woocommerce-exporter' ), $woo_cd_link ); ?></span></label><br />
105
+ <label><input type="radio" name="export_format" value="xlsx" disabled="disabled" /> <?php _e( 'Excel (XLSX)', 'woocommerce-exporter' ); ?> <span class="description"><?php _e( '(Excel 2007-2013)', 'woocommerce-exporter' ); ?> - <?php printf( __( 'available in %s', 'woocommerce-exporter' ), $woo_cd_link ); ?></span></label><br />
106
+ <label><input type="radio" name="export_format" value="xml" disabled="disabled" /> <?php _e( 'XML', 'woocommerce-exporter' ); ?> <span class="description"><?php _e( '(EXtensible Markup Language)', 'woocommerce-exporter' ); ?> - <?php printf( __( 'available in %s', 'woocommerce-exporter' ), $woo_cd_link ); ?></span></label><br />
107
+ <div class="export-options product-options">
108
+ <label><input type="radio" name="export_format" value="rss" disabled="disabled" /> <?php _e( 'RSS', 'woocommerce-exporter' ); ?> <span class="description"><?php printf( __( '(<attr title="%s">XML</attr> feed in RSS 2.0 format)', 'woocommerce-exporter' ), __( 'EXtensible Markup Language', 'woocommerce-exporter' ) ); ?> - <?php printf( __( 'available in %s', 'woocommerce-exporter' ), $woo_cd_link ); ?></span></label>
109
+ </div>
110
+ <p class="description"><?php _e( 'Adjust the export format to generate different export file formats.', 'woocommerce-exporter' ); ?></p>
111
+ </td>
112
+ </tr>
113
+ <?php
114
+ ob_end_flush();
115
+
116
+ }
117
+
118
+ // Add Export and Docs links to the Plugins screen
119
+ function woo_ce_add_settings_link( $links, $file ) {
120
+
121
+ // Manually force slug
122
+ $this_plugin = WOO_CE_RELPATH;
123
+
124
+ if( $file == $this_plugin ) {
125
+ $docs_url = 'http://www.visser.com.au/docs/';
126
+ $docs_link = sprintf( '<a href="%s" target="_blank">' . __( 'Docs', 'woocommerce-exporter' ) . '</a>', $docs_url );
127
+ $export_link = sprintf( '<a href="%s">' . __( 'Export', 'woocommerce-exporter' ) . '</a>', esc_url( add_query_arg( 'page', 'woo_ce', 'admin.php' ) ) );
128
+ array_unshift( $links, $docs_link );
129
+ array_unshift( $links, $export_link );
130
+ }
131
+ return $links;
132
+
133
+ }
134
+ add_filter( 'plugin_action_links', 'woo_ce_add_settings_link', 10, 2 );
135
+
136
+ function woo_ce_admin_custom_fields_save() {
137
+
138
+ // Save Custom Product Meta
139
+ if( isset( $_POST['custom_products'] ) ) {
140
+ $custom_products = $_POST['custom_products'];
141
+ $custom_products = explode( "\n", trim( $custom_products ) );
142
+ if( !empty( $custom_products ) ) {
143
+ $size = count( $custom_products );
144
+ if( !empty( $size ) ) {
145
+ for( $i = 0; $i < $size; $i++ )
146
+ $custom_products[$i] = sanitize_text_field( trim( stripslashes( $custom_products[$i] ) ) );
147
+ woo_ce_update_option( 'custom_products', $custom_products );
148
+ }
149
+ } else {
150
+ woo_ce_update_option( 'custom_products', '' );
151
+ }
152
+ unset( $custom_products );
153
+ }
154
+
155
+ }
156
+
157
+ // Add Store Export page to WooCommerce screen IDs
158
+ function woo_ce_wc_screen_ids( $screen_ids = array() ) {
159
+
160
+ $screen_ids[] = 'woocommerce_page_woo_ce';
161
+ return $screen_ids;
162
+
163
+ }
164
+ add_filter( 'woocommerce_screen_ids', 'woo_ce_wc_screen_ids', 10, 1 );
165
+
166
+ // Add Store Export to WordPress Administration menu
167
+ function woo_ce_admin_menu() {
168
+
169
+ $page = add_submenu_page( 'woocommerce', __( 'Store Exporter', 'woocommerce-exporter' ), __( 'Store Export', 'woocommerce-exporter' ), 'view_woocommerce_reports', 'woo_ce', 'woo_ce_html_page' );
170
+ add_action( 'admin_print_styles-' . $page, 'woo_ce_enqueue_scripts' );
171
+ add_action( 'current_screen', 'woo_ce_add_help_tab' );
172
+
173
+ }
174
+ add_action( 'admin_menu', 'woo_ce_admin_menu', 11 );
175
+
176
+ // Load CSS and jQuery scripts for Store Exporter screen
177
+ function woo_ce_enqueue_scripts() {
178
+
179
+ // Simple check that WooCommerce is activated
180
+ if( class_exists( 'WooCommerce' ) ) {
181
+
182
+ global $woocommerce;
183
+
184
+ // Load WooCommerce default Admin styling
185
+ wp_enqueue_style( 'woocommerce_admin_styles', $woocommerce->plugin_url() . '/assets/css/admin.css' );
186
+
187
+ }
188
+
189
+ // Date Picker Addon
190
+ wp_enqueue_script( 'jquery-ui-datepicker' );
191
+ wp_enqueue_style( 'jquery-ui-datepicker', plugins_url( '/templates/admin/jquery-ui-datepicker.css', WOO_CE_RELPATH ) );
192
+
193
+ // Time Picker, Date Picker Addon
194
+ wp_enqueue_script( 'jquery-ui-timepicker', plugins_url( '/js/jquery.timepicker.js', WOO_CE_RELPATH ), array( 'jquery', 'jquery-ui-datepicker' ) );
195
+ wp_enqueue_style( 'jquery-ui-datepicker', plugins_url( '/templates/admin/jquery-ui-timepicker.css', WOO_CE_RELPATH ) );
196
+
197
+ // Chosen
198
+ wp_enqueue_style( 'jquery-chosen', plugins_url( '/templates/admin/chosen.css', WOO_CE_RELPATH ) );
199
+ wp_enqueue_script( 'jquery-chosen', plugins_url( '/js/jquery.chosen.js', WOO_CE_RELPATH ), array( 'jquery' ) );
200
+
201
+ // Common
202
+ wp_enqueue_style( 'woo_ce_styles', plugins_url( '/templates/admin/export.css', WOO_CE_RELPATH ) );
203
+ wp_enqueue_script( 'woo_ce_scripts', plugins_url( '/templates/admin/export.js', WOO_CE_RELPATH ), array( 'jquery', 'jquery-ui-sortable' ) );
204
+ wp_enqueue_style( 'dashicons' );
205
+
206
+ if( WOO_CE_DEBUG ) {
207
+ wp_enqueue_style( 'jquery-csvToTable', plugins_url( '/templates/admin/jquery-csvtable.css', WOO_CE_RELPATH ) );
208
+ wp_enqueue_script( 'jquery-csvToTable', plugins_url( '/js/jquery.csvToTable.js', WOO_CE_RELPATH ), array( 'jquery' ) );
209
+ }
210
+ wp_enqueue_style( 'woo_vm_styles', plugins_url( '/templates/admin/woocommerce-admin_dashboard_vm-plugins.css', WOO_CE_RELPATH ) );
211
+
212
+ }
213
+
214
+ function woo_ce_add_help_tab() {
215
+
216
+ $screen = get_current_screen();
217
+ if( $screen->id <> 'woocommerce_page_woo_ce' )
218
+ return;
219
+
220
+ $screen->add_help_tab( array(
221
+ 'id' => 'woo_ce',
222
+ 'title' => __( 'Store Exporter', 'woocommerce-exporter' ),
223
+ 'content' =>
224
+ '<p>' . __( 'Thank you for using Store Exporter :) Should you need help using this Plugin please read the documentation, if an issue persists get in touch with us on the WordPress.org Support tab for this Plugin.', 'woocommerce-exporter' ) . '</p>' .
225
+ '<p><a href="' . 'http://www.visser.com.au/documentation/store-exporter/usage/' . '" target="_blank" class="button button-primary">' . __( 'Documentation', 'woocommerce-exporter' ) . '</a> <a href="' . 'http://wordpress.org/support/plugin/woocommerce-exporter' . '" target="_blank" class="button">' . __( 'Forum Support', 'woocommerce-exporter' ) . '</a></p>'
226
+ ) );
227
+
228
+ }
229
+
230
+ function woo_ce_admin_plugin_row() {
231
+
232
+ $troubleshooting_url = 'http://www.visser.com.au/documentation/store-exporter-deluxe/';
233
+
234
+ // Detect if another e-Commerce platform is activated
235
+ if( !woo_is_woo_activated() && ( woo_is_jigo_activated() || woo_is_wpsc_activated() ) ) {
236
+ $message = __( 'We have detected another e-Commerce Plugin than WooCommerce activated, please check that you are using Store Exporter for the correct platform.', 'woocommerce-exporter' );
237
+ $message .= sprintf( ' <a href="%s" target="_blank">%s</a>', __( 'Need help?', 'woocommerce-exporter' ), $troubleshooting_url );
238
+ echo '</tr><tr class="plugin-update-tr"><td colspan="3" class="plugin-update colspanchange"><div class="update-message">' . $message . '</div></td></tr>';
239
+ } else if( !woo_is_woo_activated() ) {
240
+ $message = __( 'We have been unable to detect the WooCommerce Plugin activated on this WordPress site, please check that you are using Exporter Deluxe for the correct platform.', 'woocommerce-exporter' );
241
+ $message .= sprintf( ' <a href="%s" target="_blank">%s</a>', $troubleshooting_url, __( 'Need help?', 'woocommerce-exporter' ) );
242
+ echo '</tr><tr class="plugin-update-tr"><td colspan="3" class="plugin-update colspanchange"><div class="update-message">' . $message . '</div></td></tr>';
243
+ }
244
+
245
+ }
246
+
247
+ // HTML active class for the currently selected tab on the Store Exporter screen
248
+ function woo_ce_admin_active_tab( $tab_name = null, $tab = null ) {
249
+
250
+ if( isset( $_GET['tab'] ) && !$tab )
251
+ $tab = $_GET['tab'];
252
+ else if( !isset( $_GET['tab'] ) && woo_ce_get_option( 'skip_overview', false ) )
253
+ $tab = 'export';
254
+ else
255
+ $tab = 'overview';
256
+
257
+ $output = '';
258
+ if( isset( $tab_name ) && $tab_name ) {
259
+ if( $tab_name == $tab )
260
+ $output = ' nav-tab-active';
261
+ }
262
+ echo $output;
263
+
264
+ }
265
+
266
+ // HTML template for each tab on the Store Exporter screen
267
+ function woo_ce_tab_template( $tab = '' ) {
268
+
269
+ if( !$tab )
270
+ $tab = 'overview';
271
+
272
+ // Store Exporter Deluxe
273
+ $woo_cd_url = 'https://www.visser.com.au/plugins/store-exporter-deluxe/?platform=wc';
274
+ $woo_cd_link = sprintf( '<a href="%s" target="_blank">' . __( 'Store Exporter Deluxe', 'woocommerce-exporter' ) . '</a>', $woo_cd_url );
275
+
276
+ $troubleshooting_url = 'http://www.visser.com.au/documentation/store-exporter-deluxe/';
277
+
278
+ switch( $tab ) {
279
+
280
+ case 'overview':
281
+ $skip_overview = woo_ce_get_option( 'skip_overview', false );
282
+ break;
283
+
284
+ case 'export':
285
+ $export_type = sanitize_text_field( ( isset( $_POST['dataset'] ) ? $_POST['dataset'] : woo_ce_get_option( 'last_export', 'product' ) ) );
286
+ $export_types = array_keys( woo_ce_get_export_types() );
287
+
288
+ // Check if the default export type exists
289
+ if( !in_array( $export_type, $export_types ) )
290
+ $export_type = 'product';
291
+
292
+ $product = woo_ce_get_export_type_count( 'product' );
293
+ $category = woo_ce_get_export_type_count( 'category' );
294
+ $tag = woo_ce_get_export_type_count( 'tag' );
295
+ $brand = '999';
296
+ $order = '999';
297
+ $customer = '999';
298
+ $user = woo_ce_get_export_type_count( 'user' );
299
+ $review = '999';
300
+ $coupon = '999';
301
+ $attribute = '999';
302
+ $subscription = '999';
303
+ $product_vendor = '999';
304
+ $commission = '999';
305
+ $shipping_class = '999';
306
+ $ticket = '999';
307
+
308
+ add_action( 'woo_ce_export_options', 'woo_ce_export_options_export_format' );
309
+ if( $product_fields = woo_ce_get_product_fields() ) {
310
+ foreach( $product_fields as $key => $product_field )
311
+ $product_fields[$key]['disabled'] = ( isset( $product_field['disabled'] ) ? $product_field['disabled'] : 0 );
312
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_category' );
313
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_tag' );
314
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_brand' );
315
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_vendor' );
316
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_status' );
317
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_type' );
318
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_stock_status' );
319
+ add_action( 'woo_ce_export_product_options_after_table', 'woo_ce_product_sorting' );
320
+ add_action( 'woo_ce_export_options', 'woo_ce_products_upsells_formatting' );
321
+ add_action( 'woo_ce_export_options', 'woo_ce_products_crosssells_formatting' );
322
+ add_action( 'woo_ce_export_options', 'woo_ce_export_options_gallery_format' );
323
+ add_action( 'woo_ce_export_after_form', 'woo_ce_products_custom_fields' );
324
+ }
325
+ if( $category_fields = woo_ce_get_category_fields() ) {
326
+ foreach( $category_fields as $key => $category_field )
327
+ $category_fields[$key]['disabled'] = ( isset( $category_field['disabled'] ) ? $category_field['disabled'] : 0 );
328
+ add_action( 'woo_ce_export_category_options_after_table', 'woo_ce_category_sorting' );
329
+ }
330
+ if( $tag_fields = woo_ce_get_tag_fields() ) {
331
+ foreach( $tag_fields as $key => $tag_field )
332
+ $tag_fields[$key]['disabled'] = ( isset( $tag_field['disabled'] ) ? $tag_field['disabled'] : 0 );
333
+ add_action( 'woo_ce_export_tag_options_after_table', 'woo_ce_tag_sorting' );
334
+ }
335
+ if( $brand_fields = woo_ce_get_brand_fields() ) {
336
+ foreach( $brand_fields as $key => $brand_field )
337
+ $brand_fields[$key]['disabled'] = ( isset( $brand_field['disabled'] ) ? $brand_field['disabled'] : 0 );
338
+ add_action( 'woo_ce_export_brand_options_before_table', 'woo_ce_brand_sorting' );
339
+ }
340
+ if( $order_fields = woo_ce_get_order_fields() ) {
341
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_date' );
342
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_status' );
343
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_customer' );
344
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_billing_country' );
345
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_shipping_country' );
346
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_user_role' );
347
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_coupon' );
348
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product' );
349
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product_category' );
350
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product_tag' );
351
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product_brand' );
352
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_order_id' );
353
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_payment_gateway' );
354
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_shipping_method' );
355
+ add_action( 'woo_ce_export_order_options_after_table', 'woo_ce_order_sorting' );
356
+ add_action( 'woo_ce_export_options', 'woo_ce_orders_items_formatting' );
357
+ add_action( 'woo_ce_export_options', 'woo_ce_orders_max_order_items' );
358
+ add_action( 'woo_ce_export_options', 'woo_ce_orders_items_types' );
359
+ add_action( 'woo_ce_export_after_form', 'woo_ce_orders_custom_fields' );
360
+ }
361
+ if( $customer_fields = woo_ce_get_customer_fields() ) {
362
+ add_action( 'woo_ce_export_customer_options_before_table', 'woo_ce_customers_filter_by_status' );
363
+ add_action( 'woo_ce_export_customer_options_before_table', 'woo_ce_customers_filter_by_user_role' );
364
+ add_action( 'woo_ce_export_after_form', 'woo_ce_customers_custom_fields' );
365
+ }
366
+ if( $user_fields = woo_ce_get_user_fields() ) {
367
+ foreach( $user_fields as $key => $user_field )
368
+ $user_fields[$key]['disabled'] = ( isset( $user_field['disabled'] ) ? $user_field['disabled'] : 0 );
369
+ add_action( 'woo_ce_export_user_options_after_table', 'woo_ce_user_sorting' );
370
+ add_action( 'woo_ce_export_after_form', 'woo_ce_users_custom_fields' );
371
+ }
372
+ if( $coupon_fields = woo_ce_get_coupon_fields() ) {
373
+ add_action( 'woo_ce_export_coupon_options_before_table', 'woo_ce_coupon_sorting' );
374
+ }
375
+ if( $subscription_fields = woo_ce_get_subscription_fields() ) {
376
+ add_action( 'woo_ce_export_subscription_options_before_table', 'woo_ce_subscriptions_filter_by_subscription_status' );
377
+ add_action( 'woo_ce_export_subscription_options_before_table', 'woo_ce_subscriptions_filter_by_subscription_product' );
378
+ }
379
+ $product_vendor_fields = woo_ce_get_product_vendor_fields();
380
+ if( $commission_fields = woo_ce_get_commission_fields() ) {
381
+ add_action( 'woo_ce_export_commission_options_before_table', 'woo_ce_commissions_filter_by_date' );
382
+ add_action( 'woo_ce_export_commission_options_before_table', 'woo_ce_commissions_filter_by_product_vendor' );
383
+ add_action( 'woo_ce_export_commission_options_before_table', 'woo_ce_commissions_filter_by_commission_status' );
384
+ add_action( 'woo_ce_export_commission_options_before_table', 'woo_ce_commission_sorting' );
385
+ }
386
+ if( $shipping_class_fields = woo_ce_get_shipping_class_fields() ) {
387
+ add_action( 'woo_ce_export_shipping_class_options_after_table', 'woo_ce_shipping_class_sorting' );
388
+ }
389
+ $attribute_fields = false;
390
+
391
+ // Export options
392
+ $limit_volume = woo_ce_get_option( 'limit_volume' );
393
+ $offset = woo_ce_get_option( 'offset' );
394
+ break;
395
+
396
+ case 'fields':
397
+ $export_type = ( isset( $_GET['type'] ) ? sanitize_text_field( $_GET['type'] ) : '' );
398
+ $export_types = array_keys( woo_ce_get_export_types() );
399
+ $fields = array();
400
+ if( in_array( $export_type, $export_types ) ) {
401
+ if( has_filter( 'woo_ce_' . $export_type . '_fields', 'woo_ce_override_' . $export_type . '_field_labels' ) )
402
+ remove_filter( 'woo_ce_' . $export_type . '_fields', 'woo_ce_override_' . $export_type . '_field_labels', 11 );
403
+ if( function_exists( sprintf( 'woo_ce_get_%s_fields', $export_type ) ) )
404
+ $fields = call_user_func( 'woo_ce_get_' . $export_type . '_fields' );
405
+ $labels = woo_ce_get_option( $export_type . '_labels', array() );
406
+ }
407
+ break;
408
+
409
+ case 'archive':
410
+ if( isset( $_GET['deleted'] ) ) {
411
+ $message = __( 'Archived export has been deleted.', 'woocommerce-exporter' );
412
+ woo_ce_admin_notice( $message );
413
+ }
414
+ if( $files = woo_ce_get_archive_files() ) {
415
+ foreach( $files as $key => $file )
416
+ $files[$key] = woo_ce_get_archive_file( $file );
417
+ }
418
+ break;
419
+
420
+ case 'settings':
421
+ $export_filename = woo_ce_get_option( 'export_filename', '' );
422
+ // Default export filename
423
+ if( $export_filename == false )
424
+ $export_filename = '%store_name%-export_%dataset%-%date%-%time%-%random%.csv';
425
+ $delete_file = woo_ce_get_option( 'delete_file', 1 );
426
+ $timeout = woo_ce_get_option( 'timeout', 0 );
427
+ $encoding = woo_ce_get_option( 'encoding', 'UTF-8' );
428
+ $bom = woo_ce_get_option( 'bom', 1 );
429
+ $delimiter = woo_ce_get_option( 'delimiter', ',' );
430
+ $category_separator = woo_ce_get_option( 'category_separator', '|' );
431
+ $escape_formatting = woo_ce_get_option( 'escape_formatting', 'all' );
432
+ $date_format = woo_ce_get_option( 'date_format', 'd/m/Y' );
433
+ // Reset the Date Format if corrupted
434
+ if( $date_format == '1' || $date_format == '' || $date_format == false )
435
+ $date_format = 'd/m/Y';
436
+ $file_encodings = ( function_exists( 'mb_list_encodings' ) ? mb_list_encodings() : false );
437
+ add_action( 'woo_ce_export_settings_top', 'woo_ce_export_settings_quicklinks' );
438
+ add_action( 'woo_ce_export_settings_after', 'woo_ce_export_settings_csv' );
439
+ add_action( 'woo_ce_export_settings_after', 'woo_ce_export_settings_extend' );
440
+ break;
441
+
442
+ case 'tools':
443
+ // Product Importer Deluxe
444
+ $woo_pd_url = 'http://www.visser.com.au/woocommerce/plugins/product-importer-deluxe/';
445
+ $woo_pd_target = ' target="_blank"';
446
+ if( function_exists( 'woo_pd_init' ) ) {
447
+ $woo_pd_url = esc_url( add_query_arg( array( 'page' => 'woo_pd', 'tab' => null ) ) );
448
+ $woo_pd_target = false;
449
+ }
450
+
451
+ // Store Toolkit
452
+ $woo_st_url = 'http://www.visser.com.au/woocommerce/plugins/store-toolkit/';
453
+ $woo_st_target = ' target="_blank"';
454
+ if( function_exists( 'woo_st_admin_init' ) ) {
455
+ $woo_st_url = esc_url( add_query_arg( array( 'page' => 'woo_st', 'tab' => null ) ) );
456
+ $woo_st_target = false;
457
+ }
458
+
459
+ // Export modules
460
+ $module_status = ( isset( $_GET['module_status'] ) ? sanitize_text_field( $_GET['module_status'] ) : false );
461
+ $modules = woo_ce_modules_list( $module_status );
462
+ $modules_all = get_transient( WOO_CE_PREFIX . '_modules_all_count' );
463
+ $modules_active = get_transient( WOO_CE_PREFIX . '_modules_active_count' );
464
+ $modules_inactive = get_transient( WOO_CE_PREFIX . '_modules_inactive_count' );
465
+ break;
466
+
467
+ }
468
+ if( $tab ) {
469
+ if( file_exists( WOO_CE_PATH . 'templates/admin/tabs-' . $tab . '.php' ) ) {
470
+ include_once( WOO_CE_PATH . 'templates/admin/tabs-' . $tab . '.php' );
471
+ } else {
472
+ $message = sprintf( __( 'We couldn\'t load the export template file <code>%s</code> within <code>%s</code>, this file should be present.', 'woocommerce-exporter' ), 'tabs-' . $tab . '.php', WOO_CE_PATH . 'templates/admin/...' );
473
+ woo_ce_admin_notice_html( $message, 'error' );
474
+ ob_start(); ?>
475
+ <p><?php _e( 'You can see this error for one of a few common reasons', 'woocommerce-exporter' ); ?>:</p>
476
+ <ul class="ul-disc">
477
+ <li><?php _e( 'WordPress was unable to create this file when the Plugin was installed or updated', 'woocommerce-exporter' ); ?></li>
478
+ <li><?php _e( 'The Plugin files have been recently changed and there has been a file conflict', 'woocommerce-exporter' ); ?></li>
479
+ <li><?php _e( 'The Plugin file has been locked and cannot be opened by WordPress', 'woocommerce-exporter' ); ?></li>
480
+ </ul>
481
+ <p><?php _e( 'Jump onto our website and download a fresh copy of this Plugin as it might be enough to fix this issue. If this persists get in touch with us.', 'woocommerce-exporter' ); ?></p>
482
+ <?php
483
+ ob_end_flush();
484
+ }
485
+ }
486
+
487
+ }
488
+
489
+ // Display the memory usage in the screen footer
490
+ function woo_ce_admin_footer_text( $footer_text = '' ) {
491
+
492
+ $current_screen = get_current_screen();
493
+ $pages = array(
494
+ 'woocommerce_page_woo_ce'
495
+ );
496
+ // Check to make sure we're on the Export screen
497
+ if ( isset( $current_screen->id ) && apply_filters( 'woo_ce_display_admin_footer_text', in_array( $current_screen->id, $pages ) ) ) {
498
+ $memory_usage = woo_ce_current_memory_usage( false );
499
+ $memory_limit = absint( ini_get( 'memory_limit' ) );
500
+ $memory_percent = absint( $memory_usage / $memory_limit * 100 );
501
+ $memory_color = 'font-weight:normal;';
502
+ if( $memory_percent > 75 )
503
+ $memory_color = 'font-weight:bold; color:orange;';
504
+ if( $memory_percent > 90 )
505
+ $memory_color = 'font-weight:bold; color:red;';
506
+ $footer_text .= ' | ' . sprintf( __( 'Memory: %s of %s MB (%s)', 'woocommerce-exporter' ), $memory_usage, $memory_limit, sprintf( '<span style="%s">%s</span>', $memory_color, $memory_percent . '%' ) );
507
+ }
508
+ return $footer_text;
509
+
510
+ }
511
+
512
+ function woo_ce_modules_status_class( $status = 'inactive' ) {
513
+
514
+ $output = '';
515
+ switch( $status ) {
516
+
517
+ case 'active':
518
+ $output = 'green';
519
+ break;
520
+
521
+ case 'inactive':
522
+ $output = 'yellow';
523
+ break;
524
+
525
+ }
526
+ echo $output;
527
+
528
+ }
529
+
530
+ function woo_ce_modules_status_label( $status = 'inactive' ) {
531
+
532
+ $output = '';
533
+ switch( $status ) {
534
+
535
+ case 'active':
536
+ $output = __( 'OK', 'woocommerce-exporter' );
537
+ break;
538
+
539
+ case 'inactive':
540
+ $output = __( 'Install', 'woocommerce-exporter' );
541
+ break;
542
+
543
+ }
544
+ echo $output;
545
+
546
+ }
547
+
548
+ // HTML template for header prompt on Store Exporter screen
549
+ function woo_ce_support_donate() {
550
+
551
+ $output = '';
552
+ $show = true;
553
+ if( function_exists( 'woo_vl_we_love_your_plugins' ) ) {
554
+ if( in_array( WOO_CE_DIRNAME, woo_vl_we_love_your_plugins() ) )
555
+ $show = false;
556
+ }
557
+ if( $show ) {
558
+ $donate_url = 'http://www.visser.com.au/donate/';
559
+ $rate_url = 'http://wordpress.org/support/view/plugin-reviews/' . WOO_CE_DIRNAME;
560
+ $output = '
561
+ <div id="support-donate_rate" class="support-donate_rate">
562
+ <p>' . sprintf( __( '<strong>Like this Plugin?</strong> %s and %s.', 'woocommerce-exporter' ), '<a href="' . $donate_url . '" target="_blank">' . __( 'Donate to support this Plugin', 'woocommerce-exporter' ) . '</a>', '<a href="' . esc_url( add_query_arg( array( 'rate' => '5' ), $rate_url ) ) . '#postform" target="_blank">rate / review us on WordPress.org</a>' ) . '</p>
563
+ </div>
564
+ ';
565
+ }
566
+ echo $output;
567
+
568
+ }
569
+ ?>
includes/admin/brand.php ADDED
@@ -0,0 +1,33 @@
1
+ <?php
2
+ if( is_admin() ) {
3
+
4
+ /* Start of: WordPress Administration */
5
+
6
+ // HTML template for Coupon Sorting widget on Store Exporter screen
7
+ function woo_ce_brand_sorting() {
8
+
9
+ $orderby = woo_ce_get_option( 'brand_orderby', 'ID' );
10
+ $order = woo_ce_get_option( 'brand_order', 'DESC' );
11
+
12
+ ob_start(); ?>
13
+ <p><label><?php _e( 'Brand Sorting', 'woocommerce-exporter' ); ?></label></p>
14
+ <div>
15
+ <select name="brand_orderby" disabled="disabled">
16
+ <option value="id"><?php _e( 'Term ID', 'woocommerce-exporter' ); ?></option>
17
+ <option value="name"><?php _e( 'Brand Name', 'woocommerce-exporter' ); ?></option>
18
+ </select>
19
+ <select name="brand_order" disabled="disabled">
20
+ <option value="ASC"><?php _e( 'Ascending', 'woocommerce-exporter' ); ?></option>
21
+ <option value="DESC"><?php _e( 'Descending', 'woocommerce-exporter' ); ?></option>
22
+ </select>
23
+ <p class="description"><?php _e( 'Select the sorting of Brands within the exported file. By default this is set to export Product Brands by Term ID in Desending order.', 'woocommerce-exporter' ); ?></p>
24
+ </div>
25
+ <?php
26
+ ob_end_flush();
27
+
28
+ }
29
+
30
+ /* End of: WordPress Administration */
31
+
32
+ }
33
+ ?>
includes/admin/category.php ADDED
@@ -0,0 +1,33 @@
1
+ <?php
2
+ if( is_admin() ) {
3
+
4
+ /* Start of: WordPress Administration */
5
+
6
+ // HTML template for Category Sorting widget on Store Exporter screen
7
+ function woo_ce_category_sorting() {
8
+
9
+ $category_orderby = woo_ce_get_option( 'category_orderby', 'ID' );
10
+ $category_order = woo_ce_get_option( 'category_order', 'DESC' );
11
+
12
+ ob_start(); ?>
13
+ <p><label><?php _e( 'Category Sorting', 'woocommerce-exporter' ); ?></label></p>
14
+ <div>
15
+ <select name="category_orderby">
16
+ <option value="id"<?php selected( 'id', $category_orderby ); ?>><?php _e( 'Term ID', 'woocommerce-exporter' ); ?></option>
17
+ <option value="name"<?php selected( 'name', $category_orderby ); ?>><?php _e( 'Category Name', 'woocommerce-exporter' ); ?></option>
18
+ </select>
19
+ <select name="category_order">
20
+ <option value="ASC"<?php selected( 'ASC', $category_order ); ?>><?php _e( 'Ascending', 'woocommerce-exporter' ); ?></option>
21
+ <option value="DESC"<?php selected( 'DESC', $category_order ); ?>><?php _e( 'Descending', 'woocommerce-exporter' ); ?></option>
22
+ </select>
23
+ <p class="description"><?php _e( 'Select the sorting of Categories within the exported file. By default this is set to export Categories by Term ID in Desending order.', 'woocommerce-exporter' ); ?></p>
24
+ </div>
25
+ <?php
26
+ ob_end_flush();
27
+
28
+ }
29
+
30
+ /* End of: WordPress Administration */
31
+
32
+ }
33
+ ?>
includes/admin/commission.php ADDED
@@ -0,0 +1,83 @@
1
+ <?php
2
+ if( is_admin() ) {
3
+
4
+ /* Start of: WordPress Administration */
5
+
6
+ // HTML template for Filter Commissions by Commission Date widget on Store Exporter screen
7
+ function woo_ce_commissions_filter_by_date() {
8
+
9
+ $woo_cd_url = 'https://www.visser.com.au/plugins/store-exporter-deluxe/?platform=wc';
10
+ $woo_cd_link = sprintf( '<a href="%s" target="_blank">' . __( 'Store Exporter Deluxe', 'woocommerce-exporter' ) . '</a>', $woo_cd_url );
11
+
12
+ $today = date( 'l' );
13
+ $yesterday = date( 'l', strtotime( '-1 days' ) );
14
+ $current_month = date( 'F' );
15
+ $last_month = date( 'F', mktime( 0, 0, 0, date( 'n' )-1, 1, date( 'Y' ) ) );
16
+ $commission_dates_variable = '';
17
+ $commission_dates_variable_length = '';
18
+ $commission_dates_from = woo_ce_get_commission_first_date();
19
+ $commission_dates_to = date( 'd/m/Y' );
20
+
21
+ ob_start(); ?>
22
+ <p><label><input type="checkbox" id="commissions-filters-date" /> <?php _e( 'Filter Commissions by Commission Date', 'woocommerce-exporter' ); ?><span class="description"> - <?php printf( __( 'available in %s', 'woocommerce-exporter' ), $woo_cd_link ); ?></span></label></p>
23
+ <div id="export-commissions-filters-date" class="separator">
24
+ <ul>
25
+ <li>
26
+ <label><input type="radio" name="commission_dates_filter" value="today" disabled="disabled" /> <?php _e( 'Today', 'woocommerce-exporter' ); ?> (<?php echo $today; ?>)</label>
27
+ </li>
28
+ <li>
29
+ <label><input type="radio" name="commission_dates_filter" value="yesterday" disabled="disabled" /> <?php _e( 'Yesterday', 'woocommerce-exporter' ); ?> (<?php echo $yesterday; ?>)</label>
30
+ </li>
31
+ <li>
32
+ <label><input type="radio" name="commission_dates_filter" value="current_week" disabled="disabled" /> <?php _e( 'Current week', 'woocommerce-exporter' ); ?></label>
33
+ </li>
34
+ <li>
35
+ <label><input type="radio" name="commission_dates_filter" value="last_week" disabled="disabled" /> <?php _e( 'Last week', 'woocommerce-exporter' ); ?></label>
36
+ </li>
37
+ <li>
38
+ <label><input type="radio" name="commission_dates_filter" value="current_month" disabled="disabled" /> <?php _e( 'Current month', 'woocommerce-exporter' ); ?> (<?php echo $current_month; ?>)</label>
39
+ </li>
40
+ <li>
41
+ <label><input type="radio" name="commission_dates_filter" value="last_month" disabled="disabled" /> <?php _e( 'Last month', 'woocommerce-exporter' ); ?> (<?php echo $last_month; ?>)</label>
42
+ </li>
43
+ <!--
44
+ <li>
45
+ <label><input type="radio" name="commission_dates_filter" value="last_quarter" disabled="disabled" /> <?php _e( 'Last quarter', 'woocommerce-exporter' ); ?> (Nov. - Jan.)</label>
46
+ </li>
47
+ -->
48
+ <li>
49
+ <label><input type="radio" name="commission_dates_filter" value="variable" disabled="disabled" /> <?php _e( 'Variable date', 'woocommerce-exporter' ); ?></label>
50
+ <div style="margin-top:0.2em;">
51
+ <?php _e( 'Last', 'woocommerce-exporter' ); ?>
52
+ <input type="text" name="commission_dates_filter_variable" class="text code" size="4" maxlength="4" value="<?php echo $commission_dates_variable; ?>" disabled="disabled" />
53
+ <select name="commission_dates_filter_variable_length" style="vertical-align:top;">
54
+ <option value=""<?php selected( $commission_dates_variable_length, '' ); ?>>&nbsp;</option>
55
+ <option value="second"<?php selected( $commission_dates_variable_length, 'second' ); ?> disabled="disabled"><?php _e( 'second(s)', 'woocommerce-exporter' ); ?></option>
56
+ <option value="minute"<?php selected( $commission_dates_variable_length, 'minute' ); ?> disabled="disabled"><?php _e( 'minute(s)', 'woocommerce-exporter' ); ?></option>
57
+ <option value="hour"<?php selected( $commission_dates_variable_length, 'hour' ); ?> disabled="disabled"><?php _e( 'hour(s)', 'woocommerce-exporter' ); ?></option>
58
+ <option value="day"<?php selected( $commission_dates_variable_length, 'day' ); ?> disabled="disabled"><?php _e( 'day(s)', 'woocommerce-exporter' ); ?></option>
59
+ <option value="week"<?php selected( $commission_dates_variable_length, 'week' ); ?> disabled="disabled"><?php _e( 'week(s)', 'woocommerce-exporter' ); ?></option>
60
+ <option value="month"<?php selected( $commission_dates_variable_length, 'month' ); ?> disabled="disabled"><?php _e( 'month(s)', 'woocommerce-exporter' ); ?></option>
61
+ <option value="year"<?php selected( $commission_dates_variable_length, 'year' ); ?> disabled="disabled"><?php _e( 'year(s)', 'woocommerce-exporter' ); ?></option>
62
+ </select>
63
+ </div>
64
+ </li>
65
+ <li>
66
+ <label><input type="radio" name="commission_dates_filter" value="manual" disabled="disabled" /> <?php _e( 'Fixed date', 'woocommerce-exporter' ); ?></label>
67
+ <div style="margin-top:0.2em;">
68
+ <input type="text" size="10" maxlength="10" id="commission_dates_from" name="commission_dates_from" value="<?php echo esc_attr( $commission_dates_from ); ?>" class="text code datepicker" disabled="disabled" /> to <input type="text" size="10" maxlength="10" id="commission_dates_to" name="commission_dates_to" value="<?php echo esc_attr( $commission_dates_to ); ?>" class="text code datepicker" disabled="disabled" />
69
+ <p class="description"><?php _e( 'Filter the dates of Orders to be included in the export. Default is the date of the first Commission to today.', 'woocommerce-exporter' ); ?></p>
70
+ </div>
71
+ </li>
72
+ </ul>
73
+ </div>
74
+ <!-- #export-commissions-filters-date -->
75
+ <?php
76
+ ob_end_flush();
77
+
78
+ }
79
+
80
+ /* End of: WordPress Administration */
81
+
82
+ }
83
+ ?>
includes/admin/coupon.php ADDED
@@ -0,0 +1,33 @@
1
+ <?php
2
+ if( is_admin() ) {
3
+
4
+ /* Start of: WordPress Administration */
5
+
6
+ // HTML template for disabled Coupon Sorting widget on Store Exporter screen
7
+ function woo_ce_coupon_sorting() {
8
+
9
+ ob_start(); ?>
10
+ <p><label><?php _e( 'Coupon Sorting', 'woocommerce-exporter' ); ?></label></p>
11
+ <div>
12
+ <select name="coupon_orderby" disabled="disabled">
13
+ <option value="ID"><?php _e( 'Coupon ID', 'woocommerce-exporter' ); ?></option>
14
+ <option value="title"><?php _e( 'Coupon Code', 'woocommerce-exporter' ); ?></option>
15
+ <option value="date"><?php _e( 'Date Created', 'woocommerce-exporter' ); ?></option>
16
+ <option value="modified"><?php _e( 'Date Modified', 'woocommerce-exporter' ); ?></option>
17
+ <option value="rand"><?php _e( 'Random', 'woocommerce-exporter' ); ?></option>
18
+ </select>
19
+ <select name="coupon_order" disabled="disabled">
20
+ <option value="ASC"><?php _e( 'Ascending', 'woocommerce-exporter' ); ?></option>
21
+ <option value="DESC"><?php _e( 'Descending', 'woocommerce-exporter' ); ?></option>
22
+ </select>
23
+ <p class="description"><?php _e( 'Select the sorting of Coupons within the exported file. By default this is set to export Coupons by Coupon ID in Desending order.', 'woocommerce-exporter' ); ?></p>
24
+ </div>
25
+ <?php
26
+ ob_end_flush();
27
+
28
+ }
29
+
30
+ /* End of: WordPress Administration */
31
+
32
+ }
33
+ ?>
includes/admin/customer.php ADDED
@@ -0,0 +1,124 @@
1
+ <?php
2
+ if( is_admin() ) {
3
+
4
+ /* Start of: WordPress Administration */
5
+
6
+ // HTML template for Filter Customers by Order Status widget on Store Exporter screen
7
+ function woo_ce_customers_filter_by_status() {
8
+
9
+ $woo_cd_url = 'https://www.visser.com.au/plugins/store-exporter-deluxe/?platform=wc';
10
+ $woo_cd_link = sprintf( '<a href="%s" target="_blank">' . __( 'Store Exporter Deluxe', 'woocommerce-exporter' ) . '</a>', $woo_cd_url );
11
+
12
+ $order_statuses = woo_ce_get_order_statuses();
13
+
14
+ ob_start(); ?>
15
+ <p><label><input type="checkbox" id="customers-filters-status" /> <?php _e( 'Filter Customers by Order Status', 'woocommerce-exporter' ); ?><span class="description"> - <?php printf( __( 'available in %s', 'woocommerce-exporter' ), $woo_cd_link ); ?></span></label></p>
16
+ <div id="export-customers-filters-status" class="separator">
17
+ <ul>
18
+ <li>
19
+ <?php if( !empty( $order_statuses ) ) { ?>
20
+ <select data-placeholder="<?php _e( 'Choose a Order Status...', 'woocommerce-exporter' ); ?>" name="customer_filter_status[]" multiple class="chzn-select" style="width:95%;">
21
+ <?php foreach( $order_statuses as $order_status ) { ?>
22
+ <option value="<?php echo $order_status->name; ?>"><?php echo ucfirst( $order_status->name ); ?></option>
23
+ <?php } ?>
24
+ </select>
25
+ <?php } else { ?>
26
+ <?php _e( 'No Order Status\'s were found.', 'woocommerce-exporter' ); ?>
27
+ <?php } ?>
28
+ </li>
29
+ </ul>
30
+ <p class="description"><?php _e( 'Select the Order Status you want to filter exported Customers by. Default is to include all Order Status options.', 'woocommerce-exporter' ); ?></p>
31
+ </div>
32
+ <!-- #export-customers-filters-status -->
33
+ <?php
34
+ ob_end_flush();
35
+
36
+ }
37
+
38
+ // HTML template for Filter Customers by User Role widget on Store Exporter screen
39
+ function woo_ce_customers_filter_by_user_role() {
40
+
41
+ $woo_cd_url = 'https://www.visser.com.au/plugins/store-exporter-deluxe/?platform=wc';
42
+ $woo_cd_link = sprintf( '<a href="%s" target="_blank">' . __( 'Store Exporter Deluxe', 'woocommerce-exporter' ) . '</a>', $woo_cd_url );
43
+
44
+ $user_roles = woo_ce_get_user_roles();
45
+
46
+ ob_start(); ?>
47
+ <p><label><input type="checkbox" id="customers-filters-user_role" /> <?php _e( 'Filter Customers by User Role', 'woocommerce-exporter' ); ?><span class="description"> - <?php printf( __( 'available in %s', 'woocommerce-exporter' ), $woo_cd_link ); ?></span></label></p>
48
+ <div id="export-customers-filters-user_role" class="separator">
49
+ <ul>
50
+ <li>
51
+ <?php if( !empty( $user_roles ) ) { ?>
52
+ <select data-placeholder="<?php _e( 'Choose a User Role...', 'woocommerce-exporter' ); ?>" name="customer_filter_user_role[]" multiple class="chzn-select" style="width:95%;">
53
+ <?php foreach( $user_roles as $key => $user_role ) { ?>
54
+ <option value="<?php echo $key; ?>"><?php echo ucfirst( $user_role['name'] ); ?></option>
55
+ <?php } ?>
56
+ </select>
57
+ <?php } else { ?>
58
+ <?php _e( 'No User Roles were found.', 'woocommerce-exporter' ); ?>
59
+ <?php } ?>
60
+ </li>
61
+ </ul>
62
+ <p class="description"><?php _e( 'Select the User Roles you want to filter exported Customers by. Default is to include all User Role options.', 'woocommerce-exporter' ); ?></p>
63
+ </div>
64
+ <!-- #export-customers-filters-user_role -->
65
+ <?php
66
+ ob_end_flush();
67
+
68
+ }
69
+
70
+ // HTML template for disabled Custom Customers widget on Store Exporter screen
71
+ function woo_ce_customers_custom_fields() {
72
+
73
+ $woo_cd_url = 'https://www.visser.com.au/plugins/store-exporter-deluxe/?platform=wc';
74
+ $woo_cd_link = sprintf( '<a href="%s" target="_blank">' . __( 'Store Exporter Deluxe', 'woocommerce-exporter' ) . '</a>', $woo_cd_url );
75
+
76
+ $custom_customers = '-';
77
+
78
+ $troubleshooting_url = 'http://www.visser.com.au/documentation/store-exporter-deluxe/usage/';
79
+
80
+ ob_start(); ?>
81
+ <form method="post" id="export-customers-custom-fields" class="export-options customer-options">
82
+ <div id="poststuff">
83
+
84
+ <div class="postbox" id="export-options customer-options">
85
+ <h3 class="hndle"><?php _e( 'Custom Customer Fields', 'woocommerce-exporter' ); ?></h3>
86
+ <div class="inside">
87
+ <p class="description"><?php _e( 'To include additional custom Customer meta in the Export Customers table above fill the Customers text box then click Save Custom Fields.', 'woocommerce-exporter' ); ?></p>
88
+ <table class="form-table">
89
+
90
+ <tr>
91
+ <th>
92
+ <label><?php _e( 'Customer meta', 'woocommerce-exporter' ); ?></label>
93
+ </th>
94
+ <td>
95
+ <textarea name="custom_customers" rows="5" cols="70" disabled="disabled"><?php echo esc_textarea( $custom_customers ); ?></textarea>
96
+ <span class="description"> - <?php printf( __( 'available in %s', 'woocommerce-exporter' ), $woo_cd_link ); ?></span>
97
+ <p class="description"><?php _e( 'Include additional custom Customer meta in your export file by adding each custom Customer meta name to a new line above.<br />For example: <code>Customer UA, Customer IP Address</code>', 'woocommerce-exporter' ); ?></p>
98
+ </td>
99
+ </tr>
100
+
101
+ </table>
102
+ <p class="submit">
103
+ <input type="button" class="button button-disabled" value="<?php _e( 'Save Custom Fields', 'woocommerce-exporter' ); ?>" />
104
+ </p>
105
+ <p class="description"><?php printf( __( 'For more information on custom Customer meta consult our <a href="%s" target="_blank">online documentation</a>.', 'woocommerce-exporter' ), $troubleshooting_url ); ?></p>
106
+ </div>
107
+ <!-- .inside -->
108
+ </div>
109
+ <!-- .postbox -->
110
+
111
+ </div>
112
+ <!-- #poststuff -->
113
+ <input type="hidden" name="action" value="update" />
114
+ </form>
115
+ <!-- #export-customers-custom-fields -->
116
+ <?php
117
+ ob_end_flush();
118
+
119
+ }
120
+
121
+ /* End of: WordPress Administration */
122
+
123
+ }
124
+ ?>
includes/admin/order.php ADDED
@@ -0,0 +1,663 @@
1
+ <?php
2
+ if( is_admin() ) {
3
+
4
+ /* Start of: WordPress Administration */
5
+
6
+ // HTML template for Filter Orders by Order Date widget on Store Exporter screen
7
+ function woo_ce_orders_filter_by_date() {
8
+
9
+ $woo_cd_url = 'https://www.visser.com.au/plugins/store-exporter-deluxe/?platform=wc';
10
+ $woo_cd_link = sprintf( '<a href="%s" target="_blank">' . __( 'Store Exporter Deluxe', 'woocommerce-exporter' ) . '</a>', $woo_cd_url );
11
+
12
+ $today = date( 'l' );
13
+ $yesterday = date( 'l', strtotime( '-1 days' ) );
14
+ $current_month = date( 'F' );
15
+ $last_month = date( 'F', mktime( 0, 0, 0, date( 'n' )-1, 1, date( 'Y' ) ) );
16
+ $order_dates_variable = '-';
17
+ $order_dates_variable_length = '';
18
+ $order_dates_from = '-';
19
+ $order_dates_to = '-';
20
+
21
+ ob_start(); ?>
22
+ <p><label><input type="checkbox" id="orders-filters-date" /> <?php _e( 'Filter Orders by Order Date', 'woocommerce-exporter' ); ?><span class="description"> - <?php printf( __( 'available in %s', 'woocommerce-exporter' ), $woo_cd_link ); ?></span></label></p>
23
+ <div id="export-orders-filters-date" class="separator">
24
+ <ul>
25
+ <li>
26
+ <label><input type="radio" name="order_dates_filter" value="today" disabled="disabled" /> <?php _e( 'Today', 'woocommerce-exporter' ); ?> (<?php echo $today; ?>)</label>
27
+ </li>
28
+ <li>
29
+ <label><input type="radio" name="order_dates_filter" value="yesterday" disabled="disabled" /> <?php _e( 'Yesterday', 'woocommerce-exporter' ); ?> (<?php echo $yesterday; ?>)</label>
30
+ </li>
31
+ <li>
32
+ <label><input type="radio" name="order_dates_filter" value="current_week" disabled="disabled" /> <?php _e( 'Current week', 'woocommerce-exporter' ); ?></label>
33
+ </li>
34
+ <li>
35
+ <label><input type="radio" name="order_dates_filter" value="last_week" disabled="disabled" /> <?php _e( 'Last week', 'woocommerce-exporter' ); ?></label>
36
+ </li>
37
+ <li>
38
+ <label><input type="radio" name="order_dates_filter" value="current_month" disabled="disabled" /> <?php _e( 'Current month', 'woocommerce-exporter' ); ?> (<?php echo $current_month; ?>)</label>
39
+ </li>
40
+ <li>
41
+ <label><input type="radio" name="order_dates_filter" value="last_month" disabled="disabled" /> <?php _e( 'Last month', 'woocommerce-exporter' ); ?> (<?php echo $last_month; ?>)</label>
42
+ </li>
43
+ <!--
44
+ <li>
45
+ <label><input type="radio" name="order_dates_filter" value="last_quarter" disabled="disabled" /> <?php _e( 'Last quarter', 'woocommerce-exporter' ); ?> (Nov. - Jan.)</label>
46
+ </li>
47
+ -->
48
+ <li>
49
+ <label><input type="radio" name="order_dates_filter" value="variable" disabled="disabled" /> <?php _e( 'Variable date', 'woocommerce-exporter' ); ?></label>
50
+ <div style="margin-top:0.2em;">
51
+ <?php _e( 'Last', 'woocommerce-exporter' ); ?>
52
+ <input type="text" name="order_dates_filter_variable" class="text code" size="4" maxlength="4" value="<?php echo $order_dates_variable; ?>" disabled="disabled" />
53
+ <select name="order_dates_filter_variable_length" style="vertical-align:top;">
54
+ <option value="">&nbsp;</option>
55
+ <option value="second" disabled="disabled"><?php _e( 'second(s)', 'woocommerce-exporter' ); ?></option>
56
+ <option value="minute" disabled="disabled"><?php _e( 'minute(s)', 'woocommerce-exporter' ); ?></option>
57
+ <option value="hour" disabled="disabled"><?php _e( 'hour(s)', 'woocommerce-exporter' ); ?></option>
58
+ <option value="day" disabled="disabled"><?php _e( 'day(s)', 'woocommerce-exporter' ); ?></option>
59
+ <option value="week" disabled="disabled"><?php _e( 'week(s)', 'woocommerce-exporter' ); ?></option>
60
+ <option value="month" disabled="disabled"><?php _e( 'month(s)', 'woocommerce-exporter' ); ?></option>
61
+ <option value="year" disabled="disabled"><?php _e( 'year(s)', 'woocommerce-exporter' ); ?></option>
62
+ </select>
63
+ </div>
64
+ </li>
65
+ <li>
66
+ <label><input type="radio" name="order_dates_filter" value="manual" disabled="disabled" /> <?php _e( 'Fixed date', 'woocommerce-exporter' ); ?></label>
67
+ <div style="margin-top:0.2em;">
68
+ <input typ