Export WordPress data to XML/CSV - Version 1.0.0

Version Description

  • WP All Export exits beta
Download this release

Release Info

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

Code changes from version 0.9.1 to 1.0.0

Files changed (177) hide show
  1. actions/admin_head.php +22 -0
  2. actions/admin_init.php +0 -0
  3. actions/admin_menu.php +6 -4
  4. actions/admin_notices.php +1 -12
  5. actions/plugins_loaded.php +0 -9
  6. actions/wp.php +0 -7
  7. actions/wp_ajax_export.php +0 -403
  8. actions/wp_ajax_export_available_rules.php +57 -0
  9. actions/wp_ajax_export_filtering.php +143 -0
  10. actions/wp_ajax_export_filtering_count.php +59 -0
  11. actions/wp_ajax_export_preview.php +137 -0
  12. actions/wp_ajax_wpallexport.php +390 -0
  13. actions/wp_loaded.php +2 -0
  14. actions/wp_session_garbage_collection.php +0 -65
  15. classes/arrayaccess.php +0 -141
  16. classes/config.php +0 -0
  17. classes/download.php +0 -0
  18. classes/handler.php +132 -0
  19. classes/helper.php +0 -0
  20. classes/input.php +8 -1
  21. classes/session.php +91 -366
  22. config/options.php +6 -2
  23. controllers/admin/export.php +294 -63
  24. controllers/admin/feedback.php +12 -0
  25. controllers/admin/help.php +0 -0
  26. controllers/admin/manage.php +328 -0
  27. controllers/admin/settings.php +13 -7
  28. controllers/controller.php +51 -14
  29. controllers/controller/admin.php +4 -1
  30. filters/.gitkeep +0 -0
  31. filters/wp_all_import_is_exported_file_valid.php +65 -0
  32. filters/wpallexport_custom_types.php +7 -0
  33. helpers/backward.php +0 -0
  34. helpers/get_taxonomies_by_object_type.php +25 -0
  35. helpers/pmxe_export_acf_field_csv.php +369 -0
  36. helpers/pmxe_export_acf_field_xml.php +345 -0
  37. helpers/pmxe_export_csv.php +589 -0
  38. helpers/pmxe_export_xml.php +432 -0
  39. helpers/pmxe_filter.php +4 -0
  40. helpers/pmxe_functions.php +14 -69
  41. helpers/pmxe_render_xml_attributes.php +7 -0
  42. helpers/pmxe_render_xml_element.php +55 -0
  43. helpers/pmxe_render_xml_text.php +21 -0
  44. helpers/str_getcsv.php +0 -0
  45. helpers/wp_all_export_check_children_assign.php +15 -0
  46. helpers/wp_all_export_get_cpt_name.php +27 -0
  47. helpers/wp_all_export_is_compatible.php +4 -0
  48. helpers/wp_all_export_prepare_template_csv.php +510 -0
  49. helpers/wp_all_export_prepare_template_xml.php +470 -0
  50. helpers/wp_all_export_rand_char.php +11 -0
  51. helpers/wp_all_export_remove_colons.php +27 -0
  52. helpers/wp_all_export_remove_source.php +22 -0
  53. helpers/wp_all_export_reverse_rules_html.php +40 -0
  54. helpers/wp_all_export_rmdir.php +13 -0
  55. helpers/wp_all_export_secure_file.php +23 -0
  56. helpers/wp_all_export_url_title.php +42 -0
  57. helpers/wp_redirect_or_javascript.php +0 -0
  58. libraries/.gitkeep +0 -0
  59. libraries/XmlExportACF.php +246 -0
  60. libraries/XmlExportEngine.php +515 -0
  61. libraries/XmlExportUser.php +354 -0
  62. libraries/XmlExportWooCommerce.php +551 -0
  63. libraries/XmlExportWooCommerceOrder.php +550 -0
  64. models/export/list.php +2 -2
  65. models/export/record.php +30 -20
  66. models/model.php +0 -0
  67. models/model/list.php +0 -0
  68. models/model/record.php +0 -0
  69. plugin.php +0 -520
  70. readme.txt +45 -19
  71. schema.php +19 -1
  72. screenshot-1.png +0 -0
  73. screenshot-2.png +0 -0
  74. sessions/.gitkeep +0 -0
  75. shortcodes/.gitkeep +0 -0
  76. static/css/admin-ie.css +0 -0
  77. static/css/admin-wp-3.8.css +0 -0
  78. static/css/admin.css +3166 -1039
  79. static/img/add-ons/acf-thumb.jpg +0 -0
  80. static/img/add-ons/woo-commerce-thumb.jpg +0 -0
  81. static/img/back.png +0 -0
  82. static/img/collapser.png +0 -0
  83. static/img/continue.png +0 -0
  84. static/img/date-picker.gif +0 -0
  85. static/img/down.gif +0 -0
  86. static/img/drag.png +0 -0
  87. static/img/elements.png +0 -0
  88. static/img/help.png +0 -0
  89. static/img/ico-add-new.png +0 -0
  90. static/img/ico-remove.png +0 -0
  91. static/img/import-templates.png +0 -0
  92. static/img/left_btn.png +0 -0
  93. static/img/list.png +0 -0
  94. static/img/loading.png +0 -0
  95. static/img/logo.png +0 -0
  96. static/img/preloader.png +0 -0
  97. static/img/progress_animated.gif +0 -0
  98. static/img/remove.png +0 -0
  99. static/img/right_btn.png +0 -0
  100. static/img/rule.png +0 -0
  101. static/img/screen-options-right-up.gif +0 -0
  102. static/img/screen-options-right.gif +0 -0
  103. static/img/soflyy-logo.png +0 -0
  104. static/img/stars.png +0 -0
  105. static/img/trash.png +0 -0
  106. static/img/xmlicon.png +0 -0
  107. static/js/admin.js +1076 -76
  108. static/js/jquery/chosen.jquery.js +1263 -0
  109. static/js/jquery/chosen.jquery.min.js +2 -0
  110. static/js/jquery/css/chosen/chosen-sprite.png +0 -0
  111. static/js/jquery/css/chosen/chosen-sprite@2x.png +0 -0
  112. static/js/jquery/css/chosen/chosen.css +450 -0
  113. static/js/jquery/css/redmond/images/animated-overlay.gif +0 -0
  114. static/js/jquery/css/redmond/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  115. static/js/jquery/css/redmond/images/ui-bg_flat_0_aaaaaa_40x100_1.png +0 -0
  116. static/js/jquery/css/redmond/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
  117. static/js/jquery/css/redmond/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  118. static/js/jquery/css/redmond/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  119. static/js/jquery/css/redmond/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  120. static/js/jquery/css/redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  121. static/js/jquery/css/redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  122. static/js/jquery/css/redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  123. static/js/jquery/css/redmond/images/ui-icons_217bc0_256x240.png +0 -0
  124. static/js/jquery/css/redmond/images/ui-icons_2e83ff_256x240.png +0 -0
  125. static/js/jquery/css/redmond/images/ui-icons_469bdd_256x240.png +0 -0
  126. static/js/jquery/css/redmond/images/ui-icons_6da8d5_256x240.png +0 -0
  127. static/js/jquery/css/redmond/images/ui-icons_cd0a0a_256x240.png +0 -0
  128. static/js/jquery/css/redmond/images/ui-icons_d8e7f3_256x240.png +0 -0
  129. static/js/jquery/css/redmond/images/ui-icons_f9bd01_256x240.png +0 -0
  130. static/js/jquery/css/redmond/jquery-ui.css +0 -0
  131. static/js/jquery/css/select2/select2-bootstrap.css +0 -0
  132. static/js/jquery/css/select2/select2-spinner.gif +0 -0
  133. static/js/jquery/css/select2/select2.css +0 -0
  134. static/js/jquery/css/select2/select2.png +0 -0
  135. static/js/jquery/css/smoothness/images/tipsy.gif +0 -0
  136. static/js/jquery/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  137. static/js/jquery/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  138. static/js/jquery/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  139. static/js/jquery/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  140. static/js/jquery/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  141. static/js/jquery/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  142. static/js/jquery/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  143. static/js/jquery/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  144. static/js/jquery/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
  145. static/js/jquery/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  146. static/js/jquery/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
  147. static/js/jquery/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
  148. static/js/jquery/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  149. static/js/jquery/css/smoothness/jquery-ui.css +0 -0
  150. static/js/jquery/css/smoothness/jquery.tipsy.css +1 -1
  151. static/js/jquery/jquery.ddslick.min.js +1 -0
  152. static/js/jquery/{jquery.mjs.nestedSortable.js → jquery.mjs.pmxe_nestedSortable.js} +13 -10
  153. static/js/jquery/jquery.tipsy.js +0 -0
  154. static/js/jquery/moment.js +0 -0
  155. static/js/jquery/select2.min.js +0 -0
  156. static/js/jquery/ui.autocomplete.js +0 -0
  157. static/js/jquery/ui.datepicker.js +0 -0
  158. static/js/pmxe.js +0 -0
  159. views/admin/export/element.php +0 -183
  160. views/admin/export/index.php +119 -56
  161. views/admin/export/options.php +245 -0
  162. views/admin/export/process.php +115 -27
  163. views/admin/export/template.php +273 -0
  164. views/admin/export/template/new_field_cpt.php +126 -0
  165. views/admin/export/template/new_field_shop_order.php +73 -0
  166. views/admin/export/template/new_field_user.php +97 -0
  167. views/admin/feedback/index.php +29 -0
  168. views/admin/help/index.php +24 -12
  169. views/admin/manage/bulk.php +17 -0
  170. views/admin/manage/delete.php +11 -0
  171. views/admin/manage/index.php +355 -0
  172. views/admin/manage/scheduling.php +57 -0
  173. views/admin/manage/templates.php +19 -0
  174. views/admin/manage/update.php +16 -0
  175. views/admin/settings/index.php +51 -13
  176. views/controller/error.php +0 -0
  177. wp-all-export.php +606 -0
actions/admin_head.php ADDED
@@ -0,0 +1,22 @@
1
+ <?php
2
+ function pmxe_admin_head(){
3
+ $input = new PMXE_Input();
4
+ $export_id = $input->get('id', false);
5
+ $export_action = $input->get('action', false);
6
+ if ($export_id){
7
+ ?>
8
+ <script type="text/javascript">
9
+ var export_id = '<?php echo $export_id; ?>';
10
+ </script>
11
+ <?php
12
+ }
13
+
14
+ $wp_all_export_ajax_nonce = wp_create_nonce( "wp_all_export_secure" );
15
+
16
+ ?>
17
+ <script type="text/javascript">
18
+ var export_action = '<?php echo $export_action; ?>';
19
+ var wp_all_export_security = '<?php echo $wp_all_export_ajax_nonce; ?>';
20
+ </script>
21
+ <?php
22
+ }
actions/admin_init.php CHANGED
File without changes
actions/admin_menu.php CHANGED
@@ -8,12 +8,14 @@ function pmxe_admin_menu() {
8
9
if (current_user_can('manage_options')) { // admin management options
10
11
- add_menu_page(__('WP All Export', 'pmxe_plugin'), __('All Export', 'pmxe_plugin'), 'manage_options', 'pmxe-admin-home', array(PMXE_Plugin::getInstance(), 'adminDispatcher'), PMXE_Plugin::ROOT_URL . '/static/img/xmlicon.png');
12
// workaround to rename 1st option to `Home`
13
$submenu['pmxe-admin-home'] = array();
14
- add_submenu_page('pmxe-admin-home', __('Export to XML', 'pmxe_plugin') . ' &lsaquo; ' . __('WP All Export', 'pmxe_plugin'), __('New Export', 'pmxe_plugin'), 'manage_options', 'pmxe-admin-export', array(PMXE_Plugin::getInstance(), 'adminDispatcher'));
15
- add_submenu_page('pmxe-admin-home', __('Settings', 'pmxe_plugin') . ' &lsaquo; ' . __('WP All Export', 'pmxe_plugin'), __('Settings', 'pmxe_plugin'), 'manage_options', 'pmxe-admin-settings', array(PMXE_Plugin::getInstance(), 'adminDispatcher'));
16
- add_submenu_page('pmxe-admin-home', __('Support', 'pmxe_plugin') . ' &lsaquo; ' . __('WP All Export', 'pmxe_plugin'), __('Support', 'pmxe_plugin'), 'manage_options', 'pmxe-admin-help', array(PMXE_Plugin::getInstance(), 'adminDispatcher'));
17
18
}
19
}
8
9
if (current_user_can('manage_options')) { // admin management options
10
11
+ add_menu_page(__('WP All Export', 'wp_all_export_plugin'), __('All Export', 'wp_all_export_plugin'), 'manage_options', 'pmxe-admin-home', array(PMXE_Plugin::getInstance(), 'adminDispatcher'), PMXE_Plugin::ROOT_URL . '/static/img/xmlicon.png');
12
// workaround to rename 1st option to `Home`
13
$submenu['pmxe-admin-home'] = array();
14
+ add_submenu_page('pmxe-admin-home', __('Export to XML', 'wp_all_export_plugin') . ' &lsaquo; ' . __('WP All Export', 'wp_all_export_plugin'), __('New Export', 'wp_all_export_plugin'), 'manage_options', 'pmxe-admin-export', array(PMXE_Plugin::getInstance(), 'adminDispatcher'));
15
+ add_submenu_page('pmxe-admin-home', __('Manage Exports', 'wp_all_export_plugin') . ' &lsaquo; ' . __('WP All Export', 'wp_all_export_plugin'), __('Manage Exports', 'wp_all_export_plugin'), 'manage_options', 'pmxe-admin-manage', array(PMXE_Plugin::getInstance(), 'adminDispatcher'));
16
+ add_submenu_page('pmxe-admin-home', __('Settings', 'wp_all_export_plugin') . ' &lsaquo; ' . __('WP All Export', 'wp_all_export_plugin'), __('Settings', 'wp_all_export_plugin'), 'manage_options', 'pmxe-admin-settings', array(PMXE_Plugin::getInstance(), 'adminDispatcher'));
17
+ add_submenu_page('pmxe-admin-home', __('Feedback', 'wp_all_export_plugin') . ' &lsaquo; ' . __('WP All Export', 'wp_all_export_plugin'), __('Feedback', 'wp_all_export_plugin'), 'manage_options', 'pmxe-admin-feedback', array(PMXE_Plugin::getInstance(), 'adminDispatcher'));
18
+ add_submenu_page('pmxe-admin-home', __('Support', 'wp_all_export_plugin') . ' &lsaquo; ' . __('WP All Export', 'wp_all_export_plugin'), __('Support', 'wp_all_export_plugin'), 'manage_options', 'pmxe-admin-help', array(PMXE_Plugin::getInstance(), 'adminDispatcher'));
19
20
}
21
}
actions/admin_notices.php CHANGED
@@ -3,18 +3,7 @@
3
function pmxe_admin_notices() {
4
5
// notify user if history folder is not writable
6
- $uploads = wp_upload_dir();
7
-
8
- // notify user
9
- if (!PMXE_Plugin::getInstance()->getOption('dismiss') and strpos($_SERVER['REQUEST_URI'], 'pmxe-admin') !== false) {
10
- ?>
11
- <div class="updated"><p>
12
- <?php printf(
13
- __('Welcome to WP All Export. We hope you like it. Please send all support requests and feedback to <a href="mailto:support@soflyy.com">support@soflyy.com</a>.<br/><br/><a href="javascript:void(0);" id="dismiss">dismiss</a>', 'pmxe_plugin')
14
- ) ?>
15
- </p></div>
16
- <?php
17
- }
18
19
$input = new PMXE_Input();
20
$messages = $input->get('pmxe_nt', array());
3
function pmxe_admin_notices() {
4
5
// notify user if history folder is not writable
6
+ $uploads = wp_upload_dir();
7
8
$input = new PMXE_Input();
9
$messages = $input->get('pmxe_nt', array());
actions/plugins_loaded.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- function pmxe_plugins_loaded() {
4
-
5
- PMXE_Plugin::$session = PMXE_Session::get_instance();
6
- do_action( 'pmxe_session_start' );
7
-
8
- return PMXE_Plugin::$session->session_started();
9
- }
actions/wp.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- function pmxe_wp() {
4
- if ( ! wp_next_scheduled( 'wp_session_garbage_collection' ) ) {
5
- wp_schedule_event( time(), 'twicedaily', 'wp_session_garbage_collection' );
6
- }
7
- }
actions/wp_ajax_export.php DELETED
@@ -1,403 +0,0 @@
1
- <?php
2
-
3
- function pmxe_wp_ajax_export(){
4
-
5
- $wp_uploads = wp_upload_dir();
6
-
7
- $default = PMXE_Plugin::get_default_import_options();
8
- $exportOptions = (isset(PMXE_Plugin::$session->data['pmxe_export']) ? PMXE_Plugin::$session->data['pmxe_export'] : array()) + $default;
9
-
10
- wp_reset_postdata();
11
-
12
- $exportQuery = new WP_Query( array( 'post_type' => $exportOptions['cpt'], 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => -1 ));
13
-
14
- ob_start();
15
-
16
- switch ($exportOptions['export_to']) {
17
- case 'xml':
18
- echo '<?xml version="1.0" encoding="UTF-8"?>';
19
-
20
- ?>
21
- <data>
22
- <?php
23
- // The Loop
24
- while ( $exportQuery->have_posts() ) :
25
-
26
- $exportQuery->the_post();
27
-
28
- $record = get_post( get_the_ID() );
29
-
30
- ?>
31
- <post>
32
- <post_type><?php echo get_post_type(); ?></post_type>
33
- <?php if ($exportOptions['is_export_title']): ?><title><?php the_title(); ?></title><?php endif; ?>
34
-
35
- <?php if ($exportOptions['is_export_content']): ?>
36
- <content><?php echo '<![CDATA['; the_content(); echo ']]>'; ?></content>
37
- <?php endif; ?>
38
-
39
- <?php if ($exportOptions['is_export_custom_fields']): ?>
40
- <custom_fields>
41
- <?php foreach (get_post_custom($record->ID) as $cur_meta_key => $cur_meta_val): ?>
42
- <?php if ( $exportOptions['export_custom_fields_logic'] == 'full_export' or ($exportOptions['export_custom_fields_logic'] == 'only' and in_array($cur_meta_key, $exportOptions['custom_fields_list']))): ?>
43
- <<?php echo $cur_meta_key; ?>><?php echo '<![CDATA[' . ((!empty($cur_meta_val) and is_array($cur_meta_val) and count($cur_meta_val) == 1) ? $cur_meta_val[0] : serialize($cur_meta_val)) . ']]>'; ?></<?php echo $cur_meta_key;?>>
44
- <?php endif; ?>
45
- <?php endforeach; ?>
46
- </custom_fields>
47
- <?php endif; ?>
48
-
49
- <?php if ($exportOptions['is_export_categories']): ?>
50
- <taxonomies>
51
- <?php
52
-
53
- global $wp_taxonomies;
54
-
55
- foreach ($wp_taxonomies as $key => $obj) {
56
-
57
- if ($exportOptions['export_categories_logic'] == 'full_export' or ($exportOptions['export_categories_logic'] == 'only' and in_array($obj->name, $exportOptions['taxonomies_list'])))
58
- {
59
- $txes_list = get_the_terms($record->ID, $obj->name);
60
-
61
- if ( ! is_wp_error($txes_list)) {
62
- $txes_new = array();
63
- if (!empty($txes_list)):
64
- foreach ($txes_list as $t) {
65
- $txes_new[] = $t->slug;
66
- }
67
- ?>
68
- <<?php echo $obj->name; ?>><?php echo implode(', ', $txes_new); ?></<?php echo $obj->name; ?>>
69
- <?php
70
- endif;
71
- }
72
- }
73
- }
74
- ?>
75
- </taxonomies>
76
- <?php endif; ?>
77
-
78
- <?php if ($exportOptions['is_export_images'] and ! empty($exportOptions['export_images_logic'])): ?>
79
-
80
- <media_gallery>
81
- <?php
82
-
83
- $attachment_imgs = get_posts( array(
84
- 'post_type' => 'attachment',
85
- 'posts_per_page' => -1,
86
- 'post_parent' => $record->ID,
87
- ) );
88
-
89
- if ( ! empty($attachment_imgs)):
90
-
91
- foreach ($attachment_imgs as $attach) {
92
- if ( wp_attachment_is_image( $attach->ID ) ){
93
- ?>
94
- <image>
95
- <?php if (in_array('urls', $exportOptions['export_images_logic'])): ?><url><?php echo wp_get_attachment_url( $attach->ID ); ?></url><?php endif;?>
96
-
97
- <?php if (in_array('meta_data', $exportOptions['export_images_logic'])): ?>
98
- <title><?php echo esc_html($attach->post_title); ?></title>
99
- <caption><?php echo esc_html($attach->post_excerpt); ?></caption>
100
- <description><?php echo $attach->post_content;?></description>
101
- <alt><?php echo get_post_meta($record->ID, '_wp_attachment_image_alt'); ?></alt>
102
- <?php endif; ?>
103
- </image>
104
- <?php
105
- }
106
- }
107
-
108
- endif;
109
-
110
- ?>
111
- </media_gallery>
112
-
113
- <?php endif; ?>
114
-
115
- <?php if ($exportOptions['is_export_other']): ?>
116
-
117
- <other_stuff>
118
-
119
- <?php if ($exportOptions['is_export_dates']): ?><date><?php echo get_post_time('U', true); ?></date><?php endif; ?>
120
- <?php if ($exportOptions['is_export_parent']): ?><parent><?php echo $record->post_parent; ?></parent><?php endif; ?>
121
- <?php if ($exportOptions['is_export_template']): ?><template><?php echo get_post_meta($record->ID, '_wp_page_template', true); ?></template><?php endif; ?>
122
- <?php if ($exportOptions['is_export_menu_order']): ?><menu_order><?php echo $record->menu_order; ?></menu_order><?php endif; ?>
123
- <?php if ($exportOptions['is_export_status']): ?><status><?php echo $record->post_status; ?></status><?php endif; ?>
124
- <?php if ($exportOptions['is_export_format']): ?><format><?php echo get_post_format($record->ID); ?></format><?php endif; ?>
125
- <?php if ($exportOptions['is_export_author']): ?><author><?php echo $record->post_author; ?></author><?php endif; ?>
126
- <?php if ($exportOptions['is_export_slug']): ?><slug><?php echo $record->guid; ?></slug><?php endif; ?>
127
- <?php if ($exportOptions['is_export_excerpt']): ?><excerpt><?php echo $record->post_excerpt; ?></excerpt><?php endif; ?>
128
- <?php if ($exportOptions['is_export_attachments']): ?>
129
- <attachments>
130
- <?php
131
-
132
- $attachment_imgs = get_posts( array(
133
- 'post_type' => 'attachment',
134
- 'posts_per_page' => -1,
135
- 'post_parent' => $record->ID,
136
- ) );
137
-
138
- if ( ! empty($attachment_imgs)):
139
-
140
- foreach ($attachment_imgs as $attach) {
141
- if ( ! wp_attachment_is_image( $attach->ID ) ){
142
- ?>
143
- <attach>
144
- <url><?php echo wp_get_attachment_url( $attach->ID ); ?></url>
145
- </attach>
146
- <?php
147
- }
148
- }
149
-
150
- endif;
151
-
152
- ?>
153
- </attachments>
154
- <?php endif; ?>
155
-
156
- </other_stuff>
157
-
158
- <?php endif; ?>
159
-
160
- </post>
161
-
162
- <?php
163
- endwhile;
164
- ?>
165
-
166
- </data>
167
- <?php
168
-
169
- break;
170
- case 'csv':
171
-
172
- // Prepare headers
173
-
174
- $headers = array();
175
-
176
- $stream = fopen("php://output", 'w');
177
-
178
- $max_attach_count = 0;
179
- $max_images_count = 0;
180
-
181
- $cf = array();
182
- $taxes = array();
183
-
184
- $articles = array();
185
-
186
- while ( $exportQuery->have_posts() ) :
187
-
188
- $attach_count = 0;
189
- $images_count = 0;
190
-
191
- $exportQuery->the_post();
192
-
193
- $record = get_post( get_the_ID() );
194
-
195
- $article = array();
196
-
197
- $article['post_type'] = $record->post_type;
198
-
199
- if ($exportOptions['is_export_title']) $article['title'] = get_the_title();
200
- if ($exportOptions['is_export_content']) $article['content'] = get_the_content();
201
-
202
- if ($exportOptions['is_export_other']):
203
- if ($exportOptions['is_export_dates']) $article['date'] = get_post_time('U', true);
204
- if ($exportOptions['is_export_parent']) $article['parent'] = $record->post_parent;
205
- if ($exportOptions['is_export_template']) $article['template'] = get_post_meta($record->ID, '_wp_page_template', true);
206
- if ($exportOptions['is_export_menu_order']) $article['menu_order'] = $record->menu_order;
207
- if ($exportOptions['is_export_status']) $article['status'] = $record->post_status;
208
- if ($exportOptions['is_export_format']) $article['format'] = get_post_format($record->ID);
209
- if ($exportOptions['is_export_author']) $article['author'] = $record->post_author;
210
- if ($exportOptions['is_export_slug']) $article['slug'] = $record->guid;
211
- if ($exportOptions['is_export_excerpt']) $article['excerpt'] = $record->post_excerpt;
212
- if ($exportOptions['is_export_attachments']):
213
- $attachment_imgs = get_posts( array(
214
- 'post_type' => 'attachment',
215
- 'posts_per_page' => -1,
216
- 'post_parent' => $record->ID,
217
- ) );
218
-
219
- if ( ! empty($attachment_imgs)):
220
-
221
- foreach ($attachment_imgs as $key => $attach) {
222
- if ( ! wp_attachment_is_image( $attach->ID ) ){
223
- $article['attach_' . ($key + 1)] = wp_get_attachment_url( $attach->ID );
224
- $attach_count++;
225
- }
226
- }
227
-
228
- if ($attach_count > $max_attach_count) $max_attach_count = $attach_count;
229
-
230
- endif;
231
- endif;
232
- endif;
233
-
234
- if ($exportOptions['is_export_custom_fields']):
235
-
236
- foreach (get_post_custom($record->ID) as $cur_meta_key => $cur_meta_val):
237
- if ( $exportOptions['export_custom_fields_logic'] == 'full_export' or ($exportOptions['export_custom_fields_logic'] == 'only' and in_array($cur_meta_key, $exportOptions['custom_fields_list']))):
238
- $article['CF_' . $cur_meta_key] = ((!empty($cur_meta_val) and is_array($cur_meta_val) and count($cur_meta_val) == 1) ? $cur_meta_val[0] : serialize($cur_meta_val));
239
-
240
- if (!in_array('CF_' . $cur_meta_key, $cf)) $cf[] = 'CF_' . $cur_meta_key;
241
-
242
- endif;
243
- endforeach;
244
-
245
- endif;
246
-
247
- if ($exportOptions['is_export_categories']):
248
-
249
- global $wp_taxonomies;
250
-
251
- foreach ($wp_taxonomies as $key => $obj) {
252
-
253
- if ($exportOptions['export_categories_logic'] == 'full_export' or ($exportOptions['export_categories_logic'] == 'only' and in_array($obj->name, $exportOptions['taxonomies_list'])))
254
- {
255
- $txes_list = get_the_terms($record->ID, $obj->name);
256
-
257
- if ( ! is_wp_error($txes_list)) {
258
- $txes_new = array();
259
- if (!empty($txes_list)):
260
- foreach ($txes_list as $t) {
261
- $txes_new[] = $t->slug;
262
- }
263
- $article['TX_' . $obj->name] = implode('|', $txes_new);
264
-
265
- if (!in_array('TX_' . $obj->name, $taxes)) $taxes[] = 'TX_' . $obj->name;
266
-
267
- endif;
268
- }
269
- }
270
- }
271
-
272
- endif;
273
-
274
- if ($exportOptions['is_export_images'] and ! empty($exportOptions['export_images_logic'])):
275
-
276
- $attachment_imgs = get_posts( array(
277
- 'post_type' => 'attachment',
278
- 'posts_per_page' => -1,
279
- 'post_parent' => $record->ID,
280
- ) );
281
-
282
- if ( ! empty($attachment_imgs)):
283
-
284
- foreach ($attachment_imgs as $key => $attach) {
285
- if ( wp_attachment_is_image( $attach->ID ) ){
286
- if (in_array('urls', $exportOptions['export_images_logic'])) $article['image_url_' . ($key + 1)] = wp_get_attachment_url( $attach->ID );
287
-
288
- if (in_array('meta_data', $exportOptions['export_images_logic'])):
289
- $article['image_title_' . ($key + 1)] = $attach->post_title;
290
- $article['image_caption_' . ($key + 1)] = $attach->post_excerpt;
291
- $article['image_description_' . ($key + 1)] = $attach->post_content;
292
- $article['image_alt_' . ($key + 1)] = get_post_meta($record->ID, '_wp_attachment_image_alt');
293
- endif;
294
-
295
- $images_count++;
296
- }
297
- }
298
-
299
- if ($max_images_count > $images_count) $max_images_count = $images_count;
300
-
301
- endif;
302
-
303
- endif;
304
-
305
- $articles[] = $article;
306
-
307
- //fputcsv($stream, $article);
308
-
309
- endwhile;
310
-
311
- $headers[] = 'post_type';
312
-
313
- if ($exportOptions['is_export_title']) $headers[] = 'title';
314
- if ($exportOptions['is_export_content']) $headers[] = 'content';
315
-
316
- if ($exportOptions['is_export_other']):
317
- if ($exportOptions['is_export_dates']) $headers[] = 'date';
318
- if ($exportOptions['is_export_parent']) $headers[] = 'parent';
319
- if ($exportOptions['is_export_template']) $headers[] = 'template';
320
- if ($exportOptions['is_export_menu_order']) $headers[] = 'menu_order';
321
- if ($exportOptions['is_export_status']) $headers[] = 'status';
322
- if ($exportOptions['is_export_format']) $headers[] = 'format';
323
- if ($exportOptions['is_export_author']) $headers[] = 'author';
324
- if ($exportOptions['is_export_slug']) $headers[] = 'slug';
325
- if ($exportOptions['is_export_excerpt']) $headers[] = 'excerpt';
326
-
327
- for ($i = 0; $i < $max_attach_count; $i++){
328
- $headers[] = 'attach_' . ($i + 1);
329
- }
330
-
331
- endif;
332
-
333
- if (!empty($cf)){
334
- foreach ($cf as $cf_key) {
335
- $headers[] = $cf_key;
336
- }
337
- }
338
-
339
- if (!empty($taxes)){
340
- foreach ($taxes as $tx) {
341
- $headers[] = $tx;
342
- }
343
- }
344
-
345
- for ($i = 0; $i < $max_images_count; $i++){
346
-
347
- if (in_array('urls', $exportOptions['export_images_logic'])) $headers[] = 'image_url_' . ($i + 1);
348
-
349
- if (in_array('meta_data', $exportOptions['export_images_logic'])):
350
- $headers[] = 'image_title_' . ($i + 1);
351
- $headers[] = 'image_caption_' . ($i + 1);
352
- $headers[] = 'image_description_' . ($i + 1);
353
- $headers[] = 'image_alt_' . ($i + 1);
354
- endif;
355
-
356
- }
357
-
358
- fputcsv($stream, $headers);
359
-
360
- foreach ($articles as $article) {
361
- $line = array();
362
- foreach ($headers as $header) {
363
- $line[$header] = (!empty($article[$header])) ? $article[$header] : '';
364
- }
365
- fputcsv($stream, $line);
366
- }
367
-
368
- break;
369
-
370
- default:
371
- # code...
372
- break;
373
- }
374
-
375
- wp_reset_postdata();
376
-
377
- $export_file = $wp_uploads['path'] . '/' . time() . '.' . $exportOptions['export_to'];
378
-
379
- if (@file_exists($export_file)) @unlink($export_file);
380
-
381
- file_put_contents($export_file, ob_get_clean());
382
-
383
- if ( file_exists($export_file)){
384
- $wp_filetype = wp_check_filetype(basename($export_file), null );
385
- $attachment_data = array(
386
- 'guid' => $wp_uploads['baseurl'] . '/' . _wp_relative_upload_path( $export_file ),
387
- 'post_mime_type' => $wp_filetype['type'],
388
- 'post_title' => preg_replace('/\.[^.]+#x2F;', '', basename($export_file)),
389
- 'post_content' => '',
390
- 'post_status' => 'inherit'
391
- );
392
- $attach_id = wp_insert_attachment( $attachment_data, $export_file );
393
- }
394
-
395
- PMXE_Plugin::$session['pmxe_export']['export_file'] = $export_file;
396
-
397
- pmxe_session_commit();
398
-
399
- exit(json_encode(array('file' => $export_file))); die;
400
-
401
- }
402
-
403
- ?>
actions/wp_ajax_export_available_rules.php ADDED
@@ -0,0 +1,57 @@
1
+ <?php
2
+
3
+ function pmxe_wp_ajax_export_available_rules(){
4
+
5
+ if ( ! check_ajax_referer( 'wp_all_export_secure', 'security', false )){
6
+ exit( json_encode(array('html' => __('Security check', 'wp_all_export_plugin'))) );
7
+ }
8
+
9
+ if ( ! current_user_can('manage_options') ){
10
+ exit( json_encode(array('html' => __('Security check', 'wp_all_export_plugin'))) );
11
+ }
12
+
13
+ ob_start();
14
+
15
+ $input = new PMXE_Input();
16
+
17
+ $post = $input->post('data', array());
18
+
19
+ ?>
20
+ <select id="wp_all_export_rule">
21
+ <option value=""><?php _e('Select Rule', 'wp_all_export_plugin'); ?></option>
22
+ <?php
23
+ if (strpos($post['selected'], 'tx_') === 0){
24
+ ?>
25
+
26
+ <!-- Taxonomies -->
27
+ <option value="in">IN</option>
28
+ <option value="not_in">NOT IN</option>
29
+
30
+ <!-- Custom Fields -->
31
+ <!--option value="between">BETWEEN</option-->
32
+
33
+ <?php
34
+ }
35
+ else
36
+ {
37
+ ?>
38
+ <option value="equals"><?php _e('equals', 'wp_all_export_plugin'); ?></option>
39
+ <option value="not_equals"><?php _e('not equals', 'wp_all_export_plugin'); ?></option>
40
+ <option value="greater"><?php _e('greater than', 'wp_all_export_plugin');?></option>
41
+ <option value="equals_or_greater"><?php _e('equals or greater than', 'wp_all_export_plugin'); ?></option>
42
+ <option value="less"><?php _e('less than', 'wp_all_export_plugin'); ?></option>
43
+ <option value="equals_or_less"><?php _e('equals or less than', 'wp_all_export_plugin'); ?></option>
44
+
45
+ <option value="contains"><?php _e('contains', 'wp_all_export_plugin'); ?></option>
46
+ <option value="not_contains"><?php _e('not contains', 'wp_all_export_plugin'); ?></option>
47
+ <option value="is_empty"><?php _e('is empty', 'wp_all_export_plugin'); ?></option>
48
+ <option value="is_not_empty"><?php _e('is not empty', 'wp_all_export_plugin'); ?></option>
49
+ <?php
50
+ }
51
+ ?>
52
+ </select>
53
+ <?php
54
+
55
+ exit(json_encode(array('html' => ob_get_clean()))); die;
56
+
57
+ }
actions/wp_ajax_export_filtering.php ADDED
@@ -0,0 +1,143 @@
1
+ <?php
2
+
3
+ function pmxe_wp_ajax_export_filtering(){
4
+
5
+ if ( ! check_ajax_referer( 'wp_all_export_secure', 'security', false )){
6
+ exit( json_encode(array('html' => __('Security check', 'wp_all_export_plugin'))) );
7
+ }
8
+
9
+ if ( ! current_user_can('manage_options') ){
10
+ exit( json_encode(array('html' => __('Security check', 'wp_all_export_plugin'))) );
11
+ }
12
+
13
+ ob_start();
14
+
15
+ $errors = new WP_Error();
16
+
17
+ $input = new PMXE_Input();
18
+
19
+ $post = $input->post('data', array());
20
+
21
+ if ( ! empty($post['cpt'])):
22
+
23
+ $engine = new XmlExportEngine($post, $errors);
24
+
25
+ $engine->init_available_data();
26
+
27
+ ?>
28
+ <div class="wpallexport-content-section">
29
+ <div class="wpallexport-collapsed-header">
30
+ <h3><?php _e('Add Filtering Options', 'wp_all_export_plugin'); ?></h3>
31
+ </div>
32
+ <div class="wpallexport-collapsed-content">
33
+ <div class="wpallexport-free-edition-notice" style="padding: 20px; margin-bottom: 10px;">
34
+ <a class="upgrade_link" target="_blank" href="http://www.wpallimport.com/upgrade-to-wp-all-export-pro/?utm_source=wordpress.org&amp;utm_medium=filter-rules&amp;utm_campaign=free+wp+all+export+plugin"><?php _e(' Filtering Options Upgrade to the professional edition of WP All Export to add filtering rules.','wp_all_export_plugin');?></a>
35
+ </div>
36
+ <div class="wp_all_export_rule_inputs">
37
+ <table>
38
+ <tr>
39
+ <th><?php _e('Element', 'wp_all_export_plugin'); ?></th>
40
+ <th><?php _e('Rule', 'wp_all_export_plugin'); ?></th>
41
+ <th><?php _e('Value', 'wp_all_export_plugin'); ?></th>
42
+ <th>&nbsp;</th>
43
+ </tr>
44
+ <tr>
45
+ <td style="width: 25%;">
46
+ <select id="wp_all_export_xml_element">
47
+ <option value=""><?php _e('Select Element', 'wp_all_export_plugin'); ?></option>
48
+ <?php echo $engine->render_filters(); ?>
49
+ </select>
50
+ </td>
51
+ <td style="width: 25%;" id="wp_all_export_available_rules">
52
+ <select id="wp_all_export_rule">
53
+ <option value=""><?php _e('Select Rule', 'wp_all_export_plugin'); ?></option>
54
+ </select>
55
+ </td>
56
+ <td style="width: 25%;">
57
+ <input id="wp_all_export_value" type="text" placeholder="value" value="" disabled="disabled"/>
58
+ </td>
59
+ <td style="width: 15%;">
60
+ <a id="wp_all_export_add_rule" href="javascript:void(0);"><?php _e('Add Rule', 'wp_all_export_plugin');?></a>
61
+ </td>
62
+ </tr>
63
+ </table>
64
+ </div>
65
+ <div id="wpallexport-filters" style="padding:0;">
66
+ <div class="wpallexport-content-section" style="padding:0; border: none;">
67
+ <fieldset id="wp_all_export_filtering_rules">
68
+ <?php
69
+ $filter_rules = PMXE_Plugin::$session->get('filter_rules_hierarhy');
70
+ $filter_rules_hierarhy = json_decode($filter_rules);
71
+ ?>
72
+ <p style="margin:20px 0 5px; text-align:center; <?php if (!empty($filter_rules_hierarhy)):?> display:none;<?php endif; ?>"><?php _e('No filtering options. Add filtering options to only export records matching some specified criteria.', 'wp_all_export_plugin');?></p>
73
+ <ol class="wp_all_export_filtering_rules">
74
+ <?php
75
+ if ( ! empty($filter_rules_hierarhy) and is_array($filter_rules_hierarhy) ):
76
+ $rulenumber = 0;
77
+ foreach ($filter_rules_hierarhy as $rule) {
78
+
79
+ if ( is_null($rule->parent_id) )
80
+ {
81
+ $rulenumber++;
82
+ ?>
83
+ <li id="item_<?php echo $rulenumber;?>" class="dragging">
84
+ <div class="drag-element">
85
+ <input type="hidden" value="<?php echo $rule->element; ?>" class="wp_all_export_xml_element" name="wp_all_export_xml_element[<?php echo $rulenumber; ?>]"/>
86
+ <input type="hidden" value="<?php echo $rule->title; ?>" class="wp_all_export_xml_element_title" name="wp_all_export_xml_element_title[<?php echo $rulenumber; ?>]"/>
87
+ <input type="hidden" value="<?php echo $rule->condition; ?>" class="wp_all_export_rule" name="wp_all_export_rule[<?php echo $rulenumber; ?>]"/>
88
+ <input type="hidden" value="<?php echo $rule->value; ?>" class="wp_all_export_value" name="wp_all_export_value[<?php echo $rulenumber; ?>]"/>
89
+ <span class="rule_element"><?php echo $rule->title; ?></span>
90
+ <span class="rule_as_is"><?php echo $rule->condition; ?></span>
91
+ <span class="rule_condition_value"><?php echo $rule->value; ?></span>
92
+ <span class="condition" <?php if ($rulenumber == count($filter_rules_hierarhy)):?>style="display:none;"<?php endif; ?>>
93
+ <label for="rule_and_<?php echo $rulenumber; ?>">AND</label>
94
+ <input id="rule_and_<?php echo $rulenumber; ?>" type="radio" value="and" name="rule[<?php echo $rulenumber; ?>]" <?php if ($rule->clause == 'AND'): ?>checked="checked"<?php endif; ?> class="rule_condition"/>
95
+ <label for="rule_or_<?php echo $rulenumber; ?>">OR</label>
96
+ <input id="rule_or_<?php echo $rulenumber; ?>" type="radio" value="or" name="rule[<?php echo $rulenumber; ?>]" <?php if ($rule->clause == 'OR'): ?>checked="checked"<?php endif; ?> class="rule_condition"/>
97
+ </span>
98
+ </div>
99
+ <a href="javascript:void(0);" class="icon-item remove-ico"></a>
100
+ <?php echo wp_all_export_reverse_rules_html($filter_rules_hierarhy, $rule, $rulenumber); ?>
101
+ </li>
102
+ <?php
103
+ }
104
+ }
105
+ endif;
106
+ ?>
107
+ </ol>
108
+ <div class="clear"></div>
109
+ <div class="ajax-console" id="filtering_result">
110
+
111
+ </div>
112
+ <!--a href="javascript:void(0);" id="wp_all_export_apply_filters" <?php if (empty($filter_rules_hierarhy)):?>style="display:none;"<?php endif; ?>><?php _e('Apply Filters To Export Data', 'wp_all_export_plugin');?></a-->
113
+ <div class="wp_all_export_filter_preloader"></div>
114
+ </fieldset>
115
+
116
+ <?php if ( "product" == $post["cpt"] and class_exists('WooCommerce')) : ?>
117
+
118
+ <div class="input wp_all_export_product_matching_mode" <?php if (empty($filter_rules_hierarhy)): ?>style="display:none;"<?php endif; ?>>
119
+ <?php $product_matching_mode = PMXE_Plugin::$session->get('product_matching_mode'); ?>
120
+ <label><?php _e("Variable product matching rules: ", "wp_all_export_plugin"); ?></label>
121
+ <select name="product_matching_mode">
122
+ <option value="strict" <?php echo ( $product_matching_mode == 'strict' ) ? 'selected="selected"' : ''; ?>><?php _e("Strict", "wp_all_export_plugin"); ?></option>
123
+ <option value="permissive" <?php echo ( $product_matching_mode == 'permissive' ) ? 'selected="selected"' : ''; ?>><?php _e("Permissive", "wp_all_export_plugin"); ?></option>
124
+ </select>
125
+ <a href="#help" class="wpallexport-help" style="position: relative; top: 0px;" title="<?php _e('Strict matching requires all variations to pass in order for the product to be exported. Permissive matching allows the product to be exported if any of the variations pass.', 'wp_all_export_plugin'); ?>">?</a>
126
+ </div>
127
+
128
+ <?php endif; ?>
129
+
130
+
131
+
132
+ </div>
133
+ </div>
134
+ </div>
135
+ </div>
136
+
137
+ <?php
138
+
139
+ endif;
140
+
141
+ exit(json_encode(array('html' => ob_get_clean()))); die;
142
+
143
+ }
actions/wp_ajax_export_filtering_count.php ADDED
@@ -0,0 +1,59 @@
1
+ <?php
2
+
3
+ function pmxe_wp_ajax_export_filtering_count(){
4
+
5
+ if ( ! check_ajax_referer( 'wp_all_export_secure', 'security', false )){
6
+ exit( json_encode(array('html' => __('Security check', 'wp_all_export_plugin'))) );
7
+ }
8
+
9
+ if ( ! current_user_can('manage_options') ){
10
+ exit( json_encode(array('html' => __('Security check', 'wp_all_export_plugin'))) );
11
+ }
12
+
13
+ ob_start();
14
+
15
+ $input = new PMXE_Input();
16
+
17
+ $post = $input->post('data', array());
18
+
19
+ $filter_args = array(
20
+ 'filter_rules_hierarhy' => $post['filter_rules_hierarhy'],
21
+ 'product_matching_mode' => $post['product_matching_mode']
22
+ );
23
+
24
+ XmlExportEngine::$is_user_export = ( 'users' == $post['cpt'] ) ? true : false;
25
+ XmlExportEngine::$post_types = array($post['cpt']);
26
+
27
+ $found_records = 0;
28
+
29
+ if ( 'users' == $post['cpt'] )
30
+ {
31
+ $exportQuery = new WP_User_Query( array( 'orderby' => 'ID', 'order' => 'ASC', 'number' => 10 ));
32
+
33
+ if ( ! empty($exportQuery->results)){
34
+ $found_records = $exportQuery->get_total();
35
+ }
36
+ }
37
+ else
38
+ {
39
+ $exportQuery = new WP_Query( array( 'post_type' => $post['cpt'], 'post_status' => 'any', 'orderby' => 'ID', 'order' => 'ASC', 'posts_per_page' => 10 ));
40
+
41
+ if ( ! empty($exportQuery->found_posts)){
42
+ $found_records = $exportQuery->found_posts;
43
+ }
44
+ }
45
+
46
+ ?>
47
+ <div class="founded_records">
48
+ <?php if ($found_records > 0) :?>
49
+ <h3><span class="matches_count"><?php echo $found_records; ?></span> <strong><?php echo wp_all_export_get_cpt_name(array($post['cpt']), $found_records); ?></strong> will be exported</h3>
50
+ <h4><?php _e("Continue to Step 2 to choose data to include in the export file."); ?></h4>
51
+ <?php else: ?>
52
+ <h4 style="line-height:60px;"><?php printf(__("No matching %s found for selected filter rules"), wp_all_export_get_cpt_name(array($post['cpt']))); ?></h4>
53
+ <?php endif; ?>
54
+ </div>
55
+ <?php
56
+
57
+ exit(json_encode(array('html' => ob_get_clean()))); die;
58
+
59
+ }
actions/wp_ajax_export_preview.php ADDED
@@ -0,0 +1,137 @@
1
+ <?php
2
+ /**
3
+ * AJAX action for preview export row
4
+ */
5
+ function pmxe_wp_ajax_export_preview(){
6
+
7
+ if ( ! check_ajax_referer( 'wp_all_export_secure', 'security', false )){
8
+ exit( json_encode(array('html' => __('Security check', 'wp_all_export_plugin'))) );
9
+ }
10
+
11
+ if ( ! current_user_can('manage_options') ){
12
+ exit( json_encode(array('html' => __('Security check', 'wp_all_export_plugin'))) );
13
+ }
14
+
15
+ ob_start();
16
+
17
+ $values = array();
18
+
19
+ parse_str($_POST['data'], $values);
20
+
21
+ $exportOptions = $values + (PMXE_Plugin::$session->has_session() ? PMXE_Plugin::$session->get_clear_session_data() : array()) + PMXE_Plugin::get_default_import_options();
22
+
23
+ XmlExportEngine::$exportOptions = $exportOptions;
24
+ XmlExportEngine::$is_user_export = $exportOptions['is_user_export'];
25
+
26
+ if ( 'advanced' == $exportOptions['export_type'] )
27
+ {
28
+ if ( XmlExportEngine::$is_user_export )
29
+ {
30
+ exit( json_encode(array('html' => __('Upgrade to the professional edition of WP All Export to export users.', 'wp_all_export_plugin'))) );
31
+ }
32
+ else
33
+ {
34
+ $exportQuery = eval('return new WP_Query(array(' . $exportOptions['wp_query'] . ', \'offset\' => 0, \'posts_per_page\' => 10));');
35
+ }
36
+ }
37
+ else
38
+ {
39
+ XmlExportEngine::$post_types = $exportOptions['cpt'];
40
+
41
+ if ( ! in_array('users', $exportOptions['cpt']))
42
+ {
43
+ $exportQuery = new WP_Query( array( 'post_type' => $exportOptions['cpt'], 'post_status' => 'any', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => 10 ));
44
+ }
45
+ else
46
+ {
47
+ exit( json_encode(array('html' => __('Upgrade to the professional edition of WP All Export to export users.', 'wp_all_export_plugin'))) );
48
+ }
49
+ }
50
+
51
+ XmlExportEngine::$exportQuery = $exportQuery;
52
+
53
+ ?>
54
+
55
+ <div id="post-preview" class="wpallexport-preview">
56
+
57
+ <div class="wpallexport-preview-content">
58
+
59
+ <?php
60
+
61
+ switch ($exportOptions['export_to']) {
62
+
63
+ case 'xml':
64
+
65
+ $dom = new DOMDocument('1.0', $exportOptions['encoding']);
66
+ $old = libxml_use_internal_errors(true);
67
+ $xml = pmxe_export_xml($exportQuery, $exportOptions, true);
68
+ $dom->loadXML($xml);
69
+ libxml_use_internal_errors($old);
70
+ $xpath = new DOMXPath($dom);
71
+ if (($elements = @$xpath->query('/data')) and $elements->length){
72
+ pmxe_render_xml_element($elements->item( 0 ), true);
73
+ }
74
+
75
+ break;
76
+
77
+ case 'csv':
78
+ ?>
79
+ <small>
80
+ <?php
81
+ $csv = pmxe_export_csv($exportQuery, $exportOptions, true);
82
+ if (!empty($csv)){
83
+ $csv_rows = array_filter(explode("\n", $csv));
84
+ if ($csv_rows){
85
+ ?>
86
+ <table class="pmxe_preview" cellpadding="0" cellspacing="0">
87
+ <?php
88
+ foreach ($csv_rows as $rkey => $row) {
89
+ $cells = str_getcsv($row, $exportOptions['delimiter']);
90
+ if ($cells){
91
+ ?>
92
+ <tr>
93
+ <?php
94
+ foreach ($cells as $key => $value) {
95
+ ?>
96
+ <td>
97
+ <?php if (!$rkey):?><strong><?php endif;?>
98
+ <?php echo $value; ?>
99
+ <?php if (!$rkey):?></strong><?php endif;?>
100
+ </td>
101
+ <?php
102
+ }
103
+ ?>
104
+ </tr>
105
+ <?php
106
+ }
107
+ }
108
+ ?>
109
+ </table>
110
+ <?php
111
+ }
112
+ }
113
+ else{
114
+ _e('Data not found.', 'pmxe_plugin');
115
+ }
116
+ ?>
117
+ </small>
118
+ <?php
119
+ break;
120
+
121
+ default:
122
+
123
+ _e('This format is not supported.', 'pmxe_plugin');
124
+
125
+ break;
126
+ }
127
+ wp_reset_postdata();
128
+ ?>
129
+
130
+ </div>
131
+
132
+ </div>
133
+
134
+ <?php
135
+
136
+ exit(json_encode(array('html' => ob_get_clean()))); die;
137
+ }
actions/wp_ajax_wpallexport.php ADDED
@@ -0,0 +1,390 @@
1
+ <?php
2
+ /**
3
+ * AJAX action export processing
4
+ */
5
+ function pmxe_wp_ajax_wpallexport(){
6
+
7
+ if ( ! check_ajax_referer( 'wp_all_export_secure', 'security', false )){
8
+ exit( __('Security check', 'wp_all_export_plugin') );
9
+ }
10
+
11
+ if ( ! current_user_can('manage_options') ){
12
+ exit( __('Security check', 'wp_all_export_plugin') );
13
+ }
14
+
15
+ $wp_uploads = wp_upload_dir();
16
+
17
+ $export = new PMXE_Export_Record();
18
+
19
+ $export->getById(PMXE_Plugin::$session->update_previous);
20
+
21
+ $exportOptions = (PMXE_Plugin::$session->has_session() ? PMXE_Plugin::$session->get_clear_session_data() : array()) + PMXE_Plugin::get_default_import_options();
22
+
23
+ wp_reset_postdata();
24
+
25
+ XmlExportEngine::$exportOptions = $exportOptions;
26
+ XmlExportEngine::$is_user_export = $exportOptions['is_user_export'];
27
+
28
+ $posts_per_page = $exportOptions['records_per_iteration'];
29
+
30
+ if ('advanced' == $exportOptions['export_type'])
31
+ {
32
+ if (XmlExportEngine::$is_user_export)
33
+ {
34
+ exit( json_encode(array('html' => __('Upgrade to the professional edition of WP All Export to export users.', 'wp_all_export_plugin'))) );
35
+ }
36
+ else
37
+ {
38
+ $exportQuery = eval('return new WP_Query(array(' . $exportOptions['wp_query'] . ', \'orderby\' => \'ID\', \'order\' => \'ASC\', \'offset\' => ' . $export->exported . ', \'posts_per_page\' => ' . $posts_per_page . ' ));');
39
+ }
40
+ }
41
+ else
42
+ {
43
+ XmlExportEngine::$post_types = $exportOptions['cpt'];
44
+
45
+ if ( ! in_array('users', $exportOptions['cpt']))
46
+ {
47
+ $exportQuery = new WP_Query( array( 'post_type' => $exportOptions['cpt'], 'post_status' => 'any', 'orderby' => 'ID', 'order' => 'ASC', 'offset' => $export->exported, 'posts_per_page' => $posts_per_page ));
48
+ }
49
+ else
50
+ {
51
+ exit( json_encode(array('html' => __('Upgrade to the professional edition of WP All Export to export users.', 'wp_all_export_plugin'))) );
52
+ }
53
+ }
54
+
55
+ XmlExportEngine::$exportQuery = $exportQuery;
56
+
57
+ $foundPosts = ( ! XmlExportEngine::$is_user_export ) ? $exportQuery->found_posts : $exportQuery->get_total();
58
+
59
+ $postCount = ( ! XmlExportEngine::$is_user_export ) ? $exportQuery->post_count : count($exportQuery->get_results());
60
+
61
+ if ( ! $export->exported )
62
+ {
63
+ if ( ! empty($export->attch_id)){
64
+ wp_delete_attachment($export->attch_id, true);
65
+ }
66
+
67
+ $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
68
+
69
+ if ( $is_secure_import and ! empty($exportOptions['filepath'])){
70
+
71
+ wp_all_export_remove_source(wp_all_export_get_absolute_path($exportOptions['filepath']));
72
+
73
+ $exportOptions['filepath'] = '';
74
+
75
+ }
76
+
77
+ PMXE_Plugin::$session->set('count', $foundPosts);
78
+ PMXE_Plugin::$session->save_data();
79
+ }
80
+
81
+ // if posts still exists then export them
82
+ if ( $postCount )
83
+ {
84
+ switch ( $exportOptions['export_to'] ) {
85
+
86
+ case 'xml':
87
+
88
+ pmxe_export_xml($exportQuery, $exportOptions);
89
+
90
+ break;
91
+
92
+ case 'csv':
93
+
94
+ pmxe_export_csv($exportQuery, $exportOptions);
95
+
96
+ break;
97
+
98
+ default:
99
+ # code...
100
+ break;
101
+ }
102
+
103
+ wp_reset_postdata();
104
+
105
+ }
106
+
107
+ if ($postCount){
108
+
109
+ $export->set(array(
110
+ 'exported' => $export->exported + $postCount
111
+ ))->save();
112
+
113
+ }
114
+
115
+ if ($posts_per_page != -1 and $postCount){
116
+
117
+ wp_send_json(array(
118
+ 'exported' => $export->exported,
119
+ 'percentage' => ceil(($export->exported/$foundPosts) * 100),
120
+ 'done' => false,
121
+ 'records_per_request' => $exportOptions['records_per_iteration']
122
+ ));
123
+
124
+ }
125
+ else
126
+ {
127
+
128
+ wp_reset_postdata();
129
+
130
+ if ( file_exists(PMXE_Plugin::$session->file)){
131
+
132
+ if ($exportOptions['export_to'] == 'xml') file_put_contents(PMXE_Plugin::$session->file, '</data>', FILE_APPEND);
133
+
134
+ $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
135
+
136
+ if ( ! $is_secure_import ){
137
+
138
+ $wp_filetype = wp_check_filetype(basename(PMXE_Plugin::$session->file), null );
139
+ $attachment_data = array(
140
+ 'guid' => $wp_uploads['baseurl'] . '/' . _wp_relative_upload_path( PMXE_Plugin::$session->file ),
141
+ 'post_mime_type' => $wp_filetype['type'],
142
+ 'post_title' => preg_replace('/\.[^.]+#x2F;', '', basename(PMXE_Plugin::$session->file)),
143
+ 'post_content' => '',
144
+ 'post_status' => 'inherit'
145
+ );
146
+
147
+ $attach_id = wp_insert_attachment( $attachment_data, PMXE_Plugin::$session->file );
148
+ if ( ! $export->isEmpty() ){
149
+ $export->set(array(
150
+ 'attch_id' => $attach_id
151
+ ))->save();
152
+ }
153
+
154
+ }
155
+ else{
156
+
157
+ $exportOptions['filepath'] = wp_all_export_get_relative_path(PMXE_Plugin::$session->file);
158
+
159
+ if ( ! $export->isEmpty() ){
160
+ $export->set(array(
161
+ 'options' => $exportOptions
162
+ ))->save();
163
+ }
164
+
165
+ }
166
+
167
+ if ( wp_all_export_is_compatible() and ($exportOptions['is_generate_templates'] or $exportOptions['is_generate_import'])){
168
+
169
+ $custom_type = (empty($exportOptions['cpt'])) ? 'post' : $exportOptions['cpt'][0];
170
+
171
+ $templateOptions = array(
172
+ 'type' => ( ! empty($exportOptions['cpt']) and $exportOptions['cpt'][0] == 'page') ? 'page' : 'post',
173
+ 'wizard_type' => 'new',
174
+ 'deligate' => 'wpallexport',
175
+ 'custom_type' => (XmlExportEngine::$is_user_export) ? 'import_users' : $custom_type,
176
+ 'status' => 'xpath',
177
+ 'is_multiple_page_parent' => 'no',
178
+ 'unique_key' => '',
179
+ 'acf' => array(),
180
+ 'fields' => array(),
181
+ 'is_multiple_field_value' => array(),
182
+ 'multiple_value' => array(),
183
+ 'fields_delimiter' => array(),
184
+
185
+ 'update_all_data' => 'no',
186
+ 'is_update_status' => 0,
187
+ 'is_update_title' => 0,
188
+ 'is_update_author' => 0,
189
+ 'is_update_slug' => 0,
190
+ 'is_update_content' => 0,
191
+ 'is_update_excerpt' => 0,
192
+ 'is_update_dates' => 0,
193
+ 'is_update_menu_order' => 0,
194
+ 'is_update_parent' => 0,
195
+ 'is_update_attachments' => 0,
196
+ 'is_update_acf' => 0,
197
+ 'update_acf_logic' => 'only',
198
+ 'acf_list' => '',
199
+ 'is_update_product_type' => 0,
200
+ 'is_update_attributes' => 0,
201
+ 'update_attributes_logic' => 'only',
202
+ 'attributes_list' => '',
203
+ 'is_update_images' => 0,
204
+ 'is_update_custom_fields' => 0,
205
+ 'update_custom_fields_logic' => 'only',
206
+ 'custom_fields_list' => '',
207
+ 'is_update_categories' => 0,
208
+ 'update_categories_logic' => 'only',
209
+ 'taxonomies_list' => '',
210
+ 'export_id' => $export->id
211
+ );
212
+
213
+ if ( in_array('product', $exportOptions['cpt']) )
214
+ {
215
+ $templateOptions['_virtual'] = 1;
216
+ $templateOptions['_downloadable'] = 1;
217
+ }
218
+
219
+ if ( XmlExportEngine::$is_user_export )
220
+ {
221
+ $templateOptions['is_update_first_name'] = 0;
222
+ $templateOptions['is_update_last_name'] = 0;
223
+ $templateOptions['is_update_role'] = 0;
224
+ $templateOptions['is_update_nickname'] = 0;
225
+ $templateOptions['is_update_description'] = 0;
226
+ $templateOptions['is_update_login'] = 0;
227
+ $templateOptions['is_update_password'] = 0;
228
+ $templateOptions['is_update_nicename'] = 0;
229
+ $templateOptions['is_update_email'] = 0;
230
+ $templateOptions['is_update_registered'] = 0;
231
+ $templateOptions['is_update_display_name'] = 0;
232
+ $templateOptions['is_update_url'] = 0;
233
+ }
234
+
235
+ if ( 'xml' == $exportOptions['export_to'] )
236
+ {
237
+ wp_all_export_prepare_template_xml($exportOptions, $templateOptions);
238
+ }
239
+ else
240
+ {
241
+ wp_all_export_prepare_template_csv($exportOptions, $templateOptions);
242
+ }
243
+
244
+ $options = $templateOptions + PMXI_Plugin::get_default_import_options();
245
+
246
+ if ($exportOptions['is_generate_templates']){
247
+
248
+ $template = new PMXI_Template_Record();
249
+
250
+ $tpl_options = $options;
251
+
252
+ if ( 'csv' == $exportOptions['export_to'] )
253
+ {
254
+ $tpl_options['delimiter'] = $exportOptions['delimiter'];
255
+ }
256
+
257
+ $tpl_options['update_all_data'] = 'yes';
258
+ $tpl_options['is_update_status'] = 1;
259
+ $tpl_options['is_update_title'] = 1;
260
+ $tpl_options['is_update_author'] = 1;
261
+ $tpl_options['is_update_slug'] = 1;
262
+ $tpl_options['is_update_content'] = 1;
263
+ $tpl_options['is_update_excerpt'] = 1;
264
+ $tpl_options['is_update_dates'] = 1;
265
+ $tpl_options['is_update_menu_order'] = 1;
266
+ $tpl_options['is_update_parent'] = 1;
267
+ $tpl_options['is_update_attachments'] = 1;
268
+ $tpl_options['is_update_acf'] = 1;
269
+ $tpl_options['update_acf_logic'] = 'full_update';
270
+ $tpl_options['acf_list'] = '';
271
+ $tpl_options['is_update_product_type'] = 1;
272
+ $tpl_options['is_update_attributes'] = 1;
273
+ $tpl_options['update_attributes_logic'] = 'full_update';
274
+ $tpl_options['attributes_list'] = '';
275
+ $tpl_options['is_update_images'] = 1;
276
+ $tpl_options['is_update_custom_fields'] = 1;
277
+ $tpl_options['update_custom_fields_logic'] = 'full_update';
278
+ $tpl_options['custom_fields_list'] = '';
279
+ $tpl_options['is_update_categories'] = 1;
280
+ $tpl_options['update_categories_logic'] = 'full_update';
281
+ $tpl_options['taxonomies_list'] = '';
282
+
283
+ $tpl_data = array(
284
+ 'name' => $exportOptions['template_name'],
285
+ 'is_keep_linebreaks' => 0,
286
+ 'is_leave_html' => 0,
287
+ 'fix_characters' => 0,
288
+ 'options' => $tpl_options,
289
+ );
290
+
291
+ if ( ! empty($exportOptions['template_name'])) { // save template in database
292
+ $template->getByName($exportOptions['template_name'])->set($tpl_data)->save();
293
+ }
294
+
295
+ }
296
+
297
+ // associate exported posts with new import
298
+ if ($exportOptions['is_generate_import']){
299
+
300
+ $import = new PMXI_Import_Record();
301
+
302
+ $import->getById($exportOptions['import_id']);
303
+
304
+ if ( ! $import->isEmpty() and $import->parent_import_id == 99999 ){
305
+
306
+ $xmlPath = PMXE_Plugin::$session->file;
307
+
308
+ $root_element = '';
309
+
310
+ $historyPath = PMXE_Plugin::$session->file;
311
+
312
+ if ( 'csv' == $exportOptions['export_to'] )
313
+ {
314
+ $options['delimiter'] = $exportOptions['delimiter'];
315
+
316
+ include_once( PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportCsvParse.php' );
317
+
318
+ $path_info = pathinfo($xmlPath);
319
+
320
+ $path_parts = explode(DIRECTORY_SEPARATOR, $path_info['dirname']);
321
+
322
+ $security_folder = array_pop($path_parts);
323
+
324
+ $target = $is_secure_import ? $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXE_Plugin::UPLOADS_DIRECTORY . DIRECTORY_SEPARATOR . $security_folder : $wp_uploads['path'];
325
+
326
+ $csv = new PMXI_CsvParser( array( 'filename' => $xmlPath, 'targetDir' => $target ) );
327
+
328
+ $historyPath = $csv->xml_path;
329
+
330
+ $root_element = 'node';
331
+
332
+ }
333
+ else
334
+ {
335
+ $root_element = 'post';
336
+ }
337
+
338
+ $import->set(array(
339
+ //'parent_import_id' => 99999,
340
+ 'xpath' => '/' . $root_element,
341
+ 'type' => 'upload',
342
+ 'options' => $options,
343
+ 'root_element' => $root_element,
344
+ 'path' => $xmlPath,
345
+ 'name' => basename($xmlPath),
346
+ 'imported' => 0,
347
+ 'created' => 0,
348
+ 'updated' => 0,
349
+ 'skipped' => 0,
350
+ 'deleted' => 0,
351
+ 'iteration' => 1,
352
+ 'count' => PMXE_Plugin::$session->count
353
+ ))->save();
354
+
355
+ $history_file = new PMXI_File_Record();
356
+ $history_file->set(array(
357
+ 'name' => $import->name,
358
+ 'import_id' => $import->id,
359
+ 'path' => $historyPath,
360
+ 'registered_on' => date('Y-m-d H:i:s')
361
+ ))->save();
362
+
363
+ $exportOptions['import_id'] = $import->id;
364
+
365
+ $export->set(array(
366
+ 'options' => $exportOptions
367
+ ))->save();
368
+ }
369
+ }
370
+ }
371
+ }
372
+
373
+ $export->set(array(
374
+ 'executing' => 0,
375
+ 'canceled' => 0
376
+ ))->save();
377
+
378
+ do_action('pmxe_after_export', $export->id);
379
+
380
+ wp_send_json(array(
381
+ 'exported' => $export->exported,
382
+ 'percentage' => 100,
383
+ 'done' => true,
384
+ 'records_per_request' => $exportOptions['records_per_iteration'],
385
+ 'file' => PMXE_Plugin::$session->file
386
+ ));
387
+
388
+ }
389
+
390
+ }
actions/wp_loaded.php CHANGED
@@ -2,5 +2,7 @@
2
3
function pmxe_wp_loaded() {
4
5
6
}
2
3
function pmxe_wp_loaded() {
4
5
+ @ini_set("max_input_time", PMXE_Plugin::getInstance()->getOption('max_input_time'));
6
+ @ini_set("max_execution_time", PMXE_Plugin::getInstance()->getOption('max_execution_time'));
7
8
}
actions/wp_session_garbage_collection.php DELETED
@@ -1,65 +0,0 @@
1
- <?php
2
-
3
- function pmxe_wp_session_garbage_collection() {
4
- global $wpdb;
5
-
6
- if ( defined( 'WP_SETUP_CONFIG' ) ) {
7
- return;
8
- }
9
-
10
- $session_mode = PMXE_Plugin::getInstance()->getOption('session_mode');
11
-
12
- if ( ! defined( 'WP_INSTALLING' ) ) {
13
- if ($session_mode == 'database'){
14
- $expiration_keys = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE '_pmxe_session_expires_%'" );
15
-
16
- $now = time();
17
- $expired_sessions = array();
18
-
19
- foreach( $expiration_keys as $expiration ) {
20
- // If the session has expired
21
- if ( $now > intval( $expiration->option_value ) ) {
22
- // Get the session ID by parsing the option_name
23
- $session_id = str_replace("_PMXE_session_expires_", "", $expiration->option_name);
24
-
25
- $expired_sessions[] = $expiration->option_name;
26
- $expired_sessions[] = "_PMXE_session_$session_id";
27
- }
28
- }
29
-
30
- // Delete all expired sessions in a single query
31
- if ( ! empty( $expired_sessions ) ) {
32
- $option_names = implode( "','", $expired_sessions );
33
- $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name IN ('$option_names')" );
34
- }
35
- }
36
- elseif ($session_mode == 'files'){
37
- $session_files = scandir( PMXE_ROOT_DIR . '/sessions');
38
-
39
- if (!empty($session_files)){
40
- $now = time();
41
- $expired_sessions = array();
42
- foreach ($session_files as $key => $file) {
43
- if ( strpos($file, "_pmxe_session_expires_") !== false){
44
- $expiration_value = @file_get_contents( PMXE_ROOT_DIR . "/sessions/" . $file );
45
-
46
- if ($now > intval($expiration_value)){
47
- $session_id = str_replace("_pmxe_session_expires_", "", $file);
48
- $expired_sessions[] = $file;
49
- $expired_sessions[] = "_pmxe_session_$session_id";
50
- }
51
- }
52
- }
53
- // Delete all expired sessions in a single query
54
- if ( ! empty( $expired_sessions ) ) {
55
- foreach ($expired_sessions as $key => $file) {
56
- @unlink( PMXE_ROOT_DIR . "/sessions/" . $file );
57
- }
58
- }
59
- }
60
- }
61
- }
62
-
63
- // Allow other plugins to hook in to the garbage collection process.
64
- do_action( 'PMXE_session_cleanup' );
65
- }
classes/arrayaccess.php DELETED
@@ -1,141 +0,0 @@
1
- <?php
2
- /**
3
- * Multidimensional ArrayAccess
4
- *
5
- * Allows ArrayAccess-like functionality with multidimensional arrays. Fully supports
6
- * both sets and unsets.
7
- *
8
- * @package WordPress
9
- * @subpackage Session
10
- * @since 3.7.0
11
- */
12
-
13
- /**
14
- * Recursive array class to allow multidimensional array access.
15
- *
16
- * @package WordPress
17
- * @since 3.7.0
18
- */
19
- class PMXE_ArrayAccess implements ArrayAccess {
20
- /**
21
- * Internal data collection.
22
- *
23
- * @var array
24
- */
25
- public $container = array();
26
-
27
- /**
28
- * Flag whether or not the internal collection has been changed.
29
- *
30
- * @var bool
31
- */
32
- protected $dirty = false;
33
-
34
- /**
35
- * Default object constructor.
36
- *
37
- * @param array $data
38
- */
39
- protected function __construct( $data = array() ) {
40
- foreach ( $data as $key => $value ) {
41
- $this[ $key ] = $value;
42
- }
43
- }
44
-
45
- /**
46
- * Allow deep copies of objects
47
- */
48
- public function __clone() {
49
- foreach ( $this->container as $key => $value ) {
50
- if ( $value instanceof self ) {
51
- $this[ $key ] = clone $value;
52
- }
53
- }
54
- }
55
-
56
- /**
57
- * Output the data container as a multidimensional array.
58
- *
59
- * @return array
60
- */
61
- public function toArray() {
62
- $data = $this->container;
63
- if (!empty($data)){
64
- foreach ( $data as $key => $value ) {
65
- if ( $value instanceof self ) {
66
- $data[ $key ] = $value->toArray();
67
- }
68
- }
69
- }
70
- return $data;
71
- }
72
-
73
- /*****************************************************************/
74
- /* ArrayAccess Implementation */
75
- /*****************************************************************/
76
-
77
- /**
78
- * Whether a offset exists
79
- *
80
- * @link http://php.net/manual/en/arrayaccess.offsetexists.php
81
- *
82
- * @param mixed $offset An offset to check for.
83
- *
84
- * @return boolean true on success or false on failure.
85
- */
86
- public function offsetExists( $offset ) {
87
- return isset( $this->container[ $offset ]) ;
88
- }
89
-
90
- /**
91
- * Offset to retrieve
92
- *
93
- * @link http://php.net/manual/en/arrayaccess.offsetget.php
94
- *
95
- * @param mixed $offset The offset to retrieve.
96
- *
97
- * @return mixed Can return all value types.
98
- */
99
- public function offsetGet( $offset ) {
100
- return isset( $this->container[ $offset ] ) ? $this->container[ $offset ] : null;
101
- }
102
-
103
- /**
104
- * Offset to set
105
- *
106
- * @link http://php.net/manual/en/arrayaccess.offsetset.php
107
- *
108
- * @param mixed $offset The offset to assign the value to.
109
- * @param mixed $value The value to set.
110
- *
111
- * @return void
112
- */
113
- public function offsetSet( $offset, $data ) {
114
- if ( is_array( $data ) ) {
115
- $data = new self( $data );
116
- }
117
- if ( $offset === null ) { // don't forget this!
118
- $this->container[] = $data;
119
- } else {
120
- $this->container[ $offset ] = $data;
121
- }
122
-
123
- $this->dirty = true;
124
- }
125
-
126
- /**
127
- * Offset to unset
128
- *
129
- * @link http://php.net/manual/en/arrayaccess.offsetunset.php
130
- *
131
- * @param mixed $offset The offset to unset.
132
- *
133
- * @return void
134
- */
135
- public function offsetUnset( $offset ) {
136
- unset( $this->container[ $offset ] );
137
-
138
- $this->dirty = true;
139
- }
140
- }
141
- ?>
classes/config.php CHANGED
File without changes
classes/download.php CHANGED
File without changes
classes/handler.php ADDED
@@ -0,0 +1,132 @@
1
+ <?php
2
+
3
+ class PMXE_Handler extends PMXE_Session {
4
+
5
+ /** cookie name */
6
+ private $_cookie;
7
+
8
+ /** session due to expire timestamp */
9
+ private $_session_expiring;
10
+
11
+ /** session expiration timestamp */
12
+ private $_session_expiration;
13
+
14
+ /** Bool based on whether a cookie exists **/
15
+ private $_has_cookie = false;
16
+
17
+ /**
18
+ * Constructor for the session class.
19
+ *
20
+ * @access public
21
+ * @return void
22
+ */
23
+ public function __construct() {
24
+
25
+ $this->set_session_expiration();
26
+
27
+ $this->_import_id = $this->generate_import_id();
28
+
29
+ $this->_data = $this->get_session_data();
30
+
31
+ }
32
+
33
+ /**
34
+ * Return true if the current user has an active session, i.e. a cookie to retrieve values
35
+ * @return boolean
36
+ */
37
+ public function has_session() {
38
+ return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in();
39
+ }
40
+
41
+ /**
42
+ * set_session_expiration function.
43
+ *
44
+ * @access public
45
+ * @return void
46
+ */
47
+ public function set_session_expiration() {
48
+ $this->_session_expiring = time() + intval( apply_filters( 'wpallexport_session_expiring', 60 * 60 * 47 ) ); // 47 Hours
49
+ $this->_session_expiration = time() + intval( apply_filters( 'wpallexport_session_expiration', 60 * 60 * 48 ) ); // 48 Hours
50
+ }
51
+
52
+ public function generate_import_id() {
53
+
54
+ $input = new PMXE_Input();
55
+ $import_id = $input->get('id', 'new');
56
+
57
+ return $import_id;
58
+
59
+ }
60
+
61
+ /**
62
+ * get_session_data function.
63
+ *
64
+ * @access public
65
+ * @return array
66
+ */
67
+ public function get_session_data() {
68
+ return (array) get_option( '_wpallexport_session_' . $this->_import_id . '_', array() );
69
+ }
70
+
71
+ /**
72
+ * get_session_data function.
73
+ *
74
+ * @access public
75
+ * @return array
76
+ */
77
+ public function get_clear_session_data() {
78
+ $this->_data = $this->get_session_data();
79
+ $clear_data = array();
80
+ foreach ($this->_data as $key => $value) {
81
+ $ckey = sanitize_key( $key );
82
+ $clear_data[ $ckey ] = maybe_unserialize( $value );
83
+ }
84
+
85
+ return $clear_data;
86
+ }
87
+
88
+ /**
89
+ * save_data function.
90
+ *
91
+ * @access public
92
+ * @return void
93
+ */
94
+ public function save_data() {
95
+ // Dirty if something changed - prevents saving nothing new
96
+
97
+ if ( $this->_dirty and $this->has_session() ) {
98
+
99
+ $session_option = '_wpallexport_session_' . $this->_import_id . '_';
100
+ $session_expiry_option = '_wpallexport_session_expires_' . $this->_import_id . '_';
101
+
102
+ update_option( $session_option, $this->_data );
103
+
104
+ if ( false === get_option( $session_option ) ) {
105
+ add_option( $session_expiry_option, $this->_session_expiration, '', 'no' );
106
+ }
107
+ }
108
+ }
109
+
110
+ public function convertData( $import_id ){
111
+
112
+ $this->_import_id = 'new';
113
+
114
+ $this->_data = $this->get_session_data();
115
+
116
+ $this->set_session_expiration();
117
+
118
+ $this->_import_id = $import_id;
119
+
120
+ $this->clean_session();
121
+
122
+ $this->_dirty = true;
123
+
124
+ $this->save_data();
125
+ }
126
+
127
+ public function clean_session( $import_id = 'new' ){
128
+
129
+ delete_option('_wpallexport_session_' . $import_id . '_');
130
+
131
+ }
132
+ }
classes/helper.php CHANGED
File without changes
classes/input.php CHANGED
@@ -19,7 +19,14 @@ class PMXE_Input {
19
}
20
21
public function get($paramName, $default = NULL) {
22
- return $this->read($_GET, $paramName, $default);
23
}
24
25
public function post($paramName, $default = NULL) {
19
}
20
21
public function get($paramName, $default = NULL) {
22
+ $this->addFilter('htmlspecialchars');
23
+ $this->addFilter('strip_tags');
24
+ $this->addFilter('esc_sql');
25
+ $result = $this->read($_GET, $paramName, $default);
26
+ $this->removeFilter('htmlspecialchars');
27
+ $this->removeFilter('strip_tags');
28
+ $this->removeFilter('esc_sql');
29
+ return $result;
30
}
31
32
public function post($paramName, $default = NULL) {
classes/session.php CHANGED
@@ -1,371 +1,96 @@
1
<?php
2
- /**
3
- * WordPress session managment.
4
- *
5
- * Standardizes WordPress session data using database-backed options for storage.
6
- * for storing user session information.
7
- *
8
- * @package WordPress
9
- * @subpackage Session
10
- * @since 3.7.0
11
- */
12
13
- /**
14
- * WordPress Session class for managing user session data.
15
- *
16
- * @package WordPress
17
- * @since 3.7.0
18
- */
19
- final class PMXE_Session extends PMXE_ArrayAccess implements Iterator, Countable {
20
- /**
21
- * ID of the current session.
22
- *
23
- * @var string
24
- */
25
- protected $session_id;
26
-
27
- /**
28
- * Unix timestamp when session expires.
29
- *
30
- * @var int
31
- */
32
- protected $expires;
33
-
34
- /**
35
- * Unix timestamp indicating when the expiration time needs to be reset.
36
- *
37
- * @var int
38
- */
39
- protected $exp_variant;
40
-
41
- /**
42
- * Singleton instance.
43
- *
44
- * @var bool|WP_Session
45
- */
46
- private static $instance = false;
47
-
48
- public $data = array();
49
-
50
- public $session_mode = '';
51
- /**
52
- * Retrieve the current session instance.
53
- *
54
- * @param bool $session_id Session ID from which to populate data.
55
- *
56
- * @return bool|WP_Session
57
- */
58
- public static function get_instance() {
59
- if ( ! self::$instance ) {
60
- self::$instance = new self();
61
- }
62
-
63
- return self::$instance;
64
- }
65
-
66
- /**
67
- * Default constructor.
68
- * Will rebuild the session collection from the given session ID if it exists. Otherwise, will
69
- * create a new session with that ID.
70
- *
71
- * @param $session_id
72
- * @uses apply_filters Calls `wp_session_expiration` to determine how long until sessions expire.
73
- */
74
- protected function __construct() {
75
-
76
- $this->session_mode = PMXE_Plugin::getInstance()->getOption('session_mode');
77
-
78
- if ($this->session_mode != 'default'){
79
-
80
- if ( isset( $_COOKIE[PMXE_SESSION_COOKIE] ) ) {
81
-
82
- $cookie = stripslashes( $_COOKIE[PMXE_SESSION_COOKIE] );
83
- $cookie_crumbs = explode( '||', $cookie );
84
-
85
- $this->session_id = (!empty($cookie_crumbs[0])) ? $cookie_crumbs[0] : $this->generate_id();
86
- $this->expires = $cookie_crumbs[1];
87
- $this->exp_variant = $cookie_crumbs[2];
88
-
89
- // Update the session expiration if we're past the variant time
90
- if ( time() > $this->exp_variant ) {
91
- $this->set_expiration();
92
- if ($this->session_mode == 'database'){
93
- update_option( "_pmxi_session_expires_{$this->session_id}", $this->expires );
94
- }
95
- elseif ($this->session_mode == 'files'){
96
- @file_put_contents(PMXE_ROOT_DIR . "/sessions/_pmxe_session_expires_{$this->session_id}.txt", $this->expires);
97
- }
98
- }
99
-
100
- } else {
101
- $this->session_id = $this->generate_id();
102
- $this->set_expiration();
103
- }
104
- }
105
- else{
106
- try{
107
- $path = @session_save_path();
108
- if ( ! @is_dir($path) or ! @is_writable($path)){
109
- @ini_set("session.save_handler", "files");
110
- @session_save_path(sys_get_temp_dir());
111
- }
112
- } catch (XmlImportException $e) {
113
-
114
- }
115
-
116
- // enable sessions
117
- if ( ! session_id()) @session_start();
118
- }
119
-
120
- $this->read_data();
121
-
122
- $this->set_cookie();
123
- }
124
-
125
- /**
126
- * Set both the expiration time and the expiration variant.