Export WordPress data to XML/CSV - Version 1.3.0

Version Description

  • improvement: added plugin version when loading tipsy JS file
  • improvement: moved ACF and WooCommerce support to add-ons
Download this release

Release Info

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

Code changes from version 1.2.10 to 1.3.0

Files changed (109) hide show
  1. actions/admin_init.php +0 -0
  2. actions/admin_menu.php +0 -0
  3. actions/admin_notices.php +0 -0
  4. actions/wp_ajax_wpae_filtering.php +40 -2
  5. actions/wp_ajax_wpae_filtering_count.php +2 -2
  6. actions/wp_loaded.php +0 -0
  7. classes/config.php +0 -0
  8. classes/download.php +0 -0
  9. classes/helper.php +0 -0
  10. classes/input.php +0 -0
  11. classes/session.php +0 -0
  12. classes/wpallimport.php +23 -16
  13. config/options.php +0 -0
  14. controllers/admin/export.php +0 -0
  15. controllers/admin/help.php +0 -0
  16. controllers/controller.php +0 -0
  17. controllers/controller/admin.php +0 -0
  18. helpers/backward.php +0 -0
  19. helpers/str_getcsv.php +0 -0
  20. helpers/wp_redirect_or_javascript.php +0 -0
  21. libraries/XmlCsvExport.php +2 -2
  22. libraries/XmlExportACF.php +0 -1766
  23. libraries/XmlExportCpt.php +33 -21
  24. libraries/XmlExportEngine.php +84 -46
  25. libraries/XmlExportUser.php +0 -747
  26. libraries/XmlExportWooCommerce.php +0 -1264
  27. libraries/XmlExportWooCommerceCoupon.php +0 -223
  28. libraries/XmlExportWooCommerceOrder.php +0 -1705
  29. models/export/list.php +0 -0
  30. models/export/record.php +0 -0
  31. models/model.php +0 -0
  32. models/model/list.php +0 -0
  33. models/model/record.php +0 -0
  34. readme.txt +5 -1
  35. schema.php +0 -0
  36. src/App/Service/Addons/AddonService.php +60 -44
  37. src/App/UnsecuredController/SchedulingController.php +16 -0
  38. src/Pro/Filtering/FilteringFactory.php +7 -0
  39. static/css/admin-ie.css +0 -0
  40. static/css/admin-wp-3.8.css +0 -0
  41. static/css/admin.css +30 -9
  42. static/img/date-picker.gif +0 -0
  43. static/img/down.gif +0 -0
  44. static/img/drag.png +0 -0
  45. static/img/ico-add-new.png +0 -0
  46. static/img/ico-remove.png +0 -0
  47. static/img/loading.png +0 -0
  48. static/img/logo.png +0 -0
  49. static/img/progress_animated.gif +0 -0
  50. static/img/screen-options-right-up.gif +0 -0
  51. static/img/screen-options-right.gif +0 -0
  52. static/img/soflyy-logo.png +0 -0
  53. static/img/stars.png +0 -0
  54. static/img/xmlicon.png +0 -0
  55. static/js/admin.js +97 -14
  56. static/js/jquery/css/redmond/images/animated-overlay.gif +0 -0
  57. static/js/jquery/css/redmond/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  58. static/js/jquery/css/redmond/images/ui-bg_flat_0_aaaaaa_40x100_1.png +0 -0
  59. static/js/jquery/css/redmond/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
  60. static/js/jquery/css/redmond/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  61. static/js/jquery/css/redmond/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  62. static/js/jquery/css/redmond/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  63. static/js/jquery/css/redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  64. static/js/jquery/css/redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  65. static/js/jquery/css/redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  66. static/js/jquery/css/redmond/images/ui-icons_217bc0_256x240.png +0 -0
  67. static/js/jquery/css/redmond/images/ui-icons_2e83ff_256x240.png +0 -0
  68. static/js/jquery/css/redmond/images/ui-icons_469bdd_256x240.png +0 -0
  69. static/js/jquery/css/redmond/images/ui-icons_6da8d5_256x240.png +0 -0
  70. static/js/jquery/css/redmond/images/ui-icons_cd0a0a_256x240.png +0 -0
  71. static/js/jquery/css/redmond/images/ui-icons_d8e7f3_256x240.png +0 -0
  72. static/js/jquery/css/redmond/images/ui-icons_f9bd01_256x240.png +0 -0
  73. static/js/jquery/css/redmond/jquery-ui.css +0 -0
  74. static/js/jquery/css/select2/select2-bootstrap.css +0 -0
  75. static/js/jquery/css/select2/select2-spinner.gif +0 -0
  76. static/js/jquery/css/select2/select2.css +0 -0
  77. static/js/jquery/css/select2/select2.png +0 -0
  78. static/js/jquery/css/smoothness/images/tipsy.gif +0 -0
  79. static/js/jquery/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  80. static/js/jquery/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  81. static/js/jquery/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  82. static/js/jquery/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  83. static/js/jquery/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  84. static/js/jquery/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  85. static/js/jquery/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  86. static/js/jquery/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  87. static/js/jquery/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
  88. static/js/jquery/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  89. static/js/jquery/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
  90. static/js/jquery/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
  91. static/js/jquery/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  92. static/js/jquery/css/smoothness/jquery-ui.css +0 -0
  93. static/js/jquery/css/smoothness/jquery.tipsy.css +0 -0
  94. static/js/jquery/jquery.tipsy.js +0 -0
  95. static/js/jquery/select2.min.js +0 -0
  96. static/js/jquery/ui.autocomplete.js +0 -0
  97. static/js/jquery/ui.datepicker.js +0 -0
  98. static/js/pmxe.js +0 -0
  99. views/admin/export/index.php +70 -20
  100. views/admin/export/options/settings.php +1 -1
  101. views/admin/export/process.php +1 -1
  102. views/admin/export/template.php +7 -7
  103. views/admin/export/variation_options.php +17 -17
  104. views/admin/export/variation_options_common.php +1 -1
  105. views/admin/help/index.php +0 -0
  106. views/admin/manage/index.php +39 -17
  107. views/admin/settings/index.php +0 -0
  108. views/controller/error.php +0 -0
  109. wp-all-export.php +62 -35
actions/admin_init.php CHANGED
File without changes
actions/admin_menu.php CHANGED
File without changes
actions/admin_notices.php CHANGED
File without changes
actions/wp_ajax_wpae_filtering.php CHANGED
@@ -46,12 +46,43 @@ function pmxe_wp_ajax_wpae_filtering(){
46
 
47
  $response['html'] = ob_get_clean();
48
 
49
- if ( (XmlExportEngine::$is_user_export && $post['cpt'] != 'shop_customer' && !$addons->isUserAddonActive()) || XmlExportEngine::$is_comment_export || XmlExportEngine::$is_taxonomy_export || $post['cpt'] == 'shop_customer' )
50
  {
51
  $response['btns'] = '';
52
  exit(json_encode($response)); die;
53
  }
54
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  ob_start();
56
 
57
  if ( XmlExportEngine::$is_auto_generate_enabled ):
@@ -61,6 +92,13 @@ function pmxe_wp_ajax_wpae_filtering(){
61
  <p><?php _e('If you already own it, remove the free edition and install the Pro edition.', PMXE_Plugin::LANGUAGE_DOMAIN);?></p>
62
  </div>
63
 
 
 
 
 
 
 
 
64
  <div class="wpallexport-free-edition-notice" id="migrate-users-notice" style="padding: 20px; margin-bottom: 10px; display: none;">
65
  <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707173&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=migrate-users"><?php _e('Upgrade to the Pro edition of WP All Export to Migrate Users', PMXE_Plugin::LANGUAGE_DOMAIN);?></a>
66
  <p><?php _e('If you already own it, remove the free edition and install the Pro edition.', PMXE_Plugin::LANGUAGE_DOMAIN);?></p>
46
 
47
  $response['html'] = ob_get_clean();
48
 
49
+ if ( (XmlExportEngine::$is_user_export && $post['cpt'] != 'shop_customer' && !$addons->isUserAddonActive()) || XmlExportEngine::$is_comment_export || XmlExportEngine::$is_taxonomy_export || ($post['cpt'] == 'shop_customer' && (!$addons->isUserAddonActive() || PMUE_EDITION != 'paid')) )
50
  {
51
  $response['btns'] = '';
52
  exit(json_encode($response)); die;
53
  }
54
+
55
+ $cpt = $post['cpt'];
56
+
57
+ if(!is_array($cpt)) {
58
+ $cpt =[$cpt];
59
+ }
60
+
61
+ $return_empty_buttons = false;
62
+ if (!$addons->isWooCommerceAddonActive() &&
63
+ (
64
+ in_array('shop_order', $cpt) || in_array('shop_review', $cpt) ||
65
+ in_array('product', $cpt) || in_array('shop_coupon', $cpt)
66
+ )
67
+ )
68
+ {
69
+ $return_empty_buttons = true;
70
+ }
71
+
72
+
73
+ if(in_array('shop_order', $cpt) && $addons->isWooCommerceOrderAddonActive()) {
74
+ $return_empty_buttons = false;
75
+ }
76
+
77
+ if(in_array('product', $cpt) && $addons->isWooCommerceProductAddonActive()) {
78
+ $return_empty_buttons = false;
79
+ }
80
+
81
+
82
+ if($return_empty_buttons) {
83
+ exit(json_encode(['btns' => ''])); die;
84
+ }
85
+
86
  ob_start();
87
 
88
  if ( XmlExportEngine::$is_auto_generate_enabled ):
92
  <p><?php _e('If you already own it, remove the free edition and install the Pro edition.', PMXE_Plugin::LANGUAGE_DOMAIN);?></p>
93
  </div>
94
 
95
+ <?php
96
+ if($addons->isUserAddonActive() && PMUE_EDITION == 'paid') {
97
+ ?>
98
+ <input type="hidden" id="user_add_on_pro_installed" value="1" />
99
+ <?php
100
+ }
101
+ ?>
102
  <div class="wpallexport-free-edition-notice" id="migrate-users-notice" style="padding: 20px; margin-bottom: 10px; display: none;">
103
  <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707173&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=migrate-users"><?php _e('Upgrade to the Pro edition of WP All Export to Migrate Users', PMXE_Plugin::LANGUAGE_DOMAIN);?></a>
104
  <p><?php _e('If you already own it, remove the free edition and install the Pro edition.', PMXE_Plugin::LANGUAGE_DOMAIN);?></p>
actions/wp_ajax_wpae_filtering_count.php CHANGED
@@ -78,7 +78,7 @@ function pmxe_wp_ajax_wpae_filtering_count(){
78
  if ($post['export_type'] == 'advanced')
79
  {
80
  if (XmlExportEngine::$is_user_export)
81
- {
82
  // get total users
83
  $totalQuery = eval('return new WP_User_Query(array(' . PMXE_Plugin::$session->get('wp_query') . ', \'offset\' => 0, \'number\' => 10 ));');
84
  if ( ! empty($totalQuery->results)){
@@ -110,7 +110,7 @@ function pmxe_wp_ajax_wpae_filtering_count(){
110
  ob_get_clean();
111
  }
112
  else
113
- {
114
  remove_all_actions('parse_query');
115
  remove_all_actions('pre_get_posts');
116
  remove_all_filters('posts_clauses');
78
  if ($post['export_type'] == 'advanced')
79
  {
80
  if (XmlExportEngine::$is_user_export)
81
+ {
82
  // get total users
83
  $totalQuery = eval('return new WP_User_Query(array(' . PMXE_Plugin::$session->get('wp_query') . ', \'offset\' => 0, \'number\' => 10 ));');
84
  if ( ! empty($totalQuery->results)){
110
  ob_get_clean();
111
  }
112
  else
113
+ {
114
  remove_all_actions('parse_query');
115
  remove_all_actions('pre_get_posts');
116
  remove_all_filters('posts_clauses');
actions/wp_loaded.php CHANGED
File without changes
classes/config.php CHANGED
File without changes
classes/download.php CHANGED
File without changes
classes/helper.php CHANGED
File without changes
classes/input.php CHANGED
File without changes
classes/session.php CHANGED
File without changes
classes/wpallimport.php CHANGED
@@ -469,6 +469,8 @@ final class PMXE_Wpallimport
469
 
470
  $implode_delimiter = ($options['delimiter'] == ',') ? '|' : ',';
471
 
 
 
472
  if ( ! empty($options['is_user_export']) ) self::$templateOptions['pmui']['import_users'] = 1;
473
 
474
  foreach ($options['ids'] as $ID => $value)
@@ -510,29 +512,32 @@ final class PMXE_Wpallimport
510
 
511
  case 'acf':
512
 
513
- if (empty($required_add_ons['PMAI_Plugin']))
514
- {
515
- $required_add_ons['PMAI_Plugin'] = array(
516
- 'name' => 'ACF Add-On Pro',
517
- 'paid' => true,
518
- 'url' => 'http://www.wpallimport.com/advanced-custom-fields/?utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=import-acf-template'
519
- );
520
- }
521
 
522
- $field_options = unserialize($options['cc_options'][$ID]);
 
 
 
 
 
 
 
 
 
523
 
524
- // add ACF group ID to the template options
525
- if( ! in_array($field_options['group_id'], self::$templateOptions['acf'])){
526
- self::$templateOptions['acf'][$field_options['group_id']] = 1;
527
- }
528
 
529
- self::$templateOptions['fields'][$field_options['key']] = XmlExportACF::prepare_import_template( $options, self::$templateOptions, $acf_list, $element_name, $field_options);
 
 
530
 
531
  break;
532
 
533
  default:
534
 
535
- $addons = new \Wpae\App\Service\Addons\AddonService();
536
  XmlExportCpt::prepare_import_template( $options, self::$templateOptions, $cf_list, $attr_list, $taxs_list, $element_name, $ID);
537
 
538
  XmlExportMediaGallery::prepare_import_template( $options, self::$templateOptions, $element_name, $ID);
@@ -543,7 +548,9 @@ final class PMXE_Wpallimport
543
 
544
  XmlExportTaxonomy::prepare_import_template( $options, self::$templateOptions, $element_name, $ID);
545
 
546
- XmlExportWooCommerceOrder::prepare_import_template( $options, self::$templateOptions, $element_name, $ID);
 
 
547
 
548
  break;
549
  }
469
 
470
  $implode_delimiter = ($options['delimiter'] == ',') ? '|' : ',';
471
 
472
+ $addons = new \Wpae\App\Service\Addons\AddonService();
473
+
474
  if ( ! empty($options['is_user_export']) ) self::$templateOptions['pmui']['import_users'] = 1;
475
 
476
  foreach ($options['ids'] as $ID => $value)
512
 
513
  case 'acf':
514
 
515
+ if($addons->isAcfAddonActive()) {
 
 
 
 
 
 
 
516
 
517
+ if (empty($required_add_ons['PMAI_Plugin']))
518
+ {
519
+ $required_add_ons['PMAI_Plugin'] = array(
520
+ 'name' => 'ACF Add-On Pro',
521
+ 'paid' => true,
522
+ 'url' => 'http://www.wpallimport.com/advanced-custom-fields/?utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=import-acf-template'
523
+ );
524
+ }
525
+
526
+ $field_options = unserialize($options['cc_options'][$ID]);
527
 
528
+ // add ACF group ID to the template options
529
+ if( ! in_array($field_options['group_id'], self::$templateOptions['acf'])){
530
+ self::$templateOptions['acf'][$field_options['group_id']] = 1;
531
+ }
532
 
533
+ self::$templateOptions['fields'][$field_options['key']] = XmlExportACF::prepare_import_template( $options, self::$templateOptions, $acf_list, $element_name, $field_options);
534
+
535
+ }
536
 
537
  break;
538
 
539
  default:
540
 
 
541
  XmlExportCpt::prepare_import_template( $options, self::$templateOptions, $cf_list, $attr_list, $taxs_list, $element_name, $ID);
542
 
543
  XmlExportMediaGallery::prepare_import_template( $options, self::$templateOptions, $element_name, $ID);
548
 
549
  XmlExportTaxonomy::prepare_import_template( $options, self::$templateOptions, $element_name, $ID);
550
 
551
+ if($addons->isWooCommerceAddonActive()) {
552
+ XmlExportWooCommerceOrder::prepare_import_template( $options, self::$templateOptions, $element_name, $ID);
553
+ }
554
 
555
  break;
556
  }
config/options.php CHANGED
File without changes
controllers/admin/export.php CHANGED
File without changes
controllers/admin/help.php CHANGED
File without changes
controllers/controller.php CHANGED
File without changes
controllers/controller/admin.php CHANGED
File without changes
helpers/backward.php CHANGED
File without changes
helpers/str_getcsv.php CHANGED
File without changes
helpers/wp_redirect_or_javascript.php CHANGED
File without changes
libraries/XmlCsvExport.php CHANGED
@@ -809,7 +809,7 @@ final Class XmlCsvExport
809
  }
810
  }
811
 
812
- if (XmlExportWooCommerceOrder::$is_active) {
813
  foreach (XmlExportWooCommerceOrder::$order_sections as $slug => $section) {
814
  if (!empty($section['meta'])) {
815
  foreach ($section['meta'] as $cur_meta_key => $field) {
@@ -828,7 +828,7 @@ final Class XmlCsvExport
828
  }
829
  }
830
 
831
- if (!XmlExportEngine::$is_comment_export) XmlExportEngine::$acf_export->auto_generate_export_fields($auto_generate);
832
 
833
  return $auto_generate;
834
  }
809
  }
810
  }
811
 
812
+ if (XmlExportEngine::get_addons_service()->isWooCommerceAddonActive() && XmlExportWooCommerceOrder::$is_active) {
813
  foreach (XmlExportWooCommerceOrder::$order_sections as $slug => $section) {
814
  if (!empty($section['meta'])) {
815
  foreach ($section['meta'] as $cur_meta_key => $field) {
828
  }
829
  }
830
 
831
+ if (XmlExportEngine::get_addons_service()->isAcfAddonActive() && !XmlExportEngine::$is_comment_export) XmlExportEngine::$acf_export->auto_generate_export_fields($auto_generate);
832
 
833
  return $auto_generate;
834
  }
libraries/XmlExportACF.php DELETED
@@ -1,1766 +0,0 @@
1
- <?php
2
-
3
- if ( ! class_exists('XmlExportACF') )
4
- {
5
- final class XmlExportACF
6
- {
7
- private $_existing_acf_meta_keys = array();
8
-
9
- private $_acf_groups = array();
10
-
11
- public function __construct()
12
- {
13
- add_filter("wp_all_export_csv_rows", array( &$this, "filter_csv_rows"), 10, 3);
14
- }
15
-
16
- public function init( & $existing_meta_keys = array() ){
17
-
18
- if ( ! class_exists( 'acf' ) ) return;
19
-
20
- global $acf;
21
-
22
- if ($acf and version_compare($acf->settings['version'], '5.0.0') >= 0){
23
-
24
- $saved_acfs = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field-group'));
25
-
26
- if (function_exists('acf_local')) {
27
- $acfs = acf_local()->groups;
28
- }
29
- if (empty($acfs) && function_exists('acf_get_local_field_groups')) {
30
- $acfs = acf_get_local_field_groups();
31
- }
32
-
33
- if ( ! empty($acfs) and is_array($acfs)) $this->_acf_groups = $acfs;
34
-
35
- }
36
- else{
37
-
38
- $this->_acf_groups = apply_filters('acf/get_field_groups', array());
39
-
40
- }
41
-
42
- if ( ! empty($saved_acfs) ){
43
- foreach ($saved_acfs as $key => $obj) {
44
- if ( ! isset($acfs[$obj->post_name]))
45
- {
46
- $this->_acf_groups[] = array(
47
- 'ID' => $obj->ID,
48
- 'title' => $obj->post_title
49
- );
50
- }
51
- }
52
- }
53
-
54
- if ( ! empty($this->_acf_groups) ){
55
-
56
- foreach ($this->_acf_groups as $key => $acfObj)
57
- {
58
- if (empty($this->_acf_groups[$key]['ID']) and ! empty($this->_acf_groups[$key]['key']))
59
- {
60
- $this->_acf_groups[$key]['ID'] = $acfs[$key]['key'];
61
- }
62
- elseif (empty($this->_acf_groups[$key]['ID']) and ! empty($this->_acf_groups[$key]['id']))
63
- {
64
- $this->_acf_groups[$key]['ID'] = $this->_acf_groups[$key]['id'];
65
- }
66
- }
67
-
68
- // get all ACF fields
69
- if ($acf->settings['version'] and version_compare($acf->settings['version'], '5.0.0') >= 0)
70
- {
71
-
72
- foreach ($this->_acf_groups as $key => $acf_obj) {
73
-
74
- if ( is_numeric($acf_obj['ID'])){
75
-
76
- $acf_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => $acf_obj['ID'], 'post_status' => 'publish', 'orderby' => 'menu_order', 'order' => 'ASC'));
77
-
78
- if ( ! empty($acf_fields) ){
79
-
80
- foreach ($acf_fields as $field) {
81
-
82
- $fieldData = (!empty($field->post_content)) ? unserialize($field->post_content) : array();
83
-
84
- $fieldData['ID'] = $field->ID;
85
- $fieldData['id'] = $field->ID;
86
- $fieldData['label'] = $field->post_title;
87
- $fieldData['key'] = $field->post_name;
88
-
89
- if (in_array($fieldData['type'], array('tab'))) continue;
90
-
91
- if (empty($fieldData['name'])) $fieldData['name'] = $field->post_excerpt;
92
-
93
- if ( ! empty($fieldData['name'])){
94
- $this->_existing_acf_meta_keys[] = $fieldData['name'];
95
- }
96
-
97
- $this->_acf_groups[$key]['fields'][] = $fieldData;
98
-
99
- }
100
- }
101
- }
102
- else
103
- {
104
- if (function_exists('acf_local')) {
105
- $acf_fields = acf_local()->fields;
106
- }
107
- if (empty($acf_fields) && function_exists('acf_get_local_fields')) {
108
- $acf_fields = acf_get_local_fields();
109
- }
110
-
111
- if ( ! empty($acf_fields) )
112
- {
113
- foreach ($acf_fields as $field_key => $field)
114
- {
115
- if ($field['parent'] == $acf_obj['key'])
116
- {
117
- $fieldData = $field;
118
-
119
- if (empty($fieldData['ID']))
120
- {
121
- $fieldData['ID'] = $fieldData['id'] = uniqid();
122
- }
123
-
124
- if ( ! empty($fieldData['name'])){
125
- $this->_existing_acf_meta_keys[] = $fieldData['name'];
126
- }
127
-
128
- $this->_acf_groups[$key]['fields'][] = $fieldData;
129
- }
130
- }
131
- }
132
- }
133
- }
134
- }
135
- else
136
- {
137
- foreach ($this->_acf_groups as $key => $acf_obj) {
138
-
139
- $fields = array();
140
-
141
- if (is_numeric($acf_obj['id'])){
142
-
143
- foreach (get_post_meta($acf_obj['id'], '') as $cur_meta_key => $cur_meta_val)
144
- {
145
- if (strpos($cur_meta_key, 'field_') !== 0) continue;
146
-
147
- $fields[] = (!empty($cur_meta_val[0])) ? unserialize($cur_meta_val[0]) : array();
148
-
149
- }
150
- }
151
- else
152
- {
153
- global $acf_register_field_group;
154
-
155
- if ( ! empty($acf_register_field_group) )
156
- {
157
- foreach ($acf_register_field_group as $group)
158
- {
159
- if ($group['id'] == $acf_obj['ID'])
160
- {
161
- foreach ($group['fields'] as $field)
162
- {
163
- $fields[] = $field;
164
- }
165
- }
166
- }
167
- }
168
- }
169
-
170
- if (count($fields)){
171
-
172
- $sortArray = array();
173
-
174
- foreach($fields as $field){
175
- foreach($field as $key2=>$value){
176
- if(!isset($sortArray[$key2])){
177
- $sortArray[$key2] = array();
178
- }
179
- $sortArray[$key2][] = $value;
180
- }
181
- }
182
-
183
- $orderby = "order_no";
184
-
185
- if(is_array($sortArray[$orderby])) {
186
- @array_multisort($sortArray[$orderby], SORT_ASC, $fields);
187
- }
188
- foreach ($fields as $field){
189
- if (in_array($field['type'], array('tab'))) continue;
190
- $this->_acf_groups[$key]['fields'][] = $field;
191
- if ( ! empty($field['name'])) $this->_existing_acf_meta_keys[] = $field['name'];
192
- }
193
- }
194
- }
195
- }
196
-
197
- if ( ! empty($existing_meta_keys)){
198
- foreach ($existing_meta_keys as $key => $meta_key) {
199
- foreach ($this->_existing_acf_meta_keys as $acf_key => $acf_value) {
200
- if (in_array($meta_key, array($acf_value, "_" . $acf_value))) {
201
- unset($existing_meta_keys[$key]);
202
- }
203
- }
204
- }
205
- }
206
- }
207
- }
208
-
209
- private static $additional_articles = array();
210
-
211
- private static $fc_sub_field_names = array();
212
-
213
- public static function export_acf_field($field_value = '', $exportOptions, $ID, $pid, &$article, $xmlWriter = false, &$acfs, $element_name = '', $element_name_ns = '', $fieldSnipped = '', $group_id = '', $preview = false, $return_value = false, $is_sub_field = false )
214
- {
215
- global $acf;
216
-
217
- $put_to_csv = true;
218
-
219
- $field_name = (!empty($exportOptions['cc_label'][$ID])) ? $exportOptions['cc_label'][$ID] : $exportOptions['name'];
220
- $field_options = (!empty($exportOptions['cc_options'][$ID])) ? unserialize($exportOptions['cc_options'][$ID]) : $exportOptions;
221
- $field_settings = (!empty($exportOptions['cc_settings'][$ID])) ? json_decode($exportOptions['cc_settings'][$ID], true) : false;
222
-
223
- $is_xml_export = false;
224
-
225
- if ( ! empty($xmlWriter) and XmlExportEngine::$exportOptions['export_to'] == 'xml' and ! in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ){
226
- $is_xml_export = true;
227
- }
228
-
229
- $is_custom_xml_export = false;
230
-
231
- if ( XmlExportEngine::$exportOptions['export_to'] == 'xml' and in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom')) ){
232
- $is_custom_xml_export = true;
233
- }
234
-
235
- if ($field_options['type'] == 'message'){
236
- $field_value = empty($field_options['message']) ? '' : $field_options['message'];
237
- }
238
-
239
-
240
- if ( ! empty($field_value))
241
- {
242
- $field_value = maybe_unserialize($field_value);
243
-
244
- $implode_delimiter = XmlExportEngine::$implode;
245
-
246
- switch ($field_options['type'])
247
- {
248
- case 'date_time_picker':
249
- $format = empty($field_options['return_format']) ? 'Y-m-d H:i:s' : $field_options['return_format'];
250
- $field_value = date($format, (is_numeric($field_value) ? $field_value : strtotime($field_value)));
251
- break;
252
- case 'date_picker':
253
- $field_value = date('Ymd', strtotime($field_value));
254
- break;
255
-
256
- case 'file':
257
- case 'image':
258
- if (is_numeric($field_value))
259
- {
260
- $field_value = wp_get_attachment_url($field_value);
261
- }
262
- elseif(is_array($field_value))
263
- {
264
- $field_value = empty($field_value['url']) ? '' : $field_value['url'];
265
- }
266
- break;
267
-
268
- case 'gallery':
269
- $v = array();
270
-
271
- foreach ($field_value as $key => $item)
272
- {
273
- if (!empty($item['url'])){
274
- $v[] = $item['url'];
275
- }
276
- elseif (is_numeric($item)){
277
- $gallery_item_url = wp_get_attachment_url($item);
278
- if (!empty($gallery_item_url)){
279
- $v[] = $gallery_item_url;
280
- }
281
- }
282
- }
283
- $field_value = implode($implode_delimiter, $v);
284
-
285
- break;
286
- case 'location-field':
287
- $localion_parts = explode("|", $field_value);
288
-
289
- if ($is_xml_export)
290
- {
291
- if ( ! empty($localion_parts) ){
292
-
293
- $xmlWriter->beginElement($element_name_ns, $element_name, null);
294
- $xmlWriter->startElement('address');
295
- $xmlWriter->writeData($localion_parts[0], 'address');
296
- $xmlWriter->closeElement();
297
-
298
- if (!empty($localion_parts[1])){
299
- $coordinates = explode(",", $localion_parts[1]);
300
- if (!empty($coordinates)){
301
- $xmlWriter->startElement('lat');
302
- $xmlWriter->writeData($coordinates[0], 'lat');
303
- $xmlWriter->closeElement();
304
- $xmlWriter->startElement('lng');
305
- $xmlWriter->writeData($coordinates[1], 'lng');
306
- $xmlWriter->closeElement();
307
- }
308
- }
309
- $xmlWriter->closeElement();
310
-
311
- }
312
- }
313
- else
314
- {
315
- if ( ! $return_value )
316
- {
317
- $acfs[$element_name] = array(
318
- $element_name . '_address',
319
- $element_name . '_lat',
320
- $element_name . '_lng'
321
- );
322
-
323
- if ( ! empty($localion_parts) )
324
- {
325
- $article[$element_name . '_address'] = $localion_parts[0];
326
- if (!empty($localion_parts[1]))
327
- {
328
- $coordinates = explode(",", $localion_parts[1]);
329
- if (!empty($coordinates))
330
- {
331
- $article[$element_name . '_lat'] = $coordinates[0];
332
- $article[$element_name . '_lng'] = $coordinates[1];
333
- }
334
- }
335
- }
336
- }
337
- else
338
- {
339
- if ( ! empty($localion_parts) )
340
- {
341
- $return_value = array(
342
- 'address' => $localion_parts[0],
343
- );
344
- if (!empty($localion_parts[1]))
345
- {
346
- $coordinates = explode(",", $localion_parts[1]);
347
- if (!empty($coordinates))
348
- {
349
- $return_value['lat'] = $coordinates[0];
350
- $return_value['lng'] = $coordinates[1];
351
- }
352
- }
353
- }
354
- }
355
- }
356
-
357
- $put_to_csv = false;
358
- break;
359
-
360
- case 'paypal_item':
361
-
362
- if ($is_xml_export)
363
- {
364
- $xmlWriter->beginElement($element_name_ns, $element_name, null);
365
- if ( is_array($field_value) ){
366
- foreach ($field_value as $key => $value) {
367
- $xmlWriter->beginElement($element_name_ns, $key, null);
368
- $xmlWriter->writeData($value, $key);
369
- $xmlWriter->closeElement();
370
- }
371
- }
372
- $xmlWriter->closeElement();
373
- }
374
- else
375
- {
376
- if ( ! $return_value )
377
- {
378
- if ( $is_custom_xml_export ){
379
- $article[$element_name] = json_encode($field_value);
380
- }
381
- else{
382
- $acfs[$element_name] = array($element_name . '_item_name', $element_name . '_item_description', $element_name . '_price');
383
-
384
- if ( is_array($field_value) )
385
- {
386
- foreach ($field_value as $key => $value)
387
- {
388
- $article[$element_name . '_' . $key] = $value;
389
- }
390
- }
391
- }
392
- }
393
- }
394
-
395
- $put_to_csv = false;
396
-
397
- break;
398
-
399
- case 'google_map':
400
-
401
- if ($is_xml_export)
402
- {
403
- $xmlWriter->beginElement($element_name_ns, $element_name, null);
404
- $xmlWriter->startElement('address');
405
- $xmlWriter->writeData($field_value['address'], 'address');
406
- $xmlWriter->closeElement();
407
- $xmlWriter->startElement('lat');
408
- $xmlWriter->writeData($field_value['lat'], 'lat');
409
- $xmlWriter->closeElement();
410
- $xmlWriter->startElement('lng');
411
- $xmlWriter->writeData($field_value['lng'], 'lng');
412
- $xmlWriter->closeElement();
413
- $xmlWriter->closeElement();
414
- }
415
- else
416
- {
417
- if ( ! $return_value )
418
- {
419
- if ( $is_custom_xml_export ){
420
- $article[$element_name] = json_encode($field_value);
421
- }
422
- else{
423
- $acfs[$element_name] = array($element_name . '_address', $element_name . '_lat', $element_name . '_lng');
424
- $article[$element_name . '_address'] = $field_value['address'];
425
- $article[$element_name . '_lat'] = $field_value['lat'];
426
- $article[$element_name . '_lng'] = $field_value['lng'];
427
- }
428
- }
429
- }
430
- $put_to_csv = false;
431
-
432
- break;
433
-
434
- case 'link':
435
-
436
- if ($is_xml_export)
437
- {
438
- $xmlWriter->beginElement($element_name_ns, $element_name, null);
439
- $xmlWriter->startElement('title');
440
- $xmlWriter->writeData($field_value['title'], 'title');
441
- $xmlWriter->closeElement();
442
- $xmlWriter->startElement('url');
443
- $xmlWriter->writeData($field_value['url'], 'url');
444
- $xmlWriter->closeElement();
445
- $xmlWriter->startElement('target');
446
- $xmlWriter->writeData($field_value['target'], 'target');
447
- $xmlWriter->closeElement();
448
- $xmlWriter->closeElement();
449
- }
450
- else
451
- {
452
- if ( ! $return_value )
453
- {
454
- if ( $is_custom_xml_export ){
455
- $article[$element_name] = json_encode($field_value);
456
- }
457
- else{
458
- $acfs[$element_name] = array($element_name . '_title', $element_name . '_url', $element_name . '_target');
459
- $article[$element_name . '_title'] = $field_value['_title'];
460
- $article[$element_name . '_url'] = $field_value['_url'];
461
- $article[$element_name . '_target'] = $field_value['_target'];
462
- }
463
- }
464
- }
465
- $put_to_csv = false;
466
-
467
- break;
468
-
469
- case 'acf_cf7':
470
- case 'gravity_forms_field':
471
-
472
- if ( ! empty($field_options['multiple']) )
473
- {
474
- $field_value = implode($implode_delimiter, $field_value);
475
- }
476
-
477
- break;
478
-
479
- case 'page_link':
480
-
481
- if (is_array($field_value))
482
- {
483
- $field_value = implode($implode_delimiter, $field_value);
484
- }
485
-
486
- break;
487
-
488
- case 'post_object':
489
-
490
- if ( ! empty($field_options['multiple'])){
491
- $v = array();
492
- foreach ($field_value as $key => $pid) {
493
-
494
- if (is_numeric($pid)){
495
- $entry = get_post($pid);
496
- if ($entry)
497
- {
498
- $v[] = $entry->post_name;
499
- }
500
- }
501
- else{
502
- $v[] = $pid->post_name;
503
- }
504
- }
505
- $field_value = implode($implode_delimiter, $v);
506
- }
507
- else{
508
- if (is_numeric($field_value)){
509
- $entry = get_post($field_value);
510
- if ($entry)
511
- {
512
- $field_value = $entry->post_name;
513
- }
514
- }
515
- else{
516
- $field_value = $field_value->post_name;
517
- }
518
- }
519
-
520
- break;
521
-
522
- case 'relationship':
523
-
524
- $v = array();
525
- foreach ($field_value as $key => $pid) {
526
- $entry = get_post($pid);
527
- if ($entry)
528
- {
529
- $v[] = $entry->post_title;
530
- }
531
- }
532
- $field_value = implode($implode_delimiter, $v);
533
-
534
- break;
535
-
536
- case 'user':
537
-
538
- if ( ! empty($field_options['multiple'])){
539
- $v = array();
540
- foreach ($field_value as $key => $user) {
541
- if (is_numeric($user)){
542
- $entry = get_user_by('ID', $user);
543
- if ($entry)
544
- {
545
- $v[] = $entry->user_email;
546
- }
547
- }
548
- else{
549
- $v[] = $user['user_email'];
550
- }
551
- }
552
- $field_value = implode($implode_delimiter, $v);
553
- }
554
- else{
555
- if (is_numeric($field_value)){
556
- $entry = get_user_by('ID', $field_value);
557
- if ($entry)
558
- {
559
- $field_value = $entry->user_email;
560
- }
561
- }
562
- else{
563
- $field_value = $field_value['user_email'];
564
- }
565
- }
566
-
567
- break;
568
-
569
- case 'taxonomy':
570
-
571
- if ($is_xml_export)
572
- {
573
- $xmlWriter->beginElement($element_name_ns, $element_name, null);
574
-
575
- if ( ! in_array($field_options['field_type'], array('radio', 'select'))){
576
- foreach ($field_value as $key => $tid) {
577
- $entry = get_term($tid , $field_options['taxonomy']);
578
- if ($entry and !is_wp_error($entry))
579
- {
580
- $xmlWriter->startElement('term');
581
- $xmlWriter->writeData($entry->name, 'term');
582
- $xmlWriter->closeElement();
583
- }
584
- }
585
- }
586
- else{
587
- $entry = get_term($field_value, $field_options['taxonomy']);
588
- if ($entry)
589
- {
590
- $xmlWriter->startElement('term');
591
- $xmlWriter->writeData($entry->name, 'term');
592
- $xmlWriter->closeElement();
593
- }
594
- }
595
-
596
- $xmlWriter->closeElement();
597
-
598
- $put_to_csv = false;
599
- }
600
- else
601
- {
602
- if ( ! in_array($field_options['field_type'], array('radio', 'select'))){
603
- $v = array();
604
- foreach ($field_value as $key => $tid) {
605
- $entry = get_term($tid , $field_options['taxonomy']);
606
- if ($entry and !is_wp_error($entry))
607
- {
608
- $v[] = $entry->name;
609
- }
610
- }
611
- $field_value = implode($implode_delimiter, $v);
612
- }
613
- else{
614
- $entry = get_term($field_value, $field_options['taxonomy']);
615
- if ($entry)
616
- {
617
- $field_value = $entry->name;
618
- }
619
- }
620
- }
621
-
622
- break;
623
-
624
- case 'select':
625
-
626
- if ( ! empty($field_options['multiple']))
627
- {
628
- $field_value = implode($implode_delimiter, $field_value);
629
- }
630
-
631
- break;
632
-
633
- case 'checkbox':
634
-
635
- if ( is_array($field_value) )
636
- {
637
- $field_value = implode($implode_delimiter, $field_value);
638
- }
639
-
640
- break;
641
-
642
- case 'clone':
643
-
644
- if ( ! empty($field_options['clone']) ) {
645
- $values = maybe_unserialize($field_value);
646
-
647
- $sub_fields = array();
648
- foreach ($field_options['clone'] as $sub_field_key) {
649
-
650
- if (strpos($sub_field_key, 'group_') === 0){
651
- $acf_groups = get_posts(array(
652
- 'posts_per_page' => 1,
653
- 'post_type' => 'acf-field-group',
654
- 'name' => $sub_field_key,
655
- 'post_status' => 'publish'
656
- ));
657
- if (!empty($acf_groups)){
658
- foreach ($acf_groups as $acf_group){
659
- $sub_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => $acf_group->ID, 'post_status' => 'publish', 'orderby' => 'menu_order', 'order' => 'ASC'));
660
- }
661
- }
662
- }
663
- else{
664
- $args = array(
665
- 'name' => $sub_field_key,
666
- 'post_type' => 'acf-field',
667
- 'post_status' => 'publish',
668
- 'posts_per_page' => 1
669
- );
670
- $my_posts = get_posts($args);
671
- if ($my_posts) {
672
- $sub_fields[] = $my_posts[0];
673
- }
674
- }
675
- }
676
- if ( ! empty($sub_fields) ){
677
-
678
- foreach ($sub_fields as $sub_field){
679
-
680
- $field_value = isset($values[$sub_field->post_excerpt]) ? $values[$sub_field->post_excerpt] : '';
681
-
682
- $sub_field_name = empty($sub_field->post_excerpt) ? str_replace("-","_", sanitize_title($sub_field->post_title)) : $sub_field->post_excerpt;
683
-
684
- $field_options = unserialize($sub_field->post_content);
685
-
686
- $sub_field_value = self::export_acf_field(
687
- $field_value,
688
- $field_options,
689
- false,
690
- $pid,
691
- $article,
692
- $xmlWriter,
693
- $acfs,
694
- $is_xml_export ? $sub_field_name : $element_name . '_' . $sub_field_name,
695
- $element_name_ns,
696
- '',
697
- '',
698
- $preview,
699
- $is_xml_export ? false : true,
700
- true
701
- );
702
-
703
- $acfs[$element_name][] = $element_name . '_' . $sub_field_name;
704
- $article[$element_name . '_' . $sub_field_name] = apply_filters('pmxe_acf_field', ($preview) ? trim(preg_replace('~[\r\n]+~', ' ', htmlspecialchars($sub_field_value))) : $sub_field_value, $element_name . '_' . $sub_field_name, $pid);
705
-
706
- }
707
- }
708
- }
709
-
710
- $put_to_csv = false;
711
-
712
- break;
713
-
714
- case 'repeater':
715
-
716
- if ($is_xml_export) $xmlWriter->beginElement($element_name_ns, $element_name, null);
717
-
718
- if( have_rows($field_name, $pid) ):
719
-
720
- $rowValues = array();
721
-
722
- $repeater_sub_field_names = array();
723
-
724
- while( have_rows($field_name, $pid) ):
725
-
726
- the_row();
727
-
728
- $row = self::acf_get_row();
729
-
730
- if ($is_xml_export) $xmlWriter->startElement('row');
731
-
732
- foreach ($row['field']['sub_fields'] as $sub_field) {
733
-
734
- if ($acf and version_compare($acf->settings['version'], '5.0.0') >= 0)
735
- {
736
- $v = $row['value'][ $row['i'] ][ $sub_field['key'] ];
737
- $cache_slug = "format_value/post_id=".$row['post_id']."/name={$sub_field['name']}";
738
- wp_cache_delete($cache_slug, 'acf');
739
-
740
- if ($acf and version_compare($acf->settings['version'], '5.7.10') >= 0) {
741
- $store = acf_get_store('values');
742
- $store->remove($row['post_id'] . ":" . $sub_field['name'] . ":formatted");
743
- }
744
-
745
- if ($is_xml_export) $v = acf_format_value($v, $row['post_id'], $sub_field);
746
- }
747
- else
748
- {
749
- $v = get_sub_field($sub_field['name']);
750
- }
751
-
752
- if ($preview && ! $is_xml_export){
753
- switch ($sub_field['type']) {
754
- case 'textarea':
755
- case 'oembed':
756
- case 'wysiwyg':
757
- case 'wp_wysiwyg':
758
- case 'date_time_picker':
759
- case 'date_picker':
760
- $v = preg_replace( "/\r|\n/", "", esc_html($v) );
761
- break;
762
- default:
763
- break;
764
- }
765
- }
766
-
767
- $sub_field['delimiter'] = $implode_delimiter;
768
-
769
- $sub_field_name = empty($sub_field['name']) ? str_replace("-","_", sanitize_title($sub_field['label'])) : $sub_field['name'];
770
-
771
- $sub_field_value = self::export_acf_field(
772
- $v,
773
- $sub_field,
774
- false,
775
- $pid,
776
- $article,
777
- $xmlWriter,
778
- $acfs,
779
- $is_xml_export ? $sub_field_name : $element_name . '_' . $sub_field_name,
780
- $element_name_ns,
781
- $fieldSnipped,
782
- '',
783
- $preview,
784
- $is_xml_export ? false : true,
785
- true
786
- );
787
-
788
- if ( ! $is_xml_export )
789
- {
790
- switch ($sub_field['type'])
791
- {
792
- case 'google_map':
793
- case 'paypal_item':
794
- case 'location-field':
795
- if ( ! empty($sub_field_value))
796
- {
797
- foreach ($sub_field_value as $repeater_key => $repeater_value)
798
- {
799
- $rowValues[$sub_field['name']][$repeater_key][] = (is_array($repeater_value)) ? implode($exportOptions['delimiter'], $repeater_value) : $repeater_value;
800
- }
801
- }
802
- break;
803
- case 'repeater':
804
- if ( ! empty($sub_field_value)){
805
- foreach ($sub_field_value as $repeater_key => $repeater_value) {
806
- if (is_array($repeater_value)){
807
- $rv = array();
808
- foreach ($repeater_value as $repeater_key2 => $repeater_value2) {
809
- $rv[] = (is_array($repeater_value2)) ? implode($exportOptions['delimiter'], $repeater_value2) : $repeater_value2;
810
- }
811
- $rowValues[$sub_field_name][$repeater_key][] = implode($exportOptions['delimiter'], $rv);
812
- }
813
- else{
814
- $rowValues[$sub_field_name][$repeater_key][] = $repeater_value;
815
- }
816
- }
817
- }
818
- break;
819
- default:
820
- $sub_field_name = empty($sub_field['name']) ? str_replace("-","_", sanitize_title($sub_field['label'])) : $sub_field['name'];
821
- $rowValues[$sub_field_name][] = apply_filters('pmxe_acf_field', pmxe_filter( (is_array($sub_field_value)) ? implode($exportOptions['delimiter'], $sub_field_value) : $sub_field_value, $fieldSnipped), $sub_field_name, $pid);
822
- break;
823
- }
824
- }
825
- }
826
-
827
- if ($is_xml_export) $xmlWriter->closeElement();
828
-
829
- endwhile;
830
-
831
- if ($return_value) return $rowValues;
832
-
833
- if ( ! $is_xml_export )
834
- {
835
- $additional_articles = array();
836
-
837
- $sub_repeater_delimiter = apply_filters('wp_all_export_repeater_delimiter', $exportOptions['delimiter'], XmlExportEngine::$exportID);
838
-
839
- foreach ($rowValues as $key => $values)
840
- {
841
- $is_have_subvalues = array_filter(array_keys($values), 'is_numeric');
842
-
843
- if (empty($is_have_subvalues))
844
- {
845
- foreach ($values as $subkey => $subvalue)
846
- {
847
- if ( ! in_array($element_name . '_' . $key . '_' . $subkey, $repeater_sub_field_names))
848
- {
849
- $repeater_sub_field_names[] = $element_name . '_' . $key . '_' . $subkey;
850
- }
851
- // Display each repeater row in its own csv line
852
- if ( ! empty($field_settings) and $field_settings['repeater_field_item_per_line'] )
853
- {
854
- $base_value = array_shift($subvalue);
855
-
856
- $article[$element_name . '_' . $key . '_' . $subkey] = ($preview) ? trim(preg_replace('~[\r\n]+~', ' ', htmlspecialchars($base_value))) : $base_value;
857
-
858
- if ( ! empty($subvalue))
859
- {
860
- foreach ($subvalue as $i => $addRowValue)
861
- {
862
- $additional_articles[$i]['settings'] = $field_settings;
863
- $additional_articles[$i]['content'][$element_name . '_' . $key . '_' . $subkey] = $addRowValue;
864
- }
865
- }
866
- }
867
- else
868
- {
869
- if ($is_custom_xml_export){
870
- $article[$element_name][$key . '_' . $subkey] = apply_filters('pmxe_acf_field', pmxe_filter(($preview) ? trim(preg_replace('~[\r\n]+~', ' ', htmlspecialchars(implode("|", $subvalue)))) : implode("|", $subvalue), $fieldSnipped), $key . '_' . $subkey, $pid);
871
- }
872
- else{
873
- $article[$element_name . '_' . $key . '_' . $subkey] = apply_filters('pmxe_acf_field', pmxe_filter(($preview) ? trim(preg_replace('~[\r\n]+~', ' ', htmlspecialchars(implode($sub_repeater_delimiter, $subvalue)))) : implode($sub_repeater_delimiter, $subvalue), $fieldSnipped), $element_name . '_' . $key . '_' . $subkey, $pid);
874
- }
875
- }
876
- }
877
-
878
- }
879
- else
880
- {
881
- if ( ! in_array($element_name . '_' . $key, $repeater_sub_field_names))
882
- {
883
- $repeater_sub_field_names[] = $element_name . '_' . $key;
884
- }
885
- // Display each repeater row in its own csv line
886
- if ( ! empty($field_settings) and $field_settings['repeater_field_item_per_line'] )
887
- {
888
- $base_value = array_shift($values);
889
-
890
- $article[$element_name . '_' . $key] = ($preview) ? trim(preg_replace('~[\r\n]+~', ' ', htmlspecialchars($base_value))) : $base_value;
891
-
892
- if ( ! empty($values))
893
- {
894
- foreach ($values as $i => $addRowValue)
895
- {
896
- $additional_articles[$i]['settings'] = $field_settings;
897
- $additional_articles[$i]['content'][$element_name . '_' . $key] = $addRowValue;
898
- }
899
- }
900
- }
901
- else
902
- {
903
- if ($is_custom_xml_export){
904
- $article[$element_name][$key] = apply_filters('pmxe_acf_field', pmxe_filter(($preview) ? trim(preg_replace('~[\r\n]+~', ' ', htmlspecialchars(implode("|", $values)))) : implode("|", $values), $fieldSnipped), $key, $pid);
905
- }
906
- else{
907
- $article[$element_name . '_' . $key] = apply_filters('pmxe_acf_field', pmxe_filter(($preview) ? trim(preg_replace('~[\r\n]+~', ' ', htmlspecialchars(implode($sub_repeater_delimiter, $values)))) : implode($sub_repeater_delimiter, $values), $fieldSnipped), $element_name . '_' . $key, $pid);
908
- }
909
- }
910
- }
911
- }
912
-
913
- if ($is_custom_xml_export){
914
- $article[$element_name] = serialize($article[$element_name]);
915
- }
916
-
917
- if ( ! empty($repeater_sub_field_names)) $acfs[$element_name] = $repeater_sub_field_names;
918
-
919
- if ( ! empty($additional_articles) )
920
- {
921
- foreach ($additional_articles as $i => $additional_article) {
922
- self::$additional_articles[] = $additional_article;
923
- }
924
- }
925
- }
926
-
927
- endif;
928
-
929
- if ($is_xml_export) $xmlWriter->closeElement();
930
-
931
- $put_to_csv = false;
932
-
933
- break;
934
-
935
- case 'flexible_content':
936
-
937
- if ( ! $is_sub_field ){
938
- $acf_flexible = get_option('wp_all_export_acf_flexible_' . XmlExportEngine::$exportID);
939
- self::$fc_sub_field_names = empty($acf_flexible[$element_name]) ? array() : $acf_flexible[$element_name];
940
- }
941
-
942
- if ($is_xml_export) $xmlWriter->beginElement($element_name_ns, $element_name, null);
943
-
944
- // check if the flexible content field has rows of data
945
- if( have_rows($field_name, $pid) ):
946
-
947
- // loop through the rows of data
948
- while ( have_rows($field_name, $pid) ) : the_row();
949
-
950
- $row = self::acf_get_row();
951
-
952
- foreach ($row['field']['layouts'] as $layout) {
953
-
954
- if ($layout['name'] == $row['value'][ $row['i'] ]['acf_fc_layout']){
955
-
956
- if ($is_xml_export) $xmlWriter->startElement(preg_replace('#^\d+#', '', $row['value'][ $row['i'] ]['acf_fc_layout']) . '_' . $row['i']);
957
-
958
- foreach ($layout['sub_fields'] as $sub_field) {
959
-
960
- $layout_field_name = $element_name . '_' . $layout['name'] . '_' . $row['i'];
961
-
962
- $v = '';
963
-
964
- if(version_compare($acf->settings['version'], '5.0.0') >= 0) {
965
- $fieldValueKey = 'key';
966
- } else {
967
- $fieldValueKey = 'name';
968
- }
969
-
970
- if (isset($row['value'][ $row['i']][ $sub_field[$fieldValueKey]]))
971
- {
972
- $v = $row['value'][ $row['i']][$sub_field[$fieldValueKey]];
973
-
974
- if ($is_xml_export)
975
- {
976
- // apply filters
977
- $v = apply_filters( "acf/format_value", $v, $pid, $sub_field );
978
- $v = apply_filters( "acf/format_value/type={$sub_field['type']}", $v, $pid, $sub_field );
979
- $v = apply_filters( "acf/format_value/name={$sub_field['_name']}", $v, $pid, $sub_field );
980
- $v = apply_filters( "acf/format_value/key={$sub_field['key']}", $v, $pid, $sub_field );
981
- }
982
- }
983
-
984
- if ($preview && ! $is_xml_export){
985
- switch ($sub_field['type']) {
986
- case 'textarea':
987
- case 'oembed':
988
- case 'wysiwyg':
989
- case 'wp_wysiwyg':
990
- case 'date_time_picker':
991
- case 'date_picker':
992
- $v = preg_replace( "/\r|\n/", "", esc_html($v) );
993
- break;
994
- default:
995
- break;
996
- }
997
- }
998
-
999
- $sub_field['delimiter'] = $implode_delimiter;
1000
-
1001
- $sub_field_values = self::export_acf_field(
1002
- $v,
1003
- $sub_field,
1004
- false,
1005
- $pid,
1006
- $article,
1007
- $xmlWriter,
1008
- $acfs,
1009
- $is_xml_export ? $sub_field['name'] : $layout_field_name . '_' . $sub_field['name'],
1010
- $element_name_ns,
1011
- $fieldSnipped,
1012
- '',
1013
- $preview,
1014
- $is_xml_export ? false : true,
1015
- true
1016
- );
1017
-
1018
- if ( ! $is_xml_export )
1019
- {
1020
- switch ($sub_field['type'])
1021
- {
1022
- case 'repeater':
1023
-
1024
- if ( ! empty($sub_field_values))
1025
- {
1026
- foreach ($sub_field_values as $key => $values) {
1027
- $article[$layout_field_name . '_' . $key] = ($preview) ? trim(preg_replace('~[\r\n]+~', ' ', htmlspecialchars(implode($implode_delimiter, $values)))) : implode($implode_delimiter, $values);
1028
- if ( ! in_array($layout_field_name . '_' . $key, self::$fc_sub_field_names)) self::$fc_sub_field_names[] = $layout_field_name . '_' . $key;
1029
- }
1030
- }
1031
-
1032
- break;
1033
- case 'flexible_content':
1034
-
1035
-
1036
- break;
1037
-
1038
- default:
1039
-
1040
- $article[$layout_field_name . '_' . $sub_field['name']] = is_array($sub_field_values) ? implode($implode_delimiter, $sub_field_values) : $sub_field_values;
1041
-
1042
- if ( ! in_array($layout_field_name . '_' . $sub_field['name'], self::$fc_sub_field_names))
1043
- self::$fc_sub_field_names[] = $layout_field_name . '_' . $sub_field['name'];
1044
-
1045
- break;
1046
- }
1047
- }
1048
- }
1049
- if ($is_xml_export) $xmlWriter->closeElement();
1050
- }
1051
- }
1052
-
1053
- endwhile;
1054
-
1055
- else :
1056
-
1057
- // no layouts found
1058
-
1059
- endif;
1060
-
1061
- if ($is_xml_export) $xmlWriter->closeElement();
1062
-
1063
- $put_to_csv = false;
1064
-
1065
- break;
1066
-
1067
- default:
1068
-
1069
- break;
1070
- }
1071
- }
1072
-
1073
- if ($return_value) return $field_value;
1074
-
1075
- if ( ! empty(self::$fc_sub_field_names)){
1076
- $acf_flexible = get_option('wp_all_export_acf_flexible_' . XmlExportEngine::$exportID);
1077
- $acfs[$element_name] = self::$fc_sub_field_names;
1078
- $acf_flexible[$element_name] = self::$fc_sub_field_names;
1079
- update_option('wp_all_export_acf_flexible_' . XmlExportEngine::$exportID, $acf_flexible);
1080
- self::$fc_sub_field_names = array();
1081
- }
1082
-
1083
- if ($put_to_csv)
1084
- {
1085
- $val = apply_filters('pmxe_acf_field', pmxe_filter( ( ! empty($field_value) ) ? maybe_serialize($field_value) : '', $fieldSnipped), $field_name, $pid);
1086
-
1087
- if ($is_xml_export)
1088
- {
1089
- $xmlWriter->beginElement($element_name_ns, $element_name, null);
1090
- $xmlWriter->writeData($val, $element_name);
1091
- $xmlWriter->closeElement();
1092
- }
1093
- else
1094
- {
1095
- if($field_value === 0 || $field_value === "0") {
1096
- $val = 0;
1097
- }
1098
-
1099
- // $article[$element_name] = ($preview) ? trim(preg_replace('~[\r\n]+~', ' ', htmlspecialchars($val))) : $val;
1100
- wp_all_export_write_article( $article, $element_name, ($preview) ? trim(preg_replace('~[\r\n]+~', ' ', htmlspecialchars($val))) : $val);
1101
- if ( ! isset($acfs[$element_name]) && ! in_array($field_options['type'], array('repeater', 'clone'))) $acfs[$element_name] = $element_name;
1102
- }
1103
- }
1104
- }
1105
-
1106
- public function filter_csv_rows($articles, $options, $export_id)
1107
- {
1108
- if ( ! empty(self::$additional_articles) and $options['export_to'] == 'csv')
1109
- {
1110
- $base_article = $articles[count($articles) - 1];
1111
-
1112
- if ( ! empty(self::$additional_articles ) )
1113
- {
1114
- foreach (self::$additional_articles as $article)
1115
- {
1116
- if ($article['settings']['repeater_field_fill_empty_columns'])
1117
- {
1118
- foreach ($article['content'] as $key => $value) {
1119
- unset($base_article[$key]);
1120
- }
1121
- $articles[] = @array_merge($base_article, $article['content']);
1122
- }
1123
- else
1124
- {
1125
- $articles[] = $article['content'];
1126
- }
1127
- }
1128
- self::$additional_articles = array();
1129
- }
1130
- }
1131
-
1132
- return $articles;
1133
- }
1134
-
1135
- public function get_fields_options( &$fields, $field_keys = array() ){
1136
-
1137
- if ( ! empty($this->_acf_groups) )
1138
- {
1139
- foreach ($this->_acf_groups as $key => $group)
1140
- {
1141
- if ( ! empty($group['fields']))
1142
- {
1143
- foreach ($group['fields'] as $field)
1144
- {
1145
- $field_key = $field['label'];
1146
-
1147
- if ( ! in_array($field_key, $field_keys) ) continue;
1148
-
1149
- $fields['ids'][] = 1;
1150
- $fields['cc_label'][] = $field['name'];
1151
- $fields['cc_php'][] = '';
1152
- $fields['cc_code'][] = '';
1153
- $fields['cc_sql'][] = '';
1154
- $fields['cc_options'][] = serialize(array_merge($field, array('group_id' => ((!empty($group['ID'])) ? $group['ID'] : $group['id']) )));
1155
- $fields['cc_type'][] = 'acf';
1156
- $fields['cc_value'][] = $field['name'];
1157
- $fields['cc_name'][] = $field_key;
1158
- $fields['cc_settings'][] = '';
1159
- }
1160
- }
1161
- }
1162
- }
1163
- }
1164
-
1165
- public function render( & $i ){
1166
-
1167
- if ( ! empty($this->_acf_groups) )
1168
- {
1169
- ?>
1170
- <p class="wpae-available-fields-group"><?php _e("ACF", "wp_all_export_plugin"); ?><span class="wpae-expander">+</span></p>
1171
- <div class="wp-all-export-acf-wrapper wpae-custom-field">
1172
- <?php
1173
-
1174
- foreach ($this->_acf_groups as $key => $group)
1175
- {
1176
- $is_acf_group_visible = false;
1177
- if (!empty($group['location'])){
1178
- foreach ( $group['location'] as $locationRule ){
1179
- $rule = array_shift($locationRule);
1180
- if ( XmlExportEngine::$is_user_export && $rule['param'] == 'user_form'){
1181
- $is_acf_group_visible = true;
1182
- break;
1183
- }
1184
- elseif ( XmlExportEngine::$is_taxonomy_export && $rule['param'] == 'taxonomy'){
1185
- $is_acf_group_visible = true;
1186
- break;
1187
- }
1188
- elseif ( 'specific' == XmlExportEngine::$exportOptions['export_type'] && $rule['param'] == 'post_type'){
1189
- if ( $rule['operator'] == '==' && in_array($rule['value'], XmlExportEngine::$post_types)){
1190
- $is_acf_group_visible = true;
1191
- break;
1192
- }
1193
- elseif ( $rule['operator'] != '==' && ! in_array($rule['value'], XmlExportEngine::$post_types)){
1194
- $is_acf_group_visible = true;
1195
- break;
1196
- }
1197
- }
1198
- elseif( 'advanced' == XmlExportEngine::$exportOptions['export_type']){
1199
- $is_acf_group_visible = true;
1200
- break;
1201
- }
1202
- }
1203
- }
1204
- else{
1205
- $is_acf_group_visible = true;
1206
- }
1207
-
1208
- if ( ! $is_acf_group_visible ) continue;
1209
-
1210
- ?>
1211
- <div class="wpae-acf-field">
1212
- <ul>
1213
- <li>
1214
- <div class="default_column" rel="">
1215
- <label class="wpallexport-element-label"><?php echo $group['title']; ?></label>
1216
- <input type="hidden" name="rules[]" value="pmxe_acf_<?php echo (!empty($group['ID'])) ? $group['ID'] : $group['id'];?>"/>
1217
- </div>
1218
- </li>
1219
- <?php
1220
- if ( ! empty($group['fields']))
1221
- {
1222
- foreach ($group['fields'] as $field)
1223
- {
1224
- ?>
1225
- <li class="pmxe_acf_<?php echo (!empty($group['ID'])) ? $group['ID'] : $group['id'];?> wp_all_export_auto_generate">
1226
- <div class="custom_column" rel="<?php echo ($i + 1);?>">
1227
- <label class="wpallexport-xml-element"><?php echo $field['label']; ?></label>
1228
- <input type="hidden" name="ids[]" value="1"/>
1229
- <input type="hidden" name="cc_label[]" value="<?php echo $field['name']; ?>"/>
1230
- <input type="hidden" name="cc_php[]" value=""/>
1231
- <input type="hidden" name="cc_code[]" value=""/>
1232
- <input type="hidden" name="cc_sql[]" value=""/>
1233
- <input type="hidden" name="cc_options[]" value="<?php echo esc_html(serialize(array_merge($field, array('group_id' => ((!empty($group['ID'])) ? $group['ID'] : $group['id']) ))));?>"/>
1234
- <input type="hidden" name="cc_type[]" value="acf"/>
1235
- <input type="hidden" name="cc_value[]" value="<?php echo $field['name']; ?>"/>
1236
- <input type="hidden" name="cc_name[]" value="<?php echo $field['label'];?>"/>
1237
- <input type="hidden" name="cc_settings[]" value=""/>
1238
- </div>
1239
- </li>
1240
- <?php
1241
- $i++;
1242
- }
1243
- }
1244
- ?>
1245
- </ul>
1246
- </div>
1247
- <?php
1248
- }
1249
- ?>
1250
- </div>
1251
- <?php
1252
- }
1253
- }
1254
-
1255
- public function render_new_field(){
1256
-
1257
- if ( ! empty($this->_acf_groups) )
1258
- {
1259
- foreach ($this->_acf_groups as $key => $group)
1260
- {
1261
- ?>
1262
- <optgroup label="<?php _e("ACF", "wp_all_export_plugin"); ?> - <?php echo $group['title']; ?>">
1263
- <?php
1264
- if ( ! empty($group['fields']))
1265
- {
1266
- foreach ($group['fields'] as $field)
1267
- {
1268
- $field_options = esc_html(serialize(array_merge($field, array('group_id' => ((!empty($group['ID'])) ? $group['ID'] : $group['id']) ))));
1269
- ?>
1270
- <option
1271
- value="acf"
1272
- label="<?php echo $field['name'];?>"
1273
- options="<?php echo $field_options; ?>"><?php echo $field['label'];?></option>
1274
- <?php
1275
- }
1276
- }
1277
- ?>
1278
- </optgroup>
1279
- <?php
1280
- }
1281
- ?>
1282
- </div>
1283
- <?php
1284
- }
1285
- }
1286
-
1287
- public function render_filters(){
1288
-
1289
- if ( ! empty($this->_acf_groups) ){
1290
- ?>
1291
- <optgroup label="<?php _e("ACF", "wp_all_export_plugin"); ?>">
1292
- <?php
1293
- foreach ($this->_acf_groups as $key => $group) {
1294
- if ( ! empty($group['fields'])){
1295
- foreach ($group['fields'] as $field) {
1296
- ?>
1297
- <option value="<?php echo 'cf_' . $field['name']; ?>"><?php echo $field['label']; ?></option>
1298
- <?php
1299
- }
1300
- }
1301
- }
1302
- ?>
1303
- </optgroup>
1304
- <?php
1305
- }
1306
-
1307
- }
1308
-
1309
- public static function prepare_import_template( $exportOptions, &$templateOptions, &$acf_list, $element_name, $field_options, $parent_delimiter = false)
1310
- {
1311
- $field_tpl_key = $element_name . '[1]';
1312
-
1313
- $acf_list[] = '[' . $field_options['name'] . '] ' . $field_options['label'];
1314
-
1315
- $field_template = false;
1316
-
1317
- $is_multiple_field_value = false;
1318
-
1319
- $is_xml_template = $exportOptions['export_to'] == 'xml';
1320
-
1321
- $xpath_separator = $is_xml_template ? '/' : '_';
1322
-
1323
- $implode_delimiter = XmlExportEngine::$implode;
1324
-
1325
- if (!empty($parent_delimiter)){
1326
- $implode_delimiter = $parent_delimiter == '|' ? ',' : '|';
1327
- }
1328
-
1329
- switch ($field_options['type'])
1330
- {
1331
- case 'text':
1332
- case 'textarea':
1333
- case 'number':
1334
- case 'email':
1335
- case 'password':
1336
- case 'url':
1337
- case 'oembed':
1338
- case 'wysiwyg':
1339
- case 'image':
1340
- case 'file':
1341
- case 'date_picker':
1342
- case 'color_picker':
1343
- case 'acf_cf7':
1344
- case 'gravity_forms_field':
1345
- case 'limiter':
1346
- case 'wp_wysiwyg':
1347
- case 'date_time_picker':
1348
- $field_template = '{' . $field_tpl_key . '}';
1349
- break;
1350
- case 'gallery':
1351
-
1352
- $field_template = array(
1353
- 'search_in_media' => 1,
1354
- 'delim' => $implode_delimiter,
1355
- 'gallery' => '{' . $field_tpl_key . '}'
1356
- );
1357
-
1358
- break;
1359
- case 'relationship':
1360
-
1361
- $field_template = array(
1362
- 'delim' => $implode_delimiter,
1363
- 'value' => '{' . $field_tpl_key . '}'
1364
- );
1365
-
1366
- break;
1367
- case 'post_object':
1368
- case 'page_link':
1369
- case 'user':
1370
-
1371
- if ($is_xml_template)
1372
- {
1373
- $field_template = '{' . $field_tpl_key . '}';
1374
- }
1375
- else
1376
- {
1377
- $field_tpl_key = str_replace("[1]", "", $field_tpl_key);
1378
-
1379
- if ($field_options['multiple'])
1380
- {
1381
- if ($implode_delimiter == "|")
1382
- $field_template = '[str_replace("|", ",",{' . $field_tpl_key . '[1]})]';
1383
- else
1384
- $field_template = '{' . $field_tpl_key . '[1]}';
1385
- }
1386
- else
1387
- {
1388
- $field_template = '{' . $field_tpl_key . '[1]}';
1389
- }
1390
- }
1391
-
1392
- break;
1393
- case 'select':
1394
- case 'checkbox':
1395
-
1396
- $templateOptions['is_multiple_field_value'][$field_options['key']] = "no";
1397
-
1398
- if ($is_xml_template)
1399
- {
1400
- if ($implode_delimiter == "|")
1401
- $field_template = '[str_replace("|", ",",{' . $field_tpl_key . '})]';
1402
- else
1403
- $field_template = '{' . $field_tpl_key . '}';
1404
- }
1405
- else
1406
- {
1407
- $field_tpl_key = str_replace("[1]", "", $field_tpl_key);
1408
-
1409
- if ($implode_delimiter == "|")
1410
- $field_template = '[str_replace("|", ",",{' . $field_tpl_key . '[1]})]';
1411
- else
1412
- $field_template = '{' . $field_tpl_key . '[1]}';
1413
- }
1414
-
1415
- break;
1416
- case 'radio':
1417
- case 'true_false':
1418
-
1419
- $templateOptions['is_multiple_field_value'][$field_options['key']] = "no";
1420
-
1421
- $field_template = '{' . $field_tpl_key . '}';
1422
-
1423
- break;
1424
- case 'location-field':
1425
- case 'google_map':
1426
-
1427
- if ( ! $is_xml_template) $field_tpl_key = str_replace("[1]", "", $field_tpl_key);
1428
-
1429
- $field_template = array(
1430
- 'address' => '{' . $field_tpl_key . $xpath_separator . 'address[1]}',
1431
- 'address_geocode' => 'address_no_key',
1432
- 'address_google_developers_api_key' => '',
1433
- 'address_google_for_work_client_id' => '',
1434
- 'address_google_for_work_digital_signature' => '',
1435
- 'lat' => '{' . $field_tpl_key . $xpath_separator . 'lat[1]}',
1436
- 'lng' => '{' . $field_tpl_key . $xpath_separator . 'lng[1]}'
1437
- );
1438
-
1439
- break;
1440
- case 'paypal_item':
1441
-
1442
- if ( ! $is_xml_template) $field_tpl_key = str_replace("[1]", "", $field_tpl_key);
1443
-
1444
- $field_template = array(
1445
- 'item_name' => '{' . $field_tpl_key . $xpath_separator . 'item_name[1]}',
1446
- 'item_description' => '{' . $field_tpl_key . $xpath_separator . 'item_description[1]}',
1447
- 'price' => '{' . $field_tpl_key . $xpath_separator . 'price[1]}'
1448
- );
1449
-
1450
- break;
1451
- case 'link':
1452
-
1453
- if ( ! $is_xml_template) $field_tpl_key = str_replace("[1]", "", $field_tpl_key);
1454
-
1455
- $field_template = array(
1456
- 'title' => '{' . $field_tpl_key . $xpath_separator . 'title[1]}',
1457
- 'url' => '{' . $field_tpl_key . $xpath_separator . 'url[1]}',
1458
- 'target' => '{' . $field_tpl_key . $xpath_separator . 'target[1]}'
1459
- );
1460
-
1461
- break;
1462
- case 'taxonomy':
1463
-
1464
- $taxonomy_options = array();
1465
-
1466
- $single_term = new stdClass;
1467
- $single_term->item_id = 1;
1468
- $single_term->parent_id = NULL;
1469
- $single_term->xpath = $is_xml_template ? '{' . $field_tpl_key . '/term[1]}' : '{' . $field_tpl_key . '}';
1470
- $single_term->assign = false;
1471
-
1472
- if ($implode_delimiter == "|"){
1473
- $single_term->xpath = '[str_replace("|", ",", '. $single_term->xpath .')]';
1474
- }
1475
-
1476
- $taxonomy_options[] = $single_term;
1477
-
1478
- $templateOptions['is_multiple_field_value'][$field_options['key']] = "no";
1479
-
1480
- $field_template = json_encode($taxonomy_options);
1481
-
1482
- break;
1483
-
1484
- case 'clone':
1485
-
1486
- if (!empty($field_options['clone'])) {
1487
- $sub_fields = array();
1488
- foreach ($field_options['clone'] as $sub_field_key) {
1489
- if (strpos($sub_field_key, 'group_') === 0) {
1490
- $acf_groups = get_posts(array(
1491
- 'posts_per_page' => 1,
1492
- 'post_type' => 'acf-field-group',
1493
- 'name' => $sub_field_key,
1494
- 'post_status' => 'publish'
1495
- ));
1496
- if (!empty($acf_groups)) {
1497
- foreach ($acf_groups as $acf_group) {
1498
- $sub_fields = get_posts(array(
1499
- 'posts_per_page' => -1,
1500
- 'post_type' => 'acf-field',
1501
- 'post_parent' => $acf_group->ID,
1502
- 'post_status' => 'publish',
1503
- 'orderby' => 'menu_order',
1504
- 'order' => 'ASC'
1505
- ));
1506
- }
1507
- }
1508
- }
1509
- else {
1510
- $args = array(
1511
- 'name' => $sub_field_key,
1512
- 'post_type' => 'acf-field',
1513
- 'post_status' => 'publish',
1514
- 'posts_per_page' => 1
1515
- );
1516
- $my_posts = get_posts($args);
1517
- if ($my_posts) {
1518
- $sub_fields[] = $my_posts[0];
1519
- }
1520
- }
1521
- }
1522
- if ( ! empty($sub_fields) ){
1523
-
1524
- foreach ($sub_fields as $n => $sub_field){
1525
-
1526
- $sub_field_options = unserialize($sub_field->post_content);
1527
- $sub_field_options['label'] = $sub_field->post_title;
1528
- $sub_field_options['name'] = $sub_field->post_excerpt;
1529
- $sub_field_options['ID'] = $sub_field->ID;
1530
- $sub_field_options['key'] = $sub_field->post_name;
1531
-
1532
- $sub_field_tpl_key = $is_xml_template ? $sub_field->post_excerpt : $element_name . '_' . strtolower($sub_field->post_excerpt);
1533
- $field_template[$sub_field->post_name] = self::prepare_import_template( $exportOptions, $templateOptions, $acf_list, $sub_field_tpl_key, $sub_field_options );
1534
- }
1535
- }
1536
- }
1537
-
1538
- break;
1539
-
1540
- case 'repeater':
1541
-
1542
- if ($is_xml_template)
1543
- {
1544
- $field_template = array(
1545
- 'is_variable' => 'yes',
1546
- 'foreach' => '{' . $field_tpl_key . '/row}',
1547
- 'rows' => array()
1548
- );
1549
- }
1550
- else
1551
- {
1552
- $field_template = array(
1553
- 'is_variable' => 'csv',
1554
- 'separator' => $implode_delimiter,
1555
- 'rows' => array()
1556
- );
1557
- }
1558
-
1559
- if (class_exists('acf')){
1560
-
1561
- global $acf;
1562
-
1563
- if ($acf and version_compare($acf->settings['version'], '5.0.0') >= 0){
1564
-
1565
- $sub_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => (( ! empty($field_options['id'])) ? $field_options['id'] : $field_options['ID']), 'post_status' => 'publish'));
1566
-
1567
- if ( ! empty($sub_fields) ){
1568
-
1569
- foreach ($sub_fields as $n => $sub_field){
1570
-
1571
- $sub_field_options = unserialize($sub_field->post_content);
1572
- $sub_field_options['label'] = $sub_field->post_title;
1573
- $sub_field_options['name'] = $sub_field->post_excerpt;
1574
- $sub_field_options['ID'] = $sub_field->ID;
1575
- $sub_field_options['key'] = $sub_field->post_name;
1576
-
1577
- $sub_field_tpl_key = $is_xml_template ? $sub_field->post_excerpt : $element_name . '_' . strtolower($sub_field->post_excerpt);
1578
- $field_template['rows']['1'][$sub_field->post_name] = self::prepare_import_template( $exportOptions, $templateOptions, $acf_list, $sub_field_tpl_key, $sub_field_options, $implode_delimiter );
1579
-
1580
- $templateOptions['is_multiple_field_value'][$field_options['key']]['rows']['1'][$sub_field->post_name] = "no";
1581
-
1582
- }
1583
- }
1584
-
1585
- }
1586
- else
1587
- {
1588
- if ( ! empty($field['sub_fields']))
1589
- {
1590
- foreach ($field['sub_fields'] as $n => $sub_field)
1591
- {
1592
- $sub_field_tpl_key = $is_xml_template ? $sub_field['name'] : $element_name . '_' . strtolower($sub_field['name']);
1593
-
1594
- $field_template['rows']['1'][$sub_field['key']] = self::prepare_import_template( $exportOptions, $templateOptions, $acf_list, $sub_field_tpl_key, $sub_field, $implode_delimiter );
1595
-
1596
- $templateOptions['is_multiple_field_value'][$field_options['key']]['rows']['1'][$sub_field['key']] = "no";
1597
- }
1598
- }
1599
- }
1600
- }
1601
-
1602
- break;
1603
-
1604
- case 'flexible_content':
1605
-
1606
- $field_template = array(
1607
- 'layouts' => array()
1608
- );
1609
-
1610
- if (class_exists('acf')){
1611
-
1612
- global $acf;
1613
-
1614
- if ($acf and version_compare($acf->settings['version'], '5.0.0') >= 0){
1615
-
1616
- $sub_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => (( ! empty($field_options['id'])) ? $field_options['id'] : $field_options['ID']), 'post_status' => 'publish'));
1617
-
1618
- if ( ! empty($field_options['layouts']))
1619
- {
1620
- foreach ($field_options['layouts'] as $key => $layout)
1621
- {
1622
- if ( ! empty($sub_fields) )
1623
- {
1624
- $field_template['layouts'][(string)($key + 1)]['acf_fc_layout'] = $layout['name'];
1625
-
1626
- foreach ($sub_fields as $n => $sub_field)
1627
- {
1628
- $sub_field_options = unserialize($sub_field->post_content);
1629
-
1630
- if ($sub_field_options['parent_layout'] == $layout['key'])
1631
- {
1632
- $sub_field_options['label'] = $sub_field->post_title;
1633
- $sub_field_options['name'] = $sub_field->post_excerpt;
1634
- $sub_field_options['ID'] = $sub_field->ID;
1635
- $sub_field_options['key'] = $sub_field->post_name;
1636
-
1637
- if ($is_xml_template)
1638
- {
1639
- $sub_field_tpl_key = $field_tpl_key . '/' . $layout['name'] . '_' . $key . '[1]/' . $sub_field->post_excerpt;
1640
- }
1641
- else
1642
- {
1643
- $sub_field_tpl_key = $element_name . '_' . $layout['name'] . '_' . $key . '_' . strtolower($sub_field->post_excerpt);
1644
- }
1645
-
1646
- $field_template['layouts'][(string)($key + 1)][$sub_field->post_name] = self::prepare_import_template( $exportOptions, $templateOptions, $acf_list, $sub_field_tpl_key, $sub_field_options );
1647
-
1648
- $templateOptions['is_multiple_field_value'][$field_options['key']]['layouts'][(string)($key + 1)][$sub_field->post_name] = "no";
1649
- }
1650
- }
1651
- }
1652
- }
1653
- }
1654
- }
1655
- else
1656
- {
1657
- if ( ! empty($field['layouts']))
1658
- {
1659
- foreach ($field['layouts'] as $key => $layout)
1660
- {
1661
- if ( ! empty($layout['sub_fields']))
1662
- {
1663
- $field_template['layouts'][(string)($key + 1)]['acf_fc_layout'] = $layout['key'];
1664
-
1665
- foreach ($layout['sub_fields'] as $n => $sub_field){
1666
-
1667
- if ($is_xml_template)
1668
- {
1669
- $sub_field_tpl_key = $field_tpl_key . '/' . $layout['name'] . '_' . $key . '[1]/' . $sub_field['name'];
1670
- }
1671
- else
1672
- {
1673
- $sub_field_tpl_key = $element_name . '_' . $layout['name'] . '_' . $key . '_' . strtolower($sub_field['name']);
1674
- }
1675
-
1676
- $field_template['layouts'][(string)($key + 1)][$sub_field['key']] = self::prepare_import_template( $exportOptions, $templateOptions, $acf_list, $sub_field_tpl_key, $sub_field );
1677
-
1678
- $templateOptions['is_multiple_field_value'][$field_options['key']]['layouts'][(string)($key + 1)][$sub_field['key']] = "no";
1679
- }
1680
- }
1681
- }
1682
- }
1683
- }
1684
- }
1685
-
1686
- break;
1687
-
1688
- default:
1689
-
1690
- $field_template = '{' . $field_tpl_key . '}';
1691
-
1692
- break;
1693
-
1694
- }
1695
- return $field_template;
1696
- }
1697
-
1698
- public function auto_generate_export_fields( & $fields ){
1699
-
1700
- if ( ! empty($this->_acf_groups) )
1701
- {
1702
- foreach ($this->_acf_groups as $key => $group)
1703
- {
1704
- if ( ! empty($group['fields']))
1705
- {
1706
- foreach ($group['fields'] as $field)
1707
- {
1708
- $fields['ids'][] = 1;
1709
- $fields['cc_label'][] = $field['name'];
1710
- $fields['cc_php'][] = 0;
1711
- $fields['cc_code'][] = '';
1712
- $fields['cc_sql'][] = '';
1713
- $fields['cc_settings'][] = '';
1714
- $fields['cc_type'][] = 'acf';
1715
- $fields['cc_options'][] = serialize(array_merge($field, array('group_id' => ((!empty($group['ID'])) ? $group['ID'] : $group['id']) )));
1716
- $fields['cc_value'][] = $field['name'];
1717
- $fields['cc_name'][] = $field['label'];
1718
- }
1719
- }
1720
- }
1721
- }
1722
- }
1723
-
1724
- /**
1725
- * __get function.
1726
- *
1727
- * @access public
1728
- * @param mixed $key
1729
- * @return mixed
1730
- */
1731
- public function __get( $key ) {
1732
- return $this->get( $key );
1733
- }
1734
-
1735
- /**
1736
- * Get a session variable
1737
- *
1738
- * @param string $key
1739
- * @param mixed $default used if the session variable isn't set
1740
- * @return mixed value of session variable
1741
- */
1742
- public function get( $key, $default = null ) {
1743
- return isset( $this->{$key} ) ? $this->{$key} : $default;
1744
- }
1745
-
1746
- public static function acf_get_row() {
1747
-
1748
- global $acf;
1749
-
1750
- if ($acf and version_compare($acf->settings['version'], '5.3.6.0') >= 0)
1751
- {
1752
- return acf_get_loop('active');
1753
- }
1754
- // check and return row
1755
- elseif( !empty($GLOBALS['acf_field']) ) {
1756
-
1757
- return end( $GLOBALS['acf_field'] );
1758
-
1759
- }
1760
-
1761
- // return
1762
- return false;
1763
-
1764
- }
1765
- }
1766
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
libraries/XmlExportCpt.php CHANGED
@@ -305,7 +305,9 @@ final class XmlExportCpt
305
 
306
  case 'acf':
307
 
308
- if (!empty($fieldLabel) and class_exists('acf')) {
 
 
309
 
310
  global $acf;
311
 
@@ -334,20 +336,21 @@ final class XmlExportCpt
334
  $field_value = get_field($fieldLabel, $entry->ID);
335
  }
336
 
337
- XmlExportACF::export_acf_field(
338
- $field_value,
339
- $exportOptions,
340
- $ID,
341
- $entry->ID,
342
- $article,
343
- $xmlWriter,
344
- $acfs,
345
- $element_name,
346
- $element_name_ns,
347
- $fieldSnippet,
348
- $field_options['group_id'],
349
- $preview
350
- );
 
351
  }
352
 
353
  break;
@@ -355,9 +358,13 @@ final class XmlExportCpt
355
  case 'woo':
356
 
357
  if ($is_xml_export) {
358
- XmlExportEngine::$woo_export->export_xml($xmlWriter, $entry, $exportOptions, $ID);
 
 
359
  } else {
360
- XmlExportEngine::$woo_export->export_csv($article, $woo, $entry, $exportOptions, $ID);
 
 
361
  }
362
 
363
  break;
@@ -365,9 +372,13 @@ final class XmlExportCpt
365
  case 'woo_order':
366
 
367
  if ($is_xml_export) {
368
- XmlExportEngine::$woo_order_export->export_xml($xmlWriter, $entry, $exportOptions, $ID, $preview);
 
 
369
  } else {
370
- XmlExportEngine::$woo_order_export->export_csv($article, $woo_order, $entry, $exportOptions, $ID, $preview);
 
 
371
  }
372
 
373
  break;
@@ -613,7 +624,7 @@ final class XmlExportCpt
613
  $templateOptions['is_update_status'] = 1;
614
  break;
615
  case 'comment_status':
616
- $templateOptions['comment_status_xpath'] = '{'.$element_name.'[1]}';
617
  $templateOptions['is_update_comment_status'] = 1;
618
  break;
619
  case 'date':
@@ -714,4 +725,5 @@ final class XmlExportCpt
714
  }
715
  return self::$userData[$userId];
716
  }
717
- }
 
305
 
306
  case 'acf':
307
 
308
+ if(XmlExportEngine::get_addons_service()->isAcfAddonActive()) {
309
+
310
+ if (!empty($fieldLabel) and class_exists('acf')) {
311
 
312
  global $acf;
313
 
336
  $field_value = get_field($fieldLabel, $entry->ID);
337
  }
338
 
339
+ XmlExportACF::export_acf_field(
340
+ $field_value,
341
+ $exportOptions,
342
+ $ID,
343
+ $entry->ID,
344
+ $article,
345
+ $xmlWriter,
346
+ $acfs,
347
+ $element_name,
348
+ $element_name_ns,
349
+ $fieldSnippet,
350
+ $field_options['group_id'],
351
+ $preview
352
+ );
353
+ }
354
  }
355
 
356
  break;
358
  case 'woo':
359
 
360
  if ($is_xml_export) {
361
+ if (XmlExportEngine::get_addons_service()->isWooCommerceAddonActive()) {
362
+ XmlExportEngine::$woo_export->export_xml($xmlWriter, $entry, $exportOptions, $ID);
363
+ }
364
  } else {
365
+ if (XmlExportEngine::get_addons_service()->isWooCommerceAddonActive()) {
366
+ XmlExportEngine::$woo_export->export_csv($article, $woo, $entry, $exportOptions, $ID);
367
+ }
368
  }
369
 
370
  break;
372
  case 'woo_order':
373
 
374
  if ($is_xml_export) {
375
+ if (XmlExportEngine::get_addons_service()->isWooCommerceAddonActive()) {
376
+ XmlExportEngine::$woo_order_export->export_xml($xmlWriter, $entry, $exportOptions, $ID, $preview);
377
+ }
378
  } else {
379
+ if (XmlExportEngine::get_addons_service()->isWooCommerceAddonActive()) {
380
+ XmlExportEngine::$woo_order_export->export_csv($article, $woo_order, $entry, $exportOptions, $ID, $preview);
381
+ }
382
  }
383
 
384
  break;
624
  $templateOptions['is_update_status'] = 1;
625
  break;
626
  case 'comment_status':
627
+ $templateOptions['comment_status_xpath'] = '{' . $element_name . '[1]}';
628
  $templateOptions['is_update_comment_status'] = 1;
629
  break;
630
  case 'date':
725
  }
726
  return self::$userData[$userId];
727
  }
728
+ }
729
+
libraries/XmlExportEngine.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  if ( ! class_exists('XmlExportEngine') ){
4
 
5
- require_once dirname(__FILE__) . '/XmlExportACF.php';
6
- require_once dirname(__FILE__) . '/XmlExportWooCommerce.php';
7
- require_once dirname(__FILE__) . '/XmlExportWooCommerceOrder.php';
8
  require_once dirname(__FILE__) . '/XmlExportComment.php';
9
  require_once dirname(__FILE__) . '/XmlExportTaxonomy.php';
10
 
@@ -35,10 +32,11 @@ if ( ! class_exists('XmlExportEngine') ){
35
  const EXPORT_TYPE_CSV = 'csv';
36
 
37
  public static $acf_export;
38
- public static $woo_export;
39
  public static $woo_order_export;
40
  public static $woo_coupon_export;
41
  public static $woo_refund_export;
 
42
  public static $user_export = false;
43
  public static $comment_export;
44
  public static $taxonomy_export;
@@ -53,7 +51,7 @@ if ( ! class_exists('XmlExportEngine') ){
53
 
54
  private static $addons_service = false;
55
 
56
- private $init_fields = array(
57
  array(
58
  'label' => 'id',
59
  'name' => 'ID',
@@ -344,15 +342,15 @@ if ( ! class_exists('XmlExportEngine') ){
344
  ),
345
  'cats' => array(
346
  'title' => __("Taxonomies", "wp_all_export_plugin"),
347
- 'content' => 'existing_taxonomies'
348
  ),
349
  'cf' => array(
350
  'title' => __("Custom Fields", "wp_all_export_plugin"),
351
- 'content' => 'existing_meta_keys'
352
  ),
353
  'other' => array(
354
  'title' => __("Other", "wp_all_export_plugin"),
355
- 'content' => 'other_fields'
356
  )
357
  );
358
 
@@ -442,13 +440,8 @@ if ( ! class_exists('XmlExportEngine') ){
442
 
443
  if ( !empty(self::$exportOptions['xml_template_type']) && in_array(self::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ) self::$implode = '#delimiter#';
444
 
445
- self::$acf_export = new XmlExportACF();
446
- self::$woo_export = new XmlExportWooCommerce();
447
  self::$comment_export = new XmlExportComment();
448
  self::$taxonomy_export = new XmlExportTaxonomy();
449
- self::$woo_order_export = new XmlExportWooCommerceOrder();
450
- self::$woo_coupon_export = new XmlExportWooCommerceCoupon();
451
-
452
  do_action('pmxe_init_addons');
453
  }
454
 
@@ -474,9 +467,18 @@ if ( ! class_exists('XmlExportEngine') ){
474
 
475
  if ('advanced' == $this->post['export_type']) {
476
 
477
- if( "" == $this->post['wp_query'] ){
478
- $this->errors->add('form-validation', __('WP Query field is required', 'pmxe_plugin'));
479
- }
 
 
 
 
 
 
 
 
 
480
  else
481
  {
482
  $this->filters->parse();
@@ -503,9 +505,10 @@ if ( ! class_exists('XmlExportEngine') ){
503
 
504
  public function init_additional_data(){
505
 
506
- self::$woo_order_export->init_additional_data();
507
- self::$woo_export->init_additional_data();
508
-
 
509
  }
510
 
511
  public function init_available_data(){
@@ -544,17 +547,21 @@ if ( ! class_exists('XmlExportEngine') ){
544
  }
545
  }
546
 
547
- // Prepare existing ACF groups & fields
548
- self::$acf_export->init($this->_existing_meta_keys);
549
-
550
- // Prepare existing WooCommerce data
551
- self::$woo_export->init($this->_existing_meta_keys);
552
 
553
- // Prepare existing WooCommerce Order data
554
- self::$woo_order_export->init($this->_existing_meta_keys);
 
555
 
556
- // Prepare existing WooCommerce Coupon data
557
- self::$woo_coupon_export->init($this->_existing_meta_keys);
 
 
 
 
558
 
559
  if(XmlExportEngine::$user_export) {
560
  // Prepare existing Users data
@@ -572,8 +579,11 @@ if ( ! class_exists('XmlExportEngine') ){
572
 
573
  public function get_available_data(){
574
 
575
- $this->available_data['acf_groups'] = self::$acf_export->get('_acf_groups');
576
- $this->available_data['existing_acf_meta_keys'] = self::$acf_export->get('_existing_acf_meta_keys');
 
 
 
577
  $this->available_data['existing_meta_keys'] = $this->_existing_meta_keys;
578
  $this->available_data['existing_taxonomies'] = $this->_existing_taxonomies;
579
 
@@ -662,8 +672,10 @@ if ( ! class_exists('XmlExportEngine') ){
662
  }
663
 
664
  if ( ! self::$is_comment_export )
665
- {
666
- self::$acf_export->get_fields_options( $fields, $field_keys );
 
 
667
  }
668
 
669
  $sort_fields = array();
@@ -698,8 +710,10 @@ if ( ! class_exists('XmlExportEngine') ){
698
  $available_sections = apply_filters("wp_all_export_available_sections", $this->available_sections);
699
  self::$globalAvailableSections = $available_sections;
700
 
701
- // Render Available WooCommerce Orders Data
702
- self::$woo_order_export->render($i);
 
 
703
 
704
  foreach ($available_sections as $slug => $section)
705
  {
@@ -821,9 +835,25 @@ if ( ! class_exists('XmlExportEngine') ){
821
  }
822
 
823
  if ( ! self::$is_comment_export )
824
- {
825
- // Render Available ACF
826
- self::$acf_export->render($i);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
827
  }
828
 
829
  return ob_get_clean();
@@ -834,8 +864,10 @@ if ( ! class_exists('XmlExportEngine') ){
834
 
835
  $available_sections = apply_filters("wp_all_export_available_sections", apply_filters('wp_all_export_filters', $this->available_sections) );
836
 
837
- // Render Filters for WooCommerce Orders
838
- self::$woo_order_export->render_filters();
 
 
839
 
840
  if ( ! empty($available_sections) )
841
  {
@@ -1000,9 +1032,11 @@ if ( ! class_exists('XmlExportEngine') ){
1000
  }
1001
 
1002
  if ( ! self::$is_comment_export )
1003
- {
1004
- // Render Available ACF
1005
- self::$acf_export->render_filters();
 
 
1006
  }
1007
 
1008
  }
@@ -1013,8 +1047,10 @@ if ( ! class_exists('XmlExportEngine') ){
1013
 
1014
  $available_sections = apply_filters("wp_all_export_available_sections", $this->available_sections);
1015
 
 
1016
  // Render Available WooCommerce Orders Data
1017
- self::$woo_order_export->render_new_field();
 
1018
 
1019
  if ( ! empty($available_sections) ):?>
1020
 
@@ -1087,9 +1123,11 @@ if ( ! class_exists('XmlExportEngine') ){
1087
  }
1088
 
1089
  if ( ! self::$is_comment_export )
1090
- {
1091
- // Render Available ACF
1092
- self::$acf_export->render_new_field();
 
 
1093
  }
1094
 
1095
  ?>
2
 
3
  if ( ! class_exists('XmlExportEngine') ){
4
 
 
 
 
5
  require_once dirname(__FILE__) . '/XmlExportComment.php';
6
  require_once dirname(__FILE__) . '/XmlExportTaxonomy.php';
7
 
32
  const EXPORT_TYPE_CSV = 'csv';
33
 
34
  public static $acf_export;
35
+ public static $woo_export = false;
36
  public static $woo_order_export;
37
  public static $woo_coupon_export;
38
  public static $woo_refund_export;
39
+ public static $woo_review_export;
40
  public static $user_export = false;
41
  public static $comment_export;
42
  public static $taxonomy_export;
51
 
52
  private static $addons_service = false;
53
 
54
+ private $init_fields = array(
55
  array(
56
  'label' => 'id',
57
  'name' => 'ID',
342
  ),
343
  'cats' => array(
344
  'title' => __("Taxonomies", "wp_all_export_plugin"),
345
+ 'content' => 'existing_taxonomies'
346
  ),
347
  'cf' => array(
348
  'title' => __("Custom Fields", "wp_all_export_plugin"),
349
+ 'content' => 'existing_meta_keys'
350
  ),
351
  'other' => array(
352
  'title' => __("Other", "wp_all_export_plugin"),
353
+ 'content' => 'other_fields'
354
  )
355
  );
356
 
440
 
441
  if ( !empty(self::$exportOptions['xml_template_type']) && in_array(self::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ) self::$implode = '#delimiter#';
442
 
 
 
443
  self::$comment_export = new XmlExportComment();
444
  self::$taxonomy_export = new XmlExportTaxonomy();
 
 
 
445
  do_action('pmxe_init_addons');
446
  }
447
 
467
 
468
  if ('advanced' == $this->post['export_type']) {
469
 
470
+ if( "" == $this->post['wp_query'] ){
471
+ $this->errors->add('form-validation', __('WP Query field is required', 'pmxe_plugin'));
472
+ }
473
+ else if(!XmlExportEngine::get_addons_service()->isWooCommerceAddonActive() && strpos($this->post['wp_query'], 'product') !== false) {
474
+ $this->errors->add('form-validation', __('The WooCommerce Export Add-On Pro is required to Export WooCommerce Products', 'pmxe_plugin'));
475
+ }
476
+ else if(!XmlExportEngine::get_addons_service()->isWooCommerceAddonActive() && strpos($this->post['wp_query'], 'shop_order') !== false) {
477
+ $this->errors->add('form-validation', __('The WooCommerce Export Add-On Pro is required to Export WooCommerce Orders', 'pmxe_plugin'));
478
+ }
479
+ else if(!XmlExportEngine::get_addons_service()->isWooCommerceAddonActive() && strpos($this->post['wp_query'], 'shop_coupon') !== false) {
480
+ $this->errors->add('form-validation', __('The WooCommerce Export Add-On Pro is required to Export WooCommerce Coupons', 'pmxe_plugin'));
481
+ }
482
  else
483
  {
484
  $this->filters->parse();
505
 
506
  public function init_additional_data(){
507
 
508
+ if(self::$woo_export) {
509
+ self::$woo_order_export->init_additional_data();
510
+ self::$woo_export->init_additional_data();
511
+ }
512
  }
513
 
514
  public function init_available_data(){
547
  }
548
  }
549
 
550
+ if(self::$acf_export) {
551
+ // Prepare existing ACF groups & fields
552
+ self::$acf_export->init($this->_existing_meta_keys);
553
+ }
 
554
 
555
+ if(XmlExportEngine::$woo_export) {
556
+ // Prepare existing WooCommerce data
557
+ self::$woo_export->init($this->_existing_meta_keys);
558
 
559
+ // Prepare existing WooCommerce Order data
560
+ self::$woo_order_export->init($this->_existing_meta_keys);
561
+
562
+ // Prepare existing WooCommerce Coupon data
563
+ self::$woo_coupon_export->init($this->_existing_meta_keys);
564
+ }
565
 
566
  if(XmlExportEngine::$user_export) {
567
  // Prepare existing Users data
579
 
580
  public function get_available_data(){
581
 
582
+ if(self::$acf_export) {
583
+ $this->available_data['acf_groups'] = self::$acf_export->get('_acf_groups');
584
+ $this->available_data['existing_acf_meta_keys'] = self::$acf_export->get('_existing_acf_meta_keys');
585
+ }
586
+
587
  $this->available_data['existing_meta_keys'] = $this->_existing_meta_keys;
588
  $this->available_data['existing_taxonomies'] = $this->_existing_taxonomies;
589
 
672
  }
673
 
674
  if ( ! self::$is_comment_export )
675
+ {
676
+ if(self::$acf_export) {
677
+ self::$acf_export->get_fields_options( $fields, $field_keys );
678
+ }
679
  }
680
 
681
  $sort_fields = array();
710
  $available_sections = apply_filters("wp_all_export_available_sections", $this->available_sections);
711
  self::$globalAvailableSections = $available_sections;
712
 
713
+ if(self::$woo_export) {
714
+ // Render Available WooCommerce Orders Data
715
+ self::$woo_order_export->render($i);
716
+ }
717
 
718
  foreach ($available_sections as $slug => $section)
719
  {
835
  }
836
 
837
  if ( ! self::$is_comment_export )
838
+ {
839
+ if(self::$acf_export) {
840
+ // Render Available ACF
841
+ self::$acf_export->render($i);
842
+ } else {
843
+ if(!self::get_addons_service()->isAcfAddonActive()) {
844
+ ?>
845
+ <p class="wpae-available-fields-group">ACF<span class="wpae-expander">+</span></p>
846
+ <div class="wpae-custom-field">
847
+
848
+ <div class="wpallexport-free-edition-notice">
849
+ <a class="upgrade_link" target="_blank"
850
+ href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=4206907&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-advanced-custom-fields">Upgrade to the ACF Export Package to Export Advanced Custom Fields</a>
851
+ </div>
852
+ </div>
853
+ <?php
854
+ }
855
+
856
+ }
857
  }
858
 
859
  return ob_get_clean();
864
 
865
  $available_sections = apply_filters("wp_all_export_available_sections", apply_filters('wp_all_export_filters', $this->available_sections) );
866
 
867
+ if(self::$woo_export) {
868
+ // Render Filters for WooCommerce Orders
869
+ self::$woo_order_export->render_filters();
870
+ }
871
 
872
  if ( ! empty($available_sections) )
873
  {
1032
  }
1033
 
1034
  if ( ! self::$is_comment_export )
1035
+ {
1036
+ if(self::$acf_export) {
1037
+ // Render Available ACF
1038
+ self::$acf_export->render_filters();
1039
+ }
1040
  }
1041
 
1042
  }
1047
 
1048
  $available_sections = apply_filters("wp_all_export_available_sections", $this->available_sections);
1049
 
1050
+ if(self::$woo_export) {
1051
  // Render Available WooCommerce Orders Data
1052
+ self::$woo_order_export->render_new_field();
1053
+ }
1054
 
1055
  if ( ! empty($available_sections) ):?>
1056
 
1123
  }
1124
 
1125
  if ( ! self::$is_comment_export )
1126
+ {
1127
+ if(self::$acf_export) {
1128
+ // Render Available ACF
1129
+ self::$acf_export->render_new_field();
1130
+ }
1131
  }
1132
 
1133
  ?>
libraries/XmlExportUser.php DELETED
@@ -1,747 +0,0 @@
1
- <?php
2
-
3
- if ( ! class_exists('XmlExportUser') ){
4
-
5
- final class XmlExportUser
6
- {
7
- private $init_fields = array(
8
- array(
9
- 'label' => 'id',
10
- 'name' => 'ID',
11
- 'type' => 'id'
12
- ),
13
- array(
14
- 'label' => 'user_email',
15
- 'name' => 'User Email',
16
- 'type' => 'user_email'
17
- ),
18
- array(
19
- 'label' => 'user_login',
20
- 'name' => 'User Login',
21
- 'type' => 'user_login'
22
- )
23
- );
24
-
25
- private $default_fields = array(
26
- array(
27
- 'label' => 'id',
28
- 'name' => 'ID',
29
- 'type' => 'id'
30
- ),
31
- array(
32
- 'label' => 'user_login',
33
- 'name' => 'User Login',
34
- 'type' => 'user_login'
35
- ),
36
- array(
37
- 'label' => 'user_email',
38
- 'name' => 'User Email',
39
- 'type' => 'user_email'
40
- ),
41
- array(
42
- 'label' => 'first_name',
43
- 'name' => 'First Name',
44
- 'type' => 'first_name'
45
- ),
46
- array(
47
- 'label' => 'last_name',
48
- 'name' => 'Last Name',
49
- 'type' => 'last_name'
50
- ),
51
- array(
52
- 'label' => 'user_registered',
53
- 'name' => 'User Registered',
54
- 'type' => 'user_registered'
55
- ),
56
- array(
57
- 'label' => 'user_nicename',
58
- 'name' => 'User Nicename',
59
- 'type' => 'user_nicename'
60
- ),
61
- array(
62
- 'label' => 'user_url',
63
- 'name' => 'User URL',
64
- 'type' => 'user_url'
65
- ),
66
- array(
67
- 'label' => 'display_name',
68
- 'name' => 'Display Name',
69
- 'type' => 'display_name'
70
- ),
71
- array(
72
- 'label' => 'nickname',
73
- 'name' => 'Nickname',
74
- 'type' => 'nickname'
75
- ),
76
- array(
77
- 'label' => 'description',
78
- 'name' => 'Description',
79
- 'type' => 'description'
80
- )
81
- );
82
-
83
- private $advanced_fields = array(
84
- array(
85
- 'label' => 'wp_capabilities',
86
- 'name' => 'User Role',
87
- 'type' => 'wp_capabilities'
88
- ),
89
- array(
90
- 'label' => 'user_pass',
91
- 'name' => 'User Pass',
92
- 'type' => 'user_pass'
93
- ),
94
- array(
95
- 'label' => 'user_activation_key',
96
- 'name' => 'User Activation Key',
97
- 'type' => 'user_activation_key'
98
- ),
99
- array(
100
- 'label' => 'user_status',
101
- 'name' => 'User Status',
102
- 'type' => 'user_status'
103
- )
104
- );
105
-
106
- private $user_core_fields = array();
107
-
108
- public static $is_active = true;
109
-
110
- public static $is_export_shop_customer = false;
111
-
112
- public function __construct()
113
- {
114
-
115
- $this->user_core_fields = array('rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front', 'wp_user_level', 'show_welcome_panel', 'dismissed_wp_pointers', 'session_tokens', 'wp_user-settings', 'wp_user-settings-time', 'wp_dashboard_quick_press_last_post_id', 'metaboxhidden_dashboard', 'closedpostboxes_dashboard', 'wp_nav_menu_recently_edited', 'meta-box-order_dashboard', 'closedpostboxes_product', 'metaboxhidden_product', 'manageedit-shop_ordercolumnshidden', 'aim', 'yim', 'jabber', 'wp_media_library_mode');
116
-
117
- if ( ( XmlExportEngine::$exportOptions['export_type'] == 'specific' and ! in_array('users', XmlExportEngine::$post_types) and ! in_array('shop_customer', XmlExportEngine::$post_types) )
118
- or ( XmlExportEngine::$exportOptions['export_type'] == 'advanced' and XmlExportEngine::$exportOptions['wp_query_selector'] != 'wp_user_query' ) ){
119
- self::$is_active = false;
120
- return;
121
- }
122
-
123
- self::$is_active = true;
124
-
125
- if (in_array('shop_customer', XmlExportEngine::$post_types)) self::$is_export_shop_customer = true;
126
-
127
- add_filter("wp_all_export_available_data", array( &$this, "filter_available_data"), 10, 1);
128
- add_filter("wp_all_export_available_sections", array( &$this, "filter_available_sections" ), 10, 1);
129
- add_filter("wp_all_export_init_fields", array( &$this, "filter_init_fields"), 10, 1);
130
- add_filter("wp_all_export_default_fields", array( &$this, "filter_default_fields"), 10, 1);
131
- add_filter("wp_all_export_other_fields", array( &$this, "filter_other_fields"), 10, 1);
132
-
133
- }
134
-
135
- // [FILTERS]
136
-
137
- /**
138
- *
139
- * Filter Init Fields
140
- *
141
- */
142
- public function filter_init_fields($init_fields){
143
- return $this->init_fields;
144
- }
145
-
146
- /**
147
- *
148
- * Filter Default Fields
149
- *
150
- */
151
- public function filter_default_fields($default_fields){
152
- return $this->default_fields;
153
- }
154
-
155
- /**
156
- *
157
- * Filter Other Fields
158
- *
159
- */
160
- public function filter_other_fields($other_fields){
161
-
162
- $other_fields = array();
163
-
164
- foreach ( $this->advanced_fields as $key => $field ) {
165
- $other_fields[] = $field;
166
- }
167
-
168
- foreach ( $this->user_core_fields as $field ) {
169
- $other_fields[] = $this->fix_titles(array(
170
- 'label' => $field,
171
- 'name' => $field,
172
- 'type' => 'cf'
173
- ));
174
- }
175
-
176
- return $other_fields;
177
- }
178
-
179
- /**
180
- *
181
- * Filter Available Data
182
- *
183
- */
184
- public function filter_available_data($available_data){
185
-
186
- if (self::$is_export_shop_customer)
187
- {
188
- $available_data['address_fields'] = $this->available_customer_data();
189
- }
190
- elseif (self::$is_woo_custom_founded)
191
- {
192
- $available_data['customer_fields'] = $this->available_customer_data();
193
- }
194
-
195
- return $available_data;
196
- }
197
-
198
- /**
199
- *
200
- * Filter Sections in Available Data
201
- *
202
- */
203
- public function filter_available_sections($available_sections){
204
-
205
- unset($available_sections['cats']);
206
- unset($available_sections['media']);
207
-
208
- if (self::$is_export_shop_customer)
209
- {
210
- $customer_data = array(
211
- 'address' => array(
212
- 'title' => __("Address", "wp_all_export_plugin"),
213
- 'content' => 'address_fields'
214
- )
215
- );
216
-
217
- return array_merge(array_slice($available_sections, 0, 1), $customer_data, array_slice($available_sections, 1));
218
- }
219
- elseif (self::$is_woo_custom_founded)
220
- {
221
- $customer_data = array(
222
- 'customer' => array(
223
- 'title' => __("Address", "wp_all_export_plugin"),
224
- 'content' => 'customer_fields'
225
- )
226
- );
227
- $available_sections = array_merge(array_slice($available_sections, 0, 1), $customer_data, array_slice($available_sections, 1));
228
- }
229
-
230
- self::$is_export_shop_customer or $available_sections['other']['title'] = __("Other", "wp_all_export_plugin");
231
-
232
- return $available_sections;
233
- }
234
-
235
- // [\FILTERS]
236
-
237
- public static $meta_keys;
238
- public static $is_woo_custom_founded = false;
239
- public function init( & $existing_meta_keys = array() )
240
- {
241
- if ( ! self::$is_active ) return;
242
-
243
- global $wpdb;
244
- //$table_prefix = $wpdb->prefix;
245
- self::$meta_keys = $wpdb->get_results("SELECT DISTINCT ".$wpdb->usermeta .".meta_key FROM $wpdb->usermeta, $wpdb->users WHERE ".$wpdb->usermeta.".user_id = ".$wpdb->users.".ID LIMIT 500");
246
-
247
- $user_ids = array();
248
- if ( ! empty(XmlExportEngine::$exportQuery->results)) {
249
- foreach ( XmlExportEngine::$exportQuery->results as $user ) :
250
- $user_ids[] = $user->ID;
251
- endforeach;
252
- }
253
-
254
- if ( ! empty(self::$meta_keys)){
255
-
256
- $address_fields = $this->available_customer_data();
257
-
258
- $customer_users = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value != %s ", '_customer_user', '0'));
259
-
260
- // detect if at least one filtered user is a WooCommerce customer
261
- if ( ! empty($customer_users) ) {
262
- foreach ($customer_users as $customer_user) {
263
- if ( in_array($customer_user->meta_value, $user_ids) )
264
- {
265
- self::$is_woo_custom_founded = true;
266
- break;
267
- }
268
- }
269
- }
270
-
271
- $exclude_keys = array('_first_variation_attributes', '_is_first_variation_created');
272
- foreach (self::$meta_keys as $meta_key) {
273
- if ( ! in_array($meta_key->meta_key, $exclude_keys))
274
- {
275
- $to_add = true;
276
- foreach ($this->default_fields as $default_value) {
277
- if ( $meta_key->meta_key == $default_value['name'] || $meta_key->meta_key == $default_value['type'] ){
278
- $to_add = false;
279
- break;
280
- }
281
- }
282
- if ( $to_add ){
283
- foreach ($this->advanced_fields as $advanced_value) {
284
- if ( $meta_key->meta_key == $advanced_value['name'] || $meta_key->meta_key == $advanced_value['type']){
285
- $to_add = false;
286
- break;
287
- }
288
- }
289
- }
290
- if ( $to_add ){
291
- foreach ($this->user_core_fields as $core_field) {
292
- if ( $meta_key->meta_key == $core_field ){
293
- $to_add = false;
294
- break;
295
- }
296
- }
297
- }
298
- if ( $to_add && ( self::$is_export_shop_customer || self::$is_woo_custom_founded ) )
299
- {
300
- foreach ($address_fields as $address_value) {
301
- if ( $meta_key->meta_key == $address_value['label']){
302
- $to_add = false;
303
- break;
304
- }
305
- }
306
- }
307
- if ( $to_add )
308
- {
309
- $existing_meta_keys[] = $meta_key->meta_key;
310
- }
311
- }
312
- }
313
- }
314
- }
315
-
316
- public function available_customer_data()
317
- {
318
-
319
- $main_fields = array(
320
- array(
321
- 'name' => __('Customer User ID', 'wp_all_export_plugin'),
322
- 'label' => '_customer_user',
323
- 'type' => 'cf'
324
- )
325
- );
326
-
327
- $data = array_merge($main_fields, $this->available_billing_information_data(), $this->available_shipping_information_data());
328
-
329
- return apply_filters('wp_all_export_available_user_data_filter', $data);
330
-
331
- }
332
-
333
- public function available_billing_information_data()
334
- {
335
-
336
- $keys = array(
337
- 'billing_first_name', 'billing_last_name', 'billing_company',
338
- 'billing_address_1', 'billing_address_2', 'billing_city',
339
- 'billing_postcode', 'billing_country', 'billing_state',
340
- 'billing_email', 'billing_phone'
341
- );
342
-
343
- $data = $this->generate_friendly_titles($keys, 'billing');
344
-
345
- return apply_filters('wp_all_export_available_billing_information_data_filter', $data);
346
-
347
- }
348
-
349
- public function available_shipping_information_data()
350
- {
351
-
352
- $keys = array(
353
- 'shipping_first_name', 'shipping_last_name', 'shipping_company',
354
- 'shipping_address_1', 'shipping_address_2', 'shipping_city',
355
- 'shipping_postcode', 'shipping_country', 'shipping_state'
356
- );
357
-
358
- $data = $this->generate_friendly_titles($keys, 'shipping');
359
-
360
- return apply_filters('wp_all_export_available_shipping_information_data_filter', $data);
361
-
362
- }
363
-
364
- public function generate_friendly_titles($keys, $keyword = ''){
365
- $data = array();
366
- foreach ($keys as $key) {
367
-
368
- $key1 = $this->fix_titles(str_replace('_', ' ', $key));
369
- $key2 = '';
370
-
371
- if(strpos($key1, $keyword)!== false)
372
- {
373
- $key1 = str_replace($keyword, '', $key1);
374
- $key2 = ' ('.__($keyword, 'wp_all_export_plugin').')';
375
- }
376
-
377
- $data[] = array(
378
- 'name' => __(trim($key1), 'woocommerce').$key2,
379
- 'label' => $key,
380
- 'type' => 'cf'
381
- );
382
-
383
- }
384
- return $data;
385
- }
386
- /**
387
- *
388
- * Helper method to fix fields title
389
- *
390
- */
391
- protected function fix_titles($field)
392
- {
393
- if (is_array($field))
394
- {
395
- $field['name'] = $this->fix_title($field['name']);
396
- }
397
- else
398
- {
399
- $field = $this->fix_title($field);
400
- }
401
- return $field;
402
- }
403
- /**
404
- *
405
- * Helper method to fix single title
406
- *
407
- */
408
- protected function fix_title($title)
409
- {
410
- $uc_title = ucwords(trim(str_replace("-", " ", str_replace("_", " ", $title))));
411
-
412
- return stripos($uc_title, "width") === false ? str_ireplace(array('id', 'url', 'sku', 'wp', 'ssl'), array('ID', 'URL', 'SKU', 'WP', 'SSL'), $uc_title) : $uc_title;
413
- }
414
-
415
- public static function prepare_data( $user, $xmlWriter = false, &$acfs, $implode_delimiter, $preview )
416
- {
417
- $article = array();
418
-
419
- // associate exported user with import
420
- if ( wp_all_export_is_compatible() and XmlExportEngine::$exportOptions['is_generate_import'] and XmlExportEngine::$exportOptions['import_id'])
421
- {
422
- $postRecord = new PMXI_Post_Record();
423
- $postRecord->clear();
424
- $postRecord->getBy(array(
425
- 'post_id' => $user->ID,
426
- 'import_id' => XmlExportEngine::$exportOptions['import_id'],
427
- ));
428
-
429
- if ($postRecord->isEmpty()){
430
- $postRecord->set(array(
431
- 'post_id' => $user->ID,
432
- 'import_id' => XmlExportEngine::$exportOptions['import_id'],
433
- 'unique_key' => $user->ID
434
- ))->save();
435
- }
436
- unset($postRecord);
437
- }
438
-
439
- $is_xml_export = false;
440
-
441
- if ( ! empty($xmlWriter) and XmlExportEngine::$exportOptions['export_to'] == 'xml' and ! in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ){
442
- $is_xml_export = true;
443
- }
444
-
445
- foreach (XmlExportEngine::$exportOptions['ids'] as $ID => $value)
446
- {
447
- $fieldName = apply_filters('wp_all_export_field_name', wp_all_export_parse_field_name(XmlExportEngine::$exportOptions['cc_name'][$ID]), XmlExportEngine::$exportID);
448
- $fieldValue = XmlExportEngine::$exportOptions['cc_value'][$ID];
449
- $fieldLabel = XmlExportEngine::$exportOptions['cc_label'][$ID];
450
- $fieldSql = XmlExportEngine::$exportOptions['cc_sql'][$ID];
451
- $fieldPhp = XmlExportEngine::$exportOptions['cc_php'][$ID];
452
- $fieldCode = XmlExportEngine::$exportOptions['cc_code'][$ID];
453
- $fieldType = XmlExportEngine::$exportOptions['cc_type'][$ID];
454
- $fieldOptions = XmlExportEngine::$exportOptions['cc_options'][$ID];
455
- $fieldSettings = empty(XmlExportEngine::$exportOptions['cc_settings'][$ID]) ? $fieldOptions : XmlExportEngine::$exportOptions['cc_settings'][$ID];
456
-
457
- if ( empty($fieldName) or empty($fieldType) or ! is_numeric($ID) ) continue;
458
-
459
- $element_name = ( ! empty($fieldName) ) ? $fieldName : 'untitled_' . $ID;
460
- $element_name_ns = '';
461
-
462
- if ( $is_xml_export )
463
- {
464
- $element_name = ( ! empty($fieldName) ) ? preg_replace('/[^a-z0-9_:-]/i', '', $fieldName) : 'untitled_' . $ID;
465
-
466
- if (strpos($element_name, ":") !== false)
467
- {
468
- $element_name_parts = explode(":", $element_name);
469
- $element_name_ns = (empty($element_name_parts[0])) ? '' : $element_name_parts[0];
470
- $element_name = (empty($element_name_parts[1])) ? 'untitled_' . $ID : preg_replace('/[^a-z0-9_-]/i', '', $element_name_parts[1]);
471
- }
472
- }
473
-
474
- $fieldSnipped = ( ! empty($fieldPhp ) and ! empty($fieldCode)) ? $fieldCode : false;
475
-
476
- switch ($fieldType)
477
- {
478
- case 'id':
479
- // For ID columns make first element in lowercase for Excel export
480
- if ($element_name == 'ID' && !$ID && isset(XmlExportEngine::$exportOptions['export_to']) && XmlExportEngine::$exportOptions['export_to'] == 'csv' && isset(XmlExportEngine::$exportOptions['export_to_sheet']) && XmlExportEngine::$exportOptions['export_to_sheet'] != 'csv'){
481
- $element_name = 'id';
482
- }
483
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_user_id', pmxe_filter($user->ID, $fieldSnipped), $user->ID) );
484
- break;
485
- case 'user_login':
486
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_user_login', pmxe_filter($user->user_login, $fieldSnipped), $user->ID) );
487
- break;
488
- case 'user_pass':
489
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_user_pass', pmxe_filter($user->user_pass, $fieldSnipped), $user->ID) );
490
- break;
491
- case 'user_email':
492
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_user_email', pmxe_filter($user->user_email, $fieldSnipped), $user->ID) );
493
- break;
494
- case 'user_nicename':
495
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_user_nicename', pmxe_filter($user->user_nicename, $fieldSnipped), $user->ID) );
496
- break;
497
- case 'user_url':
498
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_user_url', pmxe_filter($user->user_url, $fieldSnipped), $user->ID) );
499
- break;
500
- case 'user_activation_key':
501
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_user_activation_key', pmxe_filter($user->user_activation_key, $fieldSnipped), $user->ID) );
502
- break;
503
- case 'user_status':
504
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_user_status', pmxe_filter($user->user_status, $fieldSnipped), $user->ID) );
505
- break;
506
- case 'display_name':
507
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_user_display_name', pmxe_filter($user->display_name, $fieldSnipped), $user->ID) );
508
- break;
509
- case 'nickname':
510
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_user_nickname', pmxe_filter($user->nickname, $fieldSnipped), $user->ID) );
511
- break;
512
- case 'first_name':
513
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_user_first_name', pmxe_filter($user->first_name, $fieldSnipped), $user->ID) );
514
- break;
515
- case 'last_name':
516
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_user_last_name', pmxe_filter($user->last_name, $fieldSnipped), $user->ID) );
517
- break;
518
- case 'wp_capabilities':
519
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_user_wp_capabilities', pmxe_filter(implode($implode_delimiter, $user->roles), $fieldSnipped), $user->ID) );
520
- break;
521
- case 'description':
522
- $val = apply_filters('pmxe_user_description', pmxe_filter($user->description, $fieldSnipped), $user->ID);
523
- wp_all_export_write_article( $article, $element_name, ($preview) ? trim(preg_replace('~[\r\n]+~', ' ', htmlspecialchars($val))) : $val );
524
- break;
525
- case 'user_registered':
526
-
527
- $post_date = prepare_date_field_value($fieldSettings, strtotime($user->user_registered));
528
-
529
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_user_registered', pmxe_filter($post_date, $fieldSnipped), $user->ID) );
530
-
531
- break;
532
- case 'cf':
533
-
534
- if ( ! empty($fieldValue) )
535
- {
536
- $val = "";
537
-
538
- $cur_meta_values = get_user_meta($user->ID, $fieldValue);
539
-
540
- if ( ! empty($cur_meta_values) and is_array($cur_meta_values) )
541
- {
542
- foreach ($cur_meta_values as $key => $cur_meta_value)
543
- {
544
- if (empty($val))
545
- {
546
- $val = apply_filters('pmxe_custom_field', pmxe_filter(maybe_serialize($cur_meta_value), $fieldSnipped), $fieldValue, $user->ID);
547
- }
548
- else
549
- {
550
- $val = apply_filters('pmxe_custom_field', pmxe_filter($val . $implode_delimiter . maybe_serialize($cur_meta_value), $fieldSnipped), $fieldValue, $user->ID);
551
- }
552
- }
553
- wp_all_export_write_article( $article, $element_name, $val );
554
- }
555
-
556
- if ( empty($cur_meta_values) )
557
- {
558
- if ( empty($article[$element_name]) )
559
- {
560
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_custom_field', pmxe_filter('', $fieldSnipped), $fieldValue, $user->ID) );
561
- }
562
- }
563
- }
564
- break;
565
- case 'acf':
566
-
567
- if ( ! empty($fieldLabel) and class_exists( 'acf' ) )
568
- {
569
- global $acf;
570
-
571
- $field_options = unserialize($fieldOptions);
572
-
573
- if ( ! $is_xml_export )
574
- {
575
- switch ($field_options['type']) {
576
- case 'textarea':
577
- case 'oembed':
578
- case 'wysiwyg':
579
- case 'wp_wysiwyg':
580
- case 'date_time_picker':
581
- case 'date_picker':
582
-
583
- $field_value = get_field($fieldLabel, 'user_' . $user->ID, false);
584
-
585
- break;
586
-
587
- default:
588
-
589
- $field_value = get_field($fieldLabel, 'user_' . $user->ID);
590
-
591
- break;
592
- }
593
- }
594
- else
595
- {
596
- $field_value = get_field($fieldLabel, 'user_' . $user->ID);
597
- }
598
-
599
- XmlExportACF::export_acf_field(
600
- $field_value,
601
- XmlExportEngine::$exportOptions,
602
- $ID,
603
- 'user_' . $user->ID,
604
- $article,
605
- $xmlWriter,
606
- $acfs,
607
- $element_name,
608
- $element_name_ns,
609
- $fieldSnipped,
610
- $field_options['group_id'],
611
- $preview
612
- );
613
-
614
- }
615
-
616
- break;
617
- case 'sql':
618
-
619
- if ( ! empty($fieldSql) )
620
- {
621
- global $wpdb;
622
- $val = $wpdb->get_var( $wpdb->prepare( stripcslashes(str_replace("%%ID%%", "%d", $fieldSql)), $user->ID ));
623
- if ( ! empty($fieldPhp) and !empty($fieldCode) )
624
- {
625
- // if shortcode defined
626
- if (strpos($fieldCode, '[') === 0)
627
- {
628
- $val = do_shortcode(str_replace("%%VALUE%%", $val, $fieldCode));
629
- }
630
- else
631
- {
632
- $val = eval('return ' . stripcslashes(str_replace("%%VALUE%%", $val, $fieldCode)) . ';');
633
- }
634
- }
635
- wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_sql_field', $val, $element_name, $user->ID) );
636
- }
637
- break;
638
- default:
639
- # code...
640
- break;
641
- }
642
-
643
- if ( $is_xml_export and isset($article[$element_name]) )
644
- {
645
- $element_name_in_file = XmlCsvExport::_get_valid_header_name( $element_name );
646
-
647
- $xmlWriter = apply_filters('wp_all_export_add_before_element', $xmlWriter, $element_name_in_file, XmlExportEngine::$exportID, $user->ID);
648
-
649
- $xmlWriter->beginElement($element_name_ns, $element_name_in_file, null);
650
- $xmlWriter->writeData($article[$element_name], $element_name_in_file);
651
- $xmlWriter->closeElement();
652
-
653
- $xmlWriter = apply_filters('wp_all_export_add_after_element', $xmlWriter, $element_name_in_file, XmlExportEngine::$exportID, $user->ID);
654
- }
655
- }
656
- return $article;
657
- }
658
-
659
- public static function prepare_import_template( $exportOptions, &$templateOptions, $element_name, $ID)
660
- {
661
-
662
- $options = $exportOptions;
663
-
664
- $element_type = $options['cc_type'][$ID];
665
-
666
- $is_xml_template = $options['export_to'] == 'xml';
667
-
668
- $implode_delimiter = XmlExportEngine::$implode;
669
-
670
- switch ($element_type)
671
- {
672
- // Export Users
673
- case 'user_login':
674
- $templateOptions['pmui']['login'] = '{'. $element_name .'[1]}';
675
- $templateOptions['is_update_login'] = 1;
676
- break;
677
- case 'user_pass':
678
- $templateOptions['pmui']['pass'] = '{'. $element_name .'[1]}';
679
- $templateOptions['is_update_password'] = 1;
680
- break;
681
- case 'user_nicename':
682
- $templateOptions['pmui']['nicename'] = '{'. $element_name .'[1]}';
683
- $templateOptions['is_update_nicename'] = 1;
684
- break;
685
- case 'user_email':
686
- $templateOptions['pmui']['email'] = '{'. $element_name .'[1]}';
687
- $templateOptions['is_update_email'] = 1;
688
- break;
689
- case 'user_registered':
690
- $templateOptions['pmui']['registered'] = '{'. $element_name .'[1]}';
691
- $templateOptions['is_update_registered'] = 1;
692
- break;
693
- case 'display_name':
694
- $templateOptions['pmui']['display_name'] = '{'. $element_name .'[1]}';
695
- $templateOptions['is_update_display_name'] = 1;
696
- break;
697
- case 'user_url':
698
- $templateOptions['pmui']['url'] = '{'. $element_name .'[1]}';
699
- $templateOptions['is_update_url'] = 1;
700
- break;
701
-
702
- case 'first_name':
703
- $templateOptions['pmui']['first_name'] = '{'. $element_name .'[1]}';
704
- $templateOptions['is_update_first_name'] = 1;
705
- break;
706
- case 'last_name':
707
- $templateOptions['pmui']['last_name'] = '{'. $element_name .'[1]}';
708
- $templateOptions['is_update_last_name'] = 1;
709
- break;
710
- case 'wp_capabilities':
711
- $templateOptions['pmui']['role'] = '{'. $element_name .'[1]}';
712
- $templateOptions['is_update_role'] = 1;
713
- break;
714
- case 'nickname':
715
- $templateOptions['pmui']['nickname'] = '{'. $element_name .'[1]}';
716
- $templateOptions['is_update_nickname'] = 1;
717
- break;
718
- case 'description':
719
- $templateOptions['pmui']['description'] = '{'. $element_name .'[1]}';
720
- $templateOptions['is_update_description'] = 1;
721
- break;
722
- }
723
- }
724
-
725
- /**
726
- * __get function.
727
- *
728
- * @access public
729
- * @param mixed $key
730
- * @return mixed
731
- */
732
- public function __get( $key ) {
733
- return $this->get( $key );
734
- }
735
-
736
- /**
737
- * Get a session variable
738
- *
739
- * @param string $key
740
- * @param mixed $default used if the session variable isn't set
741
- * @return mixed value of session variable
742
- */
743
- public function get( $key, $default = null ) {
744
- return isset( $this->{$key} ) ? $this->{$key} : $default;
745
- }
746
- }
747
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
libraries/XmlExportWooCommerce.php DELETED
@@ -1,1264 +0,0 @@
1
- <?php
2
-
3
- if ( ! class_exists('XmlExportWooCommerce') )
4
- {
5
- final class XmlExportWooCommerce
6
- {
7
- public static $products_data = null;
8
-
9
- private $init_fields = array(
10
- array(
11
- 'name' => 'SKU',
12
- 'type' => 'woo',
13
- 'label' => '_sku'
14
- ),
15
- array(
16
- 'name' => 'product_type',
17
- 'type' => 'cats',
18
- 'label' => 'product_type',
19
- ),
20
- array(
21
- 'label' => 'parent',
22
- 'name' => 'Parent Product ID',
23
- 'type' => 'parent',
24
- )
25
- );
26
-
27
- private $_woo_data = array();
28
- private $_product_data = array();
29
-
30
- /** @var \Wpae\App\Service\WooCommerceVersion */
31
- private $wooCommerceVersion;
32
-
33
- private static $_existing_attributes = array();
34
-
35
- public static $is_active = true;
36
-
37
- public function __construct()
38
- {
39
- $this->_woo_data = array(
40
- '_stock_status', '_downloadable', '_virtual', '_regular_price', '_sale_price', '_purchase_note', '_featured', '_weight', '_length',
41
- '_width', '_height', '_sku', '_sale_price_dates_from', '_sale_price_dates_to', '_price', '_sold_individually', '_manage_stock', '_stock', '_upsell_ids', '_crosssell_ids',
42
- '_downloadable_files', '_download_limit', '_download_expiry', '_download_type', '_product_url', '_button_text', '_backorders', '_tax_status', '_tax_class', '_product_image_gallery', '_default_attributes',
43
- 'total_sales', '_product_attributes', '_product_version', '_variation_description', '_wc_rating_count', '_wc_review_count', '_wc_average_rating'
44
- );
45
-
46
- $this->wooCommerceVersion = new \Wpae\App\Service\WooCommerceVersion();
47
- $this->_product_data = array('_sku', '_price', '_regular_price','_sale_price', '_stock_status', '_stock', '_product_url', 'total_sales', 'attributes');
48
-
49
- // Old way of managing visibility
50
- if(!\Wpae\App\Service\WooCommerceVersion::isWooCommerceNewerThan('3.0')) {
51
- $this->_woo_data[] = '_visibility';
52
- $this->_product_data[] = '_visibility';
53
- }
54
-
55
- if ( ! class_exists('WooCommerce')
56
- or ( XmlExportEngine::$exportOptions['export_type'] == 'specific' and ! in_array('product', XmlExportEngine::$post_types) )
57
- or ( XmlExportEngine::$exportOptions['export_type'] == 'advanced' and strpos(XmlExportEngine::$exportOptions['wp_query'], 'product') === false ) ) {
58
- self::$is_active = false;
59
- return;
60
- }
61
-
62
- self::$is_active = true;
63
-
64
- if ( empty(PMXE_Plugin::$session) ) // if cron execution
65
- {
66
- $id = $_GET['export_id'];
67
- $export = new PMXE_Export_Record();
68
- $export->getById($id);
69
- if ( $export->options['export_to'] == 'csv'){
70
- $this->init_additional_data();
71
- }
72
- }
73
- else
74
- {
75
- self::$products_data = PMXE_Plugin::$session->get('products_data');
76
-
77
- if (empty(self::$products_data))
78
- {
79
- $this->init_additional_data();
80
- }
81
- }
82
-
83
- global $wp_taxonomies;
84
-
85
- $max_input_vars = @ini_get('max_input_vars');
86
- if (empty($max_input_vars)) $max_input_vars = 100;
87
- foreach ($wp_taxonomies as $key => $obj) { if (in_array($obj->name, array('nav_menu'))) continue;
88
-
89
- if (strpos($obj->name, "pa_") === 0 and strlen($obj->name) > 3 ){
90
-
91
- if ( count($this->init_fields) < $max_input_vars / 10 ){
92
- $this->init_fields[] = array(
93
- 'name' => $obj->label,
94
- 'label' => $obj->name,
95
- 'type' => 'attr'
96
- );
97
- }
98
- }
99
- }
100
-
101
- if ( ! empty(self::$products_data['attributes']))
102
- {
103
- foreach (self::$products_data['attributes'] as $attribute) {
104
- if ( count($this->init_fields) < $max_input_vars / 10 ) {
105
- $this->init_fields[] = $this->fix_titles(array(
106
- 'name' => str_replace('attribute_', '', $attribute->meta_key),
107
- 'label' => $attribute->meta_key,
108
- 'type' => 'cf'
109
- ));
110
- }
111
- }
112
- }
113
-
114
- $this->init_fields[] = array(
115
- 'name' => 'Product Attributes',
116
- 'label' => '_product_attributes',
117
- 'type' => 'woo'
118
- );
119
-
120
- add_filter("wp_all_export_init_fields", array( &$this, "filter_init_fields"), 10, 1);
121
- add_filter("wp_all_export_default_fields", array( &$this, "filter_default_fields"), 10, 1);
122
- add_filter("wp_all_export_other_fields", array( &$this, "filter_other_fields"), 10, 1);
123
- add_filter("wp_all_export_available_sections", array( &$this, "filter_available_sections"), 10, 1);
124
- add_filter("wp_all_export_available_data", array( &$this, "filter_available_data"), 10, 1);
125
-
126
- }
127
-
128
- // [FILTERS]
129
-
130
- /**
131
- *
132
- * Filter Init Fields
133
- *
134
- */
135
- public function filter_init_fields($init_fields){
136
- foreach ($this->init_fields as $field) {
137
- $init_fields[] = $field;
138
- }
139
- return array_map(array( &$this, 'fix_titles'), $init_fields);
140
- }
141
-
142
- /**
143
- *
144
- * Filter Default Fields
145
- *
146
- */
147
- public function filter_default_fields($default_fields){
148
- foreach ($default_fields as $key => $field) {
149
- $default_fields[$key]['auto'] = true;
150
- }
151
- $default_fields[] = array(
152
- 'label' => 'parent',
153
- 'name' => 'Parent Product ID',
154
- 'type' => 'parent',
155
- 'auto' => true
156
- );
157
- return array_map(array( &$this, 'fix_titles'), $default_fields);
158
- }
159
-
160
- /**
161
- *
162
- * Filter Other Fields
163
- *
164
- */
165
- public function filter_other_fields($other_fields){
166
-
167
- $advanced_fields = $this->get_fields_for_product_advanced_section();
168
-
169
- foreach ($advanced_fields as $advanced_field)
170
- {
171
- $other_fields[] = $advanced_field;
172
- }
173
-
174
- // add needed fields to auto generate list
175
- foreach ($other_fields as $key => $field)
176
- {
177
- if ( strpos($field['label'], '_min_') === 0 || strpos($field['label'], '_max_') === 0 )
178
- continue;
179
-
180
- if ($field['type'] == 'parent'){
181
- unset($other_fields[$key]);
182
- continue;
183
- }
184
-
185
- if ( $field['type'] != 'attr' ) $other_fields[$key]['auto'] = true;
186
-
187
- $other_fields[$key] = $this->fix_titles($other_fields[$key]);
188
- }
189
-
190
- return $other_fields;
191
- }
192
- /**
193
- *
194
- * Helper method to fix fields title
195
- *
196
- */
197
- protected function fix_titles($field)
198
- {
199
- if (is_array($field))
200
- {
201
- $field['name'] = $this->fix_title($field['name']);
202
- }
203
- else
204
- {
205
- $field = $this->fix_title($field);
206
- }
207
- return $field;
208
- }
209
- /**
210
- *
211
- * Helper method to fix single title
212
- *
213
- */
214
- protected function fix_title($title)
215
- {
216
- $uc_title = ucwords(trim(str_replace("_", " ", $title)));
217
-
218
- if($title == __('Excerpt')) {
219
- return __('Short Description');
220
- }
221
-
222
- return stripos($uc_title, "width") === false ? str_ireplace(array(' id ', ' url ', ' sku ', ' wc '), array('ID', 'URL', 'SKU', 'WC'), $uc_title) : $uc_title;
223
- }
224
-
225
- // helper method
226
- protected function get_fields_for_product_advanced_section()
227
- {
228
- $advanced_fields = array();
229
-
230
- if ( ! empty($this->_woo_data))
231
- {
232
- foreach ($this->_woo_data as $woo_key)
233
- {
234
- if ( strpos($woo_key, 'attribute_pa_') === 0 ) continue;
235
-
236
- if ( ! in_array($woo_key, $this->_product_data) )
237
- {
238
- switch ($woo_key)
239
- {
240
- case '_upsell_ids':
241
- $advanced_fields[] = array(
242
- 'name' => 'Up-Sells',
243
- 'label' => $woo_key,
244
- 'type' => 'woo'
245
- );
246
- break;
247
- case '_crosssell_ids':
248
- $advanced_fields[] = array(
249
- 'name' => 'Cross-Sells',
250
- 'label' => $woo_key,
251
- 'type' => 'woo'
252
- );
253
- break;
254
-
255
- default:
256
- $advanced_fields[] = $this->fix_titles(array(
257
- 'name' => $woo_key,
258
- 'label' => $woo_key,
259
- 'type' => 'woo'
260
- ));
261
- break;
262
- }
263
- }
264
- }
265
- }
266
- return $advanced_fields;
267
- }
268
-
269
- protected function get_fields_for_product_attributes_section()
270
- {
271
- $attributes_fields = array();
272
-
273
- if ( empty(self::$_existing_attributes) )
274
- {
275
- global $wp_taxonomies;
276
-
277
- foreach ($wp_taxonomies as $key => $obj) { if (in_array($obj->name, array('nav_menu'))) continue;
278
-
279
- if (strpos($obj->name, "pa_") === 0 and strlen($obj->name) > 3 and ! in_array($obj->name, self::$_existing_attributes))
280
- self::$_existing_attributes[] = $obj->name;
281
- }
282
- }
283
-
284
- if ( ! empty(self::$_existing_attributes) )
285
- {
286
- foreach (self::$_existing_attributes as $key => $tx_name) {
287
- $tx = get_taxonomy($tx_name);
288
- $attributes_fields[] = array(
289
- 'name' => $tx->label,
290
- 'label' => $tx_name,
291
- 'type' => 'attr'
292
- );
293
- }
294
- }
295
-
296
- if ( ! empty(self::$products_data['attributes']))
297
- {
298
- foreach (self::$products_data['attributes'] as $attribute) {
299
- $attributes_fields[] = $this->fix_titles(array(
300
- 'name' => str_replace('attribute_', '', $attribute->meta_key),
301
- 'label' => $attribute->meta_key,
302
- 'type' => 'cf'
303
- ));
304
- }
305
- }
306
-
307
- return $attributes_fields;
308
- }
309
-
310
- /**
311
- *
312
- * Filter Available Data
313
- *
314
- */
315
- public function filter_available_data($available_data){
316
- $available_data['woo_data'] = $this->_woo_data;
317
- $available_data['existing_attributes'] = self::$_existing_attributes;
318
- $available_data['product_fields'] = $this->get_fields_for_product_data_section();
319
- // $available_data['product_attributes'] = $this->get_fields_for_product_attributes_section();
320
-
321
- if ( ! empty($available_data['existing_taxonomies']) ) {
322
- $existing_taxonomies = $available_data['existing_taxonomies'];
323
- $available_data['existing_taxonomies'] = array();
324
- foreach ($existing_taxonomies as $taxonomy) {
325
- $tx = get_taxonomy($taxonomy['label']);
326
- if ($taxonomy['label'] == 'product_shipping_class')
327
- {
328
- $available_data['product_fields'][] = array(
329
- 'name' => 'Shipping Class',
330
- 'label' => $taxonomy['label'],
331
- 'type' => 'cats',
332
- 'auto' => true
333
- );
334
- }
335
- else
336
- {
337
- $available_data['existing_taxonomies'][] = array(
338
- 'name' => ($taxonomy['label'] == 'product_type') ? 'Product Type' : (empty($tx->label) ? $tx->name : $tx->label),
339
- 'label' => $taxonomy['label'],
340
- 'type' => 'cats',
341
- 'auto' => true
342
- );
343
- }
344
- }
345
- }
346
-
347
- if(\Wpae\App\Service\WooCommerceVersion::isWooCommerceNewerThan('3.0')) {
348
- $available_data['existing_taxonomies'][] = array(
349
- 'name' => 'Product Visibility',
350
- 'label' => 'product_visibility',
351
- 'type' => 'cats',
352
- 'auto' => true
353
- );
354
- }
355
-
356
- return $available_data;
357
- }
358
- // helper method
359
- protected function get_fields_for_product_data_section()
360
- {
361
- $product_fields = array();
362
- if ( ! empty($this->_product_data) )
363
- {
364
- foreach ($this->_product_data as $woo_key)
365
- {
366
- switch ($woo_key)
367
- {
368
- case '_product_url':
369
- $product_fields[] = array(
370
- 'name' => 'External Product URL',
371
- 'label' => $woo_key,
372
- 'type' => 'woo',
373
- 'auto' => true
374
- );
375
- break;
376
-
377
- default:
378
- $product_fields[] = $this->fix_titles(array(
379
- 'name' => $woo_key,
380
- 'label' => $woo_key,
381
- 'type' => 'woo',
382
- 'auto' => true
383
- ));
384
- break;
385
- }
386
- }
387
- }
388
- return $product_fields;
389
- }
390
-
391
- /**
392
- *
393
- * Filter Sections in Available Data
394
- *
395
- */
396
- public function filter_available_sections($available_sections){
397
-
398
- $available_sections['other']['title'] = __("Other", "wp_all_export_plugin");
399
-
400
- $product_data = array(
401
- 'product_data' => array(
402
- 'title' => __("Product Data", "wp_all_export_plugin"),
403
- 'content' => 'product_fields',
404
- 'additional' => array(
405
- 'attributes' => array(
406
- 'title' => __("Attributes", "wp_all_export_plugin"),
407
- 'meta' => $this->get_fields_for_product_attributes_section()
408
- )
409
- )
410
- ),
411
- // 'product_attributes' => array(
412
- // 'title' => __("Attributes", "wp_all_export_plugin"),
413
- // 'content' => 'product_attributes'
414
- // ),
415
- );
416
- return array_merge(array_slice($available_sections, 0, 1), $product_data, array_slice($available_sections, 1));
417
- }
418
-
419
- // [\FILTERS]
420
-
421
- public function init( & $existing_meta_keys = array() ){
422
-
423
- if ( ! self::$is_active ) return;
424
-
425
- $hide_fields = array('_edit_lock', '_edit_last');
426
-
427
- $this->filter_meta_keys( $existing_meta_keys );
428
-
429
- global $wp_taxonomies;
430
-
431
- foreach ($wp_taxonomies as $key => $obj) { if (in_array($obj->name, array('nav_menu'))) continue;
432
-
433
- if (strpos($obj->name, "pa_") === 0 and strlen($obj->name) > 3 and ! in_array($obj->name, self::$_existing_attributes))
434
- self::$_existing_attributes[] = $obj->name;
435
- }
436
-
437
- }
438
- // helper method
439
- protected function filter_meta_keys( & $meta_keys = array() )
440
- {
441
- if ( ! empty($meta_keys) )
442
- {
443
- foreach ($meta_keys as $key => $record_meta_key) {
444
-
445
- if ( in_array($record_meta_key, $this->_woo_data) ) unset($meta_keys[$key]);
446
-
447
- if ( strpos($record_meta_key, 'attribute_pa_') === 0 || strpos($record_meta_key, '_min_') === 0 || strpos($record_meta_key, '_max_') === 0){
448
- if ( ! in_array($record_meta_key, $this->_woo_data)){
449
- $this->_woo_data[] = $record_meta_key;
450
- unset($meta_keys[$key]);
451
- }
452
- }
453
- if ( strpos($record_meta_key, 'attribute_') === 0 && strpos($record_meta_key, 'attribute_pa_') === false )
454
- {
455
- unset($meta_keys[$key]);
456
- }
457
- }
458
- }
459
- }
460
-
461
- public function init_additional_data()
462
- {
463
- if ( ! self::$is_active ) return;
464
-
465
- $cs = PMXE_Plugin::getInstance()->getAdminCurrentScreen();
466
-
467
- if ( empty(self::$products_data) or ! empty($cs) and 'PMXE_Admin_Manage' == $cs->base )
468
- {
469
-
470
- self::$products_data = array();
471
-
472
- global $wpdb;
473
-
474
- $table_prefix = $wpdb->prefix;
475
-
476
- self::$products_data['attributes'] = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT meta_key FROM {$table_prefix}postmeta
477
- WHERE {$table_prefix}postmeta.meta_key LIKE %s AND {$table_prefix}postmeta.meta_key NOT LIKE %s", 'attribute_%', 'attribute_pa_%'));
478
-
479
- if ( ! empty(PMXE_Plugin::$session) )
480
- {
481
- PMXE_Plugin::$session->set('products_data', self::$products_data);
482
- PMXE_Plugin::$session->save_data();
483
- }
484
- }
485
- }
486
-
487
- // [prepare fields for order items]
488
- public function get_all_fields_for_order_items()
489
- {
490
- $meta_keys = wp_all_export_get_existing_meta_by_cpt('product');
491
-
492
- $this->filter_meta_keys( $meta_keys );
493
-
494
- $default_data = $this->get_default_fields_for_order_items();
495
-
496
- $product_data = $this->get_fields_for_product_data_section();
497
-
498
- $taxes_data = array();
499
-
500
- foreach ($product_data as $field)
501
- {
502
- if ( ! in_array($field['label'], array('_sku', 'attributes'))) $default_data[] = $field;
503
- }
504
-
505
- $existing_taxonomies = wp_all_export_get_existing_taxonomies_by_cpt('product');
506
-
507
- foreach ($existing_taxonomies as $taxonomy)
508
- {
509
- $tx = get_taxonomy($taxonomy['label']);
510
- if ($taxonomy['label'] == 'product_shipping_class')
511
- {
512
- $product_data[] = array(
513
- 'name' => 'Shipping Class',
514
- 'label' => $taxonomy['name'],
515
- 'type' => 'cats',
516
- 'auto' => true
517
- );
518
- }
519
- else
520
- {
521
- $taxes_data[] = array(
522
- 'name' => ($taxonomy['label'] == 'product_type') ? 'Product Type' : $tx->label,
523
- 'label' => $taxonomy['label'],
524
- 'type' => 'cats',
525
- 'auto' => true
526
- );
527
- }
528
- }
529
-
530
- return array(
531
- 'product_data' => array(
532
- 'title' => __('Product Data', 'wp_all_export_plugin'),
533
- 'meta' => $default_data,
534
- // 'additional' => array(
535
- // 'attributes' => array(
536
- // 'title' => __("Attributes", "wp_all_export_plugin"),
537
- // 'meta' => $this->get_fields_for_product_attributes_section()
538
- // )
539
- // )
540
- ),
541
- 'taxonomies' => array(
542
- 'title' => __('Taxonomies', 'wp_all_export_plugin'),
543
- 'meta' => $taxes_data
544
- ),
545
- 'cf' => array(
546
- 'title' => __('Custom Fields', 'wp_all_export_plugin'),
547
- 'meta' => $meta_keys
548
- ),
549
- 'attributes' => array(
550
- 'title' => __('Attributes', 'wp_all_export_plugin'),
551
- 'meta' => $this->get_fields_for_product_attributes_section()
552
- ),
553
- 'advanced' => array(
554
- 'title' => __('Advanced', 'wp_all_export_plugin'),
555
- 'meta' => $this->get_fields_for_product_advanced_section()
556
- )
557
- );
558
- }
559
- // helper method
560
- protected function get_default_fields_for_order_items()
561
- {
562
- $exclude_default_fields = array('id', 'title', 'permalink');
563
-
564
- $default_fields = array();
565
- foreach (XmlExportEngine::$default_fields as $field)
566
- {
567
- if ( ! in_array($field['type'], $exclude_default_fields) ) $default_fields[] = $field;
568
- }
569
- return $default_fields;
570
- }
571
- // [\prepare fields for order items]
572
-
573
- protected function prepare_export_data( $record, $options, $elId )
574
- {
575
- $data = array();
576
-
577
- $element_value = str_replace("item_data__", "", $options['cc_value'][$elId]);
578
-
579
- if ( ! empty($element_value) )
580
- {
581
- $implode_delimiter = XmlExportEngine::$implode;
582
-
583
- $element_name = ( ! empty($options['cc_name'][$elId]) ) ? $options['cc_name'][$elId] : 'untitled_' . $elId;
584
- $fieldSnipped = ( ! empty($options['cc_php'][$elId]) and ! empty($options['cc_code'][$elId]) ) ? $options['cc_code'][$elId] : false;
585
-
586
- switch ($element_value)
587
- {
588
- case 'attributes':
589
- $_product_attributes = (empty($record->post_parent)) ? get_post_meta($record->ID, '_product_attributes', true) : get_post_meta($record->post_parent, '_product_attributes', true);
590
-
591
- if ( empty(self::$_existing_attributes) )
592
- {
593
- global $wp_taxonomies;
594
-
595
- foreach ($wp_taxonomies as $key => $obj) { if (in_array($obj->name, array('nav_menu'))) continue;
596
-
597
- if (strpos($obj->name, "pa_") === 0 and strlen($obj->name) > 3 and ! in_array($obj->name, self::$_existing_attributes))
598
- self::$_existing_attributes[] = $obj->name;
599
- }
600
- }
601
-
602
- // combine taxonomies attributes
603
- if ( ! empty(self::$_existing_attributes))
604
- {
605
- foreach (self::$_existing_attributes as $taxonomy_slug) {
606
-
607
- $taxonomy = get_taxonomy($taxonomy_slug);
608
-
609
- $taxonomy_slug_xpath = str_replace("-", "_", $taxonomy_slug);
610
- $data['Attribute Name (' . $taxonomy_slug_xpath . ')'] = $taxonomy->labels->singular_name;
611
- $data['Attribute In Variations (' . $taxonomy_slug_xpath . ')'] = (!empty($_product_attributes[strtolower(urlencode($taxonomy_slug))]['is_variation'])) ? "yes" : "no";
612
- $data['Attribute Is Visible (' . $taxonomy_slug_xpath . ')'] = (!empty($_product_attributes[strtolower(urlencode($taxonomy_slug))]['is_visible'])) ? "yes" : "no";
613
- $data['Attribute Is Taxonomy (' . $taxonomy_slug_xpath . ')'] = (!empty($_product_attributes[strtolower(urlencode($taxonomy_slug))]['is_taxonomy'])) ? "yes" : "no";
614
-
615
- $element_name = 'Attribute Value (' . $taxonomy_slug_xpath . ')';
616
-
617
- if ($record->post_parent == 0)
618
- {
619
- if (isset($_product_attributes[strtolower(urlencode($taxonomy_slug))]['value'])) {
620
- $txes_list = get_the_terms($record->ID, $taxonomy_slug);
621
- if (!is_wp_error($txes_list) and !empty($txes_list)) {
622
- $attr_new = array();
623
- foreach ($txes_list as $t) {
624
- $attr_new[] = $t->name;
625
- }
626
- $data[$element_name] = apply_filters('pmxe_woo_attribute', pmxe_filter(implode($implode_delimiter, $attr_new), $fieldSnipped), $record->ID, $taxonomy_slug);
627
- }
628
- else {
629
- $data[$element_name] = pmxe_filter('', $fieldSnipped);
630
- }
631
- }
632
- else
633
- {
634
- $data[$element_name] = pmxe_filter('', $fieldSnipped);
635
- }
636
- }
637
- else
638
- {
639
- $variation_attribute = get_post_meta($record->ID, 'attribute_' . strtolower(urlencode($taxonomy_slug)), true);
640
- $term = get_term_by('slug', $variation_attribute, $taxonomy_slug);
641
- if ($term and !is_wp_error($term)){
642
- $variation_attribute = $term->name;
643
- }
644
- $data[$element_name] = apply_filters('pmxe_woo_attribute', pmxe_filter($variation_attribute, $fieldSnipped), $record->ID, $taxonomy_slug);
645
- }
646
- }
647
- }
648
-
649
- // combine custom attributes
650
- if ( ! empty(self::$products_data['attributes']))
651
- {
652
- foreach (self::$products_data['attributes'] as $attribute)
653
- {
654
- $attribute_standart_name = str_replace('attribute_', '', $attribute->meta_key);
655
- $attribute_name = ucfirst($attribute_standart_name);
656
-
657
- $data['Attribute Name (' . $attribute_name . ')'] = $attribute_name;
658
- $data['Attribute Value (' . $attribute_name . ')'] = get_post_meta($record->ID, $attribute->meta_key, true);
659
-
660
- $data['Attribute In Variations (' . $attribute_name . ')'] = (!empty($_product_attributes[$attribute_standart_name]['is_variation'])) ? "yes" : "no";
661
- $data['Attribute Is Visible (' . $attribute_name . ')'] = (!empty($_product_attributes[$attribute_standart_name]['is_visible'])) ? "yes" : "no";
662
- $data['Attribute Is Taxonomy (' . $attribute_name . ')'] = (!empty($_product_attributes[$attribute_standart_name]['is_taxonomy'])) ? "yes" : "no";
663
- }
664
- }
665
-
666
- break;
667
-
668
- default:
669
-
670
- $cur_meta_values = get_post_meta($record->ID, $element_value);
671
-
672
- if ( ! empty($cur_meta_values) and is_array($cur_meta_values) )
673
- {
674
- foreach ($cur_meta_values as $key => $cur_meta_value)
675
- {
676
- $fieldOptions = $options['cc_options'][$elId];
677
- $fieldSettings = empty($options['cc_settings'][$elId]) ? $fieldOptions : $options['cc_settings'][$elId];
678
-
679
- switch ($element_value)
680
- {
681
- case '_downloadable_files':
682
-
683
- $files = maybe_unserialize($cur_meta_value);
684
- $file_paths = array();
685
- $file_names = array();
686
-
687
- if ( ! empty($files) ){
688
-
689
- foreach ($files as $key => $file) {
690
- $file_paths[] = $file['file'];
691
- $file_names[] = $file['name'];
692
- }
693
-
694
- }
695
- $data[$element_name . ' Paths'] = pmxe_filter(implode($implode_delimiter, $file_paths), $fieldSnipped);
696
- $data[$element_name . ' Names'] = pmxe_filter(implode($implode_delimiter, $file_names), $fieldSnipped);
697
-
698
- break;
699
- case '_crosssell_ids':
700
- case '_upsell_ids':
701
-
702
- $sell_export_type = empty($options['cc_settings'][$elId]) ? 'sku' : $options['cc_settings'][$elId];
703
-
704
- $_ids = maybe_unserialize($cur_meta_value);
705
- $_values = array();
706
- if (!empty($_ids)){
707
-
708
- switch ($sell_export_type) {
709
- case 'sku':
710
- foreach ($_ids as $_id) {
711
- $_values[] = get_post_meta($_id, '_sku', true);
712
- }
713
- break;
714
- case 'id':
715
- $_values = $_ids;
716
- break;
717
- case 'name':
718
- foreach ($_ids as $_id) {
719
- $p = get_post($_id);
720
- if ($p)
721
- {
722
- $_values[] = $p->post_name;
723
- }
724
- }
725
- break;
726
- default:
727
- # code...
728
- break;
729
- }
730
- }
731
- $data[$element_name] = apply_filters('pmxe_woo_field', pmxe_filter(implode($implode_delimiter, $_values), $fieldSnipped), $element_value, $record->ID);
732
- break;
733
-
734
- case '_sale_price_dates_from':
735
- case '_sale_price_dates_to':
736
-
737
- $post_date = $cur_meta_value ? prepare_date_field_value($fieldSettings, $cur_meta_value) : "";
738
-
739
- $data[$element_name] = apply_filters('pmxe_woo_field', pmxe_filter($post_date, $fieldSnipped), $element_value, $record->ID);
740
-
741
- // wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_post_date', pmxe_filter($post_date, $fieldSnipped), $record->ID) );
742
- break;
743
-
744
- case '_tax_class':
745
-
746
- if ( $cur_meta_value == '' ){
747
- $tax_status = get_post_meta($record->ID, '_tax_status', true);
748
- if ( 'taxable' == $tax_status ){
749
- $cur_meta_value = 'standard';
750
- }
751
- }
752
- $data[$element_name] = apply_filters('pmxe_woo_field', pmxe_filter($cur_meta_value, $fieldSnipped), $element_value, $record->ID);
753
- break;
754
-
755
- default:
756
-
757
- if ( empty($data[$element_name]) )
758
- {
759
- $data[$element_name] = apply_filters('pmxe_woo_field', pmxe_filter(maybe_serialize($cur_meta_value), $fieldSnipped), $element_value, $record->ID);
760
- }
761
- else
762
- {
763
- $data[$element_name . '_' . $key] = apply_filters('pmxe_woo_field', pmxe_filter(maybe_serialize($cur_meta_value), $fieldSnipped), $element_value, $record->ID);
764
- }
765
-
766
- break;
767
- }
768
- }
769
- }
770
-
771
- if($this->wooCommerceVersion->isWooCommerceNewerThan('3.0')) {
772
- if($element_value == '_featured') {
773
- if($record->post_type == 'product_variation') {
774
- $product = new WC_Product($record->post_parent);
775
- }
776
- else {
777
- $product = new WC_Product($record->ID);
778
- }
779
-
780
- if($product) {
781
- $value = $product->is_featured() ? 'yes' : 'no';
782
- $data[$element_name] = apply_filters('pmxe_woo_field',pmxe_filter($value, $fieldSnipped), $element_value, $record->ID);
783
- }
784
- }
785
- }
786
-
787
- if ( empty($cur_meta_values) && $element_value != '_featured' )
788
- {
789
- $data[$element_name] = apply_filters('pmxe_woo_field', pmxe_filter('', $fieldSnipped), $element_value, $record->ID);
790
- }
791
-
792
- break;
793
- }
794
-
795
- }
796
-
797
-
798
- return $data;
799
- }
800
-
801
- public function export_csv( & $article, & $titles, $record, $options, $element_key )
802
- {
803
- $data_to_export = $this->prepare_export_data( $record, $options, $element_key );
804
-
805
- $rawPrices = false;
806
- $rawPrices = apply_filters('wp_all_export_raw_prices', $rawPrices);
807
-
808
- foreach ($data_to_export as $key => $data) {
809
- if ($key == 'Price' || $key == 'Regular Price' || $key == 'Sale Price') {
810
- //$data = $rawPrices ? $data :pmxe_prepare_price($data, true, true, true);
811
- }
812
- wp_all_export_write_article($article, $key, $data);
813
- }
814
- }
815
-
816
- public function get_element_header( & $headers, $options, $element_key )
817
- {
818
- $element_value = str_replace("item_data__", "", $options['cc_value'][$element_key]);
819
-
820
- switch ($element_value)
821
- {
822
- case 'attributes':
823
-
824
- // headers for taxonomy attributes
825
- if ( ! empty(self::$_existing_attributes))
826
- {
827
- foreach (self::$_existing_attributes as $taxonomy_slug) {
828
-
829
- $taxonomy = get_taxonomy($taxonomy_slug);
830
- $taxonomy_slug_xpath = str_replace("-", "_", $taxonomy_slug);
831
- $headers[] = 'Attribute Name (' . $taxonomy_slug_xpath . ')';
832
- $headers[] = 'Attribute Value (' . $taxonomy_slug_xpath . ')';
833
- $headers[] = 'Attribute In Variations (' . $taxonomy_slug_xpath . ')';
834
- $headers[] = 'Attribute Is Visible (' . $taxonomy_slug_xpath . ')';
835
- $headers[] = 'Attribute Is Taxonomy (' . $taxonomy_slug_xpath . ')';
836
- }
837
- }
838
-
839
- // headers for custom attributes
840
- if ( ! empty(self::$products_data['attributes']))
841
- {
842
- foreach (self::$products_data['attributes'] as $attribute)
843
- {
844
- $attribute_name = ucfirst(str_replace('attribute_', '', $attribute->meta_key));
845
-
846
- $headers[] = 'Attribute Name (' . $attribute_name . ')';
847
- $headers[] = 'Attribute Value (' . $attribute_name . ')';
848
- $headers[] = 'Attribute In Variations (' . $attribute_name . ')';
849
- $headers[] = 'Attribute Is Visible (' . $attribute_name . ')';
850
- $headers[] = 'Attribute Is Taxonomy (' . $attribute_name . ')';
851
- }
852
- }
853
-
854
- break;
855
-
856
- case '_downloadable_files':
857
-
858
- $headers[] = $options['cc_name'][$element_key] . ' Paths';
859
- $headers[] = $options['cc_name'][$element_key] . ' Names';
860
-
861
- break;
862
-
863
- default:
864
-
865
- if ( ! in_array($options['cc_name'][$element_key], $headers))
866
- {
867
- $headers[] = $options['cc_name'][$element_key];
868
- }
869
- else
870
- {
871
- $is_added = false;
872
- $i = 0;
873
- do
874
- {
875
- $new_element_name = $options['cc_name'][$element_key] . '_' . md5($i);
876
-
877
- if ( ! in_array($new_element_name, $headers) )
878
- {
879
- $headers[] = $new_element_name;
880
- $is_added = true;
881
- }
882
-
883
- $i++;
884
- }
885
- while ( ! $is_added );
886
- }
887
-
888
- break;
889
- }
890
- }
891
-
892
- public function export_xml( & $xmlWriter, $record, $options, $elId ){
893
-
894
- if ( ! self::$is_active ) return;
895
-
896
- $data_to_export = $this->prepare_export_data( $record, $options, $elId );
897
-
898
- foreach ($data_to_export as $key => $data)
899
- {
900
- $element_name_ns = '';
901
- $element_name = str_replace("-", "_", preg_replace('/[^a-z0-9:_]/i', '', $key));
902
- if (strpos($element_name, ":") !== false)
903
- {
904
- $element_name_parts = explode(":", $element_name);
905
- $element_name_ns = (empty($element_name_parts[0])) ? '' : $element_name_parts[0];
906
- $element_name = (empty($element_name_parts[1])) ? 'untitled_' . $elId : $element_name_parts[1];
907
- }
908
-
909
- $rawPrices = false;
910
- $rawPrices = apply_filters('wp_all_export_raw_prices', $rawPrices);
911
-
912
- if ($key == 'Price' || $key == 'Regular Price' || $key == 'Sale Price') {
913
- //$data = $rawPrices? $data :pmxe_prepare_price($data, false, true, true);
914
- }
915
-
916
- $xmlWriter = apply_filters('wp_all_export_add_before_element', $xmlWriter, $element_name, XmlExportEngine::$exportID, $record->ID);
917
-
918
- $xmlWriter->beginElement($element_name_ns, $element_name, null);
919
- $xmlWriter->writeData($data, $element_name);
920
- $xmlWriter->closeElement();
921
-
922
- $xmlWriter = apply_filters('wp_all_export_add_after_element', $xmlWriter, $element_name, XmlExportEngine::$exportID, $record->ID);
923
- }
924
-
925
- }
926
-
927
- public static function prepare_import_template( $exportOptions, &$templateOptions, &$cf_list, &$attr_list, $element_name, $element_key )
928
- {
929
- if ( ! in_array($element_key, $cf_list)) $cf_list[] = $element_key;
930
-
931
- $is_xml_template = $exportOptions['export_to'] == 'xml';
932
-
933
- $implode_delimiter = XmlExportEngine::$implode;
934
-
935
- switch ($element_key)
936
- {
937
- case '_visibility':
938
- $templateOptions['is_product_visibility'] = 'xpath';
939
- $templateOptions['single_product_visibility'] = '{'. $element_name .'[1]}';
940
- break;
941
- case '_stock_status':
942
- $templateOptions['product_stock_status'] = 'xpath';
943
- $templateOptions['single_product_stock_status'] = '{'. $element_name .'[1]}';
944
- break;
945
- case '_downloadable':
946
- $templateOptions['is_product_downloadable'] = 'xpath';
947
- $templateOptions['single_product_downloadable'] = '{'. $element_name .'[1]}';
948
- break;
949
- case '_virtual':
950
- $templateOptions['is_product_virtual'] = 'xpath';
951
- $templateOptions['single_product_virtual'] = '{'. $element_name .'[1]}';
952
- break;
953
- case '_price':
954
- $templateOptions['single_product_regular_price'] = '{'. $element_name .'[1]}';
955
- break;
956
- case '_regular_price':
957
- $templateOptions['single_product_regular_price'] = '{'. $element_name .'[1]}';
958
- if ( ! in_array('_price', $cf_list)) $cf_list[] = '_price';
959
- break;
960
- case '_sale_price':
961
- $templateOptions['single_product_sale_price'] = '{'. $element_name .'[1]}';
962
- if ( ! in_array('_price', $cf_list)) $cf_list[] = '_price';
963
- break;
964
- case '_purchase_note':
965
- $templateOptions['single_product_purchase_note'] = '{'. $element_name .'[1]}';
966
- break;
967
- case '_featured':
968
- $templateOptions['is_product_featured'] = 'xpath';
969
- $templateOptions['single_product_featured'] = '{'. $element_name .'[1]}';
970
- break;
971
- case '_weight':
972
- $templateOptions['single_product_weight'] = '{'. $element_name .'[1]}';
973
- break;
974
- case '_length':
975
- $templateOptions['single_product_length'] = '{'. $element_name .'[1]}';
976
- break;
977
- case '_width':
978
- $templateOptions['single_product_width'] = '{'. $element_name .'[1]}';
979
- break;
980
- case '_height':
981
- $templateOptions['single_product_height'] = '{'. $element_name .'[1]}';
982
- break;
983
- case '_sku':
984
- $templateOptions['single_product_sku'] = '{'. $element_name .'[1]}';
985
- //$templateOptions['single_product_parent_id'] = '{parent_id[1]}';
986
- break;
987
- case '_sale_price_dates_from':
988
- $templateOptions['single_sale_price_dates_from'] = '{'. $element_name .'[1]}';
989
- break;
990
- case '_sale_price_dates_to':
991
- $templateOptions['single_sale_price_dates_to'] = '{'. $element_name .'[1]}';
992
- break;
993
- case '_sold_individually':
994
- $templateOptions['product_sold_individually'] = 'xpath';
995
- $templateOptions['single_product_sold_individually'] = '{'. $element_name .'[1]}';
996
- break;
997
- case '_manage_stock':
998
- $templateOptions['is_product_manage_stock'] = 'xpath';
999
- $templateOptions['single_product_manage_stock'] = '{'. $element_name .'[1]}';
1000
- break;
1001
- case '_stock':
1002
- $templateOptions['single_product_stock_qty'] = '{'. $element_name .'[1]}';
1003
- break;
1004
- case '_upsell_ids':
1005
-
1006
- if ($implode_delimiter == "|")
1007
- $templateOptions['single_product_up_sells'] = '[str_replace("|", ",",{' . $element_name . '[1]})]';
1008
- else
1009
- $templateOptions['single_product_up_sells'] = '{' . $element_name . '[1]}';
1010
-
1011
- break;
1012
- case '_crosssell_ids':
1013
-
1014
- if ($implode_delimiter == "|")
1015
- $templateOptions['single_product_cross_sells'] = '[str_replace("|", ",",{' . $element_name . '[1]})]';
1016
- else
1017
- $templateOptions['single_product_cross_sells'] = '{' . $element_name . '[1]}';
1018
-
1019
- break;
1020
- case '_downloadable_files':
1021
- if ($is_xml_template)
1022
- {
1023
- $templateOptions['single_product_files'] = '{'. $element_name .'Paths[1]}';
1024
- $templateOptions['single_product_files_names'] = '{'. $element_name .'Names[1]}';
1025
- }
1026
- else
1027
- {
1028
- $templateOptions['single_product_files'] = '{'. $element_name .'paths[1]}';
1029
- $templateOptions['single_product_files_names'] = '{'. $element_name .'names[1]}';
1030
- }
1031
- break;
1032
- case '_download_limit':
1033
- $templateOptions['single_product_download_limit'] = '{'. $element_name .'[1]}';
1034
- break;
1035
- case '_download_expiry':
1036
- $templateOptions['single_product_download_expiry'] = '{'. $element_name .'[1]}';
1037
- break;
1038
- case '_download_type':
1039
- $templateOptions['single_product_download_type'] = '{'. $element_name .'[1]}';
1040
- break;
1041
- case '_product_url':
1042
- $templateOptions['single_product_url'] = '{'. $element_name .'[1]}';
1043
- break;
1044
- case '_button_text':
1045
- $templateOptions['single_product_button_text'] = '{'. $element_name .'[1]}';
1046
- break;
1047
- case '_tax_status':
1048
- $templateOptions['is_multiple_product_tax_status'] = 'no';
1049
- $templateOptions['single_product_tax_status'] = '{'. $element_name .'[1]}';
1050
- break;
1051
- case '_tax_class':
1052
- $templateOptions['is_multiple_product_tax_class'] = 'no';
1053
- $templateOptions['single_product_tax_class'] = '{'. $element_name .'[1]}';
1054
- break;
1055
- case '_backorders':
1056
- $templateOptions['product_allow_backorders'] = 'xpath';
1057
- $templateOptions['single_product_allow_backorders'] = '{'. $element_name .'[1]}';
1058
- break;
1059
- case '_variation_description':
1060
- $templateOptions['single_product_variation_description'] = '{'. $element_name .'[1]}';
1061
- break;
1062
- case '_product_attributes':
1063
- case '_default_attributes':
1064
- $templateOptions['custom_name'][] = $element_key;
1065
- $templateOptions['custom_value'][] = '{'. $element_name .'[1]}';
1066
- $templateOptions['custom_format'][] = 0;
1067
- break;
1068
- case 'product_visibility':
1069
- $templateOptions['is_product_visibility'] = 'xpath';
1070
- $templateOptions['single_product_visibility'] = '{'. $element_name .'[1]}';
1071
- break;
1072
- case 'attributes':
1073
-
1074
- global $wp_taxonomies;
1075
-
1076
- foreach ($wp_taxonomies as $key => $obj) { if (in_array($obj->name, array('nav_menu'))) continue;
1077
-
1078
- if (strpos($obj->name, "pa_") === 0 and strlen($obj->name) > 3)
1079
- {
1080
- $attribute_name = preg_replace('/[^a-z0-9_]/i', '', str_replace("-", "_", $obj->name));
1081
-
1082
- if ($is_xml_template)
1083
- {
1084
- $attributeOptions = array(
1085
- 'attribute_name' => 'AttributeName',
1086
- 'attribute_value' => 'AttributeValue',
1087
- 'advanced_in_variations_xpath' => 'AttributeInVariations',
1088
- 'advanced_is_visible_xpath' => 'AttributeIsVisible',
1089
- 'advanced_is_taxonomy_xpath' => 'AttributeIsTaxonomy'
1090
- );
1091
-
1092
- foreach ($attributeOptions as $templateKey => $xpathKey){
1093
-
1094
- if ( ! in_array('{'. $xpathKey . $attribute_name .'[1]}', $templateOptions[$templateKey]) ){
1095
- $templateOptions[$templateKey][] = '{'. $xpathKey . $attribute_name .'[1]}';
1096
- }
1097
- else{
1098
- $is_added = false;
1099
- $i = 2;
1100
- do {
1101
- $new_element_name = '{'. $xpathKey . $attribute_name .'['. $i .']}';
1102
-
1103
- if ( ! in_array($new_element_name, $templateOptions[$templateKey]) ) {
1104
- $templateOptions[$templateKey][] = $new_element_name;
1105
- $is_added = true;
1106
- }
1107
- $i++;
1108
- }
1109
- while ( ! $is_added );
1110
- }
1111
- }
1112
- }
1113
- else
1114
- {
1115
- $attributeOptions = array(
1116
- 'attribute_name' => 'attributename',
1117
- 'attribute_value' => 'attributevalue',
1118
- 'advanced_in_variations_xpath' => 'attributeinvariations',
1119
- 'advanced_is_visible_xpath' => 'attributeisvisible',
1120
- 'advanced_is_taxonomy_xpath' => 'attributeistaxonomy'
1121
- );
1122
-
1123
- foreach ($attributeOptions as $templateKey => $xpathKey){
1124
-
1125
- if ( ! isset($templateOptions[$templateKey]) || ! in_array('{'. $xpathKey . $attribute_name .'[1]}', $templateOptions[$templateKey]) ){
1126
- $templateOptions[$templateKey][] = '{'. $xpathKey . $attribute_name .'[1]}';
1127
- }
1128
- else{
1129
- $is_added = false;
1130
- $i = 2;
1131
- do {
1132
- $new_element_name = '{'. $xpathKey . $attribute_name .'_'. $i .'[1]}';
1133
-
1134
- if ( (isset($templateOptions[$templateKey]) && is_array($templateOptions[$templateKey]) && !in_array($new_element_name, $templateOptions[$templateKey])) || !isset($templateOptions[$templateKey]) ) {
1135
- $templateOptions[$templateKey][] = $new_element_name;
1136
- $is_added = true;
1137
- }
1138
- $i++;
1139
- }
1140
- while ( ! $is_added );
1141
- }
1142
- }
1143
- }
1144
-
1145
- $templateOptions['in_variations'][] = "1";
1146
- $templateOptions['is_visible'][] = "1";
1147
- $templateOptions['is_taxonomy'][] = "1";
1148
- $templateOptions['create_taxonomy_in_not_exists'][] = "1";
1149
-
1150
- $templateOptions['is_advanced'][] = "1";
1151
- $templateOptions['advanced_is_create_terms'][] = "yes";
1152
- $templateOptions['advanced_in_variations'][] = "xpath";
1153
- $templateOptions['advanced_is_visible'][] = "xpath";
1154
- $templateOptions['advanced_is_taxonomy'][] = "xpath";
1155
-
1156
- $attr_list[] = $obj->name;
1157
- }
1158
- }
1159
-
1160
- global $wpdb;
1161
-
1162
- $table_prefix = $wpdb->prefix;
1163
-
1164
- $attributes = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT meta_key FROM {$table_prefix}postmeta
1165
- WHERE {$table_prefix}postmeta.meta_key LIKE %s AND {$table_prefix}postmeta.meta_key NOT LIKE %s", 'attribute_%', 'attribute_pa_%'));
1166
-
1167
- if ( ! empty($attributes))
1168
- {
1169
- foreach ($attributes as $attribute)
1170
- {
1171
- if ($is_xml_template)
1172
- {
1173
- if (strpos($attribute->meta_key, "%") === false){
1174
- $attribute_name = ucfirst(str_replace('attribute_', '', $attribute->meta_key));
1175
- }
1176
- else{
1177
- $attribute_name = str_replace('attribute_', '', preg_replace('/[^a-z0-9_]/i', '', $attribute->meta_key));
1178
- }
1179
-
1180
- $templateOptions['attribute_name'][] = '{AttributeName' . $attribute_name .'[1]}';
1181
- $templateOptions['attribute_value'][] = '{AttributeValue' . $attribute_name .'[1]}';
1182
- $templateOptions['advanced_in_variations_xpath'][] = '{AttributeInVariations' . $attribute_name .'[1]}';
1183
- $templateOptions['advanced_is_visible_xpath'][] = '{AttributeIsVisible' . $attribute_name .'[1]}';
1184
- $templateOptions['advanced_is_taxonomy_xpath'][] = '{AttributeIsTaxonomy' . $attribute_name .'[1]}';
1185
- }
1186
- else
1187
- {
1188
- $attributeOptions = array(
1189
- 'attribute_name' => 'attributename',
1190
- 'attribute_value' => 'attributevalue',
1191
- 'advanced_in_variations_xpath' => 'attributeinvariations',
1192
- 'advanced_is_visible_xpath' => 'attributeisvisible',
1193
- 'advanced_is_taxonomy_xpath' => 'attributeistaxonomy'
1194
- );
1195
-
1196
- $attribute_name = preg_replace('/[^a-z0-9_]/i', '', str_replace('attribute_', '', XmlExportEngine::sanitizeFieldName($attribute->meta_key)));
1197
-
1198
- foreach ($attributeOptions as $templateKey => $xpathKey){
1199
-
1200
- if ( ! in_array('{'. $xpathKey . $attribute_name .'[1]}', $templateOptions[$templateKey]) ){
1201
- $templateOptions[$templateKey][] = '{'. $xpathKey . $attribute_name .'[1]}';
1202
- }
1203
- else{
1204
- $is_added = false;
1205
- $i = 2;
1206
- do {
1207
- $new_element_name = '{'. $xpathKey . $attribute_name .'_'. $i .'[1]}';
1208
-
1209
- if ( ! in_array($new_element_name, $templateOptions[$templateKey]) ) {
1210
- $templateOptions[$templateKey][] = $new_element_name;
1211
- $is_added = true;
1212
- }
1213
- $i++;
1214
- }
1215
- while ( ! $is_added );
1216
- }
1217
- }
1218
- }
1219
-
1220
- $templateOptions['in_variations'][] = "1";
1221
- $templateOptions['is_visible'][] = "1";
1222
- $templateOptions['is_taxonomy'][] = "1";
1223
- $templateOptions['create_taxonomy_in_not_exists'][] = "1";
1224
-
1225
- $templateOptions['is_advanced'][] = "1";
1226
- $templateOptions['advanced_is_create_terms'][] = "yes";
1227
- $templateOptions['advanced_in_variations'][] = "xpath";
1228
- $templateOptions['advanced_is_visible'][] = "xpath";
1229
- $templateOptions['advanced_is_taxonomy'][] = "xpath";
1230
-
1231
- $attr_list[] = str_replace('attribute_', '', $attribute->meta_key);
1232
- }
1233
- }
1234
-
1235
- break;
1236
- default:
1237
- # code...
1238
- break;
1239
- }
1240
- }
1241
-
1242
- /**
1243
- * __get function.
1244
- *
1245
- * @access public
1246
- * @param mixed $key
1247
- * @return mixed
1248
- */
1249
- public function __get( $key ) {
1250
- return $this->get( $key );
1251
- }
1252
-
1253
- /**
1254
- * Get a session variable
1255
- *
1256
- * @param string $key
1257
- * @param mixed $default used if the session variable isn't set
1258
- * @return mixed value of session variable
1259
- */
1260
- public function get( $key, $default = null ) {
1261
- return isset( $this->{$key} ) ? $this->{$key} : $default;
1262
- }
1263
- }
1264
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
libraries/XmlExportWooCommerceCoupon.php DELETED
@@ -1,223 +0,0 @@
1
- <?php
2
-
3
- if ( ! class_exists('XmlExportWooCommerceCoupon') )
4
- {
5
- final class XmlExportWooCommerceCoupon
6
- {
7
- public static $is_active = true;
8
-
9
- public $init_fields = array(
10
- array(
11
- 'name' => 'Coupon ID',
12
- 'type' => 'id',
13
- 'options' => '',
14
- 'label' => 'id'
15
- ),
16
- array(
17
- 'name' => 'Coupon Code',
18
- 'type' => 'title',
19
- 'options' => '',
20
- 'label' => 'title'
21
- ),
22
- array(
23
- 'name' => 'Expiry Date',
24
- 'type' => 'cf',
25
- 'options' => '',
26
- 'label' => 'expiry_date'
27
- )
28
- );
29
-
30
- public $default_fields = array(
31
- array(
32
- 'name' => 'Coupon ID',
33
- 'type' => 'id',
34
- 'label' => 'id'
35
- ),
36
- array(
37
- 'name' => 'Coupon Code',
38
- 'type' => 'title',
39
- 'label' => 'title'
40
- ),
41
- array(
42
- 'name' => 'Coupon Description',
43
- 'type' => 'excerpt',
44
- 'label' => 'excerpt'
45
- ),
46
- array(
47
- 'name' => 'Discount Type',
48
- 'type' => 'cf',
49
- 'label' => 'discount_type'
50
- ),
51
- array(
52
- 'name' => 'Coupon Amount',
53
- 'type' => 'cf',
54
- 'label' => 'coupon_amount'
55
- ),
56
- array(
57
- 'name' => 'Expiry Date',
58
- 'type' => 'cf',
59
- 'label' => 'expiry_date'
60
- ),
61
- array(
62
- 'name' => 'Free Shipping',
63
- 'type' => 'cf',
64
- 'label' => 'free_shipping'
65
- ),
66
- array(
67
- 'name' => 'Exclude Sale Items',
68
- 'type' => 'cf',
69
- 'label' => 'exclude_sale_items'
70
- )
71
- );
72
-
73
- public $other_fields = array(
74
- array(
75
- 'label' => 'status',
76
- 'name' => 'Status',
77
- 'type' => 'status'
78
- ),
79
- array(
80
- 'label' => 'author',
81
- 'name' => 'Author ID',
82
- 'type' => 'author'
83
- ),
84
-
85
- array(
86
- 'label' => 'author_username',
87
- 'name' => 'Author Username',
88
- 'type' => 'author'
89
- ),
90
-
91
- array(
92
- 'label' => 'author_email',
93
- 'name' => 'Author Email',
94
- 'type' => 'author'
95
- ),
96
-
97
- array(
98
- 'label' => 'author_first_name',
99
- 'name' => 'Author First Name',
100
- 'type' => 'author'
101
- ),
102
-
103
- array(
104
- 'label' => 'author_last_name',
105
- 'name' => 'Author Last Name',
106
- 'type' => 'author'
107
- ),
108
-
109
- array(
110
- 'label' => 'slug',
111
- 'name' => 'Slug',
112
- 'type' => 'slug'
113
- ),
114
- array(
115
- 'label' => 'date',
116
- 'name' => 'Date',
117
- 'type' => 'date'
118
- ),
119
- array(
120
- 'label' => 'post_type',
121
- 'name' => 'Post Type',
122
- 'type' => 'post_type'
123
- )
124
- );
125
-
126
-
127
- private $_coupon_data = array();
128
-
129
- public function __construct()
130
- {
131
- if ( ! class_exists('WooCommerce')
132
- or ( XmlExportEngine::$exportOptions['export_type'] == 'specific' and ! in_array('shop_coupon', XmlExportEngine::$post_types) )
133
- or ( XmlExportEngine::$exportOptions['export_type'] == 'advanced' and strpos(XmlExportEngine::$exportOptions['wp_query'], 'shop_coupon') === false ) ) {
134
- self::$is_active = false;
135
- return;
136
- }
137
-
138
- self::$is_active = true;
139
-
140
- $this->_coupon_data = array(
141
- 'discount_type', 'coupon_amount', 'expiry_date', 'free_shipping', 'exclude_sale_items'
142
- );
143
-
144
- add_filter("wp_all_export_default_fields", array( &$this, "filter_default_fields"), 10, 1);
145
- add_filter("wp_all_export_other_fields", array( &$this, "filter_other_fields"), 10, 1);
146
- add_filter("wp_all_export_available_data", array( &$this, "filter_available_data"), 10, 1);
147
- add_filter("wp_all_export_available_sections", array( &$this, "filter_available_sections" ), 10, 1);
148
- add_filter("wp_all_export_init_fields", array( &$this, "filter_init_fields"), 10, 1);
149
-
150
- }
151
-
152
- // [FILTERS]
153
-
154
- /**
155
- *
156
- * Filter Init Fields
157
- *
158
- */
159
- public function filter_init_fields($init_fields){
160
- return $this->init_fields;
161
- }
162
-
163
- /**
164
- *
165
- * Filter Default Fields
166
- *
167
- */
168
- public function filter_default_fields($default_fields){
169
- return $this->default_fields;
170
- }
171
-
172
- /**
173
- *
174
- * Filter Other Fields
175
- *
176
- */
177
- public function filter_other_fields($other_fields){
178
- return $this->other_fields;
179
- }
180
-
181
- /**
182
- *
183
- * Filter Available Data
184
- *
185
- */
186
- public function filter_available_data($available_data){
187
-
188
- $available_data['existing_meta_keys'] = array_merge($available_data['other_fields'], $available_data['existing_meta_keys']);
189
-
190
- return $available_data;
191
- }
192
-
193
- /**
194
- *
195
- * Filter Sections in Available Data
196
- *
197
- */
198
- public function filter_available_sections($sections){
199
- unset($sections['media']);
200
- unset($sections['other']);
201
- $sections['cf']['title'] = __("Other", "wp_all_export_plugin");
202
- return $sections;
203
- }
204
-
205
- // [\FILTERS]
206
-
207
- public function init( & $existing_meta_keys = array() ){
208
-
209
- if ( ! self::$is_active ) return;
210
-
211
- if ( ! empty($existing_meta_keys) )
212
- {
213
- foreach ($existing_meta_keys as $key => $record_meta_key)
214
- {
215
- if ( in_array($record_meta_key, $this->_coupon_data) )
216
- {
217
- unset($existing_meta_keys[$key]);
218
- }
219
- }
220
- }
221
- }
222
- }
223
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
libraries/XmlExportWooCommerceOrder.php DELETED
@@ -1,1705 +0,0 @@
1
- <?php
2
-
3
- if ( ! class_exists('XmlExportWooCommerceOrder') )
4
- {
5
- final class XmlExportWooCommerceOrder
6
- {
7
- public static $is_active = true;
8
-
9
- public static $order_sections = array();
10
- public static $order_items_per_line = false;
11
- public static $orders_data = null;
12
- public static $exportQuery = null;
13
-
14
- private $init_fields = array(
15
- array(
16
- 'name' => 'Order ID',
17
- 'type' => 'woo_order',
18
- 'options' => 'order',
19
- 'label' => 'ID'
20
- ),
21
- array(
22
- 'name' => 'Order Key',
23
- 'type' => 'woo_order',
24
- 'options' => 'order',
25
- 'label' => '_order_key'
26
- ),
27
- array(
28
- 'name' => 'Title',
29
- 'type' => 'woo_order',
30
- 'options' => 'order',
31
- 'label' => 'post_title'
32
- )
33
- );
34
-
35
- private $order_core_fields = array();
36
-
37
- public function __construct()
38
- {
39
- $this->order_core_fields = array('_prices_include_tax', '_customer_ip_address', '_customer_user_agent', '_created_via', '_order_version', '_payment_method', '_cart_discount_tax', '_order_shipping_tax', '_recorded_sales', '_order_stock_reduced', '_recorded_coupon_usage_counts', '_transaction_id');
40
-
41
- if ( ! class_exists('WooCommerce')
42
- or ( XmlExportEngine::$exportOptions['export_type'] == 'specific' and ! in_array('shop_order', XmlExportEngine::$post_types) )
43
- or ( XmlExportEngine::$exportOptions['export_type'] == 'advanced' and strpos(XmlExportEngine::$exportOptions['wp_query'], 'shop_order') === false ) ) {
44
- self::$is_active = false;
45
- return;
46
- }
47
-
48
- self::$is_active = true;
49
-
50
- if ( empty(PMXE_Plugin::$session) ) // if cron execution
51
- {
52
- $id = $_GET['export_id'];
53
- $export = new PMXE_Export_Record();
54
- $export->getById($id);
55
- if ( ! $export->isEmpty() and $export->options['export_to'] == 'csv'){
56
- $this->init_additional_data();
57
- }
58
- }
59
- else
60
- {
61
- $this->init_additional_data();
62
- }
63
-
64
- add_filter("wp_all_export_available_sections", array( &$this, "filter_available_sections" ), 10, 1);
65
- add_filter("wp_all_export_csv_rows", array( &$this, "filter_csv_rows"), 10, 2);
66
- add_filter("wp_all_export_init_fields", array( &$this, "filter_init_fields"), 10, 1);
67
-
68
- self::$order_sections = $this->available_sections();
69
-
70
- }
71
-
72
- // [FILTERS]
73
-
74
- /**
75
- *
76
- * Filter Init Fields
77
- *
78
- */
79
- public function filter_init_fields($init_fields){
80
- return $this->init_fields;
81
- }
82
-
83
- /**
84
- *
85
- * Filter Sections in Available Data
86
- *
87
- */
88
- public function filter_available_sections($sections){
89
- return array();
90
- }
91
-
92
- // [\FILTERS]
93
-
94
- public function init( & $existing_meta_keys = array() ){
95
-
96
- if ( ! self::$is_active ) return;
97
-
98
- if ( ! empty($existing_meta_keys) )
99
- {
100
- foreach (self::$order_sections as $slug => $section) :
101
-
102
- foreach ($section['meta'] as $cur_meta_key => $cur_meta_label)
103
- {
104
- foreach ($existing_meta_keys as $key => $record_meta_key)
105
- {
106
- if ( $record_meta_key == $cur_meta_key )
107
- {
108
- unset($existing_meta_keys[$key]);
109
- break;
110
- }
111
- }
112
- }
113
-
114
- endforeach;
115
-
116
- foreach ( $this->order_core_fields as $core_field ):
117
-
118
- foreach ($existing_meta_keys as $key => $record_meta_key)
119
- {
120
- if ( $record_meta_key == $core_field )
121
- {
122
- unset($existing_meta_keys[$key]);
123
- break;
124
- }
125
- }
126
-
127
- endforeach;
128
-
129
- foreach ($existing_meta_keys as $key => $record_meta_key)
130
- {
131
- self::$order_sections['cf']['meta'][$record_meta_key] = array(
132
- 'name' => $record_meta_key,
133
- 'label' => $record_meta_key,
134
- 'options' => '',
135
- 'type' => 'cf'
136
- );
137
- }
138
- }
139
-
140
- global $wpdb;
141
- $table_prefix = $wpdb->prefix;
142
-
143
- $product_data = $this->available_order_default_product_data();
144
-
145
- $meta_keys = $wpdb->get_results("SELECT DISTINCT {$table_prefix}woocommerce_order_itemmeta.meta_key FROM {$table_prefix}woocommerce_order_itemmeta");
146
- if ( ! empty($meta_keys)){
147
- foreach ($meta_keys as $meta_key) {
148
- if (strpos($meta_key->meta_key, "pa_") !== 0 and empty(self::$order_sections['cf']['meta'][$meta_key->meta_key]) and empty($product_data[$meta_key->meta_key]))
149
- self::$order_sections['other']['meta'][$meta_key->meta_key] = $this->fix_titles(array(
150
- 'name' => $meta_key->meta_key,
151
- 'label' => $meta_key->meta_key,
152
- 'options' => 'items',
153
- 'type' => 'woo_order'
154
- ));
155
- }
156
- }
157
-
158
- foreach ( $this->order_core_fields as $core_field ):
159
-
160
- self::$order_sections['other']['meta'][$core_field] = $this->fix_titles(array(
161
- 'name' => $core_field,
162
- 'label' => $core_field,
163
- 'options' => '',
164
- 'type' => 'cf'
165
- ));
166
-
167
- endforeach;
168
- }
169
-
170
- /**
171
- *
172
- * Helper method to fix fields title
173
- *
174
- */
175
- protected function fix_titles($field)
176
- {
177
- if (is_array($field))
178
- {
179
- $field['name'] = $this->fix_title($field['name']);
180
- }
181
- else
182
- {
183
- $field = $this->fix_title($field);
184
- }
185
- return $field;
186
- }
187
- /**
188
- *
189
- * Helper method to fix single title
190
- *
191
- */
192
- protected function fix_title($title)
193
- {
194
- $uc_title = ucwords(trim(str_replace("_", " ", $title)));
195
-
196
- return stripos($uc_title, "width") === false ? str_ireplace(array('id', 'url', 'sku'), array('ID', 'URL', 'SKU'), $uc_title) : $uc_title;
197
- }
198
-
199
- public function init_additional_data(){
200
-
201
- if ( ! self::$is_active || empty(XmlExportEngine::$exportQuery)) return;
202
-
203
- global $wpdb;
204
-
205
- $table_prefix = $wpdb->prefix;
206
-
207
- $in_orders = preg_replace("%(SQL_CALC_FOUND_ROWS|LIMIT.*)%", "", XmlExportEngine::$exportQuery->request);
208
- $in_orders = str_replace("{$table_prefix}posts.*", "{$table_prefix}posts.ID", $in_orders);
209
-
210
- if ( ! empty($in_orders) ){
211
-
212
- if ( empty(self::$orders_data['line_items_max_count']) ){
213
- self::$orders_data['line_items_max_count'] = $wpdb->get_var($wpdb->prepare("SELECT max(cnt) as line_items_count FROM (
214
- SELECT order_id, COUNT(*) as cnt FROM {$table_prefix}woocommerce_order_items
215
- WHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (". $in_orders .") GROUP BY order_id) AS T3", 'line_item'));
216
- }
217
-
218
- if ( empty(self::$orders_data['taxes'])){
219
- self::$orders_data['taxes'] = $wpdb->get_results($wpdb->prepare("SELECT order_item_id, order_id, order_item_name FROM {$table_prefix}woocommerce_order_items
220
- WHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (". $in_orders .") GROUP BY order_item_name", 'tax'));
221
- }
222
-
223
- if ( empty(self::$orders_data['coupons'])){
224
- self::$orders_data['coupons'] = $wpdb->get_results($wpdb->prepare("SELECT order_item_id, order_id, order_item_name FROM {$table_prefix}woocommerce_order_items
225
- WHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (". $in_orders .") GROUP BY order_item_name", 'coupon'));
226
- }
227
-
228
- if ( empty(self::$orders_data['fees'])){
229
- self::$orders_data['fees'] = $wpdb->get_results($wpdb->prepare("SELECT order_item_id, order_id, order_item_name FROM {$table_prefix}woocommerce_order_items
230
- WHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (". $in_orders .") GROUP BY order_item_name", 'fee'));
231
- }
232
-
233
- if ( empty(self::$orders_data['variations'])){
234
- self::$orders_data['variations'] = $wpdb->get_results($wpdb->prepare("SELECT meta_key FROM {$table_prefix}woocommerce_order_itemmeta
235
- WHERE {$table_prefix}woocommerce_order_itemmeta.meta_key LIKE %s AND {$table_prefix}woocommerce_order_itemmeta.order_item_id IN (
236
- SELECT {$table_prefix}woocommerce_order_items.order_item_id FROM {$table_prefix}woocommerce_order_items
237
- WHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (". $in_orders .") ) GROUP BY meta_key", 'pa_%', 'line_item'));
238
- }
239
-
240
- if ( ! empty(PMXE_Plugin::$session) )
241
- {
242
- PMXE_Plugin::$session->set('orders_data', self::$orders_data);
243
- PMXE_Plugin::$session->save_data();
244
- }
245
- }
246
- }
247
-
248
- private $order_items = null;
249
- private $order_taxes = null;
250
- private $order_shipping = null;
251
- private $order_coupons = null;
252
- private $order_surcharge = null;
253
- private $order_refunds = null;
254
- private $__total_fee_amount = null;
255
- private $__coupons_used = null;
256
- private $order_id = null;
257
-
258
- // csv headers
259
- private $woo = array();
260
- private $woo_order = array();
261
- private $acfs = array();
262
- private $taxes = array();
263
- private $attributes = array();
264
- private $articles = array();
265
- private $exclude_from_filling = array();
266
-
267
- protected function prepare_export_data( $record, $options, $elId, $preview ){
268
-
269
- // an array with data to export
270
- $data = array(
271
- 'items' => array(),
272
- 'taxes' => array(),
273
- 'shipping' => array(),
274
- 'coupons' => array(),
275
- 'surcharge' => array()
276
- );
277
-
278
- global $wpdb;
279
- $table_prefix = $wpdb->prefix;
280
-
281
- $implode_delimiter = XmlExportEngine::$implode;
282
-
283
- if ( empty($this->order_id) or $this->order_id != $record->ID)
284
- {
285
- $this->__coupons_used = array();
286
-
287
- $this->order_id = $record->ID;
288
-
289
- $all_order_items = $wpdb->get_results("SELECT * FROM {$table_prefix}woocommerce_order_items WHERE order_id = {$record->ID}");
290
-
291
- if ( ! empty($all_order_items) )
292
- {
293
- foreach ($all_order_items as $item)
294
- {
295
- switch ($item->order_item_type)
296
- {
297
- case 'line_item':
298
- $this->order_items[] = $item;
299
- break;
300
- case 'tax':
301
- $this->order_taxes[] = $item;
302
- break;
303
- case 'shipping':
304
- $this->order_shipping[] = $item;
305
- break;
306
- case 'coupon':
307
- $this->order_coupons[] = $item;
308
- break;
309
- case 'fee':
310
- $this->order_surcharge[] = $item;
311
- break;
312
- }
313
- }
314
- }
315
-
316
- $this->order_refunds = $wpdb->get_results("SELECT * FROM {$table_prefix}posts WHERE post_parent = {$record->ID} AND post_type = 'shop_order_refund'");
317
- }
318
-
319
- if ( ! empty($options['cc_value'][$elId]) ){
320
-
321
- $is_items_in_list = false;
322
- $is_item_data_in_list = false;
323
- foreach ($options['ids'] as $ID => $value)
324
- {
325
- if ($options['cc_options'][$ID] == 'items')
326
- {
327
- $is_items_in_list = true;
328
- }
329
- if ( strpos($options['cc_label'][$ID], "item_data__") !== false )
330
- {
331
- $is_item_data_in_list = true;
332
- }
333
- }
334
-
335
- $fieldSnipped = ( ! empty($options['cc_php'][$elId]) and ! empty($options['cc_code'][$elId]) ) ? $options['cc_code'][$elId] : false;
336
-
337
- if ( ! $is_items_in_list and $is_item_data_in_list )
338
- {
339
- if ( ! empty($this->order_items)){
340
-
341
- foreach ($this->order_items as $n => $order_item) {
342
-
343
- $meta_data = $wpdb->get_results("SELECT * FROM {$table_prefix}woocommerce_order_itemmeta WHERE order_item_id = {$order_item->order_item_id}", ARRAY_A);
344
-
345
- $item_data = array();
346
-
347
- foreach ($options['ids'] as $subID => $subvalue)
348
- {
349
- if ( strpos($options['cc_label'][$subID], 'item_data__') !== false )
350
- {
351
- $product_id = '';
352
- $variation_id = '';
353
- foreach ($meta_data as $meta) {
354
- if ($meta['meta_key'] == '_variation_id' and ! empty($meta['meta_value'])){
355
- $variation_id = $meta['meta_value'];
356
- }
357
- if ($meta['meta_key'] == '_product_id' and ! empty($meta['meta_value'])){
358
- $product_id = $meta['meta_value'];
359
- }
360
- }
361
-
362
- $_product_id = empty($variation_id) ? $product_id : $variation_id;
363
-
364
- $_product = get_post($_product_id);
365
-
366
- // do not export anything if product doesn't exist
367
- if ( ! empty($_product) )
368
- {
369
- $item_add_data = XmlExportCpt::prepare_data( $_product, XmlExportEngine::$exportOptions, false, $this->acfs, $this->woo, $this->woo_order, ",", $preview, true, $subID );
370
-
371
- if ( ! empty($item_add_data))
372
- {
373
- foreach ($item_add_data as $item_add_data_key => $item_add_data_value) {
374
- if ( ! isset($item_data[$item_add_data_key])) $item_data[$item_add_data_key] = $item_add_data_value;
375
- }
376
- }
377
- }
378
- }
379
- }
380
-
381
- if ( ! empty($item_data)) $data['items'][] = $item_data;
382
-
383
- }
384
-
385
- $this->order_items = null;
386
- }
387
- }
388
-
389
- switch ($options['cc_options'][$elId]) {
390
-
391
- case 'order':
392
- case 'customer':
393
-
394
- $data[$options['cc_name'][$elId]] = ( strpos($options['cc_value'][$elId], "_") === 0 ) ? get_post_meta($record->ID, $options['cc_value'][$elId], true) : $record->{$options['cc_value'][$elId]};
395
-
396
- switch ($options['cc_value'][$elId]){
397
- case 'post_title':
398
- $data[$options['cc_name'][$elId]] = str_replace("&ndash;", '-', $data[$options['cc_name'][$elId]]);
399
- break;
400
- case 'post_date':
401
- $data[$options['cc_name'][$elId]] = prepare_date_field_value($options['cc_settings'][$elId], get_post_time('U', true, $record->ID), "Ymd");
402
- break;
403
- case '_completed_date':
404
- $_completed_date = get_post_meta($record->ID, '_completed_date', true);
405
- $_completed_date_unix = empty($_completed_date) ? '' : strtotime($_completed_date);
406
- $data[$options['cc_name'][$elId]] = empty($_completed_date_unix) ? '' : prepare_date_field_value($options['cc_settings'][$elId], $_completed_date_unix, "Ymd");
407
- break;
408
- case '_customer_user_email':
409
- $customer_user_id = get_post_meta($record->ID, '_customer_user', true);
410
- if ( $customer_user_id ){
411
- $user = get_user_by( 'id', $customer_user_id );
412
- if ($user){
413
- $data[$options['cc_name'][$elId]] = $user->user_email;
414
- }
415
- }
416
- if (empty($data[$options['cc_name'][$elId]])) $data[$options['cc_name'][$elId]] = get_post_meta($record->ID, '_billing_email', true);
417
- break;
418
- }
419
-
420
- $data[$options['cc_name'][$elId]] = pmxe_filter( $data[$options['cc_name'][$elId]], $fieldSnipped);
421
-
422
- break;
423
- }
424
-
425
- }
426
-
427
- return $data;
428
- }
429
-
430
- private $additional_articles = array();
431
-
432
- public function export_csv( & $article, & $titles, $record, $options, $elId, $preview ){
433
-
434
- if ( ! self::$is_active ) return;
435
-
436
- $data_to_export = $this->prepare_export_data( $record, $options, $elId, $preview );
437
-
438
- $implode_delimiter = XmlExportEngine::$implode;
439
-
440
- foreach ($data_to_export as $key => $data) {
441
-
442
- if ( in_array($key, array('items', 'taxes', 'shipping', 'coupons', 'surcharge', 'refunds')) )
443
- {
444
- if ( ! empty($data))
445
- {
446
- if ( $key == 'items' and ( $options['order_item_per_row'] or $options['xml_template_type'] == 'custom'))
447
- {
448
- foreach ($data as $item) {
449
- $additional_article = array();
450
- if ( ! empty($item) ){
451
- foreach ($item as $item_key => $item_value) {
452
- $final_key = preg_replace("%\s#\d*%", "", $item_key);
453
- $additional_article[$final_key] = $item_value;
454
- if ( ! empty($this->exclude_from_filling[$item_key])){
455
- unset($this->exclude_from_filling[$item_key]);
456
- $this->exclude_from_filling[$final_key] = 1;
457
- }
458
- }
459
- }
460
-
461
- if ( ! empty($additional_article) )
462
- {
463
- if ( empty($this->additional_articles) )
464
- {
465
- foreach ($additional_article as $item_key => $item_value) {
466
- $article[$item_key] = $item_value;
467
- }
468
- }
469
- $this->additional_articles[] = $additional_article;
470
- }
471
- }
472
- }
473
- else
474
- {
475
- foreach ($data as $n => $item)
476
- {
477
- if ( ! empty($item))
478
- {
479
- foreach ($item as $item_key => $item_value)
480
- {
481
- $final_key = (strpos($item_key, "#") === false and ! in_array($key, array('taxes', 'shipping', 'coupons', 'surcharge', 'refunds'))) ? $item_key . " #" . ($n + 1) : $item_key;
482
-
483
- if ( ! isset($article[$final_key]))
484
- {
485
- $article[$final_key] = $item_value;
486
- }
487
- else
488
- {
489
- $article[$final_key] .= $implode_delimiter . $item_value;
490
- }
491
- // if ( ! in_array($final_key, $titles) ) $titles[] = $final_key;
492
- }
493
- }
494
- }
495
- }
496
- }
497
- }
498
- else
499
- {
500
- // $article[$key] = $data;
501
- wp_all_export_write_article( $article, $key, $data );
502
- // if ( ! in_array($key, $titles) ) $titles[] = $key;
503
- }
504
- }
505
- }
506
-
507
- public function filter_csv_rows($articles, $options){
508
-
509
- if ( ! empty($this->additional_articles) and ( $options['order_item_per_row'] or $options['xml_template_type'] == 'custom') )
510
- {
511
- $base_article = $articles[count($articles) - 1];
512
- array_shift($this->additional_articles);
513
- if ( ! empty($this->additional_articles ) ){
514
- foreach ($this->additional_articles as $article) {
515
- if ($options['order_item_fill_empty_columns'] and $options['export_to'] == 'csv')
516
- {
517
- if (!empty($this->exclude_from_filling)){
518
- foreach ($this->exclude_from_filling as $key => $value) {
519
- $article[$key] = isset($article[$key]) ? $article[$key] : '';
520
- }
521
- }
522
- foreach ($article as $key => $value) {
523
- unset($base_article[$key]);
524
- }
525
- $articles[] = @array_merge($base_article, $article);
526
- }
527
- else
528
- {
529
- $articles[] = $article;
530
- }
531
- }
532
- $this->additional_articles = array();
533
- }
534
- }
535
-
536
- return $articles;
537
- }
538
-
539
- public function get_element_header( & $headers, $options, $element_key ){
540
-
541
- switch ($options['cc_value'][$element_key])
542
- {
543
- // Rate Code (per tax)
544
- case 'tax_order_item_name':
545
- // Rate Percentage (per tax)
546
- case 'tax_rate':
547
- // Amount (per tax)
548
- case 'tax_amount':
549
-
550
- if ( ! empty(self::$orders_data['taxes']))
551
- {
552
- foreach ( self::$orders_data['taxes'] as $tax) {
553
- // $friendly_name = str_replace("per tax", $this->get_rate_friendly_name($tax->order_item_id), $options['cc_name'][$element_key]);
554
- $friendly_name = str_replace(" (per tax)", "", $options['cc_name'][$element_key]);
555
- if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
556
- }
557
- }
558
- else{
559
- $friendly_name = str_replace(" (per tax)", "", $options['cc_name'][$element_key]);
560
- if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
561
- }
562
-
563
- break;
564
- // Discount Amount (per coupon)
565
- case 'discount_amount':
566
-
567
- if ( ! empty(self::$orders_data['coupons']))
568
- {
569
- foreach ( self::$orders_data['coupons'] as $coupon) {
570
- // $friendly_name = str_replace("per coupon", $coupon->order_item_name, $options['cc_name'][$element_key]);
571
- $friendly_name = str_replace("(per coupon)", "", $options['cc_name'][$element_key]);
572
- if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
573
- if ( ! in_array("Coupon Code", $headers)) $headers[] = "Coupon Code";
574
- }
575
- }
576
- else{
577
- $friendly_name = str_replace("(per coupon)", "", $options['cc_name'][$element_key]);
578
- if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
579
- if ( ! in_array("Coupon Code", $headers)) $headers[] = "Coupon Code";
580
- }
581
-
582
- break;
583
- // Fee Amount (per surcharge)
584
- case 'fee_line_total':
585
-
586
- if ( ! empty(self::$orders_data['fees']))
587
- {
588
- foreach ( self::$orders_data['fees'] as $fee) {
589
- // $friendly_name = str_replace("Amount (per surcharge)", "(" . $fee->order_item_name . ")", $options['cc_name'][$element_key]);
590
- $friendly_name = str_replace(" (per surcharge)", "", $options['cc_name'][$element_key]);
591
- if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
592
- if ( ! in_array("Fee Name", $headers)) $headers[] = "Fee Name";
593
- }
594
- }
595
- else{
596
- $friendly_name = str_replace(" (per surcharge)", "", $options['cc_name'][$element_key]);
597
- if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
598
- if ( ! in_array("Fee Name", $headers)) $headers[] = "Fee Name";
599
- }
600
-
601
- break;
602
-
603
- // Product Variation Details
604
- case '__product_variation':
605
-
606
- if ( ! empty(self::$orders_data['line_items_max_count']) and ! empty(self::$orders_data['variations']))
607
- {
608
- if ( $options['order_item_per_row'] or $options['xml_template_type'] == 'custom'){
609
- foreach ( self::$orders_data['variations'] as $variation) {
610
- $friendly_name = $options['cc_name'][$element_key] . " (" . sanitize_title(str_replace("pa_", "", $variation->meta_key)) . ")";
611
- if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
612
- }
613
- }
614
- else{
615
- for ($i = 1; $i <= self::$orders_data['line_items_max_count']; $i++){
616
- foreach ( self::$orders_data['variations'] as $variation) {
617
- $friendly_name = $options['cc_name'][$element_key] . " #" . $i . " (" . sanitize_title(str_replace("pa_", "", $variation->meta_key)) . ")";
618
- if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
619
- }
620
- }
621
- }
622
- }
623
-
624
- break;
625
-
626
- default:
627
-
628
- switch ($options['cc_options'][$element_key])
629
- {
630
- // Order's product basic data headers
631
- case 'items':
632
-
633
- if ( $options['order_item_per_row'] or $options['xml_template_type'] == 'custom')
634
- {
635
- if ( ! in_array($options['cc_name'][$element_key], $headers)) $headers[] = $options['cc_name'][$element_key];
636
- }
637
- else
638
- {
639
- if ( ! empty(self::$orders_data['line_items_max_count'])){
640
- for ($i = 1; $i <= self::$orders_data['line_items_max_count']; $i++){
641
- $friendly_name = $options['cc_name'][$element_key] . " #" . $i;
642
- if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
643
- }
644
- }
645
- }
646
-
647
- break;
648
-
649
- default:
650
-
651
- // Order's product advanced data headers
652
- if ( strpos($options['cc_label'][$element_key], 'item_data__') !== false)
653
- {
654
- $element_label = str_replace("item_data__", "", $options['cc_label'][$element_key]);
655
-
656
- $element_headers = array();
657
-
658
- $element_name = ( ! empty($options['cc_name'][$element_key]) ) ? $options['cc_name'][$element_key] : 'untitled_' . $element_key;
659
-
660
- switch ($options['cc_type'][$element_key])
661
- {
662
- case 'woo':
663
-
664
- XmlExportEngine::$woo_export->get_element_header( $element_headers, $options, $element_key );
665
-
666
- break;
667
-
668
- case 'acf':
669
-
670
- if ( ! empty($this->acfs) ){
671
- $single_acf_field = array_shift($this->acfs);
672
- if ( is_array($single_acf_field))
673
- {
674
- foreach ($single_acf_field as $acf_header) {
675
- if ( ! in_array($acf_header, $element_headers)) $element_headers[] = $acf_header;
676
- }
677
- }
678
- else
679
- {
680
- if ( ! in_array($single_acf_field, $element_headers)) $element_headers[] = $single_acf_field;
681
- }
682
- }
683
-
684
- break;
685
-
686
- default:
687
-
688
- if ( ! in_array($element_name, $element_headers))
689
- {
690
- $element_headers[] = $element_name;
691
- }
692
- else
693
- {
694
- $is_added = false;
695
- $i = 0;
696
- do
697
- {
698
- $new_element_name = $element_name . '_' . md5($i);
699
-
700
- if ( ! in_array($new_element_name, $element_headers) )
701
- {
702
- $element_headers[] = $new_element_name;
703
- $is_added = true;
704
- }
705
-
706
- $i++;
707
- }
708
- while ( ! $is_added );
709
- }
710
-
711
- // $element_headers[] = $element_name;
712
-
713
- break;
714
- }
715
-
716
- if ( ! empty($element_headers) )
717
- {
718
- foreach ($element_headers as $header)
719
- {
720
- if ( $options['order_item_per_row'] or $options['xml_template_type'] == 'custom')
721
- {
722
- if ( ! in_array($header, $headers)) $headers[] = $header;
723
- }
724
- else
725
- {
726
- if ( ! empty(self::$orders_data['line_items_max_count'])){
727
- for ($i = 1; $i <= self::$orders_data['line_items_max_count']; $i++){
728
- $friendly_name = $header . " #" . $i;
729
- if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
730
- }
731
- }
732
- }
733
- }
734
- }
735
- }
736
- else
737
- {
738
- if ( ! in_array($options['cc_name'][$element_key], $headers))
739
- {
740
- $headers[] = $options['cc_name'][$element_key];
741
- }
742
- else
743
- {
744
- $is_added = false;
745
- $i = 0;
746
- do
747
- {
748
- $new_element_name = $options['cc_name'][$element_key] . '_' . md5($i);
749
-
750
- if ( ! in_array($new_element_name, $headers) )
751
- {
752
- $headers[] = $new_element_name;
753
- $is_added = true;
754
- }
755
-
756
- $i++;
757
- }
758
- while ( ! $is_added );
759
- }
760
- }
761
-
762
- break;
763
- }
764
-
765
- break;
766
-
767
- }
768
-
769
- }
770
-
771
- public function get_rate_friendly_name( $order_item_id ){
772
-
773
- global $wpdb;
774
- $table_prefix = $wpdb->prefix;
775
-
776
- $rate_details = null;
777
- $meta_data = $wpdb->get_results("SELECT * FROM {$table_prefix}woocommerce_order_itemmeta WHERE order_item_id = {$order_item_id}", ARRAY_A);
778
- foreach ($meta_data as $meta) {
779
- if ($meta['meta_key'] == 'rate_id'){
780
- $rate_id = $meta['meta_value'];
781
- $rate_details = $wpdb->get_row("SELECT * FROM {$table_prefix}woocommerce_tax_rates WHERE tax_rate_id = {$rate_id}");
782
- break;
783
- }
784
- }
785
-
786
- return $rate_details ? $rate_details->tax_rate_name : '';
787
-
788
- }
789
-
790
- public function export_xml( & $xmlWriter, $record, $options, $elId, $preview ){
791
-
792
- if ( ! self::$is_active ) return;
793
-
794
- $data_to_export = $this->prepare_export_data( $record, $options, $elId, $preview );
795
-
796
- foreach ($data_to_export as $key => $data) {
797
-
798
- if ( in_array($key, array('items', 'taxes', 'shipping', 'coupons', 'surcharge', 'refunds')) )
799
- {
800
- if ( ! empty($data)){
801
- $xmlWriter->startElement('Order' . ucfirst($key));
802
- foreach ($data as $item) {
803
- if ( ! empty($item)){
804
- $xmlWriter->startElement(preg_replace("%(s|es)$%", "", ucfirst($key)));
805
- foreach ($item as $item_key => $item_value) {
806
- $element_name_ns = '';
807
- $element_name = str_replace("-", "_", preg_replace('/[^a-z0-9:_]/i', '', preg_replace("%#\d*%", "", $item_key)));
808
- if (strpos($element_name, ":") !== false)
809
- {
810
- $element_name_parts = explode(":", $element_name);
811
- $element_name_ns = (empty($element_name_parts[0])) ? '' : $element_name_parts[0];
812
- $element_name = (empty($element_name_parts[1])) ? 'untitled_' . $ID : $element_name_parts[1];
813
- }
814
- $xmlWriter->beginElement($element_name_ns, $element_name, null);
815
- $xmlWriter->writeData($item_value, $element_name);
816
- $xmlWriter->closeElement();
817
- // $xmlWriter->writeElement(str_replace("-", "_", sanitize_title(preg_replace("%#\d%", "", $item_key))), $item_value);
818
- }
819
- $xmlWriter->closeElement();
820
- }
821
- }
822
- $xmlWriter->closeElement();
823
- }
824
- }
825
- else
826
- {
827
- $element_name_ns = '';
828
- $element_name = str_replace("-", "_", preg_replace('/[^a-z0-9:_]/i', '', $key));
829
- if (strpos($element_name, ":") !== false)
830
- {
831
- $element_name_parts = explode(":", $element_name);
832
- $element_name_ns = (empty($element_name_parts[0])) ? '' : $element_name_parts[0];
833
- $element_name = (empty($element_name_parts[1])) ? 'untitled_' . $ID : $element_name_parts[1];
834
- }
835
-
836
- $xmlWriter = apply_filters('wp_all_export_add_before_element', $xmlWriter, $element_name, XmlExportEngine::$exportID, $record->ID);
837
-
838
- $xmlWriter->beginElement($element_name_ns, $element_name, null);
839
- $xmlWriter->writeData($data, $element_name);
840
- $xmlWriter->closeElement();
841
-
842
- $xmlWriter = apply_filters('wp_all_export_add_after_element', $xmlWriter, $element_name, XmlExportEngine::$exportID, $record->ID);
843
- }
844
- }
845
- }
846
-
847
- public static function prepare_child_exports( $export, $is_cron = false )
848
- {
849
- $queue_exports = array();
850
-
851
- $exportList = new PMXE_Export_List();
852
-
853
- global $wpdb;
854
-
855
- $table_prefix = $wpdb->prefix;
856
- $pmxe_prefix = PMXE_Plugin::getInstance()->getTablePrefix();
857
-
858
- $in_orders = $wpdb->prepare("SELECT DISTINCT post_id FROM {$pmxe_prefix}posts WHERE export_id = %d AND iteration = %d", $export->id, $export->iteration - 1);
859
-
860
- foreach ($exportList->getBy('parent_id', $export->id)->convertRecords() as $child_export)
861
- {
862
-
863
- $whereClause = "";
864
-
865
- switch ($child_export->export_post_type)
866
- {
867
- case 'product':
868
-
869
- if ( $export->options['order_include_poducts'])
870
- {
871
- $queue_exports[] = $child_export->id;
872
-
873
- if ( ! $export->options['order_include_all_poducts'] )
874
- {
875
-
876
- $in_products = $wpdb->prepare("SELECT order_item_meta.meta_value as product_id FROM {$table_prefix}posts as posts INNER JOIN {$pmxe_prefix}posts AS order_export ON posts.ID = post_id INNER JOIN {$table_prefix}woocommerce_order_items AS order_items ON posts.ID = order_id INNER JOIN {$table_prefix}woocommerce_order_itemmeta AS order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id WHERE order_export.export_id = %d AND order_export.iteration = %d AND order_items.order_item_type = 'line_item' AND order_item_meta.meta_key = '_product_id' GROUP BY product_id", $export->id, $export->iteration - 1);
877
-
878
- $whereClause = " AND ({$table_prefix}posts.ID IN (". $in_products .") OR {$table_prefix}posts.post_parent IN (". $in_products ."))";
879
-
880
- }
881
- }
882
-
883
- break;
884
-
885
- case 'shop_coupon':
886
-
887
- if ( $export->options['order_include_coupons'])
888
- {
889
- $queue_exports[] = $child_export->id;
890
-
891
- if ( ! $export->options['order_include_all_coupons'] )
892
- {
893
- $whereClause = " AND {$table_prefix}posts.post_title IN (". $wpdb->prepare("SELECT order_item_name FROM {$table_prefix}woocommerce_order_items
894
- WHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (". $in_orders .") GROUP BY order_item_name", 'coupon') .")";
895
- }
896
- }
897
-
898
- break;
899
-
900
- case 'shop_customer':
901
-
902
- if ( $export->options['order_include_customers'])
903
- {
904
- $queue_exports[] = $child_export->id;
905
-
906
- if ( ! $export->options['order_include_all_customers'] )
907
- {
908
- $whereClause = " AND {$table_prefix}users.ID IN (" . $wpdb->prepare("SELECT meta_value FROM {$table_prefix}postmeta WHERE meta_key = %s AND post_id IN (". $in_orders .") GROUP BY meta_value", "_customer_user") . ")";
909
- }
910
- }
911
-
912
- break;
913
-
914
- default:
915
- # code...
916
- break;
917
- }
918
- $child_export_options = $child_export->options;
919
- $child_export_options['whereclause'] = $whereClause;
920
- $child_export->set(array(
921
- 'triggered' => $is_cron ? 1 : 0,
922
- 'processing' => 0,
923
- 'exported' => 0,
924
- 'executing' => $is_cron ? 0 : 1,
925
- 'canceled' => 0,
926
- 'options' => $child_export_options
927
- ))->save();
928
- }
929
- return $queue_exports;
930
- }
931
-
932
- public function get_fields_options( &$fields, $field_keys = array() ){
933
-
934
- if ( ! self::$is_active ) return;
935
-
936
- foreach (self::$order_sections as $slug => $section) :
937
- if ( ! empty($section['meta'])):
938
- foreach ($section['meta'] as $cur_meta_key => $field) {
939
-
940
- $field_key = (is_array($field)) ? $field['name'] : $field;
941
-
942
- if ( ! in_array($field_key, $field_keys) ) continue;
943
-
944
- $fields['ids'][] = 1;
945
- $fields['cc_label'][] = (is_array($field)) ? $field['label'] : $cur_meta_key;
946
- $fields['cc_php'][] = '';
947
- $fields['cc_code'][] = '';
948
- $fields['cc_sql'][] = '';
949
- $fields['cc_options'][] = (is_array($field)) ? $field['options'] : $slug;
950
- $fields['cc_type'][] = (is_array($field)) ? $field['type'] : 'woo_order';
951
- $fields['cc_value'][] = (is_array($field)) ? $field['label'] : $cur_meta_key;
952
- $fields['cc_name'][] = $field_key;
953
- $fields['cc_settings'][] = '';
954
- }
955
-
956
- endif;
957
- if ( ! empty($section['additional']) )
958
- {
959
- foreach ($section['additional'] as $sub_slug => $sub_section)
960
- {
961
- foreach ($sub_section['meta'] as $field) {
962
-
963
- $field_key = (is_array($field)) ? $field['name'] : $field;
964
-
965
- if ( ! in_array($field_key, $field_keys) ) continue;
966
-
967
- $fields['ids'][] = 1;
968
- $fields['cc_label'][] = 'item_data__' . ((is_array($field)) ? $field['label'] : $field);
969
- $fields['cc_php'][] = '';
970
- $fields['cc_code'][] = '';
971
- $fields['cc_sql'][] = '';
972
- $fields['cc_options'][] = 'item_data';
973
- $fields['cc_type'][] = (is_array($field)) ? $field['type'] : $sub_slug;
974
- $fields['cc_value'][] = 'item_data__' . ((is_array($field)) ? $field['label'] : $field);
975
- $fields['cc_name'][] = $field_key;
976
- $fields['cc_settings'][] = '';
977
- }
978
- }
979
- }
980
- endforeach;
981
-
982
- }
983
-
984
- public function render( & $i ){
985
-
986
- if ( ! self::$is_active ) return;
987
-
988
- foreach (self::$order_sections as $slug => $section) :
989
- if ( ! empty($section['meta']) or ! empty($section['additional']) ):
990
- ?>
991
- <p class="wpae-available-fields-group"><?php echo $section['title']; ?><span class="wpae-expander">+</span></p>
992
- <div class="wpae-custom-field">
993
- <?php if ( ! in_array($slug, array('order', 'customer', 'cf', 'other'))) : ?>
994
- <div class="wpallexport-free-edition-notice">
995
- <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707173&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-wooco-order-data"><?php _e('Upgrade to the Pro edition of WP All Export to Export Order Data','wp_all_export_plugin');?></a>
996
- </div>
997
- <?php endif; ?>
998
- <ul>
999
- <?php if ( ! empty($section['meta']) ): ?>
1000
- <li <?php if ( ! in_array($slug, array('order', 'customer', 'cf', 'other'))) : ?>class="wpallexport_disabled"<?php endif; ?>>
1001
- <div class="default_column" rel="">
1002
- <label class="wpallexport-element-label"><?php echo __("All", "wp_all_export_plugin") . ' ' . $section['title'] . ' ' . __("Data", "wp_all_export_plugin"); ?></label>
1003
- <input type="hidden" name="rules[]" value="pmxe_<?php echo $slug;?>"/>
1004
- </div>
1005
- </li>
1006
- <?php
1007
- foreach ($section['meta'] as $cur_meta_key => $field) {
1008
- $is_auto_field = ( ! empty($field['auto']) or XmlExportEngine::$is_auto_generate_enabled and 'specific' != $this->post['export_type']);
1009
- ?>
1010
- <li class="pmxe_<?php echo $slug; ?> <?php if ( ! in_array($slug, array('order', 'customer', 'cf', 'other'))) : ?>wpallexport_disabled<?php endif;?>">
1011
- <div class="custom_column" rel="<?php echo ($i + 1);?>">
1012
- <label class="wpallexport-xml-element"><?php echo (is_array($field)) ? $field['name'] : $field; ?></label>
1013
- <input type="hidden" name="ids[]" value="1"/>
1014
- <input type="hidden" name="cc_label[]" value="<?php echo (is_array($field)) ? $field['label'] : $cur_meta_key; ?>"/>
1015
- <input type="hidden" name="cc_php[]" value=""/>
1016
- <input type="hidden" name="cc_code[]" value=""/>
1017
- <input type="hidden" name="cc_sql[]" value=""/>
1018
- <input type="hidden" name="cc_options[]" value="<?php echo (is_array($field)) ? $field['options'] : $slug;?>"/>
1019
- <input type="hidden" name="cc_type[]" value="<?php echo (is_array($field)) ? $field['type'] : 'woo_order'; ?>"/>
1020
- <input type="hidden" name="cc_value[]" value="<?php echo (is_array($field)) ? $field['label'] : $cur_meta_key; ?>"/>
1021
- <input type="hidden" name="cc_name[]" value="<?php echo (is_array($field)) ? $field['name'] : $field;?>"/>
1022
- <input type="hidden" name="cc_settings[]" value=""/>
1023
- </div>
1024
- </li>
1025
- <?php
1026
- $i++;
1027
- }
1028
- endif;
1029
-
1030
- if ( ! empty($section['additional']) )
1031
- {
1032
- foreach ($section['additional'] as $sub_slug => $sub_section)
1033
- {
1034
- ?>
1035
- <li class="available_sub_section">
1036
- <p class="wpae-available-fields-group"><?php echo $sub_section['title']; ?><span class="wpae-expander">+</span></p>
1037
- <div class="wpae-custom-field">
1038
- <ul>
1039
- <li class="wpallexport_disabled">
1040
- <div class="default_column" rel="">
1041
- <label class="wpallexport-element-label"><?php echo __("All", "wp_all_export_plugin") . ' ' . $sub_section['title']; ?></label>
1042
- <input type="hidden" name="rules[]" value="pmxe_<?php echo $slug;?>_<?php echo $sub_slug;?>"/>
1043
- </div>
1044
- </li>
1045
- <?php
1046
- foreach ($sub_section['meta'] as $field) {
1047
- ?>
1048
- <li class="pmxe_<?php echo $slug; ?>_<?php echo $sub_slug;?> wpallexport_disabled">
1049
- <div class="custom_column" rel="<?php echo ($i + 1);?>">
1050
- <label class="wpallexport-xml-element"><?php echo (is_array($field)) ? $field['name'] : $field; ?></label>
1051
- <input type="hidden" name="ids[]" value="1"/>
1052
- <input type="hidden" name="cc_label[]" value="item_data__<?php echo (is_array($field)) ? $field['label'] : $field; ?>"/>
1053
- <input type="hidden" name="cc_php[]" value=""/>
1054
- <input type="hidden" name="cc_code[]" value=""/>
1055
- <input type="hidden" name="cc_sql[]" value=""/>
1056
- <input type="hidden" name="cc_options[]" value="item_data"/>
1057
- <input type="hidden" name="cc_type[]" value="<?php echo (is_array($field)) ? $field['type'] : $sub_slug; ?>"/>
1058
- <input type="hidden" name="cc_value[]" value="item_data__<?php echo (is_array($field)) ? $field['label'] : $field; ?>"/>
1059
- <input type="hidden" name="cc_name[]" value="<?php echo (is_array($field)) ? $field['name'] : $field;?>"/>
1060
- <input type="hidden" name="cc_settings[]" value=""/>
1061
- </div>
1062
- </li>
1063
- <?php
1064
- $i++;
1065
- }
1066
- ?>
1067
- </ul>
1068
- </li>
1069
- <?php
1070
- }
1071
- }
1072
-
1073
- ?>
1074
- </ul>
1075
- </div>
1076
- <?php
1077
- endif;
1078
- endforeach;
1079
- }
1080
-
1081
- public function render_new_field(){
1082
-
1083
- if ( ! self::$is_active ) return;
1084
-
1085
- ?>
1086
- <select class="wp-all-export-chosen-select" name="column_value_type" style="width:350px;">
1087
- <?php
1088
- foreach (self::$order_sections as $slug => $section) : //if ( in_array($slug, array('taxes', 'fees', 'items', 'notes', 'refunds'))) continue;
1089
- ?>
1090
- <optgroup label="<?php echo $section['title']; ?>">
1091
- <?php
1092
- foreach ($section['meta'] as $cur_meta_key => $field)
1093
- {
1094
- $field_label = is_array($field) ? $field['label'] : $cur_meta_key;
1095
- $field_type = is_array($field) ? $field['type'] : 'woo_order';
1096
- $field_name = is_array($field) ? $field['name'] : $field;
1097
- $field_options = is_array($field) ? $field['options'] : $slug;
1098
- ?>
1099
- <option
1100
- value="<?php echo $field_type;?>"
1101
- label="<?php echo $field_label;?>"
1102
- options="<?php echo $field_options; ?>"><?php echo $field_name;?></option>
1103
- <?php
1104
- }
1105
- ?>
1106
- </optgroup>
1107
- <?php
1108
- if ( ! empty($section['additional']) )
1109
- {
1110
- foreach ($section['additional'] as $sub_slug => $sub_section)
1111
- {
1112
- ?>
1113
- <optgroup label="<?php echo $sub_section['title']; ?>">
1114
-
1115
- <?php foreach ($sub_section['meta'] as $field): ?>
1116
-
1117
- <?php
1118
- $field_label = 'item_data__' . ( is_array($field) ? $field['label'] : $field );
1119
- $field_type = is_array($field) ? $field['type'] : $sub_slug;
1120
- $field_name = is_array($field) ? $field['name'] : $field;
1121
- $field_options = 'item_data';
1122
- ?>
1123
- <option
1124
- value="<?php echo $field_type;?>"
1125
- label="<?php echo $field_label;?>"
1126
- options="<?php echo $field_options; ?>"><?php echo $field_name;?></option>
1127
-
1128
- <?php endforeach; ?>
1129
-
1130
- </optgroup>
1131
- <?php
1132
- }
1133
- }
1134
-
1135
- endforeach;
1136
-
1137
- // Render Available ACF
1138
- XmlExportEngine::$acf_export->render_new_field();
1139
-
1140
- ?>
1141
-
1142
- <optgroup label="Advanced">
1143
- <option value="sql" label="sql"><?php _e("SQL Query", "wp_all_export_plugin"); ?></option>
1144
- </optgroup>
1145
-
1146
- </select>
1147
- <?php
1148
- }
1149
-
1150
- public function render_filters(){
1151
-
1152
- if ( ! self::$is_active ) return;
1153
-
1154
- foreach (self::$order_sections as $slug => $section) :
1155
- ?>
1156
- <optgroup label="<?php echo $section['title']; ?>">
1157
- <?php
1158
- foreach ($section['meta'] as $cur_meta_key => $field)
1159
- {
1160
- $field_label = is_array($field) ? $field['label'] : $cur_meta_key;
1161
- $field_type = is_array($field) ? $field['type'] : 'woo_order';
1162
- $field_name = is_array($field) ? $field['name'] : $field;
1163
- $field_options = is_array($field) ? $field['options'] : $slug;
1164
-
1165
- switch ($field_options)
1166
- {
1167
- case 'order':
1168
- case 'customer':
1169
- if ( strpos($field_label, '_') === 0):
1170
- ?>
1171
- <option value="<?php echo 'cf_' . $field_label; ?>"><?php echo $field_name; ?></option>
1172
- <?php
1173
- else:
1174
- ?>
1175
- <option value="<?php echo $field_label; ?>"><?php echo $field_name; ?></option>
1176
- <?php
1177
- endif;
1178
- break;
1179
- case 'notes':
1180
- case 'items':
1181
- case 'taxes':
1182
- case 'fees':
1183
- case 'refunds':
1184
- break;
1185
- default:
1186
- switch ($field_type)
1187
- {
1188
- case 'cf':
1189
- ?>
1190
- <option value="<?php echo 'cf_' . $field_label; ?>"><?php echo $field_name; ?></option>
1191
- <?php
1192
- break;
1193
- case 'cats':
1194
- case 'attr':
1195
- ?>
1196
- <option value="<?php echo 'tx_' . $field_label; ?>"><?php echo $field_name; ?></option>
1197
- <?php
1198
- break;
1199
- default:
1200
- ?>
1201
- <option value="<?php echo $field_label; ?>"><?php echo $field_name; ?></option>
1202
- <?php
1203
- break;
1204
- }
1205
- break;
1206
- }
1207
- }
1208
- ?>
1209
- </optgroup>
1210
- <?php
1211
-
1212
- endforeach;
1213
-
1214
- }
1215
-
1216
- public function available_sections(){
1217
-
1218
- $sections = array(
1219
- 'order' => array(
1220
- 'title' => __('Order', 'wp_all_export_plugin'),
1221
- 'meta' => $this->available_order_data()
1222
- ),
1223
- 'customer' => array(
1224
- 'title' => __('Customer', 'wp_all_export_plugin'),
1225
- 'meta' => $this->available_customer_data()
1226
- ),
1227
- 'items' => array(
1228
- 'title' => __('Items', 'wp_all_export_plugin'),
1229
- 'meta' => $this->available_order_default_product_data(),
1230
- 'additional' => $this->available_order_items_data()
1231
- ),
1232
- 'taxes' => array(
1233
- 'title' => __('Taxes & Shipping', 'wp_all_export_plugin'),
1234
- 'meta' => $this->available_order_taxes_data()
1235
- ),
1236
- 'fees' => array(
1237
- 'title' => __('Fees & Discounts', 'wp_all_export_plugin'),
1238
- 'meta' => $this->available_order_fees_data()
1239
- ),
1240
- 'notes' => array(
1241
- 'title' => __('Notes', 'wp_all_export_plugin'),
1242
- 'meta' => array(
1243
- 'comment_content' => __('Note Content', 'wp_all_export_plugin'),
1244
- 'comment_date' => __('Note Date', 'wp_all_export_plugin'),
1245
- 'visibility' => __('Note Visibility', 'wp_all_export_plugin'),
1246
- 'comment_author' => __('Note User Name', 'wp_all_export_plugin'),
1247
- 'comment_author_email' => __('Note User Email', 'wp_all_export_plugin')
1248
- )
1249
- ),
1250
- 'refunds' => array(
1251
- 'title' => __('Refunds', 'wp_all_export_plugin'),
1252
- 'meta' => array(
1253
- '_refund_total' => __('Refund Total', 'wp_all_export_plugin'),
1254
- 'refund_id' => __('Refund ID', 'wp_all_export_plugin'),
1255
- 'refund_amount' => __('Refund Amounts', 'wp_all_export_plugin'),
1256
- 'refund_reason' => __('Refund Reason', 'wp_all_export_plugin'),
1257
- 'refund_date' => __('Refund Date', 'wp_all_export_plugin'),
1258
- 'refund_author_email' => __('Refund Author Email', 'wp_all_export_plugin')
1259
- )
1260
- ),
1261
- 'cf' => array(
1262
- 'title' => __('Custom Fields', 'wp_all_export_plugin'),
1263
- 'meta' => array()
1264
- ),
1265
- 'other' => array(
1266
- 'title' => __('Other', 'wp_all_export_plugin'),
1267
- 'meta' => array()
1268
- )
1269
- );
1270
-
1271
- return apply_filters('wp_all_export_available_order_sections_filter', $sections);
1272
-
1273
- }
1274
-
1275
- /*
1276
- * Define the keys for orders informations to export
1277
- */
1278
- public function available_order_data()
1279
- {
1280
- $data = array(
1281
- 'ID' => __('Order ID', 'wp_all_export_plugin'),
1282
- '_order_key' => __('Order Key', 'wp_all_export_plugin'),
1283
- 'post_date' => __('Order Date', 'wp_all_export_plugin'),
1284
- '_completed_date' => __('Completed Date', 'wp_all_export_plugin'),
1285
- 'post_title' => __('Title', 'wp_all_export_plugin'),
1286
- 'post_status' => __('Order Status', 'wp_all_export_plugin'),
1287
- '_order_currency' => __('Order Currency', 'wp_all_export_plugin'),
1288
- '_payment_method_title' => __('Payment Method Title', 'wp_all_export_plugin'),
1289
- '_order_total' => __('Order Total', 'wp_all_export_plugin')
1290
- );
1291
-
1292
- return apply_filters('wp_all_export_available_order_data_filter', $data);
1293
- }
1294
-
1295
- /*
1296
- * Define the keys for general product informations to export
1297
- */
1298
- public function available_order_default_product_data()
1299
- {
1300
-
1301
- $data = array(
1302
- '_product_id' => __('Product ID', 'wp_all_export_plugin'),
1303
- '__product_sku' => __('SKU', 'wp_all_export_plugin'),
1304
- '__product_title' => __('Product Name', 'wp_all_export_plugin'),
1305
- '__product_variation' => __('Product Variation Details', 'wp_all_export_plugin'),
1306
- '_qty' => __('Quantity', 'wp_all_export_plugin'),
1307
- '_line_subtotal' => __('Item Cost', 'wp_all_export_plugin'),
1308
- '_line_total' => __('Item Total', 'wp_all_export_plugin'),
1309
- '_line_subtotal_tax' => __('Item Tax', 'wp_all_export_plugin'),
1310
- '_line_tax' => __('Item Tax Total', 'wp_all_export_plugin'),
1311
- '_line_tax_data' => __('Item Tax Data', 'wp_all_export_plugin'),
1312
- '__line_item_id' => __('Order Line ID', 'wp_all_export_plugin'),
1313
- '__line_item_title' => __('Order Line Title', 'wp_all_export_plugin'),
1314
- );
1315
-
1316
- return apply_filters('wp_all_export_available_order_default_product_data_filter', $data);
1317
- }
1318
-
1319
- public function available_order_items_data()
1320
- {
1321
-
1322
- $data = XmlExportEngine::$woo_export->get_all_fields_for_order_items();
1323
-
1324
- return apply_filters('wp_all_export_available_order_additional_product_data_filter', $data);
1325
- }
1326
-
1327
- public function available_order_taxes_data(){
1328
-
1329
- $data = array(
1330
- 'tax_order_item_name' => __('Rate Code (per tax)', 'wp_all_export_plugin'),
1331
- 'tax_rate' => __('Rate Percentage (per tax)', 'wp_all_export_plugin'),
1332
- 'tax_amount' => __('Amount (per tax)', 'wp_all_export_plugin'),
1333
- '_order_tax' => __('Total Tax Amount', 'wp_all_export_plugin'),
1334
- 'shipping_order_item_name' => __('Shipping Method', 'wp_all_export_plugin'),
1335
- '_order_shipping' => __('Shipping Cost', 'wp_all_export_plugin'),
1336
- '_order_shipping_taxes' => __('Shipping Taxes', 'wp_all_export_plugin')
1337
- );
1338
-
1339
- return apply_filters('wp_all_export_available_order_default_taxes_data_filter', $data);
1340
- }
1341
-
1342
- public function available_order_fees_data(){
1343
-
1344
- $data = array(
1345
- 'discount_amount' => __('Discount Amount (per coupon)', 'wp_all_export_plugin'),
1346
- '__coupons_used' => __('Coupons Used', 'wp_all_export_plugin'),
1347
- '_cart_discount' => __('Total Discount Amount', 'wp_all_export_plugin'),
1348
- 'fee_line_total' => __('Fee Amount (per surcharge)', 'wp_all_export_plugin'),
1349
- '__total_fee_amount' => __('Total Fee Amount', 'wp_all_export_plugin'),
1350
- '__fee_tax_data' => __('Fee Taxes', 'wp_all_export_plugin'),
1351
- );
1352
-
1353
- return apply_filters('wp_all_export_available_order_fees_data_filter', $data);
1354
- }
1355
-
1356
- public function available_customer_data()
1357
- {
1358
-
1359
- $main_fields = array(
1360
- '_customer_user' => __('Customer User ID', 'wp_all_export_plugin'),
1361
- 'post_excerpt' => __('Customer Note', 'wp_all_export_plugin')
1362
- );
1363
-
1364
- $data = array_merge($main_fields, $this->available_billing_information_data(), $this->available_shipping_information_data());
1365
-
1366
- return apply_filters('wp_all_export_available_user_data_filter', $data);
1367
-
1368
- }
1369
-
1370
- public function available_billing_information_data()
1371
- {
1372
-
1373
- $keys = array(
1374
- '_billing_first_name', '_billing_last_name', '_billing_company',
1375
- '_billing_address_1', '_billing_address_2', '_billing_city',
1376
- '_billing_postcode', '_billing_country', '_billing_state',
1377
- '_billing_email', '_customer_user_email', '_billing_phone'
1378
- );
1379
-
1380
- $data = $this->generate_friendly_titles($keys, 'billing');
1381
-
1382
- return apply_filters('wp_all_export_available_billing_information_data_filter', $data);
1383
-
1384
- }
1385
-
1386
- public function available_shipping_information_data()
1387
- {
1388
-
1389
- $keys = array(
1390
- '_shipping_first_name', '_shipping_last_name', '_shipping_company',
1391
- '_shipping_address_1', '_shipping_address_2', '_shipping_city',
1392
- '_shipping_postcode', '_shipping_country', '_shipping_state'
1393
- );
1394
-
1395
- $data = $this->generate_friendly_titles($keys, 'shipping');
1396
-
1397
- return apply_filters('wp_all_export_available_shipping_information_data_filter', $data);
1398
-
1399
- }
1400
-
1401
- public function generate_friendly_titles($keys, $keyword = ''){
1402
- $data = array();
1403
- foreach ($keys as $key) {
1404
-
1405
- $key1 = $this->fix_titles(str_replace('_', ' ', $key));
1406
- $key2 = '';
1407
-
1408
- if(strpos($key1, $keyword)!== false)
1409
- {
1410
- $key1 = str_replace($keyword, '', $key1);
1411
- $key2 = ' ('.__($keyword, 'wp_all_export_plugin').')';
1412
- }
1413
-
1414
- $data[$key] = __(trim($key1), 'wp_all_export_plugin').$key2;
1415
-
1416
- if ( '_billing_email' == $key ) $data[$key] = __('Billing Email Address', 'wp_all_export_plugin');
1417
- if ( '_customer_user_email' == $key) $data[$key] = __('Customer Account Email Address', 'wp_all_export_plugin');
1418
-
1419
- }
1420
- return $data;
1421
- }
1422
-
1423
- public static function prepare_import_template( $exportOptions, &$templateOptions, $element_name, $ID )
1424
- {
1425
-
1426
- if ( ! self::$is_active ) return;
1427
-
1428
- $options = $exportOptions;
1429
-
1430
- $element_type = $options['cc_value'][$ID];
1431
-
1432
- $is_xml_template = $options['export_to'] == 'xml';
1433
-
1434
- $implode_delimiter = XmlExportEngine::$implode;
1435
-
1436
- $billing_keys = array(
1437
- '_billing_first_name', '_billing_last_name', '_billing_company',
1438
- '_billing_address_1', '_billing_address_2', '_billing_city',
1439
- '_billing_postcode', '_billing_country', '_billing_state',
1440
- '_billing_email', '_billing_phone'
1441
- );
1442
-
1443
- $shipping_keys = array(
1444
- '_shipping_first_name', '_shipping_last_name', '_shipping_company',
1445
- '_shipping_address_1', '_shipping_address_2', '_shipping_city',
1446
- '_shipping_postcode', '_shipping_country', '_shipping_state'
1447
- );
1448
-
1449
- switch ($element_type)
1450
- {
1451
- case 'ID':
1452
- $templateOptions['unique_key'] = '{'. $element_name .'[1]}';
1453
- $templateOptions['tmp_unique_key'] = '{'. $element_name .'[1]}';
1454
- break;
1455
-
1456
- case 'post_title':
1457
- $templateOptions['title'] = '{'. $element_name .'[1]}';
1458
- $templateOptions['is_update_title'] = 1;
1459
- break;
1460
-
1461
- case 'post_status':
1462
- $templateOptions['is_update_status'] = 1;
1463
- $templateOptions['pmwi_order']['status'] = 'xpath';
1464
- $templateOptions['pmwi_order']['status_xpath'] = '{'. $element_name .'[1]}';
1465
- break;
1466
-
1467
- case 'post_date':
1468
- $templateOptions['is_update_dates'] = 1;
1469
- $templateOptions['pmwi_order']['date'] = '{'. $element_name .'[1]}';
1470
- break;
1471
-
1472
- case '_customer_user_email':
1473
- $templateOptions['pmwi_order']['billing_source_match_by'] = 'email';
1474
- $templateOptions['pmwi_order']['billing_source_email'] = '{'. $element_name .'[1]}';
1475
- $templateOptions['pmwi_order']['is_update_billing_details'] = 1;
1476
- $templateOptions['pmwi_order']['is_update_shipping_details'] = 1;
1477
- //$templateOptions['pmwi_order']['guest' . $element_type] = '{'. $element_name .'[1]}';
1478
- break;
1479
-
1480
- case 'post_excerpt':
1481
- $templateOptions['is_update_excerpt'] = 1;
1482
- $templateOptions['pmwi_order']['customer_provided_note'] = '{'. $element_name .'[1]}';
1483
- break;
1484
-
1485
- case '_transaction_id':
1486
- $templateOptions['pmwi_order']['transaction_id'] = '{'. $element_name .'[1]}';
1487
- break;
1488
-
1489
- case '_payment_method':
1490
- $templateOptions['pmwi_order']['payment_method'] = 'xpath';
1491
- $templateOptions['pmwi_order']['payment_method_xpath'] = '{'. $element_name .'[1]}';
1492
- $templateOptions['pmwi_order']['is_update_payment'] = 1;
1493
- break;
1494
-
1495
- case '__product_sku':
1496
- $templateOptions['pmwi_order']['is_update_products'] = 1;
1497
- $templateOptions['pmwi_order']['products_repeater_mode'] = $options['export_to'];
1498
- if ($is_xml_template)
1499
- {
1500
- $templateOptions['pmwi_order']['products_repeater_mode_foreach'] = '{OrderItems[1]/Item}';
1501
- $templateOptions['pmwi_order']['products'][0]['sku'] = '{'. $element_name .'[1]}';
1502
- }
1503
- else
1504
- {
1505
- $templateOptions['pmwi_order']['products_repeater_mode_separator'] = $implode_delimiter;
1506
-
1507
- if ( $options['order_item_per_row'] or $options['xml_template_type'] == 'custom') {
1508
- $templateOptions['pmwi_order']['products'][0]['sku'] = '{'. $element_name .'[1]}';
1509
- }
1510
- else{
1511
- $templateOptions['pmwi_order']['products'][0]['sku'] = '{'. $element_name .'1[1]}';
1512
- }
1513
- }
1514
- break;
1515
-
1516
- case '_qty':
1517
-
1518
- if ($is_xml_template)
1519
- {
1520
- $templateOptions['pmwi_order']['products'][0]['qty'] = '{'. $element_name .'[1]}';
1521
- }
1522
- else
1523
- {
1524
- $templateOptions['pmwi_order']['products_repeater_mode_separator'] = $implode_delimiter;
1525
-
1526
- if ( $options['order_item_per_row'] or $options['xml_template_type'] == 'custom') {
1527
- $templateOptions['pmwi_order']['products'][0]['qty'] = '{'. $element_name .'[1]}';
1528
- }
1529
- else{
1530
- $templateOptions['pmwi_order']['products'][0]['qty'] = '{'. $element_name .'1[1]}';
1531
- }
1532
- }
1533
- break;
1534
-
1535
- // prepare template for fee line items
1536
- case 'fee_line_total':
1537
- $templateOptions['pmwi_order']['is_update_fees'] = 1;
1538
- $templateOptions['pmwi_order']['fees_repeater_mode'] = $options['export_to'];
1539
- if ($is_xml_template)
1540
- {
1541
- $templateOptions['pmwi_order']['fees_repeater_mode_foreach'] = '{OrderSurcharge[1]/Surcharge}';
1542
- $templateOptions['pmwi_order']['fees'][0]['name'] = '{FeeName[1]}';
1543
- $templateOptions['pmwi_order']['fees'][0]['amount'] = '{'.$element_name.'[1]}';
1544
- }
1545
- else
1546
- {
1547
- $templateOptions['pmwi_order']['fees_repeater_mode_separator'] = $implode_delimiter;
1548
- $templateOptions['pmwi_order']['fees'][0]['name'] = '{feename[1]}';
1549
- $templateOptions['pmwi_order']['fees'][0]['amount'] = '{'.$element_name.'[1]}';
1550
- }
1551
- break;
1552
-
1553
- // prepare template for coupon line items
1554
- case 'discount_amount':
1555
- $templateOptions['pmwi_order']['is_update_coupons'] = 1;
1556
- $templateOptions['pmwi_order']['coupons_repeater_mode'] = $options['export_to'];
1557
- $templateOptions['pmwi_order']['coupons'][0]['amount_tax'] = '';
1558
- if ($is_xml_template)
1559
- {
1560
- $templateOptions['pmwi_order']['coupons_repeater_mode_foreach'] = '{OrderCoupons[1]/Coupon}';
1561
- $templateOptions['pmwi_order']['coupons'][0]['code'] = '{CouponCode[1]}';
1562
- $templateOptions['pmwi_order']['coupons'][0]['amount'] = '[str_replace("-","",{'.$element_name.'[1]})]';
1563
- }
1564
- else
1565
- {
1566
- $templateOptions['pmwi_order']['coupons_repeater_mode_separator'] = $implode_delimiter;
1567
- $templateOptions['pmwi_order']['coupons'][0]['code'] = '{couponcode[1]}';
1568
- $templateOptions['pmwi_order']['coupons'][0]['amount'] = '[str_replace("-","",{'.$element_name.'[1]})]';
1569
- }
1570
- break;
1571
-
1572
- // prepare template for shipping line items
1573
- case 'shipping_order_item_name':
1574
- $templateOptions['pmwi_order']['is_update_shipping'] = 1;
1575
- $templateOptions['pmwi_order']['shipping_repeater_mode'] = $options['export_to'];
1576
- $templateOptions['pmwi_order']['shipping'][0]['name'] = '{'. $element_name.'[1]}';
1577
- $templateOptions['pmwi_order']['shipping'][0]['class'] = 'xpath';
1578
- $templateOptions['pmwi_order']['shipping'][0]['class_xpath'] = '{'. $element_name .'[1]}';
1579
-
1580
- if ($is_xml_template)
1581
- {
1582
- $templateOptions['pmwi_order']['shipping_repeater_mode_foreach'] = '{OrderShipping[1]/Shipping}';
1583
- }
1584
- else
1585
- {
1586
- $templateOptions['pmwi_order']['shipping_repeater_mode_separator'] = $implode_delimiter;
1587
- }
1588
- break;
1589
- // shipping cost
1590
- case '_order_shipping':
1591
- $templateOptions['pmwi_order']['shipping'][0]['amount'] = '{'. $element_name .'[1]}';
1592
- break;
1593
-
1594
- // prepare template for tax line items
1595
- case 'tax_order_item_name':
1596
- $templateOptions['pmwi_order']['is_update_taxes'] = 1;
1597
- $templateOptions['pmwi_order']['taxes_repeater_mode'] = $options['export_to'];
1598
- $templateOptions['pmwi_order']['taxes'][0]['shipping_tax_amount'] = '';
1599
- $templateOptions['pmwi_order']['taxes'][0]['code'] = 'xpath';
1600
- $templateOptions['pmwi_order']['taxes'][0]['code_xpath'] = '{'. str_replace("pertax", "", $element_name) .'[1]}';
1601
-
1602
- if ($is_xml_template)
1603
- {
1604
- $templateOptions['pmwi_order']['taxes_repeater_mode_foreach'] = '{OrderTaxes[1]/Tax}';
1605
- }
1606
- else
1607
- {
1608
- $templateOptions['pmwi_order']['taxes_repeater_mode_separator'] = $implode_delimiter;
1609
- }
1610
- break;
1611
-
1612
- case 'tax_rate':
1613
- $templateOptions['pmwi_order']['taxes'][0]['tax_code'] = 'xpath';
1614
- $templateOptions['pmwi_order']['taxes'][0]['tax_code_xpath'] = '{ratename[1]}';
1615
- break;
1616
-
1617
- case 'tax_amount':
1618
- $templateOptions['pmwi_order']['taxes'][0]['tax_amount'] = '{'. str_replace("pertax", "", $element_name).'[1]}';
1619
- break;
1620
-
1621
- // order notes
1622
- case 'comment_content':
1623
- case 'comment_date':
1624
- $templateOptions['pmwi_order']['is_update_notes'] = 1;
1625
- $templateOptions['pmwi_order']['notes_repeater_mode'] = 'csv';
1626
- $templateOptions['pmwi_order']['notes_repeater_mode_separator'] = $implode_delimiter;
1627
- $templateOptions['pmwi_order']['notes'][0][str_replace('comment_', '', $element_type)] = '{'. $element_name .'[1]}';
1628
- break;
1629
- case 'visibility':
1630
- $templateOptions['pmwi_order']['notes'][0]['visibility'] = 'xpath';
1631
- $templateOptions['pmwi_order']['notes'][0]['visibility_xpath'] = '{'. $element_name .'[1]}';
1632
- break;
1633
- case 'comment_author':
1634
- $templateOptions['pmwi_order']['notes'][0]['username'] = '{'. $element_name .'[1]}';
1635
- break;
1636
- case 'comment_author_email':
1637
- $templateOptions['pmwi_order']['notes'][0]['email'] = '{'. $element_name .'[1]}';
1638
- break;
1639
- // Order Total
1640
- case '_order_total':
1641
- $templateOptions['pmwi_order']['order_total_logic'] = 'manually';
1642
- $templateOptions['pmwi_order']['order_total_xpath'] = '{'. $element_name .'[1]}';
1643
- break;
1644
- // Order Refunds
1645
- case 'refund_amount':
1646
- case 'refund_reason':
1647
- case 'refund_date':
1648
- $templateOptions['pmwi_order']['is_update_refunds'] = 1;
1649
- if ($is_xml_template)
1650
- {
1651
- $templateOptions['pmwi_order']['order_' . $element_type] = '{OrderRefunds[1]/Refund/'.$element_name.'[1]}';
1652
- }
1653
- else
1654
- {
1655
- $templateOptions['pmwi_order']['order_' . $element_type] = '{'. $element_name .'[1]}';
1656
- }
1657
- break;
1658
- case 'refund_author_email':
1659
- $templateOptions['pmwi_order']['order_refund_issued_email'] = '{'. $element_name .'[1]}';
1660
- $templateOptions['pmwi_order']['order_refund_issued_match_by'] = 'email';
1661
- if ($is_xml_template)
1662
- {
1663
- $templateOptions['pmwi_order']['order_refund_issued_email'] = '{OrderRefunds[1]/Refund/'.$element_name.'[1]}';
1664
- }
1665
- else
1666
- {
1667
- $templateOptions['pmwi_order']['order_refund_issued_email'] = '{'. $element_name .'[1]}';
1668
- }
1669
- break;
1670
- default:
1671
- if ( in_array($element_type, $billing_keys)){
1672
- $templateOptions['pmwi_order']['guest' . $element_type] = '{'. $element_name .'[1]}';
1673
- }
1674
- if ( in_array($element_type, $shipping_keys)){
1675
- $templateOptions['pmwi_order'][ltrim($element_type, '_')] = '{'. $element_name .'[1]}';
1676
- }
1677
- break;
1678
- }
1679
-
1680
- }
1681
-
1682
- /**
1683
- * __get function.
1684
- *
1685
- * @access public
1686
- * @param mixed $key
1687
- * @return mixed
1688
- */
1689
- public function __get( $key ) {
1690
- return $this->get( $key );
1691
- }
1692
-
1693
- /**
1694
- * Get a session variable
1695
- *
1696
- * @param string $key
1697
- * @param mixed $default used if the session variable isn't set
1698
- * @return mixed value of session variable
1699
- */
1700
- public function get( $key, $default = null ) {
1701
- return isset( $this->{$key} ) ? $this->{$key} : $default;
1702
- }
1703
-
1704
- }
1705
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
models/export/list.php CHANGED
File without changes
models/export/record.php CHANGED
File without changes
models/model.php CHANGED
File without changes
models/model/list.php CHANGED
File without changes
models/model/record.php CHANGED
File without changes
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: soflyy, wpallimport
3
  Requires at least: 5.0
4
  Tested up to: 5.8
5
- Stable tag: 1.2.10
6
  Tags: export, wordpress csv export, wordpress xml export, export woocommerce, 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
  Easily export any data from WordPress. Drag & drop to create a completely custom spreadsheet, CSV, or XML file.
@@ -91,6 +91,10 @@ Either: -
91
 
92
  == Changelog ==
93
 
 
 
 
 
94
  = 1.2.10 =
95
  * bugfix: WP_Query Results export only works with the User Export Add-On active
96
 
2
  Contributors: soflyy, wpallimport
3
  Requires at least: 5.0
4
  Tested up to: 5.8
5
+ Stable tag: 1.3.0
6
  Tags: export, wordpress csv export, wordpress xml export, export woocommerce, 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
  Easily export any data from WordPress. Drag & drop to create a completely custom spreadsheet, CSV, or XML file.
91
 
92
  == Changelog ==
93
 
94
+ = 1.3.0 =
95
+ * improvement: added plugin version when loading tipsy JS file
96
+ * improvement: moved ACF and WooCommerce support to add-ons
97
+
98
  = 1.2.10 =
99
  * bugfix: WP_Query Results export only works with the User Export Add-On active
100
 
schema.php CHANGED
File without changes
src/App/Service/Addons/AddonService.php CHANGED
@@ -10,34 +10,46 @@ class AddonService
10
  }
11
 
12
 
13
- public function isWooCommerceAddonActive() {
14
- return defined('PMWE_EDITION');
15
- }
16
 
17
- public function isAcfAddonActive() {
18
- return defined('PMAE_EDITION');
19
- }
20
 
21
- public function isWoocommerceAddonActiveAndIsWooCommerceExport()
22
- {
23
- return $this->isWooCommerceAddonActive() && \XmlExportWooCommerce::$is_active;
24
- }
25
 
26
- public function isUserAddonActiveAndIsUserExport()
27
- {
28
- return $this->isUserAddonActive() && \XmlExportUser::$is_active;
29
- }
30
 
31
- public function userExportsExistAndAddonNotInstalled()
32
- {
33
- $exports = new \PMXE_Export_List();
34
- $exports->getBy('parent_id', 0)->convertRecords();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
  foreach ($exports as $item) {
37
 
38
  if (
39
- ((in_array('users', $item['options']['cpt']) || in_array('shop_customer', $item['options']['cpt'])) && !$this->isUserAddonActive()) ||
40
- ($item['options']['export_type'] == 'advanced' && $item['options']['wp_query_selector'] == 'wp_user_query' && !$this->isUserAddonActive())
41
  ) {
42
  return true;
43
  }
@@ -47,27 +59,13 @@ class AddonService
47
  return false;
48
  }
49
 
50
- public function hasExportAtOlderVersionThan($version)
51
  {
52
- $exports = new \PMXE_Export_List();
53
- $exports->getBy('parent_id', 0)->convertRecords();
54
-
55
- foreach ($exports as $item) {
56
-
57
- if (!isset($item['options']['created_at_version'])) {
58
- continue;
59
- }
60
 
61
- if(version_compare($item['options']['created_at_version'], $version) < 0) {
62
- return true;
63
- }
64
- }
65
 
66
- return false;
67
- }
68
-
69
- public function wooCommerceExportsExistAndAddonNotInstalled()
70
- {
71
  $exports = new \PMXE_Export_List();
72
  $exports->getBy('parent_id', 0)->convertRecords();
73
 
@@ -89,8 +87,7 @@ class AddonService
89
  in_array('shop_order', $item['options']['cpt']) ||
90
  in_array('shop_review', $item['options']['cpt']) ||
91
  in_array('shop_coupon', $item['options']['cpt'])
92
- )
93
- && !$this->isWooCommerceAddonActive())
94
  ) {
95
  return true;
96
  }
@@ -111,14 +108,33 @@ class AddonService
111
 
112
  foreach ($exports as $item) {
113
 
114
- if(!empty($item['tpl_data']['options']['acf'])) {
115
  return true;
116
  }
117
 
 
118
 
119
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
 
121
- return false;
122
- }
123
 
124
  }
10
  }
11
 
12
 
13
+ public function isWooCommerceAddonActive() {
14
+ return defined('PMWE_EDITION');
15
+ }
16
 
17
+ public function isAcfAddonActive() {
18
+ return defined('PMAE_EDITION');
19
+ }
20
 
21
+ public function isWooCommerceOrderAddonActive() {
22
+ return defined('PMWOE_EDITION');
23
+ }
 
24
 
25
+ public function isWooCommerceProductAddonActive() {
26
+ return defined('PMWPE_EDITION');
27
+ }
 
28
 
29
+ public function isWoocommerceAddonActiveAndIsWooCommerceExport()
30
+ {
31
+ return $this->isWooCommerceAddonActive() && \XmlExportWooCommerce::$is_active;
32
+ }
33
+
34
+ public function isUserAddonActiveAndIsUserExport()
35
+ {
36
+ return $this->isUserAddonActive() && \XmlExportUser::$is_active;
37
+ }
38
+
39
+ public function userExportsExistAndAddonNotInstalled()
40
+ {
41
+ if($this->isUserAddonActive()) {
42
+ return false;
43
+ }
44
+
45
+ $exports = new \PMXE_Export_List();
46
+ $exports->getBy('parent_id', 0)->convertRecords();
47
 
48
  foreach ($exports as $item) {
49
 
50
  if (
51
+ ((in_array('users', $item['options']['cpt']) || in_array('shop_customer', $item['options']['cpt']))) ||
52
+ ($item['options']['export_type'] == 'advanced' && $item['options']['wp_query_selector'] == 'wp_user_query')
53
  ) {
54
  return true;
55
  }
59
  return false;
60
  }
61
 
62
+ public function wooCommerceExportsExistAndAddonNotInstalled()
63
  {
 
 
 
 
 
 
 
 
64
 
65
+ if($this->isWooCommerceAddonActive()) {
66
+ return false;
67
+ }
 
68
 
 
 
 
 
 
69
  $exports = new \PMXE_Export_List();
70
  $exports->getBy('parent_id', 0)->convertRecords();
71
 
87
  in_array('shop_order', $item['options']['cpt']) ||
88
  in_array('shop_review', $item['options']['cpt']) ||
89
  in_array('shop_coupon', $item['options']['cpt'])
90
+ ))
 
91
  ) {
92
  return true;
93
  }
108
 
109
  foreach ($exports as $item) {
110
 
111
+ if(is_array($item->options['cc_type']) && in_array('acf', $item->options['cc_type'])) {
112
  return true;
113
  }
114
 
115
+ }
116
 
117
+ return false;
118
+ }
119
+
120
+ public function hasExportAtOlderVersionThan($version)
121
+ {
122
+ $exports = new \PMXE_Export_List();
123
+ $exports->getBy('parent_id', 0)->convertRecords();
124
+
125
+ foreach ($exports as $item) {
126
+
127
+ if (!isset($item['options']['created_at_version'])) {
128
+ continue;
129
+ }
130
+
131
+ if(version_compare($item['options']['created_at_version'], $version) < 0) {
132
+ return true;
133
+ }
134
+ }
135
+
136
+ return false;
137
+ }
138
 
 
 
139
 
140
  }
src/App/UnsecuredController/SchedulingController.php CHANGED
@@ -35,6 +35,9 @@ class SchedulingController extends BaseController
35
  $export = new \PMXE_Export_Record();
36
  $export->getById($exportId);
37
 
 
 
 
38
  if ($export->isEmpty()) {
39
  return new JsonResponse(array('message' => 'Export not found'), 404);
40
  }
@@ -152,6 +155,19 @@ class SchedulingController extends BaseController
152
  ) {
153
  die(\__('The User Export Add-On Pro is required to run this export. You can download the add-on here: <a href="http://www.wpallimport.com/portal/" target="_blank">http://www.wpallimport.com/portal/</a>', \PMXE_Plugin::LANGUAGE_DOMAIN));
154
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  }
156
 
157
  }
35
  $export = new \PMXE_Export_Record();
36
  $export->getById($exportId);
37
 
38
+ $this->disableExportsThatDontHaveAddon($export);
39
+
40
+
41
  if ($export->isEmpty()) {
42
  return new JsonResponse(array('message' => 'Export not found'), 404);
43
  }
155
  ) {
156
  die(\__('The User Export Add-On Pro is required to run this export. You can download the add-on here: <a href="http://www.wpallimport.com/portal/" target="_blank">http://www.wpallimport.com/portal/</a>', \PMXE_Plugin::LANGUAGE_DOMAIN));
157
  }
158
+
159
+ if (
160
+ (( (in_array('product', $cpt) && in_array('product_variation', $cpt)) || in_array('shop_order', $cpt) || in_array('shop_coupon', $cpt)) && !$addons->isWooCommerceAddonActive())
161
+ ||
162
+ ($export->options['export_type'] == 'advanced' && in_array($export->options['exportquery']->query['post_type'], array(array('product', 'product_variation'), 'shop_order', 'shop_coupon')) && !$addons->isWooCommerceAddonActive())
163
+ ) {
164
+ die(\__('The WooCommerce Export Add-On Pro is required to run this export. You can download the add-on here: <a href="http://www.wpallimport.com/portal/" target="_blank">http://www.wpallimport.com/portal/</a>', \PMXE_Plugin::LANGUAGE_DOMAIN));
165
+ }
166
+
167
+ if(in_array('acf', $export->options['cc_type']) && !$addons->isAcfAddonActive()) {
168
+ die(\__('The ACF Export Add-On Pro is required to run this export. You can download the add-on here: <a href="http://www.wpallimport.com/portal/" target="_blank">http://www.wpallimport.com/portal/</a>', \PMXE_Plugin::LANGUAGE_DOMAIN));
169
+ }
170
+
171
  }
172
 
173
  }
src/Pro/Filtering/FilteringFactory.php CHANGED
@@ -10,6 +10,13 @@ class FilteringFactory
10
  {
11
  public static function getFilterEngine()
12
  {
 
 
 
 
 
 
 
13
  return new FilteringFree();
14
  }
15
 
10
  {
11
  public static function getFilterEngine()
12
  {
13
+ if (\XmlExportEngine::$is_user_export && \XmlExportEngine::get_addons_service()->isUserAddonActive() && PMUE_EDITION == 'paid'){
14
+ if (! empty(\XmlExportEngine::$post_types) and @in_array("shop_customer", \XmlExportEngine::$post_types)){
15
+ return new \Pmue\Pro\Filtering\FilteringCustomers();
16
+ }
17
+ return new \Pmue\Pro\Filtering\FilteringUsers();
18
+ }
19
+
20
  return new FilteringFree();
21
  }
22
 
static/css/admin-ie.css CHANGED
File without changes
static/css/admin-wp-3.8.css CHANGED
File without changes
static/css/admin.css CHANGED
@@ -161,6 +161,22 @@
161
  font-size: 1.3em !important;
162
  margin-bottom: 0;
163
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  .wpallexport-plugin .upgrade_link{
165
  color: #000 !important;
166
  font-size: 1.3em;
@@ -168,8 +184,13 @@
168
  }
169
  .wpallexport-plugin .wpallexport-user-export-notice,
170
  .wpallexport-plugin .wpallexport-shop_customer-export-notice,
 
 
 
 
171
  .wpallexport-plugin .wpallexport-comments-export-notice,
172
- .wpallexport-plugin .wpallexport-taxonomies-export-notice{
 
173
  padding: 20px;
174
  display: none;
175
  width: 558px;
@@ -1177,14 +1198,14 @@ a.wpallexport-import-to-format span.wpallexport-import-to-title {
1177
  .wpallexport-plugin .right fieldset{
1178
  padding: 15px;
1179
  }
1180
- .wpallexport-plugin .right fieldset input{
1181
- max-width:none;
1182
- padding:6px;
1183
- margin:0px
1184
- }
1185
- .wpallexport-plugin .right a{
1186
- text-decoration: underline;
1187
- }
1188
  .wpallexport-plugin fieldset legend{
1189
  padding: 0px 5px;
1190
  font-weight: bold;
161
  font-size: 1.3em !important;
162
  margin-bottom: 0;
163
  }
164
+
165
+ .wpallexport-plugin .wpallexport-free-edition-notice.wpallexport-user-export-notice p,
166
+ .wpallexport-plugin .wpallexport-free-edition-notice.wpallexport-shop_customer-export-notice p,
167
+ .wpallexport-plugin .wpallexport-free-edition-notice.wpallexport-shop_order-export-notice p,
168
+ .wpallexport-plugin .wpallexport-free-edition-notice.wpallexport-shop_coupon-export-notice p,
169
+ .wpallexport-plugin .wpallexport-free-edition-notice.wpallexport-shop_review-export-notice p,
170
+ .wpallexport-plugin .wpallexport-free-edition-notice.wpallexport-comments-export-notice p,
171
+ .wpallexport-plugin .wpallexport-free-edition-notice.wpallexport-taxonomies-export-notice p,
172
+ .wpallexport-plugin .wpallexport-free-edition-notice.wpallexport-product-export-notice p
173
+
174
+ {
175
+ margin-bottom: 1em;
176
+ margin-top: 0;
177
+ }
178
+
179
+
180
  .wpallexport-plugin .upgrade_link{
181
  color: #000 !important;
182
  font-size: 1.3em;
184
  }
185
  .wpallexport-plugin .wpallexport-user-export-notice,
186
  .wpallexport-plugin .wpallexport-shop_customer-export-notice,
187
+ .wpallexport-plugin .wpallexport-shop_review-export-notice,
188
+ .wpallexport-plugin .wpallexport-shop_order-export-notice,
189
+ .wpallexport-plugin .wpallexport-shop_coupon-export-notice,
190
+ .wpallexport-plugin .wpallexport-reviews-export-notice,
191
  .wpallexport-plugin .wpallexport-comments-export-notice,
192
+ .wpallexport-plugin .wpallexport-taxonomies-export-notice,
193
+ .wpallexport-plugin .wpallexport-product-export-notice {
194
  padding: 20px;
195
  display: none;
196
  width: 558px;
1198
  .wpallexport-plugin .right fieldset{
1199
  padding: 15px;
1200
  }
1201
+ .wpallexport-plugin .right fieldset input{
1202
+ max-width:none;
1203
+ padding:6px;
1204
+ margin:0px
1205
+ }
1206
+ .wpallexport-plugin .right a{
1207
+ text-decoration: underline;
1208
+ }
1209
  .wpallexport-plugin fieldset legend{
1210
  padding: 0px 5px;
1211
  font-weight: bold;
static/img/date-picker.gif CHANGED
File without changes
static/img/down.gif CHANGED
File without changes
static/img/drag.png CHANGED
File without changes
static/img/ico-add-new.png CHANGED
File without changes
static/img/ico-remove.png CHANGED
File without changes
static/img/loading.png CHANGED
File without changes
static/img/logo.png DELETED
Binary file
static/img/progress_animated.gif CHANGED
File without changes
static/img/screen-options-right-up.gif CHANGED
File without changes
static/img/screen-options-right.gif CHANGED
File without changes
static/img/soflyy-logo.png DELETED
Binary file
static/img/stars.png CHANGED
File without changes
static/img/xmlicon.png DELETED
Binary file
static/js/admin.js CHANGED
@@ -210,7 +210,7 @@
210
  };
211
 
212
  initDraggable();
213
-
214
  $('.export_variations').change(function(){
215
  setTimeout(liveFiltering, 200);
216
  $('.wp-all-export-product-bundle-warning').hide();
@@ -241,6 +241,8 @@
241
  $('table.wpallexport-layout').length && $('table.wpallexport-layout td.left h2:first-child').css('margin-top', $('.wrap').offset().top - $('table.wpallexport-layout').offset().top);
242
  }, 10);
243
 
 
 
244
  // help icons
245
  $('.wpallexport-help').tipsy({
246
  gravity: function() {
@@ -344,6 +346,8 @@
344
  }
345
  }).change();
346
 
 
 
347
  // swither show/hide logic
348
  $('input.switcher-horizontal').change('change', function (e) {
349
 
@@ -799,6 +803,8 @@
799
 
800
  if (postType != '')
801
  {
 
 
802
  if (postType == 'users'){
803
  $('.wpallexport-user-export-notice').show();
804
  showImportType = false;
@@ -816,6 +822,24 @@
816
  showImportType = false;
817
  $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideDown();
818
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
819
  else if (postType == 'taxonomies'){
820
  showImportType = false;
821
  $('.taxonomy_to_export_wrapper').slideDown();
@@ -882,7 +906,7 @@
882
 
883
  $('.wpallexport-user-export-notice').hide();
884
  $('.wpallexport-comments-export-notice').hide();
885
- $('.wpallexport-reviews-export-notice').hide();
886
  $('.wpallexport-shop_customer-export-notice').hide();
887
  $('.wpallexport-taxonomies-export-notice').hide();
888
 
@@ -911,9 +935,12 @@
911
  $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide();
912
  }
913
  else{
914
- $('.taxonomy_to_export_wrapper').slideUp();
915
 
916
- if (postType == 'users' && !$('#pmxe_user_addon_free_installed').val())
 
 
 
 
917
  {
918
  $('.wpallexport-user-export-notice').show();
919
  $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide();
@@ -923,16 +950,37 @@
923
  $('.wpallexport-comments-export-notice').show();
924
  $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide();
925
  }
926
- else if (postType == 'shop_review')
927
  {
928
- $('.wpallexport-reviews-export-notice').show();
929
- $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide();
 
930
  }
931
- else if (postType == 'shop_customer')
932
  {
933
  $('.wpallexport-shop_customer-export-notice').show();
934
  $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide();
935
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
936
  else
937
  {
938
  $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').show();
@@ -960,21 +1008,45 @@
960
  }
961
  });
962
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
963
  $(document).on('click', 'a.auto-generate-template', function(){
964
 
965
  var export_type = $('input[name="cpt"]').val();
966
 
967
- if (export_type == 'users') {
968
 
969
  $('#migrate-users-notice').slideDown();
970
  return false;
971
  }
972
 
973
- if(export_type == 'shop_order') {
974
- $('#migrate-orders-notice').slideDown();
975
- return;
976
- }
977
-
978
  $('input[name^=auto_generate]').val('1');
979
 
980
  $('.hierarhy-output').each(function(){
@@ -2850,5 +2922,16 @@
2850
  };
2851
 
2852
 
 
 
 
 
 
 
 
 
 
 
 
2853
 
2854
  });})(jQuery, window.EventService);
210
  };
211
 
212
  initDraggable();
213
+
214
  $('.export_variations').change(function(){
215
  setTimeout(liveFiltering, 200);
216
  $('.wp-all-export-product-bundle-warning').hide();
241
  $('table.wpallexport-layout').length && $('table.wpallexport-layout td.left h2:first-child').css('margin-top', $('.wrap').offset().top - $('table.wpallexport-layout').offset().top);
242
  }, 10);
243
 
244
+
245
+
246
  // help icons
247
  $('.wpallexport-help').tipsy({
248
  gravity: function() {
346
  }
347
  }).change();
348
 
349
+
350
+
351
  // swither show/hide logic
352
  $('input.switcher-horizontal').change('change', function (e) {
353
 
803
 
804
  if (postType != '')
805
  {
806
+ $('.wpallexport-free-edition-notice').hide();
807
+
808
  if (postType == 'users'){
809
  $('.wpallexport-user-export-notice').show();
810
  showImportType = false;
822
  showImportType = false;
823
  $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideDown();
824
  }
825
+ else if (postType == 'shop_order')
826
+ {
827
+ $('.wpallexport-shop_order-export-notice').show();
828
+ showImportType = false;
829
+ $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideDown();
830
+ }
831
+ else if (postType == 'shop_review')
832
+ {
833
+ $('.wpallexport-shop_review-export-notice').show();
834
+ showImportType = false;
835
+ $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideDown();
836
+ }
837
+ else if (postType == 'product')
838
+ {
839
+ $('.wpallexport-product-export-notice').show();
840
+ showImportType = false;
841
+ $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideDown();
842
+ }
843
  else if (postType == 'taxonomies'){
844
  showImportType = false;
845
  $('.taxonomy_to_export_wrapper').slideDown();
906
 
907
  $('.wpallexport-user-export-notice').hide();
908
  $('.wpallexport-comments-export-notice').hide();
909
+ $('.wpallexport-shop_review-export-notice').hide();
910
  $('.wpallexport-shop_customer-export-notice').hide();
911
  $('.wpallexport-taxonomies-export-notice').hide();
912
 
935
  $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide();
936
  }
937
  else{
 
938
 
939
+ $('.wpallexport-free-edition-notice').hide();
940
+
941
+ $('.taxonomy_to_export_wrapper').slideUp();
942
+
943
+ if (postType == 'users' && !$('#pmxe_user_addon_free_installed').val() && !$('#pmxe_user_addon_installed').val())
944
  {
945
  $('.wpallexport-user-export-notice').show();
946
  $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide();
950
  $('.wpallexport-comments-export-notice').show();
951
  $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide();
952
  }
953
+ else if (postType == 'shop_review' /*&& !$('#pmxe_woocommerce_addon_installed').val()*/)
954
  {
955
+ $('.wpallexport-shop_review-export-notice').show();
956
+ $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide();
957
+
958
  }
959
+ else if (postType == 'shop_customer' && !$('#pmxe_user_addon_installed').val())
960
  {
961
  $('.wpallexport-shop_customer-export-notice').show();
962
  $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide();
963
  }
964
+ else if (postType == 'shop_coupon' && !$('#pmxe_woocommerce_addon_installed').val())
965
+ {
966
+ $('.wpallexport-shop_coupon-export-notice').show();
967
+ $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide();
968
+ }
969
+ else if (postType == 'shop_order')
970
+ {
971
+ if(!($('#pmxe_woocommerce_addon_installed').val() || $('#pmxe_woocommerce_order_addon_installed').val())) {
972
+ $('.wpallexport-shop_order-export-notice').show();
973
+ $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide();
974
+ }
975
+ }
976
+ else if (postType == 'product')
977
+ {
978
+ if(!($('#pmxe_woocommerce_addon_installed').val() || $('#pmxe_woocommerce_order_addon_installed').val())) {
979
+
980
+ $('.wpallexport-product-export-notice').show();
981
+ $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide();
982
+ }
983
+ }
984
  else
985
  {
986
  $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').show();
1008
  }
1009
  });
1010
 
1011
+ $(document).on('keyup','.wp_query', function(){
1012
+
1013
+ var value = $(this).val();
1014
+
1015
+ if(!$('#pmxe_woocommerce_addon_installed').length) {
1016
+
1017
+ if(value.indexOf('shop_order') === -1 && value.indexOf('product') === -1 && value.indexOf('shop_coupon') === -1) {
1018
+ $('.wpallexport-free-edition-notice').hide();
1019
+ $('.wpallexport-submit-buttons').show();
1020
+ return;
1021
+ }
1022
+
1023
+ if (value.indexOf('shop_order') !== -1) {
1024
+ $('.wpallexport-shop_order-export-notice').show();
1025
+ $('.wpallexport-submit-buttons').hide();
1026
+ }
1027
+
1028
+ if (value.indexOf('product') !== -1) {
1029
+ $('.wpallexport-product-export-notice').show();
1030
+ $('.wpallexport-submit-buttons').hide();
1031
+ }
1032
+
1033
+ if (value.indexOf('shop_coupon') !== -1) {
1034
+ $('.wpallexport-shop_coupon-export-notice').show();
1035
+ $('.wpallexport-submit-buttons').hide();
1036
+ }
1037
+ }
1038
+ });
1039
+
1040
  $(document).on('click', 'a.auto-generate-template', function(){
1041
 
1042
  var export_type = $('input[name="cpt"]').val();
1043
 
1044
+ if (export_type == 'users' && !($('#user_add_on_pro_installed').length)) {
1045
 
1046
  $('#migrate-users-notice').slideDown();
1047
  return false;
1048
  }
1049
 
 
 
 
 
 
1050
  $('input[name^=auto_generate]').val('1');
1051
 
1052
  $('.hierarhy-output').each(function(){
2922
  };
2923
 
2924
 
2925
+ var oldsi = window.tb_showIframe;
2926
+
2927
+ window.tb_showIframe = function() {
2928
+
2929
+ $('#TB_iframeContent').contents().find('#plugin_install_from_iframe').on('click', function(){
2930
+ var href = $(this).attr('href');
2931
+ window.location = href;
2932
+ });
2933
+ oldsi();
2934
+ }
2935
+
2936
 
2937
  });})(jQuery, window.EventService);
static/js/jquery/css/redmond/images/animated-overlay.gif CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-bg_flat_0_aaaaaa_40x100.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-bg_flat_0_aaaaaa_40x100_1.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-bg_flat_55_fbec88_40x100.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-bg_glass_75_d0e5f5_1x400.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-bg_glass_85_dfeffc_1x400.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-bg_glass_95_fef1ec_1x400.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-icons_217bc0_256x240.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-icons_2e83ff_256x240.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-icons_469bdd_256x240.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-icons_6da8d5_256x240.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-icons_cd0a0a_256x240.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-icons_d8e7f3_256x240.png CHANGED
File without changes
static/js/jquery/css/redmond/images/ui-icons_f9bd01_256x240.png CHANGED
File without changes
static/js/jquery/css/redmond/jquery-ui.css CHANGED
File without changes
static/js/jquery/css/select2/select2-bootstrap.css CHANGED
File without changes
static/js/jquery/css/select2/select2-spinner.gif CHANGED
File without changes
static/js/jquery/css/select2/select2.css CHANGED
File without changes
static/js/jquery/css/select2/select2.png CHANGED
File without changes
static/js/jquery/css/smoothness/images/tipsy.gif CHANGED
File without changes
static/js/jquery/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png CHANGED
File without changes
static/js/jquery/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png CHANGED
File without changes
static/js/jquery/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png CHANGED
File without changes
static/js/jquery/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png CHANGED
File without changes
static/js/jquery/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png CHANGED
File without changes
static/js/jquery/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png CHANGED
File without changes
static/js/jquery/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png CHANGED
File without changes
static/js/jquery/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png CHANGED
File without changes
static/js/jquery/css/smoothness/images/ui-icons_222222_256x240.png CHANGED
File without changes
static/js/jquery/css/smoothness/images/ui-icons_2e83ff_256x240.png CHANGED
File without changes
static/js/jquery/css/smoothness/images/ui-icons_454545_256x240.png CHANGED
File without changes
static/js/jquery/css/smoothness/images/ui-icons_888888_256x240.png CHANGED
File without changes
static/js/jquery/css/smoothness/images/ui-icons_cd0a0a_256x240.png CHANGED
File without changes
static/js/jquery/css/smoothness/jquery-ui.css CHANGED
File without changes
static/js/jquery/css/smoothness/jquery.tipsy.css CHANGED
File without changes
static/js/jquery/jquery.tipsy.js CHANGED
File without changes
static/js/jquery/select2.min.js CHANGED
File without changes
static/js/jquery/ui.autocomplete.js CHANGED
File without changes
static/js/jquery/ui.datepicker.js CHANGED
File without changes
static/js/pmxe.js CHANGED
File without changes
views/admin/export/index.php CHANGED
@@ -149,28 +149,76 @@ do_action('pmxe_addons_html');
149
  <?php endforeach;?>
150
  </select>
151
  </div>
152
- <div class="wpallexport-free-edition-notice wpallexport-user-export-notice">
153
- <a class="thickbox open-plugin-details-modal upgrade_link" href="/wp-admin/plugin-install.php?tab=plugin-information&plugin=export-wp-users-xml-csv&TB_iframe=true&width=772&height=566"><?php _e('Install the User Export Add-On','wp_all_export_plugin');?></a>
154
- <p><?php _e('This free add-on is required to export users.', 'wp_all_export_plugin'); ?></p>
155
- </div>
 
 
 
156
  <div class="wpallexport-free-edition-notice wpallexport-shop_customer-export-notice">
157
- <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707173&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-wooco-customers"><?php _e('Upgrade to the Pro edition of WP All Export to Export Customers','wp_all_export_plugin');?></a>
158
- <p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
159
- </div>
160
- <div class="wpallexport-free-edition-notice wpallexport-comments-export-notice">
161
- <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707173&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-comments"><?php _e('Upgrade to the Pro edition of WP All Export to Export Comments','wp_all_export_plugin');?></a>
162
- <p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
163
  </div>
164
- <div class="wpallexport-free-edition-notice wpallexport-reviews-export-notice">
165
- <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707173&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-reviews"><?php _e('WP All Export Pro is Required to Export Reviews <br/>Purchase WP All Export Pro','wp_all_export_plugin');?></a>
166
- <p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  <div class="wpallexport-free-edition-notice wpallexport-taxonomies-export-notice">
169
- <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707173&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-taxonomies"><?php _e('Upgrade to the Pro edition of WP All Export to Export Taxonomies','wp_all_export_plugin');?></a>
170
- <p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
171
- </div>
 
 
 
 
 
 
 
172
  </div>
173
- </div>
174
 
175
  <div class="wpallexport-upload-type-container" rel="advanced_type">
176
  <div class="wpallexport-file-type-options">
@@ -189,12 +237,14 @@ do_action('pmxe_addons_html');
189
  </select>
190
 
191
  <div class="wpallexport-free-edition-notice wpallexport-user-export-notice" style="margin-bottom: 20px;">
192
- <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707173&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-users"><?php _e('Upgrade to the Pro edition of WP All Export to Export Users','wp_all_export_plugin');?></a>
193
- <p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
 
194
  </div>
195
 
196
  <div class="wpallexport-free-edition-notice wpallexport-comments-export-notice" style="margin-bottom: 20px;">
197
- <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707173&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-comments"><?php _e('Upgrade to the Pro edition of WP All Export to Export Comments','wp_all_export_plugin');?></a>
 
198
  <p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
199
  </div>
200
 
149
  <?php endforeach;?>
150
  </select>
151
  </div>
152
+
153
+ <div class="wpallexport-free-edition-notice wpallexport-user-export-notice">
154
+ <p><?php _e('The User Export Package is Required to Export Users.', 'wp_all_export_plugin'); ?></p>
155
+ <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=4206903&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-users"><?php
156
+ _e('Purchase the User Export Package','wp_all_export_plugin');?></a>
157
+ </div>
158
+
159
  <div class="wpallexport-free-edition-notice wpallexport-shop_customer-export-notice">
160
+ <p><?php _e('The User Export Package is Required to Export Customers.', 'wp_all_export_plugin'); ?></p>
161
+
162
+ <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=4206903&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-customers"><?php
163
+ _e('Purchase the User Export Package','wp_all_export_plugin');?></a>
 
 
164
  </div>
165
+
166
+
167
+ <div class="wpallexport-free-edition-notice wpallexport-shop_order-export-notice">
168
+ <p><?php _e('The WooCommerce Export Package is Required to Export Orders.', 'wp_all_export_plugin'); ?></p>
169
+ <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=4206899&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-orders"><?php
170
+ _e('Purchase the WooCommerce Export Package','wp_all_export_plugin');?></a>
171
+ </div>
172
+
173
+ <div class="wpallexport-free-edition-notice wpallexport-shop_coupon-export-notice">
174
+ <p><?php _e('The WooCommerce Export Package is Required to Export Coupons.', 'wp_all_export_plugin'); ?></p>
175
+ <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=4206899&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-coupons"><?php
176
+ _e('Purchase the WooCommerce Export Package','wp_all_export_plugin');?></a>
177
+
178
+ </div>
179
+
180
+ <div class="wpallexport-free-edition-notice wpallexport-shop_review-export-notice">
181
+
182
+ <p><?php _e('WP All Export Pro and the WooCommerce Export Add-On are Required to Export WooCommerce Reviews.', 'wp_all_export_plugin'); ?></p>
183
+
184
+ <a class="upgrade_link" target="_blank"
185
+ href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=4206899&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-reviews"><?php
186
+ _e('Purchase the WooCommerce Export Package','wp_all_export_plugin');?></a>
187
+
188
+
189
  </div>
190
+
191
+ <div class="wpallexport-free-edition-notice wpallexport-product-export-notice">
192
+ <p><?php _e('The WooCommerce Export Package is Required to Export WooCommerce Products.', 'wp_all_export_plugin'); ?></p>
193
+ <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=4206899&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-products"><?php
194
+ _e('Purchase the WooCommerce Export Package','wp_all_export_plugin');?></a>
195
+
196
+ </div>
197
+
198
+ <div class="wpallexport-free-edition-notice wpallexport-comments-export-notice">
199
+
200
+ <p><?php _e('WP All Export Pro is Required to Export Comments.', 'wp_all_export_plugin'); ?></p>
201
+
202
+ <a class="upgrade_link" target="_blank"
203
+ href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707173&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-comments"><?php
204
+ _e('Purchase WP All Export Pro','wp_all_export_plugin');?></a>
205
+
206
+ </div>
207
+
208
+
209
  <div class="wpallexport-free-edition-notice wpallexport-taxonomies-export-notice">
210
+
211
+ <p><?php _e('WP All Export Pro is Required to Export Taxonomies.', 'wp_all_export_plugin'); ?></p>
212
+
213
+ <a class="upgrade_link" target="_blank"
214
+ href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707173&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-taxonomies"><?php
215
+ _e('Purchase WP All Export Pro','wp_all_export_plugin');?></a>
216
+
217
+ </div>
218
+
219
+ <?php do_action('pmxe_after_notices_html'); ?>
220
  </div>
221
+ </div>
222
 
223
  <div class="wpallexport-upload-type-container" rel="advanced_type">
224
  <div class="wpallexport-file-type-options">
237
  </select>
238
 
239
  <div class="wpallexport-free-edition-notice wpallexport-user-export-notice" style="margin-bottom: 20px;">
240
+ <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=4206903&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-users">
241
+ <?php _e('The User Export Package is required to Export Users','wp_all_export_plugin');?></a>
242
+ <p><?php _e('If you already own it, remove the WP All Export free edition and install the User Export Package\'s plugins.', 'wp_all_export_plugin'); ?></p>
243
  </div>
244
 
245
  <div class="wpallexport-free-edition-notice wpallexport-comments-export-notice" style="margin-bottom: 20px;">
246
+ <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707173&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-comments">
247
+ <?php _e('Upgrade to the Pro edition of WP All Export to Export Comments','wp_all_export_plugin');?></a>
248
  <p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
249
  </div>
250
 
views/admin/export/options/settings.php CHANGED
@@ -49,7 +49,7 @@
49
  <div class="input" style="margin:5px 0px;">
50
  <input type="hidden" name="allow_client_mode" value="0"/>
51
  <input type="checkbox" disabled="disabled" id="allow_client_mode" name="allow_client_mode"
52
- value="1" <?php echo $post['allow_client_mode'] ? 'checked="checked"' : '' ?> />
53
  <label for="allow_client_mode"><?php _e('Allow non-admins to run this export in Client Mode', 'wp_all_export_plugin') ?></label>
54
  <span>
55
  <a href="#help" class="wpallexport-help" style="position: relative; top: 0;" title="<?php _e('When enabled, users with access to Client Mode will be able to run this export and download the export file. Go to All Export > Settings to give users access to Client Mode. <br><br><strong>Upgrade to the Pro edition of WP All Export to use this option.</strong>'); ?>">?</a>
49
  <div class="input" style="margin:5px 0px;">
50
  <input type="hidden" name="allow_client_mode" value="0"/>
51
  <input type="checkbox" disabled="disabled" id="allow_client_mode" name="allow_client_mode"
52
+ value="1" <?php echo (isset($post['allow_client_mode']) && $post['allow_client_mode']) ? 'checked="checked"' : '' ?> />
53
  <label for="allow_client_mode"><?php _e('Allow non-admins to run this export in Client Mode', 'wp_all_export_plugin') ?></label>
54
  <span>
55
  <a href="#help" class="wpallexport-help" style="position: relative; top: 0;" title="<?php _e('When enabled, users with access to Client Mode will be able to run this export and download the export file. Go to All Export > Settings to give users access to Client Mode. <br><br><strong>Upgrade to the Pro edition of WP All Export to use this option.</strong>'); ?>">?</a>
views/admin/export/process.php CHANGED
@@ -36,7 +36,7 @@
36
  </div>
37
  </div>
38
  <?php
39
- if (XmlExportWooCommerceOrder::$is_active && $update_previous->options['export_type'] == 'specific') {
40
 
41
  $exportList = new PMXE_Export_List();
42
  foreach ($exportList->getBy('parent_id', $update_previous->id)->convertRecords() as $child_export) {
36
  </div>
37
  </div>
38
  <?php
39
+ if (XmlExportEngine::get_addons_service()->isWooCommerceAddonActive() && XmlExportWooCommerceOrder::$is_active && $update_previous->options['export_type'] == 'specific') {
40
 
41
  $exportList = new PMXE_Export_List();
42
  foreach ($exportList->getBy('parent_id', $update_previous->id)->convertRecords() as $child_export) {
views/admin/export/template.php CHANGED
@@ -32,8 +32,8 @@
32
  <table class="wpallexport-layout wpallexport-export-template">
33
  <tr>
34
  <td class="left">
35
-
36
- <?php do_action('pmxe_template_header', $this->isWizard, $post); ?>
37
 
38
  <?php if ($this->errors->get_error_codes()): ?>
39
  <?php $this->error(); ?>
@@ -108,7 +108,7 @@
108
  elseif ($this->isWizard)
109
  {
110
  $new_export = true;
111
- if ( empty($post['cpt']) and ! XmlExportWooCommerceOrder::$is_active and ($addons->isUserAddonActive() && ! XmlExportUser::$is_active) and ! XmlExportComment::$is_active ){
112
  $init_fields[] =
113
  array(
114
  'label' => 'post_type',
@@ -160,7 +160,7 @@
160
  </div>
161
 
162
  <!-- Warning Messages -->
163
- <?php if ( ! XmlExportWooCommerceOrder::$is_active && ! XmlExportComment::$is_active && ! XmlExportTaxonomy::$is_active ) : ?>
164
  <div class="wp-all-export-warning" <?php if ( empty($post['ids']) or count($post['ids']) > 1 ) echo 'style="display:none;"'; ?>>
165
  <p></p>
166
  <input type="hidden" id="warning_template" value="<?php _e("Warning: without %s you won't be able to re-import this data back to this site using WP All Import.", "wp_all_export_plugin"); ?>"/>
@@ -168,11 +168,11 @@
168
  </div>
169
  <?php endif; ?>
170
 
171
- <?php if ( XmlExportWooCommerce::$is_active ) : ?>
172
  <input type="hidden" id="is_product_export" value="1"/>
173
  <?php endif; ?>
174
 
175
- <?php if ( empty($post['cpt']) and ! XmlExportWooCommerceOrder::$is_active and ( $addons->isUserAddonActive() && ! XmlExportUser::$is_active) and ! XmlExportComment::$is_active and ! XmlExportTaxonomy::$is_active ) : ?>
176
  <input type="hidden" id="is_wp_query" value="1"/>
177
  <?php endif; ?>
178
 
@@ -296,7 +296,7 @@
296
  <p><?php _e("You will not be able to reimport data to the product variations, and you will not be able to import these products to another site.", 'wp_all_export_plugin'); ?></p>
297
  </div>
298
  <!-- Display each product in its own row -->
299
- <?php if ( XmlExportWooCommerceOrder::$is_active ): ?>
300
  <div class="input" style="float: left; margin-top: 15px; margin-left:20px;" id="woo_commerce_order">
301
  <input type="hidden" name="order_item_per_row" value="0"/>
302
  <input type="checkbox" id="order_item_per_row" name="order_item_per_row" value="1" <?php if ($post['order_item_per_row']):?>checked="checked"<?php endif; ?> class="switcher"/>
32
  <table class="wpallexport-layout wpallexport-export-template">
33
  <tr>
34
  <td class="left">
35
+
36
+ <?php do_action('pmxe_template_header', $this->isWizard, $post); ?>
37
 
38
  <?php if ($this->errors->get_error_codes()): ?>
39
  <?php $this->error(); ?>
108
  elseif ($this->isWizard)
109
  {
110
  $new_export = true;
111
+ if ( empty($post['cpt']) and $addons->isWooCommerceAddonActive() and ! XmlExportWooCommerceOrder::$is_active and ($addons->isUserAddonActive() and ! XmlExportUser::$is_active) and ! XmlExportComment::$is_active ){
112
  $init_fields[] =
113
  array(
114
  'label' => 'post_type',
160
  </div>
161
 
162
  <!-- Warning Messages -->
163
+ <?php if ( $addons->isWooCommerceAddonActive() && ! XmlExportWooCommerceOrder::$is_active && ! XmlExportComment::$is_active && ! XmlExportTaxonomy::$is_active ) : ?>
164
  <div class="wp-all-export-warning" <?php if ( empty($post['ids']) or count($post['ids']) > 1 ) echo 'style="display:none;"'; ?>>
165
  <p></p>
166
  <input type="hidden" id="warning_template" value="<?php _e("Warning: without %s you won't be able to re-import this data back to this site using WP All Import.", "wp_all_export_plugin"); ?>"/>
168
  </div>
169
  <?php endif; ?>
170
 
171
+ <?php if ( $addons->isWooCommerceAddonActive() && XmlExportWooCommerce::$is_active ) : ?>
172
  <input type="hidden" id="is_product_export" value="1"/>
173
  <?php endif; ?>
174
 
175
+ <?php if ( empty($post['cpt']) and ! ($addons->isWooCommerceAddonActive() && XmlExportWooCommerceOrder::$is_active) and ! ($addons->isUserAddonActive() && XmlExportUser::$is_active) and ! XmlExportComment::$is_active and ! XmlExportTaxonomy::$is_active ) : ?>
176
  <input type="hidden" id="is_wp_query" value="1"/>
177
  <?php endif; ?>
178
 
296
  <p><?php _e("You will not be able to reimport data to the product variations, and you will not be able to import these products to another site.", 'wp_all_export_plugin'); ?></p>
297
  </div>
298
  <!-- Display each product in its own row -->
299
+ <?php if ( ($addons->isWooCommerceAddonActive() && XmlExportWooCommerceOrder::$is_active) ): ?>
300
  <div class="input" style="float: left; margin-top: 15px; margin-left:20px;" id="woo_commerce_order">
301
  <input type="hidden" name="order_item_per_row" value="0"/>
302
  <input type="checkbox" id="order_item_per_row" name="order_item_per_row" value="1" <?php if ($post['order_item_per_row']):?>checked="checked"<?php endif; ?> class="switcher"/>
views/admin/export/variation_options.php CHANGED
@@ -11,20 +11,18 @@ $random = uniqid();
11
  <div class="input" style="display: inline-block; width: 100%;">
12
  <div>
13
  <label>
14
- <input type="radio" class="export_variations <?php if (PMXE_EDITION != 'paid') {
15
  echo "variations_disabled";
16
  } ?>"
17
- value="<?php echo XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_PARENT_AND_VARIATION; ?>" <?php if ($post['export_variations'] == XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_PARENT_AND_VARIATION && PMXE_EDITION == 'paid') { ?> checked="checked" <?php } ?>
18
  name="<?php echo $random?>_export_variations"/><?php _e("Export product variations and their parent products", 'wp_all_export_plugin'); ?>
19
  </label>
20
- <div class="sub-options sub-options-<?php echo XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_PARENT_AND_VARIATION;?>">
21
  <label style="display: block; margin-bottom: 8px;">
22
- <input type="radio"
23
  name="<?php echo $random; ?>_export_variations_title_1"
24
  value="<?php echo XmlExportEngine::VARIATION_USE_PARENT_TITLE; ?>"
25
- <?php if($post['export_variations_title'] == XmlExportEngine::VARIATION_USE_PARENT_TITLE) {?>
26
- checked="checked"
27
- <?php }?>
28
  class="export_variations_title">
29
  <?php _e("Product variations use the parent product title", 'wp_all_export_plugin');?>
30
  </label>
@@ -33,10 +31,8 @@ $random = uniqid();
33
  <input type="radio"
34
  name="<?php echo $random; ?>_export_variations_title_1"
35
  value="<?php echo XmlExportEngine::VARIATION_USE_DEFAULT_TITLE; ?>"
36
- <?php if($post['export_variations_title'] == XmlExportEngine::VARIATION_USE_DEFAULT_TITLE) { ?>
37
- checked="checked"
38
- <?php } ?>
39
- class="export_variations_title">
40
  <?php _e("Product variations use the default variation product title", 'wp_all_export_plugin'); ?>
41
  </label>
42
  </div>
@@ -44,13 +40,13 @@ $random = uniqid();
44
  <div class="clear"></div>
45
  <div style="margin: 6px 0;">
46
  <label>
47
- <input type="radio" class="export_variations"
48
- value="<?php echo XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_VARIATION; ?>" <?php if ($post['export_variations'] == XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_VARIATION || PMXE_EDITION == 'free') { ?> checked="checked" <?php } ?>
49
  name="<?php echo $random; ?>_export_variations"/><?php _e("Only export product variations", 'wp_all_export_plugin'); ?>
50
  </label>
51
  <div class="sub-options sub-options-<?php echo XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_VARIATION; ?>">
52
  <label style="display: block; margin-bottom: 8px;">
53
- <input type="radio"
54
  name="<?php echo $random; ?>_export_variations_title_2"
55
  value="<?php echo XmlExportEngine::VARIATION_USE_PARENT_TITLE; ?>"
56
  <?php if($post['export_variations_title'] == XmlExportEngine::VARIATION_USE_PARENT_TITLE) {?>
@@ -61,7 +57,7 @@ $random = uniqid();
61
  </label>
62
  <div class="clear"></div>
63
  <label>
64
- <input type="radio"
65
  name="<?php echo $random; ?>_export_variations_title_2"
66
  value="<?php echo XmlExportEngine::VARIATION_USE_DEFAULT_TITLE; ?>"
67
  <?php if($post['export_variations_title'] == XmlExportEngine::VARIATION_USE_DEFAULT_TITLE) {?>
@@ -75,13 +71,17 @@ $random = uniqid();
75
  <div class="clear"></div>
76
  <div style="margin: 6px 0;">
77
  <label>
78
- <input type="radio" class="export_variations <?php if (PMXE_EDITION != 'paid') {
79
  echo "variations_disabled";
80
  } ?>"
81
- value="<?php echo XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_PARENT; ?>" <?php if ($post['export_variations'] == XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_PARENT && PMXE_EDITION == 'paid') { ?> checked="checked" <?php } ?>
82
  name="<?php echo $random?>_export_variations"/><?php _e("Only export parent products", 'wp_all_export_plugin'); ?>
83
  </label>
84
  </div>
85
 
 
 
 
 
86
  </div>
87
  </div>
11
  <div class="input" style="display: inline-block; width: 100%;">
12
  <div>
13
  <label>
14
+ <input disabled type="radio" class="export_variations <?php if (PMXE_EDITION != 'paid') {
15
  echo "variations_disabled";
16
  } ?>"
17
+ value="<?php echo XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_PARENT_AND_VARIATION; ?>"
18
  name="<?php echo $random?>_export_variations"/><?php _e("Export product variations and their parent products", 'wp_all_export_plugin'); ?>
19
  </label>
20
+ <div style="display: none;" class="sub-options sub-options-<?php echo XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_PARENT_AND_VARIATION;?>">
21
  <label style="display: block; margin-bottom: 8px;">
22
+ <input type="radio" disabled
23
  name="<?php echo $random; ?>_export_variations_title_1"
24
  value="<?php echo XmlExportEngine::VARIATION_USE_PARENT_TITLE; ?>"
25
+
 
 
26
  class="export_variations_title">
27
  <?php _e("Product variations use the parent product title", 'wp_all_export_plugin');?>
28
  </label>
31
  <input type="radio"
32
  name="<?php echo $random; ?>_export_variations_title_1"
33
  value="<?php echo XmlExportEngine::VARIATION_USE_DEFAULT_TITLE; ?>"
34
+
35
+ class="export_variations_title" disabled>
 
 
36
  <?php _e("Product variations use the default variation product title", 'wp_all_export_plugin'); ?>
37
  </label>
38
  </div>
40
  <div class="clear"></div>
41
  <div style="margin: 6px 0;">
42
  <label>
43
+ <input disabled type="radio" class="export_variations"
44
+ value="<?php echo XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_VARIATION; ?>"
45
  name="<?php echo $random; ?>_export_variations"/><?php _e("Only export product variations", 'wp_all_export_plugin'); ?>
46
  </label>
47
  <div class="sub-options sub-options-<?php echo XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_VARIATION; ?>">
48
  <label style="display: block; margin-bottom: 8px;">
49
+ <input disabled type="radio"
50
  name="<?php echo $random; ?>_export_variations_title_2"
51
  value="<?php echo XmlExportEngine::VARIATION_USE_PARENT_TITLE; ?>"
52
  <?php if($post['export_variations_title'] == XmlExportEngine::VARIATION_USE_PARENT_TITLE) {?>
57
  </label>
58
  <div class="clear"></div>
59
  <label>
60
+ <input disabled type="radio"
61
  name="<?php echo $random; ?>_export_variations_title_2"
62
  value="<?php echo XmlExportEngine::VARIATION_USE_DEFAULT_TITLE; ?>"
63
  <?php if($post['export_variations_title'] == XmlExportEngine::VARIATION_USE_DEFAULT_TITLE) {?>
71
  <div class="clear"></div>
72
  <div style="margin: 6px 0;">
73
  <label>
74
+ <input type="radio" disabled class="export_variations <?php if (PMXE_EDITION != 'paid') {
75
  echo "variations_disabled";
76
  } ?>"
77
+ value="<?php echo XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_PARENT; ?>"
78
  name="<?php echo $random?>_export_variations"/><?php _e("Only export parent products", 'wp_all_export_plugin'); ?>
79
  </label>
80
  </div>
81
 
82
+ <div class="wpallexport-free-edition-notice" style="padding: 20px; margin-bottom: 10px;">
83
+ <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&amp;download_id=2707173&amp;edd_options%5Bprice_id%5D=1&amp;utm_source=export-plugin-free&amp;utm_medium=upgrade-notice&amp;utm_campaign=variation_options">Upgrade to the Pro edition of WP All Export to filter variable products</a>
84
+ <p>If you already own it, remove the free edition and install the Pro edition.</p>
85
+ </div>
86
  </div>
87
  </div>
views/admin/export/variation_options_common.php CHANGED
@@ -6,7 +6,7 @@
6
  var exportVariations = $('#export_variations').val();
7
  var exportVariationsTitle = $('#export_variations_title').val();
8
 
9
- $('.sub-options-' + exportVariations).css('display', 'block');
10
  }
11
 
12
  $('.export_variations').change(function () {
6
  var exportVariations = $('#export_variations').val();
7
  var exportVariationsTitle = $('#export_variations_title').val();
8
 
9
+ //$('.sub-options-' + exportVariations).css('display', 'block');
10
  }
11
 
12
  $('.export_variations').change(function () {
views/admin/help/index.php CHANGED
File without changes
views/admin/manage/index.php CHANGED
@@ -22,7 +22,6 @@ $addons = new \Wpae\App\Service\Addons\AddonService();
22
  })(jQuery, ajaxurl, wp_all_export_security);
23
  </script>
24
  <!-- END TO DO -->
25
- <a class="test">Test</a>
26
  <h2></h2> <!-- Do not remove -->
27
 
28
  <script type="text/javascript">
@@ -193,23 +192,46 @@ $columns = apply_filters('pmxe_manage_imports_columns', $columns);
193
  case 'info':
194
  ?>
195
  <td style="min-width: 180px;">
196
- <a <?php
197
- if (!is_array($item['options']['cpt'])) {
198
- $item['options']['cpt'] = array($item['options']['cpt']);
199
- }
200
- if (
201
- ((in_array('users', $item['options']['cpt']) || in_array('shop_customer', $item['options']['cpt'])) && !$addons->isUserAddonActive()) ||
202
- ($item['options']['export_type'] == 'advanced' && $item['options']['wp_query_selector'] == 'wp_user_query' && !$addons->isUserAddonActive())
203
- ) {
204
- ?>
205
- href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'update'), $this->baseUrl)) ?>"
206
- <?php
207
- } else {
208
- ?>
209
- href="#" class="open_cron_scheduling"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  <?php } ?>
211
- data-itemid="<?php echo $item['id']; ?>"><?php _e('Scheduling Options', 'wp_all_export_plugin'); ?></a>
212
- <br>
213
  <?php
214
  $is_re_import_allowed = true;
215
  if ( ! empty($item['options']['ids']) )
22
  })(jQuery, ajaxurl, wp_all_export_security);
23
  </script>
24
  <!-- END TO DO -->
 
25
  <h2></h2> <!-- Do not remove -->
26
 
27
  <script type="text/javascript">
192
  case 'info':
193
  ?>
194
  <td style="min-width: 180px;">
195
+ <?php if (current_user_can(PMXE_Plugin::$capabilities)) { ?>
196
+ <a
197
+ <?php
198
+ if (!is_array($item['options']['cpt'])) {
199
+ $item['options']['cpt'] = array($item['options']['cpt']);
200
+ }
201
+ // Disable scheduling options for User exports if User Export Add-On isn't enabled
202
+ if (
203
+ ((in_array('users', $item['options']['cpt']) || in_array('shop_customer', $item['options']['cpt'])) && !$addons->isUserAddonActive()) ||
204
+ ($item['options']['export_type'] == 'advanced' && $item['options']['wp_query_selector'] == 'wp_user_query' && !$addons->isUserAddonActive())
205
+ ) {
206
+ ?>
207
+ href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'options'), $this->baseUrl)) ?>"
208
+ <?php
209
+ // Disable scheduling options for WooCo exports if WooCo Export Add-On isn't enabled
210
+ } else if (
211
+ (( (in_array('product', $item['options']['cpt']) && in_array('product_variation', $item['options']['cpt'])) || in_array('shop_order', $item['options']['cpt']) || in_array('shop_coupon', $item['options']['cpt']) || in_array('shop_review', $item['options']['cpt']) ) && !$addons->isWooCommerceAddonActive())
212
+ ||
213
+ ($item['options']['export_type'] == 'advanced' && in_array($item['options']['exportquery']->query['post_type'], array(array('product', 'product_variation'), 'shop_order', 'shop_coupon')) && !$addons->isWooCommerceAddonActive())
214
+ ) {
215
+ ?>
216
+ href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'options'), $this->baseUrl)) ?>"
217
+ <?php
218
+ // Disable scheduling options for ACF exports if ACF Export Add-On isn't enabled
219
+ } else if (
220
+ ((!in_array('comments', $item['options']['cpt']) || !in_array('shop_review', $item['options']['cpt'])) && in_array('acf', $item['options']['cc_type']) && !$addons->isAcfAddonActive()) ||
221
+ ($item['options']['export_type'] == 'advanced' && $item['options']['wp_query_selector'] != 'wp_comment_query' && in_array('acf', $item['options']['cc_type']) && !$addons->isAcfAddonActive())
222
+ ) {
223
+ ?>
224
+ href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'options'), $this->baseUrl)) ?>"
225
+ <?php
226
+ } else {
227
+
228
+ ?>
229
+ href="javascript:void(0);" class="open_cron_scheduling"
230
+
231
+ <?php } ?>
232
+ data-itemid="<?php echo $item['id']; ?>"><?php _e('Scheduling Options', 'wp_all_export_plugin'); ?></a>
233
+ <br>
234
  <?php } ?>
 
 
235
  <?php
236
  $is_re_import_allowed = true;
237
  if ( ! empty($item['options']['ids']) )
views/admin/settings/index.php CHANGED
File without changes
views/controller/error.php CHANGED
File without changes
wp-all-export.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP All Export
4
  Plugin URI: http://www.wpallimport.com/upgrade-to-wp-all-export-pro/?utm_source=export-plugin-free&utm_medium=wp-plugins-page&utm_campaign=upgrade-to-pro
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.2.10
7
  Author: Soflyy
8
  */
9
 
@@ -59,14 +59,12 @@ else {
59
  */
60
  define('PMXE_PREFIX', 'pmxe_');
61
 
62
- define('PMXE_VERSION', '1.2.10');
63
 
64
  define('PMXE_ASSETS_VERSION', '-1.0.1');
65
 
66
  define('PMXE_EDITION', 'free');
67
 
68
- define('PMXE_USE_NAMESPACES', true);
69
-
70
  /**
71
  * Plugin root uploads folder name
72
  * @var string
@@ -159,6 +157,9 @@ else {
159
 
160
  private static $hasActiveSchedulingLicense = null;
161
 
 
 
 
162
  public static $cache_key = '';
163
 
164
  /**
@@ -188,6 +189,8 @@ else {
188
  require_once $filePath;
189
  }
190
 
 
 
191
  // init plugin options
192
  $option_name = get_class($this) . '_Options';
193
  $options_default = PMXE_Config::createFromFile(self::ROOT_DIR . '/config/options.php')->toArray();
@@ -234,12 +237,10 @@ else {
234
  }
235
 
236
  // register admin page pre-dispatcher
237
- add_action('admin_init', array($this, 'adminInit'));
238
- add_action('admin_init', array($this, 'fix_db_schema'));
239
  add_action('init', array($this, 'init'));
240
 
241
- add_action( 'after_plugin_row_wp-all-export/wp-all-export.php', array($this,'custom_update_message'), 10, 3 );
242
-
243
  }
244
 
245
  /**
@@ -364,7 +365,10 @@ else {
364
  */
365
  public function adminInit() {
366
 
367
- if ( current_user_can( 'manage_options' ) && (!XmlExportEngine::get_addons_service()->isAcfAddonActive() || !XmlExportEngine::get_addons_service()->isWooCommerceAddonActive())){
 
 
 
368
 
369
  $website = get_site_url();
370
  $salt = "datacaptain";
@@ -373,10 +377,10 @@ else {
373
 
374
  $wpae_add_on_discount_link = "https://www.wpallimport.com?discount-site=" . urlencode( $website ) . "&discount-hash=" . $hash . "&discount-item=" . $product;
375
 
376
- $this->showDismissibleNotice( '<h1 style="padding-top:0">Important Notice Regarding WP All Export</h1><br><strong>WP All Export will soon receive an update requiring paid add-ons to export ACF and WooCommerce data.<br/>We are providing these Pro add-ons to all current users of WP All Export, free of charge.
377
  <br/><br/>
378
  <a href="'.$wpae_add_on_discount_link.'&utm_source=export-plugin-free&utm_medium=wpae-addons-notice&utm_campaign=free-export-acf-woo-add-ons
379
- " target="_blank">Click here to download your free Pro add-ons.</a></strong>', 'wpae_free_pro_woocommerce_addon_notice' );
380
  }
381
 
382
  // create history folder
@@ -402,6 +406,19 @@ else {
402
  $this->showNoticeAndDisablePlugin(sprintf(__('Uploads folder %s must be writable', 'wp_all_export_plugin'), $uploads['basedir'] . DIRECTORY_SEPARATOR . self::UPLOADS_DIRECTORY));
403
  }
404
 
 
 
 
 
 
 
 
 
 
 
 
 
 
405
 
406
  self::$session = new PMXE_Handler();
407
 
@@ -456,12 +473,36 @@ else {
456
  $cpt = array($cpt);
457
  }
458
 
 
 
 
 
 
 
 
 
 
 
 
 
 
459
  if (
460
  ((in_array('users', $cpt) || in_array('shop_customer', $cpt)) && !$addons->isUserAddonActive()) ||
461
  ($export->options['export_type'] == 'advanced' && $export->options['wp_query_selector'] == 'wp_user_query' && !$addons->isUserAddonActive())
462
  ) {
463
  die(\__('The User Export Add-On Pro is required to run this export. You can download the add-on here: <a href="http://www.wpallimport.com/portal/" target="_blank">http://www.wpallimport.com/portal/</a>', \PMXE_Plugin::LANGUAGE_DOMAIN));
464
  }
 
 
 
 
 
 
 
 
 
 
 
465
  }
466
 
467
 
@@ -709,7 +750,15 @@ else {
709
  public function fix_db_schema(){
710
 
711
  global $wpdb;
712
- $installed_ver = get_option( "wp_all_export_db_version" );
 
 
 
 
 
 
 
 
713
 
714
  if ( $installed_ver == PMXE_VERSION ) return true;
715
 
@@ -768,7 +817,7 @@ else {
768
  $wpdb->query("ALTER TABLE {$table} ADD `export_post_type` TEXT NOT NULL DEFAULT '';");
769
  }
770
 
771
- update_option( "wp_all_export_db_version", PMXE_VERSION );
772
  }
773
 
774
  /**
@@ -947,28 +996,6 @@ else {
947
  }
948
  return $subject;
949
  }
950
-
951
- public function custom_update_message( $file, $plugin, $status ) {
952
-
953
- if ( ! XmlExportEngine::get_addons_service()->isAcfAddonActive() || ! XmlExportEngine::get_addons_service()->isWooCommerceAddonActive() ) {
954
- $website = get_site_url();
955
- $salt = "datacaptain";
956
- $hash = base64_encode( $website . $salt );
957
- $product = "wpae-free-upgrade";
958
-
959
- $wpae_add_on_discount_link = "https://www.wpallimport.com?discount-site=" . urlencode( $website ) . "&discount-hash=" . $hash . "&discount-item=" . $product;
960
-
961
- $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
962
- printf(
963
- '<tr class="plugin-update-tr"><td colspan="%s" class="plugin-update update-message notice inline notice-warning notice-alt"><div class="update-message"><h4 style="margin: 0; font-size: 14px;">%s</h4>%s</div></td></tr>',
964
- $wp_list_table->get_column_count(),
965
- '',
966
- '<br/><h1 style="padding-top:0">Important Notice Regarding WP All Export</h1><br><strong>WP All Export will soon receive an update requiring paid add-ons to export ACF and WooCommerce data.<br/>We are providing these Pro add-ons to all current users of WP All Export, free of charge.
967
- <br/><br/>
968
- <a href="' . $wpae_add_on_discount_link . '&utm_source=export-plugin-free&utm_medium=wpae-addons-notice&utm_campaign=free-export-acf-woo-add-ons" target="_blank">Click here to download your free Pro add-ons.</a>'
969
- );
970
- }
971
- }
972
  }
973
 
974
  PMXE_Plugin::getInstance();
3
  Plugin Name: WP All Export
4
  Plugin URI: http://www.wpallimport.com/upgrade-to-wp-all-export-pro/?utm_source=export-plugin-free&utm_medium=wp-plugins-page&utm_campaign=upgrade-to-pro
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.3.0
7
  Author: Soflyy
8
  */
9
 
59
  */
60
  define('PMXE_PREFIX', 'pmxe_');
61
 
62
+ define('PMXE_VERSION', '1.3.0');
63
 
64
  define('PMXE_ASSETS_VERSION', '-1.0.1');
65
 
66
  define('PMXE_EDITION', 'free');
67
 
 
 
68
  /**
69
  * Plugin root uploads folder name
70
  * @var string
157
 
158
  private static $hasActiveSchedulingLicense = null;
159
 
160
+ /** @var \Wpae\App\Service\Addons\AddonService */
161
+ private $addons;
162
+
163
  public static $cache_key = '';
164
 
165
  /**
189
  require_once $filePath;
190
  }
191
 
192
+ $this->addons = new \Wpae\App\Service\Addons\AddonService();
193
+
194
  // init plugin options
195
  $option_name = get_class($this) . '_Options';
196
  $options_default = PMXE_Config::createFromFile(self::ROOT_DIR . '/config/options.php')->toArray();
237
  }
238
 
239
  // register admin page pre-dispatcher
240
+ add_action('admin_init', array($this, 'adminInit'), 11);
241
+ add_action('admin_init', array($this, 'fix_db_schema'), 10);
242
  add_action('init', array($this, 'init'));
243
 
 
 
244
  }
245
 
246
  /**
365
  */
366
  public function adminInit() {
367
 
368
+ $addons_not_included = get_option('wp_all_export_free_addons_not_included',false);
369
+
370
+
371
+ if ( !get_option('wp_all_export_free_addons_not_included',false) && current_user_can( 'manage_options' ) && (!XmlExportEngine::get_addons_service()->isAcfAddonActive() || !XmlExportEngine::get_addons_service()->isWooCommerceAddonActive())){
372
 
373
  $website = get_site_url();
374
  $salt = "datacaptain";
377
 
378
  $wpae_add_on_discount_link = "https://www.wpallimport.com?discount-site=" . urlencode( $website ) . "&discount-hash=" . $hash . "&discount-item=" . $product;
379
 
380
+ $this->showDismissibleNotice( '<h1 style="padding-top:0">Important Notice Regarding WP All Export</h1><br><strong>WP All Export now requires paid add-ons to export ACF and WooCommerce data.<br/>We are providing these Pro add-ons to everyone who was using WP All Export before the change, free of charge.
381
  <br/><br/>
382
  <a href="'.$wpae_add_on_discount_link.'&utm_source=export-plugin-free&utm_medium=wpae-addons-notice&utm_campaign=free-export-acf-woo-add-ons
383
+ " target="_blank">Click here to download your free Pro add-ons.</a></strong>', 'wpae_free_export_addons_notice' );
384
  }
385
 
386
  // create history folder
406
  $this->showNoticeAndDisablePlugin(sprintf(__('Uploads folder %s must be writable', 'wp_all_export_plugin'), $uploads['basedir'] . DIRECTORY_SEPARATOR . self::UPLOADS_DIRECTORY));
407
  }
408
 
409
+ if (!$addons_not_included && $this->addons->userExportsExistAndAddonNotInstalled() && current_user_can('manage_options')) {
410
+ $this->showDismissibleNotice(__('<strong style="font-size:16px">A Configured Export Requires the User Export Add-On</strong><p>Your User exports will not be able to run until you install the User Export Add-On. That add-on is available from <a href="https://wordpress.org/plugins/export-wp-users-xml-csv/" target="_blank">wordpress.org</a>.</p>', PMXE_Plugin::LANGUAGE_DOMAIN), 'wpae_user_addon_not_installed_notice');
411
+ }
412
+
413
+ if (!$addons_not_included && $this->addons->wooCommerceExportsExistAndAddonNotInstalled() && current_user_can('manage_options')) {
414
+ $this->showDismissibleNotice(__('<strong style="font-size:16px">A Configured Export Requires the WooCommerce Export Add-On Pro</strong><p>Your Products, Orders, and Coupons exports will not be able to run until you install the WooCommerce Export Add-On Pro. That add-on is available to those who were using WP All Export Free before this requirement.</p>', PMXE_Plugin::LANGUAGE_DOMAIN)
415
+ . '<p><a class="button button-primary" href="https://wpallimport.com/portal/downloads" target="_blank">' . __('Download Add-On', PMXE_Plugin::LANGUAGE_DOMAIN) . '</a></p>', 'wpae_woocommerce_addon_not_installed_notice');
416
+ }
417
+
418
+ if (!$addons_not_included && $this->addons->acfExportsExistAndNotInstalled() && current_user_can('manage_options')) {
419
+ $this->showDismissibleNotice(__('<strong style="font-size:16px">A Configured Export Requires the ACF Export Add-On Pro</strong><p>Exports that contain ACF fields will not be able to run until you install the ACF Export Add-On Pro. That add-on is available to those who were using WP All Export Free before this requirement.</p>', PMXE_Plugin::LANGUAGE_DOMAIN)
420
+ . '<p><a class="button button-primary" href="https://wpallimport.com/portal/downloads" target="_blank">' . __('Download Add-On', PMXE_Plugin::LANGUAGE_DOMAIN) . '</a></p>', 'wpae_acf_addon_not_installed_notice');
421
+ }
422
 
423
  self::$session = new PMXE_Handler();
424
 
473
  $cpt = array($cpt);
474
  }
475
 
476
+ if(isset($export->options['export_type']) && $export->options['export_type'] === 'advanced') {
477
+
478
+ if(!XmlExportEngine::get_addons_service()->isWooCommerceAddonActive() && strpos($export->options['wp_query'], 'product') !== false) {
479
+ die(\__('The WooCommerce Export Add-On Pro is required to run this export. If you already own it, you can download the add-on here: <a href="http://www.wpallimport.com/portal/downloads" target="_blank">http://www.wpallimport.com/portal/downloads</a>', \PMXE_Plugin::LANGUAGE_DOMAIN));
480
+ }
481
+ else if(!XmlExportEngine::get_addons_service()->isWooCommerceAddonActive() && strpos($export->options['wp_query'], 'shop_order') !== false) {
482
+ die(\__('The WooCommerce Export Add-On Pro is required to run this export. If you already own it, you can download the add-on here: <a href="http://www.wpallimport.com/portal/downloads" target="_blank">http://www.wpallimport.com/portal/downloads</a>', \PMXE_Plugin::LANGUAGE_DOMAIN));
483
+ }
484
+ else if(!XmlExportEngine::get_addons_service()->isWooCommerceAddonActive() && strpos($export->options['wp_query'], 'shop_coupon') !== false) {
485
+ die(\__('The WooCommerce Export Add-On Pro is required to run this export. If you already own it, you can download the add-on here: <a href="http://www.wpallimport.com/portal/downloads" target="_blank">http://www.wpallimport.com/portal/downloads</a>', \PMXE_Plugin::LANGUAGE_DOMAIN));
486
+ }
487
+ }
488
+
489
  if (
490
  ((in_array('users', $cpt) || in_array('shop_customer', $cpt)) && !$addons->isUserAddonActive()) ||
491
  ($export->options['export_type'] == 'advanced' && $export->options['wp_query_selector'] == 'wp_user_query' && !$addons->isUserAddonActive())
492
  ) {
493
  die(\__('The User Export Add-On Pro is required to run this export. You can download the add-on here: <a href="http://www.wpallimport.com/portal/" target="_blank">http://www.wpallimport.com/portal/</a>', \PMXE_Plugin::LANGUAGE_DOMAIN));
494
  }
495
+
496
+ if (
497
+ ((in_array('product', $cpt) || in_array('shop_order', $cpt) || in_array('shop_review', $cpt) || in_array('shop_coupon', $cpt)) && !$addons->isWooCommerceAddonActive()) ||
498
+ ($export->options['export_type'] == 'advanced' && $export->options['wp_query_selector'] == 'wp_user_query' && !$addons->isUserAddonActive())
499
+ ) {
500
+ die(\__('The WooCommerce Export Add-On Pro is required to run this export. You can download the add-on here: <a href="http://www.wpallimport.com/portal/" target="_blank">http://www.wpallimport.com/portal/</a>', \PMXE_Plugin::LANGUAGE_DOMAIN));
501
+ }
502
+
503
+ if(in_array('acf', $export->options['cc_type']) && !$addons->isAcfAddonActive()) {
504
+ die(\__('The ACF Export Add-On Pro is required to run this export. You can download the add-on here: <a href="http://www.wpallimport.com/portal/" target="_blank">http://www.wpallimport.com/portal/</a>', \PMXE_Plugin::LANGUAGE_DOMAIN));
505
+ }
506
  }
507
 
508
 
750
  public function fix_db_schema(){
751
 
752
  global $wpdb;
753
+
754
+ $db_version_old = get_option('wp_all_export_db_version');
755
+ $installed_ver = get_option('wp_all_export_free_db_version');
756
+
757
+ // We leave the old option so if it doesn't exist then this was installed after the export addons release.
758
+ // If it does exist we make sure it's not a Pro version.
759
+ if(!$db_version_old || version_compare($db_version_old, '1.2.10') == 1) {
760
+ update_option("wp_all_export_free_addons_not_included", true);
761
+ }
762
 
763
  if ( $installed_ver == PMXE_VERSION ) return true;
764
 
817
  $wpdb->query("ALTER TABLE {$table} ADD `export_post_type` TEXT NOT NULL DEFAULT '';");
818
  }
819
 
820
+ update_option( "wp_all_export_free_db_version", PMXE_VERSION );
821
  }
822
 
823
  /**
996
  }
997
  return $subject;
998
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
999
  }
1000
 
1001
  PMXE_Plugin::getInstance();