WooCommerce – Store Exporter - Version 1.8.4

Version Description

  • Fixed: Privilege escalation vulnerability (thanks jamesgol)
Download this release

Release Info

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

Version 1.8.4

Files changed (63) hide show
  1. common/common.php +95 -0
  2. exporter.php +570 -0
  3. includes/admin.php +893 -0
  4. includes/brand.php +148 -0
  5. includes/category.php +202 -0
  6. includes/commission.php +298 -0
  7. includes/common-dashboard_widgets.php +56 -0
  8. includes/coupon.php +205 -0
  9. includes/customer.php +301 -0
  10. includes/export-csv.php +49 -0
  11. includes/formatting.php +599 -0
  12. includes/functions.php +1002 -0
  13. includes/install.php +42 -0
  14. includes/legacy.php +10 -0
  15. includes/order.php +1636 -0
  16. includes/product.php +1697 -0
  17. includes/product_vendor.php +125 -0
  18. includes/settings.php +565 -0
  19. includes/shipping_class.php +96 -0
  20. includes/subscription.php +244 -0
  21. includes/tag.php +168 -0
  22. includes/user.php +344 -0
  23. js/jquery-ui.js +48 -0
  24. js/jquery.chosen.js +988 -0
  25. js/jquery.csvToTable.js +154 -0
  26. js/jquery.timepicker.js +2244 -0
  27. js/ui-datepicker.js +84 -0
  28. languages/woocommerce-exporter-en_GB.mo +0 -0
  29. languages/woocommerce-exporter-en_GB.po +97 -0
  30. license.txt +281 -0
  31. readme.txt +607 -0
  32. templates/admin/chosen-sprite.png +0 -0
  33. templates/admin/chosen.css +397 -0
  34. templates/admin/export.css +105 -0
  35. templates/admin/export.js +514 -0
  36. templates/admin/images/animated-overlay.gif +0 -0
  37. templates/admin/images/progress.gif +0 -0
  38. templates/admin/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  39. templates/admin/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  40. templates/admin/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  41. templates/admin/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  42. templates/admin/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  43. templates/admin/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  44. templates/admin/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  45. templates/admin/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  46. templates/admin/images/ui-icons_222222_256x240.png +0 -0
  47. templates/admin/images/ui-icons_2e83ff_256x240.png +0 -0
  48. templates/admin/images/ui-icons_454545_256x240.png +0 -0
  49. templates/admin/images/ui-icons_888888_256x240.png +0 -0
  50. templates/admin/images/ui-icons_cd0a0a_256x240.png +0 -0
  51. templates/admin/jquery-csvtable.css +40 -0
  52. templates/admin/jquery-ui-datepicker.css +347 -0
  53. templates/admin/jquery-ui-timepicker.css +12 -0
  54. templates/admin/media-csv_file.php +12 -0
  55. templates/admin/media-export_details.php +58 -0
  56. templates/admin/tabs-archive.php +80 -0
  57. templates/admin/tabs-export.php +990 -0
  58. templates/admin/tabs-fields.php +29 -0
  59. templates/admin/tabs-overview.php +135 -0
  60. templates/admin/tabs-settings.php +168 -0
  61. templates/admin/tabs-tools.php +30 -0
  62. templates/admin/tabs.php +13 -0
  63. templates/admin/woocommerce-admin_dashboard_vm-plugins.css +55 -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,570 @@
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.4
7
+ Author: Visser Labs
8
+ Author URI: http://www.visser.com.au/about/
9
+ License: GPL2
10
+ Text Domain: woocommerce-exporter
11
+ */
12
+
13
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
+
15
+ define( 'WOO_CE_DIRNAME', basename( dirname( __FILE__ ) ) );
16
+ define( 'WOO_CE_RELPATH', basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ) );
17
+ define( 'WOO_CE_PATH', plugin_dir_path( __FILE__ ) );
18
+ define( 'WOO_CE_PREFIX', 'woo_ce' );
19
+
20
+ // Turn this on to enable additional debugging options at export time
21
+ define( 'WOO_CE_DEBUG', false );
22
+
23
+ // Avoid conflicts if Store Exporter Deluxe is activated
24
+ include_once( WOO_CE_PATH . 'common/common.php' );
25
+ if( defined( 'WOO_CD_PREFIX' ) == false )
26
+ include_once( WOO_CE_PATH . 'includes/functions.php' );
27
+
28
+ function woo_ce_i18n() {
29
+
30
+ $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-exporter' );
31
+ load_plugin_textdomain( 'woocommerce-exporter', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
32
+
33
+ }
34
+ add_action( 'init', 'woo_ce_i18n' );
35
+
36
+ if( is_admin() ) {
37
+
38
+ /* Start of: WordPress Administration */
39
+
40
+ // Register our install script for first time install
41
+ include_once( WOO_CE_PATH . 'includes/install.php' );
42
+ register_activation_hook( __FILE__, 'woo_ce_install' );
43
+
44
+ // Initial scripts and export process
45
+ function woo_ce_admin_init() {
46
+
47
+ global $export, $wp_roles;
48
+
49
+ // Now is the time to de-activate Store Exporter if Store Exporter Deluxe is activated
50
+ if( defined( 'WOO_CD_PREFIX' ) ) {
51
+ include_once( WOO_CE_PATH . 'includes/install.php' );
52
+ woo_ce_deactivate_ce();
53
+ return;
54
+ }
55
+
56
+ // Check the User has the activate_plugins capability
57
+ if( current_user_can( 'activate_plugins' ) ) {
58
+
59
+ // Detect if any known conflict Plugins are activated
60
+
61
+ // WooCommerce Subscriptions Exporter - http://codecanyon.net/item/woocommerce-subscription-exporter/6569668
62
+ if( function_exists( 'wc_subs_exporter_admin_init' ) ) {
63
+ $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 );
64
+ woo_cd_admin_notice( $message, 'error', array( 'plugins.php', 'admin.php' ) );
65
+ }
66
+
67
+ }
68
+
69
+ // Check the User has the view_woocommerce_reports capability
70
+ if( current_user_can( 'view_woocommerce_reports' ) == false )
71
+ return;
72
+
73
+ // Check that we are on the Store Exporter screen
74
+ $page = ( isset($_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : false );
75
+ if( $page != strtolower( WOO_CE_PREFIX ) )
76
+ return;
77
+
78
+ // Detect other platform versions
79
+ woo_ce_detect_non_woo_install();
80
+
81
+ // Process any pre-export notice confirmations
82
+ $action = ( function_exists( 'woo_get_action' ) ? woo_get_action() : false );
83
+ switch( $action ) {
84
+
85
+ // Prompt on Export screen when insufficient memory (less than 64M is allocated)
86
+ case 'dismiss_memory_prompt':
87
+ // We need to verify the nonce.
88
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_dismiss_memory_prompt' ) ) {
89
+ woo_ce_update_option( 'dismiss_memory_prompt', 1 );
90
+ $url = add_query_arg( array( 'action' => null, '_wpnonce' => null ) );
91
+ wp_redirect( $url );
92
+ exit();
93
+ }
94
+ break;
95
+
96
+ // Prompt on Export screen when PHP configuration option max_execution_time cannot be increased
97
+ case 'dismiss_execution_time_prompt':
98
+ // We need to verify the nonce.
99
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_dismiss_execution_time_prompt' ) ) {
100
+ woo_ce_update_option( 'dismiss_execution_time_prompt', 1 );
101
+ $url = add_query_arg( array( 'action' => null, '_wpnonce' => null ) );
102
+ wp_redirect( $url );
103
+ exit();
104
+ }
105
+ break;
106
+
107
+ // Prompt on Export screen when insufficient memory (less than 64M is allocated)
108
+ case 'dismiss_php_legacy':
109
+ // We need to verify the nonce.
110
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_dismiss_php_legacy' ) ) {
111
+ woo_ce_update_option( 'dismiss_php_legacy', 1 );
112
+ $url = add_query_arg( array( 'action' => null, '_wpnonce' => null ) );
113
+ wp_redirect( $url );
114
+ exit();
115
+ }
116
+ break;
117
+
118
+ case 'dismiss_subscription_prompt':
119
+ // We need to verify the nonce.
120
+ if( !empty( $_GET ) && check_admin_referer( 'woo_ce_dismiss_subscription_prompt' ) ) {
121
+ woo_ce_update_option( 'dismiss_subscription_prompt', 1 );
122
+ $url = add_query_arg( array( 'action' => null, '_wpnonce' => null ) );
123
+ wp_redirect( $url );
124
+ exit();
125
+ }
126
+ break;
127
+
128
+ // Save skip overview preference
129
+ case 'skip_overview':
130
+ if( !empty( $_POST ) && check_admin_referer( 'skip_overview', 'woo_ce_skip_overview' ) ) {
131
+ $skip_overview = false;
132
+ if( isset( $_POST['skip_overview'] ) )
133
+ $skip_overview = 1;
134
+ woo_ce_update_option( 'skip_overview', $skip_overview );
135
+
136
+ if( $skip_overview == 1 ) {
137
+ $url = add_query_arg( array( 'tab' => 'export', '_wpnonce' => null ) );
138
+ wp_redirect( $url );
139
+ exit();
140
+ }
141
+ }
142
+ break;
143
+
144
+ // This is where the magic happens
145
+ case 'export':
146
+
147
+ // Make sure we play nice with other WooCommerce and WordPress exporters
148
+ if( !isset( $_POST['woo_ce_export'] ) )
149
+ return;
150
+
151
+ check_admin_referer( 'manual_export', 'woo_ce_export' );
152
+
153
+ // Set up the basic export options
154
+ $export = new stdClass();
155
+ $export->cron = 0;
156
+ $export->scheduled_export = 0;
157
+ $export->start_time = time();
158
+ $export->idle_memory_start = woo_ce_current_memory_usage();
159
+ $export->delete_file = woo_ce_get_option( 'delete_file', 1 );
160
+ $export->encoding = woo_ce_get_option( 'encoding', get_option( 'blog_charset', 'UTF-8' ) );
161
+ // Reset the Encoding if corrupted
162
+ if( $export->encoding == '' || $export->encoding == false || $export->encoding == 'System default' ) {
163
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Encoding export option was corrupted, defaulted to UTF-8', 'woo_ce' ) ) );
164
+ $export->encoding = 'UTF-8';
165
+ woo_ce_update_option( 'encoding', 'UTF-8' );
166
+ }
167
+ $export->delimiter = woo_ce_get_option( 'delimiter', ',' );
168
+ // Reset the Delimiter if corrupted
169
+ if( $export->delimiter == '' || $export->delimiter == false ) {
170
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Delimiter export option was corrupted, defaulted to ,', 'woo_ce' ) ) );
171
+ $export->delimiter = ',';
172
+ woo_ce_update_option( 'delimiter', ',' );
173
+ }
174
+ $export->category_separator = woo_ce_get_option( 'category_separator', '|' );
175
+ // Reset the Category Separator if corrupted
176
+ if( $export->category_separator == '' || $export->category_separator == false ) {
177
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Category Separator export option was corrupted, defaulted to |', 'woo_ce' ) ) );
178
+ $export->category_separator = '|';
179
+ woo_ce_update_option( 'category_separator', '|' );
180
+ }
181
+ $export->bom = woo_ce_get_option( 'bom', 1 );
182
+ $export->escape_formatting = woo_ce_get_option( 'escape_formatting', 'all' );
183
+ // Reset the Escape Formatting if corrupted
184
+ if( $export->escape_formatting == '' || $export->escape_formatting == false ) {
185
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Escape Formatting export option was corrupted, defaulted to all', 'woo_ce' ) ) );
186
+ $export->escape_formatting = 'all';
187
+ woo_ce_update_option( 'escape_formatting', 'all' );
188
+ }
189
+ $export->date_format = woo_ce_get_option( 'date_format', 'd/m/Y' );
190
+ // Reset the Date Format if corrupted
191
+ if( $export->date_format == '1' || $export->date_format == '' || $export->date_format == false ) {
192
+ woo_ce_error_log( sprintf( 'Warning: %s', __( 'Date Format export option was corrupted, defaulted to d/m/Y', 'woo_ce' ) ) );
193
+ $export->date_format = 'd/m/Y';
194
+ woo_ce_update_option( 'date_format', 'd/m/Y' );
195
+ }
196
+
197
+ // Save export option changes made on the Export screen
198
+ $export->limit_volume = ( isset( $_POST['limit_volume'] ) ? sanitize_text_field( $_POST['limit_volume'] ) : '' );
199
+ woo_ce_update_option( 'limit_volume', $export->limit_volume );
200
+ if( $export->limit_volume == '' )
201
+ $export->limit_volume = -1;
202
+ $export->offset = ( isset( $_POST['offset'] ) ? sanitize_text_field( $_POST['offset'] ) : '' );
203
+ woo_ce_update_option( 'offset', $export->offset );
204
+ if( $export->offset == '' )
205
+ $export->offset = 0;
206
+
207
+ // Set default values for all export options to be later passed onto the export process
208
+ $export->fields = array();
209
+ $export->fields_order = false;
210
+ $export->export_format = 'csv';
211
+
212
+ // Product sorting
213
+ $export->product_categories = false;
214
+ $export->product_tags = false;
215
+ $export->product_status = false;
216
+ $export->product_type = false;
217
+ $export->product_orderby = false;
218
+ $export->product_order = false;
219
+ $export->gallery_formatting = false;
220
+ $export->upsell_formatting = false;
221
+ $export->crosssell_formatting = false;
222
+
223
+ // Category sorting
224
+ $export->category_orderby = false;
225
+ $export->category_order = false;
226
+
227
+ // Tag sorting
228
+ $export->tag_orderby = false;
229
+ $export->tag_order = false;
230
+
231
+ // User sorting
232
+ $export->user_orderby = false;
233
+ $export->user_order = false;
234
+
235
+ $export->type = ( isset( $_POST['dataset'] ) ? sanitize_text_field( $_POST['dataset'] ) : false );
236
+ if( $export->type ) {
237
+ $export->fields = ( isset( $_POST[$export->type . '_fields'] ) ? array_map( 'sanitize_text_field', $_POST[$export->type . '_fields'] ) : false );
238
+ $export->fields_order = ( isset( $_POST[$export->type . '_fields_order'] ) ? array_map( 'absint', $_POST[$export->type . '_fields_order'] ) : false );
239
+ woo_ce_update_option( 'last_export', $export->type );
240
+ }
241
+ switch( $export->type ) {
242
+
243
+ case 'product':
244
+ // Set up dataset specific options
245
+ $export->product_categories = ( isset( $_POST['product_filter_category'] ) ? woo_ce_format_product_filters( array_map( 'absint', $_POST['product_filter_category'] ) ) : false );
246
+ $export->product_tags = ( isset( $_POST['product_filter_tag'] ) ? woo_ce_format_product_filters( array_map( 'absint', $_POST['product_filter_tag'] ) ) : false );
247
+ $export->product_status = ( isset( $_POST['product_filter_status'] ) ? woo_ce_format_product_filters( array_map( 'sanitize_text_field', $_POST['product_filter_status'] ) ) : false );
248
+ $export->product_type = ( isset( $_POST['product_filter_type'] ) ? woo_ce_format_product_filters( array_map( 'sanitize_text_field', $_POST['product_filter_type'] ) ) : false );
249
+ $export->product_orderby = ( isset( $_POST['product_orderby'] ) ? sanitize_text_field( $_POST['product_orderby'] ) : false );
250
+ $export->product_order = ( isset( $_POST['product_order'] ) ? sanitize_text_field( $_POST['product_order'] ) : false );
251
+ $export->gallery_formatting = ( isset( $_POST['product_gallery_formatting'] ) ? absint( $_POST['product_gallery_formatting'] ) : false );
252
+ $export->upsell_formatting = ( isset( $_POST['product_upsell_formatting'] ) ? absint( $_POST['product_upsell_formatting'] ) : false );
253
+ $export->crosssell_formatting = ( isset( $_POST['product_crosssell_formatting'] ) ? absint( $_POST['product_crosssell_formatting'] ) : false );
254
+
255
+ // Save dataset export specific options
256
+ if( $export->product_orderby <> woo_ce_get_option( 'product_orderby' ) )
257
+ woo_ce_update_option( 'product_orderby', $export->product_orderby );
258
+ if( $export->product_order <> woo_ce_get_option( 'product_order' ) )
259
+ woo_ce_update_option( 'product_order', $export->product_order );
260
+ if( $export->upsell_formatting <> woo_ce_get_option( 'upsell_formatting' ) )
261
+ woo_ce_update_option( 'upsell_formatting', $export->upsell_formatting );
262
+ if( $export->crosssell_formatting <> woo_ce_get_option( 'crosssell_formatting' ) )
263
+ woo_ce_update_option( 'crosssell_formatting', $export->crosssell_formatting );
264
+ break;
265
+
266
+ case 'category':
267
+ // Set up dataset specific options
268
+ $export->category_orderby = ( isset( $_POST['category_orderby'] ) ? sanitize_text_field( $_POST['category_orderby'] ) : false );
269
+ $export->category_order = ( isset( $_POST['category_order'] ) ? sanitize_text_field( $_POST['category_order'] ) : false );
270
+
271
+ // Save dataset export specific options
272
+ if( $export->category_orderby <> woo_ce_get_option( 'category_orderby' ) )
273
+ woo_ce_update_option( 'category_orderby', $export->category_orderby );
274
+ if( $export->category_order <> woo_ce_get_option( 'category_order' ) )
275
+ woo_ce_update_option( 'category_order', $export->category_order );
276
+ break;
277
+
278
+ case 'tag':
279
+ // Set up dataset specific options
280
+ $export->tag_orderby = ( isset( $_POST['tag_orderby'] ) ? sanitize_text_field( $_POST['tag_orderby'] ) : false );
281
+ $export->tag_order = ( isset( $_POST['tag_order'] ) ? sanitize_text_field( $_POST['tag_order'] ) : false );
282
+
283
+ // Save dataset export specific options
284
+ if( $export->tag_orderby <> woo_ce_get_option( 'tag_orderby' ) )
285
+ woo_ce_update_option( 'tag_orderby', $export->tag_orderby );
286
+ if( $export->tag_order <> woo_ce_get_option( 'tag_order' ) )
287
+ woo_ce_update_option( 'tag_order', $export->tag_order );
288
+ break;
289
+
290
+ case 'user':
291
+ // Set up dataset specific options
292
+ $export->user_orderby = ( isset( $_POST['user_orderby'] ) ? sanitize_text_field( $_POST['user_orderby'] ) : false );
293
+ $export->user_order = ( isset( $_POST['user_order'] ) ? sanitize_text_field( $_POST['user_order'] ) : false );
294
+
295
+ // Save dataset export specific options
296
+ if( $export->user_orderby <> woo_ce_get_option( 'user_orderby' ) )
297
+ woo_ce_update_option( 'user_orderby', $export->user_orderby );
298
+ if( $export->user_order <> woo_ce_get_option( 'user_order' ) )
299
+ woo_ce_update_option( 'user_order', $export->user_order );
300
+ break;
301
+
302
+ }
303
+ if( $export->type ) {
304
+
305
+ $timeout = 600;
306
+ if( isset( $_POST['timeout'] ) ) {
307
+ $timeout = absint( $_POST['timeout'] );
308
+ if( $timeout <> woo_ce_get_option( 'timeout' ) )
309
+ woo_ce_update_option( 'timeout', $timeout );
310
+ }
311
+ if( !ini_get( 'safe_mode' ) ) {
312
+ @set_time_limit( $timeout );
313
+ @ini_set( 'max_execution_time', $timeout );
314
+ }
315
+
316
+ @ini_set( 'memory_limit', WP_MAX_MEMORY_LIMIT );
317
+
318
+ $export->args = array(
319
+ 'limit_volume' => $export->limit_volume,
320
+ 'offset' => $export->offset,
321
+ 'encoding' => $export->encoding,
322
+ 'date_format' => $export->date_format,
323
+ 'product_categories' => $export->product_categories,
324
+ 'product_tags' => $export->product_tags,
325
+ 'product_status' => $export->product_status,
326
+ 'product_type' => $export->product_type,
327
+ 'product_orderby' => $export->product_orderby,
328
+ 'product_order' => $export->product_order,
329
+ 'category_orderby' => $export->category_orderby,
330
+ 'category_order' => $export->category_order,
331
+ 'tag_orderby' => $export->tag_orderby,
332
+ 'tag_order' => $export->tag_order,
333
+ 'user_orderby' => $export->user_orderby,
334
+ 'user_order' => $export->user_order
335
+ );
336
+ if( empty( $export->fields ) ) {
337
+ $message = __( 'No export fields were selected, please try again with at least a single export field.', 'woocommerce-exporter' );
338
+ woo_ce_admin_notice( $message, 'error' );
339
+ return false;
340
+ }
341
+ woo_ce_save_fields( $export->type, $export->fields, $export->fields_order );
342
+
343
+ if( $export->export_format == 'csv' ) {
344
+ $export->filename = woo_ce_generate_csv_filename( $export->type );
345
+ }
346
+
347
+ // Print file contents to debug export screen
348
+ if( WOO_CE_DEBUG ) {
349
+
350
+ if( in_array( $export->export_format, array( 'csv' ) ) ) {
351
+ woo_ce_export_dataset( $export->type );
352
+ }
353
+ $export->idle_memory_end = woo_ce_current_memory_usage();
354
+ $export->end_time = time();
355
+
356
+ // Print file contents to browser
357
+ } else {
358
+ if( in_array( $export->export_format, array( 'csv' ) ) ) {
359
+
360
+ // Generate CSV contents
361
+ $bits = woo_ce_export_dataset( $export->type );
362
+ unset( $export->fields );
363
+ if( empty( $bits ) ) {
364
+ $message = __( 'No export entries were found, please try again with different export filters.', 'woocommerce-exporter' );
365
+ woo_ce_admin_notice( $message, 'error' );
366
+ return;
367
+ }
368
+ if( $export->delete_file ) {
369
+
370
+ // Print to browser
371
+ if( $export->export_format == 'csv' )
372
+ woo_ce_generate_csv_header( $export->type );
373
+ echo $bits;
374
+ exit();
375
+
376
+ } else {
377
+
378
+ // Save to file and insert to WordPress Media
379
+ if( $export->filename && $bits ) {
380
+ if( $export->export_format == 'csv' )
381
+ $post_ID = woo_ce_save_file_attachment( $export->filename, 'text/csv' );
382
+ $upload = wp_upload_bits( $export->filename, null, $bits );
383
+ if( ( $post_ID == false ) || $upload['error'] ) {
384
+ wp_delete_attachment( $post_ID, true );
385
+ if( isset( $upload['error'] ) )
386
+ wp_redirect( esc_url( add_query_arg( array( 'failed' => true, 'message' => urlencode( $upload['error'] ) ) ) ) );
387
+ else
388
+ wp_redirect( esc_url( add_query_arg( array( 'failed' => true ) ) ) );
389
+ return;
390
+ }
391
+ $attach_data = wp_generate_attachment_metadata( $post_ID, $upload['file'] );
392
+ wp_update_attachment_metadata( $post_ID, $attach_data );
393
+ update_attached_file( $post_ID, $upload['file'] );
394
+ if( $post_ID ) {
395
+ woo_ce_save_file_guid( $post_ID, $export->type, $upload['url'] );
396
+ woo_ce_save_file_details( $post_ID );
397
+ }
398
+ $export_type = $export->type;
399
+ unset( $export );
400
+
401
+ // The end memory usage and time is collected at the very last opportunity prior to the CSV header being rendered to the screen
402
+ woo_ce_update_file_detail( $post_ID, '_woo_idle_memory_end', woo_ce_current_memory_usage() );
403
+ woo_ce_update_file_detail( $post_ID, '_woo_end_time', time() );
404
+
405
+ // Generate CSV header
406
+ woo_ce_generate_csv_header( $export_type );
407
+ unset( $export_type );
408
+
409
+ // Print file contents to screen
410
+ if( $upload['file'] ) {
411
+ readfile( $upload['file'] );
412
+ } else {
413
+ $url = add_query_arg( 'failed', true );
414
+ wp_redirect( $url );
415
+ }
416
+ unset( $upload );
417
+ } else {
418
+ $url = add_query_arg( 'failed', true );
419
+ wp_redirect( $url );
420
+ }
421
+
422
+ }
423
+
424
+ }
425
+ exit();
426
+ }
427
+ }
428
+ break;
429
+
430
+ // Save changes on Settings screen
431
+ case 'save-settings':
432
+ // We need to verify the nonce.
433
+ if( !empty( $_POST ) && check_admin_referer( 'save_settings', 'woo_ce_save_settings' ) ) {
434
+ // Sanitize each setting field as needed
435
+ woo_ce_update_option( 'export_filename', strip_tags( (string)$_POST['export_filename'] ) );
436
+ woo_ce_update_option( 'delete_file', sanitize_text_field( (int)$_POST['delete_file'] ) );
437
+ woo_ce_update_option( 'encoding', sanitize_text_field( (string)$_POST['encoding'] ) );
438
+ woo_ce_update_option( 'delimiter', sanitize_text_field( (string)$_POST['delimiter'] ) );
439
+ woo_ce_update_option( 'category_separator', sanitize_text_field( (string)$_POST['category_separator'] ) );
440
+ woo_ce_update_option( 'bom', absint( (int)$_POST['bom'] ) );
441
+ woo_ce_update_option( 'escape_formatting', sanitize_text_field( (string)$_POST['escape_formatting'] ) );
442
+ if( $_POST['date_format'] == 'custom' && !empty( $_POST['date_format_custom'] ) )
443
+ woo_ce_update_option( 'date_format', sanitize_text_field( (string)$_POST['date_format_custom'] ) );
444
+ else
445
+ woo_ce_update_option( 'date_format', sanitize_text_field( (string)$_POST['date_format'] ) );
446
+
447
+ $message = __( 'Changes have been saved.', 'woocommerce-exporter' );
448
+ woo_ce_admin_notice( $message );
449
+ }
450
+ break;
451
+
452
+ // Save changes on Field Editor screen
453
+ case 'save-fields':
454
+ // We need to verify the nonce.
455
+ if( !empty( $_POST ) && check_admin_referer( 'save_fields', 'woo_ce_save_fields' ) ) {
456
+ $fields = ( isset( $_POST['fields'] ) ? array_filter( $_POST['fields'] ) : array() );
457
+ $export_type = ( isset( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : '' );
458
+ $export_types = array_keys( woo_ce_get_export_types() );
459
+ // Check we are saving against a valid export type
460
+ if( in_array( $export_type, $export_types ) ) {
461
+ woo_ce_update_option( $export_type . '_labels', $fields );
462
+ $message = __( 'Field labels have been saved.', 'woocommerce-exporter' );
463
+ woo_ce_admin_notice( $message );
464
+ } else {
465
+ $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' );
466
+ woo_ce_admin_notice( $message, 'error' );
467
+ }
468
+ }
469
+ break;
470
+
471
+ }
472
+
473
+ }
474
+ add_action( 'admin_init', 'woo_ce_admin_init', 10 );
475
+
476
+ // HTML templates and form processor for Store Exporter screen
477
+ function woo_ce_html_page() {
478
+
479
+ global $wpdb, $export;
480
+
481
+ $title = apply_filters( 'woo_ce_template_header', __( 'Store Exporter', 'woocommerce-exporter' ) );
482
+ woo_ce_template_header( $title );
483
+ woo_ce_support_donate();
484
+ $action = ( function_exists( 'woo_get_action' ) ? woo_get_action() : false );
485
+ switch( $action ) {
486
+
487
+ case 'export':
488
+ if( WOO_CE_DEBUG ) {
489
+ if( false === ( $export_log = get_transient( WOO_CE_PREFIX . '_debug_log' ) ) ) {
490
+ $export_log = __( 'No export entries were found, please try again with different export filters.', 'woocommerce-exporter' );
491
+ } else {
492
+ // We take the contents of our WordPress Transient and de-base64 it back to CSV format
493
+ $export_log = base64_decode( $export_log );
494
+ }
495
+ delete_transient( WOO_CE_PREFIX . '_debug_log' );
496
+ $output = '
497
+ <h3>' . sprintf( __( 'Export Details: %s', 'woocommerce-exporter' ), esc_attr( $export->filename ) ) . '</h3>
498
+ <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>
499
+ <textarea id="export_log">' . esc_textarea( print_r( $export, true ) ) . '</textarea>
500
+ <hr />';
501
+ if( in_array( $export->export_format, array( 'csv' ) ) ) {
502
+ $output .= '
503
+ <script type="text/javascript">
504
+ $j(function() {
505
+ $j(\'#export_sheet\').CSVToTable(\'\', { startLine: 0 });
506
+ });
507
+ </script>
508
+ <h3>' . __( 'Export', 'woocommerce-exporter' ) . '</h3>
509
+ <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>
510
+ <div id="export_sheet">' . esc_textarea( $export_log ) . '</div>
511
+ <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>
512
+ <hr />';
513
+ }
514
+ $output .= '
515
+ <h3>' . __( 'Export Log', 'woocommerce-exporter' ) . '</h3>
516
+ <p>' . __( 'This prints the raw export contents and is helpful when the jQuery plugin above fails due to major formatting errors.', 'woocommerce-exporter' ) . '</p>
517
+ <textarea id="export_log" wrap="off">' . esc_textarea( $export_log ) . '</textarea>
518
+ <hr />
519
+ ';
520
+ echo $output;
521
+ }
522
+
523
+ woo_ce_manage_form();
524
+ break;
525
+
526
+ case 'update':
527
+ // Save Custom Product Meta
528
+ if( isset( $_POST['custom_products'] ) ) {
529
+ $custom_products = $_POST['custom_products'];
530
+ $custom_products = explode( "\n", trim( $custom_products ) );
531
+ $size = count( $custom_products );
532
+ if( !empty( $size ) ) {
533
+ for( $i = 0; $i < $size; $i++ )
534
+ $custom_products[$i] = sanitize_text_field( trim( $custom_products[$i] ) );
535
+ woo_ce_update_option( 'custom_products', $custom_products );
536
+ }
537
+ }
538
+
539
+ $message = __( 'Custom Fields saved. You can now select those additional fields from the Export Fields list.', 'woocommerce-exporter' );
540
+ woo_ce_admin_notice_html( $message );
541
+ woo_ce_manage_form();
542
+ break;
543
+
544
+ default:
545
+ woo_ce_manage_form();
546
+ break;
547
+
548
+ }
549
+ woo_ce_template_footer();
550
+
551
+ }
552
+
553
+ // HTML template for Export screen
554
+ function woo_ce_manage_form() {
555
+
556
+ $tab = ( isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : false );
557
+ // If Skip Overview is set then jump to Export screen
558
+ if( $tab == false && woo_ce_get_option( 'skip_overview', false ) )
559
+ $tab = 'export';
560
+
561
+ woo_ce_admin_fail_notices();
562
+
563
+ include_once( WOO_CE_PATH . 'templates/admin/tabs.php' );
564
+
565
+ }
566
+
567
+ /* End of: WordPress Administration */
568
+
569
+ }
570
+ ?>
includes/admin.php ADDED
@@ -0,0 +1,893 @@
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
+ set_transient( WOO_CE_PREFIX . '_notice', base64_encode( $output ), MINUTE_IN_SECONDS );
19
+ add_action( 'admin_notices', 'woo_ce_admin_notice_print' );
20
+ }
21
+
22
+ }
23
+
24
+ // HTML template for admin notice
25
+ function woo_ce_admin_notice_html( $message = '', $priority = 'updated', $screen = '' ) {
26
+
27
+ // Display admin notice on specific screen
28
+ if( !empty( $screen ) ) {
29
+
30
+ global $pagenow;
31
+
32
+ if( is_array( $screen ) ) {
33
+ if( in_array( $pagenow, $screen ) == false )
34
+ return;
35
+ } else {
36
+ if( $pagenow <> $screen )
37
+ return;
38
+ }
39
+
40
+ } ?>
41
+ <div id="message" class="<?php echo $priority; ?>">
42
+ <p><?php echo $message; ?></p>
43
+ </div>
44
+ <?php
45
+
46
+ }
47
+
48
+ // Grabs the WordPress transient that holds the admin notice and prints it
49
+ function woo_ce_admin_notice_print() {
50
+
51
+ $output = get_transient( WOO_CE_PREFIX . '_notice' );
52
+ if( $output !== false ) {
53
+ delete_transient( WOO_CE_PREFIX . '_notice' );
54
+ $output = base64_decode( $output );
55
+ echo $output;
56
+ }
57
+
58
+ }
59
+
60
+ // HTML template header on Store Exporter screen
61
+ function woo_ce_template_header( $title = '', $icon = 'woocommerce' ) {
62
+
63
+ if( $title )
64
+ $output = $title;
65
+ else
66
+ $output = __( 'Store Export', 'woocommerce-exporter' ); ?>
67
+ <div id="woo-ce" class="wrap">
68
+ <div id="icon-<?php echo $icon; ?>" class="icon32 icon32-woocommerce-importer"><br /></div>
69
+ <h2>
70
+ <?php echo $output; ?>
71
+ </h2>
72
+ <?php
73
+
74
+ }
75
+
76
+ // HTML template footer on Store Exporter screen
77
+ function woo_ce_template_footer() { ?>
78
+ </div>
79
+ <!-- .wrap -->
80
+ <?php
81
+
82
+ }
83
+
84
+ function woo_ce_export_options_export_format() {
85
+
86
+ $woo_cd_url = 'http://www.visser.com.au/woocommerce/plugins/exporter-deluxe/';
87
+ $woo_cd_link = sprintf( '<a href="%s" target="_blank">' . __( 'Store Exporter Deluxe', 'woocommerce-exporter' ) . '</a>', $woo_cd_url );
88
+
89
+ ob_start(); ?>
90
+ <tr>
91
+ <th>
92
+ <label><?php _e( 'Export format', 'woocommerce-exporter' ); ?></label>
93
+ </th>
94
+ <td>
95
+ <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 />
96
+ <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 />
97
+ <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 />
98
+ <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 />
99
+ <div class="export-options product-options">
100
+ <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>
101
+ </div>
102
+ <p class="description"><?php _e( 'Adjust the export format to generate different export file formats.', 'woocommerce-exporter' ); ?></p>
103
+ </td>
104
+ </tr>
105
+ <?php
106
+ ob_end_flush();
107
+
108
+ }
109
+
110
+ // Add Export and Docs links to the Plugins screen
111
+ function woo_ce_add_settings_link( $links, $file ) {
112
+
113
+ // Manually force slug
114
+ $this_plugin = WOO_CE_RELPATH;
115
+
116
+ if( $file == $this_plugin ) {
117
+ $docs_url = 'http://www.visser.com.au/docs/';
118
+ $docs_link = sprintf( '<a href="%s" target="_blank">' . __( 'Docs', 'woocommerce-exporter' ) . '</a>', $docs_url );
119
+ $export_link = sprintf( '<a href="%s">' . __( 'Export', 'woocommerce-exporter' ) . '</a>', esc_url( add_query_arg( 'page', 'woo_ce', 'admin.php' ) ) );
120
+ array_unshift( $links, $docs_link );
121
+ array_unshift( $links, $export_link );
122
+ }
123
+ return $links;
124
+
125
+ }
126
+ add_filter( 'plugin_action_links', 'woo_ce_add_settings_link', 10, 2 );
127
+
128
+ // Add Store Export page to WooCommerce screen IDs
129
+ function woo_ce_wc_screen_ids( $screen_ids = array() ) {
130
+
131
+ $screen_ids[] = 'woocommerce_page_woo_ce';
132
+ return $screen_ids;
133
+
134
+ }
135
+ add_filter( 'woocommerce_screen_ids', 'woo_ce_wc_screen_ids', 10, 1 );
136
+
137
+ // Add Store Export to WordPress Administration menu
138
+ function woo_ce_admin_menu() {
139
+
140
+ $page = add_submenu_page( 'woocommerce', __( 'Store Exporter', 'woocommerce-exporter' ), __( 'Store Export', 'woocommerce-exporter' ), 'view_woocommerce_reports', 'woo_ce', 'woo_ce_html_page' );
141
+ add_action( 'admin_print_styles-' . $page, 'woo_ce_enqueue_scripts' );
142
+ add_action( 'current_screen', 'woo_ce_add_help_tab' );
143
+
144
+ }
145
+ add_action( 'admin_menu', 'woo_ce_admin_menu', 11 );
146
+
147
+ // Load CSS and jQuery scripts for Store Exporter screen
148
+ function woo_ce_enqueue_scripts() {
149
+
150
+ // Simple check that WooCommerce is activated
151
+ if( class_exists( 'WooCommerce' ) ) {
152
+
153
+ global $woocommerce;
154
+
155
+ // Load WooCommerce default Admin styling
156
+ wp_enqueue_style( 'woocommerce_admin_styles', $woocommerce->plugin_url() . '/assets/css/admin.css' );
157
+
158
+ }
159
+
160
+ // Date Picker
161
+ wp_enqueue_script( 'jquery-ui-datepicker' );
162
+ wp_enqueue_style( 'jquery-ui-datepicker', plugins_url( '/templates/admin/jquery-ui-datepicker.css', WOO_CE_RELPATH ) );
163
+
164
+ // Time Picker, Date Picker Addon
165
+ wp_enqueue_script( 'jquery-ui-timepicker', plugins_url( '/js/jquery.timepicker.js', WOO_CE_RELPATH ), array( 'jquery', 'jquery-ui-datepicker' ) );
166
+ wp_enqueue_style( 'jquery-ui-datepicker', plugins_url( '/templates/admin/jquery-ui-timepicker.css', WOO_CE_RELPATH ) );
167
+
168
+ // Chosen
169
+ wp_enqueue_style( 'jquery-chosen', plugins_url( '/templates/admin/chosen.css', WOO_CE_RELPATH ) );
170
+ wp_enqueue_script( 'jquery-chosen', plugins_url( '/js/jquery.chosen.js', WOO_CE_RELPATH ), array( 'jquery' ) );
171
+
172
+ // Common
173
+ wp_enqueue_style( 'woo_ce_styles', plugins_url( '/templates/admin/export.css', WOO_CE_RELPATH ) );
174
+ wp_enqueue_script( 'woo_ce_scripts', plugins_url( '/templates/admin/export.js', WOO_CE_RELPATH ), array( 'jquery', 'jquery-ui-sortable' ) );
175
+ wp_enqueue_style( 'dashicons' );
176
+
177
+ if( WOO_CE_DEBUG ) {
178
+ wp_enqueue_style( 'jquery-csvToTable', plugins_url( '/templates/admin/jquery-csvtable.css', WOO_CE_RELPATH ) );
179
+ wp_enqueue_script( 'jquery-csvToTable', plugins_url( '/js/jquery.csvToTable.js', WOO_CE_RELPATH ), array( 'jquery' ) );
180
+ }
181
+ wp_enqueue_style( 'woo_vm_styles', plugins_url( '/templates/admin/woocommerce-admin_dashboard_vm-plugins.css', WOO_CE_RELPATH ) );
182
+
183
+ }
184
+
185
+ function woo_ce_add_help_tab() {
186
+
187
+ $screen = get_current_screen();
188
+ if( $screen->id <> 'woocommerce_page_woo_ce' )
189
+ return;
190
+
191
+ $screen->add_help_tab( array(
192
+ 'id' => 'woo_ce',
193
+ 'title' => __( 'Store Exporter', 'woocommerce-exporter' ),
194
+ 'content' =>
195
+ '<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>' .
196
+ '<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>'
197
+ ) );
198
+
199
+ }
200
+
201
+ function woo_ce_plugin_page_notices() {
202
+
203
+ global $pagenow;
204
+
205
+ if( $pagenow == 'plugins.php' ) {
206
+ if( woo_is_jigo_activated() || woo_is_wpsc_activated() ) {
207
+ $r_plugins = array(
208
+ 'woocommerce-exporter/exporter.php',
209
+ 'woocommerce-store-exporter/exporter.php'
210
+ );
211
+ $i_plugins = get_plugins();
212
+ foreach( $r_plugins as $path ) {
213
+ if( isset( $i_plugins[$path] ) ) {
214
+ add_action( 'after_plugin_row_' . $path, 'woo_ce_plugin_page_notice', 10, 3 );
215
+ break;
216
+ }
217
+ }
218
+ }
219
+ }
220
+
221
+ }
222
+
223
+ // HTML active class for the currently selected tab on the Store Exporter screen
224
+ function woo_ce_admin_active_tab( $tab_name = null, $tab = null ) {
225
+
226
+ if( isset( $_GET['tab'] ) && !$tab )
227
+ $tab = $_GET['tab'];
228
+ else if( !isset( $_GET['tab'] ) && woo_ce_get_option( 'skip_overview', false ) )
229
+ $tab = 'export';
230
+ else
231
+ $tab = 'overview';
232
+
233
+ $output = '';
234
+ if( isset( $tab_name ) && $tab_name ) {
235
+ if( $tab_name == $tab )
236
+ $output = ' nav-tab-active';
237
+ }
238
+ echo $output;
239
+
240
+ }
241
+
242
+ // HTML template for each tab on the Store Exporter screen
243
+ function woo_ce_tab_template( $tab = '' ) {
244
+
245
+ if( !$tab )
246
+ $tab = 'overview';
247
+
248
+ // Store Exporter Deluxe
249
+ $woo_cd_url = 'http://www.visser.com.au/woocommerce/plugins/exporter-deluxe/';
250
+ $woo_cd_link = sprintf( '<a href="%s" target="_blank">' . __( 'Store Exporter Deluxe', 'woocommerce-exporter' ) . '</a>', $woo_cd_url );
251
+
252
+ $troubleshooting_url = 'http://www.visser.com.au/documentation/store-exporter-deluxe/';
253
+
254
+ switch( $tab ) {
255
+
256
+ case 'overview':
257
+ $skip_overview = woo_ce_get_option( 'skip_overview', false );
258
+ break;
259
+
260
+ case 'export':
261
+ $export_type = sanitize_text_field( ( isset( $_POST['dataset'] ) ? $_POST['dataset'] : woo_ce_get_option( 'last_export', 'product' ) ) );
262
+ $types = array_keys( woo_ce_get_export_types() );
263
+ // Check if the default export type exists
264
+ if( !in_array( $export_type, $types ) )
265
+ $export_type = 'product';
266
+
267
+ $products = woo_ce_return_count( 'product' );
268
+ $categories = woo_ce_return_count( 'category' );
269
+ $tags = woo_ce_return_count( 'tag' );
270
+ $brands = '999';
271
+ $orders = '999';
272
+ $customers = '999';
273
+ $users = woo_ce_return_count( 'user' );
274
+ $coupons = '999';
275
+ $attributes = '999';
276
+ $subscriptions = '999';
277
+ $product_vendors = '999';
278
+ $commissions = '999';
279
+ $shipping_classes = '999';
280
+
281
+ add_action( 'woo_ce_export_options', 'woo_ce_export_options_export_format' );
282
+ if( $product_fields = woo_ce_get_product_fields() ) {
283
+ foreach( $product_fields as $key => $product_field )
284
+ $product_fields[$key]['disabled'] = ( isset( $product_field['disabled'] ) ? $product_field['disabled'] : 0 );
285
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_category' );
286
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_tag' );
287
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_brand' );
288
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_vendor' );
289
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_status' );
290
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_type' );
291
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_stock_status' );
292
+ add_action( 'woo_ce_export_product_options_after_table', 'woo_ce_product_sorting' );
293
+ add_action( 'woo_ce_export_options', 'woo_ce_products_upsells_formatting' );
294
+ add_action( 'woo_ce_export_options', 'woo_ce_products_crosssells_formatting' );
295
+ add_action( 'woo_ce_export_options', 'woo_ce_export_options_gallery_format' );
296
+ add_action( 'woo_ce_export_after_form', 'woo_ce_products_custom_fields' );
297
+ }
298
+ if( $category_fields = woo_ce_get_category_fields() ) {
299
+ foreach( $category_fields as $key => $category_field )
300
+ $category_fields[$key]['disabled'] = ( isset( $category_field['disabled'] ) ? $category_field['disabled'] : 0 );
301
+ add_action( 'woo_ce_export_category_options_after_table', 'woo_ce_category_sorting' );
302
+ }
303
+ if( $tag_fields = woo_ce_get_tag_fields() ) {
304
+ foreach( $tag_fields as $key => $tag_field )
305
+ $tag_fields[$key]['disabled'] = ( isset( $tag_field['disabled'] ) ? $tag_field['disabled'] : 0 );
306
+ add_action( 'woo_ce_export_tag_options_after_table', 'woo_ce_tag_sorting' );
307
+ }
308
+ if( $brand_fields = woo_ce_get_brand_fields() ) {
309
+ foreach( $brand_fields as $key => $brand_field )
310
+ $brand_fields[$key]['disabled'] = ( isset( $brand_field['disabled'] ) ? $brand_field['disabled'] : 0 );
311
+ add_action( 'woo_ce_export_brand_options_before_table', 'woo_ce_brand_sorting' );
312
+ }
313
+ if( $order_fields = woo_ce_get_order_fields() ) {
314
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_date' );
315
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_status' );
316
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_customer' );
317
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_billing_country' );
318
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_shipping_country' );
319
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_user_role' );
320
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_coupon' );
321
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product' );
322
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product_category' );
323
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product_tag' );
324
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product_brand' );
325
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_order_id' );
326
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_payment_gateway' );
327
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_shipping_method' );
328
+ add_action( 'woo_ce_export_order_options_after_table', 'woo_ce_order_sorting' );
329
+ add_action( 'woo_ce_export_options', 'woo_ce_orders_items_formatting' );
330
+ add_action( 'woo_ce_export_options', 'woo_ce_orders_max_order_items' );
331
+ add_action( 'woo_ce_export_options', 'woo_ce_orders_items_types' );
332
+ add_action( 'woo_ce_export_after_form', 'woo_ce_orders_custom_fields' );
333
+ }
334
+ if( $customer_fields = woo_ce_get_customer_fields() ) {
335
+ add_action( 'woo_ce_export_customer_options_before_table', 'woo_ce_customers_filter_by_status' );
336
+ add_action( 'woo_ce_export_customer_options_before_table', 'woo_ce_customers_filter_by_user_role' );
337
+ add_action( 'woo_ce_export_after_form', 'woo_ce_customers_custom_fields' );
338
+ }
339
+ if( $user_fields = woo_ce_get_user_fields() ) {
340
+ foreach( $user_fields as $key => $user_field )
341
+ $user_fields[$key]['disabled'] = ( isset( $user_field['disabled'] ) ? $user_field['disabled'] : 0 );
342
+ add_action( 'woo_ce_export_user_options_after_table', 'woo_ce_user_sorting' );
343
+ add_action( 'woo_ce_export_after_form', 'woo_ce_users_custom_fields' );
344
+ }
345
+ if( $coupon_fields = woo_ce_get_coupon_fields() ) {
346
+ add_action( 'woo_ce_export_coupon_options_before_table', 'woo_ce_coupon_sorting' );
347
+ }
348
+ if( $subscription_fields = woo_ce_get_subscription_fields() ) {
349
+ add_action( 'woo_ce_export_subscription_options_before_table', 'woo_ce_subscriptions_filter_by_subscription_status' );
350
+ add_action( 'woo_ce_export_subscription_options_before_table', 'woo_ce_subscriptions_filter_by_subscription_product' );
351
+ }
352
+ $product_vendor_fields = woo_ce_get_product_vendor_fields();
353
+ if( $commission_fields = woo_ce_get_commission_fields() ) {
354
+ add_action( 'woo_ce_export_commission_options_before_table', 'woo_ce_commissions_filter_by_date' );
355
+ add_action( 'woo_ce_export_commission_options_before_table', 'woo_ce_commissions_filter_by_product_vendor' );
356
+ add_action( 'woo_ce_export_commission_options_before_table', 'woo_ce_commissions_filter_by_commission_status' );
357
+ add_action( 'woo_ce_export_commission_options_before_table', 'woo_ce_commission_sorting' );
358
+ }
359
+ if( $shipping_class_fields = woo_ce_get_shipping_class_fields() ) {
360
+ add_action( 'woo_ce_export_shipping_class_options_after_table', 'woo_ce_shipping_class_sorting' );
361
+ }
362
+ $attribute_fields = false;
363
+
364
+ // Export modules
365
+ $modules = woo_ce_modules_list();
366
+
367
+ // Export options
368
+ $limit_volume = woo_ce_get_option( 'limit_volume' );
369
+ $offset = woo_ce_get_option( 'offset' );
370
+ break;
371
+
372
+ case 'fields':
373
+ $export_type = ( isset( $_GET['type'] ) ? sanitize_text_field( $_GET['type'] ) : '' );
374
+ $types = array_keys( woo_ce_get_export_types() );
375
+ $fields = array();
376
+ if( in_array( $export_type, $types ) ) {
377
+ if( has_filter( 'woo_ce_' . $export_type . '_fields', 'woo_ce_override_' . $export_type . '_field_labels' ) )
378
+ remove_filter( 'woo_ce_' . $export_type . '_fields', 'woo_ce_override_' . $export_type . '_field_labels', 11 );
379
+ if( function_exists( sprintf( 'woo_ce_get_%s_fields', $export_type ) ) )
380
+ $fields = call_user_func( 'woo_ce_get_' . $export_type . '_fields' );
381
+ $labels = woo_ce_get_option( $export_type . '_labels', array() );
382
+ }
383
+ break;
384
+
385
+ case 'archive':
386
+ if( isset( $_GET['deleted'] ) ) {
387
+ $message = __( 'Archived export has been deleted.', 'woocommerce-exporter' );
388
+ woo_ce_admin_notice( $message );
389
+ }
390
+ if( $files = woo_ce_get_archive_files() ) {
391
+ foreach( $files as $key => $file )
392
+ $files[$key] = woo_ce_get_archive_file( $file );
393
+ }
394
+ break;
395
+
396
+ case 'settings':
397
+ $export_filename = woo_ce_get_option( 'export_filename', '' );
398
+ // Default export filename
399
+ if( empty( $export_filename ) )
400
+ $export_filename = 'woo-export_%dataset%-%date%.csv';
401
+ $delete_file = woo_ce_get_option( 'delete_file', 0 );
402
+ $timeout = woo_ce_get_option( 'timeout', 0 );
403
+ $encoding = woo_ce_get_option( 'encoding', 'UTF-8' );
404
+ $bom = woo_ce_get_option( 'bom', 1 );
405
+ $delimiter = woo_ce_get_option( 'delimiter', ',' );
406
+ $category_separator = woo_ce_get_option( 'category_separator', '|' );
407
+ $escape_formatting = woo_ce_get_option( 'escape_formatting', 'all' );
408
+ $date_format = woo_ce_get_option( 'date_format', 'd/m/Y' );
409
+ if( $date_format == 1 || $date_format == '' )
410
+ $date_format = 'd/m/Y';
411
+ $file_encodings = ( function_exists( 'mb_list_encodings' ) ? mb_list_encodings() : false );
412
+ add_action( 'woo_ce_export_settings_top', 'woo_ce_export_settings_quicklinks' );
413
+ add_action( 'woo_ce_export_settings_after', 'woo_ce_export_settings_csv' );
414
+ add_action( 'woo_ce_export_settings_after', 'woo_ce_export_settings_cron' );
415
+ break;
416
+
417
+ case 'tools':
418
+ // Product Importer Deluxe
419
+ $woo_pd_url = 'http://www.visser.com.au/woocommerce/plugins/product-importer-deluxe/';
420
+ $woo_pd_target = ' target="_blank"';
421
+ if( function_exists( 'woo_pd_init' ) ) {
422
+ $woo_pd_url = esc_url( add_query_arg( array( 'page' => 'woo_pd', 'tab' => null ) ) );
423
+ $woo_pd_target = false;
424
+ }
425
+
426
+ // Store Toolkit
427
+ $woo_st_url = 'http://www.visser.com.au/woocommerce/plugins/store-toolkit/';
428
+ $woo_st_target = ' target="_blank"';
429
+ if( function_exists( 'woo_st_admin_init' ) ) {
430
+ $woo_st_url = esc_url( add_query_arg( array( 'page' => 'woo_st', 'tab' => null ) ) );
431
+ $woo_st_target = false;
432
+ }
433
+ break;
434
+
435
+ }
436
+ if( $tab ) {
437
+ if( file_exists( WOO_CE_PATH . 'templates/admin/tabs-' . $tab . '.php' ) ) {
438
+ include_once( WOO_CE_PATH . 'templates/admin/tabs-' . $tab . '.php' );
439
+ } else {
440
+ $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/...' );
441
+ woo_ce_admin_notice_html( $message, 'error' );
442
+ ob_start(); ?>
443
+ <p><?php _e( 'You can see this error for one of a few common reasons', 'woocommerce-exporter' ); ?>:</p>
444
+ <ul class="ul-disc">
445
+ <li><?php _e( 'WordPress was unable to create this file when the Plugin was installed or updated', 'woocommerce-exporter' ); ?></li>
446
+ <li><?php _e( 'The Plugin files have been recently changed and there has been a file conflict', 'woocommerce-exporter' ); ?></li>
447
+ <li><?php _e( 'The Plugin file has been locked and cannot be opened by WordPress', 'woocommerce-exporter' ); ?></li>
448
+ </ul>
449
+ <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>
450
+ <?php
451
+ ob_end_flush();
452
+ }
453
+ }
454
+
455
+ }
456
+
457
+ // List of WordPress Plugins that Store Exporter Deluxe integrates with
458
+ function woo_ce_modules_list( $modules = array() ) {
459
+
460
+ $modules[] = array(
461
+ 'name' => 'aioseop',
462
+ 'title' => __( 'All in One SEO Pack', 'woocommerce-exporter' ),
463
+ 'description' => __( 'Optimize your WooCommerce Products for Search Engines. Requires Store Toolkit for All in One SEO Pack integration.', 'woocommerce-exporter' ),
464
+ 'url' => 'http://wordpress.org/extend/plugins/all-in-one-seo-pack/',
465
+ 'slug' => 'all-in-one-seo-pack',
466
+ 'function' => 'aioseop_activate'
467
+ );
468
+ $modules[] = array(
469
+ 'name' => 'store_toolkit',
470
+ 'title' => __( 'Store Toolkit', 'woocommerce-exporter' ),
471
+ 'description' => __( 'Store Toolkit includes a growing set of commonly-used WooCommerce administration tools aimed at web developers and store maintainers.', 'woocommerce-exporter' ),
472
+ 'url' => 'http://wordpress.org/extend/plugins/woocommerce-store-toolkit/',
473
+ 'slug' => 'woocommerce-store-toolkit',
474
+ 'function' => 'woo_st_admin_init'
475
+ );
476
+ $modules[] = array(
477
+ 'name' => 'ultimate_seo',
478
+ 'title' => __( 'SEO Ultimate', 'woocommerce-exporter' ),
479
+ 'description' => __( 'This all-in-one SEO plugin gives you control over Product details.', 'woocommerce-exporter' ),
480
+ 'url' => 'http://wordpress.org/extend/plugins/seo-ultimate/',
481
+ 'slug' => 'seo-ultimate',
482
+ 'function' => 'su_wp_incompat_notice'
483
+ );
484
+ $modules[] = array(
485
+ 'name' => 'gpf',
486
+ 'title' => __( 'Advanced Google Product Feed', 'woocommerce-exporter' ),
487
+ 'description' => __( 'Easily configure data to be added to your Google Merchant Centre feed.', 'woocommerce-exporter' ),
488
+ 'url' => 'http://www.leewillis.co.uk/wordpress-plugins/',
489
+ 'function' => 'woocommerce_gpf_install'
490
+ );
491
+ $modules[] = array(
492
+ 'name' => 'wpseo',
493
+ 'title' => __( 'WordPress SEO by Yoast', 'woocommerce-exporter' ),
494
+ 'description' => __( 'The first true all-in-one SEO solution for WordPress.', 'woocommerce-exporter' ),
495
+ 'url' => 'http://yoast.com/wordpress/seo/#utm_source=wpadmin&utm_medium=plugin&utm_campaign=wpseoplugin',
496
+ 'slug' => 'wordpress-seo',
497
+ 'function' => 'wpseo_admin_init'
498
+ );
499
+ $modules[] = array(
500
+ 'name' => 'msrp',
501
+ 'title' => __( 'WooCommerce MSRP Pricing', 'woocommerce-exporter' ),
502
+ 'description' => __( 'Define and display MSRP prices (Manufacturer\'s suggested retail price) to your customers.', 'woocommerce-exporter' ),
503
+ 'url' => 'http://www.woothemes.com/products/msrp-pricing/',
504
+ 'function' => 'woocommerce_msrp_activate'
505
+ );
506
+ $modules[] = array(
507
+ 'name' => 'wc_brands',
508
+ 'title' => __( 'WooCommerce Brands Addon', 'woocommerce-exporter' ),
509
+ 'description' => __( 'Create, assign and list brands for products, and allow customers to filter by brand.', 'woocommerce-exporter' ),
510
+ 'url' => 'http://www.woothemes.com/products/brands/',
511
+ 'class' => 'WC_Brands'
512
+ );
513
+ $modules[] = array(
514
+ 'name' => 'wc_cog',
515
+ 'title' => __( 'Cost of Goods', 'woocommerce-exporter' ),
516
+ 'description' => __( 'Easily track total profit and cost of goods by adding a Cost of Good field to simple and variable products.', 'woocommerce-exporter' ),
517
+ 'url' => 'http://www.skyverge.com/product/woocommerce-cost-of-goods-tracking/',
518
+ 'class' => 'WC_COG'
519
+ );
520
+ $modules[] = array(
521
+ 'name' => 'per_product_shipping',
522
+ 'title' => __( 'Per-Product Shipping', 'woocommerce-exporter' ),
523
+ 'description' => __( 'Define separate shipping costs per product which are combined at checkout to provide a total shipping cost.', 'woocommerce-exporter' ),
524
+ 'url' => 'http://www.woothemes.com/products/per-product-shipping/',
525
+ 'function' => 'woocommerce_per_product_shipping_init'
526
+ );
527
+ $modules[] = array(
528
+ 'name' => 'vendors',
529
+ 'title' => __( 'Product Vendors', 'woocommerce-exporter' ),
530
+ 'description' => __( 'Turn your store into a multi-vendor marketplace (such as Etsy or Creative Market).', 'woocommerce-exporter' ),
531
+ 'url' => 'http://www.woothemes.com/products/product-vendors/',
532
+ 'class' => 'WooCommerce_Product_Vendors'
533
+ );
534
+ $modules[] = array(
535
+ 'name' => 'wc_vendors',
536
+ 'title' => __( 'WC Vendors', 'woocommerce-exporter' ),
537
+ 'description' => __( 'Allow vendors to sell their own products and receive a commission for each sale.', 'woocommerce-exporter' ),
538
+ 'url' => 'http://wcvendors.com',
539
+ 'class' => 'WC_Vendors'
540
+ );
541
+ $modules[] = array(
542
+ 'name' => 'acf',
543
+ 'title' => __( 'Advanced Custom Fields', 'woocommerce-exporter' ),
544
+ 'description' => __( 'Powerful fields for WordPress developers.', 'woocommerce-exporter' ),
545
+ 'url' => 'http://www.advancedcustomfields.com',
546
+ 'class' => 'acf'
547
+ );
548
+ $modules[] = array(
549
+ 'name' => 'product_addons',
550
+ 'title' => __( 'Product Add-ons', 'woocommerce-exporter' ),
551
+ 'description' => __( 'Allow your customers to customise your products by adding input boxes, dropdowns or a field set of checkboxes.', 'woocommerce-exporter' ),
552
+ 'url' => 'http://www.woothemes.com/products/product-add-ons/',
553
+ 'class' => 'Product_Addon_Admin'
554
+ );
555
+ $modules[] = array(
556
+ 'name' => 'seq',
557
+ 'title' => __( 'WooCommerce Sequential Order Numbers', 'woocommerce-exporter' ),
558
+ 'description' => __( 'This plugin extends the WooCommerce e-commerce plugin by setting sequential order numbers for new orders.', 'woocommerce-exporter' ),
559
+ 'url' => 'https://wordpress.org/plugins/woocommerce-sequential-order-numbers/',
560
+ 'slug' => 'woocommerce-sequential-order-numbers',
561
+ 'class' => 'WC_Seq_Order_Number'
562
+ );
563
+ $modules[] = array(
564
+ 'name' => 'seq_pro',
565
+ 'title' => __( 'WooCommerce Sequential Order Numbers Pro', 'woocommerce-exporter' ),
566
+ 'description' => __( 'Tame your WooCommerce Order Numbers.', 'woocommerce-exporter' ),
567
+ 'url' => 'http://www.woothemes.com/products/sequential-order-numbers-pro/',
568
+ 'class' => 'WC_Seq_Order_Number_Pro'
569
+ );
570
+ $modules[] = array(
571
+ 'name' => 'print_invoice_delivery_note',
572
+ 'title' => __( 'WooCommerce Print Invoice & Delivery Note', 'woocommerce-exporter' ),
573
+ 'description' => __( 'Print invoices and delivery notes for WooCommerce orders.', 'woocommerce-exporter' ),
574
+ 'url' => 'http://wordpress.org/plugins/woocommerce-delivery-notes/',
575
+ 'slug' => 'woocommerce-delivery-notes',
576
+ 'class' => 'WooCommerce_Delivery_Notes'
577
+ );
578
+ $modules[] = array(
579
+ 'name' => 'pdf_invoices_packing_slips',
580
+ 'title' => __( 'WooCommerce PDF Invoices & Packing Slips', 'woocommerce-exporter' ),
581
+ 'description' => __( 'Create, print & automatically email PDF invoices & packing slips for WooCommerce orders.', 'woocommerce-exporter' ),
582
+ 'url' => 'https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/',
583
+ 'slug' => 'woocommerce-pdf-invoices-packing-slips',
584
+ 'class' => 'WooCommerce_PDF_Invoices'
585
+ );
586
+ $modules[] = array(
587
+ 'name' => 'checkout_manager',
588
+ 'title' => __( 'WooCommerce Checkout Manager', 'woocommerce-exporter' ),
589
+ 'description' => __( 'Manages WooCommerce Checkout.', 'woocommerce-exporter' ),
590
+ 'url' => 'http://wordpress.org/plugins/woocommerce-checkout-manager/',
591
+ 'slug' => 'woocommerce-checkout-manager',
592
+ 'function' => 'wccs_install'
593
+ );
594
+ $modules[] = array(
595
+ 'name' => 'checkout_manager_pro',
596
+ 'title' => __( 'WooCommerce Checkout Manager Pro', 'woocommerce-exporter' ),
597
+ 'description' => __( 'Manages the WooCommerce Checkout page and WooCommerce Checkout processes.', 'woocommerce-exporter' ),
598
+ 'url' => 'http://www.trottyzone.com/product/woocommerce-checkout-manager-pro',
599
+ 'function' => array( 'wccs_install', 'wccs_install_pro' )
600
+ );
601
+ $modules[] = array(
602
+ 'name' => 'pgsk',
603
+ 'title' => __( 'Poor Guys Swiss Knife', 'woocommerce-exporter' ),
604
+ 'description' => __( 'A Swiss Knife for WooCommerce.', 'woocommerce-exporter' ),
605
+ 'url' => 'http://wordpress.org/plugins/woocommerce-poor-guys-swiss-knife/',
606
+ 'slug' => 'woocommerce-poor-guys-swiss-knife',
607
+ 'function' => 'wcpgsk_init'
608
+ );
609
+ $modules[] = array(
610
+ 'name' => 'checkout_field_editor',
611
+ 'title' => __( 'Checkout Field Editor', 'woocommerce-exporter' ),
612
+ 'description' => __( 'Add, edit and remove fields shown on your WooCommerce checkout page.', 'woocommerce-exporter' ),
613
+ 'url' => 'http://www.woothemes.com/products/woocommerce-checkout-field-editor/',
614
+ 'function' => 'woocommerce_init_checkout_field_editor'
615
+ );
616
+ $modules[] = array(
617
+ 'name' => 'checkout_field_manager',
618
+ 'title' => __( 'Checkout Field Manager', 'woocommerce-exporter' ),
619
+ 'description' => __( 'Quickly and effortlessly add, remove and re-orders fields in the checkout process.', 'woocommerce-exporter' ),
620
+ 'url' => 'http://61extensions.com/shop/woocommerce-checkout-field-manager/',
621
+ 'function' => 'sod_woocommerce_checkout_manager_settings'
622
+ );
623
+ $modules[] = array(
624
+ 'name' => 'checkout_addons',
625
+ 'title' => __( 'WooCommerce Checkout Add-Ons', 'woocommerce-exporter' ),
626
+ 'description' => __( 'Add fields at checkout for add-on products and services while optionally setting a cost for each add-on.', 'woocommerce-exporter' ),
627
+ 'url' => 'http://www.skyverge.com/product/woocommerce-checkout-add-ons/',
628
+ 'function' => 'init_woocommerce_checkout_add_ons'
629
+ );
630
+ $modules[] = array(
631
+ 'name' => 'local_pickup_plus',
632
+ 'title' => __( 'Local Pickup Plus', 'woocommerce-exporter' ),
633
+ 'description' => __( 'Let customers pick up products from specific locations.', 'woocommerce-exporter' ),
634
+ 'url' => 'http://www.woothemes.com/products/local-pickup-plus/',
635
+ 'class' => 'WC_Local_Pickup_Plus'
636
+ );
637
+ $modules[] = array(
638
+ 'name' => 'gravity_forms',
639
+ 'title' => __( 'Gravity Forms', 'woocommerce-exporter' ),
640
+ 'description' => __( 'Gravity Forms is hands down the best contact form plugin for WordPress powered websites.', 'woocommerce-exporter' ),
641
+ 'url' => 'http://woothemes.com/woocommerce',
642
+ 'class' => 'RGForms'
643
+ );
644
+ $modules[] = array(
645
+ 'name' => 'currency_switcher',
646
+ 'title' => __( 'WooCommerce Currency Switcher', 'woocommerce-exporter' ),
647
+ 'description' => __( 'Currency Switcher for WooCommerce allows your shop to display prices and accept payments in multiple currencies.', 'woocommerce-exporter' ),
648
+ 'url' => 'http://aelia.co/shop/currency-switcher-woocommerce/',
649
+ 'class' => 'WC_Aelia_CurrencySwitcher'
650
+ );
651
+ $modules[] = array(
652
+ 'name' => 'subscriptions',
653
+ 'title' => __( 'WooCommerce Subscriptions', 'woocommerce-exporter' ),
654
+ 'description' => __( 'WC Subscriptions makes it easy to create and manage products with recurring payments.', 'woocommerce-exporter' ),
655
+ 'url' => 'http://www.woothemes.com/products/woocommerce-subscriptions/',
656
+ 'class' => 'WC_Subscriptions_Manager'
657
+ );
658
+ $modules[] = array(
659
+ 'name' => 'extra_product_options',
660
+ 'title' => __( 'Extra Product Options', 'woocommerce-exporter' ),
661
+ 'description' => __( 'Create extra price fields globally or per-Product', 'woocommerce-exporter' ),
662
+ 'url' => 'http://codecanyon.net/item/woocommerce-extra-product-options/7908619',
663
+ 'class' => 'TM_Extra_Product_Options'
664
+ );
665
+ $modules[] = array(
666
+ 'name' => 'woocommerce_jetpack',
667
+ 'title' => __( 'WooCommerce Jetpack', 'woocommerce-exporter' ),
668
+ 'description' => __( 'Supercharge your WooCommerce site with these awesome powerful features.', 'woocommerce-exporter' ),
669
+ 'url' => 'https://wordpress.org/plugins/woocommerce-jetpack/',
670
+ 'slug' => 'woocommerce-jetpack',
671
+ 'class' => 'WC_Jetpack'
672
+ );
673
+ $modules[] = array(
674
+ 'name' => 'woocommerce_jetpack_plus',
675
+ 'title' => __( 'WooCommerce Jetpack Plus', 'woocommerce-exporter' ),
676
+ 'description' => __( 'Unlock all WooCommerce Jetpack features and supercharge your WordPress WooCommerce site even more.', 'woocommerce-exporter' ),
677
+ 'url' => 'http://woojetpack.com/shop/wordpress-woocommerce-jetpack-plus/',
678
+ 'class' => 'WC_Jetpack_Plus'
679
+ );
680
+ $modules[] = array(
681
+ 'name' => 'woocommerce_brands',
682
+ 'title' => __( 'WooCommerce Brands', 'woocommerce-exporter' ),
683
+ 'description' => __( 'Woocommerce Brands Plugin. After Install and active this plugin you\'ll have some shortcode and some widget for display your brands in fornt-end website.', 'woocommerce-exporter' ),
684
+ 'url' => 'http://proword.net/Woocommerce_Brands/',
685
+ 'class' => 'woo_brands'
686
+ );
687
+ $modules[] = array(
688
+ 'name' => 'woocommerce_bookings',
689
+ 'title' => __( 'WooCommerce Bookings', 'woocommerce-exporter' ),
690
+ 'description' => __( 'Setup bookable products such as for reservations, services and hires.', 'woocommerce-exporter' ),
691
+ 'url' => 'http://www.woothemes.com/products/woocommerce-bookings/',
692
+ 'class' => 'WC_Bookings'
693
+ );
694
+ $modules[] = array(
695
+ 'name' => 'eu_vat',
696
+ 'title' => __( 'WooCommerce EU VAT Number', 'woocommerce-exporter' ),
697
+ 'description' => __( 'The EU VAT Number extension lets you collect and validate EU VAT numbers during checkout to identify B2B transactions verses B2C.', 'woocommerce-exporter' ),
698
+ 'url' => 'http://woothemes.com/',
699
+ 'function' => '__wc_eu_vat_number_init'
700
+ );
701
+ $modules[] = array(
702
+ 'name' => 'hear_about_us',
703
+ 'title' => __( 'WooCommerce Hear About Us', 'woocommerce-exporter' ),
704
+ 'description' => __( 'Ask where your new customers come from at Checkout.', 'woocommerce-exporter' ),
705
+ 'url' => 'https://wordpress.org/plugins/woocommerce-hear-about-us/',
706
+ 'slug' => 'woocommerce-hear-about-us', // Define this if the Plugin is hosted on the WordPress repo
707
+ 'class' => 'WooCommerce_HearAboutUs'
708
+ );
709
+ $modules[] = array(
710
+ 'name' => 'wholesale_pricing',
711
+ 'title' => __( 'WooCommerce Wholesale Pricing', 'woocommerce-exporter' ),
712
+ 'description' => __( 'Allows you to set wholesale prices for products and variations.', 'woocommerce-exporter' ),
713
+ 'url' => 'http://ignitewoo.com/woocommerce-extensions-plugins-themes/woocommerce-wholesale-pricing/',
714
+ 'class' => 'woocommerce_wholesale_pricing'
715
+ );
716
+ $modules[] = array(
717
+ 'name' => 'woocommerce_barcodes',
718
+ 'title' => __( 'Barcodes for WooCommerce', 'woocommerce-exporter' ),
719
+ 'description' => __( 'Allows you to add GTIN (former EAN) codes natively to your products.', 'woocommerce-exporter' ),
720
+ 'url' => 'http://www.wolkenkraft.com/produkte/barcodes-fuer-woocommerce/',
721
+ 'function' => 'wpps_requirements_met'
722
+ );
723
+ $modules[] = array(
724
+ 'name' => 'woocommerce_smart_coupons',
725
+ 'title' => __( 'WooCommerce Smart Coupons', 'woocommerce-exporter' ),
726
+ 'description' => __( 'WooCommerce Smart Coupons lets customers buy gift certificates, store credits or coupons easily.', 'woocommerce-exporter' ),
727
+ 'url' => 'http://www.woothemes.com/products/smart-coupons/',
728
+ 'class' => 'WC_Smart_Coupons'
729
+ );
730
+ $modules[] = array(
731
+ 'name' => 'woocommerce_preorders',
732
+ 'title' => __( 'WooCommerce Pre-Orders', 'woocommerce-exporter' ),
733
+ 'description' => __( 'Sell pre-orders for products in your WooCommerce store.', 'woocommerce-exporter' ),
734
+ 'url' => 'http://www.woothemes.com/products/woocommerce-pre-orders/',
735
+ 'class' => 'WC_Pre_Orders'
736
+ );
737
+ $modules[] = array(
738
+ 'name' => 'order_numbers_basic',
739
+ 'title' => __( 'WooCommerce Basic Ordernumbers', 'woocommerce-exporter' ),
740
+ 'description' => __( 'Lets the user freely configure the order numbers in WooCommerce.', 'woocommerce-exporter' ),
741
+ 'url' => 'http://open-tools.net/woocommerce/advanced-ordernumbers-for-woocommerce.html',
742
+ 'class' => 'OpenToolsOrdernumbersBasic'
743
+ );
744
+ $modules[] = array(
745
+ 'name' => 'admin_custom_order_fields',
746
+ 'title' => __( 'WooCommerce Admin Custom Order Fields', 'woocommerce-exporter' ),
747
+ 'description' => __( 'Easily add custom fields to your WooCommerce orders and display them in the Orders admin, the My Orders section and order emails.', 'woocommerce-exporter' ),
748
+ 'url' => 'http://www.woothemes.com/products/woocommerce-admin-custom-order-fields/',
749
+ 'function' => 'init_woocommerce_admin_custom_order_fields'
750
+ );
751
+ $modules[] = array(
752
+ 'name' => 'table_rate_shipping_plus',
753
+ 'title' => __( 'WooCommerce Table Rate Shipping Plus', 'woocommerce-exporter' ),
754
+ 'description' => __( 'Calculate shipping costs based on destination, weight and price.', 'woocommerce-exporter' ),
755
+ 'url' => 'http://mangohour.com/plugins/woocommerce-table-rate-shipping',
756
+ 'function' => 'mh_wc_table_rate_plus_init'
757
+ );
758
+ $modules[] = array(
759
+ 'name' => 'barcode_isbn',
760
+ 'title' => __( 'WooCommerce Barcode & ISBN', 'woocommerce-exporter' ),
761
+ 'description' => __( 'A plugin to add a barcode & ISBN to WooCommerce.', 'woocommerce-exporter' ),
762
+ 'url' => 'https://wordpress.org/plugins/woocommerce-barcode-isbn/',
763
+ 'slug' => 'woocommerce-barcode-isbn',
764
+ 'function' => 'woo_add_barcode'
765
+ );
766
+ $modules[] = array(
767
+ 'name' => 'video_product_tab',
768
+ 'title' => __( 'WooCommerce Video Product Tab', 'woocommerce-exporter' ),
769
+ 'description' => __( 'Extends WooCommerce to allow you to add a Video to the Product page.', 'woocommerce-exporter' ),
770
+ 'url' => 'https://wordpress.org/plugins/woocommerce-video-product-tab/',
771
+ 'slug' => 'woocommerce-video-product-tab',
772
+ 'class' => 'WooCommerce_Video_Product_Tab'
773
+ );
774
+ $modules[] = array(
775
+ 'name' => 'external_featured_image',
776
+ 'title' => __( 'Nelio External Featured Image', 'woocommerce-exporter' ),
777
+ 'description' => __( 'Use external images from anywhere as the featured image of your pages and posts.', 'woocommerce-exporter' ),
778
+ 'url' => 'https://wordpress.org/plugins/external-featured-image/',
779
+ 'slug' => 'external-featured-image', // Define this if the Plugin is hosted on the WordPress repo
780
+ 'function' => '_nelioefi_url'
781
+ );
782
+
783
+ /*
784
+ $modules[] = array(
785
+ 'name' => '',
786
+ 'title' => __( '', 'woocommerce-exporter' ),
787
+ 'description' => __( '', 'woocommerce-exporter' ),
788
+ 'url' => '',
789
+ 'slug' => '', // Define this if the Plugin is hosted on the WordPress repo
790
+ 'function' => ''
791
+ );
792
+ */
793
+
794
+ $modules = apply_filters( 'woo_ce_modules_addons', $modules );
795
+
796
+ if( !empty( $modules ) ) {
797
+ foreach( $modules as $key => $module ) {
798
+ $modules[$key]['status'] = 'inactive';
799
+ // Check if each module is activated
800
+ if( isset( $module['function'] ) ) {
801
+ if( is_array( $module['function'] ) ) {
802
+ $size = count( $module['function'] );
803
+ for( $i = 0; $i < $size; $i++ ) {
804
+ if( function_exists( $module['function'][$i] ) ) {
805
+ $modules[$key]['status'] = 'active';
806
+ break;
807
+ }
808
+ }
809
+ } else {
810
+ if( function_exists( $module['function'] ) )
811
+ $modules[$key]['status'] = 'active';
812
+ }
813
+ } else if( isset( $module['class'] ) ) {
814
+ if( is_array( $module['class'] ) ) {
815
+ $size = count( $module['class'] );
816
+ for( $i = 0; $i < $size; $i++ ) {
817
+ if( function_exists( $module['class'][$i] ) ) {
818
+ $modules[$key]['status'] = 'active';
819
+ break;
820
+ }
821
+ }
822
+ } else {
823
+ if( class_exists( $module['class'] ) )
824
+ $modules[$key]['status'] = 'active';
825
+ }
826
+ }
827
+ // Check if the Plugin has a slug and if current user can install Plugins
828
+ if( current_user_can( 'install_plugins' ) && isset( $module['slug'] ) )
829
+ $modules[$key]['url'] = admin_url( sprintf( 'plugin-install.php?tab=search&type=tag&s=%s', $module['slug'] ) );
830
+ }
831
+ }
832
+ return $modules;
833
+
834
+ }
835
+
836
+ function woo_ce_modules_status_class( $status = 'inactive' ) {
837
+
838
+ $output = '';
839
+ switch( $status ) {
840
+
841
+ case 'active':
842
+ $output = 'green';
843
+ break;
844
+
845
+ case 'inactive':
846
+ $output = 'yellow';
847
+ break;
848
+
849
+ }
850
+ echo $output;
851
+
852
+ }
853
+
854
+ function woo_ce_modules_status_label( $status = 'inactive' ) {
855
+
856
+ $output = '';
857
+ switch( $status ) {
858
+
859
+ case 'active':
860
+ $output = __( 'OK', 'woocommerce-exporter' );
861
+ break;
862
+
863
+ case 'inactive':
864
+ $output = __( 'Install', 'woocommerce-exporter' );
865
+ break;
866
+
867
+ }
868
+ echo $output;
869
+
870
+ }
871
+
872
+ // HTML template for header prompt on Store Exporter screen
873
+ function woo_ce_support_donate() {
874
+
875
+ $output = '';
876
+ $show = true;
877
+ if( function_exists( 'woo_vl_we_love_your_plugins' ) ) {
878
+ if( in_array( WOO_CE_DIRNAME, woo_vl_we_love_your_plugins() ) )
879
+ $show = false;
880
+ }
881
+ if( $show ) {
882
+ $donate_url = 'http://www.visser.com.au/donate/';
883
+ $rate_url = 'http://wordpress.org/support/view/plugin-reviews/' . WOO_CE_DIRNAME;
884
+ $output = '
885
+ <div id="support-donate_rate" class="support-donate_rate">
886
+ <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>
887
+ </div>
888
+ ';
889
+ }
890
+ echo $output;
891
+
892
+ }
893
+ ?>
includes/brand.php ADDED
@@ -0,0 +1,148 @@
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
+
34
+ // Returns a list of Brand export columns
35
+ function woo_ce_get_brand_fields( $format = 'full' ) {
36
+
37
+ $export_type = 'brand';
38
+
39
+ $fields = array();
40
+ $fields[] = array(
41
+ 'name' => 'term_id',
42
+ 'label' => __( 'Term ID', 'woocommerce-exporter' )
43
+ );
44
+ $fields[] = array(
45
+ 'name' => 'name',
46
+ 'label' => __( 'Brand Name', 'woocommerce-exporter' )
47
+ );
48
+ $fields[] = array(
49
+ 'name' => 'slug',
50
+ 'label' => __( 'Brand Slug', 'woocommerce-exporter' )
51
+ );
52
+ $fields[] = array(
53
+ 'name' => 'parent_id',
54
+ 'label' => __( 'Parent Term ID', 'woocommerce-exporter' )
55
+ );
56
+ $fields[] = array(
57
+ 'name' => 'description',
58
+ 'label' => __( 'Brand Description', 'woocommerce-exporter' )
59
+ );
60
+ $fields[] = array(
61
+ 'name' => 'image',
62
+ 'label' => __( 'Brand Image', 'woocommerce-exporter' )
63
+ );
64
+
65
+ /*
66
+ $fields[] = array(
67
+ 'name' => '',
68
+ 'label' => __( '', 'woocommerce-exporter' )
69
+ );
70
+ */
71
+
72
+ // Allow Plugin/Theme authors to add support for additional columns
73
+ $fields = apply_filters( 'woo_ce_' . $export_type . '_fields', $fields, $export_type );
74
+
75
+ switch( $format ) {
76
+
77
+ case 'summary':
78
+ $output = array();
79
+ $size = count( $fields );
80
+ for( $i = 0; $i < $size; $i++ ) {
81
+ if( isset( $fields[$i] ) )
82
+ $output[$fields[$i]['name']] = 'on';
83
+ }
84
+ return $output;
85
+ break;
86
+
87
+ case 'full':
88
+ default:
89
+ $sorting = woo_ce_get_option( $export_type . '_sorting', array() );
90
+ $size = count( $fields );
91
+ for( $i = 0; $i < $size; $i++ ) {
92
+ $fields[$i]['reset'] = $i;
93
+ $fields[$i]['order'] = ( isset( $sorting[$fields[$i]['name']] ) ? $sorting[$fields[$i]['name']] : $i );
94
+ }
95
+ // Check if we are using PHP 5.3 and above
96
+ if( version_compare( phpversion(), '5.3' ) >= 0 )
97
+ usort( $fields, woo_ce_sort_fields( 'order' ) );
98
+ return $fields;
99
+ break;
100
+
101
+ }
102
+
103
+ }
104
+
105
+ function woo_ce_override_brand_field_labels( $fields = array() ) {
106
+
107
+ $labels = woo_ce_get_option( 'brand_labels', array() );
108
+ if( !empty( $labels ) ) {
109
+ foreach( $fields as $key => $field ) {
110
+ if( isset( $labels[$field['name']] ) )
111
+ $fields[$key]['label'] = $labels[$field['name']];
112
+ }
113
+ }
114
+ return $fields;
115
+
116
+ }
117
+ add_filter( 'woo_ce_brand_fields', 'woo_ce_override_brand_field_labels', 11 );
118
+
119
+ // Returns a list of WooCommerce Product Brands to export process
120
+ function woo_ce_get_product_brands( $args = array() ) {
121
+
122
+ $term_taxonomy = apply_filters( 'woo_ce_brand_term_taxonomy', 'product_brand' );
123
+ $defaults = array(
124
+ 'orderby' => 'name',
125
+ 'order' => 'ASC',
126
+ 'hide_empty' => 0
127
+ );
128
+ $args = wp_parse_args( $args, $defaults );
129
+ $brands = get_terms( $term_taxonomy, $args );
130
+ if( !empty( $brands ) && is_wp_error( $brands ) == false ) {
131
+ foreach( $brands as $key => $brand ) {
132
+ $brands[$key]->description = woo_ce_format_description_excerpt( $brand->description );
133
+ $brands[$key]->parent_name = '';
134
+ if( $brands[$key]->parent_id = $brand->parent ) {
135
+ if( $parent_brand = get_term( $brands[$key]->parent_id, $term_taxonomy ) ) {
136
+ $brands[$key]->parent_name = $parent_brand->name;
137
+ }
138
+ unset( $parent_brand );
139
+ } else {
140
+ $brands[$key]->parent_id = '';
141
+ }
142
+ $brands[$key]->image = ( function_exists( 'get_brand_thumbnail_url' ) ? get_brand_thumbnail_url( $brand->term_id ) : false );
143
+ }
144
+ return $brands;
145
+ }
146
+
147
+ }
148
+ ?>
includes/category.php ADDED
@@ -0,0 +1,202 @@
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
+
34
+ // Returns a list of Category export columns
35
+ function woo_ce_get_category_fields( $format = 'full' ) {
36
+
37
+ $export_type = 'category';
38
+
39
+ $fields = array();
40
+ $fields[] = array(
41
+ 'name' => 'term_id',
42
+ 'label' => __( 'Term ID', 'woocommerce-exporter' )
43
+ );
44
+ $fields[] = array(
45
+ 'name' => 'name',
46
+ 'label' => __( 'Category Name', 'woocommerce-exporter' )
47
+ );
48
+ $fields[] = array(
49
+ 'name' => 'slug',
50
+ 'label' => __( 'Category Slug', 'woocommerce-exporter' )
51
+ );
52
+ $fields[] = array(
53
+ 'name' => 'parent_id',
54
+ 'label' => __( 'Parent Term ID', 'woocommerce-exporter' )
55
+ );
56
+ $fields[] = array(
57
+ 'name' => 'description',
58
+ 'label' => __( 'Category Description', 'woocommerce-exporter' )
59
+ );
60
+ $fields[] = array(
61
+ 'name' => 'display_type',
62
+ 'label' => __( 'Display Type', 'woocommerce-exporter' )
63
+ );
64
+ $fields[] = array(
65
+ 'name' => 'image',
66
+ 'label' => __( 'Category Image', 'woocommerce-exporter' )
67
+ );
68
+
69
+ /*
70
+ $fields[] = array(
71
+ 'name' => '',
72
+ 'label' => __( '', 'woocommerce-exporter' )
73
+ );
74
+ */
75
+
76
+ // Allow Plugin/Theme authors to add support for additional columns
77
+ $fields = apply_filters( 'woo_ce_' . $export_type . '_fields', $fields, $export_type );
78
+
79
+ if( $remember = woo_ce_get_option( $export_type . '_fields', array() ) ) {
80
+ $remember = maybe_unserialize( $remember );
81
+ $size = count( $fields );
82
+ for( $i = 0; $i < $size; $i++ ) {
83
+ $fields[$i]['disabled'] = ( isset( $fields[$i]['disabled'] ) ? $fields[$i]['disabled'] : 0 );
84
+ $fields[$i]['default'] = 1;
85
+ if( !array_key_exists( $fields[$i]['name'], $remember ) )
86
+ $fields[$i]['default'] = 0;
87
+ }
88
+ }
89
+
90
+ switch( $format ) {
91
+
92
+ case 'summary':
93
+ $output = array();
94
+ $size = count( $fields );
95
+ for( $i = 0; $i < $size; $i++ ) {
96
+ if( isset( $fields[$i] ) )
97
+ $output[$fields[$i]['name']] = 'on';
98
+ }
99
+ return $output;
100
+ break;
101
+
102
+ case 'full':
103
+ default:
104
+ $sorting = woo_ce_get_option( $export_type . '_sorting', array() );
105
+ $size = count( $fields );
106
+ for( $i = 0; $i < $size; $i++ ) {
107
+ $fields[$i]['reset'] = $i;
108
+ $fields[$i]['order'] = ( isset( $sorting[$fields[$i]['name']] ) ? $sorting[$fields[$i]['name']] : $i );
109
+ }
110
+ // Check if we are using PHP 5.3 and above
111
+ if( version_compare( phpversion(), '5.3' ) >= 0 )
112
+ usort( $fields, woo_ce_sort_fields( 'order' ) );
113
+ return $fields;
114
+ break;
115
+
116
+ }
117
+
118
+ }
119
+
120
+ function woo_ce_override_category_field_labels( $fields = array() ) {
121
+
122
+ $labels = woo_ce_get_option( 'category_labels', array() );
123
+ if( !empty( $labels ) ) {
124
+ foreach( $fields as $key => $field ) {
125
+ if( isset( $labels[$field['name']] ) )
126
+ $fields[$key]['label'] = $labels[$field['name']];
127
+ }
128
+ }
129
+ return $fields;
130
+
131
+ }
132
+ add_filter( 'woo_ce_category_fields', 'woo_ce_override_category_field_labels', 11 );
133
+
134
+ // Returns the export column header label based on an export column slug
135
+ function woo_ce_get_category_field( $name = null, $format = 'name' ) {
136
+
137
+ $output = '';
138
+ if( $name ) {
139
+ $fields = woo_ce_get_category_fields();
140
+ $size = count( $fields );
141
+ for( $i = 0; $i < $size; $i++ ) {
142
+ if( $fields[$i]['name'] == $name ) {
143
+ switch( $format ) {
144
+
145
+ case 'name':
146
+ $output = $fields[$i]['label'];
147
+ break;
148
+
149
+ case 'full':
150
+ $output = $fields[$i];
151
+ break;
152
+
153
+ }
154
+ $i = $size;
155
+ }
156
+ }
157