Version Description
- WP All Export exits beta
Download this release
Release Info
Developer | soflyy |
Plugin | ![]() |
Version | 1.0.0 |
Comparing to | |
See all releases |
Code changes from version 0.9.1 to 1.0.0
- actions/admin_head.php +22 -0
- actions/admin_init.php +0 -0
- actions/admin_menu.php +6 -4
- actions/admin_notices.php +1 -12
- actions/plugins_loaded.php +0 -9
- actions/wp.php +0 -7
- actions/wp_ajax_export.php +0 -403
- actions/wp_ajax_export_available_rules.php +57 -0
- actions/wp_ajax_export_filtering.php +143 -0
- actions/wp_ajax_export_filtering_count.php +59 -0
- actions/wp_ajax_export_preview.php +137 -0
- actions/wp_ajax_wpallexport.php +390 -0
- actions/wp_loaded.php +2 -0
- actions/wp_session_garbage_collection.php +0 -65
- classes/arrayaccess.php +0 -141
- classes/config.php +0 -0
- classes/download.php +0 -0
- classes/handler.php +132 -0
- classes/helper.php +0 -0
- classes/input.php +8 -1
- classes/session.php +91 -366
- config/options.php +6 -2
- controllers/admin/export.php +294 -63
- controllers/admin/feedback.php +12 -0
- controllers/admin/help.php +0 -0
- controllers/admin/manage.php +328 -0
- controllers/admin/settings.php +13 -7
- controllers/controller.php +51 -14
- controllers/controller/admin.php +4 -1
- filters/.gitkeep +0 -0
- filters/wp_all_import_is_exported_file_valid.php +65 -0
- filters/wpallexport_custom_types.php +7 -0
- helpers/backward.php +0 -0
- helpers/get_taxonomies_by_object_type.php +25 -0
- helpers/pmxe_export_acf_field_csv.php +369 -0
- helpers/pmxe_export_acf_field_xml.php +345 -0
- helpers/pmxe_export_csv.php +589 -0
- helpers/pmxe_export_xml.php +432 -0
- helpers/pmxe_filter.php +4 -0
- helpers/pmxe_functions.php +14 -69
- helpers/pmxe_render_xml_attributes.php +7 -0
- helpers/pmxe_render_xml_element.php +55 -0
- helpers/pmxe_render_xml_text.php +21 -0
- helpers/str_getcsv.php +0 -0
- helpers/wp_all_export_check_children_assign.php +15 -0
- helpers/wp_all_export_get_cpt_name.php +27 -0
- helpers/wp_all_export_is_compatible.php +4 -0
- helpers/wp_all_export_prepare_template_csv.php +510 -0
- helpers/wp_all_export_prepare_template_xml.php +470 -0
- helpers/wp_all_export_rand_char.php +11 -0
- helpers/wp_all_export_remove_colons.php +27 -0
- helpers/wp_all_export_remove_source.php +22 -0
- helpers/wp_all_export_reverse_rules_html.php +40 -0
- helpers/wp_all_export_rmdir.php +13 -0
- helpers/wp_all_export_secure_file.php +23 -0
- helpers/wp_all_export_url_title.php +42 -0
- helpers/wp_redirect_or_javascript.php +0 -0
- libraries/.gitkeep +0 -0
- libraries/XmlExportACF.php +246 -0
- libraries/XmlExportEngine.php +515 -0
- libraries/XmlExportUser.php +354 -0
- libraries/XmlExportWooCommerce.php +551 -0
- libraries/XmlExportWooCommerceOrder.php +550 -0
- models/export/list.php +2 -2
- models/export/record.php +30 -20
- models/model.php +0 -0
- models/model/list.php +0 -0
- models/model/record.php +0 -0
- plugin.php +0 -520
- readme.txt +45 -19
- schema.php +19 -1
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- sessions/.gitkeep +0 -0
- shortcodes/.gitkeep +0 -0
- static/css/admin-ie.css +0 -0
- static/css/admin-wp-3.8.css +0 -0
- static/css/admin.css +3166 -1039
- static/img/add-ons/acf-thumb.jpg +0 -0
- static/img/add-ons/woo-commerce-thumb.jpg +0 -0
- static/img/back.png +0 -0
- static/img/collapser.png +0 -0
- static/img/continue.png +0 -0
- static/img/date-picker.gif +0 -0
- static/img/down.gif +0 -0
- static/img/drag.png +0 -0
- static/img/elements.png +0 -0
- static/img/help.png +0 -0
- static/img/ico-add-new.png +0 -0
- static/img/ico-remove.png +0 -0
- static/img/import-templates.png +0 -0
- static/img/left_btn.png +0 -0
- static/img/list.png +0 -0
- static/img/loading.png +0 -0
- static/img/logo.png +0 -0
- static/img/preloader.png +0 -0
- static/img/progress_animated.gif +0 -0
- static/img/remove.png +0 -0
- static/img/right_btn.png +0 -0
- static/img/rule.png +0 -0
- static/img/screen-options-right-up.gif +0 -0
- static/img/screen-options-right.gif +0 -0
- static/img/soflyy-logo.png +0 -0
- static/img/stars.png +0 -0
- static/img/trash.png +0 -0
- static/img/xmlicon.png +0 -0
- static/js/admin.js +1076 -76
- static/js/jquery/chosen.jquery.js +1263 -0
- static/js/jquery/chosen.jquery.min.js +2 -0
- static/js/jquery/css/chosen/chosen-sprite.png +0 -0
- static/js/jquery/css/chosen/chosen-sprite@2x.png +0 -0
- static/js/jquery/css/chosen/chosen.css +450 -0
- static/js/jquery/css/redmond/images/animated-overlay.gif +0 -0
- static/js/jquery/css/redmond/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_flat_0_aaaaaa_40x100_1.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
- static/js/jquery/css/redmond/images/ui-icons_217bc0_256x240.png +0 -0
- static/js/jquery/css/redmond/images/ui-icons_2e83ff_256x240.png +0 -0
- static/js/jquery/css/redmond/images/ui-icons_469bdd_256x240.png +0 -0
- static/js/jquery/css/redmond/images/ui-icons_6da8d5_256x240.png +0 -0
- static/js/jquery/css/redmond/images/ui-icons_cd0a0a_256x240.png +0 -0
- static/js/jquery/css/redmond/images/ui-icons_d8e7f3_256x240.png +0 -0
- static/js/jquery/css/redmond/images/ui-icons_f9bd01_256x240.png +0 -0
- static/js/jquery/css/redmond/jquery-ui.css +0 -0
- static/js/jquery/css/select2/select2-bootstrap.css +0 -0
- static/js/jquery/css/select2/select2-spinner.gif +0 -0
- static/js/jquery/css/select2/select2.css +0 -0
- static/js/jquery/css/select2/select2.png +0 -0
- static/js/jquery/css/smoothness/images/tipsy.gif +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- static/js/jquery/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
- static/js/jquery/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- static/js/jquery/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
- static/js/jquery/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
- static/js/jquery/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- static/js/jquery/css/smoothness/jquery-ui.css +0 -0
- static/js/jquery/css/smoothness/jquery.tipsy.css +1 -1
- static/js/jquery/jquery.ddslick.min.js +1 -0
- static/js/jquery/{jquery.mjs.nestedSortable.js → jquery.mjs.pmxe_nestedSortable.js} +13 -10
- static/js/jquery/jquery.tipsy.js +0 -0
- static/js/jquery/moment.js +0 -0
- static/js/jquery/select2.min.js +0 -0
- static/js/jquery/ui.autocomplete.js +0 -0
- static/js/jquery/ui.datepicker.js +0 -0
- static/js/pmxe.js +0 -0
- views/admin/export/element.php +0 -183
- views/admin/export/index.php +119 -56
- views/admin/export/options.php +245 -0
- views/admin/export/process.php +115 -27
- views/admin/export/template.php +273 -0
- views/admin/export/template/new_field_cpt.php +126 -0
- views/admin/export/template/new_field_shop_order.php +73 -0
- views/admin/export/template/new_field_user.php +97 -0
- views/admin/feedback/index.php +29 -0
- views/admin/help/index.php +24 -12
- views/admin/manage/bulk.php +17 -0
- views/admin/manage/delete.php +11 -0
- views/admin/manage/index.php +355 -0
- views/admin/manage/scheduling.php +57 -0
- views/admin/manage/templates.php +19 -0
- views/admin/manage/update.php +16 -0
- views/admin/settings/index.php +51 -13
- views/controller/error.php +0 -0
- 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', '
|
12 |
Â
// workaround to rename 1st option to `Home`
|
13 |
Â
$submenu['pmxe-admin-home'] = array();
|
14 |
-
add_submenu_page('pmxe-admin-home', __('Export to XML', '
|
15 |
-
add_submenu_page('pmxe-admin-home', __('
|
16 |
-
add_submenu_page('pmxe-admin-home', __('
|
Â
|
|
Â
|
|
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') . ' ‹ ' . __('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') . ' ‹ ' . __('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') . ' ‹ ' . __('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') . ' ‹ ' . __('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') . ' ‹ ' . __('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('/\.[^.]+$/', '', 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 |
-
?>
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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Â
|
|
Â
|
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&utm_medium=filter-rules&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> </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 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â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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 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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('/\.[^.]+$/', '', 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;
|