WooCommerce – Store Exporter - Version 1.8.2

Version Description

  • Added: Order support for Extra Product Options
  • Fixed: Detect corrupted Date Format
  • Added: Detection of corrupted WordPress options at export time
  • Added: Total Sales to Products export
  • Fixed: Advanced Google Product Feed not being included in Products export
  • Added: Custom User meta to Customers export
  • Added: Support for exporting Shipping Classes
  • Changed: Product URL is now External URL
  • Added: Product URL is the absolute URL to the Product
  • Added: Support for custom User fields
  • Fixed: Admin notice not showing for saving custom fields
Download this release

Release Info

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

Version 1.8.2

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