WooCommerce – Store Exporter - Version 1.8.8

Version Description

  • Fixed: Missing WordPress SEO resource
Download this release

Release Info

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

Version 1.8.8

Files changed (65) hide show
  1. common/common.php +95 -0
  2. exporter.php +731 -0
  3. includes/admin.php +547 -0
  4. includes/brand.php +175 -0
  5. includes/category.php +225 -0
  6. includes/commission.php +325 -0
  7. includes/common-dashboard_widgets.php +56 -0
  8. includes/coupon.php +228 -0
  9. includes/customer.php +361 -0
  10. includes/export-csv.php +51 -0
  11. includes/formatting.php +416 -0
  12. includes/functions.php +1537 -0
  13. includes/install.php +42 -0
  14. includes/legacy.php +10 -0
  15. includes/order.php +1665 -0
  16. includes/product-extend.php +802 -0
  17. includes/product.php +1702 -0
  18. includes/product_vendor.php +166 -0
  19. includes/settings.php +567 -0
  20. includes/shipping_class.php +113 -0
  21. includes/subscription.php +323 -0
  22. includes/tag.php +185 -0
  23. includes/user-extend.php +102 -0
  24. includes/user.php +355 -0
  25. js/jquery-ui.js +48 -0
  26. js/jquery.chosen.js +988 -0
  27. js/jquery.csvToTable.js +154 -0
  28. js/jquery.timepicker.js +2245 -0
  29. js/ui-datepicker.js +84 -0
  30. languages/woocommerce-exporter-en_GB.mo +0 -0
  31. languages/woocommerce-exporter-en_GB.po +97 -0
  32. license.txt +281 -0
  33. readme.txt +635 -0
  34. templates/admin/chosen-sprite.png +0 -0
  35. templates/admin/chosen.css +397 -0
  36. templates/admin/export.css +113 -0
  37. templates/admin/export.js +535 -0
  38. templates/admin/images/animated-overlay.gif +0 -0
  39. templates/admin/images/progress.gif +0 -0
  40. templates/admin/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  41. templates/admin/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  42. templates/admin/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  43. templates/admin/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  44. templates/admin/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  45. templates/admin/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  46. templates/admin/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  47. templates/admin/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  48. templates/admin/images/ui-icons_222222_256x240.png +0 -0
  49. templates/admin/images/ui-icons_2e83ff_256x240.png +0 -0
  50. templates/admin/images/ui-icons_454545_256x240.png +0 -0
  51. templates/admin/images/ui-icons_888888_256x240.png +0 -0
  52. templates/admin/images/ui-icons_cd0a0a_256x240.png +0 -0
  53. templates/admin/jquery-csvtable.css +40 -0
  54. templates/admin/jquery-ui-datepicker.css +347 -0
  55. templates/admin/jquery-ui-timepicker.css +12 -0
  56. templates/admin/media-csv_file.php +13 -0
  57. templates/admin/media-export_details.php +41 -0
  58. templates/admin/tabs-archive.php +80 -0
  59. templates/admin/tabs-export.php +964 -0
  60. templates/admin/tabs-fields.php +29 -0
  61. templates/admin/tabs-overview.php +135 -0
  62. templates/admin/tabs-settings.php +192 -0
  63. templates/admin/tabs-tools.php +96 -0
  64. templates/admin/tabs.php +15 -0
  65. 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,731 @@
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.8.8
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
+ define( 'WOO_CE_DEBUG', false );
25
+
26
+ // Avoid conflicts if Store Exporter Deluxe is activated
27
+ include_once( WOO_CE_PATH . 'common/common.php' );
28
+ if( defined( 'WOO_CD_PREFIX' ) == false )
29
+ include_once( WOO_CE_PATH . 'includes/functions.php' );
30
+
31
+ // Plugin language support
32
+ function woo_ce_i18n() {
33
+
34
+ $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-exporter' );
35
+ load_textdomain( 'woocommerce-exporter', WP_LANG_DIR . '/woocommerce-exporter/woocommerce-exporter-' . $locale . '.mo' );
36
+ load_plugin_textdomain( 'woocommerce-exporter', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
37
+
38
+ }
39
+ add_action( 'init', 'woo_ce_i18n', 11 );
40
+
41
+ if( is_admin() ) {
42
+
43
+ /* Start of: WordPress Administration */
44
+
45
+ // Register our install script for first time install
46
+ include_once( WOO_CE_PATH . 'includes/install.php' );
47
+ register_activation_hook( __FILE__, 'woo_ce_install' );
48
+
49
+ // Initial scripts and export process
50
+ function woo_ce_admin_init() {
51
+
52
+ global $export, $wp_roles;
53
+
54
+ // Now is the time to de-activate Store Exporter if Store Exporter Deluxe is activated
55
+ if( defined( 'WOO_CD_PREFIX' ) ) {
56
+ include_once( WOO_CE_PATH . 'includes/install.php' );
57
+ woo_ce_deactivate_ce();
58
+ return;
59
+ }
60
+
61
+ // Check the User has the activate_plugins capability
62
+ if( current_user_can( 'activate_plugins' ) ) {
63
+
64
+ // Detect if any known conflict Plugins are activated
65
+
66
+ // WooCommerce Subscriptions Exporter - http://codecanyon.net/item/woocommerce-subscription-exporter/6569668
67
+ if( function_exists( 'wc_subs_exporter_admin_init' ) ) {
68
+ $message = sprintf( __( '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. <a href="%s" target="_blank">Need help?</a>', 'woocommerce-exporter' ), $troubleshooting_url );
69
+ woo_ce_admin_notice( $message, 'error', array( 'plugins.php', 'admin.php' ) );
70
+ }
71
+
72
+ }
73
+
74
+ // Check the User has the view_woocommerce_reports capability
75
+ if( current_user_can( 'view_woocommerce_reports' ) == false )
76
+ return;
77
+
78
+ // Add memory usage to screen footer
79
+ add_filter( 'admin_footer_text', 'woo_ce_admin_footer_text' );
80
+
81
+ // Check that we are on the Store Exporter screen
82
+ $page = ( isset($_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : false );
83
+ if( $page != strtolower( WOO_CE_PREFIX ) )
84
+ return;
85
+
86
+ // Detect other platform versions
87
+ woo_ce_detect_non_woo_install();
88
+
89
+ // Process any pre-export notice confirmations
90
+ $action = ( function_exists( 'woo_get_action' ) ? woo_get_action() : false );
91
+ switch( $action ) {
92
+
93
+ // Reset all dismissed notices within Store Exporter Deluxe
94
+ case 'nuke_notices':
95
+ // We need to verify the nonce.
96
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_nuke_notices' ) ) {
97
+ // Remember that we've dismissed this notice
98
+ woo_ce_nuke_dismissed_notices();
99
+ $message = __( 'All dimissed notices within Store Exporter Deluxe have been restored.', 'woocommerce-exporter' );
100
+ woo_ce_admin_notice( $message );
101
+ }
102
+ break;
103
+
104
+ // Delete all WordPress Options associated with Store Exporter Deluxe
105
+ case 'nuke_options':
106
+ // We need to verify the nonce.
107
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_nuke_options' ) ) {
108
+ // Delete WordPress Options used by Store Exporter Deluxe (Uninstall)
109
+ if( woo_ce_nuke_options() ) {
110
+ $message = __( 'All Store Exporter Deluxe WordPress Options have been deleted from your WordPress site, you can now de-activate and delete Store Exporter Deluxe.', 'woocommerce-exporter' );
111
+ woo_ce_admin_notice( $message );
112
+ } else {
113
+ $message = __( 'Not all Store Exporter Deluxe WordPress Options could be deleted from your WordPress site, please see the WordPress Options table for Options prefixed by <code>woo_ce_</code>.', 'woocommerce-exporter' );
114
+ woo_ce_admin_notice( $message, 'error' );
115
+ }
116
+ }
117
+ break;
118
+
119
+ // Delete all Archives
120
+ case 'nuke_archives':
121
+ // We need to verify the nonce.
122
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_nuke_archives' ) ) {
123
+ // Delete saved exports
124
+ if( woo_ce_nuke_archive_files() ) {
125
+ $message = __( 'All existing Archives and their export files have been deleted from your WordPress site.', 'woocommerce-exporter' );
126
+ woo_ce_admin_notice( $message );
127
+ } else {
128
+ $message = __( 'There were no existing Archives to be deleted from your WordPress site.', 'woocommerce-exporter' );
129
+ woo_ce_admin_notice( $message, 'error' );
130
+ }
131
+ }
132
+ break;
133
+
134
+ // Prompt on Export screen when insufficient memory (less than 64M is allocated)
135
+ case 'dismiss_memory_prompt':
136
+ // We need to verify the nonce.
137
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_dismiss_memory_prompt' ) ) {
138
+ // Remember that we've dismissed this notice
139
+ woo_ce_update_option( 'dismiss_memory_prompt', 1 );
140
+ $url = add_query_arg( array( 'action' => null, '_wpnonce' => null ) );
141
+ wp_redirect( $url );
142
+ exit();
143
+ }
144
+ break;
145
+
146
+ // Prompt on Export screen when PHP configuration option max_execution_time cannot be increased
147
+ case 'dismiss_execution_time_prompt':
148
+ // We need to verify the nonce.
149
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_dismiss_execution_time_prompt' ) ) {
150
+ // Remember that we've dismissed this notice
151
+ woo_ce_update_option( 'dismiss_execution_time_prompt', 1 );
152
+ $url = add_query_arg( array( 'action' => null, '_wpnonce' => null ) );
153
+ wp_redirect( $url );
154
+ exit();
155
+ }
156
+ break;
157
+
158
+ // Prompt on Export screen when PHP 5.2 or lower is installed
159
+ case 'dismiss_php_legacy':
160
+ // We need to verify the nonce.
161
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_dismiss_php_legacy' ) ) {
162
+ // Remember that we've dismissed this notice
163
+ woo_ce_update_option( 'dismiss_php_legacy', 1 );
164
+ $url = add_query_arg( array( 'action' => null, '_wpnonce' => null ) );
165
+ wp_redirect( $url );
166
+ exit();
167
+ }
168
+ break;
169
+
170
+ case 'dismiss_subscription_prompt':
171
+ // We need to verify the nonce.
172
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_dismiss_subscription_prompt' ) ) {
173
+ // Remember that we've dismissed this notice
174
+ woo_ce_update_option( 'dismiss_subscription_prompt', 1 );
175
+ $url = add_query_arg( array( 'action' => null, '_wpnonce' => null ) );
176
+ wp_redirect( $url );
177
+ exit();
178
+ }
179
+ break;
180
+
181
+ case 'dismiss_archives_prompt':
182
+ // We need to verify the nonce.
183
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_dismiss_archives_prompt' ) ) {
184
+ // Remember that we've dismissed this notice
185
+ woo_ce_update_option( 'dismiss_archives_prompt', 1 );
186
+ $url = add_query_arg( array( 'action' => null, '_wpnonce' => null ) );
187
+ wp_redirect( $url );
188
+ exit();
189
+ }
190
+ break;
191
+
192
+ case 'hide_archives_tab':
193
+ // We need to verify the nonce.
194
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_hide_archives_tab' ) ) {
195
+ // Remember to hide the Archives tab
196
+ woo_ce_update_option( 'hide_archives_tab', 1 );
197
+ $url = add_query_arg( array( 'tab' => 'export', 'action' => null, '_wpnonce' => null ) );
198
+ wp_redirect( $url );
199
+ exit();
200
+ }
201
+ break;
202
+
203
+ case 'restore_archives_tab':
204
+ // We need to verify the nonce.
205
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_restore_archives_tab' ) ) {
206
+ // Remember to show the Archives tab
207
+ woo_ce_update_option( 'hide_archives_tab', 0 );
208
+ $url = add_query_arg( array( 'tab' => 'archive', 'action' => null, '_wpnonce' => null ) );
209
+ wp_redirect( $url );
210
+ exit();
211
+ }
212
+ break;
213
+
214
+ // Reset the Transient counters for all Export Types
215
+ case 'refresh_export_type_counts':
216
+ // We need to verify the nonce.
217
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_refresh_export_type_counts' ) ) {
218
+ $transients = array(
219
+ 'product',
220
+ 'category',
221
+ 'tag',
222
+ 'user'
223
+ );
224
+ foreach( $transients as $transient ) {
225
+ // Delete the existing count Transients
226
+ delete_transient( WOO_CE_PREFIX . '_' . $transient . '_count' );
227
+ // Refresh the count Transients
228
+ woo_ce_get_export_type_count( $transient );
229
+ }
230
+ $url = add_query_arg( array( 'action' => null, '_wpnonce' => null ) );
231
+ wp_redirect( $url );
232
+ exit();
233
+ }
234
+ break;
235
+
236
+ case 'refresh_module_counts':
237
+ // We need to verify the nonce.
238
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_refresh_module_counts' ) ) {
239
+ // Delete the existing count Transients
240
+ delete_transient( WOO_CE_PREFIX . '_modules_all_count' );
241
+ delete_transient( WOO_CE_PREFIX . '_modules_active_count' );
242
+ delete_transient( WOO_CE_PREFIX . '_modules_inactive_count' );
243
+ // Refresh the count Transients
244
+ woo_ce_admin_modules_list();
245
+ $url = add_query_arg( array( 'action' => null, '_wpnonce' => null ) );
246
+ wp_redirect( $url );
247
+ exit();
248
+ }
249
+ break;
250
+
251
+ // Save skip overview preference
252
+ case 'skip_overview':
253
+ // We need to verify the nonce.
254
+ if( !empty( $_POST ) && check_admin_referer( 'skip_overview', 'woo_ce_skip_overview' ) ) {
255
+ $skip_overview = false;
256
+ if( isset( $_POST['skip_overview'] ) )
257
+ $skip_overview = 1;
258
+ // Remember that we've dismissed this notice
259
+ woo_ce_update_option( 'skip_overview', $skip_overview );
260
+
261
+ if( $skip_overview == 1 ) {
262
+ $url = add_query_arg( array( 'tab' => 'export', '_wpnonce' => null ) );
263
+ wp_redirect( $url );
264
+ exit();
265
+ }
266
+ }
267
+ break;
268
+
269
+ // This is where the magic happens
270
+ case 'export':
271
+
272
+ // Make sure we play nice with other WooCommerce and WordPress exporters
273
+ if( !isset( $_POST['woo_ce_export'] ) )
274
+ return;
275
+
276
+ check_admin_referer( 'manual_export', 'woo_ce_export' );
277
+
278
+ // Welcome in the age of GZIP compression and Object caching
279
+ if( !defined( 'DONOTCACHEPAGE' ) )
280
+ define( 'DONOTCACHEPAGE', true );
281
+ if( !defined( 'DONOTCACHCEOBJECT' ) )
282
+ define( 'DONOTCACHCEOBJECT', true );
283
+
284
+ $timeout = woo_ce_get_option( 'timeout', 0 );
285
+ if( !ini_get( 'safe_mode' ) ) {
286
+ @set_time_limit( $timeout );
287
+ @ini_set( 'max_execution_time', $timeout );
288
+ }
289
+ @ini_set( 'memory_limit', WP_MAX_MEMORY_LIMIT );
290
+
291
+ // Set up the basic export options
292
+ $export = new stdClass();
293
+ $export->cron = 0;
294
+ $export->scheduled_export = 0;
295
+ $export->start_time = time();
296
+ $export->idle_memory_start = woo_ce_current_memory_usage();
297
+ $export->encoding = woo_ce_get_option( 'encoding', get_option( 'blog_charset', 'UTF-8' ) );
298
+ // Reset the Encoding if corrupted
299
+ if( $export->encoding == '' || $export->encoding == false || $export->encoding == 'System default' ) {
300
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Encoding export option was corrupted, defaulted to UTF-8', 'woocommerce-exporter' ) ) );
301
+ $export->encoding = 'UTF-8';
302
+ woo_ce_update_option( 'encoding', 'UTF-8' );
303
+ }
304
+ $export->delimiter = woo_ce_get_option( 'delimiter', ',' );
305
+ // Reset the Delimiter if corrupted
306
+ if( $export->delimiter == '' || $export->delimiter == false ) {
307
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Delimiter export option was corrupted, defaulted to ,', 'woocommerce-exporter' ) ) );
308
+ $export->delimiter = ',';
309
+ woo_ce_update_option( 'delimiter', ',' );
310
+ }
311
+ $export->category_separator = woo_ce_get_option( 'category_separator', '|' );
312
+ // Reset the Category Separator if corrupted
313
+ if( $export->category_separator == '' || $export->category_separator == false ) {
314
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Category Separator export option was corrupted, defaulted to |', 'woocommerce-exporter' ) ) );
315
+ $export->category_separator = '|';
316
+ woo_ce_update_option( 'category_separator', '|' );
317
+ }
318
+ $export->bom = woo_ce_get_option( 'bom', 1 );
319
+ $export->escape_formatting = woo_ce_get_option( 'escape_formatting', 'all' );
320
+ // Reset the Escape Formatting if corrupted
321
+ if( $export->escape_formatting == '' || $export->escape_formatting == false ) {
322
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Escape Formatting export option was corrupted, defaulted to all.', 'woocommerce-exporter' ) ) );
323
+ $export->escape_formatting = 'all';
324
+ woo_ce_update_option( 'escape_formatting', 'all' );
325
+ }
326
+ $date_format = woo_ce_get_option( 'date_format', 'd/m/Y' );
327
+ // Reset the Date Format if corrupted
328
+ if( $date_format == '1' || $date_format == '' || $date_format == false ) {
329
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Date Format export option was corrupted, defaulted to d/m/Y', 'woocommerce-exporter' ) ) );
330
+ $date_format = 'd/m/Y';
331
+ woo_ce_update_option( 'date_format', $date_format );
332
+ }
333
+
334
+ // Save export option changes made on the Export screen
335
+ $export->limit_volume = ( isset( $_POST['limit_volume'] ) ? sanitize_text_field( $_POST['limit_volume'] ) : '' );
336
+ woo_ce_update_option( 'limit_volume', $export->limit_volume );
337
+ if( in_array( $export->limit_volume, array( '', '0', '-1' ) ) ) {
338
+ woo_ce_update_option( 'limit_volume', '' );
339
+ $export->limit_volume = -1;
340
+ }
341
+ $export->offset = ( isset( $_POST['offset'] ) ? sanitize_text_field( $_POST['offset'] ) : '' );
342
+ woo_ce_update_option( 'offset', $export->offset );
343
+ if( in_array( $export->offset, array( '', '0' ) ) ) {
344
+ woo_ce_update_option( 'offset', '' );
345
+ $export->offset = 0;
346
+ }
347
+ $export->type = ( isset( $_POST['dataset'] ) ? sanitize_text_field( $_POST['dataset'] ) : false );
348
+
349
+ // Set default values for all export options to be later passed onto the export process
350
+ $export->fields = array();
351
+ $export->fields_order = false;
352
+ $export->export_format = 'csv';
353
+
354
+ // Product sorting
355
+ $export->product_categories = false;
356
+ $export->product_tags = false;
357
+ $export->product_status = false;
358
+ $export->product_type = false;
359
+ $export->product_orderby = false;
360
+ $export->product_order = false;
361
+ $export->gallery_formatting = false;
362
+ $export->upsell_formatting = false;
363
+ $export->crosssell_formatting = false;
364
+
365
+ // Category sorting
366
+ $export->category_orderby = false;
367
+ $export->category_order = false;
368
+
369
+ // Tag sorting
370
+ $export->tag_orderby = false;
371
+ $export->tag_order = false;
372
+
373
+ // User sorting
374
+ $export->user_orderby = false;
375
+ $export->user_order = false;
376
+
377
+ if( !empty( $export->type ) ) {
378
+ $export->fields = ( isset( $_POST[$export->type . '_fields'] ) ? array_map( 'sanitize_text_field', $_POST[$export->type . '_fields'] ) : false );
379
+ $export->fields_order = ( isset( $_POST[$export->type . '_fields_order'] ) ? array_map( 'absint', $_POST[$export->type . '_fields_order'] ) : false );
380
+ woo_ce_update_option( 'last_export', $export->type );
381
+ }
382
+ switch( $export->type ) {
383
+
384
+ case 'product':
385
+ // Set up dataset specific options
386
+ $export->product_categories = ( isset( $_POST['product_filter_category'] ) ? woo_ce_format_product_filters( array_map( 'absint', $_POST['product_filter_category'] ) ) : false );
387
+ $export->product_tags = ( isset( $_POST['product_filter_tag'] ) ? woo_ce_format_product_filters( array_map( 'absint', $_POST['product_filter_tag'] ) ) : false );
388
+ $export->product_status = ( isset( $_POST['product_filter_status'] ) ? woo_ce_format_product_filters( array_map( 'sanitize_text_field', $_POST['product_filter_status'] ) ) : false );
389
+ $export->product_type = ( isset( $_POST['product_filter_type'] ) ? woo_ce_format_product_filters( array_map( 'sanitize_text_field', $_POST['product_filter_type'] ) ) : false );
390
+ $export->product_orderby = ( isset( $_POST['product_orderby'] ) ? sanitize_text_field( $_POST['product_orderby'] ) : false );
391
+ $export->product_order = ( isset( $_POST['product_order'] ) ? sanitize_text_field( $_POST['product_order'] ) : false );
392
+ $export->gallery_formatting = ( isset( $_POST['product_gallery_formatting'] ) ? absint( $_POST['product_gallery_formatting'] ) : false );
393
+ $export->upsell_formatting = ( isset( $_POST['product_upsell_formatting'] ) ? absint( $_POST['product_upsell_formatting'] ) : false );
394
+ $export->crosssell_formatting = ( isset( $_POST['product_crosssell_formatting'] ) ? absint( $_POST['product_crosssell_formatting'] ) : false );
395
+
396
+ // Save dataset export specific options
397
+ if( $export->product_orderby <> woo_ce_get_option( 'product_orderby' ) )
398
+ woo_ce_update_option( 'product_orderby', $export->product_orderby );
399
+ if( $export->product_order <> woo_ce_get_option( 'product_order' ) )
400
+ woo_ce_update_option( 'product_order', $export->product_order );
401
+ if( $export->upsell_formatting <> woo_ce_get_option( 'upsell_formatting' ) )
402
+ woo_ce_update_option( 'upsell_formatting', $export->upsell_formatting );
403
+ if( $export->crosssell_formatting <> woo_ce_get_option( 'crosssell_formatting' ) )
404
+ woo_ce_update_option( 'crosssell_formatting', $export->crosssell_formatting );
405
+ break;
406
+
407
+ case 'category':
408
+ // Set up dataset specific options
409
+ $export->category_orderby = ( isset( $_POST['category_orderby'] ) ? sanitize_text_field( $_POST['category_orderby'] ) : false );
410
+ $export->category_order = ( isset( $_POST['category_order'] ) ? sanitize_text_field( $_POST['category_order'] ) : false );
411
+
412
+ // Save dataset export specific options
413
+ if( $export->category_orderby <> woo_ce_get_option( 'category_orderby' ) )
414
+ woo_ce_update_option( 'category_orderby', $export->category_orderby );
415
+ if( $export->category_order <> woo_ce_get_option( 'category_order' ) )
416
+ woo_ce_update_option( 'category_order', $export->category_order );
417
+ break;
418
+
419
+ case 'tag':
420
+ // Set up dataset specific options
421
+ $export->tag_orderby = ( isset( $_POST['tag_orderby'] ) ? sanitize_text_field( $_POST['tag_orderby'] ) : false );
422
+ $export->tag_order = ( isset( $_POST['tag_order'] ) ? sanitize_text_field( $_POST['tag_order'] ) : false );
423
+
424
+ // Save dataset export specific options
425
+ if( $export->tag_orderby <> woo_ce_get_option( 'tag_orderby' ) )
426
+ woo_ce_update_option( 'tag_orderby', $export->tag_orderby );
427
+ if( $export->tag_order <> woo_ce_get_option( 'tag_order' ) )
428
+ woo_ce_update_option( 'tag_order', $export->tag_order );
429
+ break;
430
+
431
+ case 'user':
432
+ // Set up dataset specific options
433
+ $export->user_orderby = ( isset( $_POST['user_orderby'] ) ? sanitize_text_field( $_POST['user_orderby'] ) : false );
434
+ $export->user_order = ( isset( $_POST['user_order'] ) ? sanitize_text_field( $_POST['user_order'] ) : false );
435
+
436
+ // Save dataset export specific options
437
+ if( $export->user_orderby <> woo_ce_get_option( 'user_orderby' ) )
438
+ woo_ce_update_option( 'user_orderby', $export->user_orderby );
439
+ if( $export->user_order <> woo_ce_get_option( 'user_order' ) )
440
+ woo_ce_update_option( 'user_order', $export->user_order );
441
+ break;
442
+
443
+ }
444
+ if( $export->type ) {
445
+
446
+ $timeout = 600;
447
+ if( isset( $_POST['timeout'] ) ) {
448
+ $timeout = absint( $_POST['timeout'] );
449
+ if( $timeout <> woo_ce_get_option( 'timeout' ) )
450
+ woo_ce_update_option( 'timeout', $timeout );
451
+ }
452
+ if( !ini_get( 'safe_mode' ) ) {
453
+ @set_time_limit( $timeout );
454
+ @ini_set( 'max_execution_time', $timeout );
455
+ }
456
+
457
+ @ini_set( 'memory_limit', WP_MAX_MEMORY_LIMIT );
458
+
459
+ $export->args = array(
460
+ 'limit_volume' => $export->limit_volume,
461
+ 'offset' => $export->offset,
462
+ 'encoding' => $export->encoding,
463
+ 'date_format' => $date_format,
464
+ 'product_categories' => $export->product_categories,
465
+ 'product_tags' => $export->product_tags,
466
+ 'product_status' => $export->product_status,
467
+ 'product_type' => $export->product_type,
468
+ 'product_orderby' => $export->product_orderby,
469
+ 'product_order' => $export->product_order,
470
+ 'category_orderby' => $export->category_orderby,
471
+ 'category_order' => $export->category_order,
472
+ 'tag_orderby' => $export->tag_orderby,
473
+ 'tag_order' => $export->tag_order,
474
+ 'user_orderby' => $export->user_orderby,
475
+ 'user_order' => $export->user_order
476
+ );
477
+ if( empty( $export->fields ) ) {
478
+ $message = __( 'No export fields were selected, please try again with at least a single export field.', 'woocommerce-exporter' );
479
+ woo_ce_admin_notice( $message, 'error' );
480
+ return;
481
+ }
482
+ woo_ce_save_fields( $export->type, $export->fields, $export->fields_order );
483
+
484
+ if( $export->export_format == 'csv' ) {
485
+ $export->filename = woo_ce_generate_csv_filename( $export->type );
486
+ }
487
+
488
+ // Print file contents to debug export screen
489
+ if( WOO_CE_DEBUG ) {
490
+
491
+ if( in_array( $export->export_format, array( 'csv' ) ) ) {
492
+ woo_ce_export_dataset( $export->type );
493
+ }
494
+ $export->idle_memory_end = woo_ce_current_memory_usage();
495
+ $export->end_time = time();
496
+
497
+ // Print file contents to browser
498
+ } else {
499
+ if( in_array( $export->export_format, array( 'csv' ) ) ) {
500
+
501
+ // Generate CSV contents
502
+ $bits = woo_ce_export_dataset( $export->type );
503
+ unset( $export->fields );
504
+ if( empty( $bits ) ) {
505
+ $message = __( 'No export entries were found, please try again with different export filters.', 'woocommerce-exporter' );
506
+ woo_ce_admin_notice( $message, 'error' );
507
+ return;
508
+ }
509
+ if( woo_ce_get_option( 'delete_file', 1 ) ) {
510
+
511
+ // Print directly to browser
512
+ if( $export->export_format == 'csv' )
513
+ woo_ce_generate_csv_header( $export->type );
514
+ echo $bits;
515
+ exit();
516
+
517
+ } else {
518
+
519
+ // Save to file and insert to WordPress Media
520
+ if( $export->filename && $bits ) {
521
+ if( $export->export_format == 'csv' )
522
+ $post_ID = woo_ce_save_file_attachment( $export->filename, 'text/csv' );
523
+ $upload = wp_upload_bits( $export->filename, null, $bits );
524
+ if( ( $post_ID == false ) || $upload['error'] ) {
525
+ wp_delete_attachment( $post_ID, true );
526
+ if( isset( $upload['error'] ) )
527
+ wp_redirect( esc_url( add_query_arg( array( 'failed' => true, 'message' => urlencode( $upload['error'] ) ) ) ) );
528
+ else
529
+ wp_redirect( esc_url( add_query_arg( array( 'failed' => true ) ) ) );
530
+ return;
531
+ }
532
+ $attach_data = wp_generate_attachment_metadata( $post_ID, $upload['file'] );
533
+ wp_update_attachment_metadata( $post_ID, $attach_data );
534
+ update_attached_file( $post_ID, $upload['file'] );
535
+ if( $post_ID ) {
536
+ woo_ce_save_file_guid( $post_ID, $export->type, $upload['url'] );
537
+ woo_ce_save_file_details( $post_ID );
538
+ }
539
+ $export_type = $export->type;
540
+ unset( $export );
541
+
542
+ // The end memory usage and time is collected at the very last opportunity prior to the CSV header being rendered to the screen
543
+ woo_ce_update_file_detail( $post_ID, '_woo_idle_memory_end', woo_ce_current_memory_usage() );
544
+ woo_ce_update_file_detail( $post_ID, '_woo_end_time', time() );
545
+
546
+ // Generate CSV header
547
+ woo_ce_generate_csv_header( $export_type );
548
+ unset( $export_type );
549
+
550
+ // Print file contents to screen
551
+ if( $upload['file'] ) {
552
+ readfile( $upload['file'] );
553
+ } else {
554
+ $url = add_query_arg( 'failed', true );
555
+ wp_redirect( $url );
556
+ }
557
+ unset( $upload );
558
+ } else {
559
+ $url = add_query_arg( 'failed', true );
560
+ wp_redirect( $url );
561
+ }
562
+
563
+ }
564
+
565
+ }
566
+ exit();
567
+ }
568
+ }
569
+ break;
570
+
571
+ // Save changes on Settings screen
572
+ case 'save-settings':
573
+ // We need to verify the nonce.
574
+ if( !empty( $_POST ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'woo_ce_save_settings' ) ) {
575
+ if( check_admin_referer( 'woo_ce_save_settings' ) ) {
576
+ // Sanitize each setting field as needed
577
+
578
+ // Strip file extension from export filename
579
+ $export_filename = strip_tags( (string)$_POST['export_filename'] );
580
+ woo_ce_update_option( 'export_filename', $export_filename );
581
+ woo_ce_update_option( 'delete_file', sanitize_text_field( absint( $_POST['delete_file'] ) ) );
582
+ woo_ce_update_option( 'encoding', sanitize_text_field( (string)$_POST['encoding'] ) );
583
+ woo_ce_update_option( 'delimiter', sanitize_text_field( (string)$_POST['delimiter'] ) );
584
+ woo_ce_update_option( 'category_separator', sanitize_text_field( (string)$_POST['category_separator'] ) );
585
+ woo_ce_update_option( 'bom', absint( absint( $_POST['bom'] ) ) );
586
+ woo_ce_update_option( 'escape_formatting', sanitize_text_field( (string)$_POST['escape_formatting'] ) );
587
+ if( $_POST['date_format'] == 'custom' && !empty( $_POST['date_format_custom'] ) )
588
+ woo_ce_update_option( 'date_format', sanitize_text_field( (string)$_POST['date_format_custom'] ) );
589
+ else
590
+ woo_ce_update_option( 'date_format', sanitize_text_field( (string)$_POST['date_format'] ) );
591
+
592
+ $message = __( 'Changes have been saved.', 'woocommerce-exporter' );
593
+ woo_ce_admin_notice( $message );
594
+ }
595
+ }
596
+ break;
597
+
598
+ // Save changes on Field Editor screen
599
+ case 'save-fields':
600
+ // We need to verify the nonce.
601
+ if( !empty( $_POST ) && check_admin_referer( 'save_fields', 'woo_ce_save_fields' ) ) {
602
+ $fields = ( isset( $_POST['fields'] ) ? array_filter( $_POST['fields'] ) : array() );
603
+ $export_type = ( isset( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : '' );
604
+ $export_types = array_keys( woo_ce_get_export_types() );
605
+ // Check we are saving against a valid export type
606
+ if( in_array( $export_type, $export_types ) ) {
607
+ woo_ce_update_option( $export_type . '_labels', $fields );
608
+ $message = __( 'Field labels have been saved.', 'woocommerce-exporter' );
609
+ woo_ce_admin_notice( $message );
610
+ } else {
611
+ $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' );
612
+ woo_ce_admin_notice( $message, 'error' );
613
+ }
614
+ }
615
+ break;
616
+
617
+ }
618
+
619
+ }
620
+ add_action( 'admin_init', 'woo_ce_admin_init', 11 );
621
+
622
+ // HTML templates and form processor for Store Exporter screen
623
+ function woo_ce_html_page() {
624
+
625
+ global $wpdb, $export;
626
+
627
+ $title = apply_filters( 'woo_ce_template_header', __( 'Store Exporter', 'woocommerce-exporter' ) );
628
+ woo_ce_template_header( $title );
629
+ woo_ce_support_donate();
630
+ $action = ( function_exists( 'woo_get_action' ) ? woo_get_action() : false );
631
+ switch( $action ) {
632
+
633
+ case 'export':
634
+ if( WOO_CE_DEBUG ) {
635
+ $output = '';
636
+ if( false === ( $export_log = get_transient( WOO_CE_PREFIX . '_debug_log' ) ) ) {
637
+ $export_log = __( 'No export entries were found within the debug Transient, please try again with different export filters.', 'woocommerce-exporter' );
638
+ } else {
639
+ // We take the contents of our WordPress Transient and de-base64 it back to CSV format
640
+ $export_log = base64_decode( $export_log );
641
+ }
642
+ delete_transient( WOO_CE_PREFIX . '_debug_log' );
643
+ $output = '
644
+ <h3>' . sprintf( __( 'Export Details: %s', 'woocommerce-exporter' ), esc_attr( $export->filename ) ) . '</h3>
645
+ <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>
646
+ <textarea id="export_log">' . esc_textarea( print_r( $export, true ) ) . '</textarea>
647
+ <hr />';
648
+ if( in_array( $export->export_format, array( 'csv' ) ) ) {
649
+ $output .= '
650
+ <script type="text/javascript">
651
+ $j(function() {
652
+ $j(\'#export_sheet\').CSVToTable(\'\', {
653
+ startLine: 0
654
+ });
655
+ });
656
+ </script>
657
+ <h3>' . __( 'Export', 'woocommerce-exporter' ) . '</h3>
658
+ <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>
659
+ <div id="export_sheet">' . esc_textarea( $export_log ) . '</div>
660
+ <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>
661
+ <hr />';
662
+ }
663
+ $output .= '
664
+ <h3>' . __( 'Export Log', 'woocommerce-exporter' ) . '</h3>
665
+ <p>' . __( 'This prints the raw export contents and is helpful when the jQuery plugin above fails due to major formatting errors.', 'woocommerce-exporter' ) . '</p>
666
+ <textarea id="export_log" wrap="off">' . esc_textarea( $export_log ) . '</textarea>
667
+ <hr />
668
+ ';
669
+ echo $output;
670
+ }
671
+
672
+ woo_ce_manage_form();
673
+ break;
674
+
675
+ case 'update':
676
+ // Save Custom Product Meta
677
+ if( isset( $_POST['custom_products'] ) ) {
678
+ $custom_products = $_POST['custom_products'];
679
+ $custom_products = explode( "\n", trim( $custom_products ) );
680
+ if( !empty( $custom_products ) ) {
681
+ $size = count( $custom_products );
682
+ if( !empty( $size ) ) {
683
+ for( $i = 0; $i < $size; $i++ )
684
+ $custom_products[$i] = sanitize_text_field( trim( stripslashes( $custom_products[$i] ) ) );
685
+ woo_ce_update_option( 'custom_products', $custom_products );
686
+ }
687
+ } else {
688
+ woo_ce_update_option( 'custom_products', '' );
689
+ }
690
+ unset( $custom_products );
691
+ }
692
+
693
+ $message = __( 'Custom Fields saved. You can now select those additional fields from the Export Fields list.', 'woocommerce-exporter' );
694
+ woo_ce_admin_notice_html( $message );
695
+ woo_ce_manage_form();
696
+ break;
697
+
698
+ default:
699
+ woo_ce_manage_form();
700
+ break;
701
+
702
+ }
703
+ woo_ce_template_footer();
704
+
705
+ }
706
+
707
+ // HTML template for Export screen
708
+ function woo_ce_manage_form() {
709
+
710
+ $tab = ( isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : false );
711
+ // If Skip Overview is set then jump to Export screen
712
+ if( $tab == false && woo_ce_get_option( 'skip_overview', false ) )
713
+ $tab = 'export';
714
+
715
+ // Check that WC() is available
716
+ if( !function_exists( 'WC' ) ) {
717
+ $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' );
718
+ woo_cd_admin_notice_html( $message, 'error' );
719
+ return;
720
+ }
721
+
722
+ woo_ce_admin_fail_notices();
723
+
724
+ include_once( WOO_CE_PATH . 'templates/admin/tabs.php' );
725
+
726
+ }
727
+
728
+ /* End of: WordPress Administration */
729
+
730
+ }
731
+ ?>
includes/admin.php ADDED
@@ -0,0 +1,547 @@
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 = '' ) {
28
+
29
+ // Display admin notice on specific screen
30
+ if( !empty( $screen ) ) {
31
+
32
+ global $pagenow;
33
+
34
+ if( is_array( $screen ) ) {
35
+ if( in_array( $pagenow, $screen ) == false )
36
+ return;
37
+ } else {
38
+ if( $pagenow <> $screen )
39
+ return;
40
+ }
41
+
42
+ } ?>
43
+ <div id="message" class="<?php echo $priority; ?>">
44
+ <p><?php echo $message; ?></p>
45
+ </div>
46
+ <?php
47
+
48
+ }
49
+
50
+ // Grabs the WordPress transient that holds the admin notice and prints it
51
+ function woo_ce_admin_notice_print() {
52
+
53
+ $output = get_transient( WOO_CE_PREFIX . '_notice' );
54
+ if( $output !== false ) {
55
+ delete_transient( WOO_CE_PREFIX . '_notice' );
56
+ $output = base64_decode( $output );
57
+ echo $output;
58
+ }
59
+
60
+ }
61
+
62
+ // HTML template header on Store Exporter screen
63
+ function woo_ce_template_header( $title = '', $icon = 'woocommerce' ) {
64
+
65
+ if( $title )
66
+ $output = $title;
67
+ else
68
+ $output = __( 'Store Export', 'woocommerce-exporter' ); ?>
69
+ <div id="woo-ce" class="wrap">
70
+ <div id="icon-<?php echo $icon; ?>" class="icon32 icon32-woocommerce-importer"><br /></div>
71
+ <h2>
72
+ <?php echo $output; ?>
73
+ </h2>
74
+ <?php
75
+
76
+ }
77
+
78
+ // HTML template footer on Store Exporter screen
79
+ function woo_ce_template_footer() { ?>
80
+ </div>
81
+ <!-- .wrap -->
82
+ <?php
83
+
84
+ }
85
+
86
+ function woo_ce_export_options_export_format() {
87
+
88
+ $woo_cd_url = 'http://www.visser.com.au/woocommerce/plugins/exporter-deluxe/';
89
+ $woo_cd_link = sprintf( '<a href="%s" target="_blank">' . __( 'Store Exporter Deluxe', 'woocommerce-exporter' ) . '</a>', $woo_cd_url );
90
+
91
+ ob_start(); ?>
92
+ <tr>
93
+ <th>
94
+ <label><?php _e( 'Export format', 'woocommerce-exporter' ); ?></label>
95
+ </th>
96
+ <td>
97
+ <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 />
98
+ <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 />
99
+ <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 />
100
+ <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 />
101
+ <div class="export-options product-options">
102
+ <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>
103
+ </div>
104
+ <p class="description"><?php _e( 'Adjust the export format to generate different export file formats.', 'woocommerce-exporter' ); ?></p>
105
+ </td>
106
+ </tr>
107
+ <?php
108
+ ob_end_flush();
109
+
110
+ }
111
+
112
+ // Add Export and Docs links to the Plugins screen
113
+ function woo_ce_add_settings_link( $links, $file ) {
114
+
115
+ // Manually force slug
116
+ $this_plugin = WOO_CE_RELPATH;
117
+
118
+ if( $file == $this_plugin ) {
119
+ $docs_url = 'http://www.visser.com.au/docs/';
120
+ $docs_link = sprintf( '<a href="%s" target="_blank">' . __( 'Docs', 'woocommerce-exporter' ) . '</a>', $docs_url );
121
+ $export_link = sprintf( '<a href="%s">' . __( 'Export', 'woocommerce-exporter' ) . '</a>', esc_url( add_query_arg( 'page', 'woo_ce', 'admin.php' ) ) );
122
+ array_unshift( $links, $docs_link );
123
+ array_unshift( $links, $export_link );
124
+ }
125
+ return $links;
126
+
127
+ }
128
+ add_filter( 'plugin_action_links', 'woo_ce_add_settings_link', 10, 2 );
129
+
130
+ // Add Store Export page to WooCommerce screen IDs
131
+ function woo_ce_wc_screen_ids( $screen_ids = array() ) {
132
+
133
+ $screen_ids[] = 'woocommerce_page_woo_ce';
134
+ return $screen_ids;
135
+
136
+ }
137
+ add_filter( 'woocommerce_screen_ids', 'woo_ce_wc_screen_ids', 10, 1 );
138
+
139
+ // Add Store Export to WordPress Administration menu
140
+ function woo_ce_admin_menu() {
141
+
142
+ $page = add_submenu_page( 'woocommerce', __( 'Store Exporter', 'woocommerce-exporter' ), __( 'Store Export', 'woocommerce-exporter' ), 'view_woocommerce_reports', 'woo_ce', 'woo_ce_html_page' );
143
+ add_action( 'admin_print_styles-' . $page, 'woo_ce_enqueue_scripts' );
144
+ add_action( 'current_screen', 'woo_ce_add_help_tab' );
145
+
146
+ }
147
+ add_action( 'admin_menu', 'woo_ce_admin_menu', 11 );
148
+
149
+ // Load CSS and jQuery scripts for Store Exporter screen
150
+ function woo_ce_enqueue_scripts() {
151
+
152
+ // Simple check that WooCommerce is activated
153
+ if( class_exists( 'WooCommerce' ) ) {
154
+
155
+ global $woocommerce;
156
+
157
+ // Load WooCommerce default Admin styling
158
+ wp_enqueue_style( 'woocommerce_admin_styles', $woocommerce->plugin_url() . '/assets/css/admin.css' );
159
+
160
+ }
161
+
162
+ // Date Picker Addon
163
+ wp_enqueue_script( 'jquery-ui-datepicker' );
164
+ wp_enqueue_style( 'jquery-ui-datepicker', plugins_url( '/templates/admin/jquery-ui-datepicker.css', WOO_CE_RELPATH ) );
165
+
166
+ // Time Picker, Date Picker Addon
167
+ wp_enqueue_script( 'jquery-ui-timepicker', plugins_url( '/js/jquery.timepicker.js', WOO_CE_RELPATH ), array( 'jquery', 'jquery-ui-datepicker' ) );
168
+ wp_enqueue_style( 'jquery-ui-datepicker', plugins_url( '/templates/admin/jquery-ui-timepicker.css', WOO_CE_RELPATH ) );
169
+
170
+ // Chosen
171
+ wp_enqueue_style( 'jquery-chosen', plugins_url( '/templates/admin/chosen.css', WOO_CE_RELPATH ) );
172
+ wp_enqueue_script( 'jquery-chosen', plugins_url( '/js/jquery.chosen.js', WOO_CE_RELPATH ), array( 'jquery' ) );
173
+
174
+ // Common
175
+ wp_enqueue_style( 'woo_ce_styles', plugins_url( '/templates/admin/export.css', WOO_CE_RELPATH ) );
176
+ wp_enqueue_script( 'woo_ce_scripts', plugins_url( '/templates/admin/export.js', WOO_CE_RELPATH ), array( 'jquery', 'jquery-ui-sortable' ) );
177
+ wp_enqueue_style( 'dashicons' );
178
+
179
+ if( WOO_CE_DEBUG ) {
180
+ wp_enqueue_style( 'jquery-csvToTable', plugins_url( '/templates/admin/jquery-csvtable.css', WOO_CE_RELPATH ) );
181
+ wp_enqueue_script( 'jquery-csvToTable', plugins_url( '/js/jquery.csvToTable.js', WOO_CE_RELPATH ), array( 'jquery' ) );
182
+ }
183
+ wp_enqueue_style( 'woo_vm_styles', plugins_url( '/templates/admin/woocommerce-admin_dashboard_vm-plugins.css', WOO_CE_RELPATH ) );
184
+
185
+ }
186
+
187
+ function woo_ce_add_help_tab() {
188
+
189
+ $screen = get_current_screen();
190
+ if( $screen->id <> 'woocommerce_page_woo_ce' )
191
+ return;
192
+
193
+ $screen->add_help_tab( array(
194
+ 'id' => 'woo_ce',
195
+ 'title' => __( 'Store Exporter', 'woocommerce-exporter' ),
196
+ 'content' =>
197
+ '<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>' .
198
+ '<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>'
199
+ ) );
200
+
201
+ }
202
+
203
+ function woo_ce_plugin_page_notices() {
204
+
205
+ global $pagenow;
206
+
207
+ if( $pagenow == 'plugins.php' ) {
208
+ if( woo_is_jigo_activated() || woo_is_wpsc_activated() ) {
209
+ $r_plugins = array(
210
+ 'woocommerce-exporter/exporter.php',
211
+ 'woocommerce-store-exporter/exporter.php'
212
+ );
213
+ $i_plugins = get_plugins();
214
+ foreach( $r_plugins as $path ) {
215
+ if( isset( $i_plugins[$path] ) ) {
216
+ add_action( 'after_plugin_row_' . $path, 'woo_ce_plugin_page_notice', 10, 3 );
217
+ break;
218
+ }
219
+ }
220
+ }
221
+ }
222
+
223
+ }
224
+
225
+ // HTML active class for the currently selected tab on the Store Exporter screen
226
+ function woo_ce_admin_active_tab( $tab_name = null, $tab = null ) {
227
+
228
+ if( isset( $_GET['tab'] ) && !$tab )
229
+ $tab = $_GET['tab'];
230
+ else if( !isset( $_GET['tab'] ) && woo_ce_get_option( 'skip_overview', false ) )
231
+ $tab = 'export';
232
+ else
233
+ $tab = 'overview';
234
+
235
+ $output = '';
236
+ if( isset( $tab_name ) && $tab_name ) {
237
+ if( $tab_name == $tab )
238
+ $output = ' nav-tab-active';
239
+ }
240
+ echo $output;
241
+
242
+ }
243
+
244
+ // HTML template for each tab on the Store Exporter screen
245
+ function woo_ce_tab_template( $tab = '' ) {
246
+
247
+ if( !$tab )
248
+ $tab = 'overview';
249
+
250
+ // Store Exporter Deluxe
251
+ $woo_cd_url = 'http://www.visser.com.au/woocommerce/plugins/exporter-deluxe/';
252
+ $woo_cd_link = sprintf( '<a href="%s" target="_blank">' . __( 'Store Exporter Deluxe', 'woocommerce-exporter' ) . '</a>', $woo_cd_url );
253
+
254
+ $troubleshooting_url = 'http://www.visser.com.au/documentation/store-exporter-deluxe/';
255
+
256
+ switch( $tab ) {
257
+
258
+ case 'overview':
259
+ $skip_overview = woo_ce_get_option( 'skip_overview', false );
260
+ break;
261
+
262
+ case 'export':
263
+ $export_type = sanitize_text_field( ( isset( $_POST['dataset'] ) ? $_POST['dataset'] : woo_ce_get_option( 'last_export', 'product' ) ) );
264
+ $export_types = array_keys( woo_ce_get_export_types() );
265
+
266
+ // Check if the default export type exists
267
+ if( !in_array( $export_type, $export_types ) )
268
+ $export_type = 'product';
269
+
270
+ $product = woo_ce_get_export_type_count( 'product' );
271
+ $category = woo_ce_get_export_type_count( 'category' );
272
+ $tag = woo_ce_get_export_type_count( 'tag' );
273
+ $brand = '999';
274
+ $order = '999';
275
+ $customer = '999';
276
+ $user = woo_ce_get_export_type_count( 'user' );
277
+ $review = '999';
278
+ $coupon = '999';
279
+ $attribute = '999';
280
+ $subscription = '999';
281
+ $product_vendor = '999';
282
+ $commission = '999';
283
+ $shipping_class = '999';
284
+ $ticket = '999';
285
+
286
+ add_action( 'woo_ce_export_options', 'woo_ce_export_options_export_format' );
287
+ if( $product_fields = woo_ce_get_product_fields() ) {
288
+ foreach( $product_fields as $key => $product_field )
289
+ $product_fields[$key]['disabled'] = ( isset( $product_field['disabled'] ) ? $product_field['disabled'] : 0 );
290
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_category' );
291
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_tag' );
292
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_brand' );
293
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_vendor' );
294
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_status' );
295
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_type' );
296
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_stock_status' );
297
+ add_action( 'woo_ce_export_product_options_after_table', 'woo_ce_product_sorting' );
298
+ add_action( 'woo_ce_export_options', 'woo_ce_products_upsells_formatting' );
299
+ add_action( 'woo_ce_export_options', 'woo_ce_products_crosssells_formatting' );
300
+ add_action( 'woo_ce_export_options', 'woo_ce_export_options_gallery_format' );
301
+ add_action( 'woo_ce_export_after_form', 'woo_ce_products_custom_fields' );
302
+ }
303
+ if( $category_fields = woo_ce_get_category_fields() ) {
304
+ foreach( $category_fields as $key => $category_field )
305
+ $category_fields[$key]['disabled'] = ( isset( $category_field['disabled'] ) ? $category_field['disabled'] : 0 );
306
+ add_action( 'woo_ce_export_category_options_after_table', 'woo_ce_category_sorting' );
307
+ }
308
+ if( $tag_fields = woo_ce_get_tag_fields() ) {
309
+ foreach( $tag_fields as $key => $tag_field )
310
+ $tag_fields[$key]['disabled'] = ( isset( $tag_field['disabled'] ) ? $tag_field['disabled'] : 0 );
311
+ add_action( 'woo_ce_export_tag_options_after_table', 'woo_ce_tag_sorting' );
312
+ }
313
+ if( $brand_fields = woo_ce_get_brand_fields() ) {
314
+ foreach( $brand_fields as $key => $brand_field )
315
+ $brand_fields[$key]['disabled'] = ( isset( $brand_field['disabled'] ) ? $brand_field['disabled'] : 0 );
316
+ add_action( 'woo_ce_export_brand_options_before_table', 'woo_ce_brand_sorting' );
317
+ }
318
+ if( $order_fields = woo_ce_get_order_fields() ) {
319
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_date' );
320
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_status' );
321
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_customer' );
322
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_billing_country' );
323
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_shipping_country' );
324
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_user_role' );
325
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_coupon' );
326
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product' );
327
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product_category' );
328
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product_tag' );
329
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product_brand' );
330
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_order_id' );
331
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_payment_gateway' );
332
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_shipping_method' );
333
+ add_action( 'woo_ce_export_order_options_after_table', 'woo_ce_order_sorting' );
334
+ add_action( 'woo_ce_export_options', 'woo_ce_orders_items_formatting' );
335
+ add_action( 'woo_ce_export_options', 'woo_ce_orders_max_order_items' );
336
+ add_action( 'woo_ce_export_options', 'woo_ce_orders_items_types' );
337
+ add_action( 'woo_ce_export_after_form', 'woo_ce_orders_custom_fields' );
338
+ }
339
+ if( $customer_fields = woo_ce_get_customer_fields() ) {
340
+ add_action( 'woo_ce_export_customer_options_before_table', 'woo_ce_customers_filter_by_status' );
341
+ add_action( 'woo_ce_export_customer_options_before_table', 'woo_ce_customers_filter_by_user_role' );
342
+ add_action( 'woo_ce_export_after_form', 'woo_ce_customers_custom_fields' );
343
+ }
344
+ if( $user_fields = woo_ce_get_user_fields() ) {
345
+ foreach( $user_fields as $key => $user_field )
346
+ $user_fields[$key]['disabled'] = ( isset( $user_field['disabled'] ) ? $user_field['disabled'] : 0 );
347
+ add_action( 'woo_ce_export_user_options_after_table', 'woo_ce_user_sorting' );
348
+ add_action( 'woo_ce_export_after_form', 'woo_ce_users_custom_fields' );
349
+ }
350
+ if( $coupon_fields = woo_ce_get_coupon_fields() ) {
351
+ add_action( 'woo_ce_export_coupon_options_before_table', 'woo_ce_coupon_sorting' );
352
+ }
353
+ if( $subscription_fields = woo_ce_get_subscription_fields() ) {
354
+ add_action( 'woo_ce_export_subscription_options_before_table', 'woo_ce_subscriptions_filter_by_subscription_status' );
355
+ add_action( 'woo_ce_export_subscription_options_before_table', 'woo_ce_subscriptions_filter_by_subscription_product' );
356
+ }
357
+ $product_vendor_fields = woo_ce_get_product_vendor_fields();
358
+ if( $commission_fields = woo_ce_get_commission_fields() ) {
359
+ add_action( 'woo_ce_export_commission_options_before_table', 'woo_ce_commissions_filter_by_date' );
360
+ add_action( 'woo_ce_export_commission_options_before_table', 'woo_ce_commissions_filter_by_product_vendor' );
361
+ add_action( 'woo_ce_export_commission_options_before_table', 'woo_ce_commissions_filter_by_commission_status' );
362
+ add_action( 'woo_ce_export_commission_options_before_table', 'woo_ce_commission_sorting' );
363
+ }
364
+ if( $shipping_class_fields = woo_ce_get_shipping_class_fields() ) {
365
+ add_action( 'woo_ce_export_shipping_class_options_after_table', 'woo_ce_shipping_class_sorting' );
366
+ }
367
+ $attribute_fields = false;
368
+
369
+ // Export options
370
+ $limit_volume = woo_ce_get_option( 'limit_volume' );
371
+ $offset = woo_ce_get_option( 'offset' );
372
+ break;
373
+
374
+ case 'fields':
375
+ $export_type = ( isset( $_GET['type'] ) ? sanitize_text_field( $_GET['type'] ) : '' );
376
+ $export_types = array_keys( woo_ce_get_export_types() );
377
+ $fields = array();
378
+ if( in_array( $export_type, $export_types ) ) {
379
+ if( has_filter( 'woo_ce_' . $export_type . '_fields', 'woo_ce_override_' . $export_type . '_field_labels' ) )
380
+ remove_filter( 'woo_ce_' . $export_type . '_fields', 'woo_ce_override_' . $export_type . '_field_labels', 11 );
381
+ if( function_exists( sprintf( 'woo_ce_get_%s_fields', $export_type ) ) )
382
+ $fields = call_user_func( 'woo_ce_get_' . $export_type . '_fields' );
383
+ $labels = woo_ce_get_option( $export_type . '_labels', array() );
384
+ }
385
+ break;
386
+
387
+ case 'archive':
388
+ if( isset( $_GET['deleted'] ) ) {
389
+ $message = __( 'Archived export has been deleted.', 'woocommerce-exporter' );
390
+ woo_ce_admin_notice( $message );
391
+ }
392
+ if( $files = woo_ce_get_archive_files() ) {
393
+ foreach( $files as $key => $file )
394
+ $files[$key] = woo_ce_get_archive_file( $file );
395
+ }
396
+ break;
397
+
398
+ case 'settings':
399
+ $export_filename = woo_ce_get_option( 'export_filename', '' );
400
+ // Default export filename
401
+ if( $export_filename == false )
402
+ $export_filename = '%store_name%-export_%dataset%-%date%-%time%-%random%.csv';
403
+ $delete_file = woo_ce_get_option( 'delete_file', 1 );
404
+ $timeout = woo_ce_get_option( 'timeout', 0 );
405
+ $encoding = woo_ce_get_option( 'encoding', 'UTF-8' );
406
+ $bom = woo_ce_get_option( 'bom', 1 );
407
+ $delimiter = woo_ce_get_option( 'delimiter', ',' );
408
+ $category_separator = woo_ce_get_option( 'category_separator', '|' );
409
+ $escape_formatting = woo_ce_get_option( 'escape_formatting', 'all' );
410
+ $date_format = woo_ce_get_option( 'date_format', 'd/m/Y' );
411
+ // Reset the Date Format if corrupted
412
+ if( $date_format == '1' || $date_format == '' || $date_format == false )
413
+ $date_format = 'd/m/Y';
414
+ $file_encodings = ( function_exists( 'mb_list_encodings' ) ? mb_list_encodings() : false );
415
+ add_action( 'woo_ce_export_settings_top', 'woo_ce_export_settings_quicklinks' );
416
+ add_action( 'woo_ce_export_settings_after', 'woo_ce_export_settings_csv' );
417
+ add_action( 'woo_ce_export_settings_after', 'woo_ce_export_settings_extend' );
418
+ break;
419
+
420
+ case 'tools':
421
+ // Product Importer Deluxe
422
+ $woo_pd_url = 'http://www.visser.com.au/woocommerce/plugins/product-importer-deluxe/';
423
+ $woo_pd_target = ' target="_blank"';
424
+ if( function_exists( 'woo_pd_init' ) ) {
425
+ $woo_pd_url = esc_url( add_query_arg( array( 'page' => 'woo_pd', 'tab' => null ) ) );
426
+ $woo_pd_target = false;
427
+ }
428
+
429
+ // Store Toolkit
430
+ $woo_st_url = 'http://www.visser.com.au/woocommerce/plugins/store-toolkit/';
431
+ $woo_st_target = ' target="_blank"';
432
+ if( function_exists( 'woo_st_admin_init' ) ) {
433
+ $woo_st_url = esc_url( add_query_arg( array( 'page' => 'woo_st', 'tab' => null ) ) );
434
+ $woo_st_target = false;
435
+ }
436
+
437
+ // Export modules
438
+ $module_status = ( isset( $_GET['module_status'] ) ? sanitize_text_field( $_GET['module_status'] ) : false );
439
+ $modules = woo_ce_admin_modules_list( $module_status );
440
+ $modules_all = get_transient( WOO_CE_PREFIX . '_modules_all_count' );
441
+ $modules_active = get_transient( WOO_CE_PREFIX . '_modules_active_count' );
442
+ $modules_inactive = get_transient( WOO_CE_PREFIX . '_modules_inactive_count' );
443
+ break;
444
+
445
+ }
446
+ if( $tab ) {
447
+ if( file_exists( WOO_CE_PATH . 'templates/admin/tabs-' . $tab . '.php' ) ) {
448
+ include_once( WOO_CE_PATH . 'templates/admin/tabs-' . $tab . '.php' );
449
+ } else {
450
+ $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/...' );
451
+ woo_ce_admin_notice_html( $message, 'error' );
452
+ ob_start(); ?>
453
+ <p><?php _e( 'You can see this error for one of a few common reasons', 'woocommerce-exporter' ); ?>:</p>
454
+ <ul class="ul-disc">
455
+ <li><?php _e( 'WordPress was unable to create this file when the Plugin was installed or updated', 'woocommerce-exporter' ); ?></li>
456
+ <li><?php _e( 'The Plugin files have been recently changed and there has been a file conflict', 'woocommerce-exporter' ); ?></li>
457
+ <li><?php _e( 'The Plugin file has been locked and cannot be opened by WordPress', 'woocommerce-exporter' ); ?></li>
458
+ </ul>
459
+ <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>
460
+ <?php
461
+ ob_end_flush();
462
+ }
463
+ }
464
+
465
+ }
466
+
467
+ // Display the memory usage in the screen footer
468
+ function woo_ce_admin_footer_text( $footer_text = '' ) {
469
+
470
+ $current_screen = get_current_screen();
471
+ $pages = array(
472
+ 'woocommerce_page_woo_ce'
473
+ );
474
+ // Check to make sure we're on the Export screen
475
+ if ( isset( $current_screen->id ) && apply_filters( 'woo_ce_display_admin_footer_text', in_array( $current_screen->id, $pages ) ) ) {
476
+ $memory_usage = woo_ce_current_memory_usage( false );
477
+ $memory_limit = absint( ini_get( 'memory_limit' ) );
478
+ $memory_percent = absint( $memory_usage / $memory_limit * 100 );
479
+ $memory_color = 'font-weight:normal;';
480
+ if( $memory_percent > 75 )
481
+ $memory_color = 'font-weight:bold; color:orange;';
482
+ if( $memory_percent > 90 )
483
+ $memory_color = 'font-weight:bold; color:red;';
484
+ $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 . '%' ) );
485
+ }
486
+ return $footer_text;
487
+
488
+ }
489
+
490
+ function woo_ce_modules_status_class( $status = 'inactive' ) {
491
+
492
+ $output = '';
493
+ switch( $status ) {
494
+
495
+ case 'active':
496
+ $output = 'green';
497
+ break;
498
+
499
+ case 'inactive':
500
+ $output = 'yellow';
501
+ break;
502
+
503
+ }
504
+ echo $output;
505
+
506
+ }
507
+
508
+ function woo_ce_modules_status_label( $status = 'inactive' ) {
509
+
510
+ $output = '';
511
+ switch( $status ) {
512
+
513
+ case 'active':
514
+ $output = __( 'OK', 'woocommerce-exporter' );
515
+ break;
516
+
517
+ case 'inactive':
518
+ $output = __( 'Install', 'woocommerce-exporter' );
519
+ break;
520
+
521
+ }
522
+ echo $output;
523
+
524
+ }
525
+
526
+ // HTML template for header prompt on Store Exporter screen
527
+ function woo_ce_support_donate() {
528
+
529
+ $output = '';
530
+ $show = true;
531
+ if( function_exists( 'woo_vl_we_love_your_plugins' ) ) {
532
+ if( in_array( WOO_CE_DIRNAME, woo_vl_we_love_your_plugins() ) )
533
+ $show = false;
534
+ }
535
+ if( $show ) {
536
+ $donate_url = 'http://www.visser.com.au/donate/';
537
+ $rate_url = 'http://wordpress.org/support/view/plugin-reviews/' . WOO_CE_DIRNAME;
538
+ $output = '
539
+ <div id="support-donate_rate" class="support-donate_rate">
540
+ <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>
541
+ </div>
542
+ ';
543
+ }
544
+ echo $output;
545
+
546
+ }
547
+ ?>
includes/brand.php ADDED
@@ -0,0 +1,175 @@
1
+ <?php
2
+ if( is_admin() ) {
3
+
4
+ /* Start of: WordPress Administration */
5
+
6
+ function woo_ce_get_export_type_brand_count( $count = 0, $export_type = '', $args ) {
7
+
8
+ if( $export_type <> 'brand' )
9
+ return $count;
10
+
11
+ $count = 0;
12
+ // Check if the existing Transient exists
13
+ $cached = get_transient( WOO_CE_PREFIX . '_brand_count' );
14
+ if( $cached == false ) {
15
+ $term_taxonomy = apply_filters( 'woo_ce_brand_term_taxonomy', 'product_brand' );
16
+ if( taxonomy_exists( $term_taxonomy ) )
17
+ $count = wp_count_terms( $term_taxonomy );
18
+ set_transient( WOO_CE_PREFIX . '_brand_count', $count, HOUR_IN_SECONDS );
19
+ } else {
20
+ $count = $cached;
21
+ }
22
+ return $count;
23
+
24
+ }
25
+ add_filter( 'woo_ce_get_export_type_count', 'woo_ce_get_export_type_brand_count', 10, 3 );
26
+
27
+ // HTML template for Coupon Sorting widget on Store Exporter screen
28
+ function woo_ce_brand_sorting() {
29
+
30
+ $orderby = woo_ce_get_option( 'brand_orderby', 'ID' );
31
+ $order = woo_ce_get_option( 'brand_order', 'DESC' );
32
+
33
+ ob_start(); ?>
34
+ <p><label><?php _e( 'Brand Sorting', 'woocommerce-exporter' ); ?></label></p>
35
+ <div>
36
+ <select name="brand_orderby" disabled="disabled">
37
+ <option value="id"><?php _e( 'Term ID', 'woocommerce-exporter' ); ?></option>
38
+ <option value="name"><?php _e( 'Brand Name', 'woocommerce-exporter' ); ?></option>
39
+ </select>
40
+ <select name="brand_order" disabled="disabled">
41
+ <option value="ASC"><?php _e( 'Ascending', 'woocommerce-exporter' ); ?></option>
42
+ <option value="DESC"><?php _e( 'Descending', 'woocommerce-exporter' ); ?></option>
43
+ </select>
44
+ <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>
45
+ </div>
46
+ <?php
47
+ ob_end_flush();
48
+
49
+ }
50
+
51
+ /* End of: WordPress Administration */
52
+
53
+ }
54
+
55
+ // Returns a list of Brand export columns
56
+ function woo_ce_get_brand_fields( $format = 'full' ) {
57
+
58
+ $export_type = 'brand';
59
+
60
+ $fields = array();
61
+ $fields[] = array(
62
+ 'name' => 'term_id',
63
+ 'label' => __( 'Term ID', 'woocommerce-exporter' )
64
+ );
65
+ $fields[] = array(
66
+ 'name' => 'name',
67
+ 'label' => __( 'Brand Name', 'woocommerce-exporter' )
68
+ );
69
+ $fields[] = array(
70
+ 'name' => 'slug',
71
+ 'label' => __( 'Brand Slug', 'woocommerce-exporter' )
72
+ );
73
+ $fields[] = array(
74
+ 'name' => 'parent_id',
75
+ 'label' => __( 'Parent Term ID', 'woocommerce-exporter' )
76
+ );
77
+ $fields[] = array(
78
+ 'name' => 'description',
79
+ 'label' => __( 'Brand Description', 'woocommerce-exporter' )
80
+ );
81
+ $fields[] = array(
82
+ 'name' => 'image',
83
+ 'label' => __( 'Brand Image', 'woocommerce-exporter' )
84
+ );
85
+
86
+ /*
87
+ $fields[] = array(
88
+ 'name' => '',
89
+ 'label' => __( '', 'woocommerce-exporter' )
90
+ );
91
+ */
92
+
93
+ // Drop in our content filters here
94
+ add_filter( 'sanitize_key', 'woo_ce_sanitize_key' );
95
+
96
+ // Allow Plugin/Theme authors to add support for additional columns
97
+ $fields = apply_filters( 'woo_ce_' . $export_type . '_fields', $fields, $export_type );
98
+
99
+ // Remove our content filters here to play nice with other Plugins
100
+ remove_filter( 'sanitize_key', 'woo_ce_sanitize_key' );
101
+
102
+ switch( $format ) {
103
+
104
+ case 'summary':
105
+ $output = array();
106
+ $size = count( $fields );
107
+ for( $i = 0; $i < $size; $i++ ) {
108
+ if( isset( $fields[$i] ) )
109
+ $output[$fields[$i]['name']] = 'on';
110
+ }
111
+ return $output;
112
+ break;
113
+
114
+ case 'full':
115
+ default:
116
+ $sorting = woo_ce_get_option( $export_type . '_sorting', array() );
117
+ $size = count( $fields );
118
+ for( $i = 0; $i < $size; $i++ ) {
119
+ $fields[$i]['reset'] = $i;
120
+ $fields[$i]['order'] = ( isset( $sorting[$fields[$i]['name']] ) ? $sorting[$fields[$i]['name']] : $i );
121
+ }
122
+ // Check if we are using PHP 5.3 and above
123
+ if( version_compare( phpversion(), '5.3' ) >= 0 )
124
+ usort( $fields, woo_ce_sort_fields( 'order' ) );
125
+ return $fields;
126
+ break;
127
+
128
+ }
129
+
130
+ }
131
+
132
+ function woo_ce_override_brand_field_labels( $fields = array() ) {
133
+
134
+ $labels = woo_ce_get_option( 'brand_labels', array() );
135
+ if( !empty( $labels ) ) {
136
+ foreach( $fields as $key => $field ) {
137
+ if( isset( $labels[$field['name']] ) )
138
+ $fields[$key]['label'] = $labels[$field['name']];
139
+ }
140
+ }
141
+ return $fields;
142
+
143
+ }
144
+ add_filter( 'woo_ce_brand_fields', 'woo_ce_override_brand_field_labels', 11 );
145
+
146
+ // Returns a list of WooCommerce Product Brands to export process
147
+ function woo_ce_get_product_brands( $args = array() ) {
148
+
149
+ $term_taxonomy = apply_filters( 'woo_ce_brand_term_taxonomy', 'product_brand' );
150
+ $defaults = array(
151
+ 'orderby' => 'name',
152
+ 'order' => 'ASC',
153
+ 'hide_empty' => 0
154
+ );
155
+ $args = wp_parse_args( $args, $defaults );
156
+ $brands = get_terms( $term_taxonomy, $args );
157
+ if( !empty( $brands ) && is_wp_error( $brands ) == false ) {
158
+ foreach( $brands as $key => $brand ) {
159
+ $brands[$key]->description = woo_ce_format_description_excerpt( $brand->description );
160
+ $brands[$key]->parent_name = '';
161
+ if( $brands[$key]->parent_id = $brand->parent ) {
162
+ if( $parent_brand = get_term( $brands[$key]->parent_id, $term_taxonomy ) ) {
163
+ $brands[$key]->parent_name = $parent_brand->name;
164
+ }
165
+ unset( $parent_brand );
166
+ } else {
167
+ $brands[$key]->parent_id = '';
168
+ }
169
+ $brands[$key]->image = ( function_exists( 'get_brand_thumbnail_url' ) ? get_brand_thumbnail_url( $brand->term_id ) : false );
170
+ }
171
+ return $brands;
172
+ }
173
+
174
+ }
175
+ ?>
includes/category.php ADDED
@@ -0,0 +1,225 @@
1
+ <?php
2
+ if( is_admin() ) {
3
+
4
+ /* Start of: WordPress Administration */
5
+
6
+ function woo_ce_get_export_type_category_count() {
7
+
8
+ $count = 0;
9
+ // Check if the existing Transient exists
10
+ $cached = get_transient( WOO_CE_PREFIX . '_category_count' );
11
+ if( $cached == false ) {
12
+ $term_taxonomy = 'product_cat';
13
+ if( taxonomy_exists( $term_taxonomy ) )
14
+ $count = wp_count_terms( $term_taxonomy );
15
+ set_transient( WOO_CE_PREFIX . '_category_count', $count, HOUR_IN_SECONDS );
16
+ } else {
17
+ $count = $cached;
18
+ }
19
+ return $count;
20
+
21
+ }
22
+
23
+ // HTML template for Category Sorting widget on Store Exporter screen
24
+ function woo_ce_category_sorting() {
25
+
26
+ $category_orderby = woo_ce_get_option( 'category_orderby', 'ID' );
27
+ $category_order = woo_ce_get_option( 'category_order', 'DESC' );
28
+
29
+ ob_start(); ?>
30
+ <p><label><?php _e( 'Category Sorting', 'woocommerce-exporter' ); ?></label></p>
31
+ <div>
32
+ <select name="category_orderby">
33
+ <option value="id"<?php selected( 'id', $category_orderby ); ?>><?php _e( 'Term ID', 'woocommerce-exporter' ); ?></option>
34
+ <option value="name"<?php selected( 'name', $category_orderby ); ?>><?php _e( 'Category Name', 'woocommerce-exporter' ); ?></option>
35
+ </select>
36
+ <select name="category_order">
37
+ <option value="ASC"<?php selected( 'ASC', $category_order ); ?>><?php _e( 'Ascending', 'woocommerce-exporter' ); ?></option>
38
+ <option value="DESC"<?php selected( 'DESC', $category_order ); ?>><?php _e( 'Descending', 'woocommerce-exporter' ); ?></option>
39
+ </select>
40
+ <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>
41
+ </div>
42
+ <?php
43
+ ob_end_flush();
44
+
45
+ }
46
+
47
+ /* End of: WordPress Administration */
48
+
49
+ }
50
+
51
+ // Returns a list of Category export columns
52
+ function woo_ce_get_category_fields( $format = 'full' ) {
53
+
54
+ $export_type = 'category';
55
+
56
+ $fields = array();
57
+ $fields[] = array(
58
+ 'name' => 'term_id',
59
+ 'label' => __( 'Term ID', 'woocommerce-exporter' )
60
+ );
61
+ $fields[] = array(
62
+ 'name' => 'name',
63
+ 'label' => __( 'Category Name', 'woocommerce-exporter' )
64
+ );
65
+ $fields[] = array(
66
+ 'name' => 'slug',
67
+ 'label' => __( 'Category Slug', 'woocommerce-exporter' )
68
+ );
69
+ $fields[] = array(
70
+ 'name' => 'parent_id',
71
+ 'label' => __( 'Parent Term ID', 'woocommerce-exporter' )
72
+ );
73
+ $fields[] = array(
74
+ 'name' => 'description',
75
+ 'label' => __( 'Category Description', 'woocommerce-exporter' )
76
+ );
77
+ $fields[] = array(
78
+ 'name' => 'display_type',
79
+ 'label' => __( 'Display Type', 'woocommerce-exporter' )
80
+ );
81
+ $fields[] = array(
82
+ 'name' => 'image',
83
+ 'label' => __( 'Category Image', 'woocommerce-exporter' )
84
+ );
85
+
86
+ /*
87
+ $fields[] = array(
88
+ 'name' => '',
89
+ 'label' => __( '', 'woocommerce-exporter' )
90
+ );
91
+ */
92
+
93
+ // Drop in our content filters here
94
+ add_filter( 'sanitize_key', 'woo_ce_sanitize_key' );
95
+
96
+ // Allow Plugin/Theme authors to add support for additional columns
97
+ $fields = apply_filters( 'woo_ce_' . $export_type . '_fields', $fields, $export_type );
98
+
99
+ // Remove our content filters here to play nice with other Plugins
100
+ remove_filter( 'sanitize_key', 'woo_ce_sanitize_key' );
101
+
102
+ if( $remember = woo_ce_get_option( $export_type . '_fields', array() ) ) {
103
+ $remember = maybe_unserialize( $remember );
104
+ $size = count( $fields );
105
+ for( $i = 0; $i < $size; $i++ ) {
106
+ $fields[$i]['disabled'] = ( isset( $fields[$i]['disabled'] ) ? $fields[$i]['disabled'] : 0 );
107
+ $fields[$i]['default'] = 1;
108
+ if( !array_key_exists( $fields[$i]['name'], $remember ) )
109
+ $fields[$i]['default'] = 0;
110
+ }
111
+ }
112
+
113
+ switch( $format ) {
114
+
115
+ case 'summary':
116
+ $output = array();
117
+ $size = count( $fields );
118
+ for( $i = 0; $i < $size; $i++ ) {
119
+ if( isset( $fields[$i] ) )
120
+ $output[$fields[$i]['name']] = 'on';
121
+ }
122
+ return $output;
123
+ break;
124
+
125
+ case 'full':
126
+ default:
127
+ $sorting = woo_ce_get_option( $export_type . '_sorting', array() );
128
+ $size = count( $fields );
129
+ for( $i = 0; $i < $size; $i++ ) {
130
+ $fields[$i]['reset'] = $i;
131
+ $fields[$i]['order'] = ( isset( $sorting[$fields[$i]['name']] ) ? $sorting[$fields[$i]['name']] : $i );
132
+ }
133
+ // Check if we are using PHP 5.3 and above
134
+ if( version_compare( phpversion(), '5.3' ) >= 0 )
135
+ usort( $fields, woo_ce_sort_fields( 'order' ) );
136
+ return $fields;
137
+ break;
138
+
139
+ }
140
+
141
+ }
142
+
143
+ function woo_ce_override_category_field_labels( $fields = array() ) {
144
+
145
+ $labels = woo_ce_get_option( 'category_labels', array() );
146
+ if( !empty( $labels ) ) {
147
+ foreach( $fields as $key => $field ) {
148
+ if( isset( $labels[$field['name']] ) )
149
+ $fields[$key]['label'] = $labels[$field['name']];
150
+ }
151
+ }
152
+ return $fields;
153
+
154
+ }
155
+ add_filter( 'woo_ce_category_fields', 'woo_ce_override_category_field_labels', 11 );
156
+
157
+ // Returns the export column header label based on an export column slug
158
+ function woo_ce_get_category_field( $name = null, $format = 'name' ) {
159
+
160
+ $output = '';
161
+ if( $name ) {
162
+ $fields = woo_ce_get_category_fields();
163
+ $size = count( $fields );
164
+ for( $i = 0; $i < $size; $i++ ) {
165
+ if( $fields[$i]['name'] == $name ) {
166
+ switch( $format ) {
167
+
168
+ case 'name':
169
+ $output = $fields[$i]['label'];
170
+ break;
171
+
172
+ case 'full':
173
+ $output = $fields[$i];
174
+ break;
175
+
176
+ }
177
+ $i = $size;
178
+ }
179
+ }
180
+ }
181
+ return $output;
182
+
183
+ }
184
+
185
+ // Returns a list of WooCommerce Product Categories to export process
186
+ function woo_ce_get_product_categories( $args = array() ) {
187
+
188
+ $term_taxonomy = 'product_cat';
189
+ $defaults = array(
190
+ 'orderby' => 'name',
191
+ 'order' => 'ASC',
192
+ 'hide_empty' => 0
193
+ );
194
+ $args = wp_parse_args( $args, $defaults );
195
+ $categories = get_terms( $term_taxonomy, $args );
196
+ if( !empty( $categories ) && is_wp_error( $categories ) == false ) {
197
+ foreach( $categories as $key => $category ) {
198
+ $categories[$key]->description = woo_ce_format_description_excerpt( $category->description );
199
+ $categories[$key]->parent_name = '';
200
+ if( $categories[$key]->parent_id = $category->parent ) {
201
+ if( $parent_category = get_term( $categories[$key]->parent_id, $term_taxonomy ) ) {
202
+ $categories[$key]->parent_name = $parent_category->name;
203
+ }
204
+ unset( $parent_category );
205
+ } else {
206
+ $categories[$key]->parent_id = '';
207
+ }
208
+ $categories[$key]->image = woo_ce_get_category_thumbnail_url( $category->term_id );
209
+ $categories[$key]->display_type = get_woocommerce_term_meta( $category->term_id, 'display_type', true );
210
+ }
211
+ return $categories;
212
+ }
213
+
214
+ }
215
+
216
+ function woo_ce_get_category_thumbnail_url( $category_id = 0, $size = 'full' ) {
217
+
218
+ if ( $thumbnail_id = get_woocommerce_term_meta( $category_id, 'thumbnail_id', true ) ) {
219
+ $image_attributes = wp_get_attachment_image_src( $thumbnail_id, $size );
220
+ if( is_array( $image_attributes ) )
221
+ return current( $image_attributes );
222
+ }
223
+
224
+ }
225
+ ?>
includes/commission.php ADDED
@@ -0,0 +1,325 @@