Export WordPress data to XML/CSV - Version 1.0.1

Version Description

  • fixed export taxonomy: name instead of slug
  • fixed pass data through php function
  • added advanced (custom fields) section to export woo orders
  • added draggable element deletion
  • added auto-generate product export fields
  • added 'attributes' field to product data
  • added button to download bundle for WP All Import
  • updated export file name
  • changed export files destination to /exports
Download this release

Release Info

Developer soflyy
Plugin Icon 128x128 Export WordPress data to XML/CSV
Version 1.0.1
Comparing to
See all releases

Code changes from version 1.0.0 to 1.0.1

actions/wp_ajax_export_filtering.php CHANGED
@@ -31,7 +31,7 @@ function pmxe_wp_ajax_export_filtering(){
31
  </div>
32
  <div class="wpallexport-collapsed-content">
33
  <div class="wpallexport-free-edition-notice" style="padding: 20px; margin-bottom: 10px;">
34
- <a class="upgrade_link" target="_blank" href="http://www.wpallimport.com/upgrade-to-wp-all-export-pro/?utm_source=wordpress.org&amp;utm_medium=filter-rules&amp;utm_campaign=free+wp+all+export+plugin"><?php _e(' Filtering Options Upgrade to the professional edition of WP All Export to add filtering rules.','wp_all_export_plugin');?></a>
35
  </div>
36
  <div class="wp_all_export_rule_inputs">
37
  <table>
31
  </div>
32
  <div class="wpallexport-collapsed-content">
33
  <div class="wpallexport-free-edition-notice" style="padding: 20px; margin-bottom: 10px;">
34
+ <a class="upgrade_link" target="_blank" href="http://www.wpallimport.com/upgrade-to-wp-all-export-pro/?utm_source=wordpress.org&amp;utm_medium=filter-rules&amp;utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the professional edition of WP All Export to add filtering rules.','wp_all_export_plugin');?></a>
35
  </div>
36
  <div class="wp_all_export_rule_inputs">
37
  <table>
actions/wp_ajax_wpallexport.php CHANGED
@@ -164,8 +164,9 @@ function pmxe_wp_ajax_wpallexport(){
164
 
165
  }
166
 
167
- if ( wp_all_export_is_compatible() and ($exportOptions['is_generate_templates'] or $exportOptions['is_generate_import'])){
168
-
 
169
  $custom_type = (empty($exportOptions['cpt'])) ? 'post' : $exportOptions['cpt'][0];
170
 
171
  $templateOptions = array(
@@ -239,134 +240,136 @@ function pmxe_wp_ajax_wpallexport(){
239
  else
240
  {
241
  wp_all_export_prepare_template_csv($exportOptions, $templateOptions);
242
- }
243
-
244
- $options = $templateOptions + PMXI_Plugin::get_default_import_options();
245
 
246
- if ($exportOptions['is_generate_templates']){
247
 
248
- $template = new PMXI_Template_Record();
249
-
250
- $tpl_options = $options;
251
-
252
- if ( 'csv' == $exportOptions['export_to'] )
253
- {
254
- $tpl_options['delimiter'] = $exportOptions['delimiter'];
255
- }
256
-
257
- $tpl_options['update_all_data'] = 'yes';
258
- $tpl_options['is_update_status'] = 1;
259
- $tpl_options['is_update_title'] = 1;
260
- $tpl_options['is_update_author'] = 1;
261
- $tpl_options['is_update_slug'] = 1;
262
- $tpl_options['is_update_content'] = 1;
263
- $tpl_options['is_update_excerpt'] = 1;
264
- $tpl_options['is_update_dates'] = 1;
265
- $tpl_options['is_update_menu_order'] = 1;
266
- $tpl_options['is_update_parent'] = 1;
267
- $tpl_options['is_update_attachments'] = 1;
268
- $tpl_options['is_update_acf'] = 1;
269
- $tpl_options['update_acf_logic'] = 'full_update';
270
- $tpl_options['acf_list'] = '';
271
- $tpl_options['is_update_product_type'] = 1;
272
- $tpl_options['is_update_attributes'] = 1;
273
- $tpl_options['update_attributes_logic'] = 'full_update';
274
- $tpl_options['attributes_list'] = '';
275
- $tpl_options['is_update_images'] = 1;
276
- $tpl_options['is_update_custom_fields'] = 1;
277
- $tpl_options['update_custom_fields_logic'] = 'full_update';
278
- $tpl_options['custom_fields_list'] = '';
279
- $tpl_options['is_update_categories'] = 1;
280
- $tpl_options['update_categories_logic'] = 'full_update';
281
- $tpl_options['taxonomies_list'] = '';
282
-
283
- $tpl_data = array(
284
- 'name' => $exportOptions['template_name'],
285
- 'is_keep_linebreaks' => 0,
286
- 'is_leave_html' => 0,
287
- 'fix_characters' => 0,
288
- 'options' => $tpl_options,
289
- );
290
-
291
- if ( ! empty($exportOptions['template_name'])) { // save template in database
292
- $template->getByName($exportOptions['template_name'])->set($tpl_data)->save();
293
- }
294
 
 
 
 
295
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
 
297
- // associate exported posts with new import
298
- if ($exportOptions['is_generate_import']){
299
-
300
- $import = new PMXI_Import_Record();
301
 
302
- $import->getById($exportOptions['import_id']);
 
303
 
304
- if ( ! $import->isEmpty() and $import->parent_import_id == 99999 ){
 
 
305
 
306
- $xmlPath = PMXE_Plugin::$session->file;
307
 
308
- $root_element = '';
309
 
310
- $historyPath = PMXE_Plugin::$session->file;
311
 
312
- if ( 'csv' == $exportOptions['export_to'] )
313
- {
314
- $options['delimiter'] = $exportOptions['delimiter'];
315
 
316
- include_once( PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportCsvParse.php' );
317
 
318
- $path_info = pathinfo($xmlPath);
 
 
319
 
320
- $path_parts = explode(DIRECTORY_SEPARATOR, $path_info['dirname']);
321
 
322
- $security_folder = array_pop($path_parts);
323
 
324
- $target = $is_secure_import ? $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXE_Plugin::UPLOADS_DIRECTORY . DIRECTORY_SEPARATOR . $security_folder : $wp_uploads['path'];
325
 
326
- $csv = new PMXI_CsvParser( array( 'filename' => $xmlPath, 'targetDir' => $target ) );
327
-
328
- $historyPath = $csv->xml_path;
329
 
330
- $root_element = 'node';
331
 
332
- }
333
- else
334
- {
335
- $root_element = 'post';
336
- }
337
 
338
- $import->set(array(
339
- //'parent_import_id' => 99999,
340
- 'xpath' => '/' . $root_element,
341
- 'type' => 'upload',
342
- 'options' => $options,
343
- 'root_element' => $root_element,
344
- 'path' => $xmlPath,
345
- 'name' => basename($xmlPath),
346
- 'imported' => 0,
347
- 'created' => 0,
348
- 'updated' => 0,
349
- 'skipped' => 0,
350
- 'deleted' => 0,
351
- 'iteration' => 1,
352
- 'count' => PMXE_Plugin::$session->count
353
- ))->save();
354
 
355
- $history_file = new PMXI_File_Record();
356
- $history_file->set(array(
357
- 'name' => $import->name,
358
- 'import_id' => $import->id,
359
- 'path' => $historyPath,
360
- 'registered_on' => date('Y-m-d H:i:s')
361
- ))->save();
362
 
363
- $exportOptions['import_id'] = $import->id;
364
-
365
- $export->set(array(
366
- 'options' => $exportOptions
367
- ))->save();
368
- }
369
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
370
  }
371
  }
372
 
164
 
165
  }
166
 
167
+ // Generate templa for WP All Import
168
+ if ($exportOptions['is_generate_templates']){
169
+
170
  $custom_type = (empty($exportOptions['cpt'])) ? 'post' : $exportOptions['cpt'][0];
171
 
172
  $templateOptions = array(
240
  else
241
  {
242
  wp_all_export_prepare_template_csv($exportOptions, $templateOptions);
243
+ }
 
 
244
 
245
+ //$template = new PMXI_Template_Record();
246
 
247
+ $tpl_options = $templateOptions;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
249
+ if ( 'csv' == $exportOptions['export_to'] )
250
+ {
251
+ $tpl_options['delimiter'] = $exportOptions['delimiter'];
252
  }
253
+
254
+ $tpl_options['update_all_data'] = 'yes';
255
+ $tpl_options['is_update_status'] = 1;
256
+ $tpl_options['is_update_title'] = 1;
257
+ $tpl_options['is_update_author'] = 1;
258
+ $tpl_options['is_update_slug'] = 1;
259
+ $tpl_options['is_update_content'] = 1;
260
+ $tpl_options['is_update_excerpt'] = 1;
261
+ $tpl_options['is_update_dates'] = 1;
262
+ $tpl_options['is_update_menu_order'] = 1;
263
+ $tpl_options['is_update_parent'] = 1;
264
+ $tpl_options['is_update_attachments'] = 1;
265
+ $tpl_options['is_update_acf'] = 1;
266
+ $tpl_options['update_acf_logic'] = 'full_update';
267
+ $tpl_options['acf_list'] = '';
268
+ $tpl_options['is_update_product_type'] = 1;
269
+ $tpl_options['is_update_attributes'] = 1;
270
+ $tpl_options['update_attributes_logic'] = 'full_update';
271
+ $tpl_options['attributes_list'] = '';
272
+ $tpl_options['is_update_images'] = 1;
273
+ $tpl_options['is_update_custom_fields'] = 1;
274
+ $tpl_options['update_custom_fields_logic'] = 'full_update';
275
+ $tpl_options['custom_fields_list'] = '';
276
+ $tpl_options['is_update_categories'] = 1;
277
+ $tpl_options['update_categories_logic'] = 'full_update';
278
+ $tpl_options['taxonomies_list'] = '';
279
+
280
+ $tpl_data = array(
281
+ 'name' => $exportOptions['template_name'],
282
+ 'is_keep_linebreaks' => 0,
283
+ 'is_leave_html' => 0,
284
+ 'fix_characters' => 0,
285
+ 'options' => $tpl_options,
286
+ );
287
+
288
+ $exportOptions['tpl_data'] = $tpl_data;
289
+
290
+ $export->set(array(
291
+ 'options' => $exportOptions
292
+ ))->save();
293
+
294
+ // if ( ! empty($exportOptions['template_name'])) { // save template in database
295
+ // $template->getByName($exportOptions['template_name'])->set($tpl_data)->save();
296
+ // }
297
 
298
+ }
 
 
 
299
 
300
+ // associate exported posts with new import
301
+ if ( wp_all_export_is_compatible() and $exportOptions['is_generate_import']){
302
 
303
+ $options = $templateOptions + PMXI_Plugin::get_default_import_options();
304
+
305
+ $import = new PMXI_Import_Record();
306
 
307
+ $import->getById($exportOptions['import_id']);
308
 
309
+ if ( ! $import->isEmpty() and $import->parent_import_id == 99999 ){
310
 
311
+ $xmlPath = PMXE_Plugin::$session->file;
312
 
313
+ $root_element = '';
 
 
314
 
315
+ $historyPath = PMXE_Plugin::$session->file;
316
 
317
+ if ( 'csv' == $exportOptions['export_to'] )
318
+ {
319
+ $options['delimiter'] = $exportOptions['delimiter'];
320
 
321
+ include_once( PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportCsvParse.php' );
322
 
323
+ $path_info = pathinfo($xmlPath);
324
 
325
+ $path_parts = explode(DIRECTORY_SEPARATOR, $path_info['dirname']);
326
 
327
+ $security_folder = array_pop($path_parts);
 
 
328
 
329
+ $target = $is_secure_import ? $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXE_Plugin::UPLOADS_DIRECTORY . DIRECTORY_SEPARATOR . $security_folder : $wp_uploads['path'];
330
 
331
+ $csv = new PMXI_CsvParser( array( 'filename' => $xmlPath, 'targetDir' => $target ) );
332
+
333
+ $historyPath = $csv->xml_path;
 
 
334
 
335
+ $root_element = 'node';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336
 
337
+ }
338
+ else
339
+ {
340
+ $root_element = 'post';
341
+ }
 
 
342
 
343
+ $import->set(array(
344
+ 'xpath' => '/' . $root_element,
345
+ 'type' => 'upload',
346
+ 'options' => $options,
347
+ 'root_element' => $root_element,
348
+ 'path' => $xmlPath,
349
+ 'name' => basename($xmlPath),
350
+ 'imported' => 0,
351
+ 'created' => 0,
352
+ 'updated' => 0,
353
+ 'skipped' => 0,
354
+ 'deleted' => 0,
355
+ 'iteration' => 1,
356
+ 'count' => PMXE_Plugin::$session->count
357
+ ))->save();
358
+
359
+ $history_file = new PMXI_File_Record();
360
+ $history_file->set(array(
361
+ 'name' => $import->name,
362
+ 'import_id' => $import->id,
363
+ 'path' => $historyPath,
364
+ 'registered_on' => date('Y-m-d H:i:s')
365
+ ))->save();
366
+
367
+ $exportOptions['import_id'] = $import->id;
368
+
369
+ $export->set(array(
370
+ 'options' => $exportOptions
371
+ ))->save();
372
+ }
373
  }
374
  }
375
 
classes/download.php CHANGED
@@ -6,7 +6,7 @@ class PMXE_Download
6
  static public function zip($file_name)
7
  {
8
 
9
- header('Content-type: application/zip');
10
  header("Content-Disposition: attachment; filename=\"".basename($file_name)."\"");
11
  readfile($file_name);
12
  die;
6
  static public function zip($file_name)
7
  {
8
 
9
+ header('Content-type: application/zip;');
10
  header("Content-Disposition: attachment; filename=\"".basename($file_name)."\"");
11
  readfile($file_name);
12
  die;
classes/handler.php CHANGED
@@ -126,7 +126,9 @@ class PMXE_Handler extends PMXE_Session {
126
 
127
  public function clean_session( $import_id = 'new' ){
128
 
129
- delete_option('_wpallexport_session_' . $import_id . '_');
 
130
 
131
  }
 
132
  }
126
 
127
  public function clean_session( $import_id = 'new' ){
128
 
129
+ delete_option('_wpallexport_session_' . $import_id . '_');
130
+ delete_option('_wpallexport_session_expires_' . $import_id . '_');
131
 
132
  }
133
+
134
  }
classes/zip.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! class_exists('PMXE_Zip')){
4
+
5
+ class PMXE_Zip
6
+ {
7
+ /**
8
+ * Add files and sub-directories in a folder to zip file.
9
+ * @param string $folder
10
+ * @param ZipArchive $zipFile
11
+ * @param int $exclusiveLength Number of text to be exclusived from the file path.
12
+ */
13
+ private static function folderToZip($folder, &$zipFile, $exclusiveLength) {
14
+ $handle = opendir($folder);
15
+ while (false !== $f = readdir($handle)) {
16
+ if ($f != '.' && $f != '..') {
17
+ $filePath = "$folder/$f";
18
+ // Remove prefix from file path before add to zip.
19
+ $localPath = substr($filePath, $exclusiveLength);
20
+ if (is_file($filePath)) {
21
+ $zipFile->addFile($filePath, $localPath);
22
+ } elseif (is_dir($filePath)) {
23
+ // Add sub-directory.
24
+ $zipFile->addEmptyDir($localPath);
25
+ self::folderToZip($filePath, $zipFile, $exclusiveLength);
26
+ }
27
+ }
28
+ }
29
+ closedir($handle);
30
+ }
31
+
32
+ /**
33
+ * Zip a folder (include itself).
34
+ * Usage:
35
+ * PMXE_Zip::zipDir('/path/to/sourceDir', '/path/to/out.zip');
36
+ *
37
+ * @param string $sourcePath Path of directory to be zip.
38
+ * @param string $outZipPath Path of output zip file.
39
+ */
40
+ public static function zipDir($sourcePath, $outZipPath)
41
+ {
42
+ $pathInfo = pathInfo($sourcePath);
43
+ $parentPath = $pathInfo['dirname'];
44
+ $dirName = $pathInfo['basename'];
45
+
46
+ $z = new ZipArchive();
47
+ $z->open($outZipPath, ZIPARCHIVE::CREATE);
48
+ $z->addEmptyDir($dirName);
49
+ self::folderToZip($sourcePath, $z, strlen("$parentPath/"));
50
+ $z->close();
51
+ }
52
+ }
53
+
54
+ }
controllers/admin/export.php CHANGED
@@ -81,7 +81,8 @@ class PMXE_Admin_Export extends PMXE_Controller_Admin {
81
  'wp_query' => '',
82
  'filter_rules_hierarhy' => '',
83
  'product_matching_mode' => 'strict',
84
- 'wp_query_selector' => 'wp_query'
 
85
  ));
86
 
87
  // Delete history
@@ -102,6 +103,48 @@ class PMXE_Admin_Export extends PMXE_Controller_Admin {
102
  $engine = new XmlExportEngine($post, $this->errors);
103
  $engine->init_additional_data();
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  }
106
 
107
  if ($this->input->post('is_submitted') and ! $this->errors->get_error_codes()) {
@@ -110,7 +153,14 @@ class PMXE_Admin_Export extends PMXE_Controller_Admin {
110
 
111
  PMXE_Plugin::$session->save_data();
112
 
113
- wp_redirect(add_query_arg('action', 'template', $this->baseUrl)); die();
 
 
 
 
 
 
 
114
 
115
  }
116
 
@@ -222,15 +272,21 @@ class PMXE_Admin_Export extends PMXE_Controller_Admin {
222
  $post_types = PMXE_Plugin::$session->get('cpt');
223
  if ( ! empty($post_types) )
224
  {
225
- $post_type_details = get_post_type_object( array_shift($post_types) );
226
- $friendly_name = $post_type_details->labels->name . ' Export - ' . date("Y F d H:i");
 
 
 
 
 
 
227
  }
228
  else
229
  {
230
  $friendly_name = 'WP_Query Export - ' . date("Y F d H:i");
231
  }
232
  $post['template_name'] = $friendly_name;
233
- }
234
 
235
  if ( ! $this->errors->get_error_codes()) {
236
  if ($this->isWizard) {
81
  'wp_query' => '',
82
  'filter_rules_hierarhy' => '',
83
  'product_matching_mode' => 'strict',
84
+ 'wp_query_selector' => 'wp_query',
85
+ 'auto_generate' => 0
86
  ));
87
 
88
  // Delete history
103
  $engine = new XmlExportEngine($post, $this->errors);
104
  $engine->init_additional_data();
105
 
106
+ if ( ! empty($post['auto_generate']) )
107
+ {
108
+ $auto_generate = array(
109
+ 'ids' => array(),
110
+ 'cc_label' => array(),
111
+ 'cc_php' => array(),
112
+ 'cc_code' => array(),
113
+ 'cc_sql' => array(),
114
+ 'cc_type' => array(),
115
+ 'cc_options' => array(),
116
+ 'cc_value' => array(),
117
+ 'cc_name' => array()
118
+ );
119
+
120
+ $available_data = $engine->init_available_data();
121
+ $available_sections = apply_filters("wp_all_export_available_sections", $engine->get('available_sections'));
122
+
123
+ foreach ($available_sections as $slug => $section)
124
+ {
125
+ foreach ($available_data[$section['content']] as $field)
126
+ {
127
+ if (is_array($field) and isset($field['auto']))
128
+ {
129
+ $auto_generate['ids'][] = 1;
130
+ $auto_generate['cc_label'][] = $field['label'];
131
+ $auto_generate['cc_php'][] = 0;
132
+ $auto_generate['cc_code'][] = '';
133
+ $auto_generate['cc_sql'][] = '';
134
+ $auto_generate['cc_type'][] = $field['type'];
135
+ $auto_generate['cc_options'][] = '';
136
+ $auto_generate['cc_value'][] = $field['label'];
137
+ $auto_generate['cc_name'][] = $field['name'];
138
+ }
139
+ }
140
+ }
141
+ foreach ($auto_generate as $key => $value)
142
+ {
143
+ PMXE_Plugin::$session->set($key, $value);
144
+ }
145
+ PMXE_Plugin::$session->save_data();
146
+ }
147
+
148
  }
149
 
150
  if ($this->input->post('is_submitted') and ! $this->errors->get_error_codes()) {
153
 
154
  PMXE_Plugin::$session->save_data();
155
 
156
+ if ( ! empty($post['auto_generate']) )
157
+ {
158
+ wp_redirect(add_query_arg('action', 'options', $this->baseUrl)); die();
159
+ }
160
+ else
161
+ {
162
+ wp_redirect(add_query_arg('action', 'template', $this->baseUrl)); die();
163
+ }
164
 
165
  }
166
 
272
  $post_types = PMXE_Plugin::$session->get('cpt');
273
  if ( ! empty($post_types) )
274
  {
275
+ if ( ! in_array('users', $post_types)){
276
+ $post_type_details = get_post_type_object( array_shift($post_types) );
277
+ $friendly_name = $post_type_details->labels->name . ' Export - ' . date("Y F d H:i");
278
+ }
279
+ else
280
+ {
281
+ $friendly_name = 'Users Export - ' . date("Y F d H:i");
282
+ }
283
  }
284
  else
285
  {
286
  $friendly_name = 'WP_Query Export - ' . date("Y F d H:i");
287
  }
288
  $post['template_name'] = $friendly_name;
289
+ }
290
 
291
  if ( ! $this->errors->get_error_codes()) {
292
  if ($this->isWizard) {
controllers/admin/manage.php CHANGED
@@ -254,22 +254,94 @@ class PMXE_Admin_Manage extends PMXE_Controller_Admin {
254
  $export_data = array();
255
 
256
  if ( ! $export->getById($id)->isEmpty()){
257
- $template = new PMXI_Template_Record();
258
- if ( ! empty($export->options['template_name'])) {
259
- $template->getByName($export->options['template_name']);
260
- if ( ! $template->isEmpty() ){
261
- $export_data[] = $template->toArray(TRUE);
262
- $uploads = wp_upload_dir();
263
- $targetDir = $uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::TEMP_DIRECTORY;
264
- $export_file_name = "templates_".uniqid().".txt";
265
- file_put_contents($targetDir . DIRECTORY_SEPARATOR . $export_file_name, json_encode($export_data));
266
- PMXI_download::csv($targetDir . DIRECTORY_SEPARATOR . $export_file_name);
267
- }
268
- }
269
  }
270
  }
271
  }
272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  /*
274
  * Download import log file
275
  *
@@ -289,19 +361,21 @@ class PMXE_Admin_Manage extends PMXE_Controller_Admin {
289
 
290
  $filepath = '';
291
 
292
- if ( ! $export->getById($id)->isEmpty()){
293
-
294
-
295
- if ( ! $is_secure_import){
296
- $filepath = wp_get_attachment_url($export->attch_id);
297
  }
298
- else{
 
299
  $filepath = wp_all_export_get_absolute_path($export->options['filepath']);
300
  }
301
 
302
- if ( @file_exists($filepath) ){
303
-
304
- switch ($export['options']['export_to']) {
 
305
  case 'xml':
306
  PMXE_download::xml($filepath);
307
  break;
@@ -313,13 +387,14 @@ class PMXE_Admin_Manage extends PMXE_Controller_Admin {
313
  wp_redirect(add_query_arg('pmxe_nt', urlencode(__('File format not supported', 'pmxe_plugin')), $this->baseUrl)); die();
314
  break;
315
  }
316
-
317
  }
318
- else{
 
319
  wp_redirect(add_query_arg('pmxe_nt', urlencode(__('The exported file is missing and can\'t be downloaded. Please re-run your export to re-generate it.', 'pmxe_plugin')), $this->baseUrl)); die();
320
  }
321
  }
322
- else {
 
323
  wp_redirect(add_query_arg('pmxe_nt', urlencode(__('The exported file is missing and can\'t be downloaded. Please re-run your export to re-generate it.', 'pmxe_plugin')), $this->baseUrl)); die();
324
  }
325
  }
254
  $export_data = array();
255
 
256
  if ( ! $export->getById($id)->isEmpty()){
257
+
258
+ $export_data[] = $export->options['tpl_data'];
259
+ $uploads = wp_upload_dir();
260
+ $targetDir = $uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::TEMP_DIRECTORY;
261
+
262
+ $export_file_name = "WP All Import Template - " . $export->friendly_name . ".txt";
263
+
264
+ file_put_contents($targetDir . DIRECTORY_SEPARATOR . $export_file_name, json_encode($export_data));
265
+
266
+ PMXI_download::csv($targetDir . DIRECTORY_SEPARATOR . $export_file_name);
267
+
 
268
  }
269
  }
270
  }
271
 
272
+ /*
273
+ * Download bundle for WP All Import
274
+ *
275
+ */
276
+ public function bundle(){
277
+
278
+ $nonce = (!empty($_REQUEST['_wpnonce'])) ? $_REQUEST['_wpnonce'] : '';
279
+ if ( ! wp_verify_nonce( $nonce, '_wpnonce-download_bundle' ) ) {
280
+ die( __('Security check', 'wp_all_export_plugin') );
281
+ } else {
282
+
283
+ $uploads = wp_upload_dir();
284
+
285
+ //generate temporary folder
286
+ $tmp_dir = $uploads['basedir'] . DIRECTORY_SEPARATOR . PMXE_Plugin::TEMP_DIRECTORY . DIRECTORY_SEPARATOR . md5($nonce) . DIRECTORY_SEPARATOR;
287
+ $bundle_dir = $tmp_dir . 'bundle' . DIRECTORY_SEPARATOR;
288
+
289
+ // clear tmp dir
290
+ wp_all_export_rrmdir($tmp_dir);
291
+
292
+ @mkdir($tmp_dir);
293
+
294
+ $id = PMXE_Plugin::$session->update_previous;
295
+
296
+ if (empty($id))
297
+ $id = $this->input->get('id');
298
+
299
+ $export = new PMXE_Export_Record();
300
+
301
+ if ( ! $export->getById($id)->isEmpty())
302
+ {
303
+
304
+ $friendly_name = str_replace(":", "_", $export->friendly_name);
305
+
306
+ @mkdir($bundle_dir);
307
+
308
+ if ( ! empty($export->options['tpl_data']))
309
+ {
310
+ $template_data = array($export->options['tpl_data']);
311
+ $template = "WP All Import Template - " . $friendly_name . ".txt";
312
+
313
+ file_put_contents($bundle_dir . $template, json_encode($template_data));
314
+
315
+ $readme = __("The other two files in this zip are the export file containing all of your data and the import template for WP All Import. \n\nTo import this data, create a new import with WP All Import and upload this zip file.", "wp_all_export_plugin");
316
+
317
+ file_put_contents($bundle_dir . 'readme.txt', $readme);
318
+ }
319
+
320
+ $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
321
+
322
+ if ( ! $is_secure_import)
323
+ {
324
+ $filepath = get_attached_file($export->attch_id);
325
+ }
326
+ else
327
+ {
328
+ $filepath = wp_all_export_get_absolute_path($export->options['filepath']);
329
+ }
330
+
331
+ @copy( $filepath, $bundle_dir . basename($filepath) );
332
+
333
+ $bundle_path = $tmp_dir . sanitize_file_name($friendly_name) . '.zip';
334
+
335
+ PMXE_Zip::zipDir($bundle_dir, $bundle_path);
336
+
337
+ $bundle_url = $uploads['baseurl'] . str_replace($uploads['basedir'], '', $bundle_path);
338
+
339
+ PMXE_download::zip($bundle_url);
340
+
341
+ }
342
+ }
343
+ }
344
+
345
  /*
346
  * Download import log file
347
  *
361
 
362
  $filepath = '';
363
 
364
+ if ( ! $export->getById($id)->isEmpty())
365
+ {
366
+ if ( ! $is_secure_import)
367
+ {
368
+ $filepath = get_attached_file($export->attch_id);
369
  }
370
+ else
371
+ {
372
  $filepath = wp_all_export_get_absolute_path($export->options['filepath']);
373
  }
374
 
375
+ if ( @file_exists($filepath) )
376
+ {
377
+ switch ($export['options']['export_to'])
378
+ {
379
  case 'xml':
380
  PMXE_download::xml($filepath);
381
  break;
387
  wp_redirect(add_query_arg('pmxe_nt', urlencode(__('File format not supported', 'pmxe_plugin')), $this->baseUrl)); die();
388
  break;
389
  }
 
390
  }
391
+ else
392
+ {
393
  wp_redirect(add_query_arg('pmxe_nt', urlencode(__('The exported file is missing and can\'t be downloaded. Please re-run your export to re-generate it.', 'pmxe_plugin')), $this->baseUrl)); die();
394
  }
395
  }
396
+ else
397
+ {
398
  wp_redirect(add_query_arg('pmxe_nt', urlencode(__('The exported file is missing and can\'t be downloaded. Please re-run your export to re-generate it.', 'pmxe_plugin')), $this->baseUrl)); die();
399
  }
400
  }
filters/wp_all_import_is_exported_file_valid.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- function pmxe_wp_all_import_is_exported_file_valid($is_valid, $export_id, $elements_cloud){
4
 
5
  $exportRecord = new PMXE_Export_Record();
6
  $exportRecord->getById($export_id);
@@ -10,14 +10,7 @@ function pmxe_wp_all_import_is_exported_file_valid($is_valid, $export_id, $eleme
10
  foreach ($exportOptions['ids'] as $ID => $value) {
11
  if (is_numeric($ID)){
12
 
13
- if ($exportOptions['export_to'] == 'csv')
14
- {
15
- $element_name = ( ! empty($exportOptions['cc_name'][$ID]) ) ? preg_replace('/[^a-z0-9_]/i', '', $exportOptions['cc_name'][$ID]) : 'untitled_' . $ID;
16
- }
17
- else
18
- {
19
- $element_name = ( ! empty($exportOptions['cc_name'][$ID]) ) ? str_replace(" ", "_", $exportOptions['cc_name'][$ID]) : 'untitled_' . $ID;
20
- }
21
 
22
  switch ($exportOptions['cc_type'][$ID]) {
23
  case 'id':
@@ -59,7 +52,7 @@ function pmxe_wp_all_import_is_exported_file_valid($is_valid, $export_id, $eleme
59
  }
60
  }
61
  }
62
-
63
  return $is_valid;
64
 
65
  }
1
  <?php
2
 
3
+ function pmxe_wp_all_import_is_exported_file_valid($is_valid, $export_id, $elements_cloud){
4
 
5
  $exportRecord = new PMXE_Export_Record();
6
  $exportRecord->getById($export_id);
10
  foreach ($exportOptions['ids'] as $ID => $value) {
11
  if (is_numeric($ID)){
12
 
13
+ $element_name = ( ! empty($exportOptions['cc_name'][$ID]) ) ? preg_replace('/[^a-z0-9_]/i', '', $exportOptions['cc_name'][$ID]) : 'untitled_' . $ID;
 
 
 
 
 
 
 
14
 
15
  switch ($exportOptions['cc_type'][$ID]) {
16
  case 'id':
52
  }
53
  }
54
  }
55
+
56
  return $is_valid;
57
 
58
  }
helpers/pmxe_export_csv.php CHANGED
@@ -111,6 +111,22 @@ function pmxe_export_csv($exportQuery, $exportOptions, $preview = false, $is_cro
111
  }
112
  }
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  if ( ! empty($attachment_ids)):
115
  $img_urls = array();
116
  $img_titles = array();
@@ -330,9 +346,9 @@ function pmxe_export_csv($exportQuery, $exportOptions, $preview = false, $is_cro
330
  break;
331
 
332
  case 'woo':
333
-
334
  XmlExportWooCommerce::getInstance()->export_csv($article, $woo, $record, $exportOptions, $ID);
335
-
336
  break;
337
 
338
  case 'woo_order':
@@ -364,7 +380,8 @@ function pmxe_export_csv($exportQuery, $exportOptions, $preview = false, $is_cro
364
  break;
365
 
366
  case 'cats':
367
- if ( ! empty($exportOptions['cc_value'][$ID]) ){
 
368
  $txes_list = get_the_terms($record->ID, $exportOptions['cc_value'][$ID]);
369
  if ( ! is_wp_error($txes_list) and ! empty($txes_list) ) {
370
 
@@ -399,16 +416,19 @@ function pmxe_export_csv($exportQuery, $exportOptions, $preview = false, $is_cro
399
  $article[$element_name] = apply_filters('pmxe_post_taxonomy', pmxe_filter(implode($implode_delimiter, $hierarchy_groups), $fieldSnipped), get_the_ID());
400
  }
401
 
402
- }
403
 
404
  if ( ! in_array($element_name, $taxes)) $taxes[] = $element_name;
405
 
406
  if ($exportOptions['cc_label'][$ID] == 'product_type' and get_post_type() == 'product_variation'){
407
 
408
- $article[$element_name] = 'variable';
409
- $article['parent_sku'] = get_post_meta($record->post_parent, '_sku', true);
410
 
411
  }
 
 
 
 
412
  }
413
  break;
414
 
@@ -471,12 +491,14 @@ function pmxe_export_csv($exportQuery, $exportOptions, $preview = false, $is_cro
471
 
472
  break;
473
  case 'cats':
474
- if ( ! empty($taxes) ){
 
 
475
  $tx = array_shift($taxes);
476
  $headers[] = $tx;
477
- if ($tx == 'product_type'){
478
- $headers[] = 'parent_sku';
479
- }
480
  }
481
  break;
482
  case 'attr':
@@ -501,8 +523,8 @@ function pmxe_export_csv($exportQuery, $exportOptions, $preview = false, $is_cro
501
 
502
  break;
503
  case 'woo':
504
-
505
- XmlExportWooCommerce::getInstance()->get_element_header( $headers, $exportOptions, $ID );
506
 
507
  break;
508
 
111
  }
112
  }
113
 
114
+ $attachment_imgs = get_posts( array(
115
+ 'post_type' => 'attachment',
116
+ 'posts_per_page' => -1,
117
+ 'post_parent' => $record->ID,
118
+ ) );
119
+
120
+ if ( ! empty($attachment_imgs)):
121
+
122
+ foreach ($attachment_imgs as $attach) {
123
+ if ( wp_attachment_is_image( $attach->ID ) and ! in_array($attach->ID, $attachment_ids)){
124
+ $attachment_ids[] = $attach->ID;
125
+ }
126
+ }
127
+
128
+ endif;
129
+
130
  if ( ! empty($attachment_ids)):
131
  $img_urls = array();
132
  $img_titles = array();
346
  break;
347
 
348
  case 'woo':
349
+
350
  XmlExportWooCommerce::getInstance()->export_csv($article, $woo, $record, $exportOptions, $ID);
351
+
352
  break;
353
 
354
  case 'woo_order':
380
  break;
381
 
382
  case 'cats':
383
+ if ( ! empty($exportOptions['cc_value'][$ID]) ){
384
+ $article[$element_name] = '';
385
  $txes_list = get_the_terms($record->ID, $exportOptions['cc_value'][$ID]);
386
  if ( ! is_wp_error($txes_list) and ! empty($txes_list) ) {
387
 
416
  $article[$element_name] = apply_filters('pmxe_post_taxonomy', pmxe_filter(implode($implode_delimiter, $hierarchy_groups), $fieldSnipped), get_the_ID());
417
  }
418
 
419
+ }
420
 
421
  if ( ! in_array($element_name, $taxes)) $taxes[] = $element_name;
422
 
423
  if ($exportOptions['cc_label'][$ID] == 'product_type' and get_post_type() == 'product_variation'){
424
 
425
+ $article[$element_name] = 'variable';
 
426
 
427
  }
428
+
429
+ if ($exportOptions['cc_label'][$ID] == 'product_type') $article['parent_sku'] = get_post_meta($record->post_parent, '_sku', true);
430
+ //if ( ! in_array('parent_sku', $taxes)) $taxes[] = 'parent_sku';
431
+
432
  }
433
  break;
434
 
491
 
492
  break;
493
  case 'cats':
494
+ if ( ! empty($taxes) )
495
+ {
496
+
497
  $tx = array_shift($taxes);
498
  $headers[] = $tx;
499
+
500
+ if ( $exportOptions['cc_label'][$ID] == 'product_type' ) $headers[] = 'parent_sku';
501
+
502
  }
503
  break;
504
  case 'attr':
523
 
524
  break;
525
  case 'woo':
526
+
527
+ XmlExportWooCommerce::getInstance()->get_element_header( $headers, $exportOptions, $ID );
528
 
529
  break;
530
 
helpers/pmxe_export_xml.php CHANGED
@@ -46,7 +46,7 @@ function pmxe_export_xml($exportQuery, $exportOptions, $preview = false, $is_cro
46
 
47
  if (empty($exportOptions['cc_name'][$ID]) or empty($exportOptions['cc_type'][$ID])) continue;
48
 
49
- $element_name = ( ! empty($exportOptions['cc_name'][$ID]) ) ? str_replace(" ", "_", $exportOptions['cc_name'][$ID]) : 'untitled_' . $ID;
50
  $fieldSnipped = ( ! empty($exportOptions['cc_php'][$ID]) and ! empty($exportOptions['cc_code'][$ID]) ) ? $exportOptions['cc_code'][$ID] : false;
51
 
52
  switch ($exportOptions['cc_type'][$ID]) {
@@ -91,6 +91,22 @@ function pmxe_export_xml($exportQuery, $exportOptions, $preview = false, $is_cro
91
  }
92
  }
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  if ( ! empty($attachment_ids)):
95
 
96
  foreach ($attachment_ids as $attach_id) {
@@ -249,7 +265,7 @@ function pmxe_export_xml($exportQuery, $exportOptions, $preview = false, $is_cro
249
  case 'woo':
250
 
251
  XmlExportWooCommerce::getInstance()->export_xml($xmlWriter, $record, $exportOptions, $ID);
252
-
253
  break;
254
  case 'woo_order':
255
 
@@ -295,55 +311,58 @@ function pmxe_export_xml($exportQuery, $exportOptions, $preview = false, $is_cro
295
  }
296
  break;
297
  case 'cats':
298
- if ( ! empty($exportOptions['cc_value'][$ID]) ){
299
- $txes_list = get_the_terms($record->ID, $exportOptions['cc_value'][$ID]);
300
- if ( ! is_wp_error($txes_list)) {
301
-
302
- $txes_ids = array();
303
- $hierarchy_groups = array();
304
-
305
- if ( ! empty($txes_list) ):
306
- foreach ($txes_list as $t) {
307
- $txes_ids[] = $t->term_id;
308
- }
 
 
 
 
 
 
 
 
309
 
310
- foreach ($txes_list as $t) {
311
- if ( wp_all_export_check_children_assign($t->term_id, $exportOptions['cc_value'][$ID], $txes_ids) ){
312
- $ancestors = get_ancestors( $t->term_id, $exportOptions['cc_value'][$ID] );
313
- if (count($ancestors) > 0){
314
- $hierarchy_group = array();
315
- for ( $i = count($ancestors) - 1; $i >= 0; $i-- ) {
316
- $term = get_term_by('id', $ancestors[$i], $exportOptions['cc_value'][$ID]);
317
- if ($term){
318
- $hierarchy_group[] = $term->name;
 
319
  }
 
 
 
 
 
320
  }
321
- $hierarchy_group[] = $t->name;
322
- $hierarchy_groups[] = implode(">", $hierarchy_group);
323
- }
324
- else{
325
- $hierarchy_groups[] = $t->name;
326
  }
327
- }
328
- }
329
-
330
- if ( ! empty($hierarchy_groups) ){
331
 
332
- $xmlWriter->startElement($element_name);
333
- $xmlWriter->writeCData(apply_filters('pmxe_post_taxonomy', pmxe_filter(implode('|', $hierarchy_groups), $fieldSnipped), get_the_ID()));
334
- $xmlWriter->endElement();
335
-
336
- }
337
-
338
- endif;
339
 
340
- }
341
- if ($exportOptions['cc_label'][$ID] == 'product_type' and get_post_type() == 'product_variation'){
 
 
 
 
 
342
 
343
- $xmlWriter->writeElement('parent_sku', get_post_meta($record->post_parent, '_sku', true));
344
- $xmlWriter->writeElement($element_name, 'variable');
345
-
346
- }
347
  }
348
  break;
349
 
46
 
47
  if (empty($exportOptions['cc_name'][$ID]) or empty($exportOptions['cc_type'][$ID])) continue;
48
 
49
+ $element_name = ( ! empty($exportOptions['cc_name'][$ID]) ) ? preg_replace('/[^a-z0-9_]/i', '', $exportOptions['cc_name'][$ID]) : 'untitled_' . $ID;
50
  $fieldSnipped = ( ! empty($exportOptions['cc_php'][$ID]) and ! empty($exportOptions['cc_code'][$ID]) ) ? $exportOptions['cc_code'][$ID] : false;
51
 
52
  switch ($exportOptions['cc_type'][$ID]) {
91
  }
92
  }
93
 
94
+ $attachment_imgs = get_posts( array(
95
+ 'post_type' => 'attachment',
96
+ 'posts_per_page' => -1,
97
+ 'post_parent' => $record->ID,
98
+ ) );
99
+
100
+ if ( ! empty($attachment_imgs)):
101
+
102
+ foreach ($attachment_imgs as $attach) {
103
+ if ( wp_attachment_is_image( $attach->ID ) and ! in_array($attach->ID, $attachment_ids)){
104
+ $attachment_ids[] = $attach->ID;
105
+ }
106
+ }
107
+
108
+ endif;
109
+
110
  if ( ! empty($attachment_ids)):
111
 
112
  foreach ($attachment_ids as $attach_id) {
265
  case 'woo':
266
 
267
  XmlExportWooCommerce::getInstance()->export_xml($xmlWriter, $record, $exportOptions, $ID);
268
+
269
  break;
270
  case 'woo_order':
271
 
311
  }
312
  break;
313
  case 'cats':
314
+ if ( ! empty($exportOptions['cc_value'][$ID]) )
315
+ {
316
+ if ($exportOptions['cc_label'][$ID] == 'product_type' and get_post_type() == 'product_variation')
317
+ {
318
+ $xmlWriter->writeElement('parent_sku', get_post_meta($record->post_parent, '_sku', true));
319
+ $xmlWriter->writeElement($element_name, 'variable');
320
+ }
321
+ else
322
+ {
323
+ $txes_list = get_the_terms($record->ID, $exportOptions['cc_value'][$ID]);
324
+ if ( ! is_wp_error($txes_list)) {
325
+
326
+ $txes_ids = array();
327
+ $hierarchy_groups = array();
328
+
329
+ if ( ! empty($txes_list) ):
330
+ foreach ($txes_list as $t) {
331
+ $txes_ids[] = $t->term_id;
332
+ }
333
 
334
+ foreach ($txes_list as $t) {
335
+ if ( wp_all_export_check_children_assign($t->term_id, $exportOptions['cc_value'][$ID], $txes_ids) ){
336
+ $ancestors = get_ancestors( $t->term_id, $exportOptions['cc_value'][$ID] );
337
+ if (count($ancestors) > 0){
338
+ $hierarchy_group = array();
339
+ for ( $i = count($ancestors) - 1; $i >= 0; $i-- ) {
340
+ $term = get_term_by('id', $ancestors[$i], $exportOptions['cc_value'][$ID]);
341
+ if ($term){
342
+ $hierarchy_group[] = $term->name;
343
+ }
344
  }
345
+ $hierarchy_group[] = $t->name;
346
+ $hierarchy_groups[] = implode(">", $hierarchy_group);
347
+ }
348
+ else{
349
+ $hierarchy_groups[] = $t->name;
350
  }
 
 
 
 
 
351
  }
352
+ }
 
 
 
353
 
354
+ if ( ! empty($hierarchy_groups) ){
 
 
 
 
 
 
355
 
356
+ $xmlWriter->startElement($element_name);
357
+ $xmlWriter->writeCData(apply_filters('pmxe_post_taxonomy', pmxe_filter(implode('|', $hierarchy_groups), $fieldSnipped), get_the_ID()));
358
+ $xmlWriter->endElement();
359
+
360
+ }
361
+
362
+ endif;
363
 
364
+ }
365
+ }
 
 
366
  }
367
  break;
368
 
helpers/pmxe_functions.php CHANGED
@@ -22,4 +22,19 @@
22
  $uploads = wp_upload_dir();
23
  return ( strpos($path, $uploads['basedir']) === false and ! preg_match('%^https?://%i', $path)) ? $uploads['basedir'] . $path : $path;
24
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  }
22
  $uploads = wp_upload_dir();
23
  return ( strpos($path, $uploads['basedir']) === false and ! preg_match('%^https?://%i', $path)) ? $uploads['basedir'] . $path : $path;
24
  }
25
+ }
26
+
27
+ if ( ! function_exists('wp_all_export_rrmdir') ){
28
+ function wp_all_export_rrmdir($dir) {
29
+ if (is_dir($dir)) {
30
+ $objects = scandir($dir);
31
+ foreach ($objects as $object) {
32
+ if ($object != "." && $object != "..") {
33
+ if (filetype($dir . "/" . $object) == "dir") wp_all_export_rrmdir($dir . "/" . $object); else unlink($dir . "/" . $object);
34
+ }
35
+ }
36
+ reset($objects);
37
+ rmdir($dir);
38
+ }
39
+ }
40
  }
helpers/wp_all_export_prepare_template_csv.php CHANGED
@@ -2,7 +2,10 @@
2
 
3
  function wp_all_export_prepare_template_csv($exportOptions, &$templateOptions)
4
  {
5
- if ($exportOptions['ids']){
 
 
 
6
  $cf_list = array();
7
  $attr_list = array();
8
  $taxs_list = array();
@@ -17,37 +20,22 @@ function wp_all_export_prepare_template_csv($exportOptions, &$templateOptions)
17
  $templateOptions['tmp_unique_key'] = '{'. $element_name .'[1]}';
18
  break;
19
  case 'title':
 
 
 
 
 
20
  $templateOptions[$exportOptions['cc_type'][$ID]] = '{'. $element_name .'[1]}';
21
- $templateOptions['is_update_title'] = 1;
22
- break;
23
- case 'content':
24
- $templateOptions[$exportOptions['cc_type'][$ID]] = '{'. $element_name .'[1]}';
25
- $templateOptions['is_update_content'] = 1;
26
- break;
27
- case 'author':
28
- $templateOptions[$exportOptions['cc_type'][$ID]] = '{'. $element_name .'[1]}';
29
- $templateOptions['is_update_author'] = 1;
30
- break;
31
- case 'date':
32
- $templateOptions[$exportOptions['cc_type'][$ID]] = '{'. $element_name .'[1]}';
33
- $templateOptions['is_update_dates'] = 1;
34
- break;
35
  case 'status':
36
  $templateOptions['status_xpath'] = '{'. $element_name .'[1]}';
37
  $templateOptions['is_update_status'] = 1;
38
- break;
39
- case 'parent':
40
- $templateOptions['single_page_parent'] = '{'. $element_name .'[1]}';
41
- $templateOptions['is_update_parent'] = 1;
42
- break;
43
- case 'excerpt':
44
- $templateOptions['post_excerpt'] = '{'. $element_name .'[1]}';
45
- $templateOptions['is_update_excerpt'] = 1;
46
- break;
47
- case 'slug':
48
- $templateOptions['post_slug'] = '{'. $element_name .'[1]}';
49
- $templateOptions['is_update_slug'] = 1;
50
- break;
51
  case 'post_type':
52
  if ( empty($exportOptions['cpt']) ){
53
  $templateOptions['is_override_post_type'] = 1;
@@ -65,8 +53,18 @@ function wp_all_export_prepare_template_csv($exportOptions, &$templateOptions)
65
  }
66
  break;
67
  case 'woo':
68
- //$element_name = 'woo' . $element_name;
69
- if ( ! empty($exportOptions['cc_value'][$ID]) ){
 
 
 
 
 
 
 
 
 
 
70
  $cf_list[] = $exportOptions['cc_label'][$ID];
71
  switch ($exportOptions['cc_label'][$ID]) {
72
  case '_visibility':
@@ -180,10 +178,10 @@ function wp_all_export_prepare_template_csv($exportOptions, &$templateOptions)
180
  {
181
  $templateOptions['attribute_name'][] = '{attributename' . $obj->name .'[1]}';
182
  $templateOptions['attribute_value'][] = '{attributevalue' . $obj->name .'[1]}';
183
- $templateOptions['in_variations'][] = 1;
184
- $templateOptions['is_visible'][] = 1;
185
- $templateOptions['is_taxonomy'][] = 1;
186
- $templateOptions['create_taxonomy_in_not_exists'][] = 1;
187
  $attr_list[] = $obj->name;
188
  }
189
  }
@@ -198,6 +196,15 @@ function wp_all_export_prepare_template_csv($exportOptions, &$templateOptions)
198
 
199
  case 'acf':
200
 
 
 
 
 
 
 
 
 
 
201
  $field_options = unserialize($exportOptions['cc_options'][$ID]);
202
 
203
  // add ACF group ID to the template options
@@ -506,5 +513,8 @@ function wp_all_export_prepare_template_csv($exportOptions, &$templateOptions)
506
  $templateOptions['is_update_acf'] = 1;
507
  $templateOptions['acf_list'] = $acf_list;
508
  }
 
 
 
509
  }
510
  }
2
 
3
  function wp_all_export_prepare_template_csv($exportOptions, &$templateOptions)
4
  {
5
+ if ($exportOptions['ids']){
6
+
7
+ $required_add_ons = array();
8
+
9
  $cf_list = array();
10
  $attr_list = array();
11
  $taxs_list = array();
20
  $templateOptions['tmp_unique_key'] = '{'. $element_name .'[1]}';
21
  break;
22
  case 'title':
23
+ case 'content':
24
+ case 'author':
25
+ case 'parent':
26
+ case 'excerpt':
27
+ case 'slug':
28
  $templateOptions[$exportOptions['cc_type'][$ID]] = '{'. $element_name .'[1]}';
29
+ $templateOptions['is_update_' . $exportOptions['cc_type'][$ID]] = 1;
30
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
31
  case 'status':
32
  $templateOptions['status_xpath'] = '{'. $element_name .'[1]}';
33
  $templateOptions['is_update_status'] = 1;
34
+ break;
35
+ case 'date':
36
+ $templateOptions[$exportOptions['cc_type'][$ID]] = '{'. $element_name .'[1]}';
37
+ $templateOptions['is_update_dates'] = 1;
38
+ break;
 
 
 
 
 
 
 
 
39
  case 'post_type':
40
  if ( empty($exportOptions['cpt']) ){
41
  $templateOptions['is_override_post_type'] = 1;
53
  }
54
  break;
55
  case 'woo':
56
+
57
+ if ( ! empty($exportOptions['cc_value'][$ID]) )
58
+ {
59
+ if (empty($required_add_ons['PMWI_Plugin']))
60
+ {
61
+ $required_add_ons['PMWI_Plugin'] = array(
62
+ 'name' => 'WooCommerce Add-On Pro',
63
+ 'paid' => true,
64
+ 'url' => 'http://www.wpallimport.com/woocommerce-product-import/'
65
+ );
66
+ }
67
+
68
  $cf_list[] = $exportOptions['cc_label'][$ID];
69
  switch ($exportOptions['cc_label'][$ID]) {
70
  case '_visibility':
178
  {
179
  $templateOptions['attribute_name'][] = '{attributename' . $obj->name .'[1]}';
180
  $templateOptions['attribute_value'][] = '{attributevalue' . $obj->name .'[1]}';
181
+ $templateOptions['in_variations'][] = "1";
182
+ $templateOptions['is_visible'][] = "1";
183
+ $templateOptions['is_taxonomy'][] = "1";
184
+ $templateOptions['create_taxonomy_in_not_exists'][] = "1";
185
  $attr_list[] = $obj->name;
186
  }
187
  }
196
 
197
  case 'acf':
198
 
199
+ if (empty($required_add_ons['PMAI_Plugin']))
200
+ {
201
+ $required_add_ons['PMAI_Plugin'] = array(
202
+ 'name' => 'ACF Add-On Pro',
203
+ 'paid' => true,
204
+ 'url' => 'http://www.wpallimport.com/advanced-custom-fields/?utm_source=wordpress.org&utm_medium=wpai-import-template&utm_campaign=free+wp+all+export+plugin'
205
+ );
206
+ }
207
+
208
  $field_options = unserialize($exportOptions['cc_options'][$ID]);
209
 
210
  // add ACF group ID to the template options
513
  $templateOptions['is_update_acf'] = 1;
514
  $templateOptions['acf_list'] = $acf_list;
515
  }
516
+
517
+ $templateOptions['required_add_ons'] = $required_add_ons;
518
+
519
  }
520
  }
helpers/wp_all_export_prepare_template_xml.php CHANGED
@@ -3,50 +3,39 @@
3
  function wp_all_export_prepare_template_xml($exportOptions, &$templateOptions)
4
  {
5
  if ($exportOptions['ids']){
 
 
 
6
  $cf_list = array();
7
  $attr_list = array();
8
  $taxs_list = array();
9
  $acf_list = array();
10
  foreach ($exportOptions['ids'] as $ID => $value) {
11
  if (empty($exportOptions['cc_type'][$ID])) continue;
12
- $element_name = (!empty($exportOptions['cc_name'][$ID])) ? str_replace(" ", "_", $exportOptions['cc_name'][$ID]) : 'untitled_' . $ID;
13
  switch ($exportOptions['cc_type'][$ID]) {
14
  case 'id':
15
  $templateOptions['unique_key'] = '{'. $element_name .'[1]}';
16
  $templateOptions['tmp_unique_key'] = '{'. $element_name .'[1]}';
17
  break;
18
  case 'title':
 
 
 
 
 
19
  $templateOptions[$exportOptions['cc_type'][$ID]] = '{'. $element_name .'[1]}';
20
- $templateOptions['is_update_title'] = 1;
21
- break;
22
- case 'content':
23
- $templateOptions[$exportOptions['cc_type'][$ID]] = '{'. $element_name .'[1]}';
24
- $templateOptions['is_update_content'] = 1;
25
- break;
26
- case 'author':
27
- $templateOptions[$exportOptions['cc_type'][$ID]] = '{'. $element_name .'[1]}';
28
- $templateOptions['is_update_author'] = 1;
29
- break;
30
  case 'date':
31
  $templateOptions[$exportOptions['cc_type'][$ID]] = '{'. $element_name .'[1]}';
32
  $templateOptions['is_update_dates'] = 1;
33
  break;
34
- case 'status':
35
- $templateOptions['status_xpath'] = '{'. $element_name .'[1]}';
36
- $templateOptions['is_update_status'] = 1;
37
- break;
38
- case 'parent':
39
- $templateOptions['single_page_parent'] = '{'. $element_name .'[1]}';
40
- $templateOptions['is_update_parent'] = 1;
41
- break;
42
- case 'excerpt':
43
- $templateOptions['post_excerpt'] = '{'. $element_name .'[1]}';
44
- $templateOptions['is_update_excerpt'] = 1;
45
- break;
46
- case 'slug':
47
- $templateOptions['post_slug'] = '{'. $element_name .'[1]}';
48
- $templateOptions['is_update_slug'] = 1;
49
- break;
50
  case 'post_type':
51
  if ( empty($exportOptions['cpt']) ){
52
  $templateOptions['is_override_post_type'] = 1;
@@ -62,8 +51,17 @@ function wp_all_export_prepare_template_xml($exportOptions, &$templateOptions)
62
  }
63
  break;
64
  case 'woo':
65
- //$element_name = 'woo' . $element_name;
66
- if ( ! empty($exportOptions['cc_value'][$ID]) ){
 
 
 
 
 
 
 
 
 
67
 
68
  $cf_list[] = $exportOptions['cc_label'][$ID];
69
  switch ($exportOptions['cc_label'][$ID]) {
@@ -176,12 +174,12 @@ function wp_all_export_prepare_template_xml($exportOptions, &$templateOptions)
176
 
177
  if (strpos($obj->name, "pa_") === 0 and strlen($obj->name) > 3)
178
  {
179
- $templateOptions['attribute_name'][] = '{attributename' . $obj->name .'[1]}';
180
- $templateOptions['attribute_value'][] = '{attributevalue' . $obj->name .'[1]}';
181
- $templateOptions['in_variations'][] = 1;
182
- $templateOptions['is_visible'][] = 1;
183
- $templateOptions['is_taxonomy'][] = 1;
184
- $templateOptions['create_taxonomy_in_not_exists'][] = 1;
185
  $attr_list[] = $obj->name;
186
  }
187
  }
@@ -195,6 +193,15 @@ function wp_all_export_prepare_template_xml($exportOptions, &$templateOptions)
195
  break;
196
  case 'acf':
197
 
 
 
 
 
 
 
 
 
 
198
  $field_options = unserialize($exportOptions['cc_options'][$ID]);
199
 
200
  // add ACF group ID to the template options
@@ -466,5 +473,8 @@ function wp_all_export_prepare_template_xml($exportOptions, &$templateOptions)
466
  $templateOptions['is_update_acf'] = 1;
467
  $templateOptions['acf_list'] = $acf_list;
468
  }
 
 
 
469
  }
470
  }
3
  function wp_all_export_prepare_template_xml($exportOptions, &$templateOptions)
4
  {
5
  if ($exportOptions['ids']){
6
+
7
+ $required_add_ons = array();
8
+
9
  $cf_list = array();
10
  $attr_list = array();
11
  $taxs_list = array();
12
  $acf_list = array();
13
  foreach ($exportOptions['ids'] as $ID => $value) {
14
  if (empty($exportOptions['cc_type'][$ID])) continue;
15
+ $element_name = (!empty($exportOptions['cc_name'][$ID])) ? str_replace("-", "_", preg_replace('/[^a-z0-9_]/i', '', $exportOptions['cc_name'][$ID])) : 'untitled_' . $ID;
16
  switch ($exportOptions['cc_type'][$ID]) {
17
  case 'id':
18
  $templateOptions['unique_key'] = '{'. $element_name .'[1]}';
19
  $templateOptions['tmp_unique_key'] = '{'. $element_name .'[1]}';
20
  break;
21
  case 'title':
22
+ case 'content':
23
+ case 'author':
24
+ case 'parent':
25
+ case 'excerpt':
26
+ case 'slug':
27
  $templateOptions[$exportOptions['cc_type'][$ID]] = '{'. $element_name .'[1]}';
28
+ $templateOptions['is_update_' . $exportOptions['cc_type'][$ID]] = 1;
29
+ break;
30
+ case 'status':
31
+ $templateOptions['status_xpath'] = '{'. $element_name .'[1]}';
32
+ $templateOptions['is_update_status'] = 1;
33
+ break;
 
 
 
 
34
  case 'date':
35
  $templateOptions[$exportOptions['cc_type'][$ID]] = '{'. $element_name .'[1]}';
36
  $templateOptions['is_update_dates'] = 1;
37
  break;
38
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  case 'post_type':
40
  if ( empty($exportOptions['cpt']) ){
41
  $templateOptions['is_override_post_type'] = 1;
51
  }
52
  break;
53
  case 'woo':
54
+
55
+ if ( ! empty($exportOptions['cc_value'][$ID]) )
56
+ {
57
+ if (empty($required_add_ons['PMWI_Plugin']))
58
+ {
59
+ $required_add_ons['PMWI_Plugin'] = array(
60
+ 'name' => 'WooCommerce Add-On Pro',
61
+ 'paid' => true,
62
+ 'url' => 'http://www.wpallimport.com/woocommerce-product-import/'
63
+ );
64
+ }
65
 
66
  $cf_list[] = $exportOptions['cc_label'][$ID];
67
  switch ($exportOptions['cc_label'][$ID]) {
174
 
175
  if (strpos($obj->name, "pa_") === 0 and strlen($obj->name) > 3)
176
  {
177
+ $templateOptions['attribute_name'][] = '{AttributeName' . $obj->name .'[1]}';
178
+ $templateOptions['attribute_value'][] = '{AttributeValue' . $obj->name .'[1]}';
179
+ $templateOptions['in_variations'][] = "1";
180
+ $templateOptions['is_visible'][] = "1";
181
+ $templateOptions['is_taxonomy'][] = "1";
182
+ $templateOptions['create_taxonomy_in_not_exists'][] = "1";
183
  $attr_list[] = $obj->name;
184
  }
185
  }
193
  break;
194
  case 'acf':
195
 
196
+ if (empty($required_add_ons['PMAI_Plugin']))
197
+ {
198
+ $required_add_ons['PMAI_Plugin'] = array(
199
+ 'name' => 'ACF Add-On Pro',
200
+ 'paid' => true,
201
+ 'url' => 'http://www.wpallimport.com/advanced-custom-fields/?utm_source=wordpress.org&utm_medium=wpai-import-template&utm_campaign=free+wp+all+export+plugin'
202
+ );
203
+ }
204
+
205
  $field_options = unserialize($exportOptions['cc_options'][$ID]);
206
 
207
  // add ACF group ID to the template options
473
  $templateOptions['is_update_acf'] = 1;
474
  $templateOptions['acf_list'] = $acf_list;
475
  }
476
+
477
+ $templateOptions['required_add_ons'] = $required_add_ons;
478
+
479
  }
480
  }
libraries/XmlExportACF.php CHANGED
@@ -26,7 +26,7 @@ if ( ! class_exists('XmlExportACF') ){
26
 
27
  private $_acf_groups = array();
28
 
29
- public function __construct() {
30
 
31
  }
32
 
26
 
27
  private $_acf_groups = array();
28
 
29
+ private function __construct() {
30
 
31
  }
32
 
libraries/XmlExportEngine.php CHANGED
@@ -283,6 +283,7 @@ if ( ! class_exists('XmlExportEngine') ){
283
  public function init_additional_data(){
284
 
285
  $this->woo_order_export->init_additional_data();
 
286
 
287
  }
288
 
@@ -458,14 +459,14 @@ if ( ! class_exists('XmlExportEngine') ){
458
 
459
  foreach ($this->available_data[$section['content']] as $field) {
460
  switch ($section['content']) {
461
- case 'existing_meta_keys':
462
  ?>
463
- <option value="<?php echo 'cf_' . $field; ?>"><?php echo $field; ?></option>
464
  <?php
465
  break;
466
  case 'existing_taxonomies':
467
  ?>
468
- <option value="<?php echo 'tx_' . $field; ?>"><?php echo $field; ?></option>
469
  <?php
470
  break;
471
 
283
  public function init_additional_data(){
284
 
285
  $this->woo_order_export->init_additional_data();
286
+ $this->woo_export->init_additional_data();
287
 
288
  }
289
 
459
 
460
  foreach ($this->available_data[$section['content']] as $field) {
461
  switch ($section['content']) {
462
+ case 'existing_meta_keys':
463
  ?>
464
+ <option value="<?php echo 'cf_' . (is_array($field) ? $field['label'] : $field); ?>"><?php echo (is_array($field) ? $field['name'] : $field); ?></option>
465
  <?php
466
  break;
467
  case 'existing_taxonomies':
468
  ?>
469
+ <option value="<?php echo 'tx_' . (is_array($field) ? $field['label'] : $field); ?>"><?php echo (is_array($field) ? $field['name'] : $field); ?></option>
470
  <?php
471
  break;
472
 
libraries/XmlExportUser.php CHANGED
@@ -185,7 +185,7 @@ if ( ! class_exists('XmlExportUser') ){
185
 
186
  public static $is_active = true;
187
 
188
- public function __construct()
189
  {
190
 
191
  if ( ( XmlExportEngine::$exportOptions['export_type'] == 'specific' and ! in_array('users', XmlExportEngine::$post_types) )
185
 
186
  public static $is_active = true;
187
 
188
+ private function __construct()
189
  {
190
 
191
  if ( ( XmlExportEngine::$exportOptions['export_type'] == 'specific' and ! in_array('users', XmlExportEngine::$post_types) )
libraries/XmlExportWooCommerce.php CHANGED
@@ -22,6 +22,8 @@ if ( ! class_exists('XmlExportWooCommerce') ){
22
  return self::$instance;
23
  }
24
 
 
 
25
  private $init_fields = array(
26
  array(
27
  'name' => 'SKU',
@@ -42,7 +44,7 @@ if ( ! class_exists('XmlExportWooCommerce') ){
42
 
43
  public static $is_active = true;
44
 
45
- public function __construct(){
46
 
47
  if ( ! class_exists('WooCommerce')
48
  or ( XmlExportEngine::$exportOptions['export_type'] == 'specific' and ! in_array('product', XmlExportEngine::$post_types) )
@@ -55,11 +57,25 @@ if ( ! class_exists('XmlExportWooCommerce') ){
55
  '_visibility', '_stock_status', '_downloadable', '_virtual', '_regular_price', '_sale_price', '_purchase_note', '_featured', '_weight', '_length',
56
  '_width', '_height', '_sku', '_sale_price_dates_from', '_sale_price_dates_to', '_price', '_sold_individually', '_manage_stock', '_stock', '_upsell_ids', '_crosssell_ids',
57
  '_downloadable_files', '_download_limit', '_download_expiry', '_download_type', '_product_url', '_button_text', '_backorders', '_tax_status', '_tax_class', '_product_image_gallery', '_default_attributes',
58
- 'total_sales', '_product_attributes'
59
  );
60
 
61
  $this->_product_data = array('_sku', '_price', '_regular_price','_sale_price', '_stock_status', '_stock', '_visibility', '_product_url', 'total_sales', 'attributes');
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  add_filter("wp_all_export_init_fields", array( &$this, "filter_init_fields"), 10, 1);
64
  add_filter("wp_all_export_default_fields", array( &$this, "filter_default_fields"), 10, 1);
65
  add_filter("wp_all_export_other_fields", array( &$this, "filter_other_fields"), 10, 1);
@@ -89,6 +105,8 @@ if ( ! class_exists('XmlExportWooCommerce') ){
89
 
90
  }
91
 
 
 
92
  $filters['other'] = array(
93
  'title' => __('Advanced', 'wp_all_export_plugin'),
94
  'fields' => array()
@@ -99,14 +117,15 @@ if ( ! class_exists('XmlExportWooCommerce') ){
99
  foreach ($this->_woo_data as $woo_key) {
100
  if ( ! in_array($woo_key, $this->_product_data))
101
  {
102
- $filters['other']['fields']['cf_' . $woo_key] = $woo_key;
103
  }
104
  }
105
 
106
  if ( ! empty(self::$_existing_attributes) )
107
  {
108
  foreach (self::$_existing_attributes as $key => $tx_name) {
109
- $filters['other']['fields']['tx_' . $tx_name] = $tx_name;
 
110
  }
111
  }
112
  }
@@ -154,7 +173,7 @@ if ( ! class_exists('XmlExportWooCommerce') ){
154
  if ( ! in_array($woo_key, $this->_product_data) )
155
  {
156
  $other_fields[] = array(
157
- 'name' => $woo_key,
158
  'label' => $woo_key,
159
  'type' => 'woo'
160
  );
@@ -168,13 +187,15 @@ if ( ! class_exists('XmlExportWooCommerce') ){
168
  continue;
169
 
170
  $other_fields[$key]['auto'] = true;
 
171
  }
172
 
173
  if ( ! empty(self::$_existing_attributes) )
174
  {
175
  foreach (self::$_existing_attributes as $key => $tx_name) {
 
176
  $other_fields[] = array(
177
- 'name' => $tx_name,
178
  'label' => $tx_name,
179
  'type' => 'attr'
180
  );
@@ -217,7 +238,33 @@ if ( ! class_exists('XmlExportWooCommerce') ){
217
  );
218
 
219
  }
220
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
 
222
  return $available_data;
223
  }
@@ -274,6 +321,30 @@ if ( ! class_exists('XmlExportWooCommerce') ){
274
 
275
  }
276
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  protected function prepare_export_data( $record, $options, $elId )
278
  {
279
  $data = array();
@@ -282,7 +353,7 @@ if ( ! class_exists('XmlExportWooCommerce') ){
282
  {
283
  $implode_delimiter = ($options['delimiter'] == ',') ? '|' : ',';
284
 
285
- $element_name = ( ! empty($options['cc_name'][$elId]) ) ? str_replace(" ", "_", $options['cc_name'][$elId]) : 'untitled_' . $elId;
286
  $fieldSnipped = ( ! empty($options['cc_php'][$elId]) and ! empty($options['cc_code'][$elId]) ) ? $options['cc_code'][$elId] : false;
287
 
288
  switch ($options['cc_value'][$elId])
@@ -300,6 +371,7 @@ if ( ! class_exists('XmlExportWooCommerce') ){
300
  }
301
  }
302
 
 
303
  if ( ! empty(self::$_existing_attributes))
304
  {
305
  foreach (self::$_existing_attributes as $taxonomy_slug) {
@@ -333,6 +405,19 @@ if ( ! class_exists('XmlExportWooCommerce') ){
333
 
334
  }
335
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
336
  break;
337
 
338
  default:
@@ -344,11 +429,7 @@ if ( ! class_exists('XmlExportWooCommerce') ){
344
  foreach ($cur_meta_values as $key => $cur_meta_value)
345
  {
346
  switch ($options['cc_label'][$elId])
347
- {
348
- case 'attributes':
349
-
350
-
351
- break;
352
  case '_downloadable_files':
353
 
354
  $files = maybe_unserialize($cur_meta_value);
@@ -408,16 +489,15 @@ if ( ! class_exists('XmlExportWooCommerce') ){
408
  return $data;
409
  }
410
 
411
- public function export_csv( & $article, & $titles, $record, $options, $elId )
412
  {
413
  if ( ! self::$is_active ) return;
414
 
415
- $data_to_export = $this->prepare_export_data( $record, $options, $elId );
416
 
417
  foreach ($data_to_export as $key => $data)
418
  {
419
- $article[$key] = $data;
420
- if ( ! in_array($key, $titles) ) $titles[] = $key;
421
  }
422
 
423
  }
@@ -428,6 +508,7 @@ if ( ! class_exists('XmlExportWooCommerce') ){
428
  {
429
  case 'attributes':
430
 
 
431
  if ( ! empty(self::$_existing_attributes))
432
  {
433
  foreach (self::$_existing_attributes as $taxonomy_slug) {
@@ -439,6 +520,18 @@ if ( ! class_exists('XmlExportWooCommerce') ){
439
  }
440
  }
441
 
 
 
 
 
 
 
 
 
 
 
 
 
442
  break;
443
 
444
  default:
@@ -457,73 +550,11 @@ if ( ! class_exists('XmlExportWooCommerce') ){
457
 
458
  foreach ($data_to_export as $key => $data)
459
  {
460
- $xmlWriter->startElement(str_replace("-", "_", preg_replace('/[^a-z0-9_]/i', '', sanitize_title($key))));
461
  $xmlWriter->writeCData($data);
462
  $xmlWriter->endElement();
463
  }
464
 
465
- }
466
-
467
- public function render( & $i ){
468
-
469
- if ( self::$is_active and ! empty($this->_woo_data) ){
470
- ?>
471
- <p class="wpae-available-fields-group"><?php _e("WooCommerce", "wp_all_export_plugin"); ?><span class="wpae-expander">+</span></p>
472
- <div class="wpae-custom-field">
473
- <ul>
474
- <li>
475
- <div class="default_column" rel="">
476
- <label class="wpallexport-element-label"><?php _e("All WooCommerce Data", "wp_all_export_plugin"); ?></label>
477
- <input type="hidden" name="rules[]" value="pmxe_woo"/>
478
- </div>
479
- </li>
480
- <?php
481
- foreach ($this->_woo_data as $cur_meta_key) {
482
- if ( strpos($cur_meta_key, 'attribute_pa_') === 0 ) continue;
483
- ?>
484
- <li class="pmxe_woo">
485
- <div class="custom_column" rel="<?php echo ($i + 1);?>">
486
- <label class="wpallexport-xml-element">&lt;<?php echo $cur_meta_key; ?>&gt;</label>
487
- <input type="hidden" name="ids[]" value="1"/>
488
- <input type="hidden" name="cc_label[]" value="<?php echo $cur_meta_key; ?>"/>
489
- <input type="hidden" name="cc_php[]" value=""/>
490
- <input type="hidden" name="cc_code[]" value=""/>
491
- <input type="hidden" name="cc_sql[]" value=""/>
492
- <input type="hidden" name="cc_options[]" value=""/>
493
- <input type="hidden" name="cc_type[]" value="woo"/>
494
- <input type="hidden" name="cc_value[]" value="<?php echo $cur_meta_key; ?>"/>
495
- <input type="hidden" name="cc_name[]" value="<?php echo str_replace(" ", "_", $cur_meta_key);?>"/>
496
- </div>
497
- </li>
498
- <?php
499
- $i++;
500
- }
501
- if ( ! empty($this->_existing_attributes) ){
502
- foreach ($this->_existing_attributes as $key => $tx_name) {
503
- ?>
504
- <li class="pmxe_woo">
505
- <div class="custom_column" rel="<?php echo ($i + 1);?>">
506
- <label class="wpallexport-xml-element">&lt;<?php echo $tx_name; ?>&gt;</label>
507
- <input type="hidden" name="ids[]" value="1"/>
508
- <input type="hidden" name="cc_label[]" value="<?php echo $tx_name; ?>"/>
509
- <input type="hidden" name="cc_php[]" value=""/>
510
- <input type="hidden" name="cc_code[]" value=""/>
511
- <input type="hidden" name="cc_sql[]" value=""/>
512
- <input type="hidden" name="cc_options[]" value=""/>
513
- <input type="hidden" name="cc_type[]" value="attr"/>
514
- <input type="hidden" name="cc_value[]" value="<?php echo $tx_name; ?>"/>
515
- <input type="hidden" name="cc_name[]" value="<?php echo str_replace(" ", "_", $tx_name);?>"/>
516
- </div>
517
- </li>
518
- <?php
519
- $i++;
520
- }
521
- }
522
- ?>
523
- </ul>
524
- </div>
525
- <?php
526
- }
527
  }
528
 
529
  /**
22
  return self::$instance;
23
  }
24
 
25
+ public static $products_data = null;
26
+
27
  private $init_fields = array(
28
  array(
29
  'name' => 'SKU',
44
 
45
  public static $is_active = true;
46
 
47
+ private function __construct(){
48
 
49
  if ( ! class_exists('WooCommerce')
50
  or ( XmlExportEngine::$exportOptions['export_type'] == 'specific' and ! in_array('product', XmlExportEngine::$post_types) )
57
  '_visibility', '_stock_status', '_downloadable', '_virtual', '_regular_price', '_sale_price', '_purchase_note', '_featured', '_weight', '_length',
58
  '_width', '_height', '_sku', '_sale_price_dates_from', '_sale_price_dates_to', '_price', '_sold_individually', '_manage_stock', '_stock', '_upsell_ids', '_crosssell_ids',
59
  '_downloadable_files', '_download_limit', '_download_expiry', '_download_type', '_product_url', '_button_text', '_backorders', '_tax_status', '_tax_class', '_product_image_gallery', '_default_attributes',
60
+ 'total_sales', '_product_attributes', '_product_version'
61
  );
62
 
63
  $this->_product_data = array('_sku', '_price', '_regular_price','_sale_price', '_stock_status', '_stock', '_visibility', '_product_url', 'total_sales', 'attributes');
64
 
65
+ if ( empty(PMXE_Plugin::$session) ) // if cron execution
66
+ {
67
+ $id = $_GET['export_id'];
68
+ $export = new PMXE_Export_Record();
69
+ $export->getById($id);
70
+ if ( ! $export->isEmpty() and $export->options['export_to'] == 'csv'){
71
+ $this->init_additional_data();
72
+ }
73
+ }
74
+ else
75
+ {
76
+ self::$products_data = PMXE_Plugin::$session->get('products_data');
77
+ }
78
+
79
  add_filter("wp_all_export_init_fields", array( &$this, "filter_init_fields"), 10, 1);
80
  add_filter("wp_all_export_default_fields", array( &$this, "filter_default_fields"), 10, 1);
81
  add_filter("wp_all_export_other_fields", array( &$this, "filter_other_fields"), 10, 1);
105
 
106
  }
107
 
108
+ $filters['product_data']['fields']['tx_product_shipping_class'] = 'Shipping Class';
109
+
110
  $filters['other'] = array(
111
  'title' => __('Advanced', 'wp_all_export_plugin'),
112
  'fields' => array()
117
  foreach ($this->_woo_data as $woo_key) {
118
  if ( ! in_array($woo_key, $this->_product_data))
119
  {
120
+ $filters['other']['fields']['cf_' . $woo_key] = ucwords(str_replace("_", " ", trim($woo_key, "_")));
121
  }
122
  }
123
 
124
  if ( ! empty(self::$_existing_attributes) )
125
  {
126
  foreach (self::$_existing_attributes as $key => $tx_name) {
127
+ $tx = get_taxonomy($tx_name);
128
+ $filters['other']['fields']['tx_' . $tx_name] = $tx->label;
129
  }
130
  }
131
  }
173
  if ( ! in_array($woo_key, $this->_product_data) )
174
  {
175
  $other_fields[] = array(
176
+ 'name' => ucwords(str_replace("_", " ", trim($woo_key, "_"))),
177
  'label' => $woo_key,
178
  'type' => 'woo'
179
  );
187
  continue;
188
 
189
  $other_fields[$key]['auto'] = true;
190
+ $other_fields[$key]['name'] = ucwords(str_replace("_", " ", trim($other_fields[$key]['name'])));
191
  }
192
 
193
  if ( ! empty(self::$_existing_attributes) )
194
  {
195
  foreach (self::$_existing_attributes as $key => $tx_name) {
196
+ $tx = get_taxonomy($tx_name);
197
  $other_fields[] = array(
198
+ 'name' => $tx->label,
199
  'label' => $tx_name,
200
  'type' => 'attr'
201
  );
238
  );
239
 
240
  }
241
+ }
242
+
243
+ if ( ! empty($available_data['existing_taxonomies']) ) {
244
+ $existing_taxonomies = $available_data['existing_taxonomies'];
245
+ $available_data['existing_taxonomies'] = array();
246
+ foreach ($existing_taxonomies as $tx_name) {
247
+ $tx = get_taxonomy($tx_name);
248
+ if ($tx_name == 'product_shipping_class')
249
+ {
250
+ $available_data['product_fields'][] = array(
251
+ 'name' => 'Shipping Class',
252
+ 'label' => $tx_name,
253
+ 'type' => 'cats',
254
+ 'auto' => true
255
+ );
256
+ }
257
+ else
258
+ {
259
+ $available_data['existing_taxonomies'][] = array(
260
+ 'name' => ($tx_name == 'product_type') ? 'Product Type' : $tx->label,
261
+ 'label' => $tx_name,
262
+ 'type' => 'cats',
263
+ 'auto' => true
264
+ );
265
+ }
266
+ }
267
+ }
268
 
269
  return $available_data;
270
  }
321
 
322
  }
323
 
324
+ public function init_additional_data()
325
+ {
326
+ if ( ! self::$is_active ) return;
327
+
328
+ if ( empty(self::$products_data) or 'PMXE_Admin_Manage' == PMXE_Plugin::getInstance()->getAdminCurrentScreen()->base )
329
+ {
330
+
331
+ self::$products_data = array();
332
+
333
+ global $wpdb;
334
+
335
+ $table_prefix = $wpdb->prefix;
336
+
337
+ self::$products_data['attributes'] = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT meta_key FROM {$table_prefix}postmeta
338
+ WHERE {$table_prefix}postmeta.meta_key LIKE %s AND {$table_prefix}postmeta.meta_key NOT LIKE %s", 'attribute_%', 'attribute_pa_%'));
339
+
340
+ if ( ! empty(PMXE_Plugin::$session) )
341
+ {
342
+ PMXE_Plugin::$session->set('products_data', self::$products_data);
343
+ PMXE_Plugin::$session->save_data();
344
+ }
345
+ }
346
+ }
347
+
348
  protected function prepare_export_data( $record, $options, $elId )
349
  {
350
  $data = array();
353
  {
354
  $implode_delimiter = ($options['delimiter'] == ',') ? '|' : ',';
355
 
356
+ $element_name = ( ! empty($options['cc_name'][$elId]) ) ? $options['cc_name'][$elId] : 'untitled_' . $elId;
357
  $fieldSnipped = ( ! empty($options['cc_php'][$elId]) and ! empty($options['cc_code'][$elId]) ) ? $options['cc_code'][$elId] : false;
358
 
359
  switch ($options['cc_value'][$elId])
371
  }
372
  }
373
 
374
+ // combine taxonomies attributes
375
  if ( ! empty(self::$_existing_attributes))
376
  {
377
  foreach (self::$_existing_attributes as $taxonomy_slug) {
405
 
406
  }
407
  }
408
+
409
+ // combine custom attributes
410
+ if ( ! empty(self::$products_data['attributes']))
411
+ {
412
+ foreach (self::$products_data['attributes'] as $attribute)
413
+ {
414
+ $attribute_name = ucfirst(str_replace('attribute_', '', $attribute->meta_key));
415
+
416
+ $data['Attribute Name (' . $attribute_name . ')'] = $attribute_name;
417
+ $data['Attribute Value (' . $attribute_name . ')'] = get_post_meta($record->ID, $attribute->meta_key, true);
418
+ }
419
+ }
420
+
421
  break;
422
 
423
  default:
429
  foreach ($cur_meta_values as $key => $cur_meta_value)
430
  {
431
  switch ($options['cc_label'][$elId])
432
+ {
 
 
 
 
433
  case '_downloadable_files':
434
 
435
  $files = maybe_unserialize($cur_meta_value);
489
  return $data;
490
  }
491
 
492
+ public function export_csv( & $article, & $titles, $record, $options, $element_key )
493
  {
494
  if ( ! self::$is_active ) return;
495
 
496
+ $data_to_export = $this->prepare_export_data( $record, $options, $element_key );
497
 
498
  foreach ($data_to_export as $key => $data)
499
  {
500
+ $article[$key] = $data;
 
501
  }
502
 
503
  }
508
  {
509
  case 'attributes':
510
 
511
+ // headers for taxonomy attributes
512
  if ( ! empty(self::$_existing_attributes))
513
  {
514
  foreach (self::$_existing_attributes as $taxonomy_slug) {
520
  }
521
  }
522
 
523
+ // headers for custom attributes
524
+ if ( ! empty(self::$products_data['attributes']))
525
+ {
526
+ foreach (self::$products_data['attributes'] as $attribute)
527
+ {
528
+ $attribute_name = ucfirst(str_replace('attribute_', '', $attribute->meta_key));
529
+
530
+ $headers[] = 'Attribute Name (' . $attribute_name . ')';
531
+ $headers[] = 'Attribute Value (' . $attribute_name . ')';
532
+ }
533
+ }
534
+
535
  break;
536
 
537
  default:
550
 
551
  foreach ($data_to_export as $key => $data)
552
  {
553
+ $xmlWriter->startElement(str_replace("-", "_", preg_replace('/[^a-z0-9_]/i', '', $key)));
554
  $xmlWriter->writeCData($data);
555
  $xmlWriter->endElement();
556
  }
557
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
558
  }
559
 
560
  /**
libraries/XmlExportWooCommerceOrder.php CHANGED
@@ -51,7 +51,7 @@ if ( ! class_exists('XmlExportWooCommerceOrder') ){
51
 
52
  private $filter_sections = array();
53
 
54
- public function __construct()
55
  {
56
 
57
  if ( ! class_exists('WooCommerce')
51
 
52
  private $filter_sections = array();
53
 
54
+ private function __construct()
55
  {
56
 
57
  if ( ! class_exists('WooCommerce')
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: soflyy, wpallimport
3
  Requires at least: 4.1
4
  Tested up to: 4.3
5
- Stable tag: 1.0.0
6
  Tags: wordpress csv export, wordpress xml export, xml, csv, datafeed, export, migrate, export csv from wordpress, export xml from wordpress, advanced xml export, advanced csv export, export data, bulk csv export, export custom post type, export woocommerce products, export woocommerce orders, migrate woocommerce, csv export, export csv, xml export, export xml, csv exporter, datafeed
7
 
8
  WP All Export is an extremely powerful exporter that makes it easy to export any XML or CSV file from WordPress.
@@ -34,7 +34,7 @@ For technical support from the developers, please consider purchasing WP All Exp
34
 
35
  * **Add rules to filter data:** WP All Export Pro makes it easy to export specific datasets. Want to export all WooCommerce orders over $100? Want to export all of the green shirts from your WooCommerce store? Want to export all new posts from 2014, except the ones added by Steve?
36
 
37
- You can with a simple to use interface on the New Export page in WP All Export Pro.
38
 
39
  * **Export WordPress users:** WP All Export Pro adds the ability to export WordPress users and all custom data associated with them. Available data is organized and cleaned up so you don’t need to know anything about how WordPress stores users in order to export them.
40
 
@@ -46,6 +46,18 @@ For technical support from the developers, please consider purchasing WP All Exp
46
 
47
  [Upgrade to the professional edition of WP All Export.](http://www.wpallimport.com/upgrade-to-wp-all-export-pro/?utm_source=wordpress.org&utm_medium=wordpress-dot-org-slash-wpae&utm_campaign=free+wp+all+export+plugin)
48
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  == Premium Support ==
50
  Upgrade to the professional edition of WP All Export for premium support.
51
 
@@ -60,6 +72,17 @@ Either: -
60
 
61
  == Changelog ==
62
 
 
 
 
 
 
 
 
 
 
 
 
63
  = 1.0.0 =
64
  * WP All Export exits beta
65
 
2
  Contributors: soflyy, wpallimport
3
  Requires at least: 4.1
4
  Tested up to: 4.3
5
+ Stable tag: 1.0.1
6
  Tags: wordpress csv export, wordpress xml export, xml, csv, datafeed, export, migrate, export csv from wordpress, export xml from wordpress, advanced xml export, advanced csv export, export data, bulk csv export, export custom post type, export woocommerce products, export woocommerce orders, migrate woocommerce, csv export, export csv, xml export, export xml, csv exporter, datafeed
7
 
8
  WP All Export is an extremely powerful exporter that makes it easy to export any XML or CSV file from WordPress.
34
 
35
  * **Add rules to filter data:** WP All Export Pro makes it easy to export specific datasets. Want to export all WooCommerce orders over $100? Want to export all of the green shirts from your WooCommerce store? Want to export all new posts from 2014, except the ones added by Steve?
36
 
37
+ You can with a simple to use interface on the 'New Export' page in WP All Export Pro.
38
 
39
  * **Export WordPress users:** WP All Export Pro adds the ability to export WordPress users and all custom data associated with them. Available data is organized and cleaned up so you don’t need to know anything about how WordPress stores users in order to export them.
40
 
46
 
47
  [Upgrade to the professional edition of WP All Export.](http://www.wpallimport.com/upgrade-to-wp-all-export-pro/?utm_source=wordpress.org&utm_medium=wordpress-dot-org-slash-wpae&utm_campaign=free+wp+all+export+plugin)
48
 
49
+ = WordPress CSV Exports =
50
+
51
+ A CSV is a very simple type of spreadsheet file where each column is separated by a comma. With WP All Export you can very easily set up a WordPress CSV export and control the order and title of the columns.
52
+
53
+ Very often you'll want to edit your data with Microsoft Excel, Google Sheets, Numbers, or maybe something else. This is why a CSV export is so powerful - all spreadsheet software can read, edit, and save CSV files. WP All Export allows you edit your WordPress data using whatever spreadsheet software you are most comfortable with.
54
+
55
+ = WordPress XML Exports =
56
+
57
+ Sometimes you'll want to export your data so that some other tool, software, or service can use it. Very often they will require your data to be formatted as an XML file. XML is very similar to HTML, but you don't need to know anything about that in order to set up an XML export with WP All Export.
58
+
59
+ If you want to set up a WordPress XML export all you need to do is select 'XML' when configuring your export template. And just like a CSV export, an XML export will allow you to customize the element names and put them in any order you wish.
60
+
61
  == Premium Support ==
62
  Upgrade to the professional edition of WP All Export for premium support.
63
 
72
 
73
  == Changelog ==
74
 
75
+ = 1.0.1 =
76
+ * fixed export taxonomy: name instead of slug
77
+ * fixed pass data through php function
78
+ * added advanced (custom fields) section to export woo orders
79
+ * added draggable element deletion
80
+ * added auto-generate product export fields
81
+ * added 'attributes' field to product data
82
+ * added button to download bundle for WP All Import
83
+ * updated export file name
84
+ * changed export files destination to /exports
85
+
86
  = 1.0.0 =
87
  * WP All Export exits beta
88
 
static/css/admin.css CHANGED
@@ -169,7 +169,7 @@
169
  float: right;
170
  position: relative;
171
  right: 30px;
172
- top: -15px;
173
  }
174
  .wpallexport-plugin .wpallexport-csv-delimiter input[type="text"]{
175
  vertical-align:middle;
@@ -216,7 +216,13 @@
216
  .wpallexport-plugin .pmxe_date_format_wrapper{
217
  display: none;
218
  }
219
-
 
 
 
 
 
 
220
 
221
  /*--------------------------------------------------------------------------
222
  *
@@ -2636,6 +2642,24 @@
2636
  text-align: center;
2637
  padding-top: 30px;
2638
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2639
  .wpallexport-plugin #export_finished .wpallexport-log-details{
2640
  display: none;
2641
  }
169
  float: right;
170
  position: relative;
171
  right: 30px;
172
+ top: -16px;
173
  }
174
  .wpallexport-plugin .wpallexport-csv-delimiter input[type="text"]{
175
  vertical-align:middle;
216
  .wpallexport-plugin .pmxe_date_format_wrapper{
217
  display: none;
218
  }
219
+ .wpallexport-plugin span.auto-generate-template{
220
+ color: #888;
221
+ display: block;
222
+ font-size: 12px;
223
+ margin-right: 190px;
224
+ opacity: 0.7;
225
+ }
226
 
227
  /*--------------------------------------------------------------------------
228
  *
2642
  text-align: center;
2643
  padding-top: 30px;
2644
  }
2645
+ .wpallexport-plugin #export_finished p{
2646
+ color: #777;
2647
+ font-size: 16px;
2648
+ }
2649
+ .wpallexport-plugin #export_finished .wp_all_export_download div.input{
2650
+ display: inline-block;
2651
+ vertical-align: top;
2652
+ }
2653
+ .wpallexport-plugin #export_finished .wp_all_export_download div.input .button-primary{
2654
+ width: 193px;
2655
+ background-image: none;
2656
+ }
2657
+ .wpallexport-plugin #export_finished .wp_all_export_download div.input span{
2658
+ color: #777;
2659
+ display: block;
2660
+ font-size: 10px;
2661
+ }
2662
+
2663
  .wpallexport-plugin #export_finished .wpallexport-log-details{
2664
  display: none;
2665
  }
static/js/admin.js CHANGED
@@ -199,12 +199,14 @@
199
  $('.wpallexport-import-from').click(function(){
200
 
201
  var showImportType = false;
 
 
202
 
203
  switch ($(this).attr('rel')){
204
  case 'specific_type':
205
- if ($('input[name=cpt]').val() != ''){
206
 
207
- if ($('input[name=cpt]').val() == 'users'){
208
  $('.wpallexport-user-export-notice').show();
209
  showImportType = false;
210
  $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideDown();
@@ -214,16 +216,26 @@
214
  $('.wpallexport-user-export-notice').hide();
215
  showImportType = true;
216
  $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideDown();
217
- }
 
 
 
 
 
 
 
 
218
  }
219
  else
220
  {
 
221
  $('.wpallexport-user-export-notice').hide();
222
  showImportType = false;
223
  $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideUp();
224
  }
225
  break;
226
  case 'advanced_type':
 
227
  if ($('input[name=wp_query_selector]').val() == 'wp_user_query')
228
  {
229
  $('.wpallexport-user-export-notice').show();
@@ -286,11 +298,21 @@
286
  $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').show();
287
  }
288
 
 
 
 
 
 
 
 
 
 
289
  filtering(postType);
290
 
291
  }
292
  else
293
  {
 
294
  $('.wpallexport-user-export-notice').hide();
295
  $('.wpallexport-choose-file').find('input[name=cpt]').val('');
296
  $('#file_selector').find('.dd-selected').css({'color':'#cfceca'});
@@ -312,7 +334,20 @@
312
  }
313
  }
314
  });
 
 
 
 
 
 
 
 
 
 
315
 
 
 
 
316
  $('form.wpallexport-choose-file').find('input[type=submit]').click(function(e){
317
  e.preventDefault();
318
 
@@ -929,9 +964,9 @@
929
 
930
  };
931
 
932
- $(this).find('.preview_a_row').click( function(){
933
  doPreview($(this), 1);
934
- });
935
 
936
  $('.wpae-available-fields-group').click(function(){
937
  var $mode = $(this).find('.wpae-expander').text();
@@ -1114,6 +1149,12 @@
1114
  }
1115
  //[/End Step 3]
1116
 
 
 
 
 
 
 
1117
  // additional functionality
1118
 
1119
  $('.wpallexport-overlay').click(function(){
199
  $('.wpallexport-import-from').click(function(){
200
 
201
  var showImportType = false;
202
+
203
+ var postType = $('input[name=cpt]').val();
204
 
205
  switch ($(this).attr('rel')){
206
  case 'specific_type':
207
+ if (postType != ''){
208
 
209
+ if (postType == 'users'){
210
  $('.wpallexport-user-export-notice').show();
211
  showImportType = false;
212
  $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideDown();
216
  $('.wpallexport-user-export-notice').hide();
217
  showImportType = true;
218
  $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideDown();
219
+ }
220
+ if (postType == 'product')
221
+ {
222
+ $('.auto-generate-template').show();
223
+ }
224
+ else
225
+ {
226
+ $('.auto-generate-template').hide();
227
+ }
228
  }
229
  else
230
  {
231
+ $('.auto-generate-template').hide();
232
  $('.wpallexport-user-export-notice').hide();
233
  showImportType = false;
234
  $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideUp();
235
  }
236
  break;
237
  case 'advanced_type':
238
+ $('.auto-generate-template').hide();
239
  if ($('input[name=wp_query_selector]').val() == 'wp_user_query')
240
  {
241
  $('.wpallexport-user-export-notice').show();
298
  $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').show();
299
  }
300
 
301
+ if (postType == 'product')
302
+ {
303
+ $('.auto-generate-template').show();
304
+ }
305
+ else
306
+ {
307
+ $('.auto-generate-template').hide();
308
+ }
309
+
310
  filtering(postType);
311
 
312
  }
313
  else
314
  {
315
+ $('.auto-generate-template').hide();
316
  $('.wpallexport-user-export-notice').hide();
317
  $('.wpallexport-choose-file').find('input[name=cpt]').val('');
318
  $('#file_selector').find('.dd-selected').css({'color':'#cfceca'});
334
  }
335
  }
336
  });
337
+
338
+ $('a.auto-generate-template').click(function(){
339
+ $('input[name^=auto_generate]').val('1');
340
+
341
+ $('.hierarhy-output').each(function(){
342
+ var sortable = $('.wp_all_export_filtering_rules.ui-sortable');
343
+ if (sortable.length){
344
+ $(this).val(window.JSON.stringify(sortable.pmxe_nestedSortable('toArray', {startDepthCount: 0})));
345
+ }
346
+ });
347
 
348
+ $(this).parents('form:first').submit();
349
+ });
350
+
351
  $('form.wpallexport-choose-file').find('input[type=submit]').click(function(e){
352
  e.preventDefault();
353
 
964
 
965
  };
966
 
967
+ $(this).find('.preview_a_row').click( function(){
968
  doPreview($(this), 1);
969
+ });
970
 
971
  $('.wpae-available-fields-group').click(function(){
972
  var $mode = $(this).find('.wpae-expander').text();
1149
  }
1150
  //[/End Step 3]
1151
 
1152
+ //[Step 4]
1153
+ $('.download_data').click(function(){
1154
+ window.location.href = $(this).attr('rel');
1155
+ });
1156
+ //[/End Step 4]
1157
+
1158
  // additional functionality
1159
 
1160
  $('.wpallexport-overlay').click(function(){
views/admin/export/index.php CHANGED
@@ -109,8 +109,16 @@
109
  <p class="wpallexport-submit-buttons" <?php if ('advanced' == $post['export_type']) echo 'style="display:block;"';?>>
110
  <input type="hidden" name="custom_type" value="">
111
  <input type="hidden" name="is_submitted" value="1" />
 
 
112
  <?php wp_nonce_field('choose-cpt', '_wpnonce_choose-cpt'); ?>
 
 
 
113
  <input type="submit" class="button button-primary button-hero wpallexport-large-button" value="<?php _e('Continue to Step 2', 'wp_all_export_plugin') ?>" id="advanced_upload"/>
 
 
 
114
  </p>
115
 
116
  <table><tr><td class="wpallexport-note"></td></tr></table>
109
  <p class="wpallexport-submit-buttons" <?php if ('advanced' == $post['export_type']) echo 'style="display:block;"';?>>
110
  <input type="hidden" name="custom_type" value="">
111
  <input type="hidden" name="is_submitted" value="1" />
112
+ <input type="hidden" name="auto_generate" value="0" />
113
+
114
  <?php wp_nonce_field('choose-cpt', '_wpnonce_choose-cpt'); ?>
115
+
116
+ <a href="javascript:void(0);" class="back rad3 auto-generate-template" style="float:none; background: #e4e6e6; padding: 0 50px;"><?php _e('Skip to Step 3', 'wp_all_export_plugin'); ?></a>
117
+
118
  <input type="submit" class="button button-primary button-hero wpallexport-large-button" value="<?php _e('Continue to Step 2', 'wp_all_export_plugin') ?>" id="advanced_upload"/>
119
+
120
+ <span class="auto-generate-template"><?php _e('Auto Generate Export Template', 'wp_all_export_plugin'); ?></span>
121
+
122
  </p>
123
 
124
  <table><tr><td class="wpallexport-note"></td></tr></table>
views/admin/export/options.php CHANGED
@@ -72,7 +72,7 @@
72
  <div class="wpallexport-collapsed-content" style="padding: 0;">
73
  <div class="wpallexport-collapsed-content-inner">
74
  <div class="wpallexport-free-edition-notice" style="padding: 20px; margin-bottom: 10px;">
75
- <a class="upgrade_link" target="_blank" href="http://www.wpallimport.com/upgrade-to-pro/?utm_source=free-plugin&amp;utm_medium=in-plugin&amp;utm_campaign=download-from-url"><?php _e('Upgrade to the professional edition of WP All Export to use this feature.','wp_all_export_plugin');?></a>
76
  </div>
77
  <input type="hidden" name="selected_post_type" value="<?php echo array_shift($post['cpt']); ?>"/>
78
  <div class="wp_all_export_rule_inputs">
@@ -85,13 +85,13 @@
85
  </tr>
86
  <tr>
87
  <td style="width: 25%;">
88
- <select id="wp_all_export_xml_element" disabled="disabled">
89
  <option value=""><?php _e('Select Element', 'wp_all_export_plugin'); ?></option>
90
  <?php echo $engine->render_filters(); ?>
91
  </select>
92
  </td>
93
  <td style="width: 25%;" id="wp_all_export_available_rules">
94
- <select id="wp_all_export_rule" disabled="disabled">
95
  <option value=""><?php _e('Select Rule', 'wp_all_export_plugin'); ?></option>
96
  </select>
97
  </td>
@@ -195,9 +195,7 @@
195
  <div class="input" style="margin:5px 0px;">
196
  <label for="records_per_request"><?php _e('In each iteration, process', 'wp_all_export_plugin');?> <input type="text" name="records_per_iteration" style="vertical-align:middle; font-size:11px; background:#fff !important; width: 40px; text-align:center;" value="<?php echo esc_attr($post['records_per_iteration']) ?>" /> <?php _e('records', 'wp_all_export_plugin'); ?></label>
197
  <a href="#help" class="wpallexport-help" style="position: relative; top: -2px;" title="<?php _e('WP All Export must be able to process this many records in less than your server\'s timeout settings. If your export fails before completion, to troubleshoot you should lower this number.', 'wp_all_export_plugin'); ?>">?</a>
198
- </div>
199
- <!--h4><?php _e('File Type:', 'pmxe_plugin'); ?></h4-->
200
-
201
  <br>
202
  <hr>
203
  <p style="text-align:right;">
72
  <div class="wpallexport-collapsed-content" style="padding: 0;">
73
  <div class="wpallexport-collapsed-content-inner">
74
  <div class="wpallexport-free-edition-notice" style="padding: 20px; margin-bottom: 10px;">
75
+ <a class="upgrade_link" target="_blank" href="http://www.wpallimport.com/upgrade-to-pro/?utm_source=free-plugin&amp;utm_medium=in-plugin&amp;utm_campaign=download-from-url"><?php _e('Upgrade to the professional edition of WP All Export to add filtering rules.','wp_all_export_plugin');?></a>
76
  </div>
77
  <input type="hidden" name="selected_post_type" value="<?php echo array_shift($post['cpt']); ?>"/>
78
  <div class="wp_all_export_rule_inputs">
85
  </tr>
86
  <tr>
87
  <td style="width: 25%;">
88
+ <select id="wp_all_export_xml_element">
89
  <option value=""><?php _e('Select Element', 'wp_all_export_plugin'); ?></option>
90
  <?php echo $engine->render_filters(); ?>
91
  </select>
92
  </td>
93
  <td style="width: 25%;" id="wp_all_export_available_rules">
94
+ <select id="wp_all_export_rule">
95
  <option value=""><?php _e('Select Rule', 'wp_all_export_plugin'); ?></option>
96
  </select>
97
  </td>
195
  <div class="input" style="margin:5px 0px;">
196
  <label for="records_per_request"><?php _e('In each iteration, process', 'wp_all_export_plugin');?> <input type="text" name="records_per_iteration" style="vertical-align:middle; font-size:11px; background:#fff !important; width: 40px; text-align:center;" value="<?php echo esc_attr($post['records_per_iteration']) ?>" /> <?php _e('records', 'wp_all_export_plugin'); ?></label>
197
  <a href="#help" class="wpallexport-help" style="position: relative; top: -2px;" title="<?php _e('WP All Export must be able to process this many records in less than your server\'s timeout settings. If your export fails before completion, to troubleshoot you should lower this number.', 'wp_all_export_plugin'); ?>">?</a>
198
+ </div>
 
 
199
  <br>
200
  <hr>
201
  <p style="text-align:right;">
views/admin/export/process.php CHANGED
@@ -35,7 +35,16 @@
35
  <div id="export_finished">
36
  <!--h1><?php _e('Export Complete!', 'wp_all_export_plugin'); ?></h1-->
37
  <h3><?php _e('WP All Export successfully exported your data!','wp_all_export_plugin'); ?></h3>
38
- <h3><a href="<?php echo add_query_arg(array('action' => 'download', '_wpnonce' => wp_create_nonce( '_wpnonce-download_feed' )), $this->baseUrl); ?>" id="download_log" style="text-decoration: underline;"><?php _e('Download Exported Data', 'wp_all_export_plugin'); ?></a></h3>
 
 
 
 
 
 
 
 
 
39
  <hr>
40
  <a href="<?php echo add_query_arg(array('page' => 'pmxe-admin-manage'), remove_query_arg(array('id','page'), $this->baseUrl)); ?>" id="manage_imports"><?php _e('Manage Exports', 'wp_all_export_plugin') ?></a>
41
  </div>
35
  <div id="export_finished">
36
  <!--h1><?php _e('Export Complete!', 'wp_all_export_plugin'); ?></h1-->
37
  <h3><?php _e('WP All Export successfully exported your data!','wp_all_export_plugin'); ?></h3>
38
+ <p><?php _e('Download Data', 'wp_all_export_plugin'); ?></p>
39
+ <div class="input wp_all_export_download">
40
+ <div class="input">
41
+ <button class="button button-primary button-hero wpallexport-large-button download_data" rel="<?php echo add_query_arg(array('action' => 'download', '_wpnonce' => wp_create_nonce( '_wpnonce-download_feed' )), $this->baseUrl); ?>"><?php echo strtoupper($update_previous->options['export_to']); ?></button>
42
+ </div>
43
+ <div class="input" style="margin-left: 10px;">
44
+ <button class="button button-primary button-hero wpallexport-large-button download_data" rel="<?php echo add_query_arg(array('page' => 'pmxe-admin-manage', 'id' => $update_previous->id, 'action' => 'bundle', '_wpnonce' => wp_create_nonce( '_wpnonce-download_bundle' )), $this->baseUrl); ?>"><?php _e('Bundle', 'wp_all_export_plugin'); ?></button>
45
+ <span><?php _e('Settings & Data for WP All Import', 'wp_all_export_plugin'); ?></span>
46
+ </div>
47
+ </div>
48
  <hr>
49
  <a href="<?php echo add_query_arg(array('page' => 'pmxe-admin-manage'), remove_query_arg(array('id','page'), $this->baseUrl)); ?>" id="manage_imports"><?php _e('Manage Exports', 'wp_all_export_plugin') ?></a>
50
  </div>
views/admin/manage/index.php CHANGED
@@ -128,16 +128,22 @@ $columns = apply_filters('pmxe_manage_imports_columns', $columns);
128
  break;
129
  case 'name':
130
  ?>
131
- <td>
132
  <strong><?php echo $item['friendly_name']; ?></strong> <br>
133
  <div class="row-actions">
134
  <span class="edit"><a class="edit" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'template'), $this->baseUrl)) ?>"><?php _e('Edit Template', 'wp_all_export_plugin') ?></a></span> |
135
  <span class="edit"><a class="edit" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'options'), $this->baseUrl)) ?>"><?php _e('Edit Options', 'wp_all_export_plugin') ?></a></span> |
136
  <?php if ( ! $is_secure_import and $item['attch_id']): ?>
137
- <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'get_file', '_wpnonce' => wp_create_nonce( '_wpnonce-download_feed' )), $this->baseUrl)) ?>"><?php _e('Download', 'wp_all_export_plugin') ?></a></span> |
 
 
 
138
  <?php endif; ?>
139
  <?php if ($is_secure_import and ! empty($item['options']['filepath'])): ?>
140
- <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'get_file', '_wpnonce' => wp_create_nonce( '_wpnonce-download_feed' )), $this->baseUrl)) ?>"><?php _e('Download', 'wp_all_export_plugin') ?></a></span> |
 
 
 
141
  <?php endif; ?>
142
  <span class="delete"><a class="delete" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'delete'), $this->baseUrl)) ?>"><?php _e('Delete', 'wp_all_export_plugin') ?></a></span>
143
  </div>
@@ -193,16 +199,16 @@ $columns = apply_filters('pmxe_manage_imports_columns', $columns);
193
  <a href="<?php echo add_query_arg(array('page' => 'pmxi-admin-import', 'id' => $item['options']['import_id'], 'deligate' => 'wpallexport'), remove_query_arg('page', $this->baseUrl)); ?>"><?php _e("Import with WP All Import", "wp_all_export_plugin"); ?></a>
194
  <?php endif;?>
195
  <?php
196
- if ( wp_all_export_is_compatible() and (empty($item['options']['cpt']) or ! in_array('shop_order', $item['options']['cpt']))){
197
- $template = new PMXI_Template_Record();
198
- if ( ! empty($item['options']['template_name'])) {
199
- $template->getByName($item['options']['template_name']);
200
- if ( ! $template->isEmpty() ){
201
  ?>
202
  <br/>
203
  <a href="<?php echo add_query_arg(array('id' => $item['id'], 'action' => 'templates'), $this->baseUrl)?>"><?php _e('Download Import Templates', 'wp_all_export_plugin'); ?></a>
204
  <?php
205
- }
206
  }
207
  }
208
  ?>
@@ -304,7 +310,7 @@ $columns = apply_filters('pmxe_manage_imports_columns', $columns);
304
  break;
305
  case 'actions':
306
  ?>
307
- <td style="width: 130px;">
308
  <?php if ( ! $item['processing'] and ! $item['executing'] ): ?>
309
  <!--h2 style="float:left;"><a class="add-new-h2" href="<?php echo add_query_arg(array('id' => $item['id'], 'action' => 'edit'), $this->baseUrl); ?>"><?php _e('Edit', 'wp_all_export_plugin'); ?></a></h2-->
310
  <h2 style="float:left;"><a class="add-new-h2" href="<?php echo add_query_arg(array('id' => $item['id'], 'action' => 'update'), $this->baseUrl); ?>"><?php _e('Run Export', 'wp_all_export_plugin'); ?></a></h2>
128
  break;
129
  case 'name':
130
  ?>
131
+ <td style="min-width: 325px;">
132
  <strong><?php echo $item['friendly_name']; ?></strong> <br>
133
  <div class="row-actions">
134
  <span class="edit"><a class="edit" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'template'), $this->baseUrl)) ?>"><?php _e('Edit Template', 'wp_all_export_plugin') ?></a></span> |
135
  <span class="edit"><a class="edit" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'options'), $this->baseUrl)) ?>"><?php _e('Edit Options', 'wp_all_export_plugin') ?></a></span> |
136
  <?php if ( ! $is_secure_import and $item['attch_id']): ?>
137
+ <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'get_file', '_wpnonce' => wp_create_nonce( '_wpnonce-download_feed' )), $this->baseUrl)) ?>"><?php echo strtoupper($item['options']['export_to']); ?></a></span> |
138
+ <?php if (! empty($item['options']['tpl_data'])):?>
139
+ <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'bundle', '_wpnonce' => wp_create_nonce( '_wpnonce-download_bundle' )), $this->baseUrl)) ?>"><?php _e('Bundle', 'wp_all_export_plugin'); ?></a></span> |
140
+ <?php endif; ?>
141
  <?php endif; ?>
142
  <?php if ($is_secure_import and ! empty($item['options']['filepath'])): ?>
143
+ <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'get_file', '_wpnonce' => wp_create_nonce( '_wpnonce-download_feed' )), $this->baseUrl)) ?>"><?php echo strtoupper($item['options']['export_to']); ?></a></span> |
144
+ <?php if (! empty($item['options']['tpl_data'])):?>
145
+ <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'bundle', '_wpnonce' => wp_create_nonce( '_wpnonce-download_bundle' )), $this->baseUrl)) ?>"><?php _e('Bundle', 'wp_all_export_plugin'); ?></a></span> |
146
+ <?php endif; ?>
147
  <?php endif; ?>
148
  <span class="delete"><a class="delete" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'delete'), $this->baseUrl)) ?>"><?php _e('Delete', 'wp_all_export_plugin') ?></a></span>
149
  </div>
199
  <a href="<?php echo add_query_arg(array('page' => 'pmxi-admin-import', 'id' => $item['options']['import_id'], 'deligate' => 'wpallexport'), remove_query_arg('page', $this->baseUrl)); ?>"><?php _e("Import with WP All Import", "wp_all_export_plugin"); ?></a>
200
  <?php endif;?>
201
  <?php
202
+ if ( empty($item['options']['cpt']) or ! in_array('shop_order', $item['options']['cpt'])) {
203
+ //$template = new PMXI_Template_Record();
204
+ if ( ! empty($item['options']['tpl_data'])) {
205
+ //$template->getByName($item['options']['template_name']);
206
+ //if ( ! $template->isEmpty() ){
207
  ?>
208
  <br/>
209
  <a href="<?php echo add_query_arg(array('id' => $item['id'], 'action' => 'templates'), $this->baseUrl)?>"><?php _e('Download Import Templates', 'wp_all_export_plugin'); ?></a>
210
  <?php
211
+ //}
212
  }
213
  }
214
  ?>
310
  break;
311
  case 'actions':
312
  ?>
313
+ <td style="min-width: 130px;">
314
  <?php if ( ! $item['processing'] and ! $item['executing'] ): ?>
315
  <!--h2 style="float:left;"><a class="add-new-h2" href="<?php echo add_query_arg(array('id' => $item['id'], 'action' => 'edit'), $this->baseUrl); ?>"><?php _e('Edit', 'wp_all_export_plugin'); ?></a></h2-->
316
  <h2 style="float:left;"><a class="add-new-h2" href="<?php echo add_query_arg(array('id' => $item['id'], 'action' => 'update'), $this->baseUrl); ?>"><?php _e('Run Export', 'wp_all_export_plugin'); ?></a></h2>
wp-all-export.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP All Export
4
  Plugin URI: http://www.wpallimport.com/export/
5
  Description: Export any post type to a CSV or XML file. Edit the exported data, and then re-import it later using WP All Import.
6
- Version: 1.0.0
7
  Author: Soflyy
8
  */
9
 
@@ -50,7 +50,7 @@ else {
50
  */
51
  define('PMXE_PREFIX', 'pmxe_');
52
 
53
- define('PMXE_VERSION', '1.0.0');
54
 
55
  define('PMXE_EDITION', 'free');
56
 
@@ -63,7 +63,7 @@ else {
63
  * Plugin uploads folder name
64
  * @var string
65
  */
66
- define('WP_ALL_EXPORT_UPLOADS_DIRECTORY', WP_ALL_EXPORT_UPLOADS_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'uploads');
67
 
68
  /**
69
  * Plugin temp folder name
3
  Plugin Name: WP All Export
4
  Plugin URI: http://www.wpallimport.com/export/
5
  Description: Export any post type to a CSV or XML file. Edit the exported data, and then re-import it later using WP All Import.
6
+ Version: 1.0.1
7
  Author: Soflyy
8
  */
9
 
50
  */
51
  define('PMXE_PREFIX', 'pmxe_');
52
 
53
+ define('PMXE_VERSION', '1.0.1');
54
 
55
  define('PMXE_EDITION', 'free');
56
 
63
  * Plugin uploads folder name
64
  * @var string
65
  */
66
+ define('WP_ALL_EXPORT_UPLOADS_DIRECTORY', WP_ALL_EXPORT_UPLOADS_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'exports');
67
 
68
  /**
69
  * Plugin temp folder name