WooCommerce – Store Exporter - Version 1.8.1

Version Description

  • Adeded: Export modules to the Export screen
Download this release

Release Info

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

Version 1.8.1

Files changed (59) hide show
  1. common/common.php +83 -0
  2. exporter.php +547 -0
  3. includes/admin.php +613 -0
  4. includes/brands.php +114 -0
  5. includes/categories.php +197 -0
  6. includes/common-dashboard_widgets.php +52 -0
  7. includes/coupons.php +187 -0
  8. includes/customers.php +210 -0
  9. includes/export-csv.php +49 -0
  10. includes/formatting.php +471 -0
  11. includes/functions.php +870 -0
  12. includes/install.php +41 -0
  13. includes/legacy.php +10 -0
  14. includes/orders.php +1187 -0
  15. includes/product_vendors.php +85 -0
  16. includes/products.php +1380 -0
  17. includes/settings.php +278 -0
  18. includes/subscriptions.php +108 -0
  19. includes/tags.php +164 -0
  20. includes/users.php +270 -0
  21. js/jquery-ui.js +48 -0
  22. js/jquery.chosen.js +988 -0
  23. js/jquery.csvToTable.js +154 -0
  24. js/ui-datepicker.js +84 -0
  25. languages/woo_ce-en_GB.mo +0 -0
  26. languages/woo_ce-en_GB.po +97 -0
  27. license.txt +281 -0
  28. readme.txt +562 -0
  29. templates/admin/chosen-sprite.png +0 -0
  30. templates/admin/chosen.css +397 -0
  31. templates/admin/export.css +103 -0
  32. templates/admin/export.js +336 -0
  33. templates/admin/images/animated-overlay.gif +0 -0
  34. templates/admin/images/progress.gif +0 -0
  35. templates/admin/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  36. templates/admin/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  37. templates/admin/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  38. templates/admin/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  39. templates/admin/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  40. templates/admin/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  41. templates/admin/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  42. templates/admin/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  43. templates/admin/images/ui-icons_222222_256x240.png +0 -0
  44. templates/admin/images/ui-icons_2e83ff_256x240.png +0 -0
  45. templates/admin/images/ui-icons_454545_256x240.png +0 -0
  46. templates/admin/images/ui-icons_888888_256x240.png +0 -0
  47. templates/admin/images/ui-icons_cd0a0a_256x240.png +0 -0
  48. templates/admin/jquery-csvtable.css +40 -0
  49. templates/admin/jquery-ui-datepicker.css +347 -0
  50. templates/admin/media-csv_file.php +12 -0
  51. templates/admin/media-export_details.php +54 -0
  52. templates/admin/tabs-archive.php +79 -0
  53. templates/admin/tabs-export.php +777 -0
  54. templates/admin/tabs-fields.php +28 -0
  55. templates/admin/tabs-overview.php +98 -0
  56. templates/admin/tabs-settings.php +149 -0
  57. templates/admin/tabs-tools.php +30 -0
  58. templates/admin/tabs.php +13 -0
  59. templates/admin/woocommerce-admin_dashboard_vm-plugins.css +55 -0
common/common.php ADDED
@@ -0,0 +1,83 @@
1
+ <?php
2
+ /**
3
+ *
4
+ * Filename: common.php
5
+ * Description: common.php loads commonly accessed functions across the Visser Labs suite.
6
+ *
7
+ * - woo_get_action
8
+ * - woo_is_wpsc_activated
9
+ * - woo_is_woo_activated
10
+ * - woo_is_jigo_activated
11
+ * - woo_get_woo_version
12
+ */
13
+
14
+ if( is_admin() ) {
15
+
16
+ /* Start of: WordPress Administration */
17
+
18
+ // Load Dashboard widgets
19
+ include_once( WOO_CE_PATH . 'includes/common-dashboard_widgets.php' );
20
+
21
+ /* End of: WordPress Administration */
22
+
23
+ }
24
+
25
+ if( !function_exists( 'woo_get_action' ) ) {
26
+ function woo_get_action( $prefer_get = false ) {
27
+
28
+ if ( isset( $_GET['action'] ) && $prefer_get )
29
+ return $_GET['action'];
30
+
31
+ if ( isset( $_POST['action'] ) )
32
+ return $_POST['action'];
33
+
34
+ if ( isset( $_GET['action'] ) )
35
+ return $_GET['action'];
36
+
37
+ return false;
38
+
39
+ }
40
+ }
41
+
42
+ if( !function_exists( 'woo_is_wpsc_activated' ) ) {
43
+ function woo_is_wpsc_activated() {
44
+
45
+ if( class_exists( 'WP_eCommerce' ) || defined( 'WPSC_VERSION' ) )
46
+ return true;
47
+
48
+ }
49
+ }
50
+
51
+ if( !function_exists( 'woo_is_woo_activated' ) ) {
52
+ function woo_is_woo_activated() {
53
+
54
+ if( class_exists( 'Woocommerce' ) )
55
+ return true;
56
+
57
+ }
58
+ }
59
+
60
+ if( !function_exists( 'woo_is_jigo_activated' ) ) {
61
+ function woo_is_jigo_activated() {
62
+
63
+ if( function_exists( 'jigoshop_init' ) )
64
+ return true;
65
+
66
+ }
67
+ }
68
+
69
+ if( !function_exists( 'woo_get_woo_version' ) ) {
70
+ function woo_get_woo_version() {
71
+
72
+ $version = false;
73
+ if( defined( 'WC_VERSION' ) ) {
74
+ $version = WC_VERSION;
75
+ // Backwards compatibility
76
+ } else if( defined( 'WOOCOMMERCE_VERSION' ) ) {
77
+ $version = WOOCOMMERCE_VERSION;
78
+ }
79
+ return $version;
80
+
81
+ }
82
+ }
83
+ ?>
exporter.php ADDED
@@ -0,0 +1,547 @@
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 2007 XLS, etc.).
6
+ Version: 1.8.1
7
+ Author: Visser Labs
8
+ Author URI: http://www.visser.com.au/about/
9
+ License: GPL2
10
+ */
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
13
+
14
+ define( 'WOO_CE_DIRNAME', basename( dirname( __FILE__ ) ) );
15
+ define( 'WOO_CE_RELPATH', basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ) );
16
+ define( 'WOO_CE_PATH', plugin_dir_path( __FILE__ ) );
17
+ define( 'WOO_CE_PREFIX', 'woo_ce' );
18
+
19
+ // Turn this on to enable additional debugging options at export time
20
+ define( 'WOO_CE_DEBUG', false );
21
+
22
+ // Avoid conflicts if Store Exporter Deluxe is activated
23
+ include_once( WOO_CE_PATH . 'common/common.php' );
24
+ if( defined( 'WOO_CD_PREFIX' ) == false ) {
25
+ include_once( WOO_CE_PATH . 'includes/functions.php' );
26
+ }
27
+
28
+ function woo_ce_i18n() {
29
+
30
+ load_plugin_textdomain( 'woo_ce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
31
+
32
+ }
33
+ add_action( 'init', 'woo_ce_i18n' );
34
+
35
+ if( is_admin() ) {
36
+
37
+ /* Start of: WordPress Administration */
38
+
39
+ include_once( WOO_CE_PATH . 'includes/install.php' );
40
+ register_activation_hook( __FILE__, 'woo_ce_install' );
41
+
42
+ // Initial scripts and export process
43
+ function woo_ce_admin_init() {
44
+
45
+ global $export, $wp_roles;
46
+
47
+ // Now is the time to de-activate Store Exporter if Store Exporter Deluxe is activated
48
+ if( defined( 'WOO_CD_PREFIX' ) ) {
49
+ include_once( WOO_CE_PATH . 'includes/install.php' );
50
+ woo_ce_deactivate_ce();
51
+ }
52
+
53
+ // Check that we are on the Store Exporter screen
54
+ $page = ( isset($_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : false );
55
+ if( $page != strtolower( WOO_CE_PREFIX ) )
56
+ return;
57
+
58
+ // Detect other platform versions
59
+ woo_ce_detect_non_woo_install();
60
+
61
+ // Add Store Exporter widgets to Export screen
62
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_category' );
63
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_tag' );
64
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_status' );
65
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_type' );
66
+ add_action( 'woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_stock_status' );
67
+ add_action( 'woo_ce_export_product_options_after_table', 'woo_ce_products_product_sorting' );
68
+ add_action( 'woo_ce_export_category_options_after_table', 'woo_ce_category_order_sorting' );
69
+ add_action( 'woo_ce_export_tag_options_after_table', 'woo_ce_tag_order_sorting' );
70
+ add_action( 'woo_ce_export_user_options_after_table', 'woo_ce_users_user_sorting' );
71
+ add_action( 'woo_ce_export_options', 'woo_ce_products_upsells_formatting' );
72
+ add_action( 'woo_ce_export_options', 'woo_ce_products_crosssells_formatting' );
73
+ add_action( 'woo_ce_export_after_form', 'woo_ce_products_custom_fields' );
74
+
75
+ // Add Store Exporter Deluxe widgets to Export screen
76
+ add_action( 'woo_ce_export_brand_options_before_table', 'woo_ce_brands_brand_sorting' );
77
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_date' );
78
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_status' );
79
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_customer' );
80
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_user_role' );
81
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_coupon' );
82
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product_category' );
83
+ add_action( 'woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product_tag' );
84
+ add_action( 'woo_ce_export_order_options_after_table', 'woo_ce_orders_order_sorting' );
85
+ add_action( 'woo_ce_export_customer_options_before_table', 'woo_ce_customers_filter_by_status' );
86
+ add_action( 'woo_ce_export_coupon_options_before_table', 'woo_ce_coupons_coupon_sorting' );
87
+ add_action( 'woo_ce_export_options', 'woo_ce_orders_items_formatting' );
88
+ add_action( 'woo_ce_export_options', 'woo_ce_orders_max_order_items' );
89
+ add_action( 'woo_ce_export_options', 'woo_ce_orders_items_types' );
90
+ add_action( 'woo_ce_export_after_form', 'woo_ce_orders_custom_fields' );
91
+ add_action( 'woo_ce_export_options', 'woo_ce_export_options_export_format' );
92
+ add_action( 'woo_ce_export_options', 'woo_ce_export_options_gallery_format' );
93
+
94
+ // Add Store Exporter Deluxe options to Settings screen
95
+ add_action( 'woo_ce_export_settings_top', 'woo_ce_export_settings_quicklinks' );
96
+ add_action( 'woo_ce_export_settings_general', 'woo_ce_export_settings_additional' );
97
+ add_action( 'woo_ce_export_settings_after', 'woo_ce_export_settings_cron' );
98
+
99
+ $action = woo_get_action();
100
+ switch( $action ) {
101
+
102
+ // Prompt on Export screen when insufficient memory (less than 64M is allocated)
103
+ case 'dismiss_memory_prompt':
104
+ woo_ce_update_option( 'dismiss_memory_prompt', 1 );
105
+ $url = add_query_arg( 'action', null );
106
+ wp_redirect( $url );
107
+ exit();
108
+ break;
109
+
110
+ // Prompt on Export screen when insufficient memory (less than 64M is allocated)
111
+ case 'dismiss_php_legacy':
112
+ woo_ce_update_option( 'dismiss_php_legacy', 1 );
113
+ $url = add_query_arg( 'action', null );
114
+ wp_redirect( $url );
115
+ exit();
116
+ break;
117
+
118
+ // Save skip overview preference
119
+ case 'skip_overview':
120
+ $skip_overview = false;
121
+ if( isset( $_POST['skip_overview'] ) )
122
+ $skip_overview = 1;
123
+ woo_ce_update_option( 'skip_overview', $skip_overview );
124
+
125
+ if( $skip_overview == 1 ) {
126
+ $url = add_query_arg( 'tab', 'export' );
127
+ wp_redirect( $url );
128
+ exit();
129
+ }
130
+ break;
131
+
132
+ // This is where the magic happens
133
+ case 'export':
134
+
135
+ // Set up the basic export options
136
+ $export = new stdClass();
137
+ $export->cron = 0;
138
+ $export->start_time = time();
139
+ $export->idle_memory_start = woo_ce_current_memory_usage();
140
+ $export->delete_file = woo_ce_get_option( 'delete_file', 0 );
141
+ $export->encoding = woo_ce_get_option( 'encoding', get_option( 'blog_charset', 'UTF-8' ) );
142
+ // Check for bad encoding
143
+ if( $export->encoding == '' || $export->encoding == false || $export->encoding == 'System default' )
144
+ $export->encoding = 'UTF-8';
145
+ $export->delimiter = woo_ce_get_option( 'delimiter', ',' );
146
+ $export->category_separator = woo_ce_get_option( 'category_separator', '|' );
147
+ $export->bom = woo_ce_get_option( 'bom', 1 );
148
+ $export->escape_formatting = woo_ce_get_option( 'escape_formatting', 'all' );
149
+ $export->date_format = woo_ce_get_option( 'date_format', 'd/m/Y' );
150
+ if( $export->date_format == 1 || $export->date_format == '' )
151
+ $export->date_format = 'd/m/Y';
152
+
153
+ // Save export option changes made on the Export screen
154
+ $export->limit_volume = ( isset( $_POST['limit_volume'] ) ? sanitize_text_field( $_POST['limit_volume'] ) : '' );
155
+ woo_ce_update_option( 'limit_volume', $export->limit_volume );
156
+ if( $export->limit_volume == '' )
157
+ $export->limit_volume = -1;
158
+ $export->offset = ( isset( $_POST['offset'] ) ? sanitize_text_field( $_POST['offset'] ) : '' );
159
+ woo_ce_update_option( 'offset', $export->offset );
160
+ if( $export->offset == '' )
161
+ $export->offset = 0;
162
+
163
+ // Set default values for all export options to be later passed onto the export process
164
+ $export->fields = false;
165
+ $export->fields_order = false;
166
+ $export->export_format = 'csv';
167
+
168
+ // Product sorting
169
+ $export->product_categories = false;
170
+ $export->product_tags = false;
171
+ $export->product_status = false;
172
+ $export->product_type = false;
173
+ $export->product_orderby = false;
174
+ $export->product_order = false;
175
+ $export->upsell_formatting = false;
176
+ $export->crosssell_formatting = false;
177
+
178
+ // Category sorting
179
+ $export->category_orderby = false;
180
+ $export->category_order = false;
181
+
182
+ // Tag sorting
183
+ $export->tag_orderby = false;
184
+ $export->tag_order = false;
185
+
186
+ // User sorting
187
+ $export->user_orderby = false;
188
+ $export->user_order = false;
189
+
190
+ $export->type = ( isset( $_POST['dataset'] ) ? sanitize_text_field( $_POST['dataset'] ) : false );
191
+ if( $export->type )
192
+ woo_ce_update_option( 'last_export', $export->type );
193
+ switch( $export->type ) {
194
+
195
+ case 'product':
196
+ // Set up dataset specific options
197
+ $export->fields = ( isset( $_POST['product_fields'] ) ? array_map( 'sanitize_text_field', $_POST['product_fields'] ) : false );
198
+ $export->fields_order = ( isset( $_POST['product_fields_order'] ) ? array_map( 'absint', $_POST['product_fields_order'] ) : false );
199
+ $export->product_categories = ( isset( $_POST['product_filter_category'] ) ? woo_ce_format_product_filters( array_map( 'absint', $_POST['product_filter_category'] ) ) : false );
200
+ $export->product_tags = ( isset( $_POST['product_filter_tag'] ) ? woo_ce_format_product_filters( array_map( 'absint', $_POST['product_filter_tag'] ) ) : false );
201
+ $export->product_status = ( isset( $_POST['product_filter_status'] ) ? woo_ce_format_product_filters( array_map( 'sanitize_text_field', $_POST['product_filter_status'] ) ) : false );
202
+ $export->product_type = ( isset( $_POST['product_filter_type'] ) ? woo_ce_format_product_filters( array_map( 'sanitize_text_field', $_POST['product_filter_type'] ) ) : false );
203
+ $export->product_orderby = ( isset( $_POST['product_orderby'] ) ? sanitize_text_field( $_POST['product_orderby'] ) : false );
204
+ $export->product_order = ( isset( $_POST['product_order'] ) ? sanitize_text_field( $_POST['product_order'] ) : false );
205
+ $export->upsell_formatting = ( isset( $_POST['product_upsell_formatting'] ) ? absint( $_POST['product_upsell_formatting'] ) : false );
206
+ $export->crosssell_formatting = ( isset( $_POST['product_crosssell_formatting'] ) ? absint( $_POST['product_crosssell_formatting'] ) : false );
207
+
208
+ // Save dataset export specific options
209
+ if( $export->product_orderby <> woo_ce_get_option( 'product_orderby' ) )
210
+ woo_ce_update_option( 'product_orderby', $export->product_orderby );
211
+ if( $export->product_order <> woo_ce_get_option( 'product_order' ) )
212
+ woo_ce_update_option( 'product_order', $export->product_order );
213
+ if( $export->upsell_formatting <> woo_ce_get_option( 'upsell_formatting' ) )
214
+ woo_ce_update_option( 'upsell_formatting', $export->upsell_formatting );
215
+ if( $export->crosssell_formatting <> woo_ce_get_option( 'crosssell_formatting' ) )
216
+ woo_ce_update_option( 'crosssell_formatting', $export->crosssell_formatting );
217
+ break;
218
+
219
+ case 'category':
220
+ // Set up dataset specific options
221
+ $export->fields = ( isset( $_POST['category_fields'] ) ? array_map( 'sanitize_text_field', $_POST['category_fields'] ) : false );
222
+ $export->fields_order = ( isset( $_POST['category_fields_order'] ) ? array_map( 'absint', $_POST['category_fields_order'] ) : false );
223
+ $export->category_orderby = ( isset( $_POST['category_orderby'] ) ? sanitize_text_field( $_POST['category_orderby'] ) : false );
224
+ $export->category_order = ( isset( $_POST['category_order'] ) ? sanitize_text_field( $_POST['category_order'] ) : false );
225
+
226
+ // Save dataset export specific options
227
+ if( $export->category_orderby <> woo_ce_get_option( 'category_orderby' ) )
228
+ woo_ce_update_option( 'category_orderby', $export->category_orderby );
229
+ if( $export->category_order <> woo_ce_get_option( 'category_order' ) )
230
+ woo_ce_update_option( 'category_order', $export->category_order );
231
+ break;
232
+
233
+ case 'tag':
234
+ // Set up dataset specific options
235
+ $export->fields = ( isset( $_POST['tag_fields'] ) ? array_map( 'sanitize_text_field', $_POST['tag_fields'] ) : false );
236
+ $export->fields_order = ( isset( $_POST['tag_fields_order'] ) ? array_map( 'absint', $_POST['tag_fields_order'] ) : false );
237
+ $export->tag_orderby = ( isset( $_POST['tag_orderby'] ) ? sanitize_text_field( $_POST['tag_orderby'] ) : false );
238
+ $export->tag_order = ( isset( $_POST['tag_order'] ) ? sanitize_text_field( $_POST['tag_order'] ) : false );
239
+
240
+ // Save dataset export specific options
241
+ if( $export->tag_orderby <> woo_ce_get_option( 'tag_orderby' ) )
242
+ woo_ce_update_option( 'tag_orderby', $export->tag_orderby );
243
+ if( $export->tag_order <> woo_ce_get_option( 'tag_order' ) )
244
+ woo_ce_update_option( 'tag_order', $export->tag_order );
245
+ break;
246
+
247
+ case 'user':
248
+ // Set up dataset specific options
249
+ $export->fields = array_map( 'sanitize_text_field', $_POST['user_fields'] );
250
+ $export->fields_order = ( isset( $_POST['user_fields_order'] ) ? array_map( 'absint', $_POST['user_fields_order'] ) : false );
251
+ $export->user_orderby = ( isset( $_POST['user_orderby'] ) ? sanitize_text_field( $_POST['user_orderby'] ) : false );
252
+ $export->user_order = ( isset( $_POST['user_order'] ) ? sanitize_text_field( $_POST['user_order'] ) : false );
253
+
254
+ // Save dataset export specific options
255
+ if( $export->user_orderby <> woo_ce_get_option( 'user_orderby' ) )
256
+ woo_ce_update_option( 'user_orderby', $export->user_orderby );
257
+ if( $export->user_order <> woo_ce_get_option( 'user_order' ) )
258
+ woo_ce_update_option( 'user_order', $export->user_order );
259
+ break;
260
+
261
+ }
262
+ if( $export->type ) {
263
+
264
+ $timeout = 600;
265
+ if( isset( $_POST['timeout'] ) ) {
266
+ $timeout = absint( (int)$_POST['timeout'] );
267
+ if( $timeout <> woo_ce_get_option( 'timeout' ) )
268
+ woo_ce_update_option( 'timeout', $timeout );
269
+ }
270
+ if( !ini_get( 'safe_mode' ) )
271
+ @set_time_limit( (int)$timeout );
272
+
273
+ @ini_set( 'memory_limit', WP_MAX_MEMORY_LIMIT );
274
+ @ini_set( 'max_execution_time', (int)$timeout );
275
+
276
+ $export->args = array(
277
+ 'limit_volume' => $export->limit_volume,
278
+ 'offset' => $export->offset,
279
+ 'encoding' => $export->encoding,
280
+ 'date_format' => $export->date_format,
281
+ 'product_categories' => $export->product_categories,
282
+ 'product_tags' => $export->product_tags,
283
+ 'product_status' => $export->product_status,
284
+ 'product_type' => $export->product_type,
285
+ 'product_orderby' => $export->product_orderby,
286
+ 'product_order' => $export->product_order,
287
+ 'category_orderby' => $export->category_orderby,
288
+ 'category_order' => $export->category_order,
289
+ 'tag_orderby' => $export->tag_orderby,
290
+ 'tag_order' => $export->tag_order,
291
+ 'user_orderby' => $export->user_orderby,
292
+ 'user_order' => $export->user_order
293
+ );
294
+ woo_ce_save_fields( $export->type, $export->fields, $export->fields_order );
295
+
296
+ if( $export->export_format == 'csv' ) {
297
+ $export->filename = woo_ce_generate_csv_filename( $export->type );
298
+ }
299
+
300
+ // Print file contents to debug export screen
301
+ if( WOO_CE_DEBUG ) {
302
+
303
+ if( in_array( $export->export_format, array( 'csv' ) ) ) {
304
+ woo_ce_export_dataset( $export->type );
305
+ }
306
+ $export->idle_memory_end = woo_ce_current_memory_usage();
307
+ $export->end_time = time();
308
+
309
+ // Print file contents to browser
310
+ } else {
311
+ if( in_array( $export->export_format, array( 'csv' ) ) ) {
312
+
313
+ // Generate CSV contents
314
+ $bits = woo_ce_export_dataset( $export->type );
315
+ unset( $export->fields );
316
+ if( !$bits ) {
317
+ $message = __( 'No export entries were found, please try again with different export filters.', 'woo_ce' );
318
+ woo_ce_admin_notice( $message, 'error' );
319
+ return;
320
+ }
321
+ if( $export->delete_file ) {
322
+
323
+ // Print to browser
324
+ if( $export->export_format == 'csv' )
325
+ woo_ce_generate_csv_header( $export->type );
326
+ echo $bits;
327
+ exit();
328
+
329
+ } else {
330
+
331
+ // Save to file and insert to WordPress Media
332
+ if( $export->filename && $bits ) {
333
+ if( $export->export_format == 'csv' )
334
+ $post_ID = woo_ce_save_file_attachment( $export->filename, 'text/csv' );
335
+ $upload = wp_upload_bits( $export->filename, null, $bits );
336
+ if( ( $post_ID == false ) || $upload['error'] ) {
337
+ wp_delete_attachment( $post_ID, true );
338
+ if( isset( $upload['error'] ) )
339
+ wp_redirect( add_query_arg( array( 'failed' => true, 'message' => urlencode( $upload['error'] ) ) ) );
340
+ else
341
+ wp_redirect( add_query_arg( array( 'failed' => true ) ) );
342
+ return;
343
+ }
344
+ $attach_data = wp_generate_attachment_metadata( $post_ID, $upload['file'] );
345
+ wp_update_attachment_metadata( $post_ID, $attach_data );
346
+ update_attached_file( $post_ID, $upload['file'] );
347
+ if( $post_ID ) {
348
+ woo_ce_save_file_guid( $post_ID, $export->type, $upload['url'] );
349
+ woo_ce_save_file_details( $post_ID );
350
+ }
351
+ $export_type = $export->type;
352
+ unset( $export );
353
+
354
+ // The end memory usage and time is collected at the very last opportunity prior to the CSV header being rendered to the screen
355
+ woo_ce_update_file_detail( $post_ID, '_woo_idle_memory_end', woo_ce_current_memory_usage() );
356
+ woo_ce_update_file_detail( $post_ID, '_woo_end_time', time() );
357
+
358
+ // Generate CSV header
359
+ woo_ce_generate_csv_header( $export_type );
360
+ unset( $export_type );
361
+
362
+ // Print file contents to screen
363
+ if( $upload['file'] )
364
+ readfile( $upload['file'] );
365
+ else
366
+ wp_redirect( add_query_arg( 'failed', true ) );
367
+ unset( $upload );
368
+ } else {
369
+ wp_redirect( add_query_arg( 'failed', true ) );
370
+ }
371
+
372
+ }
373
+
374
+ }
375
+ exit();
376
+ }
377
+ }
378
+ break;
379
+
380
+ // Save changes on Settings screen
381
+ case 'save-settings':
382
+ // Sanitize each setting field as needed
383
+ woo_ce_update_option( 'export_filename', strip_tags( (string)$_POST['export_filename'] ) );
384
+ woo_ce_update_option( 'delete_file', sanitize_text_field( (int)$_POST['delete_file'] ) );
385
+ woo_ce_update_option( 'encoding', sanitize_text_field( (string)$_POST['encoding'] ) );
386
+ woo_ce_update_option( 'delimiter', sanitize_text_field( (string)$_POST['delimiter'] ) );
387
+ woo_ce_update_option( 'category_separator', sanitize_text_field( (string)$_POST['category_separator'] ) );
388
+ woo_ce_update_option( 'bom', absint( (int)$_POST['bom'] ) );
389
+ woo_ce_update_option( 'escape_formatting', sanitize_text_field( (string)$_POST['escape_formatting'] ) );
390
+ if( $_POST['date_format'] == 'custom' && !empty( $_POST['date_format_custom'] ) )
391
+ woo_ce_update_option( 'date_format', sanitize_text_field( (string)$_POST['date_format_custom'] ) );
392
+ else
393
+ woo_ce_update_option( 'date_format', sanitize_text_field( (string)$_POST['date_format'] ) );
394
+
395
+ $message = __( 'Changes have been saved.', 'woo_ce' );
396
+ woo_ce_admin_notice( $message );
397
+ break;
398
+
399
+ // Save changes on Field Editor screen
400
+ case 'save-fields':
401
+ $fields = ( isset( $_POST['fields'] ) ? array_filter( $_POST['fields'] ) : array() );
402
+ $types = array_keys( woo_ce_return_export_types() );
403
+ $export_type = ( isset( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : '' );
404
+ if( in_array( $export_type, $types ) ) {
405
+ woo_ce_update_option( $export_type . '_labels', $fields );
406
+ $message = __( 'Changes have been saved.', 'woo_ce' );
407
+ woo_ce_admin_notice( $message );
408
+ } else {
409
+ $message = __( 'Changes could not be saved.', 'woo_ce' );
410
+ woo_ce_admin_notice( $message, 'error' );
411
+ }
412
+ break;
413
+
414
+ }
415
+
416
+ }
417
+ add_action( 'admin_init', 'woo_ce_admin_init', 11 );
418
+
419
+ // HTML templates and form processor for Store Exporter screen
420
+ function woo_ce_html_page() {
421
+
422
+ global $wpdb, $export;
423
+
424
+ $title = apply_filters( 'woo_ce_template_header', __( 'Store Exporter', 'woo_ce' ) );
425
+ woo_ce_template_header( $title );
426
+ woo_ce_support_donate();
427
+ $action = woo_get_action();
428
+ switch( $action ) {
429
+
430
+ case 'export':
431
+ $message = __( 'Chosen WooCommerce details have been exported from your store.', 'woo_ce' );
432
+ woo_ce_admin_notice( $message );
433
+ if( WOO_CE_DEBUG ) {
434
+ $output = '';
435
+ $troubleshooting_url = 'http://www.visser.com.au/documentation/store-exporter-deluxe/usage/';
436
+ if( false === ( $export_log = get_transient( WOO_CE_PREFIX . '_debug_log' ) ) ) {
437
+ $export_log = __( 'No export entries were found, please try again with different export filters.', 'woo_ce' );
438
+ } else {
439
+ $export_log = base64_decode( $export_log );
440
+ delete_transient( WOO_CE_PREFIX . '_debug_log' );
441
+ }
442
+ $output = '
443
+ <h3>' . sprintf( __( 'Export Details: %s', 'woo_ce' ), esc_attr( $export->filename ) ) . '</h3>
444
+ <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.', 'woo_ce' ) . '</p>
445
+ <textarea id="export_log">' . esc_textarea( print_r( $export, true ) ) . '</textarea>
446
+ <hr />';
447
+ if( in_array( $export->export_format, array( 'csv' ) ) ) {
448
+ $output .= '
449
+ <script>
450
+ $j(function() {
451
+ $j(\'#export_sheet\').CSVToTable(\'\', { startLine: 0 });
452
+ });
453
+ </script>
454
+ <h3>' . __( 'Export', 'woo_ce' ) . '</h3>
455
+ <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.', 'woo_ce' ) . '</p>
456
+ <div id="export_sheet">' . esc_textarea( $export_log ) . '</div>
457
+ <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.', 'woo_ce' ) . '</p>
458
+ <hr />';
459
+ }
460
+ $output .= '
461
+ <h3>' . __( 'Export Log', 'woo_ce' ) . '</h3>
462
+ <p>' . __( 'This prints the raw export contents and is helpful when the jQuery plugin above fails due to major formatting errors.', 'woo_ce' ) . '</p>
463
+ <textarea id="export_log" wrap="off">' . esc_textarea( $export_log ) . '</textarea>
464
+ <hr />
465
+ ';
466
+ echo $output;
467
+ }
468
+
469
+ woo_ce_manage_form();
470
+ break;
471
+
472
+ case 'update':
473
+ // Save Custom Product Meta
474
+ if( isset( $_POST['custom_products'] ) ) {
475
+ $custom_products = $_POST['custom_products'];
476
+ $custom_products = explode( "\n", trim( $custom_products ) );
477
+ $size = count( $custom_products );
478
+ if( $size ) {
479
+ for( $i = 0; $i < $size; $i++ )
480
+ $custom_products[$i] = sanitize_text_field( trim( $custom_products[$i] ) );
481
+ woo_ce_update_option( 'custom_products', $custom_products );
482
+ }
483
+ }
484
+
485
+ // Save Custom Order Meta
486
+ if( isset( $_POST['custom_orders'] ) ) {
487
+ $custom_orders = $_POST['custom_orders'];
488
+ $custom_orders = explode( "\n", trim( $custom_orders ) );
489
+ $size = count( $custom_orders );
490
+ if( $size ) {
491
+ for( $i = 0; $i < $size; $i++ )
492
+ $custom_orders[$i] = sanitize_text_field( trim( $custom_orders[$i] ) );
493
+ woo_ce_update_option( 'custom_orders', $custom_orders );
494
+ }
495
+ }
496
+
497
+ // Save Custom Order Item Meta
498
+ if( isset( $_POST['custom_order_items'] ) ) {
499
+ $custom_order_items = $_POST['custom_order_items'];
500
+ if( !empty( $custom_order_items ) ) {
501
+ $custom_order_items = explode( "\n", trim( $custom_order_items ) );
502
+ $size = count( $custom_order_items );
503
+ if( $size ) {
504
+ for( $i = 0; $i < $size; $i++ )
505
+ $custom_order_items[$i] = sanitize_text_field( trim( $custom_order_items[$i] ) );
506
+ woo_ce_update_option( 'custom_order_items', $custom_order_items );
507
+ }
508
+ } else {
509
+ woo_ce_update_option( 'custom_order_items', '' );
510
+ }
511
+ }
512
+
513
+ $message = __( 'Custom Fields saved.', 'woo_ce' );
514
+ woo_ce_admin_notice( $message );
515
+ woo_ce_manage_form();
516
+ break;
517
+
518
+ default:
519
+ woo_ce_manage_form();
520
+ break;
521
+
522
+ }
523
+ woo_ce_template_footer();
524
+
525
+ }
526
+
527
+ // HTML template for Export screen
528
+ function woo_ce_manage_form() {
529
+
530
+ $tab = false;
531
+ if( isset( $_GET['tab'] ) ) {
532
+ $tab = sanitize_text_field( $_GET['tab'] );
533
+ // If Skip Overview is set then jump to Export screen
534
+ } else if( woo_ce_get_option( 'skip_overview', false ) ) {
535
+ $tab = 'export';
536
+ }
537
+ $url = add_query_arg( 'page', 'woo_ce' );
538
+ woo_ce_fail_notices();
539
+
540
+ include_once( WOO_CE_PATH . 'templates/admin/tabs.php' );
541
+
542
+ }
543
+
544
+ /* End of: WordPress Administration */
545
+
546
+ }
547
+ ?>
includes/admin.php ADDED
@@ -0,0 +1,613 @@
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', 'woo_ce' ); ?>
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
+ <a href="<?php echo add_query_arg( array( 'tab' => 'export', 'empty' => null ) ); ?>" class="add-new-h2"><?php _e( 'Add New', 'woo_ce' ); ?></a>
72
+ </h2>
73
+ <?php
74
+
75
+ }
76
+
77
+ // HTML template footer on Store Exporter screen
78
+ function woo_ce_template_footer() { ?>
79
+ </div>
80
+ <!-- .wrap -->
81
+ <?php
82
+
83
+ }
84
+
85
+ // Add Export and Docs links to the Plugins screen
86
+ function woo_ce_add_settings_link( $links, $file ) {
87
+
88
+ // Manually force slug
89
+ $this_plugin = WOO_CE_RELPATH;
90
+
91
+ if( $file == $this_plugin ) {
92
+ $docs_url = 'http://www.visser.com.au/docs/';
93
+ $docs_link = sprintf( '<a href="%s" target="_blank">' . __( 'Docs', 'woo_ce' ) . '</a>', $docs_url );
94
+ $export_link = sprintf( '<a href="%s">' . __( 'Export', 'woo_ce' ) . '</a>', add_query_arg( 'page', 'woo_ce', 'admin.php' ) );
95
+ array_unshift( $links, $docs_link );
96
+ array_unshift( $links, $export_link );
97
+ }
98
+ return $links;
99
+
100
+ }
101
+ add_filter( 'plugin_action_links', 'woo_ce_add_settings_link', 10, 2 );
102
+
103
+ // Add Store Export page to WooCommerce screen IDs
104
+ function woo_ce_wc_screen_ids( $screen_ids = array() ) {
105
+
106
+ $screen_ids[] = 'woocommerce_page_woo_ce';
107
+ return $screen_ids;
108
+
109
+ }
110
+ add_filter( 'woocommerce_screen_ids', 'woo_ce_wc_screen_ids', 10, 1 );
111
+
112
+ // Add Store Export to WordPress Administration menu
113
+ function woo_ce_admin_menu() {
114
+
115
+ $page = add_submenu_page( 'woocommerce', __( 'Store Exporter', 'woo_ce' ), __( 'Store Export', 'woo_ce' ), 'view_woocommerce_reports', 'woo_ce', 'woo_ce_html_page' );
116
+ add_action( 'admin_print_styles-' . $page, 'woo_ce_enqueue_scripts' );
117
+
118
+ }
119
+ add_action( 'admin_menu', 'woo_ce_admin_menu', 11 );
120
+
121
+ // Load CSS and jQuery scripts for Store Exporter screen
122
+ function woo_ce_enqueue_scripts( $hook ) {
123
+
124
+ // Simple check that WooCommerce is activated
125
+ if( class_exists( 'WooCommerce' ) ) {
126
+
127
+ global $woocommerce;
128
+
129
+ // Load WooCommerce default Admin styling
130
+ wp_enqueue_style( 'woocommerce_admin_styles', $woocommerce->plugin_url() . '/assets/css/admin.css' );
131
+
132
+ }
133
+
134
+ // Date Picker
135
+ wp_enqueue_script( 'jquery-ui-datepicker' );
136
+ wp_enqueue_style( 'jquery-ui-datepicker', plugins_url( '/templates/admin/jquery-ui-datepicker.css', WOO_CE_RELPATH ) );
137
+
138
+ // Chosen
139
+ wp_enqueue_style( 'jquery-chosen', plugins_url( '/templates/admin/chosen.css', WOO_CE_RELPATH ) );
140
+ wp_enqueue_script( 'jquery-chosen', plugins_url( '/js/jquery.chosen.js', WOO_CE_RELPATH ), array( 'jquery' ) );
141
+
142
+ // Common
143
+ wp_enqueue_style( 'woo_ce_styles', plugins_url( '/templates/admin/export.css', WOO_CE_RELPATH ) );
144
+ wp_enqueue_script( 'woo_ce_scripts', plugins_url( '/templates/admin/export.js', WOO_CE_RELPATH ), array( 'jquery', 'jquery-ui-sortable' ) );
145
+ wp_enqueue_style( 'dashicons' );
146
+
147
+ if( WOO_CE_DEBUG ) {
148
+ wp_enqueue_style( 'jquery-csvToTable', plugins_url( '/templates/admin/jquery-csvtable.css', WOO_CE_RELPATH ) );
149
+ wp_enqueue_script( 'jquery-csvToTable', plugins_url( '/js/jquery.csvToTable.js', WOO_CE_RELPATH ), array( 'jquery' ) );
150
+ }
151
+ wp_enqueue_style( 'woo_vm_styles', plugins_url( '/templates/admin/woocommerce-admin_dashboard_vm-plugins.css', WOO_CE_RELPATH ) );
152
+
153
+ }
154
+
155
+ // HTML active class for the currently selected tab on the Store Exporter screen
156
+ function woo_ce_admin_active_tab( $tab_name = null, $tab = null ) {
157
+
158
+ if( isset( $_GET['tab'] ) && !$tab )
159
+ $tab = $_GET['tab'];
160
+ else if( !isset( $_GET['tab'] ) && woo_ce_get_option( 'skip_overview', false ) )
161
+ $tab = 'export';
162
+ else
163
+ $tab = 'overview';
164
+
165
+ $output = '';
166
+ if( isset( $tab_name ) && $tab_name ) {
167
+ if( $tab_name == $tab )
168
+ $output = ' nav-tab-active';
169
+ }
170
+ echo $output;
171
+
172
+ }
173
+
174
+ // HTML template for each tab on the Store Exporter screen
175
+ function woo_ce_tab_template( $tab = '' ) {
176
+
177
+ if( !$tab )
178
+ $tab = 'overview';
179
+
180
+ // Store Exporter Deluxe
181
+ $woo_cd_url = 'http://www.visser.com.au/woocommerce/plugins/exporter-deluxe/';
182
+ $woo_cd_link = sprintf( '<a href="%s" target="_blank">' . __( 'Store Exporter Deluxe', 'woo_ce' ) . '</a>', $woo_cd_url );
183
+
184
+ $troubleshooting_url = 'http://www.visser.com.au/documentation/store-exporter-deluxe/';
185
+
186
+ switch( $tab ) {
187
+
188
+ case 'overview':
189
+ $skip_overview = woo_ce_get_option( 'skip_overview', false );
190
+ break;
191
+
192
+ case 'export':
193
+ $export_type = sanitize_text_field( ( isset( $_POST['dataset'] ) ? $_POST['dataset'] : woo_ce_get_option( 'last_export', 'product' ) ) );
194
+ $types = array_keys( woo_ce_return_export_types() );
195
+ // Check if the default export type exists
196
+ if( !in_array( $export_type, $types ) )
197
+ $export_type = 'product';
198
+
199
+ $products = woo_ce_return_count( 'product' );
200
+ $categories = woo_ce_return_count( 'category' );
201
+ $tags = woo_ce_return_count( 'tag' );
202
+ $brands = '999';
203
+ $orders = '999';
204
+ $customers = '999';
205
+ $users = woo_ce_return_count( 'user' );
206
+ $coupons = '999';
207
+ $attributes = '999';
208
+ $subscriptions = '999';
209
+ $product_vendors = '999';
210
+
211
+ if( $product_fields = woo_ce_get_product_fields() ) {
212
+ foreach( $product_fields as $key => $product_field )
213
+ $product_fields[$key]['disabled'] = ( isset( $product_field['disabled'] ) ? $product_field['disabled'] : 0 );
214
+ }
215
+ if( $category_fields = woo_ce_get_category_fields() ) {
216
+ foreach( $category_fields as $key => $category_field )
217
+ $category_fields[$key]['disabled'] = ( isset( $category_field['disabled'] ) ? $category_field['disabled'] : 0 );
218
+ }
219
+ if( $tag_fields = woo_ce_get_tag_fields() ) {
220
+ foreach( $tag_fields as $key => $tag_field )
221
+ $tag_fields[$key]['disabled'] = ( isset( $tag_field['disabled'] ) ? $tag_field['disabled'] : 0 );
222
+ }
223
+ if( $brand_fields = woo_ce_get_brand_fields() ) {
224
+ foreach( $brand_fields as $key => $brand_field )
225
+ $brand_fields[$key]['disabled'] = ( isset( $brand_field['disabled'] ) ? $brand_field['disabled'] : 0 );
226
+ }
227
+ $order_fields = woo_ce_get_order_fields();
228
+ $customer_fields = woo_ce_get_customer_fields();
229
+ if( $user_fields = woo_ce_get_user_fields() ) {
230
+ foreach( $user_fields as $key => $user_field )
231
+ $user_fields[$key]['disabled'] = ( isset( $user_field['disabled'] ) ? $user_field['disabled'] : 0 );
232
+ }
233
+ $coupon_fields = woo_ce_get_coupon_fields();
234
+ $subscription_fields = woo_ce_get_subscription_fields();
235
+ $product_vendor_fields = woo_ce_get_product_vendor_fields();
236
+ $attribute_fields = false;
237
+
238
+ // Export modules
239
+ $modules = woo_ce_modules_list();
240
+
241
+ // Export options
242
+ $limit_volume = woo_ce_get_option( 'limit_volume' );
243
+ $offset = woo_ce_get_option( 'offset' );
244
+ break;
245
+
246
+ case 'fields':
247
+ $export_type = ( isset( $_GET['type'] ) ? sanitize_text_field( $_GET['type'] ) : '' );
248
+ $types = array_keys( woo_ce_return_export_types() );
249
+ $fields = array();
250
+ if( in_array( $export_type, $types ) ) {
251
+ if( has_filter( 'woo_ce_' . $export_type . '_fields', 'woo_ce_override_' . $export_type . '_field_labels' ) )
252
+ remove_filter( 'woo_ce_' . $export_type . '_fields', 'woo_ce_override_' . $export_type . '_field_labels', 11 );
253
+ if( function_exists( sprintf( 'woo_ce_get_%s_fields', $export_type ) ) )
254
+ $fields = call_user_func( 'woo_ce_get_' . $export_type . '_fields' );
255
+ $labels = woo_ce_get_option( $export_type . '_labels', array() );
256
+ }
257
+ break;
258
+
259
+ case 'archive':
260
+ if( isset( $_GET['deleted'] ) ) {
261
+ $message = __( 'Archived export has been deleted.', 'woo_ce' );
262
+ woo_ce_admin_notice( $message );
263
+ }
264
+ if( $files = woo_ce_get_archive_files() ) {
265
+ foreach( $files as $key => $file )
266
+ $files[$key] = woo_ce_get_archive_file( $file );
267
+ }
268
+ break;
269
+
270
+ case 'settings':
271
+ $export_filename = woo_ce_get_option( 'export_filename', '' );
272
+ // Default export filename
273
+ if( empty( $export_filename ) )
274
+ $export_filename = 'woo-export_%dataset%-%date%.csv';
275
+ $delete_file = woo_ce_get_option( 'delete_file', 0 );
276
+ $timeout = woo_ce_get_option( 'timeout', 0 );
277
+ $encoding = woo_ce_get_option( 'encoding', 'UTF-8' );
278
+ $bom = woo_ce_get_option( 'bom', 1 );
279
+ $delimiter = woo_ce_get_option( 'delimiter', ',' );
280
+ $category_separator = woo_ce_get_option( 'category_separator', '|' );
281
+ $escape_formatting = woo_ce_get_option( 'escape_formatting', 'all' );
282
+ $date_format = woo_ce_get_option( 'date_format', 'd/m/Y' );
283
+ if( $date_format == 1 || $date_format == '' )
284
+ $date_format = 'd/m/Y';
285
+ $file_encodings = ( function_exists( 'mb_list_encodings' ) ? mb_list_encodings() : false );
286
+ break;
287
+
288
+ case 'tools':
289
+ // Product Importer Deluxe
290
+ $woo_pd_url = 'http://www.visser.com.au/woocommerce/plugins/product-importer-deluxe/';
291
+ $woo_pd_target = ' target="_blank"';
292
+ if( function_exists( 'woo_pd_init' ) ) {
293
+ $woo_pd_url = add_query_arg( array( 'page' => 'woo_pd', 'tab' => null ) );
294
+ $woo_pd_target = false;
295
+ }
296
+
297
+ // Store Toolkit
298
+ $woo_st_url = 'http://www.visser.com.au/woocommerce/plugins/store-toolkit/';
299
+ $woo_st_target = ' target="_blank"';
300
+ if( function_exists( 'woo_st_admin_init' ) ) {
301
+ $woo_st_url = add_query_arg( array( 'page' => 'woo_st', 'tab' => null ) );
302
+ $woo_st_target = false;
303
+ }
304
+ break;
305
+
306
+ }
307
+ if( $tab ) {
308
+ if( file_exists( WOO_CE_PATH . 'templates/admin/tabs-' . $tab . '.php' ) ) {
309
+ include_once( WOO_CE_PATH . 'templates/admin/tabs-' . $tab . '.php' );
310
+ } else {
311
+ $message = sprintf( __( 'We couldn\'t load the export template file <code>%s</code> within <code>%s</code>, this file should be present.', 'woo_ce' ), 'tabs-' . $tab . '.php', WOO_CE_PATH . 'templates/admin/...' );
312
+ woo_ce_admin_notice_html( $message, 'error' );
313
+ ob_start(); ?>
314
+ <p><?php _e( 'You can see this error for one of a few common reasons', 'woo_ce' ); ?>:</p>
315
+ <ul class="ul-disc">
316
+ <li><?php _e( 'WordPress was unable to create this file when the Plugin was installed or updated', 'woo_ce' ); ?></li>
317
+ <li><?php _e( 'The Plugin files have been recently changed and there has been a file conflict', 'woo_ce' ); ?></li>
318
+ <li><?php _e( 'The Plugin file has been locked and cannot be opened by WordPress', 'woo_ce' ); ?></li>
319
+ </ul>
320
+ <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.', 'woo_ce' ); ?></p>
321
+ <?php
322
+ ob_end_flush();
323
+ }
324
+ }
325
+
326
+ }
327
+
328
+ // List of WordPress Plugins that Product Importer Deluxe integrates with
329
+ function woo_ce_modules_list( $modules = array() ) {
330
+
331
+ $modules[] = array(
332
+ 'name' => 'aioseop',
333
+ 'title' => __( 'All in One SEO Pack', 'woo_ce' ),
334
+ 'description' => __( 'Optimize your WooCommerce Products for Search Engines. Requires Store Toolkit for All in One SEO Pack integration.', 'woo_ce' ),
335
+ 'url' => 'http://wordpress.org/extend/plugins/all-in-one-seo-pack/',
336
+ 'slug' => 'all-in-one-seo-pack',
337
+ 'function' => 'aioseop_activate'
338
+ );
339
+ $modules[] = array(
340
+ 'name' => 'store_toolkit',
341
+ 'title' => __( 'Store Toolkit', 'woo_ce' ),
342
+ 'description' => __( 'Store Toolkit includes a growing set of commonly-used WooCommerce administration tools aimed at web developers and store maintainers.', 'woo_ce' ),
343
+ 'url' => 'http://wordpress.org/extend/plugins/woocommerce-store-toolkit/',
344
+ 'slug' => 'woocommerce-store-toolkit',
345
+ 'function' => 'woo_st_admin_init'
346
+ );
347
+ $modules[] = array(
348
+ 'name' => 'ultimate_seo',
349
+ 'title' => __( 'SEO Ultimate', 'woo_ce' ),
350
+ 'description' => __( 'This all-in-one SEO plugin gives you control over Product details.', 'woo_ce' ),
351
+ 'url' => 'http://wordpress.org/extend/plugins/seo-ultimate/',
352
+ 'slug' => 'seo-ultimate',
353
+ 'function' => 'su_wp_incompat_notice'
354
+ );
355
+ $modules[] = array(
356
+ 'name' => 'gpf',
357
+ 'title' => __( 'Advanced Google Product Feed', 'woo_ce' ),
358
+ 'description' => __( 'Easily configure data to be added to your Google Merchant Centre feed.', 'woo_ce' ),
359
+ 'url' => 'http://www.leewillis.co.uk/wordpress-plugins/',
360
+ 'function' => 'woocommerce_gpf_install'
361
+ );
362
+ $modules[] = array(
363
+ 'name' => 'wpseo',
364
+ 'title' => __( 'WordPress SEO by Yoast', 'woo_ce' ),
365
+ 'description' => __( 'The first true all-in-one SEO solution for WordPress.', 'woo_ce' ),
366
+ 'url' => 'http://yoast.com/wordpress/seo/#utm_source=wpadmin&utm_medium=plugin&utm_campaign=wpseoplugin',
367
+ 'slug' => 'wordpress-seo',
368
+ 'function' => 'wpseo_admin_init'
369
+ );
370
+ $modules[] = array(
371
+ 'name' => 'msrp',
372
+ 'title' => __( 'WooCommerce MSRP Pricing', 'woo_ce' ),
373
+ 'description' => __( 'Define and display MSRP prices (Manufacturer\'s suggested retail price) to your customers.', 'woo_ce' ),
374
+ 'url' => 'http://www.woothemes.com/products/msrp-pricing/',
375
+ 'function' => 'woocommerce_msrp_activate'
376
+ );
377
+ $modules[] = array(
378
+ 'name' => 'wc_brands',
379
+ 'title' => __( 'WooCommerce Brands Addon', 'woo_ce' ),
380
+ 'description' => __( 'Create, assign and list brands for products, and allow customers to filter by brand.', 'woo_ce' ),
381
+ 'url' => 'http://www.woothemes.com/products/brands/',
382
+ 'class' => 'WC_Brands'
383
+ );
384
+ $modules[] = array(
385
+ 'name' => 'wc_cog',
386
+ 'title' => __( 'Cost of Goods', 'woo_ce' ),
387
+ 'description' => __( 'Easily track total profit and cost of goods by adding a Cost of Good field to simple and variable products.', 'woo_ce' ),
388
+ 'url' => 'http://www.skyverge.com/product/woocommerce-cost-of-goods-tracking/',
389
+ 'class' => 'WC_COG'
390
+ );
391
+ $modules[] = array(
392
+ 'name' => 'per_product_shipping',
393
+ 'title' => __( 'Per-Product Shipping', 'woo_ce' ),
394
+ 'description' => __( 'Define separate shipping costs per product which are combined at checkout to provide a total shipping cost.', 'woo_ce' ),
395
+ 'url' => 'http://www.woothemes.com/products/per-product-shipping/',
396
+ 'function' => 'woocommerce_per_product_shipping_init'
397
+ );
398
+ $modules[] = array(
399
+ 'name' => 'vendors',
400
+ 'title' => __( 'Product Vendors', 'woo_ce' ),
401
+ 'description' => __( 'Turn your store into a multi-vendor marketplace (such as Etsy or Creative Market).', 'woo_ce' ),
402
+ 'url' => 'http://www.woothemes.com/products/product-vendors/',
403
+ 'class' => 'WooCommerce_Product_Vendors'
404
+ );
405
+ $modules[] = array(
406
+ 'name' => 'acf',
407
+ 'title' => __( 'Advanced Custom Fields', 'woo_ce' ),
408
+ 'description' => __( 'Powerful fields for WordPress developers.', 'woo_ce' ),
409
+ 'url' => 'http://www.advancedcustomfields.com',
410
+ 'class' => 'acf'
411
+ );
412
+ $modules[] = array(
413
+ 'name' => 'product_addons',
414
+ 'title' => __( 'Product Add-ons', 'woo_ce' ),
415
+ 'description' => __( 'Allow your customers to customise your products by adding input boxes, dropdowns or a field set of checkboxes.', 'woo_ce' ),
416
+ 'url' => 'http://www.woothemes.com/products/product-add-ons/',
417
+ 'class' => 'Product_Addon_Admin'
418
+ );
419
+ $modules[] = array(
420
+ 'name' => 'seq',
421
+ 'title' => __( 'WooCommerce Sequential Order Numbers', 'woo_ce' ),
422
+ 'description' => __( 'This plugin extends the WooCommerce e-commerce plugin by setting sequential order numbers for new orders.', 'woo_ce' ),
423
+ 'url' => 'https://wordpress.org/plugins/woocommerce-sequential-order-numbers/',
424
+ 'slug' => 'woocommerce-sequential-order-numbers',
425
+ 'class' => 'WC_Seq_Order_Number'
426
+ );
427
+ $modules[] = array(
428
+ 'name' => 'seq_pro',
429
+ 'title' => __( 'WooCommerce Sequential Order Numbers Pro', 'woo_ce' ),
430
+ 'description' => __( 'Tame your WooCommerce Order Numbers.', 'woo_ce' ),
431
+ 'url' => 'http://www.woothemes.com/products/sequential-order-numbers-pro/',
432
+ 'class' => 'WC_Seq_Order_Number'
433
+ );
434
+ $modules[] = array(
435
+ 'name' => 'print_invoice_delivery_note',
436
+ 'title' => __( 'WooCommerce Print Invoice & Delivery Note', 'woo_ce' ),
437
+ 'description' => __( 'Print invoices and delivery notes for WooCommerce orders.', 'woo_ce' ),
438
+ 'url' => 'http://wordpress.org/plugins/woocommerce-delivery-notes/',
439
+ 'slug' => 'woocommerce-delivery-notes',
440
+ 'class' => 'WooCommerce_Delivery_Notes'
441
+ );
442
+ $modules[] = array(
443
+ 'name' => 'pdf_invoices_packing_slips',
444
+ 'title' => __( 'WooCommerce PDF Invoices & Packing Slips', 'woo_ce' ),
445
+ 'description' => __( 'Create, print & automatically email PDF invoices & packing slips for WooCommerce orders.', 'woo_ce' ),
446
+ 'url' => 'https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/',
447
+ 'slug' => 'woocommerce-pdf-invoices-packing-slips',
448
+ 'class' => 'WooCommerce_PDF_Invoices'
449
+ );
450
+ $modules[] = array(
451
+ 'name' => 'checkout_manager',
452
+ 'title' => __( 'WooCommerce Checkout Manager', 'woo_ce' ),
453
+ 'description' => __( 'Manages WooCommerce Checkout.', 'woo_ce' ),
454
+ 'url' => 'http://wordpress.org/plugins/woocommerce-checkout-manager/',
455
+ 'slug' => 'woocommerce-checkout-manager',
456
+ 'function' => 'wccs_install'
457
+ );
458
+ $modules[] = array(
459
+ 'name' => 'checkout_manager_pro',
460
+ 'title' => __( 'WooCommerce Checkout Manager Pro', 'woo_ce' ),
461
+ 'description' => __( 'Manages the WooCommerce Checkout page and WooCommerce Checkout processes.', 'woo_ce' ),
462
+ 'url' => 'http://www.trottyzone.com/product/woocommerce-checkout-manager-pro',
463
+ 'function' => 'wccs_install'
464
+ );
465
+ $modules[] = array(
466
+ 'name' => 'pgsk',
467
+ 'title' => __( 'Poor Guys Swiss Knife', 'woo_ce' ),
468
+ 'description' => __( 'A Swiss Knife for WooCommerce.', 'woo_ce' ),
469
+ 'url' => 'http://wordpress.org/plugins/woocommerce-poor-guys-swiss-knife/',
470
+ 'slug' => 'woocommerce-poor-guys-swiss-knife',
471
+ 'function' => 'wcpgsk_init'
472
+ );
473
+ $modules[] = array(
474
+ 'name' => 'checkout_field_editor',
475
+ 'title' => __( 'Checkout Field Editor', 'woo_ce' ),
476
+ 'description' => __( 'Add, edit and remove fields shown on your WooCommerce checkout page.', 'woo_ce' ),
477
+ 'url' => 'http://www.woothemes.com/products/woocommerce-checkout-field-editor/',
478
+ 'function' => 'woocommerce_init_checkout_field_editor'
479
+ );
480
+ $modules[] = array(
481
+ 'name' => 'checkout_field_manager',
482
+ 'title' => __( 'Checkout Field Manager', 'woo_ce' ),
483
+ 'description' => __( 'Quickly and effortlessly add, remove and re-orders fields in the checkout process.', 'woo_ce' ),
484
+ 'url' => 'http://61extensions.com/shop/woocommerce-checkout-field-manager/',
485
+ 'function' => 'sod_woocommerce_checkout_manager_settings'
486
+ );
487
+ $modules[] = array(
488
+ 'name' => 'checkout_addons',
489
+ 'title' => __( 'WooCommerce Checkout Add-Ons', 'woo_ce' ),
490
+ 'description' => __( 'Add fields at checkout for add-on products and services while optionally setting a cost for each add-on.', 'woo_ce' ),
491
+ 'url' => 'http://www.skyverge.com/product/woocommerce-checkout-add-ons/',
492
+ 'function' => 'init_woocommerce_checkout_add_ons'
493
+ );
494
+ $modules[] = array(
495
+ 'name' => 'local_pickup_plus',
496
+ 'title' => __( 'Local Pickup Plus', 'woo_ce' ),
497
+ 'description' => __( 'Let customers pick up products from specific locations.', 'woo_ce' ),
498
+ 'url' => 'http://www.woothemes.com/products/local-pickup-plus/',
499
+ 'class' => 'WC_Local_Pickup_Plus'
500
+ );
501
+ $modules[] = array(
502
+ 'name' => 'gravity_forms',
503
+ 'title' => __( 'Gravity Forms', 'woo_ce' ),
504
+ 'description' => __( 'Gravity Forms is hands down the best contact form plugin for WordPress powered websites.', 'woo_ce' ),
505
+ 'url' => 'http://woothemes.com/woocommerce',
506
+ 'class' => 'RGForms'
507
+ );
508
+ $modules[] = array(
509
+ 'name' => 'currency_switcher',
510
+ 'title' => __( 'WooCommerce Currency Switcher', 'woo_ce' ),
511
+ 'description' => __( 'Currency Switcher for WooCommerce allows your shop to display prices and accept payments in multiple currencies.', 'woo_ce' ),
512
+ 'url' => 'http://aelia.co/shop/currency-switcher-woocommerce/',
513
+ 'class' => 'WC_Aelia_CurrencySwitcher'
514
+ );
515
+ $modules[] = array(
516
+ 'name' => 'subscriptions',
517
+ 'title' => __( 'WooCommerce Subscriptions', 'woo_ce' ),
518
+ 'description' => __( 'WC Subscriptions makes it easy to create and manage products with recurring payments.', 'woo_ce' ),
519
+ 'url' => 'http://www.woothemes.com/products/woocommerce-subscriptions/',
520
+ 'class' => 'WC_Subscriptions_Manager'
521
+ );
522
+
523
+ /*
524
+ $modules[] = array(
525
+ 'name' => '',
526
+ 'title' => __( '', 'woo_ce' ),
527
+ 'description' => __( '', 'woo_ce' ),
528
+ 'url' => '',
529
+ 'slug' => '', // Define this if the Plugin is hosted on the WordPress repo
530
+ 'function' => ''
531
+ );
532
+ */
533
+
534
+ $modules = apply_filters( 'woo_ce_modules_addons', $modules );
535
+
536
+ if( !empty( $modules ) ) {
537
+ foreach( $modules as $key => $module ) {
538
+ $modules[$key]['status'] = 'inactive';
539
+ // Check if each module is activated
540
+ if( isset( $module['function'] ) ) {
541
+ if( function_exists( $module['function'] ) )
542
+ $modules[$key]['status'] = 'active';
543
+ } else if( isset( $module['class'] ) ) {
544
+ if( class_exists( $module['class'] ) )
545
+ $modules[$key]['status'] = 'active';
546
+ }
547
+ // Check if the Plugin has a slug and if current user can install Plugins
548
+ if( current_user_can( 'install_plugins' ) && isset( $module['slug'] ) )
549
+ $modules[$key]['url'] = admin_url( sprintf( 'plugin-install.php?tab=search&type=tag&s=%s', $module['slug'] ) );
550
+ }
551
+ }
552
+ return $modules;
553
+
554
+ }
555
+
556
+ function woo_ce_modules_status_class( $status = 'inactive' ) {
557
+
558
+ $output = '';
559
+ switch( $status ) {
560
+
561
+ case 'active':
562
+ $output = 'green';
563
+ break;
564
+
565
+ case 'inactive':
566
+ $output = 'yellow';
567
+ break;
568
+
569
+ }
570
+ echo $output;
571
+
572
+ }
573
+
574
+ function woo_ce_modules_status_label( $status = 'inactive' ) {
575
+
576
+ $output = '';
577
+ switch( $status ) {
578
+
579
+ case 'active':
580
+ $output = __( 'OK', 'woo_ce' );
581
+ break;
582
+
583
+ case 'inactive':
584
+ $output = __( 'Install', 'woo_ce' );
585
+ break;
586
+
587
+ }
588
+ echo $output;
589
+
590
+ }
591
+
592
+ // HTML template for header prompt on Store Exporter screen
593
+ function woo_ce_support_donate() {
594
+
595
+ $output = '';
596
+ $show = true;
597
+ if( function_exists( 'woo_vl_we_love_your_plugins' ) ) {
598
+ if( in_array( WOO_CE_DIRNAME, woo_vl_we_love_your_plugins() ) )
599
+ $show = false;
600
+ }
601
+ if( $show ) {
602
+ $donate_url = 'http://www.visser.com.au/donate/';
603
+ $rate_url = 'http://wordpress.org/support/view/plugin-reviews/' . WOO_CE_DIRNAME;
604
+ $output = '
605
+ <div id="support-donate_rate" class="support-donate_rate">
606
+ <p>' . sprintf( __( '<strong>Like this Plugin?</strong> %s and %s.', 'woo_ce' ), '<a href="' . $donate_url . '" target="_blank">' . __( 'Donate to support this Plugin', 'woo_ce' ) . '</a>', '<a href="' . add_query_arg( array( 'rate' => '5' ), $rate_url ) . '#postform" target="_blank">rate / review us on WordPress.org</a>' ) . '</p>
607
+ </div>
608
+ ';
609
+ }
610
+ echo $output;
611
+
612
+ }
613
+ ?>
includes/brands.php ADDED
@@ -0,0 +1,114 @@
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_brands_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', 'woo_ce' ); ?></label></p>
14
+ <div>
15
+ <select name="brand_orderby" disabled="disabled">
16
+ <option value="id"><?php _e( 'Term ID', 'woo_ce' ); ?></option>
17
+ <option value="name"><?php _e( 'Brand Name', 'woo_ce' ); ?></option>
18
+ </select>
19
+ <select name="brand_order" disabled="disabled">
20
+ <option value="ASC"><?php _e( 'Ascending', 'woo_ce' ); ?></option>
21
+ <option value="DESC"><?php _e( 'Descending', 'woo_ce' ); ?></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.', 'woo_ce' ); ?></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', 'woo_ce' )
43
+ );
44
+ $fields[] = array(
45
+ 'name' => 'name',
46
+ 'label' => __( 'Brand Name', 'woo_ce' )
47
+ );
48
+ $fields[] = array(
49
+ 'name' => 'slug',
50
+ 'label' => __( 'Brand Slug', 'woo_ce' )
51
+ );
52
+ $fields[] = array(
53
+ 'name' => 'parent_id',
54
+ 'label' => __( 'Parent Term ID', 'woo_ce' )
55
+ );
56
+ $fields[] = array(
57
+ 'name' => 'description',
58
+ 'label' => __( 'Brand Description', 'woo_ce' )
59
+ );
60
+ $fields[] = array(
61
+ 'name' => 'image',
62
+ 'label' => __( 'Brand Image', 'woo_ce' )
63
+ );
64
+
65
+ /*
66
+ $fields[] = array(
67
+ 'name' => '',
68
+ 'label' => __( '', 'woo_ce' )
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]['order'] = ( isset( $sorting[$fields[$i]['name']] ) ? $sorting[$fields[$i]['name']] : $i );
93
+ usort( $fields, woo_ce_sort_fields( 'order' ) );
94
+ return $fields;
95
+ break;
96
+
97
+ }
98
+
99
+ }
100
+
101
+ function woo_ce_override_brand_field_labels( $fields = array() ) {
102
+
103
+ $labels = woo_ce_get_option( 'brand_labels', array() );
104
+ if( !empty( $labels ) ) {
105
+ foreach( $fields as $key => $field ) {
106
+ if( isset( $labels[$field['name']] ) )
107
+ $fields[$key]['label'] = $labels[$field['name']];
108
+ }
109
+ }
110
+ return $fields;
111
+
112
+ }
113
+ add_filter( 'woo_ce_brand_fields', 'woo_ce_override_brand_field_labels', 11 );
114
+ ?>
includes/categories.php ADDED
@@ -0,0 +1,197 @@
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_order_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', 'woo_ce' ); ?></label></p>
14
+ <div>
15
+ <select name="category_orderby">
16
+ <option value="id"<?php selected( 'id', $category_orderby ); ?>><?php _e( 'Term ID', 'woo_ce' ); ?></option>
17
+ <option value="name"<?php selected( 'name', $category_orderby ); ?>><?php _e( 'Category Name', 'woo_ce' ); ?></option>
18
+ </select>
19
+ <select name="category_order">
20
+ <option value="ASC"<?php selected( 'ASC', $category_order ); ?>><?php _e( 'Ascending', 'woo_ce' ); ?></option>
21
+ <option value="DESC"<?php selected( 'DESC', $category_order ); ?>><?php _e( 'Descending', 'woo_ce' ); ?></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.', 'woo_ce' ); ?></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', 'woo_ce' )
43
+ );
44
+ $fields[] = array(
45
+ 'name' => 'name',
46
+ 'label' => __( 'Category Name', 'woo_ce' )
47
+ );
48
+ $fields[] = array(
49
+ 'name' => 'slug',
50
+ 'label' => __( 'Category Slug', 'woo_ce' )
51
+ );
52
+ $fields[] = array(
53
+ 'name' => 'parent_id',
54
+ 'label' => __( 'Parent Term ID', 'woo_ce' )
55
+ );
56
+ $fields[] = array(
57
+ 'name' => 'description',
58
+ 'label' => __( 'Category Description', 'woo_ce' )
59
+ );
60
+ $fields[] = array(
61
+ 'name' => 'display_type',
62
+ 'label' => __( 'Display Type', 'woo_ce' )
63
+ );
64
+ $fields[] = array(
65
+ 'name' => 'image',
66
+ 'label' => __( 'Category Image', 'woo_ce' )
67
+ );
68
+
69
+ /*
70
+ $fields[] = array(
71
+ 'name' => '',
72
+ 'label' => __( '', 'woo_ce' )
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]['order'] = ( isset( $sorting[$fields[$i]['name']] ) ? $sorting[$fields[$i]['name']] : $i );
108
+ usort( $fields, woo_ce_sort_fields( 'order' ) );
109
+ return $fields;
110
+ break;
111
+
112
+ }
113
+
114
+ }
115
+
116
+ function woo_ce_override_category_field_labels( $fields = array() ) {
117
+
118
+ $labels = woo_ce_get_option( 'category_labels', array() );
119
+ if( !empty( $labels ) ) {
120
+ foreach( $fields as $key => $field ) {
121
+ if( isset( $labels[$field['name']] ) )
122
+ $fields[$key]['label'] = $labels[$field['name']];
123
+ }
124
+ }
125
+ return $fields;
126
+
127
+ }
128
+ add_filter( 'woo_ce_category_fields', 'woo_ce_override_category_field_labels', 11 );
129
+
130
+ // Returns the export column header label based on an export column slug
131
+ function woo_ce_get_category_field( $name = null, $format = 'name' ) {
132
+
133
+ $output = '';
134
+ if( $name ) {
135
+ $fields = woo_ce_get_category_fields();
136
+ $size = count( $fields );
137
+ for( $i = 0; $i < $size; $i++ ) {
138
+ if( $fields[$i]['name'] == $name ) {
139
+ switch( $format ) {
140
+
141
+ case 'name':
142
+ $output = $fields[$i]['label'];
143
+ break;
144
+
145
+ case 'full':
146
+ $output = $fields[$i];
147
+ break;
148
+
149
+ }
150
+ $i = $size;
151
+ }
152
+ }
153
+ }
154
+ return $output;
155
+
156
+ }
157
+
158
+ // Returns a list of WooCommerce Product Categories to export process
159
+ function woo_ce_get_product_categories( $args = array() ) {
160
+
161
+ $term_taxonomy = 'product_cat';
162
+ $defaults = array(
163
+ 'orderby' => 'name',
164
+ 'order' => 'ASC',
165
+ 'hide_empty' => 0
166
+ );
167
+ $args = wp_parse_args( $args, $defaults );
168
+ $categories = get_terms( $term_taxonomy, $args );
169
+ if( !empty( $categories ) && is_wp_error( $categories ) == false ) {
170
+ foreach( $categories as $key => $category ) {
171
+ $categories[$key]->parent_name = '';
172
+ if( $categories[$key]->parent_id = $category->parent ) {
173
+ if( $parent_category = get_term( $categories[$key]->parent_id, $term_taxonomy ) ) {
174
+ $categories[$key]->parent_name = $parent_category->name;
175
+ }
176
+ unset( $parent_category );
177
+ } else {
178
+ $categories[$key]->parent_id = '';
179
+ }
180
+ $categories[$key]->image = woo_ce_get_category_thumbnail_url( $category->term_id );
181
+ $categories[$key]->display_type = get_woocommerce_term_meta( $category->term_id, 'display_type', true );
182
+ }
183
+ return $categories;
184
+ }
185
+
186
+ }
187
+
188
+ function woo_ce_get_category_thumbnail_url( $category_id = 0, $size = 'full' ) {
189
+
190
+ if ( $thumbnail_id = get_woocommerce_term_meta( $category_id, 'thumbnail_id', true ) ) {
191
+ $image_attributes = wp_get_attachment_image_src( $thumbnail_id, $size );
192
+ if( is_array( $image_attributes ) )
193
+ return current( $image_attributes );
194
+ }
195
+
196
+ }
197
+ ?>
includes/common-dashboard_widgets.php ADDED
@@ -0,0 +1,52 @@
1
+ <?php
2
+ /*
3
+
4
+ Filename: common-dashboard_widgets.php
5
+ Description: common-dashboard_widgets.php loads commonly access Dashboard widgets across the Visser Labs suite.
6
+ Version: 1.3
7
+
8
+ */
9
+
10
+ /* Start of: WooCommerce News - by Visser Labs */
11
+
12
+ if( !function_exists( 'woo_vl_dashboard_setup' ) ) {
13
+
14
+ function woo_vl_dashboard_setup() {
15
+
16
+ wp_add_dashboard_widget( 'woo_vl_news_widget', __( 'Plugin News - by Visser Labs', 'woo_vl' ), 'woo_vl_news_widget' );
17
+
18
+ }
19
+ add_action( 'wp_dashboard_setup', 'woo_vl_dashboard_setup' );
20
+
21
+ function woo_vl_news_widget() {
22
+
23
+ include_once( ABSPATH . WPINC . '/feed.php' );
24
+
25
+ $rss = fetch_feed( 'http://www.visser.com.au/blog/category/woocommerce/feed/' );
26
+ $output = '<div class="rss-widget">';
27
+ if( !is_wp_error( $rss ) ) {
28
+ $maxitems = $rss->get_item_quantity( 5 );
29
+ $rss_items = $rss->get_items( 0, $maxitems );
30
+ $output .= '<ul>';
31
+ foreach ( $rss_items as $item ) :
32
+ $output .= '<li>';
33
+ $output .= '<a href="' . $item->get_permalink() . '" title="' . 'Posted ' . $item->get_date( 'j F Y | g:i a' ) . '" class="rsswidget">' . $item->get_title() . '</a>';
34
+ $output .= '<span class="rss-date">' . $item->get_date( 'j F, Y' ) . '</span>';
35
+ $output .= '<div class="rssSummary">' . $item->get_description() . '</div>';
36
+ $output .= '</li>';
37
+ endforeach;
38
+ $output .= '</ul>';
39
+ } else {
40
+ $message = __( 'Connection failed. Please check your network settings.', 'woo_vl' );
41
+ $output .= '<p>' . $message . '</p>';
42
+ }
43
+ $output .= '</div>';
44
+
45
+ echo $output;
46
+
47
+ }
48
+
49
+ }
50
+
51
+ /* End of: WooCommerce News - by Visser Labs */
52
+ ?>
includes/coupons.php ADDED
@@ -0,0 +1,187 @@
1
+ <?php
2
+ if( is_admin() ) {
3
+
4
+ /* Start of: WordPress Administration */
5
+
6
+ // HTML template for disabled Coupon Sorting widget on Store Exporter screen
7
+ function woo_ce_coupons_coupon_sorting() {
8
+
9
+ ob_start(); ?>
10
+ <p><label><?php _e( 'Coupon Sorting', 'woo_ce' ); ?></label></p>
11
+ <div>
12
+ <select name="coupon_orderby" disabled="disabled">
13
+ <option value="ID"><?php _e( 'Coupon ID', 'woo_ce' ); ?></option>
14
+ <option value="title"><?php _e( 'Coupon Code', 'woo_ce' ); ?></option>
15
+ <option value="date"><?php _e( 'Date Created', 'woo_ce' ); ?></option>
16
+ <option value="modified"><?php _e( 'Date Modified', 'woo_ce' ); ?></option>
17
+ <option value="rand"><?php _e( 'Random', 'woo_ce' ); ?></option>
18
+ </select>
19
+ <select name="coupon_order" disabled="disabled">
20
+ <option value="ASC"><?php _e( 'Ascending', 'woo_ce' ); ?></option>
21
+ <option value="DESC"><?php _e( 'Descending', 'woo_ce' ); ?></option>
22
+ </select>
23
+ <p class="description"><?php _e( 'Select the sorting of Coupons within the exported file. By default this is set to export Coupons by Coupon ID in Desending order.', 'woo_ce' ); ?></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 Coupon export columns
35
+ function woo_ce_get_coupon_fields( $format = 'full' ) {
36
+
37
+ $export_type = 'coupon';
38
+
39
+ $fields = array();
40
+ $fields[] = array(
41
+ 'name' => 'coupon_code',
42
+ 'label' => __( 'Coupon Code', 'woo_ce' )
43
+ );
44
+ $fields[] = array(
45
+ 'name' => 'coupon_description',
46
+ 'label' => __( 'Coupon Description', 'woo_ce' )
47
+ );
48
+ $fields[] = array(
49
+ 'name' => 'discount_type',
50
+ 'label' => __( 'Discount Type', 'woo_ce' )
51
+ );
52
+ $fields[] = array(
53
+ 'name' => 'coupon_amount',
54
+ 'label' => __( 'Coupon Amount', 'woo_ce' )
55
+ );
56
+ $fields[] = array(
57
+ 'name' => 'individual_use',
58
+ 'label' => __( 'Individual Use', 'woo_ce' )
59
+ );
60
+ $fields[] = array(
61
+ 'name' => 'apply_before_tax',
62
+ 'label' => __( 'Apply before tax', 'woo_ce' )
63
+ );
64
+ $fields[] = array(
65
+ 'name' => 'exclude_sale_items',
66
+ 'label' => __( 'Exclude sale items', 'woo_ce' )
67
+ );
68
+ $fields[] = array(
69
+ 'name' => 'minimum_amount',
70
+ 'label' => __( 'Minimum Amount', 'woo_ce' )
71
+ );
72
+ $fields[] = array(
73
+ 'name' => 'product_ids',
74
+ 'label' => __( 'Products', 'woo_ce' )
75
+ );
76
+ $fields[] = array(
77
+ 'name' => 'exclude_product_ids',
78
+ 'label' => __( 'Exclude Products', 'woo_ce' )
79
+ );
80
+ $fields[] = array(
81
+ 'name' => 'product_categories',
82
+ 'label' => __( 'Product Categories', 'woo_ce' )
83
+ );
84
+ $fields[] = array(
85
+ 'name' => 'exclude_product_categories',
86
+ 'label' => __( 'Exclude Product Categories', 'woo_ce' )
87
+ );
88
+ $fields[] = array(
89
+ 'name' => 'customer_email',
90
+ 'label' => __( 'Customer e-mails', 'woo_ce' )
91
+ );
92
+ $fields[] = array(
93
+ 'name' => 'usage_limit',
94
+ 'label' => __( 'Usage Limit', 'woo_ce' )
95
+ );
96
+ $fields[] = array(
97
+ 'name' => 'expiry_date',
98
+ 'label' => __( 'Expiry Date', 'woo_ce' )
99
+ );
100
+
101
+ /*
102
+ $fields[] = array(
103
+ 'name' => '',
104
+ 'label' => __( '', 'woo_ce' )
105
+ );
106
+ */
107
+
108
+ // Allow Plugin/Theme authors to add support for additional columns
109
+ $fields = apply_filters( 'woo_ce_' . $export_type . '_fields', $fields, $export_type );
110
+
111
+ switch( $format ) {
112
+
113
+ case 'summary':
114
+ $output = array();
115
+ $size = count( $fields );
116
+ for( $i = 0; $i < $size; $i++ ) {
117
+ if( isset( $fields[$i] ) )
118
+ $output[$fields[$i]['name']] = 'on';
119
+ }
120
+ return $output;
121
+ break;
122
+
123
+ case 'full':
124
+ default:
125
+ $sorting = woo_ce_get_option( $export_type . '_sorting', array() );
126
+ $size = count( $fields );
127
+ for( $i = 0; $i < $size; $i++ )
128
+ $fields[$i]['order'] = ( isset( $sorting[$fields[$i]['name']] ) ? $sorting[$fields[$i]['name']] : $i );
129
+ usort( $fields, woo_ce_sort_fields( 'order' ) );
130
+ return $fields;
131
+ break;
132
+
133
+ }
134
+
135
+ }
136
+
137
+ function woo_ce_override_coupon_field_labels( $fields = array() ) {
138
+
139
+ $labels = woo_ce_get_option( 'coupon_labels', array() );
140
+ if( !empty( $labels ) ) {
141
+ foreach( $fields as $key => $field ) {
142
+ if( isset( $labels[$field['name']] ) )
143
+ $fields[$key]['label'] = $labels[$field['name']];
144
+ }
145
+ }
146
+ return $fields;
147
+
148
+ }
149
+ add_filter( 'woo_ce_coupon_fields', 'woo_ce_override_coupon_field_labels', 11 );
150
+
151
+ // Returns a list of Coupon IDs
152
+ function woo_ce_get_coupons( $args = array() ) {
153
+
154
+ global $export;
155
+
156
+ $limit_volume = -1;
157
+ $offset = 0;
158
+
159
+ if( $args ) {
160
+ $limit_volume = ( isset( $args['limit_volume'] ) ? $args['limit_volume'] : false );
161
+ $offset = ( isset( $args['offset'] ) ? $args['offset'] : false );
162
+ $orderby = ( isset( $args['coupon_orderby'] ) ? $args['coupon_orderby'] : 'ID' );
163
+ $order = ( isset( $args['coupon_order'] ) ? $args['coupon_order'] : 'ASC' );
164
+ }
165
+
166
+ $post_type = 'shop_coupon';
167
+ $args = array(
168
+ 'post_type' => $post_type,
169
+ 'orderby' => $orderby,
170
+ 'order' => $order,
171
+ 'offset' => $offset,
172
+ 'posts_per_page' => $limit_volume,
173
+ 'post_status' => woo_ce_post_statuses(),
174
+ 'fields' => 'ids'
175
+ );
176
+ $coupons = array();
177
+ $coupon_ids = new WP_Query( $args );
178
+ if( $coupon_ids->posts ) {
179
+ foreach( $coupon_ids->posts as $coupon_id )
180
+ $coupons[] = $coupon_id;
181
+ unset( $coupon_ids, $coupon_id );
182
+ }
183
+ return $coupons;
184
+
185
+ }
186
+
187
+ ?>
includes/customers.php ADDED
@@ -0,0 +1,210 @@
1
+ <?php
2
+ if( is_admin() ) {
3
+
4
+ /* Start of: WordPress Administration */
5
+
6
+ // HTML template for disabled Filter Customers by Order Status widget on Store Exporter screen
7
+ function woo_ce_customers_filter_by_status() {
8
+
9
+ $woo_cd_url = 'http://www.visser.com.au/woocommerce/plugins/exporter-deluxe/';
10
+ $woo_cd_link = sprintf( '<a href="%s" target="_blank">' . __( 'Store Exporter Deluxe', 'woo_ce' ) . '</a>', $woo_cd_url );
11
+
12
+ $order_statuses = woo_ce_get_order_statuses();
13
+
14
+ ob_start(); ?>
15
+ <p><label><input type="checkbox" id="customers-filters-status" /> <?php _e( 'Filter Customers by Order Status', 'woo_ce' ); ?><span class="description"> - <?php printf( __( 'available in %s', 'woo_ce' ), $woo_cd_link ); ?></span></label></p>
16
+ <div id="export-customers-filters-status" class="separator">
17
+ <ul>
18
+ <?php if( $order_statuses ) { ?>
19
+ <?php foreach( $order_statuses as $order_status ) { ?>
20
+ <li><label><input type="checkbox" name="customer_filter_status[<?php echo $order_status->name; ?>]" value="<?php echo $order_status->name; ?>" disabled="disabled" /> <?php echo ucfirst( $order_status->name ); ?></label></li>
21
+ <?php } ?>
22
+ <?php } else { ?>
23
+ <li><?php _e( 'No Order Status\'s were found.', 'jigo_ce' ); ?></li>
24
+ <?php } ?>
25
+ </ul>
26
+ <p class="description"><?php _e( 'Select the Order Status you want to filter exported Customers by. Default is to include all Order Status options.', 'woo_ce' ); ?></p>
27
+ </div>
28
+ <!-- #export-customers-filters-status -->
29
+ <?php
30
+ ob_end_flush();
31
+
32
+ }
33
+
34
+ /* End of: WordPress Administration */
35
+
36
+ }
37
+
38
+ // Returns a list of Customer export columns
39
+ function woo_ce_get_customer_fields( $format = 'full' ) {
40
+
41
+ $export_type = 'customer';
42
+
43
+ $fields = array();
44
+ $fields[] = array(
45
+ 'name' => 'user_id',
46
+ 'label' => __( 'User ID', 'woo_ce' )
47
+ );
48
+ $fields[] = array(
49
+ 'name' => 'user_name',
50
+ 'label' => __( 'Usernam