Version Description
- improvement: pull the parent taxonomy data when exporting variations
- improvement: remove spaces from export filename
- improvement: new filter wp_all_export_after_csv_line
- improvement: date options for sale price dates from/to
- improvement: possibility to use tab as csv delimiter
- improvement: new filter 'wp_all_export_csv_headers'
- bug fix: db schema on multisite
- bug fix: import template for media items
- bug fix: export ACF repeater in XML format
- bug fix: export in CSV format when 'Main XML Tag' & 'Record XML Tag' option are blank
- bug fix: export ACF date_time_picker
Download this release
Release Info
Developer | soflyy |
Plugin | Export WordPress data to XML/CSV |
Version | 1.0.8 |
Comparing to | |
See all releases |
Code changes from version 1.0.7 to 1.0.8
- actions/pmxe_after_export.php +39 -1
- actions/wp_ajax_dismiss_export_warnings.php +23 -0
- actions/wp_ajax_wpae_filtering_count.php +1 -1
- actions/wp_ajax_wpae_preview.php +264 -21
- actions/wp_ajax_wpallexport.php +6 -4
- classes/CdataStrategy.php +7 -0
- classes/CdataStrategyAlways.php +12 -0
- classes/CdataStrategyFactory.php +22 -0
- classes/CdataStrategyIllegalCharacters.php +20 -0
- classes/CdataStrategyIllegalCharactersHtmlEntities.php +12 -0
- classes/CdataStrategyNever.php +12 -0
- classes/XMLWriter.php +396 -31
- classes/wpallimport.php +8 -6
- controllers/admin/export.php +21 -17
- controllers/admin/manage.php +1 -15
- controllers/controller/admin.php +2 -0
- filters/wpallexport_custom_types.php +4 -4
- helpers/pmxe_filter.php +3 -0
- helpers/pmxe_functions.php +2 -2
- helpers/pmxe_render_xml_text.php +6 -3
- helpers/wp_all_export_secure_file.php +1 -1
- libraries/WpaeInvalidPhpException.php +5 -0
- libraries/WpaeInvalidStringException.php +6 -0
- libraries/WpaeMethodNotFoundException.php +6 -0
- libraries/WpaePhpInterpreterErrorHandler.php +58 -0
- libraries/WpaeString.php +150 -0
- libraries/WpaeTooMuchRecursionException.php +6 -0
- libraries/WpaeXmlProcessor.php +548 -0
- libraries/XmlCsvExport.php +269 -277
- libraries/XmlExportACF.php +165 -65
- libraries/XmlExportComment.php +9 -7
- libraries/XmlExportCpt.php +42 -26
- libraries/XmlExportEngine.php +206 -86
- libraries/XmlExportMediaGallery.php +1 -1
- libraries/XmlExportUser.php +57 -77
- libraries/XmlExportWooCommerce.php +45 -7
- libraries/XmlExportWooCommerceOrder.php +538 -72
- libraries/XmlGoogleMerchants.php +156 -54
- libraries/XmlSpec.php +25 -0
- models/export/record.php +60 -11
- readme.txt +15 -2
- schema.php +1 -1
- static/codemirror/autorefresh.js +47 -0
- static/codemirror/codemirror.css +7 -4
- static/codemirror/codemirror.js +58 -1
- static/css/admin.css +141 -13
- static/img/preloader.gif +0 -0
- static/js/admin.js +571 -77
- static/js/jquery/jquery.mjs.pmxe_nestedSortable.js +1 -1
- views/admin/export/blocks/filters.php +2 -1
- views/admin/export/index.php +5 -5
- views/admin/export/template.php +258 -77
- views/admin/export/template/add_new_field.php +7 -0
- views/admin/export/template/advanced_field_options.php +2 -1
- views/admin/export/template/custom_xml_help.php +107 -0
- views/admin/help/index.php +3 -4
- views/admin/manage/index.php +22 -16
- views/admin/manage/scheduling.php +1 -1
- views/admin/manage/update.php +2 -6
- views/admin/settings/index.php +3 -5
- wp-all-export.php +15 -4
actions/pmxe_after_export.php
CHANGED
@@ -30,7 +30,45 @@ function pmxe_pmxe_after_export($export_id, $export)
|
|
30 |
else
|
31 |
{
|
32 |
$filepath = wp_all_export_get_absolute_path($export->options['filepath']);
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
// Split large exports into chunks
|
36 |
if ( $export->options['split_large_exports'] and $splitSize < $export->exported )
|
30 |
else
|
31 |
{
|
32 |
$filepath = wp_all_export_get_absolute_path($export->options['filepath']);
|
33 |
+
}
|
34 |
+
|
35 |
+
$is_export_csv_headers = apply_filters('wp_all_export_is_csv_headers_enabled', true, $export->id);
|
36 |
+
|
37 |
+
// Remove headers row from CSV file
|
38 |
+
if ( ! $is_export_csv_headers && @file_exists($filepath) && $export->options['export_to'] == 'csv' ){
|
39 |
+
|
40 |
+
$tmp_file = str_replace(basename($filepath), 'iteration_' . basename($filepath), $filepath);
|
41 |
+
copy($filepath, $tmp_file);
|
42 |
+
$in = fopen($tmp_file, 'r');
|
43 |
+
$out = fopen($filepath, 'w');
|
44 |
+
|
45 |
+
$headers = fgetcsv($in);
|
46 |
+
|
47 |
+
if (is_resource($in)) {
|
48 |
+
$lineNumber = 0;
|
49 |
+
while ( ! feof($in) ) {
|
50 |
+
$data = fgetcsv($in, 0, XmlExportEngine::$exportOptions['delimiter']);
|
51 |
+
if ( empty($data) ) continue;
|
52 |
+
$data_assoc = array_combine($headers, array_values($data));
|
53 |
+
$line = array();
|
54 |
+
foreach ($headers as $header) {
|
55 |
+
$line[$header] = ( isset($data_assoc[$header]) ) ? $data_assoc[$header] : '';
|
56 |
+
}
|
57 |
+
if ( ! $lineNumber && XmlExportEngine::$exportOptions['include_bom']){
|
58 |
+
fwrite($out, chr(0xEF).chr(0xBB).chr(0xBF));
|
59 |
+
fputcsv($out, $line, XmlExportEngine::$exportOptions['delimiter']);
|
60 |
+
}
|
61 |
+
else{
|
62 |
+
fputcsv($out, $line, XmlExportEngine::$exportOptions['delimiter']);
|
63 |
+
}
|
64 |
+
apply_filters('wp_all_export_after_csv_line', $out, XmlExportEngine::$exportID);
|
65 |
+
$lineNumber++;
|
66 |
+
}
|
67 |
+
fclose($in);
|
68 |
+
}
|
69 |
+
fclose($out);
|
70 |
+
@unlink($tmp_file);
|
71 |
+
}
|
72 |
|
73 |
// Split large exports into chunks
|
74 |
if ( $export->options['split_large_exports'] and $splitSize < $export->exported )
|
actions/wp_ajax_dismiss_export_warnings.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function pmxe_wp_ajax_dismiss_export_warnings(){
|
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( PMXE_Plugin::$capabilities ) ){
|
10 |
+
exit( json_encode(array('html' => __('Security check', 'wp_all_export_plugin'))) );
|
11 |
+
}
|
12 |
+
|
13 |
+
$input = new PMXE_Input();
|
14 |
+
|
15 |
+
$post = $input->post('data', false);
|
16 |
+
|
17 |
+
if ( ! empty($post) && ! empty($post['export_id'])){
|
18 |
+
$option_name = 'wpae_dismiss_warnings_' . $post['export_id'];
|
19 |
+
update_option($option_name, 1);
|
20 |
+
}
|
21 |
+
|
22 |
+
exit(json_encode(array('result' => true)));
|
23 |
+
}
|
actions/wp_ajax_wpae_filtering_count.php
CHANGED
@@ -198,7 +198,7 @@ function pmxe_wp_ajax_wpae_filtering_count(){
|
|
198 |
<?php if ($found_records > 0) :?>
|
199 |
<?php if (XmlExportEngine::$is_user_export || XmlExportEngine::$is_comment_export): ?>
|
200 |
<h3><span class="matches_count"><?php echo $found_records; ?></span> <strong><?php echo wp_all_export_get_cpt_name($cpt, $found_records); ?></strong> can be exported</h3>
|
201 |
-
<h4><?php printf(__('Upgrade to the Pro edition of WP All Export to
|
202 |
<?php else:?>
|
203 |
<h3><span class="matches_count"><?php echo $found_records; ?></span> <strong><?php echo wp_all_export_get_cpt_name($cpt, $found_records); ?></strong> will be exported</h3>
|
204 |
<h4><?php _e("Continue to configure and run your export.", "wp_all_export_plugin"); ?></h4>
|
198 |
<?php if ($found_records > 0) :?>
|
199 |
<?php if (XmlExportEngine::$is_user_export || XmlExportEngine::$is_comment_export): ?>
|
200 |
<h3><span class="matches_count"><?php echo $found_records; ?></span> <strong><?php echo wp_all_export_get_cpt_name($cpt, $found_records); ?></strong> can be exported</h3>
|
201 |
+
<h4><?php printf(__('Upgrade to the Pro edition of WP All Export to Export %s', 'wp_all_export_plugin'), wp_all_export_get_cpt_name($cpt)); ?></h4>
|
202 |
<?php else:?>
|
203 |
<h3><span class="matches_count"><?php echo $found_records; ?></span> <strong><?php echo wp_all_export_get_cpt_name($cpt, $found_records); ?></strong> will be exported</h3>
|
204 |
<h4><?php _e("Continue to configure and run your export.", "wp_all_export_plugin"); ?></h4>
|
actions/wp_ajax_wpae_preview.php
CHANGED
@@ -11,18 +11,30 @@ function pmxe_wp_ajax_wpae_preview(){
|
|
11 |
if ( ! current_user_can( PMXE_Plugin::$capabilities ) ){
|
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 |
-
$export_id = (isset($_GET['id'])) ? stripcslashes($_GET['id']) : 0;
|
22 |
|
23 |
$exportOptions = $values + (PMXE_Plugin::$session->has_session() ? PMXE_Plugin::$session->get_clear_session_data() : array()) + PMXE_Plugin::get_default_import_options();
|
24 |
|
25 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
$engine = new XmlExportEngine($exportOptions, $errors);
|
28 |
|
@@ -31,6 +43,66 @@ function pmxe_wp_ajax_wpae_preview(){
|
|
31 |
XmlExportEngine::$is_comment_export = $exportOptions['is_comment_export'];
|
32 |
XmlExportEngine::$exportID = $export_id;
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
if ( 'advanced' == $exportOptions['export_type'] )
|
35 |
{
|
36 |
if ( XmlExportEngine::$is_user_export )
|
@@ -51,11 +123,15 @@ function pmxe_wp_ajax_wpae_preview(){
|
|
51 |
XmlExportEngine::$post_types = $exportOptions['cpt'];
|
52 |
|
53 |
if ( in_array('users', $exportOptions['cpt']) or in_array('shop_customer', $exportOptions['cpt']))
|
54 |
-
{
|
55 |
-
|
|
|
|
|
56 |
}
|
57 |
elseif( in_array('comments', $exportOptions['cpt']))
|
58 |
-
{
|
|
|
|
|
59 |
global $wp_version;
|
60 |
|
61 |
if ( version_compare($wp_version, '4.2.0', '>=') )
|
@@ -65,7 +141,8 @@ function pmxe_wp_ajax_wpae_preview(){
|
|
65 |
else
|
66 |
{
|
67 |
$exportQuery = get_comments( array( 'orderby' => 'comment_ID', 'order' => 'ASC', 'number' => 10 ));
|
68 |
-
}
|
|
|
69 |
}
|
70 |
else
|
71 |
{
|
@@ -75,23 +152,41 @@ function pmxe_wp_ajax_wpae_preview(){
|
|
75 |
|
76 |
add_filter('posts_join', 'wp_all_export_posts_join', 10, 1);
|
77 |
add_filter('posts_where', 'wp_all_export_posts_where', 10, 1);
|
78 |
-
$exportQuery = new WP_Query( array( 'post_type' => $exportOptions['cpt'], 'post_status' => 'any', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => 10 ));
|
79 |
remove_filter('posts_where', 'wp_all_export_posts_where');
|
80 |
remove_filter('posts_join', 'wp_all_export_posts_join');
|
81 |
}
|
82 |
}
|
83 |
|
84 |
-
XmlExportEngine::$exportQuery = $exportQuery;
|
|
|
|
|
85 |
|
86 |
?>
|
87 |
|
88 |
<div id="post-preview" class="wpallexport-preview">
|
89 |
-
|
90 |
-
<p class="wpallexport-preview-title"><?php echo sprintf("Preview first 10 %s", wp_all_export_get_cpt_name($exportOptions['cpt'], 10)); ?></p>
|
91 |
|
|
|
|
|
92 |
<div class="wpallexport-preview-content">
|
93 |
|
94 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
$wp_uploads = wp_upload_dir();
|
96 |
|
97 |
$functions = $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . WP_ALL_EXPORT_UPLOADS_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'functions.php';
|
@@ -103,19 +198,167 @@ function pmxe_wp_ajax_wpae_preview(){
|
|
103 |
case 'xml':
|
104 |
|
105 |
$dom = new DOMDocument('1.0', $exportOptions['encoding']);
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
-
|
109 |
-
|
110 |
-
$dom->loadXML($xml);
|
111 |
-
libxml_use_internal_errors($old);
|
112 |
-
$xpath = new DOMXPath($dom);
|
113 |
|
114 |
-
|
|
|
|
|
|
|
115 |
|
116 |
-
|
117 |
-
|
118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
break;
|
121 |
|
11 |
if ( ! current_user_can( PMXE_Plugin::$capabilities ) ){
|
12 |
exit( json_encode(array('html' => __('Security check', 'wp_all_export_plugin'))) );
|
13 |
}
|
14 |
+
|
15 |
+
XmlExportEngine::$is_preview = true;
|
16 |
+
|
17 |
+
$custom_xml_valid = true;
|
18 |
+
|
19 |
ob_start();
|
20 |
|
21 |
$values = array();
|
22 |
|
23 |
parse_str($_POST['data'], $values);
|
24 |
|
25 |
+
$export_id = (isset($_GET['id'])) ? stripcslashes($_GET['id']) : 0;
|
26 |
|
27 |
$exportOptions = $values + (PMXE_Plugin::$session->has_session() ? PMXE_Plugin::$session->get_clear_session_data() : array()) + PMXE_Plugin::get_default_import_options();
|
28 |
|
29 |
+
$exportOptions['custom_xml_template'] = (isset($_POST['custom_xml'])) ? stripcslashes($_POST['custom_xml']) : '';
|
30 |
+
$exportOptions['custom_xml_template'] = str_replace('<ID>','<id>', $exportOptions['custom_xml_template'] );
|
31 |
+
$exportOptions['custom_xml_template'] = str_replace('</ID>','</id>', $exportOptions['custom_xml_template'] );
|
32 |
+
|
33 |
+
if ( ! empty($exportOptions['custom_xml_template'])) {
|
34 |
+
$custom_xml_template_line_count = substr_count($exportOptions['custom_xml_template'], "\n");
|
35 |
+
}
|
36 |
+
|
37 |
+
$errors = new WP_Error();
|
38 |
|
39 |
$engine = new XmlExportEngine($exportOptions, $errors);
|
40 |
|
43 |
XmlExportEngine::$is_comment_export = $exportOptions['is_comment_export'];
|
44 |
XmlExportEngine::$exportID = $export_id;
|
45 |
|
46 |
+
|
47 |
+
|
48 |
+
if ( in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ){
|
49 |
+
|
50 |
+
if ( empty(XmlExportEngine::$exportOptions['custom_xml_template']) )
|
51 |
+
{
|
52 |
+
$errors->add('form-validation', __('XML template is empty.', 'wp_all_export_plugin'));
|
53 |
+
}
|
54 |
+
|
55 |
+
if ( ! empty(XmlExportEngine::$exportOptions['custom_xml_template'])){
|
56 |
+
|
57 |
+
$engine->init_additional_data();
|
58 |
+
|
59 |
+
$engine->init_available_data();
|
60 |
+
|
61 |
+
$result = $engine->parse_custom_xml_template();
|
62 |
+
$line_numbers = $result['line_numbers'];
|
63 |
+
if ( ! $errors->get_error_codes()) {
|
64 |
+
XmlExportEngine::$exportOptions = array_merge(XmlExportEngine::$exportOptions, $result);
|
65 |
+
}
|
66 |
+
|
67 |
+
$originalXmlTemplate = $exportOptions['custom_xml_template'];
|
68 |
+
libxml_use_internal_errors(true);
|
69 |
+
libxml_clear_errors();
|
70 |
+
|
71 |
+
//Add root se we make sure there is a root tag
|
72 |
+
$result['original_post_loop'] = '<root>'.$result['original_post_loop'].'</root>';
|
73 |
+
|
74 |
+
$custom_xml_template = simplexml_load_string($result['original_post_loop']);
|
75 |
+
|
76 |
+
if ($custom_xml_template === false) {
|
77 |
+
$custom_xml_template_errors = libxml_get_errors();
|
78 |
+
libxml_clear_errors();
|
79 |
+
$custom_xml_valid = false;
|
80 |
+
// Remove one line because we added root
|
81 |
+
$line_difference = $custom_xml_template_line_count - $line_numbers - 1;
|
82 |
+
}
|
83 |
+
$exportOptions['custom_xml_template'] = str_replace("<!-- BEGIN POST LOOP -->", "<!-- BEGIN LOOP -->", $exportOptions['custom_xml_template']);
|
84 |
+
$exportOptions['custom_xml_template'] = str_replace("<!-- END POST LOOP -->", "<!-- END LOOP -->", $exportOptions['custom_xml_template']);
|
85 |
+
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
if(isset($_GET['show_cdata'])) {
|
90 |
+
XmlExportEngine::$exportOptions['show_cdata_in_preview'] = (bool)$_GET['show_cdata'];
|
91 |
+
} else {
|
92 |
+
XmlExportEngine::$exportOptions['show_cdata_in_preview'] = false;
|
93 |
+
}
|
94 |
+
|
95 |
+
if ( $errors->get_error_codes()) {
|
96 |
+
$msgs = $errors->get_error_messages();
|
97 |
+
if ( ! is_array($msgs)) {
|
98 |
+
$msgs = array($msgs);
|
99 |
+
}
|
100 |
+
foreach ($msgs as $msg): ?>
|
101 |
+
<div class="error"><p><?php echo $msg ?></p></div>
|
102 |
+
<?php endforeach;
|
103 |
+
exit( json_encode(array('html' => ob_get_clean())) );
|
104 |
+
}
|
105 |
+
|
106 |
if ( 'advanced' == $exportOptions['export_type'] )
|
107 |
{
|
108 |
if ( XmlExportEngine::$is_user_export )
|
123 |
XmlExportEngine::$post_types = $exportOptions['cpt'];
|
124 |
|
125 |
if ( in_array('users', $exportOptions['cpt']) or in_array('shop_customer', $exportOptions['cpt']))
|
126 |
+
{
|
127 |
+
add_action('pre_user_query', 'wp_all_export_pre_user_query', 10, 1);
|
128 |
+
$exportQuery = new WP_User_Query( array( 'orderby' => 'ID', 'order' => 'ASC', 'number' => 10 ));
|
129 |
+
remove_action('pre_user_query', 'wp_all_export_pre_user_query');
|
130 |
}
|
131 |
elseif( in_array('comments', $exportOptions['cpt']))
|
132 |
+
{
|
133 |
+
add_action('comments_clauses', 'wp_all_export_comments_clauses', 10, 1);
|
134 |
+
|
135 |
global $wp_version;
|
136 |
|
137 |
if ( version_compare($wp_version, '4.2.0', '>=') )
|
141 |
else
|
142 |
{
|
143 |
$exportQuery = get_comments( array( 'orderby' => 'comment_ID', 'order' => 'ASC', 'number' => 10 ));
|
144 |
+
}
|
145 |
+
remove_action('comments_clauses', 'wp_all_export_comments_clauses');
|
146 |
}
|
147 |
else
|
148 |
{
|
152 |
|
153 |
add_filter('posts_join', 'wp_all_export_posts_join', 10, 1);
|
154 |
add_filter('posts_where', 'wp_all_export_posts_where', 10, 1);
|
155 |
+
$exportQuery = new WP_Query( array( 'post_type' => $exportOptions['cpt'], 'post_status' => 'any', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => 10 ));
|
156 |
remove_filter('posts_where', 'wp_all_export_posts_where');
|
157 |
remove_filter('posts_join', 'wp_all_export_posts_join');
|
158 |
}
|
159 |
}
|
160 |
|
161 |
+
XmlExportEngine::$exportQuery = $exportQuery;
|
162 |
+
|
163 |
+
$engine->init_additional_data();
|
164 |
|
165 |
?>
|
166 |
|
167 |
<div id="post-preview" class="wpallexport-preview">
|
|
|
|
|
168 |
|
169 |
+
<p class="wpallexport-preview-title"><?php echo sprintf("Preview first 10 %s", wp_all_export_get_cpt_name($exportOptions['cpt'], 10)); ?></p>
|
170 |
+
|
171 |
<div class="wpallexport-preview-content">
|
172 |
|
173 |
<?php
|
174 |
+
|
175 |
+
if(!$custom_xml_valid) {
|
176 |
+
$error_msg = '<strong class="error">' . __('Invalid XML', 'wp_all_import_plugin') . '</strong><ul class="error">';
|
177 |
+
foreach($custom_xml_template_errors as $error) {
|
178 |
+
$error_msg .= '<li>';
|
179 |
+
$error_msg .= __('Line', 'wp_all_import_plugin') . ' ' . ($error->line + $line_difference) . ', ';
|
180 |
+
$error_msg .= __('Column', 'wp_all_import_plugin') . ' ' . $error->column . ', ';
|
181 |
+
$error_msg .= __('Code', 'wp_all_import_plugin') . ' ' . $error->code . ': ';
|
182 |
+
$error_msg .= '<em>' . trim(esc_html($error->message)) . '</em>';
|
183 |
+
$error_msg .= '</li>';
|
184 |
+
}
|
185 |
+
$error_msg .= '</ul>';
|
186 |
+
echo $error_msg;
|
187 |
+
exit( json_encode(array('html' => ob_get_clean())) );
|
188 |
+
}
|
189 |
+
|
190 |
$wp_uploads = wp_upload_dir();
|
191 |
|
192 |
$functions = $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . WP_ALL_EXPORT_UPLOADS_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'functions.php';
|
198 |
case 'xml':
|
199 |
|
200 |
$dom = new DOMDocument('1.0', $exportOptions['encoding']);
|
201 |
+
libxml_use_internal_errors(true);
|
202 |
+
try{
|
203 |
+
$xml = XmlCsvExport::export_xml(true);
|
204 |
+
} catch (WpaeMethodNotFoundException $e) {
|
205 |
+
|
206 |
+
// Find the line where the function is
|
207 |
+
$errorMessage = '';
|
208 |
+
$functionName = $e->getMessage();
|
209 |
+
$txtParts = explode("\n",$originalXmlTemplate);
|
210 |
+
for ($i=0, $length = count($txtParts);$i<$length;$i++)
|
211 |
+
{
|
212 |
+
$tmp = strstr($txtParts[$i], $functionName);
|
213 |
+
if ($tmp) {
|
214 |
+
$errorMessage .= 'Error parsing XML feed: Call to undefined function <em>"'.$functionName.'"</em> on Line '.($i+1);
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
$error_msg = '<span class="error">'.__($errorMessage, 'wp_all_import_plugin').'</span>';
|
219 |
+
echo $error_msg;
|
220 |
+
exit( json_encode(array('html' => ob_get_clean())) );
|
221 |
+
} catch (WpaeInvalidStringException $e) {
|
222 |
+
|
223 |
+
// Find the line where the function is
|
224 |
+
$errorMessage = '';
|
225 |
+
$functionName = $e->getMessage();
|
226 |
+
$txtParts = explode("\n",$originalXmlTemplate);
|
227 |
+
for ($i=0, $length = count($txtParts);$i<$length;$i++)
|
228 |
+
{
|
229 |
+
$tmp = strstr($txtParts[$i], $functionName);
|
230 |
+
if ($tmp) {
|
231 |
+
$errorMessage .= 'Error parsing XML feed: Unterminated string on line '.($i+1);
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
+
$error_msg = '<span class="error">'.__($errorMessage, 'wp_all_import_plugin').'</span>';
|
236 |
+
echo $error_msg;
|
237 |
+
exit( json_encode(array('html' => ob_get_clean())) );
|
238 |
+
} catch (WpaeTooMuchRecursionException $e) {
|
239 |
+
$errorMessage = __('There was a problem parsing the custom XML template');
|
240 |
+
$error_msg = '<span class="error">'.__($errorMessage, 'wp_all_import_plugin').'</span>';
|
241 |
+
echo $error_msg;
|
242 |
+
exit( json_encode(array('html' => ob_get_clean())) );
|
243 |
+
|
244 |
+
}
|
245 |
+
|
246 |
+
$xml_errors = false;
|
247 |
+
|
248 |
+
$main_xml_tag = '';
|
249 |
+
|
250 |
+
switch ( XmlExportEngine::$exportOptions['xml_template_type'] ){
|
251 |
+
|
252 |
+
case 'custom':
|
253 |
+
case 'XmlGoogleMerchants':
|
254 |
+
|
255 |
+
require_once PMXE_ROOT_DIR . '/classes/XMLWriter.php';
|
256 |
|
257 |
+
$preview_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . "\n<Preview>\n" . $xml . "\n</Preview>";
|
|
|
|
|
|
|
|
|
258 |
|
259 |
+
$preview_xml = str_replace('<![CDATA[', 'CDATABEGIN', $preview_xml);
|
260 |
+
$preview_xml = str_replace(']]>', 'CDATACLOSE', $preview_xml);
|
261 |
+
$preview_xml = str_replace('&', '&', $preview_xml);
|
262 |
+
$preview_xml = str_replace('&', '&', $preview_xml);
|
263 |
|
264 |
+
$xml = PMXE_XMLWriter::preprocess_xml( XmlExportEngine::$exportOptions['custom_xml_template_header'] ) . "\n" . $xml . "\n" . PMXE_XMLWriter::preprocess_xml( XmlExportEngine::$exportOptions['custom_xml_template_footer'] );
|
265 |
+
|
266 |
+
$xml = str_replace('<![CDATA[', 'CDATABEGIN', $xml);
|
267 |
+
$xml = str_replace(']]>', 'CDATACLOSE', $xml);
|
268 |
+
$xml = str_replace('&', '&', $xml);
|
269 |
+
$xml = str_replace('&', '&', $xml);
|
270 |
+
|
271 |
+
// Determine XML root element
|
272 |
+
preg_match_all("%<[\w]+[\s|>]{1}%", XmlExportEngine::$exportOptions['custom_xml_template_header'], $matches);
|
273 |
+
|
274 |
+
if ( ! empty($matches[0]) ){
|
275 |
+
$main_xml_tag = preg_replace("%[\s|<|>]%","",array_shift($matches[0]));
|
276 |
+
}
|
277 |
+
|
278 |
+
libxml_clear_errors();
|
279 |
+
$dom->loadXML($xml);
|
280 |
+
$xml_errors = libxml_get_errors();
|
281 |
+
libxml_clear_errors();
|
282 |
+
if (! $xml_errors ){
|
283 |
+
$xpath = new DOMXPath($dom);
|
284 |
+
if (($elements = @$xpath->query('/' . $main_xml_tag)) and $elements->length){
|
285 |
+
pmxe_render_xml_element($elements->item( 0 ), true);
|
286 |
+
}
|
287 |
+
else{
|
288 |
+
$xml_errors = true;
|
289 |
+
}
|
290 |
+
}
|
291 |
+
|
292 |
+
break;
|
293 |
+
|
294 |
+
default:
|
295 |
+
|
296 |
+
libxml_clear_errors();
|
297 |
+
$dom->loadXML($xml);
|
298 |
+
$xml_errors = libxml_get_errors();
|
299 |
+
libxml_clear_errors();
|
300 |
+
|
301 |
+
$xpath = new DOMXPath($dom);
|
302 |
+
|
303 |
+
// Determine XML root element
|
304 |
+
$main_xml_tag = apply_filters('wp_all_export_main_xml_tag', $exportOptions['main_xml_tag'], XmlExportEngine::$exportID);
|
305 |
+
$elements = @$xpath->query('/' . $main_xml_tag);
|
306 |
+
if ($elements->length){
|
307 |
+
pmxe_render_xml_element($elements->item( 0 ), true);
|
308 |
+
$xml_errors = false;
|
309 |
+
}
|
310 |
+
else{
|
311 |
+
$error_msg = '<strong>' . __('Can\'t preview the document.', 'wp_all_import_plugin') . '</strong><ul>';
|
312 |
+
$error_msg .= '<li>';
|
313 |
+
$error_msg .= __('You can continue export or try to use <data> tag as root element.', 'wp_all_import_plugin');
|
314 |
+
$error_msg .= '</li>';
|
315 |
+
$error_msg .= '</ul>';
|
316 |
+
echo $error_msg;
|
317 |
+
exit( json_encode(array('html' => ob_get_clean())) );
|
318 |
+
}
|
319 |
+
|
320 |
+
break;
|
321 |
+
|
322 |
+
}
|
323 |
+
|
324 |
+
if ( $xml_errors ){
|
325 |
+
|
326 |
+
$preview_dom = new DOMDocument('1.0', $exportOptions['encoding']);
|
327 |
+
libxml_clear_errors();
|
328 |
+
$preview_dom->loadXML($preview_xml);
|
329 |
+
$preview_xml_errors = libxml_get_errors();
|
330 |
+
libxml_clear_errors();
|
331 |
+
|
332 |
+
if ($preview_xml_errors){
|
333 |
+
$error_msg = '<strong class="error">' . __('Invalid XML', 'wp_all_import_plugin') . '</strong><ul class="error">';
|
334 |
+
foreach($preview_xml_errors as $error) {
|
335 |
+
$error_msg .= '<li>';
|
336 |
+
$error_msg .= __('Line', 'wp_all_import_plugin') . ' ' . $error->line . ', ';
|
337 |
+
$error_msg .= __('Column', 'wp_all_import_plugin') . ' ' . $error->column . ', ';
|
338 |
+
$error_msg .= __('Code', 'wp_all_import_plugin') . ' ' . $error->code . ': ';
|
339 |
+
$error_msg .= '<em>' . trim(esc_html($error->message)) . '</em>';
|
340 |
+
$error_msg .= '</li>';
|
341 |
+
}
|
342 |
+
$error_msg .= '</ul>';
|
343 |
+
echo $error_msg;
|
344 |
+
exit( json_encode(array('html' => ob_get_clean())) );
|
345 |
+
}
|
346 |
+
else{
|
347 |
+
$xpath = new DOMXPath($preview_dom);
|
348 |
+
if (($elements = @$xpath->query('/Preview')) and $elements->length){
|
349 |
+
pmxe_render_xml_element($elements->item( 0 ), true);
|
350 |
+
}
|
351 |
+
else{
|
352 |
+
$error_msg = '<strong>' . __('Can\'t preview the document. Root element is not detected.', 'wp_all_import_plugin') . '</strong><ul>';
|
353 |
+
$error_msg .= '<li>';
|
354 |
+
$error_msg .= __('You can continue export or try to use <data> tag as root element.', 'wp_all_import_plugin');
|
355 |
+
$error_msg .= '</li>';
|
356 |
+
$error_msg .= '</ul>';
|
357 |
+
echo $error_msg;
|
358 |
+
exit( json_encode(array('html' => ob_get_clean())) );
|
359 |
+
}
|
360 |
+
}
|
361 |
+
}
|
362 |
|
363 |
break;
|
364 |
|
actions/wp_ajax_wpallexport.php
CHANGED
@@ -48,11 +48,11 @@ function pmxe_wp_ajax_wpallexport(){
|
|
48 |
{
|
49 |
if (XmlExportEngine::$is_user_export)
|
50 |
{
|
51 |
-
exit( json_encode(array('html' => __('Upgrade to the Pro edition of WP All Export to
|
52 |
}
|
53 |
elseif(XmlExportEngine::$is_comment_export)
|
54 |
{
|
55 |
-
exit( json_encode(array('html' => __('Upgrade to the Pro edition of WP All Export to
|
56 |
}
|
57 |
else
|
58 |
{
|
@@ -75,11 +75,11 @@ function pmxe_wp_ajax_wpallexport(){
|
|
75 |
|
76 |
if (in_array('users', $exportOptions['cpt']) or in_array('shop_customer', $exportOptions['cpt']))
|
77 |
{
|
78 |
-
exit( json_encode(array('html' => __('Upgrade to the Pro edition of WP All Export to
|
79 |
}
|
80 |
elseif(in_array('comments', $exportOptions['cpt']))
|
81 |
{
|
82 |
-
exit( json_encode(array('html' => __('Upgrade to the Pro edition of WP All Export to
|
83 |
}
|
84 |
else
|
85 |
{
|
@@ -97,6 +97,8 @@ function pmxe_wp_ajax_wpallexport(){
|
|
97 |
|
98 |
XmlExportEngine::$exportQuery = $exportQuery;
|
99 |
|
|
|
|
|
100 |
// get total founded records
|
101 |
if (XmlExportEngine::$is_comment_export)
|
102 |
{
|
48 |
{
|
49 |
if (XmlExportEngine::$is_user_export)
|
50 |
{
|
51 |
+
exit( json_encode(array('html' => __('Upgrade to the Pro edition of WP All Export to Export Users', 'wp_all_export_plugin'))) );
|
52 |
}
|
53 |
elseif(XmlExportEngine::$is_comment_export)
|
54 |
{
|
55 |
+
exit( json_encode(array('html' => __('Upgrade to the Pro edition of WP All Export to Export Comments', 'wp_all_export_plugin'))) );
|
56 |
}
|
57 |
else
|
58 |
{
|
75 |
|
76 |
if (in_array('users', $exportOptions['cpt']) or in_array('shop_customer', $exportOptions['cpt']))
|
77 |
{
|
78 |
+
exit( json_encode(array('html' => __('Upgrade to the Pro edition of WP All Export to Export Users', 'wp_all_export_plugin'))) );
|
79 |
}
|
80 |
elseif(in_array('comments', $exportOptions['cpt']))
|
81 |
{
|
82 |
+
exit( json_encode(array('html' => __('Upgrade to the Pro edition of WP All Export to Export Comments', 'wp_all_export_plugin'))) );
|
83 |
}
|
84 |
else
|
85 |
{
|
97 |
|
98 |
XmlExportEngine::$exportQuery = $exportQuery;
|
99 |
|
100 |
+
$engine->init_additional_data();
|
101 |
+
|
102 |
// get total founded records
|
103 |
if (XmlExportEngine::$is_comment_export)
|
104 |
{
|
classes/CdataStrategy.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
interface CdataStrategy
|
5 |
+
{
|
6 |
+
public function should_cdata_be_applied($field);
|
7 |
+
}
|
classes/CdataStrategyAlways.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once('CdataStrategy.php');
|
4 |
+
|
5 |
+
class CdataStrategyAlways implements CdataStrategy
|
6 |
+
{
|
7 |
+
public function should_cdata_be_applied($field)
|
8 |
+
{
|
9 |
+
return true;
|
10 |
+
}
|
11 |
+
|
12 |
+
}
|
classes/CdataStrategyFactory.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once(__DIR__.'/CdataStrategyAlways.php');
|
4 |
+
require_once(__DIR__.'/CdataStrategyIllegalCharacters.php');
|
5 |
+
require_once(__DIR__.'/CdataStrategyNever.php');
|
6 |
+
|
7 |
+
|
8 |
+
class CdataStrategyFactory
|
9 |
+
{
|
10 |
+
public function create_strategy($strategy) {
|
11 |
+
|
12 |
+
if($strategy == 'all') {
|
13 |
+
return new CdataStrategyAlways();
|
14 |
+
} else if($strategy == 'never') {
|
15 |
+
return new CdataStrategyNever();
|
16 |
+
} else if($strategy == 'auto') {
|
17 |
+
return new CdataStrategyIllegalCharacters();
|
18 |
+
} else {
|
19 |
+
return new CdataStrategyIllegalCharacters();
|
20 |
+
}
|
21 |
+
}
|
22 |
+
}
|
classes/CdataStrategyIllegalCharacters.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once('CdataStrategy.php');
|
4 |
+
|
5 |
+
class CdataStrategyIllegalCharacters implements CdataStrategy
|
6 |
+
{
|
7 |
+
private $illegalCharacters = ['<','>','&', '\'', '"'];
|
8 |
+
|
9 |
+
public function should_cdata_be_applied($field)
|
10 |
+
{
|
11 |
+
foreach($this->illegalCharacters as $character) {
|
12 |
+
if(strpos($field, $character) !== false) {
|
13 |
+
return true;
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
return false;
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
classes/CdataStrategyIllegalCharactersHtmlEntities.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once('CdataStrategy.php');
|
4 |
+
|
5 |
+
class CdataStrategyIllegalCharactersHtmlEntities implements CdataStrategy
|
6 |
+
{
|
7 |
+
public function should_cdata_be_applied($field)
|
8 |
+
{
|
9 |
+
return strlen($field) != strlen(htmlentities($field));
|
10 |
+
}
|
11 |
+
|
12 |
+
}
|
classes/CdataStrategyNever.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once('CdataStrategy.php');
|
4 |
+
|
5 |
+
class CdataStrategyNever implements CdataStrategy
|
6 |
+
{
|
7 |
+
public function should_cdata_be_applied($field)
|
8 |
+
{
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
|
12 |
+
}
|
classes/XMLWriter.php
CHANGED
@@ -1,37 +1,402 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
class PMXE_XMLWriter extends XMLWriter
|
4 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
if (empty($ns))
|
9 |
-
{
|
10 |
-
return $this->writeElement( $element, $value );
|
11 |
-
}
|
12 |
-
else
|
13 |
-
{
|
14 |
-
return $this->writeElementNS( $ns, $element, $uri, $value );
|
15 |
-
}
|
16 |
-
}
|
17 |
-
|
18 |
-
public function beginElement($ns, $element, $uri)
|
19 |
-
{
|
20 |
-
if (empty($ns))
|
21 |
-
{
|
22 |
-
return $this->startElement( $element );
|
23 |
-
}
|
24 |
-
else
|
25 |
-
{
|
26 |
-
return $this->startElementNS( $ns, $element, $uri );
|
27 |
-
}
|
28 |
-
}
|
29 |
-
|
30 |
-
public function writeData( $value, $element_name )
|
31 |
-
{
|
32 |
-
$is_wrap_into_cdata = ! ( empty($value) or is_numeric($value) );
|
33 |
-
$wrap_value_into_cdata = apply_filters('wp_all_export_is_wrap_value_into_cdata', $is_wrap_into_cdata, $value, $element_name);
|
34 |
-
if ( $wrap_value_into_cdata === false ) $this->text($value); else $this->writeCData($value);
|
35 |
-
}
|
36 |
-
|
37 |
}
|
1 |
<?php
|
2 |
|
3 |
+
// Handle eval errors that cause the script to finish
|
4 |
+
$wpaeErrorHandler = new WpaePhpInterpreterErrorHandler();
|
5 |
+
register_shutdown_function(array($wpaeErrorHandler, 'handle'));
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class PMXE_XMLWriter
|
9 |
+
*/
|
10 |
class PMXE_XMLWriter extends XMLWriter
|
11 |
{
|
12 |
+
/**
|
13 |
+
* @var array
|
14 |
+
*/
|
15 |
+
public $articles = array();
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @param array $articles
|
20 |
+
*/
|
21 |
+
public function writeArticle($articles = array())
|
22 |
+
{
|
23 |
+
|
24 |
+
$article = array_shift($articles);
|
25 |
+
|
26 |
+
if (!empty($articles)) {
|
27 |
+
|
28 |
+
$keys = array();
|
29 |
+
foreach ($articles as $a) {
|
30 |
+
|
31 |
+
foreach ($a as $key => $value) {
|
32 |
+
|
33 |
+
if (!isset($article[$key])) {
|
34 |
+
$article[$key] = array($value);
|
35 |
+
} else {
|
36 |
+
$article[$key] = array($article[$key], $value);
|
37 |
+
}
|
38 |
+
|
39 |
+
if (!in_array($key, $keys)) $keys[] = $key;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
if (!empty($article)) {
|
45 |
+
foreach ($article as $key => $value) {
|
46 |
+
if (!is_array($value) && strpos($value, '#delimiter#') !== FALSE) {
|
47 |
+
$article[$key] = explode('#delimiter#', $value);
|
48 |
+
}
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
$this->articles[] = $article;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @param $ns
|
57 |
+
* @param $element
|
58 |
+
* @param $uri
|
59 |
+
* @param $value
|
60 |
+
* @return bool
|
61 |
+
*/
|
62 |
+
public function putElement($ns, $element, $uri, $value)
|
63 |
+
{
|
64 |
+
if (in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants'))) return true;
|
65 |
+
|
66 |
+
if (empty($ns)) {
|
67 |
+
return $this->writeElement($element, $value);
|
68 |
+
} else {
|
69 |
+
return $this->writeElementNS($ns, $element, $uri, $value);
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @param $ns
|
75 |
+
* @param $element
|
76 |
+
* @param $uri
|
77 |
+
* @return bool
|
78 |
+
*/
|
79 |
+
public function beginElement($ns, $element, $uri)
|
80 |
+
{
|
81 |
+
if (in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants'))) return true;
|
82 |
+
|
83 |
+
if (empty($ns)) {
|
84 |
+
return $this->startElement($element);
|
85 |
+
} else {
|
86 |
+
return $this->startElementNS($ns, $element, $uri);
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @return bool
|
92 |
+
*/
|
93 |
+
public function closeElement()
|
94 |
+
{
|
95 |
+
|
96 |
+
if (in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants'))) return true;
|
97 |
+
|
98 |
+
return $this->endElement();
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @param $value
|
103 |
+
* @param $element_name
|
104 |
+
*
|
105 |
+
* @return bool
|
106 |
+
*/
|
107 |
+
public function writeData($value, $element_name)
|
108 |
+
{
|
109 |
+
if (in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants'))) return true;
|
110 |
+
|
111 |
+
$cdataStrategyFactory = new CdataStrategyFactory();
|
112 |
+
|
113 |
+
if (!isset(XmlExportEngine::$exportOptions['custom_xml_cdata_logic'])) {
|
114 |
+
XmlExportEngine::$exportOptions['custom_xml_cdata_logic'] = 'auto';
|
115 |
+
}
|
116 |
+
$cdataStrategy = $cdataStrategyFactory->create_strategy(XmlExportEngine::$exportOptions['custom_xml_cdata_logic']);
|
117 |
+
$is_wrap_into_cdata = $cdataStrategy->should_cdata_be_applied($value);
|
118 |
+
|
119 |
+
$wrap_value_into_cdata = apply_filters('wp_all_export_is_wrap_value_into_cdata', $is_wrap_into_cdata, $value, $element_name);
|
120 |
+
|
121 |
+
if ($wrap_value_into_cdata === false) {
|
122 |
+
$this->writeRaw($value);
|
123 |
+
} else {
|
124 |
+
if (XmlExportEngine::$is_preview && XmlExportEngine::$exportOptions['show_cdata_in_preview']) {
|
125 |
+
$this->text('CDATABEGIN' . $value . 'CDATACLOSE');
|
126 |
+
} else if (XmlExportEngine::$is_preview && !XmlExportEngine::$exportOptions['show_cdata_in_preview']) {
|
127 |
+
return $this->text($value);
|
128 |
+
} else {
|
129 |
+
$this->writeCdata($value);
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* @return mixed|string
|
136 |
+
*/
|
137 |
+
public function wpae_flush()
|
138 |
+
{
|
139 |
+
if (!in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants'))) return $this->flush(true);
|
140 |
+
|
141 |
+
$xml = '';
|
142 |
+
foreach ($this->articles as $article) {
|
143 |
+
|
144 |
+
$founded_values = array_keys($article);
|
145 |
+
$node_tpl = XmlExportEngine::$exportOptions['custom_xml_template_loop'];
|
146 |
+
|
147 |
+
// clean up XPaths for not found values
|
148 |
+
$node_tpl = str_replace('{ID}', '{id}', $node_tpl);
|
149 |
+
preg_match_all("%(\{[^\}\{]*\})%", $node_tpl, $matches);
|
150 |
+
$xpaths = array_unique($matches[0]);
|
151 |
+
|
152 |
+
if (!empty($xpaths)) {
|
153 |
+
foreach ($xpaths as $xpath) {
|
154 |
+
if (!in_array(preg_replace("%[\{\}]%", "", $xpath), $founded_values)) {
|
155 |
+
$node_tpl = str_replace($xpath, "", $node_tpl);
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
foreach ($article as $key => $value) {
|
161 |
+
switch ($key) {
|
162 |
+
case 'id':
|
163 |
+
$node_tpl = str_replace('{id}', '{' . $value . '}', $node_tpl);
|
164 |
+
break;
|
165 |
+
default:
|
166 |
+
// replace [ and ]
|
167 |
+
$v = str_replace(']', 'CLOSEBRAKET', str_replace('[', 'OPENBRAKET', $value));
|
168 |
+
// replace { and }
|
169 |
+
$v = str_replace('}', 'CLOSECURVE', str_replace('{', 'OPENCURVE', $v));
|
170 |
+
|
171 |
+
$originalValue = $v;
|
172 |
+
|
173 |
+
if (is_array($v)) {
|
174 |
+
$delimiter = uniqid();
|
175 |
+
$v = "[explode('" . $delimiter . "', '" . implode($delimiter, $v) . "')]";
|
176 |
+
} else {
|
177 |
+
$v = '{' . $v . '}';
|
178 |
+
}
|
179 |
+
|
180 |
+
$arrayTypes = array(
|
181 |
+
'Product Tags', 'Tags', 'Product Categories', 'Categories', 'Image URL', 'Image Filename', 'Image Path', 'Image ID', 'Image Title', 'Image Caption', 'Image Description', 'Image Alt Text', 'Product Type', 'Categories'
|
182 |
+
);
|
183 |
+
|
184 |
+
// We have an empty array, which is transformed into {}
|
185 |
+
if(in_array($key, $arrayTypes) && $v == "{}") {
|
186 |
+
$delimiter = uniqid();
|
187 |
+
$v = "[explode('" . $delimiter . "', '" . implode($delimiter, array()) . "')]";
|
188 |
+
}
|
189 |
+
|
190 |
+
// We have an array with just one value (Which is transformed into a string)
|
191 |
+
if(in_array($key, $arrayTypes) && count($originalValue) == 1) {
|
192 |
+
$delimiter = uniqid();
|
193 |
+
$v = "[explode('" . $delimiter . "', '" . implode($delimiter, array($originalValue)) . "')]";
|
194 |
+
}
|
195 |
+
|
196 |
+
$node_tpl = str_replace('{' . $key . '}', $v, $node_tpl);
|
197 |
+
|
198 |
+
break;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
$xml .= $node_tpl;
|
203 |
+
}
|
204 |
+
|
205 |
+
$this->articles = array();
|
206 |
+
|
207 |
+
$wpaeString = new WpaeString();
|
208 |
+
$xmlPrepreocesor = new WpaeXmlProcessor($wpaeString);
|
209 |
+
return $xmlPrepreocesor->process($xml);
|
210 |
+
}
|
211 |
+
|
212 |
+
public static function getIndentationCount($content, $str)
|
213 |
+
{
|
214 |
+
$lines = explode("\r", $content);
|
215 |
+
foreach ($lines as $lineNumber => $line) {
|
216 |
+
if (strpos($line, $str) !== false) {
|
217 |
+
return substr_count($line, "\t");
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
return -1;
|
222 |
+
}
|
223 |
+
|
224 |
+
public static function indentTag($tag, $indentationCount, $index)
|
225 |
+
{
|
226 |
+
if($index == 0) {
|
227 |
+
$indentationString = "";
|
228 |
+
} else {
|
229 |
+
$indentationString = str_repeat("\t", $indentationCount);
|
230 |
+
}
|
231 |
+
|
232 |
+
return $indentationString . $tag;
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* @param string $xml
|
237 |
+
* @return mixed|string
|
238 |
+
*
|
239 |
+
* @throws WpaeInvalidStringException
|
240 |
+
* @throws WpaeMethodNotFoundException
|
241 |
+
*/
|
242 |
+
public static function preprocess_xml($xml = '')
|
243 |
+
{
|
244 |
+
$xml = str_replace('<![CDATA[', 'DOMCdataSection', $xml);
|
245 |
+
|
246 |
+
preg_match_all("%(\[[^\]\[]*\])%", $xml, $matches);
|
247 |
+
$snipets = empty($matches) ? array() : array_unique($matches[0]);
|
248 |
+
$simple_snipets = array();
|
249 |
+
preg_match_all("%(\{[^\}\{]*\})%", $xml, $matches);
|
250 |
+
$xpaths = array_unique($matches[0]);
|
251 |
+
|
252 |
+
if (!empty($xpaths)) {
|
253 |
+
foreach ($xpaths as $xpath) {
|
254 |
+
if (!in_array($xpath, $snipets)) $simple_snipets[] = $xpath;
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
if (!empty($snipets)) {
|
259 |
+
foreach ($snipets as $snipet) {
|
260 |
+
// if function is found
|
261 |
+
if (preg_match("%\w+\(.*\)%", $snipet)) {
|
262 |
+
|
263 |
+
$filtered = trim(trim(trim($snipet, "]"), "["));
|
264 |
+
$filtered = preg_replace("%[\{\}]%", "\"", $filtered);
|
265 |
+
$filtered = str_replace('CLOSEBRAKET', ']', str_replace('OPENBRAKET', '[', $filtered));
|
266 |
+
$filtered = str_replace('CLOSECURVE', '}', str_replace('OPENCURVE', '{', $filtered));
|
267 |
+
|
268 |
+
$functionName = self::sanitizeFunctionName($filtered);
|
269 |
+
|
270 |
+
$numberOfSingleQuotes = substr_count($filtered, "'");
|
271 |
+
$numberOfDoubleQuotes = substr_count($filtered, "\"");
|
272 |
+
|
273 |
+
if ($numberOfSingleQuotes % 2 || $numberOfDoubleQuotes % 2) {
|
274 |
+
throw new WpaeInvalidStringException($functionName);
|
275 |
+
}
|
276 |
+
|
277 |
+
if (!function_exists($functionName)) {
|
278 |
+
throw new WpaeMethodNotFoundException($functionName);
|
279 |
+
}
|
280 |
+
|
281 |
+
$values = eval("return " . $filtered . ";");
|
282 |
+
|
283 |
+
$v = '';
|
284 |
+
if (is_array($values)) {
|
285 |
+
$tag = false;
|
286 |
+
|
287 |
+
preg_match_all("%(<[\w]+[\s|>]{1})" . preg_quote($snipet) . "%", $xml, $matches);
|
288 |
+
|
289 |
+
if (!empty($matches[1])) {
|
290 |
+
$tag = array_shift($matches[1]);
|
291 |
+
}
|
292 |
+
if (empty($tag)) $tag = "<item>";
|
293 |
+
|
294 |
+
$indentationCount = self::getIndentationCount($xml, $tag);
|
295 |
+
|
296 |
+
$i = 0;
|
297 |
+
foreach ($values as $number => $value) {
|
298 |
+
$v .= self::indentTag($tag . self::maybe_cdata($value) . str_replace("<", "</", $tag) . "\n", $indentationCount, $i);
|
299 |
+
$i++;
|
300 |
+
}
|
301 |
+
|
302 |
+
$xml = str_replace($tag . $snipet . str_replace("<", "</", $tag), $v, $xml);
|
303 |
+
} else {
|
304 |
+
$xml = str_replace($snipet, self::maybe_cdata($values), $xml);
|
305 |
+
}
|
306 |
+
}
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
if (!empty($simple_snipets)) {
|
311 |
+
foreach ($simple_snipets as $snipet) {
|
312 |
+
$filtered = preg_replace("%[\{\}]%", "", $snipet);
|
313 |
+
|
314 |
+
$is_attribute = false;
|
315 |
+
|
316 |
+
//Encode data in attributes
|
317 |
+
if (strpos($xml, "\"$snipet\"") !== false || strpos($xml, "'$snipet'") !== false) {
|
318 |
+
$is_attribute = true;
|
319 |
+
$filtered = str_replace('&', '&', $filtered);
|
320 |
+
$filtered = str_replace('&', '&', $filtered);
|
321 |
+
$filtered = str_replace('\'', ''', $filtered);
|
322 |
+
$filtered = str_replace('"', '"', $filtered);
|
323 |
+
$filtered = str_replace('<', '<', $filtered);
|
324 |
+
$filtered = str_replace('>', '>', $filtered);
|
325 |
+
}
|
326 |
+
|
327 |
+
$filtered = str_replace('CLOSEBRAKET', ']', str_replace('OPENBRAKET', '[', $filtered));
|
328 |
+
$filtered = str_replace('CLOSECURVE', '}', str_replace('OPENCURVE', '{', $filtered));
|
329 |
+
|
330 |
+
if ($is_attribute) {
|
331 |
+
$xml = str_replace($snipet, $filtered, $xml);
|
332 |
+
} else {
|
333 |
+
$xml = str_replace($snipet, self::maybe_cdata($filtered), $xml);
|
334 |
+
}
|
335 |
+
}
|
336 |
+
}
|
337 |
+
|
338 |
+
$xml = str_replace('DOMCdataSection', '<![CDATA[', $xml);
|
339 |
+
|
340 |
+
return $xml;
|
341 |
+
}
|
342 |
+
|
343 |
+
/**
|
344 |
+
* @param $v
|
345 |
+
* @return string
|
346 |
+
*/
|
347 |
+
public static function maybe_cdata($v)
|
348 |
+
{
|
349 |
+
|
350 |
+
if (XmlExportEngine::$is_preview) {
|
351 |
+
$v = str_replace('&', '&', $v);
|
352 |
+
$v = htmlspecialchars($v);
|
353 |
+
}
|
354 |
+
|
355 |
+
if (XmlExportEngine::$is_preview && !XmlExportEngine::$exportOptions['show_cdata_in_preview']) {
|
356 |
+
return $v;
|
357 |
+
}
|
358 |
+
|
359 |
+
$cdataStrategyFactory = new CdataStrategyFactory();
|
360 |
+
|
361 |
+
if (!isset(XmlExportEngine::$exportOptions['custom_xml_cdata_logic'])) {
|
362 |
+
XmlExportEngine::$exportOptions['custom_xml_cdata_logic'] = 'auto';
|
363 |
+
}
|
364 |
+
|
365 |
+
$cdataStrategy = $cdataStrategyFactory->create_strategy(XmlExportEngine::$exportOptions['custom_xml_cdata_logic']);
|
366 |
+
$is_wrap_into_cdata = $cdataStrategy->should_cdata_be_applied($v);
|
367 |
+
|
368 |
+
if ($is_wrap_into_cdata === false) {
|
369 |
+
return $v;
|
370 |
+
} else {
|
371 |
+
if (XmlExportEngine::$is_preview && XmlExportEngine::$exportOptions['show_cdata_in_preview']) {
|
372 |
+
return 'CDATABEGIN' . $v . 'CDATACLOSE';
|
373 |
+
} else {
|
374 |
+
return "<![CDATA[" . $v . "]]>";
|
375 |
+
}
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* @param $filtered
|
381 |
+
* @return mixed
|
382 |
+
*/
|
383 |
+
private static function sanitizeFunctionName($filtered)
|
384 |
+
{
|
385 |
+
$functionName = preg_replace('/"[^"]+"/', '', $filtered);
|
386 |
+
$functionName = preg_replace('/\'[^\']+\'/', '', $functionName);
|
387 |
+
|
388 |
+
$firstSingleQuote = strpos($functionName, '\'');
|
389 |
+
$firstDoubleQuote = strpos($functionName, '"');
|
390 |
+
|
391 |
+
if ($firstDoubleQuote < $firstSingleQuote && $firstDoubleQuote != 0) {
|
392 |
+
$functionName = explode('"', $functionName);
|
393 |
+
$functionName = $functionName[0];
|
394 |
+
} else if ($firstSingleQuote != 0) {
|
395 |
+
$functionName = explode('\'', $functionName);
|
396 |
+
$functionName = $functionName[0];
|
397 |
+
}
|
398 |
+
$functionName = str_replace(['(', ')', ',', ' ', '\'', '"'], '', $functionName);
|
399 |
|
400 |
+
return $functionName;
|
401 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
402 |
}
|
classes/wpallimport.php
CHANGED
@@ -210,8 +210,6 @@ final class PMXE_Wpallimport
|
|
210 |
'make_simple_product' => 1,
|
211 |
'single_product_regular_price_adjust_type' => '%',
|
212 |
'single_product_sale_price_adjust_type' => '%',
|
213 |
-
'is_update_attributes' => 1,
|
214 |
-
'update_attributes_logic' => 'full_update',
|
215 |
'is_variation_product_manage_stock' => 'no',
|
216 |
'variation_stock_status' => 'auto'
|
217 |
);
|
@@ -326,7 +324,7 @@ final class PMXE_Wpallimport
|
|
326 |
|
327 |
$tpl_data = array(
|
328 |
'name' => $exportOptions['template_name'],
|
329 |
-
'is_keep_linebreaks' =>
|
330 |
'is_leave_html' => 0,
|
331 |
'fix_characters' => 0,
|
332 |
'options' => $tpl_options,
|
@@ -499,11 +497,11 @@ final class PMXE_Wpallimport
|
|
499 |
$field_options = unserialize($options['cc_options'][$ID]);
|
500 |
|
501 |
// add ACF group ID to the template options
|
502 |
-
if( !
|
503 |
-
|
504 |
}
|
505 |
|
506 |
-
|
507 |
|
508 |
break;
|
509 |
|
@@ -527,9 +525,13 @@ final class PMXE_Wpallimport
|
|
527 |
if ( ! empty($attr_list) )
|
528 |
{
|
529 |
self::$templateOptions['is_update_attributes'] = 1;
|
|
|
530 |
self::$templateOptions['attributes_list'] = $attr_list;
|
531 |
self::$templateOptions['attributes_only_list'] = implode(',', $attr_list);
|
532 |
}
|
|
|
|
|
|
|
533 |
if ( ! empty($taxs_list) )
|
534 |
{
|
535 |
self::$templateOptions['is_update_categories'] = 1;
|
210 |
'make_simple_product' => 1,
|
211 |
'single_product_regular_price_adjust_type' => '%',
|
212 |
'single_product_sale_price_adjust_type' => '%',
|
|
|
|
|
213 |
'is_variation_product_manage_stock' => 'no',
|
214 |
'variation_stock_status' => 'auto'
|
215 |
);
|
324 |
|
325 |
$tpl_data = array(
|
326 |
'name' => $exportOptions['template_name'],
|
327 |
+
'is_keep_linebreaks' => 1,
|
328 |
'is_leave_html' => 0,
|
329 |
'fix_characters' => 0,
|
330 |
'options' => $tpl_options,
|
497 |
$field_options = unserialize($options['cc_options'][$ID]);
|
498 |
|
499 |
// add ACF group ID to the template options
|
500 |
+
if( ! in_array($field_options['group_id'], self::$templateOptions['acf'])){
|
501 |
+
self::$templateOptions['acf'][$field_options['group_id']] = 1;
|
502 |
}
|
503 |
|
504 |
+
self::$templateOptions['fields'][$field_options['key']] = XmlExportACF::prepare_import_template( $options, self::$templateOptions, $acf_list, $element_name, $field_options);
|
505 |
|
506 |
break;
|
507 |
|
525 |
if ( ! empty($attr_list) )
|
526 |
{
|
527 |
self::$templateOptions['is_update_attributes'] = 1;
|
528 |
+
self::$templateOptions['update_attributes_logic'] = 'only';
|
529 |
self::$templateOptions['attributes_list'] = $attr_list;
|
530 |
self::$templateOptions['attributes_only_list'] = implode(',', $attr_list);
|
531 |
}
|
532 |
+
else{
|
533 |
+
self::$templateOptions['is_update_attributes'] = 0;
|
534 |
+
}
|
535 |
if ( ! empty($taxs_list) )
|
536 |
{
|
537 |
self::$templateOptions['is_update_categories'] = 1;
|
controllers/admin/export.php
CHANGED
@@ -178,7 +178,8 @@ class PMXE_Admin_Export extends PMXE_Controller_Admin {
|
|
178 |
|
179 |
$default = PMXE_Plugin::get_default_import_options();
|
180 |
|
181 |
-
|
|
|
182 |
$DefaultOptions = (PMXE_Plugin::$session->has_session() ? PMXE_Plugin::$session->get_clear_session_data() : array()) + $default;
|
183 |
$post = $this->input->post($DefaultOptions);
|
184 |
}
|
@@ -190,7 +191,7 @@ class PMXE_Admin_Export extends PMXE_Controller_Admin {
|
|
190 |
foreach ($post as $key => $value) {
|
191 |
PMXE_Plugin::$session->set($key, $value);
|
192 |
}
|
193 |
-
|
194 |
}
|
195 |
|
196 |
$max_input_vars = @ini_get('max_input_vars');
|
@@ -233,6 +234,23 @@ class PMXE_Admin_Export extends PMXE_Controller_Admin {
|
|
233 |
$this->errors->add('form-validation', __('CSV delimiter must be specified.', 'wp_all_export_plugin'));
|
234 |
}
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
if ( ! $this->errors->get_error_codes()) {
|
237 |
|
238 |
if ( ! empty($post['name']) and !empty($post['save_template_as']) ) { // save template in database
|
@@ -305,21 +323,7 @@ class PMXE_Admin_Export extends PMXE_Controller_Admin {
|
|
305 |
|
306 |
if ($this->input->post('is_submitted')) {
|
307 |
|
308 |
-
check_admin_referer('options', '_wpnonce_options');
|
309 |
-
|
310 |
-
$post['main_xml_tag'] = preg_replace('/[^a-z0-9]/i', '', $post['main_xml_tag']);
|
311 |
-
if ( empty($post['main_xml_tag']) ){
|
312 |
-
$this->errors->add('form-validation', __('Main XML Tag is required.', 'wp_all_export_plugin'));
|
313 |
-
}
|
314 |
-
|
315 |
-
$post['record_xml_tag'] = preg_replace('/[^a-z0-9]/i', '', $post['record_xml_tag']);
|
316 |
-
if ( empty($post['record_xml_tag']) ){
|
317 |
-
$this->errors->add('form-validation', __('Single Record XML Tag is required.', 'wp_all_export_plugin'));
|
318 |
-
}
|
319 |
-
|
320 |
-
if ($post['main_xml_tag'] == $post['record_xml_tag']){
|
321 |
-
$this->errors->add('form-validation', __('Main XML Tag equals to Single Record XML Tag.', 'wp_all_export_plugin'));
|
322 |
-
}
|
323 |
|
324 |
if ($post['is_generate_templates'] and '' == $post['template_name']){
|
325 |
$friendly_name = '';
|
178 |
|
179 |
$default = PMXE_Plugin::get_default_import_options();
|
180 |
|
181 |
+
$this->data['dismiss_warnings'] = 0;
|
182 |
+
if ($this->isWizard) {
|
183 |
$DefaultOptions = (PMXE_Plugin::$session->has_session() ? PMXE_Plugin::$session->get_clear_session_data() : array()) + $default;
|
184 |
$post = $this->input->post($DefaultOptions);
|
185 |
}
|
191 |
foreach ($post as $key => $value) {
|
192 |
PMXE_Plugin::$session->set($key, $value);
|
193 |
}
|
194 |
+
$this->data['dismiss_warnings'] = get_option('wpae_dismiss_warnings_' . $this->data['export']->id, 0);
|
195 |
}
|
196 |
|
197 |
$max_input_vars = @ini_get('max_input_vars');
|
234 |
$this->errors->add('form-validation', __('CSV delimiter must be specified.', 'wp_all_export_plugin'));
|
235 |
}
|
236 |
|
237 |
+
if ( 'xml' == $post['export_to'] )
|
238 |
+
{
|
239 |
+
$post['main_xml_tag'] = preg_replace('/[^a-z0-9]/i', '', $post['main_xml_tag']);
|
240 |
+
if ( empty($post['main_xml_tag']) ){
|
241 |
+
$this->errors->add('form-validation', __('Main XML Tag is required.', 'wp_all_export_plugin'));
|
242 |
+
}
|
243 |
+
|
244 |
+
$post['record_xml_tag'] = preg_replace('/[^a-z0-9]/i', '', $post['record_xml_tag']);
|
245 |
+
if ( empty($post['record_xml_tag']) ){
|
246 |
+
$this->errors->add('form-validation', __('Single Record XML Tag is required.', 'wp_all_export_plugin'));
|
247 |
+
}
|
248 |
+
|
249 |
+
if ($post['main_xml_tag'] == $post['record_xml_tag']){
|
250 |
+
$this->errors->add('form-validation', __('Main XML Tag equals to Single Record XML Tag.', 'wp_all_export_plugin'));
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
if ( ! $this->errors->get_error_codes()) {
|
255 |
|
256 |
if ( ! empty($post['name']) and !empty($post['save_template_as']) ) { // save template in database
|
323 |
|
324 |
if ($this->input->post('is_submitted')) {
|
325 |
|
326 |
+
check_admin_referer('options', '_wpnonce_options');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
|
328 |
if ($post['is_generate_templates'] and '' == $post['template_name']){
|
329 |
$friendly_name = '';
|
controllers/admin/manage.php
CHANGED
@@ -173,21 +173,7 @@ class PMXE_Admin_Manage extends PMXE_Controller_Admin {
|
|
173 |
|
174 |
if ($this->input->post('is_confirmed')) {
|
175 |
|
176 |
-
check_admin_referer('update-export', '_wpnonce_update-export');
|
177 |
-
|
178 |
-
$post['main_xml_tag'] = preg_replace('/[^a-z0-9]/i', '', $post['main_xml_tag']);
|
179 |
-
if ( empty($post['main_xml_tag']) ){
|
180 |
-
$this->errors->add('form-validation', __('Main XML Tag is required.', 'wp_all_export_plugin'));
|
181 |
-
}
|
182 |
-
|
183 |
-
$post['record_xml_tag'] = preg_replace('/[^a-z0-9]/i', '', $post['record_xml_tag']);
|
184 |
-
if ( empty($post['record_xml_tag']) ){
|
185 |
-
$this->errors->add('form-validation', __('Single Record XML Tag is required.', 'wp_all_export_plugin'));
|
186 |
-
}
|
187 |
-
|
188 |
-
if ($post['main_xml_tag'] == $post['record_xml_tag']){
|
189 |
-
$this->errors->add('form-validation', __('Main XML Tag equals to Single Record XML Tag.', 'wp_all_export_plugin'));
|
190 |
-
}
|
191 |
|
192 |
$iteration = ( empty($item->options['creata_a_new_export_file']) && ! empty($post['creata_a_new_export_file'])) ? 0 : $item->iteration;
|
193 |
|
173 |
|
174 |
if ($this->input->post('is_confirmed')) {
|
175 |
|
176 |
+
check_admin_referer('update-export', '_wpnonce_update-export');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
$iteration = ( empty($item->options['creata_a_new_export_file']) && ! empty($post['creata_a_new_export_file'])) ? 0 : $item->iteration;
|
179 |
|
controllers/controller/admin.php
CHANGED
@@ -79,6 +79,8 @@ abstract class PMXE_Controller_Admin extends PMXE_Controller {
|
|
79 |
wp_enqueue_script('jquery-codemirror-javascript', PMXE_ROOT_URL . '/static/codemirror/javascript.js', array('jquery-codemirror-xml'), PMXE_VERSION);
|
80 |
wp_enqueue_script('jquery-codemirror-clike', PMXE_ROOT_URL . '/static/codemirror/clike.js', array('jquery-codemirror-javascript'), PMXE_VERSION);
|
81 |
wp_enqueue_script('jquery-codemirror-php', PMXE_ROOT_URL . '/static/codemirror/php.js', array('jquery-codemirror-clike'), PMXE_VERSION);
|
|
|
|
|
82 |
wp_enqueue_script('wp-pointer');
|
83 |
|
84 |
/* load plupload scripts */
|
79 |
wp_enqueue_script('jquery-codemirror-javascript', PMXE_ROOT_URL . '/static/codemirror/javascript.js', array('jquery-codemirror-xml'), PMXE_VERSION);
|
80 |
wp_enqueue_script('jquery-codemirror-clike', PMXE_ROOT_URL . '/static/codemirror/clike.js', array('jquery-codemirror-javascript'), PMXE_VERSION);
|
81 |
wp_enqueue_script('jquery-codemirror-php', PMXE_ROOT_URL . '/static/codemirror/php.js', array('jquery-codemirror-clike'), PMXE_VERSION);
|
82 |
+
wp_enqueue_script('jquery-codemirror-autorefresh', PMXE_ROOT_URL . '/static/codemirror/autorefresh.js', array('jquery-codemirror'), PMXE_VERSION);
|
83 |
+
|
84 |
wp_enqueue_script('wp-pointer');
|
85 |
|
86 |
/* load plupload scripts */
|
filters/wpallexport_custom_types.php
CHANGED
@@ -4,9 +4,9 @@ function pmxe_wpallexport_custom_types($custom_types)
|
|
4 |
{
|
5 |
if (class_exists('WooCommerce'))
|
6 |
{
|
7 |
-
if ( ! empty($custom_types['product'])) $custom_types['product']->labels->name = __('Products','wp_all_export_plugin');
|
8 |
-
if ( ! empty($custom_types['shop_order'])) $custom_types['shop_order']->labels->name = __('Orders','wp_all_export_plugin');
|
9 |
-
if ( ! empty($custom_types['shop_coupon'])) $custom_types['shop_coupon']->labels->name = __('Coupons','wp_all_export_plugin');
|
10 |
if ( ! empty($custom_types['product_variation'])) unset($custom_types['product_variation']);
|
11 |
if ( ! empty($custom_types['shop_order_refund'])) unset($custom_types['shop_order_refund']);
|
12 |
|
@@ -23,7 +23,7 @@ function pmxe_wpallexport_custom_types($custom_types)
|
|
23 |
{
|
24 |
$ordered_custom_types['shop_customer'] = new stdClass();
|
25 |
$ordered_custom_types['shop_customer']->labels = new stdClass();
|
26 |
-
$ordered_custom_types['shop_customer']->labels->name = __('Customers','wp_all_export_plugin');
|
27 |
}
|
28 |
else
|
29 |
{
|
4 |
{
|
5 |
if (class_exists('WooCommerce'))
|
6 |
{
|
7 |
+
if ( ! empty($custom_types['product'])) $custom_types['product']->labels->name = __('WooCommerce Products','wp_all_export_plugin');
|
8 |
+
if ( ! empty($custom_types['shop_order'])) $custom_types['shop_order']->labels->name = __('WooCommerce Orders','wp_all_export_plugin');
|
9 |
+
if ( ! empty($custom_types['shop_coupon'])) $custom_types['shop_coupon']->labels->name = __('WooCommerce Coupons','wp_all_export_plugin');
|
10 |
if ( ! empty($custom_types['product_variation'])) unset($custom_types['product_variation']);
|
11 |
if ( ! empty($custom_types['shop_order_refund'])) unset($custom_types['shop_order_refund']);
|
12 |
|
23 |
{
|
24 |
$ordered_custom_types['shop_customer'] = new stdClass();
|
25 |
$ordered_custom_types['shop_customer']->labels = new stdClass();
|
26 |
+
$ordered_custom_types['shop_customer']->labels->name = __('WooCommerce Customers','wp_all_export_plugin');
|
27 |
}
|
28 |
else
|
29 |
{
|
helpers/pmxe_filter.php
CHANGED
@@ -1,4 +1,7 @@
|
|
1 |
<?php
|
2 |
function pmxe_filter($value, $custom_func){
|
|
|
|
|
|
|
3 |
return $value;
|
4 |
}
|
1 |
<?php
|
2 |
function pmxe_filter($value, $custom_func){
|
3 |
+
if ( ! empty($custom_func) and "" != $custom_func and function_exists($custom_func)){
|
4 |
+
return call_user_func($custom_func, $value);
|
5 |
+
}
|
6 |
return $value;
|
7 |
}
|
helpers/pmxe_functions.php
CHANGED
@@ -64,7 +64,7 @@
|
|
64 |
|
65 |
$_existing_meta_keys = array();
|
66 |
if ( ! empty($meta_keys)){
|
67 |
-
$exclude_keys = array('_first_variation_attributes', '_is_first_variation_created'
|
68 |
foreach ($meta_keys as $meta_key) {
|
69 |
if ( strpos($meta_key->meta_key, "_tmp") === false && strpos($meta_key->meta_key, "_v_") === false && ! in_array($meta_key->meta_key, $exclude_keys))
|
70 |
$_existing_meta_keys[] = $meta_key->meta_key;
|
@@ -86,7 +86,7 @@
|
|
86 |
foreach ($post_taxonomies as $tx) {
|
87 |
if (strpos($tx->name, "pa_") !== 0)
|
88 |
$_existing_taxonomies[] = array(
|
89 |
-
'name' => $tx->label,
|
90 |
'label' => $tx->name,
|
91 |
'type' => 'cats'
|
92 |
);
|
64 |
|
65 |
$_existing_meta_keys = array();
|
66 |
if ( ! empty($meta_keys)){
|
67 |
+
$exclude_keys = array('_first_variation_attributes', '_is_first_variation_created');
|
68 |
foreach ($meta_keys as $meta_key) {
|
69 |
if ( strpos($meta_key->meta_key, "_tmp") === false && strpos($meta_key->meta_key, "_v_") === false && ! in_array($meta_key->meta_key, $exclude_keys))
|
70 |
$_existing_meta_keys[] = $meta_key->meta_key;
|
86 |
foreach ($post_taxonomies as $tx) {
|
87 |
if (strpos($tx->name, "pa_") !== 0)
|
88 |
$_existing_taxonomies[] = array(
|
89 |
+
'name' => empty($tx->label) ? $tx->name : $tx->label,
|
90 |
'label' => $tx->name,
|
91 |
'type' => 'cats'
|
92 |
);
|
helpers/pmxe_render_xml_text.php
CHANGED
@@ -14,8 +14,11 @@ function pmxe_render_xml_text($text, $shorten = false, $is_render_collapsed = fa
|
|
14 |
$text = $mtch[0];
|
15 |
$more = '<span class="xml-more">[' . __('more', 'pmxi_plugin') . ']</span>';
|
16 |
}
|
|
|
|
|
|
|
|
|
|
|
17 |
$is_short = strlen($text) <= 40;
|
18 |
-
|
19 |
-
$text = preg_replace('%(?<!\s)\b(?!\s|\W[\w\s])|\w{20}%', '$0​', $text); // put explicit breaks for xml content to wrap
|
20 |
-
echo '<div class="xml-content textonly' . ($is_short ? ' short' : '') . ($is_render_collapsed ? ' collapsed' : '') . '">' . $text . $more . '</div>';
|
21 |
}
|
14 |
$text = $mtch[0];
|
15 |
$more = '<span class="xml-more">[' . __('more', 'pmxi_plugin') . ']</span>';
|
16 |
}
|
17 |
+
$text = esc_html($text);
|
18 |
+
// $text = preg_replace('%(?<!\s)\b(?!\s|\W[\w\s])|\w{20}%', '$0​', $text); // put explicit breaks for xml content to wrap
|
19 |
+
$is_cdata = ( strpos($text, 'CDATABEGIN') !== false );
|
20 |
+
$text = str_replace('CDATABEGIN', '<![CDATA[', $text);
|
21 |
+
$text = str_replace('CDATACLOSE', ']]>', $text);
|
22 |
$is_short = strlen($text) <= 40;
|
23 |
+
echo '<div class="xml-content textonly' . ($is_short ? ' short' : '') . ($is_cdata ? ' cdata' : '') . ($is_render_collapsed ? ' collapsed' : '') . '">' . $text . $more . '</div>';
|
|
|
|
|
24 |
}
|
helpers/wp_all_export_secure_file.php
CHANGED
@@ -9,7 +9,7 @@ if ( ! function_exists('wp_all_export_secure_file') ){
|
|
9 |
|
10 |
$dir = $targetDir . DIRECTORY_SEPARATOR . ( ( $ID ) ? md5( $ID . NONCE_SALT ) : md5( time() . NONCE_SALT ) );
|
11 |
|
12 |
-
@mkdir($dir, 0755);
|
13 |
|
14 |
if (@is_writable($dir) and @is_dir($dir)){
|
15 |
$targetDir = $dir;
|
9 |
|
10 |
$dir = $targetDir . DIRECTORY_SEPARATOR . ( ( $ID ) ? md5( $ID . NONCE_SALT ) : md5( time() . NONCE_SALT ) );
|
11 |
|
12 |
+
if ( ! is_dir($dir) ) @mkdir($dir, 0755);
|
13 |
|
14 |
if (@is_writable($dir) and @is_dir($dir)){
|
15 |
$targetDir = $dir;
|
libraries/WpaeInvalidPhpException.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WpaeInvalidPhpException extends Exception
|
4 |
+
{
|
5 |
+
}
|
libraries/WpaeInvalidStringException.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WpaeInvalidStringException extends Exception
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
libraries/WpaeMethodNotFoundException.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WpaeMethodNotFoundException extends Exception
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
libraries/WpaePhpInterpreterErrorHandler.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WpaePhpInterpreterErrorHandler
|
4 |
+
{
|
5 |
+
public function handle(){
|
6 |
+
|
7 |
+
$error = $this->getLastError();
|
8 |
+
if($error && strpos($error['file'], 'functions.php') !== false){
|
9 |
+
$wp_uploads = $this->getUploadsDir();
|
10 |
+
$functions = 'in '.$wp_uploads['basedir'] . DIRECTORY_SEPARATOR . WP_ALL_EXPORT_UPLOADS_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'functions.php:'.$error['line'];
|
11 |
+
$error['message'] = str_replace($functions, '', $error['message']);
|
12 |
+
$error['message'] = str_replace("\\n",'',$error['message']);
|
13 |
+
$errorParts = explode('Stack trace', $error['message']);
|
14 |
+
$error['message'] = $errorParts[0];
|
15 |
+
$error['message'] .=' on line '.$error['line'];
|
16 |
+
$error['message'] = str_replace("\n",'',$error['message']);
|
17 |
+
$error['message'] = str_replace("Uncaught Error:", '', $error['message']);
|
18 |
+
$error['message'] = 'PHP Error: ' . $error['message'];
|
19 |
+
$error['message'] = str_replace(' ', ' ', $error['message']);
|
20 |
+
echo "[[ERROR]]";
|
21 |
+
if($error['message'] == '') {
|
22 |
+
$error['message'] = __('An unknown error occured', 'wp_all_import_plugin');
|
23 |
+
}
|
24 |
+
$this->terminate(json_encode(array('error' => '<span class="error">'.$error['message'].'</span>', 'line' => $error['line'], 'title' => __('An error occurred','wp_all_import_plugin'))));
|
25 |
+
} else if(strpos($error['file'], 'XMLWriter.php') !== false ) {
|
26 |
+
if(strpos($error['message'],'syntax error, unexpected') !== false) {
|
27 |
+
echo "[[ERROR]]";
|
28 |
+
$this->terminate(json_encode(array('error'=>__('You probably forgot to close a quote', 'wp_all_import_plugin'),'title' => __('An error occurred','wp_all_import_plugin'))));
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @return array
|
35 |
+
*/
|
36 |
+
protected function getLastError()
|
37 |
+
{
|
38 |
+
return error_get_last();
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return mixed
|
43 |
+
*/
|
44 |
+
protected function getUploadsDir()
|
45 |
+
{
|
46 |
+
return wp_upload_dir();
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Hack to be able to test the class in isolation
|
51 |
+
*
|
52 |
+
* @param $message
|
53 |
+
*/
|
54 |
+
protected function terminate($message)
|
55 |
+
{
|
56 |
+
exit($message);
|
57 |
+
}
|
58 |
+
}
|
libraries/WpaeString.php
ADDED
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class WpaeString
|
5 |
+
{
|
6 |
+
public function isBetween($haystack, $search, $start, $end)
|
7 |
+
{
|
8 |
+
if($haystack == $search) {
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
if (strpos($haystack, $start) === false) {
|
12 |
+
return false;
|
13 |
+
}
|
14 |
+
|
15 |
+
$haystack = str_replace($search, "#SNIPPET#", $haystack);
|
16 |
+
$search = "#SNIPPET#";
|
17 |
+
|
18 |
+
$searchPosition = strpos($haystack, $search);
|
19 |
+
|
20 |
+
$firstString = substr($haystack, 0, $searchPosition);
|
21 |
+
$lastString = substr($haystack, $searchPosition + strlen($search), strlen($haystack));
|
22 |
+
|
23 |
+
$isInFirstString = false;
|
24 |
+
$isInLastString = false;
|
25 |
+
|
26 |
+
// Make sure the number of strings in the part before and after is not equal
|
27 |
+
// to exclude cases like [a]b[c] we want only cases like a[b]c
|
28 |
+
$numberOfStartInFirstString = substr_count($firstString, $start);
|
29 |
+
$numberOfEndInFirstString = substr_count($firstString, $end);
|
30 |
+
|
31 |
+
$numberOfStartInLastString = substr_count($lastString, $start);
|
32 |
+
$numberOfEndInLastString = substr_count($lastString, $end);
|
33 |
+
|
34 |
+
if(strpos($firstString, $start) !== false && $numberOfStartInFirstString - $numberOfEndInFirstString) {
|
35 |
+
$isInFirstString = true;
|
36 |
+
}
|
37 |
+
|
38 |
+
if(strpos($lastString, $end) !== false && $numberOfStartInLastString - $numberOfEndInLastString) {
|
39 |
+
$isInLastString = true;
|
40 |
+
}
|
41 |
+
|
42 |
+
return $isInFirstString && $isInLastString;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @param $sanitizedSnippet
|
47 |
+
* @return mixed
|
48 |
+
*/
|
49 |
+
public function quoteParams($sanitizedSnippet)
|
50 |
+
{
|
51 |
+
|
52 |
+
if(strpos($sanitizedSnippet, 'array') !== false) {
|
53 |
+
return $sanitizedSnippet;
|
54 |
+
}
|
55 |
+
|
56 |
+
if(strpos($sanitizedSnippet, '"') === false && strpos($sanitizedSnippet, "'") === false ) {
|
57 |
+
$sanitizedSnippet = str_replace("(","(\"",$sanitizedSnippet);
|
58 |
+
$sanitizedSnippet = str_replace(")","\")",$sanitizedSnippet);
|
59 |
+
|
60 |
+
return $sanitizedSnippet;
|
61 |
+
}
|
62 |
+
|
63 |
+
$sanitizedString = "";
|
64 |
+
|
65 |
+
$isInString = false;
|
66 |
+
|
67 |
+
for($i=0; $i< strlen($sanitizedSnippet); $i++) {
|
68 |
+
if($sanitizedSnippet[$i] == "\"") {
|
69 |
+
if($isInString) {
|
70 |
+
$isInString = false;
|
71 |
+
} else {
|
72 |
+
$isInString = true;
|
73 |
+
}
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
if($sanitizedSnippet[$i] === "," && $isInString) {
|
78 |
+
$sanitizedString.="*middlecomma*";
|
79 |
+
} else {
|
80 |
+
$sanitizedString .= $sanitizedSnippet[$i];
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
$sanitizedSnippet = $sanitizedString;
|
85 |
+
|
86 |
+
if(strpos($sanitizedSnippet,"(") !== false && strpos($sanitizedSnippet, ")") !== false) {
|
87 |
+
|
88 |
+
$sanitizedSnippet = str_replace("()", '("")', $sanitizedSnippet);
|
89 |
+
$parts = explode("(", $sanitizedSnippet);
|
90 |
+
if (!isset($parts[1])) {
|
91 |
+
//TODO: Can this happen?
|
92 |
+
}
|
93 |
+
$params = $parts[1];
|
94 |
+
$parameterPart = $parts[1];
|
95 |
+
$originalParameterPart = $parts[1];
|
96 |
+
|
97 |
+
$params = explode(")", $params);
|
98 |
+
$params = $params[0];
|
99 |
+
|
100 |
+
if (strpos($params, ",") !== false) {
|
101 |
+
$params = explode(",", $params);
|
102 |
+
} else {
|
103 |
+
$params = [$params];
|
104 |
+
}
|
105 |
+
|
106 |
+
foreach ($params as $param) {
|
107 |
+
if (!preg_match('/".*"/', $param)) {
|
108 |
+
$parameterPart = str_replace(','.$param, ',"' .trim($param) . '"', $parameterPart);
|
109 |
+
$parameterPart = str_replace('('.$param, '("' .trim($param) . '"', $parameterPart);
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
$sanitizedSnippet = str_replace($originalParameterPart, $parameterPart, $sanitizedSnippet);
|
114 |
+
}
|
115 |
+
|
116 |
+
$sanitizedSnippet = str_replace('*middlecomma*', ',', $sanitizedSnippet);
|
117 |
+
|
118 |
+
return $sanitizedSnippet;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* @param $sanitizedSnippet
|
123 |
+
* @return string
|
124 |
+
*/
|
125 |
+
private function quoteStringWithTokenizer($sanitizedSnippet)
|
126 |
+
{
|
127 |
+
$sanitizedSnippet = explode("(", $sanitizedSnippet);
|
128 |
+
$functionName = $sanitizedSnippet[0];
|
129 |
+
$sanitizedSnippet = $sanitizedSnippet[1];
|
130 |
+
$sanitizedSnippet = str_replace(')', '', $sanitizedSnippet);
|
131 |
+
|
132 |
+
$tokens = token_get_all('<?php ' . $sanitizedSnippet . ' ?>');
|
133 |
+
|
134 |
+
$sanitizedString = "";
|
135 |
+
|
136 |
+
foreach ($tokens as $token) {
|
137 |
+
if ($token[0] == 319) {
|
138 |
+
$sanitizedString .= '"' . $token[1] . '",';
|
139 |
+
}
|
140 |
+
if ($token[0] == 323) {
|
141 |
+
$sanitizedString .= $token[1] . ',';
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
$sanitizedString = substr($sanitizedString, 0, -1);
|
146 |
+
$sanitizedString = $functionName . '(' . $sanitizedSnippet . ')';
|
147 |
+
|
148 |
+
return $sanitizedString;
|
149 |
+
}
|
150 |
+
}
|
libraries/WpaeTooMuchRecursionException.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WpaeTooMuchRecursionException extends Exception
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
libraries/WpaeXmlProcessor.php
ADDED
@@ -0,0 +1,548 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WpaeXmlProcessor
|
4 |
+
{
|
5 |
+
/** @var array */
|
6 |
+
protected $tags;
|
7 |
+
|
8 |
+
/** @var string */
|
9 |
+
protected $xml;
|
10 |
+
|
11 |
+
/** @var DOMDocument */
|
12 |
+
private $dom;
|
13 |
+
|
14 |
+
private $step = 0;
|
15 |
+
|
16 |
+
/** @var WpaeString */
|
17 |
+
private $wpaeString;
|
18 |
+
|
19 |
+
public function __construct(WpaeString $wpaeString)
|
20 |
+
{
|
21 |
+
$this->wpaeString = $wpaeString;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function process($xml)
|
25 |
+
{
|
26 |
+
$this->step = 0;
|
27 |
+
|
28 |
+
$xml = $this->preprocessXml($xml);
|
29 |
+
$xml = $this->handleSimpleSnippets($xml);
|
30 |
+
|
31 |
+
// Add a snippet to trigger a process
|
32 |
+
$snippetCount = count($this->parseSnippetsInString($xml));
|
33 |
+
if($snippetCount == 0 ) {
|
34 |
+
$xml .="<filler>[str_replace('a','b','c')]</filler>";
|
35 |
+
}
|
36 |
+
|
37 |
+
// While we have snippets
|
38 |
+
while ($snippetCount = count($this->parseSnippetsInString($xml))) {
|
39 |
+
|
40 |
+
$this->step++;
|
41 |
+
$xml = '<root>' . $xml . '</root>';
|
42 |
+
$this->initVariables($xml);
|
43 |
+
|
44 |
+
$root = $this->dom->getElementsByTagName("root");
|
45 |
+
$this->dom->recover = true;
|
46 |
+
$this->parseElement($root->item(0));
|
47 |
+
|
48 |
+
$this->dom->preserveWhiteSpace = false;
|
49 |
+
$this->dom->formatOutput = true;
|
50 |
+
$response = $this->dom->saveXML($this->dom);
|
51 |
+
|
52 |
+
$xml = $this->cleanResponse($xml, $response);
|
53 |
+
|
54 |
+
if ($this->step > 8) {
|
55 |
+
throw new WpaeTooMuchRecursionException('Too much recursion');
|
56 |
+
}
|
57 |
+
}
|
58 |
+
$xml = $this->postProcessXml($xml);
|
59 |
+
$xml = $this->decodeSpecialCharacters($xml);
|
60 |
+
$xml = $this->encodeSpecialCharsInAttributes($xml);
|
61 |
+
|
62 |
+
return $xml;
|
63 |
+
}
|
64 |
+
|
65 |
+
private function parseElement(DOMNode $element)
|
66 |
+
{
|
67 |
+
if($element->hasAttributes() && $element->nodeValue == '') {
|
68 |
+
$textNode = new DOMText('##FILLER##');
|
69 |
+
$element->appendChild($textNode);
|
70 |
+
return $this->parseElement($textNode);
|
71 |
+
}
|
72 |
+
if ($element->nodeType === XML_TEXT_NODE) {
|
73 |
+
$nodeAttributes = $this->getNodeAttributes($element->parentNode);
|
74 |
+
|
75 |
+
$snippets = $this->parseSnippetsInString($element->nodeValue . $nodeAttributes);
|
76 |
+
$maxTagValues = 0;
|
77 |
+
$tagValues = array();
|
78 |
+
|
79 |
+
if (count($snippets) > 0) {
|
80 |
+
if (count($snippets) == 1) {
|
81 |
+
$snippet = $snippets[0];
|
82 |
+
$isInFunction = $this->wpaeString->isBetween($nodeAttributes.$element->nodeValue, $snippet, '[',']');
|
83 |
+
|
84 |
+
$snippetValues = $this->processSnippet($snippet, $isInFunction);
|
85 |
+
|
86 |
+
if (!is_array($snippetValues)) {
|
87 |
+
$newValueNode = $element->parentNode->cloneNode(true);
|
88 |
+
$newValueNode->nodeValue =
|
89 |
+
str_replace(
|
90 |
+
$snippet,
|
91 |
+
$snippetValues,
|
92 |
+
$newValueNode->nodeValue
|
93 |
+
);
|
94 |
+
// If the element has attributes, replace the values in them also
|
95 |
+
$this->replaceSnippetInAttributes($newValueNode, $snippet, $snippetValues);
|
96 |
+
$this->elementCdata($newValueNode);
|
97 |
+
$element->parentNode->parentNode->replaceChild($newValueNode, $element->parentNode);
|
98 |
+
} else {
|
99 |
+
foreach ($snippetValues as $snippetValue) {
|
100 |
+
$newValueNode = $element->parentNode->cloneNode(true);
|
101 |
+
$newValueNode->nodeValue = str_replace($snippet, $snippetValue, $newValueNode->nodeValue);
|
102 |
+
$this->replaceSnippetInAttributes($newValueNode, $snippet, $snippetValue);
|
103 |
+
$this->elementCdata($newValueNode);
|
104 |
+
$element->parentNode->parentNode->appendChild($newValueNode);
|
105 |
+
}
|
106 |
+
|
107 |
+
$element->parentNode->parentNode->removeChild($element->parentNode);
|
108 |
+
}
|
109 |
+
} else if (count($snippets) > 1) {
|
110 |
+
foreach ($snippets as $snippet) {
|
111 |
+
$wholeValue = $nodeAttributes.$element->nodeValue;
|
112 |
+
$wholeValue = str_replace("\n", '', $wholeValue);
|
113 |
+
$isInFunction = $this->wpaeString->isBetween($wholeValue, $snippet, '[',']');
|
114 |
+
$snippetValue = $this->processSnippet($snippet,$isInFunction);
|
115 |
+
|
116 |
+
$tagValues[$snippet] = $snippetValue;
|
117 |
+
|
118 |
+
|
119 |
+
if (count($tagValues[$snippet]) > $maxTagValues) {
|
120 |
+
$maxTagValues = count($tagValues[$snippet]);
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
//We have arrays
|
125 |
+
if ($maxTagValues > 1) {
|
126 |
+
for ($i = 0; $i < $maxTagValues; $i++) {
|
127 |
+
$elementClone = $element->parentNode->cloneNode(true);
|
128 |
+
$elementValue = $elementClone->nodeValue;
|
129 |
+
|
130 |
+
foreach ($snippets as $snippet) {
|
131 |
+
// We might have the case that
|
132 |
+
// there are arrays but also implodes in the same tag
|
133 |
+
if(is_array($tagValues[$snippet])) {
|
134 |
+
if (isset($tagValues[$snippet][$i])) {
|
135 |
+
$elementValue = str_replace($snippet, $tagValues[$snippet][$i], $elementValue);
|
136 |
+
$this->replaceSnippetInAttributes($elementClone, $snippet, $tagValues[$snippet][$i]);
|
137 |
+
|
138 |
+
} else {
|
139 |
+
$elementValue = str_replace($snippet, "", $elementValue);
|
140 |
+
$this->replaceSnippetInAttributes($elementClone, $snippet, "");
|
141 |
+
}
|
142 |
+
} else {
|
143 |
+
$elementValue = str_replace($snippet, $tagValues[$snippet], $elementValue);
|
144 |
+
$this->replaceSnippetInAttributes($elementClone, $snippet, $tagValues[$snippet]);
|
145 |
+
}
|
146 |
+
}
|
147 |
+
$elementClone->nodeValue = $elementValue;
|
148 |
+
$this->elementCdata($elementClone);
|
149 |
+
$element->parentNode->parentNode->appendChild($elementClone);
|
150 |
+
}
|
151 |
+
$element->parentNode->parentNode->removeChild($element->parentNode);
|
152 |
+
} else {
|
153 |
+
// Doing this to replace multiple snippet in the same tag (not to treat them as array and
|
154 |
+
// replace the snippet with the first letter of the string
|
155 |
+
foreach ($snippets as $snippet) {
|
156 |
+
if(isset($tagValues[$snippet])){
|
157 |
+
$element->nodeValue = str_replace($snippet, $tagValues[$snippet], $element->nodeValue);
|
158 |
+
$this->replaceSnippetInAttributes($element->parentNode, $snippet, $tagValues[$snippet]);
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
}
|
163 |
+
}
|
164 |
+
$this->elementCdata($element);
|
165 |
+
} else {
|
166 |
+
if ($element->hasChildNodes()) {
|
167 |
+
for ($i = 0; $i < $element->childNodes->length; $i++) {
|
168 |
+
$this->parseElement($element->childNodes->item($i));
|
169 |
+
}
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* @param $filtered
|
176 |
+
* @return mixed
|
177 |
+
*/
|
178 |
+
private function sanitizeFunctionName($filtered)
|
179 |
+
{
|
180 |
+
$functionName = preg_replace('/"[^"]+"/', '', $filtered);
|
181 |
+
$functionName = preg_replace('/\'[^\']+\'/', '', $functionName);
|
182 |
+
$functionName = str_replace('array','', $functionName);
|
183 |
+
|
184 |
+
$firstSingleQuote = strpos($functionName, '\'');
|
185 |
+
$firstDoubleQuote = strpos($functionName, '"');
|
186 |
+
|
187 |
+
if ($firstDoubleQuote < $firstSingleQuote && $firstDoubleQuote != 0) {
|
188 |
+
$functionName = explode('"', $functionName);
|
189 |
+
$functionName = $functionName[0];
|
190 |
+
} else if ($firstSingleQuote != 0) {
|
191 |
+
$functionName = explode('\'', $functionName);
|
192 |
+
$functionName = $functionName[0];
|
193 |
+
}
|
194 |
+
$functionName = str_replace(['(', ')', ',', ' ', '\'', '"'], '', $functionName);
|
195 |
+
|
196 |
+
return $functionName;
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* @param $originalTag
|
201 |
+
* @return array
|
202 |
+
*/
|
203 |
+
private function parseSnippetsInString($originalTag)
|
204 |
+
{
|
205 |
+
$results = array();
|
206 |
+
$matches = array();
|
207 |
+
preg_match_all("%(\[[^\]\[]*\])%", $originalTag, $matches);
|
208 |
+
|
209 |
+
$snippets = empty($matches) ? array() : array_unique($matches[0]);
|
210 |
+
|
211 |
+
foreach ($snippets as $snippet) {
|
212 |
+
$isCdataString = '<![CDATA' . $snippet;
|
213 |
+
|
214 |
+
if (strpos($this->xml, $isCdataString) === false) {
|
215 |
+
$results[] = $snippet;
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
return $results;
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* @param $v
|
224 |
+
* @return string
|
225 |
+
*/
|
226 |
+
private function maybe_cdata($v)
|
227 |
+
{
|
228 |
+
if (XmlExportEngine::$is_preview) {
|
229 |
+
$v = str_replace('&', '&', $v);
|
230 |
+
$v = htmlspecialchars($v);
|
231 |
+
}
|
232 |
+
|
233 |
+
if (XmlExportEngine::$is_preview && !XmlExportEngine::$exportOptions['show_cdata_in_preview']) {
|
234 |
+
return $v;
|
235 |
+
}
|
236 |
+
|
237 |
+
$cdataStrategyFactory = new CdataStrategyFactory();
|
238 |
+
|
239 |
+
if (!isset(XmlExportEngine::$exportOptions['custom_xml_cdata_logic'])) {
|
240 |
+
XmlExportEngine::$exportOptions['custom_xml_cdata_logic'] = 'auto';
|
241 |
+
}
|
242 |
+
$cdataStrategy = $cdataStrategyFactory->create_strategy(XmlExportEngine::$exportOptions['custom_xml_cdata_logic']);
|
243 |
+
$is_wrap_into_cdata = $cdataStrategy->should_cdata_be_applied($this->decodeSpecialCharacters($v));
|
244 |
+
|
245 |
+
if ($is_wrap_into_cdata === false) {
|
246 |
+
return $v;
|
247 |
+
} else {
|
248 |
+
return 'CDATABEGIN' . $v . 'CDATACLOSE';
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* @param $filtered
|
254 |
+
* @param $functionName
|
255 |
+
* @throws WpaeInvalidStringException
|
256 |
+
*/
|
257 |
+
private function checkCorrectNumberOfQuotes($filtered, $functionName)
|
258 |
+
{
|
259 |
+
$numberOfSingleQuotes = substr_count($filtered, "'");
|
260 |
+
$numberOfDoubleQuotes = substr_count($filtered, "\"");
|
261 |
+
|
262 |
+
if ($numberOfSingleQuotes % 2 || $numberOfDoubleQuotes % 2) {
|
263 |
+
throw new WpaeInvalidStringException($functionName);
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* @param $filtered
|
269 |
+
* @return mixed
|
270 |
+
*/
|
271 |
+
private function sanitizeAttribute($filtered)
|
272 |
+
{
|
273 |
+
$filtered = str_replace('&', '&', $filtered);
|
274 |
+
$filtered = str_replace('&', '&', $filtered);
|
275 |
+
$filtered = str_replace("'", ''', $filtered);
|
276 |
+
$filtered = str_replace('"', '"', $filtered);
|
277 |
+
$filtered = str_replace('<', '<', $filtered);
|
278 |
+
$filtered = str_replace('>', '>', $filtered);
|
279 |
+
return $filtered;
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* @param $functionName
|
284 |
+
* @throws WpaeMethodNotFoundException
|
285 |
+
*/
|
286 |
+
private function checkIfFunctionExists($functionName)
|
287 |
+
{
|
288 |
+
if (!function_exists($functionName) && $functionName != 'array') {
|
289 |
+
throw new WpaeMethodNotFoundException($functionName);
|
290 |
+
}
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* @param $snippet
|
295 |
+
* @return mixed
|
296 |
+
*/
|
297 |
+
private function sanitizeSnippet($snippet)
|
298 |
+
{
|
299 |
+
$sanitizedSnippet = str_replace(array('[', ']'), '', $snippet);
|
300 |
+
$sanitizedSnippet = str_replace('\'', '"', $sanitizedSnippet);
|
301 |
+
|
302 |
+
return $sanitizedSnippet;
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* @param $xml
|
307 |
+
*
|
308 |
+
* @return mixed
|
309 |
+
*/
|
310 |
+
private function handleSimpleSnippets($xml)
|
311 |
+
{
|
312 |
+
preg_match_all("%(\[[^\]\[]*\])%", $xml, $matches);
|
313 |
+
$snippets = empty($matches) ? array() : array_unique($matches[0]);
|
314 |
+
|
315 |
+
$simple_snipets = array();
|
316 |
+
preg_match_all("%(\{[^\}\{]*\})%", $xml, $matches);
|
317 |
+
$xpaths = array_unique($matches[0]);
|
318 |
+
|
319 |
+
if (!empty($xpaths)) {
|
320 |
+
foreach ($xpaths as $xpath) {
|
321 |
+
if (!in_array($xpath, $snippets)) $simple_snipets[] = $xpath;
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
if (!empty($simple_snipets)) {
|
326 |
+
foreach ($simple_snipets as $snippet) {
|
327 |
+
|
328 |
+
$filtered = preg_replace("%[\{\}]%", "", $snippet);
|
329 |
+
|
330 |
+
//Encode data in attributes
|
331 |
+
if (strpos($xml, "\"$snippet\"") !== false || strpos($xml, "'$snippet'") !== false) {
|
332 |
+
$attributeValue = str_replace('&', '&', $filtered);
|
333 |
+
$attributeValue = str_replace('&', '&', $attributeValue);
|
334 |
+
$attributeValue = str_replace('\'', ''', $attributeValue);
|
335 |
+
$attributeValue = str_replace('"', '"', $attributeValue);
|
336 |
+
$attributeValue = str_replace('<', '<', $attributeValue);
|
337 |
+
$attributeValue = str_replace('>', '>', $attributeValue);
|
338 |
+
|
339 |
+
$xml = str_replace("\"".$snippet."\"", "\"".$attributeValue."\"", $xml);
|
340 |
+
$xml = str_replace("'".$snippet."'", "\"".$attributeValue."\"", $xml);
|
341 |
+
}
|
342 |
+
|
343 |
+
|
344 |
+
|
345 |
+
$filteredEncoded = $this->encodeSpecialCharacters($filtered);
|
346 |
+
|
347 |
+
$xml = str_replace($snippet, $filteredEncoded, $xml);
|
348 |
+
}
|
349 |
+
}
|
350 |
+
return $xml;
|
351 |
+
}
|
352 |
+
|
353 |
+
/**
|
354 |
+
* @param $xml
|
355 |
+
*
|
356 |
+
* @return mixed
|
357 |
+
*/
|
358 |
+
public function encodeSpecialCharsInAttributes($xml)
|
359 |
+
{
|
360 |
+
preg_match_all('/<.*?=["\'](.*?)["\'].*?>/', $xml, $attributes);
|
361 |
+
$attributes = $attributes[1];
|
362 |
+
|
363 |
+
foreach ($attributes as $attribute) {
|
364 |
+
|
365 |
+
$attribute = trim($attribute, "'\"");
|
366 |
+
|
367 |
+
if (!$this->wpaeString->isBetween($xml, $attribute, '<![CDATA[', ']]>')) {
|
368 |
+
|
369 |
+
$xml = str_replace(array('\'' . $attribute . '\'', '"' . $attribute . '"'), '"' . $attribute . '"', $xml);
|
370 |
+
}
|
371 |
+
}
|
372 |
+
|
373 |
+
return $xml;
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* @param $xml
|
378 |
+
* @return DOMDocument
|
379 |
+
*/
|
380 |
+
private function initVariables($xml)
|
381 |
+
{
|
382 |
+
$this->xml = $xml;
|
383 |
+
|
384 |
+
$dom = new DOMDocument();
|
385 |
+
$dom->recover = true;
|
386 |
+
$dom->preserveWhiteSpace = false;
|
387 |
+
$dom->substituteEntities = false;
|
388 |
+
$dom->resolveExternals = false;
|
389 |
+
|
390 |
+
$dom->loadXML($xml);
|
391 |
+
$this->dom = $dom;
|
392 |
+
}
|
393 |
+
|
394 |
+
/**
|
395 |
+
* @param $snippet
|
396 |
+
* @param bool $isInFunction
|
397 |
+
*
|
398 |
+
* @return mixed
|
399 |
+
* @throws WpaeInvalidStringException
|
400 |
+
* @throws WpaeMethodNotFoundException
|
401 |
+
*/
|
402 |
+
private function processSnippet($snippet, $isInFunction = false)
|
403 |
+
{
|
404 |
+
|
405 |
+
$sanitizedSnippet = $this->sanitizeSnippet($snippet);
|
406 |
+
$sanitizedSnippet = $this->wpaeString->quoteParams($sanitizedSnippet);
|
407 |
+
$functionName = $this->sanitizeFunctionName($sanitizedSnippet);
|
408 |
+
$this->checkCorrectNumberOfQuotes($sanitizedSnippet, $functionName);
|
409 |
+
$this->checkIfFunctionExists($functionName);
|
410 |
+
$sanitizedSnippet = str_replace(',)', ',"")', $sanitizedSnippet);
|
411 |
+
|
412 |
+
$snippetValue = eval('return ' . $sanitizedSnippet . ';');
|
413 |
+
|
414 |
+
$snippetValue = $this->encodeSpecialCharacters($snippetValue);
|
415 |
+
|
416 |
+
if(strpos($snippet, 'explode') !== false && $isInFunction) {
|
417 |
+
$snippetValue = 'array('."'" . implode("','", $snippetValue) . "'".')';
|
418 |
+
}
|
419 |
+
|
420 |
+
return $snippetValue;
|
421 |
+
}
|
422 |
+
|
423 |
+
public function getNodeAttributes(DOMNode $dom)
|
424 |
+
{
|
425 |
+
$result = "";
|
426 |
+
if ($dom->hasAttributes()) {
|
427 |
+
for ($i = 0; $i < $dom->attributes->length; $i++)
|
428 |
+
$result .= $dom->attributes->item($i)->nodeValue;
|
429 |
+
}
|
430 |
+
|
431 |
+
return $result;
|
432 |
+
}
|
433 |
+
|
434 |
+
/**
|
435 |
+
* @param DOMNode $newValueNode
|
436 |
+
* @param $snippet
|
437 |
+
* @param $snippetValue
|
438 |
+
* @internal param $snippetValues
|
439 |
+
*/
|
440 |
+
private function replaceSnippetInAttributes(DOMNode $newValueNode, $snippet, $snippetValue)
|
441 |
+
{
|
442 |
+
$snippetValue = $this->sanitizeAttribute($snippetValue);
|
443 |
+
if ($newValueNode->hasAttributes()) {
|
444 |
+
for ($i = 0; $i < $newValueNode->attributes->length; $i++) {
|
445 |
+
|
446 |
+
$newValueNode->attributes->item($i)->nodeValue =
|
447 |
+
str_replace(
|
448 |
+
$snippet,
|
449 |
+
$snippetValue,
|
450 |
+
$newValueNode->attributes->item($i)->nodeValue
|
451 |
+
);
|
452 |
+
}
|
453 |
+
}
|
454 |
+
}
|
455 |
+
|
456 |
+
/**
|
457 |
+
* @param DOMNode $element
|
458 |
+
*/
|
459 |
+
private function elementCdata(DOMNode $element)
|
460 |
+
{
|
461 |
+
$hasSnippets = $this->parseSnippetsInString($element->nodeValue);
|
462 |
+
|
463 |
+
if (strpos($element->nodeValue, '<![CDATA[') === false && strpos($element->nodeValue, 'CDATABEGIN') === false && !$hasSnippets) {
|
464 |
+
$element->nodeValue = $this->maybe_cdata($element->nodeValue);
|
465 |
+
}
|
466 |
+
}
|
467 |
+
|
468 |
+
private function encodeSpecialCharacters($text)
|
469 |
+
{
|
470 |
+
$text = str_replace('&', '&', $text);
|
471 |
+
$text = str_replace('&', '##amp##', $text);
|
472 |
+
$text = str_replace("'", '##x27##', $text);
|
473 |
+
$text = str_replace('"', '##quot##', $text);
|
474 |
+
$text = str_replace('<', '##lt##', $text);
|
475 |
+
$text = str_replace('>', '##gt##', $text);
|
476 |
+
|
477 |
+
return $text;
|
478 |
+
}
|
479 |
+
|
480 |
+
private function decodeSpecialCharacters($text)
|
481 |
+
{
|
482 |
+
$text = str_replace('##amp##', '&', $text);
|
483 |
+
$text = str_replace('##x27##', "'", $text);
|
484 |
+
$text = str_replace('##quot##', '"', $text);
|
485 |
+
$text = str_replace('##lt##', '<', $text);
|
486 |
+
$text = str_replace('##gt##', '>', $text);
|
487 |
+
|
488 |
+
return $text;
|
489 |
+
}
|
490 |
+
|
491 |
+
/**
|
492 |
+
* @param $xml
|
493 |
+
* @return mixed
|
494 |
+
*/
|
495 |
+
private function postProcessXml($xml)
|
496 |
+
{
|
497 |
+
$xml = str_replace('<id>', '<ID>', $xml);
|
498 |
+
$xml = str_replace('</id>', '</ID>', $xml);
|
499 |
+
|
500 |
+
$xml = str_replace('CDATABEGIN', '<![CDATA[', $xml);
|
501 |
+
$xml = str_replace('CDATACLOSE', ']]>', $xml);
|
502 |
+
|
503 |
+
$xml = str_replace('CLOSEBRAKET', ']', str_replace('OPENBRAKET', '[', $xml));
|
504 |
+
$xml = str_replace('CLOSECURVE', '}', str_replace('OPENCURVE', '{', $xml));
|
505 |
+
|
506 |
+
$xml = str_replace('##FILLER##', '', $xml);
|
507 |
+
$xml = str_replace('<filler>c</filler>', '', $xml);
|
508 |
+
$xml = str_replace('<filler><![CDATA[c]]></filler>', '', $xml);
|
509 |
+
$xml = str_replace('<filler>CDATABEGINcCDATACLOSE</filler>', '', $xml);
|
510 |
+
|
511 |
+
$xml = str_replace('<comment>', '<!--', $xml);
|
512 |
+
$xml = str_replace('</comment>', '-->', $xml);
|
513 |
+
|
514 |
+
$xml = "\n ".trim($xml);
|
515 |
+
return $xml;
|
516 |
+
}
|
517 |
+
|
518 |
+
/**
|
519 |
+
* @param $xml
|
520 |
+
* @return mixed
|
521 |
+
*/
|
522 |
+
private function preprocessXml($xml)
|
523 |
+
{
|
524 |
+
$xml = str_replace('<!--', '<comment>', $xml);
|
525 |
+
$xml = str_replace('-->', '</comment>', $xml);
|
526 |
+
|
527 |
+
$xml = str_replace("\"{}\"", '""', $xml);
|
528 |
+
$xml = str_replace("{}", '""', $xml);
|
529 |
+
$xml = str_replace(">\"\"<", '><', $xml);
|
530 |
+
$xml = str_replace("[implode(',',{})]", "", $xml);
|
531 |
+
return $xml;
|
532 |
+
}
|
533 |
+
|
534 |
+
/**
|
535 |
+
* @param $xml
|
536 |
+
* @param $response
|
537 |
+
* @return mixed
|
538 |
+
*/
|
539 |
+
private function cleanResponse($xml, $response)
|
540 |
+
{
|
541 |
+
$response = str_replace('<root>', '', $response);
|
542 |
+
$response = str_replace('</root>', '', $response);
|
543 |
+
$xml = str_replace("<?xml version=\"1.0\"?>", '', $response);
|
544 |
+
$xml = str_replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "", $xml);
|
545 |
+
|
546 |
+
return $xml;
|
547 |
+
}
|
548 |
+
}
|
libraries/XmlCsvExport.php
CHANGED
@@ -2,30 +2,15 @@
|
|
2 |
|
3 |
final Class XmlCsvExport
|
4 |
{
|
5 |
-
|
6 |
-
* Singletone instance
|
7 |
-
* @var XmlCsvExport
|
8 |
-
*/
|
9 |
-
protected static $instance;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Return singletone instance
|
13 |
-
* @return XmlCsvExport
|
14 |
-
*/
|
15 |
-
static public function getInstance() {
|
16 |
-
if ( self::$instance == NULL ) {
|
17 |
-
self::$instance = new self();
|
18 |
-
}
|
19 |
-
return self::$instance;
|
20 |
-
}
|
21 |
|
22 |
-
|
23 |
|
24 |
public static function export()
|
25 |
-
{
|
26 |
switch ( XmlExportEngine::$exportOptions['export_to'] )
|
27 |
{
|
28 |
-
case 'xml':
|
29 |
self::export_xml();
|
30 |
break;
|
31 |
|
@@ -52,53 +37,48 @@ final Class XmlCsvExport
|
|
52 |
$woo = array();
|
53 |
$woo_order = array();
|
54 |
$acfs = array();
|
55 |
-
$taxes = array();
|
56 |
-
$attributes = array();
|
57 |
$articles = array();
|
58 |
|
59 |
-
|
|
|
|
|
60 |
|
61 |
// [ Exporting requested data ]
|
62 |
|
63 |
-
if ( XmlExportEngine::$is_user_export ) // exporting WordPress users
|
64 |
-
|
65 |
-
foreach ( XmlExportEngine::$exportQuery->results as $user )
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
}
|
71 |
-
elseif ( XmlExportEngine::$is_comment_export ) // exporting comments
|
72 |
-
{
|
73 |
global $wp_version;
|
74 |
|
75 |
-
if ( version_compare($wp_version, '4.2.0', '>=') )
|
76 |
-
{
|
77 |
$comments = XmlExportEngine::$exportQuery->get_comments();
|
78 |
}
|
79 |
-
else
|
80 |
-
{
|
81 |
$comments = XmlExportEngine::$exportQuery;
|
82 |
}
|
83 |
|
84 |
-
foreach ( $comments as $comment )
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
if ( ! $preview) do_action('pmxe_exported_post', $record->ID, XmlExportEngine::$exportRecord );
|
98 |
-
endwhile;
|
99 |
wp_reset_postdata();
|
100 |
-
|
101 |
-
// [ \Exporting requested data ]
|
102 |
|
103 |
// [ Prepare CSV headers ]
|
104 |
if (XmlExportEngine::$exportOptions['ids']):
|
@@ -107,32 +87,29 @@ final Class XmlCsvExport
|
|
107 |
{
|
108 |
if ( empty(XmlExportEngine::$exportOptions['cc_name'][$ID]) or empty(XmlExportEngine::$exportOptions['cc_type'][$ID]) or ! is_numeric($ID) ) continue;
|
109 |
|
110 |
-
self::prepare_csv_headers( $headers, $ID, $
|
111 |
}
|
112 |
|
113 |
endif;
|
114 |
|
115 |
$headers = apply_filters( 'wp_all_export_csv_headers', $headers, XmlExportEngine::$exportID );
|
116 |
|
117 |
-
if ($is_cron)
|
118 |
-
|
119 |
-
if ( ! $exported_by_cron )
|
120 |
-
{
|
121 |
fputcsv($stream, array_map(array('XmlCsvExport', '_get_valid_header_name'), $headers), XmlExportEngine::$exportOptions['delimiter']);
|
|
|
122 |
}
|
123 |
-
else
|
124 |
-
{
|
125 |
self::merge_headers( $file_path, $headers );
|
126 |
}
|
127 |
}
|
128 |
else
|
129 |
{
|
130 |
-
if ($preview or empty(PMXE_Plugin::$session->file))
|
131 |
-
{
|
132 |
fputcsv($stream, array_map(array('XmlCsvExport', '_get_valid_header_name'), $headers), XmlExportEngine::$exportOptions['delimiter']);
|
|
|
133 |
}
|
134 |
-
else
|
135 |
-
{
|
136 |
self::merge_headers( PMXE_Plugin::$session->file, $headers );
|
137 |
}
|
138 |
}
|
@@ -144,6 +121,7 @@ final Class XmlCsvExport
|
|
144 |
$line[$header] = ( isset($article[$header]) ) ? $article[$header] : '';
|
145 |
}
|
146 |
fputcsv($stream, $line, XmlExportEngine::$exportOptions['delimiter']);
|
|
|
147 |
}
|
148 |
|
149 |
if ($preview) return ob_get_clean();
|
@@ -152,10 +130,33 @@ final Class XmlCsvExport
|
|
152 |
|
153 |
}
|
154 |
|
155 |
-
|
156 |
-
public static $node_xml_tag = '';
|
157 |
public static function export_xml( $preview = false, $is_cron = false, $file_path = false, $exported_by_cron = 0 )
|
158 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
if ( XmlExportEngine::$exportOptions['delimiter'] == '\t' ) XmlExportEngine::$exportOptions['delimiter'] = "\t";
|
160 |
|
161 |
require_once PMXE_ROOT_DIR . '/classes/XMLWriter.php';
|
@@ -163,23 +164,26 @@ final Class XmlCsvExport
|
|
163 |
$woo = array();
|
164 |
$woo_order = array();
|
165 |
$acfs = array();
|
166 |
-
$taxes = array();
|
167 |
-
$attributes = array();
|
168 |
|
169 |
self::$main_xml_tag = apply_filters('wp_all_export_main_xml_tag', XmlExportEngine::$exportOptions['main_xml_tag'], XmlExportEngine::$exportID);
|
170 |
self::$node_xml_tag = apply_filters('wp_all_export_record_xml_tag', XmlExportEngine::$exportOptions['record_xml_tag'], XmlExportEngine::$exportID);
|
171 |
-
|
172 |
-
$implode_delimiter = (XmlExportEngine::$exportOptions['delimiter'] == ',') ? '|' : ',';
|
173 |
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
$xmlWriter->setIndentString("\t");
|
178 |
-
$xmlWriter->startDocument('1.0', XmlExportEngine::$exportOptions['encoding']);
|
179 |
-
$xmlWriter->startElement(self::$main_xml_tag);
|
180 |
|
181 |
-
|
182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
// [ Exporting requested data ]
|
185 |
|
@@ -190,18 +194,27 @@ final Class XmlCsvExport
|
|
190 |
$is_export_record = apply_filters('wp_all_export_xml_rows', true, $user, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
191 |
|
192 |
if ( ! $is_export_record ) continue;
|
|
|
|
|
|
|
|
|
193 |
|
194 |
-
|
195 |
-
self::before_xml_node( $xmlWriter, $user->ID);
|
196 |
|
197 |
-
|
198 |
|
199 |
-
|
200 |
|
201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
-
|
204 |
-
|
205 |
|
206 |
if ( ! $preview) do_action('pmxe_exported_post', $user->ID, XmlExportEngine::$exportRecord );
|
207 |
|
@@ -212,71 +225,81 @@ final Class XmlCsvExport
|
|
212 |
{
|
213 |
global $wp_version;
|
214 |
|
215 |
-
if ( version_compare($wp_version, '4.2.0', '>=') )
|
216 |
-
{
|
217 |
$comments = XmlExportEngine::$exportQuery->get_comments();
|
218 |
}
|
219 |
-
else
|
220 |
-
{
|
221 |
$comments = XmlExportEngine::$exportQuery;
|
222 |
}
|
223 |
|
224 |
-
foreach ( $comments as $comment )
|
225 |
-
|
226 |
-
$is_export_record = apply_filters('wp_all_export_xml_rows', true, $comment, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
227 |
|
228 |
-
|
229 |
|
230 |
-
|
231 |
-
self::before_xml_node( $xmlWriter, $comment->comment_ID);
|
232 |
|
233 |
-
|
|
|
|
|
234 |
|
235 |
-
|
236 |
|
237 |
-
|
238 |
|
239 |
-
|
240 |
-
self::after_xml_node( $xmlWriter, $comment->comment_ID);
|
241 |
|
242 |
-
|
|
|
|
|
|
|
|
|
|
|
243 |
|
244 |
-
|
245 |
-
|
246 |
-
else // exporting custom post types
|
247 |
-
{
|
248 |
-
while ( XmlExportEngine::$exportQuery->have_posts() ) :
|
249 |
-
|
250 |
-
XmlExportEngine::$exportQuery->the_post();
|
251 |
-
|
252 |
-
$record = get_post( get_the_ID() );
|
253 |
-
|
254 |
-
$is_export_record = apply_filters('wp_all_export_xml_rows', true, $record, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
255 |
|
256 |
-
|
257 |
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
wp_reset_postdata();
|
274 |
}
|
275 |
// [ \Exporting requested data ]
|
276 |
|
277 |
-
$xmlWriter->
|
278 |
|
279 |
-
if ($preview)
|
|
|
|
|
280 |
|
281 |
return self::save_xml_to_file( $xmlWriter, $file_path, $is_cron, $exported_by_cron );
|
282 |
|
@@ -284,20 +307,15 @@ final Class XmlCsvExport
|
|
284 |
|
285 |
// [ XML Export Helpers ]
|
286 |
private static function xml_header($xmlWriter, $is_cron, $exported_by_cron)
|
287 |
-
{
|
288 |
-
if ($is_cron)
|
289 |
-
|
290 |
-
|
291 |
-
{
|
292 |
$additional_data = apply_filters('wp_all_export_additional_data', array(), XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
293 |
|
294 |
-
if ( ! empty($additional_data))
|
295 |
-
|
296 |
-
|
297 |
-
{
|
298 |
-
$xmlWriter->startElement(preg_replace('/[^a-z0-9_-]/i', '', $key));
|
299 |
-
$xmlWriter->writeData($value, preg_replace('/[^a-z0-9_-]/i', '', $key));
|
300 |
-
$xmlWriter->endElement();
|
301 |
}
|
302 |
}
|
303 |
}
|
@@ -309,13 +327,9 @@ final Class XmlCsvExport
|
|
309 |
|
310 |
$additional_data = apply_filters('wp_all_export_additional_data', array(), XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
311 |
|
312 |
-
if ( ! empty($additional_data))
|
313 |
-
|
314 |
-
|
315 |
-
{
|
316 |
-
$xmlWriter->startElement(preg_replace('/[^a-z0-9_-]/i', '', $key));
|
317 |
-
$xmlWriter->writeData($value, preg_replace('/[^a-z0-9_-]/i', '', $key));
|
318 |
-
$xmlWriter->endElement();
|
319 |
}
|
320 |
}
|
321 |
}
|
@@ -326,13 +340,9 @@ final Class XmlCsvExport
|
|
326 |
{
|
327 |
$add_before_node = apply_filters('wp_all_export_add_before_node', array(), XmlExportEngine::$exportOptions, XmlExportEngine::$exportID, $pid);
|
328 |
|
329 |
-
if ( ! empty($add_before_node))
|
330 |
-
|
331 |
-
|
332 |
-
{
|
333 |
-
$xmlWriter->startElement(preg_replace('/[^a-z0-9_-]/i', '', $key));
|
334 |
-
$xmlWriter->writeData($value, preg_replace('/[^a-z0-9_-]/i', '', $key));
|
335 |
-
$xmlWriter->endElement();
|
336 |
}
|
337 |
}
|
338 |
}
|
@@ -341,75 +351,85 @@ final Class XmlCsvExport
|
|
341 |
{
|
342 |
$add_after_node = apply_filters('wp_all_export_add_after_node', array(), XmlExportEngine::$exportOptions, XmlExportEngine::$exportID, $pid);
|
343 |
|
344 |
-
if ( ! empty($add_after_node))
|
345 |
-
|
346 |
-
|
347 |
-
{
|
348 |
-
$xmlWriter->startElement(preg_replace('/[^a-z0-9_-]/i', '', $key));
|
349 |
-
$xmlWriter->writeData($value, preg_replace('/[^a-z0-9_-]/i', '', $key));
|
350 |
-
$xmlWriter->endElement();
|
351 |
}
|
352 |
}
|
353 |
}
|
354 |
|
355 |
private static function save_xml_to_file( $xmlWriter, $file_path, $is_cron, $exported_by_cron )
|
356 |
{
|
|
|
|
|
357 |
if ($is_cron)
|
358 |
-
{
|
359 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
|
361 |
-
|
|
|
362 |
|
363 |
-
if ( ! $exported_by_cron )
|
364 |
-
{
|
365 |
// The BOM will help some programs like Microsoft Excel read your export file if it includes non-English characters.
|
366 |
-
if (XmlExportEngine::$exportOptions['include_bom'])
|
367 |
-
|
368 |
-
file_put_contents($file_path, chr(0xEF).chr(0xBB).chr(0xBF).substr($xml, 0, (strlen(self::$main_xml_tag) + 4) * (-1)));
|
369 |
}
|
370 |
-
else
|
371 |
-
|
372 |
-
file_put_contents($file_path, substr($xml, 0, (strlen(self::$main_xml_tag) + 4) * (-1)));
|
373 |
}
|
374 |
}
|
375 |
-
else
|
376 |
-
|
377 |
-
file_put_contents($file_path,
|
378 |
}
|
379 |
|
380 |
return $file_path;
|
381 |
|
382 |
}
|
383 |
-
else
|
384 |
-
{
|
385 |
|
386 |
if ( empty(PMXE_Plugin::$session->file) ){
|
387 |
|
388 |
// generate export file name
|
389 |
$export_file = wp_all_export_generate_export_file( XmlExportEngine::$exportID );
|
390 |
|
391 |
-
|
|
|
392 |
|
393 |
-
|
|
|
|
|
|
|
394 |
|
395 |
-
|
396 |
-
if (XmlExportEngine::$exportOptions['include_bom'])
|
397 |
-
{
|
398 |
-
file_put_contents($export_file, chr(0xEF).chr(0xBB).chr(0xBF).substr($xml, 0, (strlen(self::$main_xml_tag) + 4) * (-1)));
|
399 |
}
|
400 |
-
|
401 |
-
|
402 |
-
|
|
|
|
|
|
|
403 |
}
|
|
|
|
|
|
|
404 |
|
405 |
PMXE_Plugin::$session->set('file', $export_file);
|
406 |
-
|
407 |
PMXE_Plugin::$session->save_data();
|
408 |
|
409 |
}
|
410 |
-
else
|
411 |
-
|
412 |
-
|
|
|
413 |
}
|
414 |
|
415 |
return true;
|
@@ -419,12 +439,11 @@ final Class XmlCsvExport
|
|
419 |
// [ \XML Export Helpers ]
|
420 |
|
421 |
// [ CSV Export Helpers ]
|
422 |
-
public static function prepare_csv_headers( & $headers, $ID,
|
423 |
{
|
424 |
$element_name = ( ! empty(XmlExportEngine::$exportOptions['cc_name'][$ID]) ) ? XmlExportEngine::$exportOptions['cc_name'][$ID] : 'untitled_' . $ID;
|
425 |
|
426 |
-
if ( strpos(XmlExportEngine::$exportOptions['cc_label'][$ID], "item_data__") !== false )
|
427 |
-
{
|
428 |
XmlExportEngine::$woo_order_export->get_element_header( $headers, XmlExportEngine::$exportOptions, $ID );
|
429 |
return;
|
430 |
}
|
@@ -432,55 +451,42 @@ final Class XmlCsvExport
|
|
432 |
switch (XmlExportEngine::$exportOptions['cc_type'][$ID])
|
433 |
{
|
434 |
case 'woo':
|
435 |
-
|
436 |
-
XmlExportEngine::$woo_export->get_element_header( $headers, XmlExportEngine::$exportOptions, $ID );
|
437 |
-
|
438 |
break;
|
439 |
|
440 |
case 'woo_order':
|
441 |
-
|
442 |
-
XmlExportEngine::$woo_order_export->get_element_header( $headers, XmlExportEngine::$exportOptions, $ID );
|
443 |
-
|
444 |
break;
|
445 |
|
446 |
case 'acf':
|
447 |
-
|
448 |
-
if ( ! empty($acfs) )
|
449 |
-
{
|
450 |
$single_acf_field = array_shift($acfs);
|
451 |
|
452 |
-
if ( is_array($single_acf_field))
|
453 |
-
{
|
454 |
foreach ($single_acf_field as $acf_header) {
|
455 |
if ( ! in_array($acf_header, $headers)) $headers[] = $acf_header;
|
456 |
}
|
457 |
}
|
458 |
-
else
|
459 |
-
{
|
460 |
if ( ! in_array($single_acf_field, $headers)) $headers[] = $single_acf_field;
|
461 |
}
|
462 |
}
|
463 |
-
|
464 |
break;
|
465 |
|
466 |
default:
|
467 |
|
468 |
if ($element_name == 'ID') $element_name = 'id';
|
469 |
|
470 |
-
if ( ! in_array($element_name, $headers))
|
471 |
-
{
|
472 |
$headers[] = $element_name;
|
473 |
}
|
474 |
-
else
|
475 |
-
{
|
476 |
$is_added = false;
|
477 |
$i = 0;
|
478 |
-
do
|
479 |
-
{
|
480 |
$new_element_name = $element_name . '_' . md5($i);
|
481 |
|
482 |
-
if ( ! in_array($new_element_name, $headers) )
|
483 |
-
{
|
484 |
$headers[] = $new_element_name;
|
485 |
$is_added = true;
|
486 |
}
|
@@ -490,8 +496,10 @@ final Class XmlCsvExport
|
|
490 |
while ( ! $is_added );
|
491 |
}
|
492 |
|
493 |
-
if ( XmlExportEngine::$exportOptions['cc_label'][$ID] == 'product_type' and ! in_array('parent_id', $headers))
|
494 |
-
|
|
|
|
|
495 |
break;
|
496 |
}
|
497 |
|
@@ -503,12 +511,10 @@ final Class XmlCsvExport
|
|
503 |
|
504 |
$elementIndex = array_pop($element_name_parts);
|
505 |
|
506 |
-
if (wp_all_export_isValidMd5($elementIndex))
|
507 |
-
{
|
508 |
$element_name_in_file = str_replace("_" . $elementIndex, "", $element_name);
|
509 |
}
|
510 |
-
else
|
511 |
-
{
|
512 |
$element_name_in_file = $element_name;
|
513 |
}
|
514 |
|
@@ -527,24 +533,19 @@ final Class XmlCsvExport
|
|
527 |
|
528 |
$old_headers = array();
|
529 |
|
530 |
-
foreach ($clear_old_headers as $i => $header)
|
531 |
-
{
|
532 |
$header = str_replace("'", "", str_replace('"', "", str_replace(chr(0xEF).chr(0xBB).chr(0xBF), "", $header)));
|
533 |
|
534 |
-
if ( ! in_array($header, $old_headers))
|
535 |
-
{
|
536 |
$old_headers[] = $header;
|
537 |
}
|
538 |
-
else
|
539 |
-
{
|
540 |
$is_added = false;
|
541 |
$i = 0;
|
542 |
-
do
|
543 |
-
{
|
544 |
$new_element_name = $header . '_' . md5($i);
|
545 |
|
546 |
-
if ( ! in_array($new_element_name, $old_headers) )
|
547 |
-
{
|
548 |
$old_headers[] = $new_element_name;
|
549 |
$is_added = true;
|
550 |
}
|
@@ -557,43 +558,33 @@ final Class XmlCsvExport
|
|
557 |
|
558 |
$is_update_headers = false;
|
559 |
|
560 |
-
foreach ($headers as $header)
|
561 |
-
|
562 |
-
if ( ! in_array($header, $old_headers))
|
563 |
-
{
|
564 |
$is_update_headers = true;
|
565 |
break;
|
566 |
}
|
567 |
}
|
568 |
|
569 |
-
if ($is_update_headers)
|
570 |
-
|
571 |
-
|
572 |
-
$headers = $old_headers + $headers;
|
573 |
-
|
574 |
$tmp_file = str_replace(basename($file), 'iteration_' . basename($file), $file);
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
$in = fopen($tmp_file, 'r');
|
579 |
-
|
580 |
$out = fopen($file, 'w');
|
581 |
-
|
582 |
$headers = apply_filters('wp_all_export_csv_headers', $headers, XmlExportEngine::$exportID);
|
583 |
|
584 |
-
if ( XmlExportEngine::$exportOptions['include_bom'] )
|
585 |
-
{
|
586 |
fputcsv($out, chr(0xEF).chr(0xBB).chr(0xBF) . array_map(array('XmlCsvExport', '_get_valid_header_name'), $headers), XmlExportEngine::$exportOptions['delimiter']);
|
587 |
}
|
588 |
-
else
|
589 |
-
{
|
590 |
fputcsv($out, array_map(array('XmlCsvExport', '_get_valid_header_name'), $headers), XmlExportEngine::$exportOptions['delimiter']);
|
591 |
}
|
592 |
|
|
|
|
|
593 |
$exclude_old_headers = fgetcsv($in);
|
594 |
|
595 |
-
if (is_resource($in))
|
596 |
-
{
|
597 |
while ( ! feof($in) ) {
|
598 |
$data = fgetcsv($in, 0, XmlExportEngine::$exportOptions['delimiter']);
|
599 |
if ( empty($data) ) continue;
|
@@ -603,6 +594,7 @@ final Class XmlCsvExport
|
|
603 |
$line[$header] = ( isset($data_assoc[$header]) ) ? $data_assoc[$header] : '';
|
604 |
}
|
605 |
fputcsv($out, $line, XmlExportEngine::$exportOptions['delimiter']);
|
|
|
606 |
}
|
607 |
fclose($in);
|
608 |
}
|
@@ -613,22 +605,17 @@ final Class XmlCsvExport
|
|
613 |
|
614 |
private static function save_csv_to_file( $file_path, $is_cron, $exported_by_cron )
|
615 |
{
|
616 |
-
if ($is_cron)
|
617 |
-
|
618 |
-
if ( ! $exported_by_cron )
|
619 |
-
{
|
620 |
// The BOM will help some programs like Microsoft Excel read your export file if it includes non-English characters.
|
621 |
-
if (XmlExportEngine::$exportOptions['include_bom'])
|
622 |
-
{
|
623 |
file_put_contents($file_path, chr(0xEF).chr(0xBB).chr(0xBF).ob_get_clean());
|
624 |
}
|
625 |
-
else
|
626 |
-
{
|
627 |
file_put_contents($file_path, ob_get_clean());
|
628 |
}
|
629 |
}
|
630 |
-
else
|
631 |
-
{
|
632 |
file_put_contents($file_path, ob_get_clean(), FILE_APPEND);
|
633 |
}
|
634 |
|
@@ -643,22 +630,18 @@ final Class XmlCsvExport
|
|
643 |
$export_file = wp_all_export_generate_export_file( XmlExportEngine::$exportID );
|
644 |
|
645 |
// The BOM will help some programs like Microsoft Excel read your export file if it includes non-English characters.
|
646 |
-
if (XmlExportEngine::$exportOptions['include_bom'])
|
647 |
-
{
|
648 |
file_put_contents($export_file, chr(0xEF).chr(0xBB).chr(0xBF).ob_get_clean());
|
649 |
}
|
650 |
-
else
|
651 |
-
{
|
652 |
file_put_contents($export_file, ob_get_clean());
|
653 |
}
|
654 |
|
655 |
PMXE_Plugin::$session->set('file', $export_file);
|
656 |
-
|
657 |
PMXE_Plugin::$session->save_data();
|
658 |
|
659 |
}
|
660 |
-
else
|
661 |
-
{
|
662 |
file_put_contents(PMXE_Plugin::$session->file, ob_get_clean(), FILE_APPEND);
|
663 |
}
|
664 |
|
@@ -719,10 +702,8 @@ final Class XmlCsvExport
|
|
719 |
}
|
720 |
if ( ! empty($section['additional']) )
|
721 |
{
|
722 |
-
foreach ($section['additional'] as $sub_slug => $sub_section)
|
723 |
-
|
724 |
-
foreach ($sub_section['meta'] as $field)
|
725 |
-
{
|
726 |
$field_options = ( in_array($sub_slug, array('images', 'attachments')) ) ? esc_attr('{"is_export_featured":true,"is_export_attached":true,"image_separator":"|"}') : '0';
|
727 |
$field_name = '';
|
728 |
switch ($sub_slug) {
|
@@ -737,8 +718,7 @@ final Class XmlCsvExport
|
|
737 |
break;
|
738 |
}
|
739 |
|
740 |
-
if ( is_array($field) and isset($field['auto']) )
|
741 |
-
{
|
742 |
$auto_generate['ids'][] = 1;
|
743 |
$auto_generate['cc_label'][] = is_array($field) ? $field['label'] : $field;
|
744 |
$auto_generate['cc_php'][] = 0;
|
@@ -776,4 +756,16 @@ final Class XmlCsvExport
|
|
776 |
|
777 |
return $auto_generate;
|
778 |
}
|
779 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
final Class XmlCsvExport
|
4 |
{
|
5 |
+
public static $main_xml_tag = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
public static $node_xml_tag = '';
|
8 |
|
9 |
public static function export()
|
10 |
+
{
|
11 |
switch ( XmlExportEngine::$exportOptions['export_to'] )
|
12 |
{
|
13 |
+
case 'xml':
|
14 |
self::export_xml();
|
15 |
break;
|
16 |
|
37 |
$woo = array();
|
38 |
$woo_order = array();
|
39 |
$acfs = array();
|
|
|
|
|
40 |
$articles = array();
|
41 |
|
42 |
+
// self::$implode = (XmlExportEngine::$exportOptions['delimiter'] == ',') ? '|' : ',';
|
43 |
+
//
|
44 |
+
// self::$implode = apply_filters('wp_all_export_implode_delimiter', self::$implode, XmlExportEngine::$exportID);
|
45 |
|
46 |
// [ Exporting requested data ]
|
47 |
|
48 |
+
if ( XmlExportEngine::$is_user_export ) { // exporting WordPress users
|
49 |
+
|
50 |
+
foreach ( XmlExportEngine::$exportQuery->results as $user ) {
|
51 |
+
$articles[] = XmlExportUser::prepare_data($user, false, $acfs, XmlExportEngine::$implode, $preview);
|
52 |
+
$articles = apply_filters('wp_all_export_csv_rows', $articles, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
53 |
+
if (!$preview) do_action('pmxe_exported_post', $user->ID, XmlExportEngine::$exportRecord);
|
54 |
+
}
|
55 |
}
|
56 |
+
elseif ( XmlExportEngine::$is_comment_export ) { // exporting comments
|
|
|
57 |
global $wp_version;
|
58 |
|
59 |
+
if ( version_compare($wp_version, '4.2.0', '>=') ) {
|
|
|
60 |
$comments = XmlExportEngine::$exportQuery->get_comments();
|
61 |
}
|
62 |
+
else {
|
|
|
63 |
$comments = XmlExportEngine::$exportQuery;
|
64 |
}
|
65 |
|
66 |
+
foreach ( $comments as $comment ) {
|
67 |
+
$articles[] = XmlExportComment::prepare_data($comment, false, XmlExportEngine::$implode, $preview);
|
68 |
+
$articles = apply_filters('wp_all_export_csv_rows', $articles, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
69 |
+
if (!$preview) do_action('pmxe_exported_post', $comment->comment_ID, XmlExportEngine::$exportRecord);
|
70 |
+
}
|
71 |
+
} else { // exporting custom post types
|
72 |
+
while ( XmlExportEngine::$exportQuery->have_posts() ) {
|
73 |
+
XmlExportEngine::$exportQuery->the_post();
|
74 |
+
$record = get_post(get_the_ID());
|
75 |
+
$articles[] = XmlExportCpt::prepare_data($record, false, $acfs, $woo, $woo_order, XmlExportEngine::$implode, $preview);
|
76 |
+
$articles = apply_filters('wp_all_export_csv_rows', $articles, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
77 |
+
if (!$preview) do_action('pmxe_exported_post', $record->ID, XmlExportEngine::$exportRecord);
|
78 |
+
}
|
|
|
|
|
79 |
wp_reset_postdata();
|
80 |
+
}
|
81 |
+
// [ \Exporting requested data ]
|
82 |
|
83 |
// [ Prepare CSV headers ]
|
84 |
if (XmlExportEngine::$exportOptions['ids']):
|
87 |
{
|
88 |
if ( empty(XmlExportEngine::$exportOptions['cc_name'][$ID]) or empty(XmlExportEngine::$exportOptions['cc_type'][$ID]) or ! is_numeric($ID) ) continue;
|
89 |
|
90 |
+
self::prepare_csv_headers( $headers, $ID, $acfs );
|
91 |
}
|
92 |
|
93 |
endif;
|
94 |
|
95 |
$headers = apply_filters( 'wp_all_export_csv_headers', $headers, XmlExportEngine::$exportID );
|
96 |
|
97 |
+
if ($is_cron) {
|
98 |
+
if ( ! $exported_by_cron ) {
|
|
|
|
|
99 |
fputcsv($stream, array_map(array('XmlCsvExport', '_get_valid_header_name'), $headers), XmlExportEngine::$exportOptions['delimiter']);
|
100 |
+
apply_filters('wp_all_export_after_csv_line', $stream, XmlExportEngine::$exportID);
|
101 |
}
|
102 |
+
else {
|
|
|
103 |
self::merge_headers( $file_path, $headers );
|
104 |
}
|
105 |
}
|
106 |
else
|
107 |
{
|
108 |
+
if ($preview or empty(PMXE_Plugin::$session->file)) {
|
|
|
109 |
fputcsv($stream, array_map(array('XmlCsvExport', '_get_valid_header_name'), $headers), XmlExportEngine::$exportOptions['delimiter']);
|
110 |
+
apply_filters('wp_all_export_after_csv_line', $stream, XmlExportEngine::$exportID);
|
111 |
}
|
112 |
+
else {
|
|
|
113 |
self::merge_headers( PMXE_Plugin::$session->file, $headers );
|
114 |
}
|
115 |
}
|
121 |
$line[$header] = ( isset($article[$header]) ) ? $article[$header] : '';
|
122 |
}
|
123 |
fputcsv($stream, $line, XmlExportEngine::$exportOptions['delimiter']);
|
124 |
+
apply_filters('wp_all_export_after_csv_line', $stream, XmlExportEngine::$exportID);
|
125 |
}
|
126 |
|
127 |
if ($preview) return ob_get_clean();
|
130 |
|
131 |
}
|
132 |
|
133 |
+
|
|
|
134 |
public static function export_xml( $preview = false, $is_cron = false, $file_path = false, $exported_by_cron = 0 )
|
135 |
{
|
136 |
+
$is_custom_xml = ( ! empty(XmlExportEngine::$exportOptions['xml_template_type']) && in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ) ? true : false;
|
137 |
+
|
138 |
+
if ( ! empty(XmlExportEngine::$exportOptions['xml_template_type']) ){
|
139 |
+
|
140 |
+
switch (XmlExportEngine::$exportOptions['xml_template_type']) {
|
141 |
+
case 'custom':
|
142 |
+
case 'XmlGoogleMerchants':
|
143 |
+
XmlExportEngine::$exportOptions['ids'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['ids'];
|
144 |
+
XmlExportEngine::$exportOptions['cc_label'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_label'];
|
145 |
+
XmlExportEngine::$exportOptions['cc_type'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_type'];
|
146 |
+
XmlExportEngine::$exportOptions['cc_value'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_value'];
|
147 |
+
XmlExportEngine::$exportOptions['cc_name'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_name'];
|
148 |
+
XmlExportEngine::$exportOptions['cc_php'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_php'];
|
149 |
+
XmlExportEngine::$exportOptions['cc_code'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_code'];
|
150 |
+
XmlExportEngine::$exportOptions['cc_sql'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_sql'];
|
151 |
+
XmlExportEngine::$exportOptions['cc_options'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_options'];
|
152 |
+
XmlExportEngine::$exportOptions['cc_settings'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_settings'];
|
153 |
+
break;
|
154 |
+
default:
|
155 |
+
# code...
|
156 |
+
break;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
if ( XmlExportEngine::$exportOptions['delimiter'] == '\t' ) XmlExportEngine::$exportOptions['delimiter'] = "\t";
|
161 |
|
162 |
require_once PMXE_ROOT_DIR . '/classes/XMLWriter.php';
|
164 |
$woo = array();
|
165 |
$woo_order = array();
|
166 |
$acfs = array();
|
|
|
|
|
167 |
|
168 |
self::$main_xml_tag = apply_filters('wp_all_export_main_xml_tag', XmlExportEngine::$exportOptions['main_xml_tag'], XmlExportEngine::$exportID);
|
169 |
self::$node_xml_tag = apply_filters('wp_all_export_record_xml_tag', XmlExportEngine::$exportOptions['record_xml_tag'], XmlExportEngine::$exportID);
|
|
|
|
|
170 |
|
171 |
+
// self::$implode = (XmlExportEngine::$exportOptions['delimiter'] == ',') ? '|' : ',';
|
172 |
+
//
|
173 |
+
// if ( $is_custom_xml ) self::$implode = '#delimiter#';
|
|
|
|
|
|
|
174 |
|
175 |
+
$xmlWriter = new PMXE_XMLWriter();
|
176 |
+
|
177 |
+
if ( ! $is_custom_xml ) {
|
178 |
+
|
179 |
+
$xmlWriter->openMemory();
|
180 |
+
$xmlWriter->setIndent(true);
|
181 |
+
$xmlWriter->setIndentString("\t");
|
182 |
+
$xmlWriter->startDocument('1.0', XmlExportEngine::$exportOptions['encoding']);
|
183 |
+
$xmlWriter->startElement(self::$main_xml_tag);
|
184 |
+
// add additional data after XML root element
|
185 |
+
self::xml_header( $xmlWriter, $is_cron, $exported_by_cron );
|
186 |
+
}
|
187 |
|
188 |
// [ Exporting requested data ]
|
189 |
|
194 |
$is_export_record = apply_filters('wp_all_export_xml_rows', true, $user, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
195 |
|
196 |
if ( ! $is_export_record ) continue;
|
197 |
+
|
198 |
+
if ( ! $is_custom_xml ) {
|
199 |
+
// add additional information before each node
|
200 |
+
self::before_xml_node( $xmlWriter, $user->ID);
|
201 |
|
202 |
+
$xmlWriter->startElement(self::$node_xml_tag);
|
|
|
203 |
|
204 |
+
XmlExportUser::prepare_data( $user, $xmlWriter, $acfs, XmlExportEngine::$implode, $preview );
|
205 |
|
206 |
+
$xmlWriter->closeElement(); // end post
|
207 |
|
208 |
+
// add additional information after each node
|
209 |
+
self::after_xml_node( $xmlWriter, $user->ID);
|
210 |
+
}
|
211 |
+
else {
|
212 |
+
$articles = array();
|
213 |
+
$articles[] = XmlExportUser::prepare_data( $user, $xmlWriter, $acfs, XmlExportEngine::$implode, $preview );
|
214 |
+
$articles = apply_filters('wp_all_export_csv_rows', $articles, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
215 |
|
216 |
+
$xmlWriter->writeArticle( $articles );
|
217 |
+
}
|
218 |
|
219 |
if ( ! $preview) do_action('pmxe_exported_post', $user->ID, XmlExportEngine::$exportRecord );
|
220 |
|
225 |
{
|
226 |
global $wp_version;
|
227 |
|
228 |
+
if ( version_compare($wp_version, '4.2.0', '>=') ) {
|
|
|
229 |
$comments = XmlExportEngine::$exportQuery->get_comments();
|
230 |
}
|
231 |
+
else {
|
|
|
232 |
$comments = XmlExportEngine::$exportQuery;
|
233 |
}
|
234 |
|
235 |
+
foreach ( $comments as $comment ) {
|
|
|
|
|
236 |
|
237 |
+
$is_export_record = apply_filters('wp_all_export_xml_rows', true, $comment, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
238 |
|
239 |
+
if (!$is_export_record) continue;
|
|
|
240 |
|
241 |
+
if (!$is_custom_xml) {
|
242 |
+
// add additional information before each node
|
243 |
+
self::before_xml_node($xmlWriter, $comment->comment_ID);
|
244 |
|
245 |
+
$xmlWriter->startElement(self::$node_xml_tag);
|
246 |
|
247 |
+
XmlExportComment::prepare_data($comment, $xmlWriter, XmlExportEngine::$implode, $preview);
|
248 |
|
249 |
+
$xmlWriter->closeElement(); // end post
|
|
|
250 |
|
251 |
+
// add additional information after each node
|
252 |
+
self::after_xml_node($xmlWriter, $comment->comment_ID);
|
253 |
+
} else {
|
254 |
+
$articles = array();
|
255 |
+
$articles[] = XmlExportComment::prepare_data($comment, $xmlWriter, XmlExportEngine::$implode, $preview);
|
256 |
+
$articles = apply_filters('wp_all_export_csv_rows', $articles, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
257 |
|
258 |
+
$xmlWriter->writeArticle($articles);
|
259 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
|
261 |
+
if (!$preview) do_action('pmxe_exported_post', $comment->comment_ID, XmlExportEngine::$exportRecord);
|
262 |
|
263 |
+
}
|
264 |
+
}
|
265 |
+
else {// exporting custom post types
|
266 |
+
while ( XmlExportEngine::$exportQuery->have_posts() ) {
|
267 |
+
XmlExportEngine::$exportQuery->the_post();
|
268 |
+
$record = get_post(get_the_ID());
|
269 |
+
|
270 |
+
$is_export_record = apply_filters('wp_all_export_xml_rows', true, $record, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
271 |
+
|
272 |
+
if (!$is_export_record) continue;
|
273 |
+
|
274 |
+
if (!$is_custom_xml) {
|
275 |
+
// add additional information before each node
|
276 |
+
self::before_xml_node($xmlWriter, $record->ID);
|
277 |
+
$xmlWriter->startElement(self::$node_xml_tag);
|
278 |
+
XmlExportCpt::prepare_data($record, $xmlWriter, $acfs, $woo, $woo_order, XmlExportEngine::$implode, $preview);
|
279 |
+
|
280 |
+
$xmlWriter->closeElement(); // end post
|
281 |
+
|
282 |
+
// add additional information after each node
|
283 |
+
self::after_xml_node($xmlWriter, $record->ID);
|
284 |
+
} else {
|
285 |
+
$articles = array();
|
286 |
+
$articles[] = XmlExportCpt::prepare_data($record, $xmlWriter, $acfs, $woo, $woo_order, XmlExportEngine::$implode, $preview);
|
287 |
+
$articles = apply_filters('wp_all_export_csv_rows', $articles, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
288 |
+
|
289 |
+
$xmlWriter->writeArticle($articles);
|
290 |
+
}
|
291 |
+
|
292 |
+
if (!$preview) do_action('pmxe_exported_post', $record->ID, XmlExportEngine::$exportRecord);
|
293 |
+
}
|
294 |
wp_reset_postdata();
|
295 |
}
|
296 |
// [ \Exporting requested data ]
|
297 |
|
298 |
+
if ( ! $is_custom_xml ) $xmlWriter->closeElement(); // close root XML element
|
299 |
|
300 |
+
if ($preview) {
|
301 |
+
return $xmlWriter->wpae_flush();
|
302 |
+
}
|
303 |
|
304 |
return self::save_xml_to_file( $xmlWriter, $file_path, $is_cron, $exported_by_cron );
|
305 |
|
307 |
|
308 |
// [ XML Export Helpers ]
|
309 |
private static function xml_header($xmlWriter, $is_cron, $exported_by_cron)
|
310 |
+
{
|
311 |
+
if ($is_cron) {
|
312 |
+
if ( ! $exported_by_cron ) {
|
313 |
+
|
|
|
314 |
$additional_data = apply_filters('wp_all_export_additional_data', array(), XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
315 |
|
316 |
+
if ( ! empty($additional_data)) {
|
317 |
+
foreach ($additional_data as $key => $value) {
|
318 |
+
self::addElement($xmlWriter, $key, $value);
|
|
|
|
|
|
|
|
|
319 |
}
|
320 |
}
|
321 |
}
|
327 |
|
328 |
$additional_data = apply_filters('wp_all_export_additional_data', array(), XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
|
329 |
|
330 |
+
if ( ! empty($additional_data)) {
|
331 |
+
foreach ($additional_data as $key => $value) {
|
332 |
+
self::addElement($xmlWriter, $key, $value);
|
|
|
|
|
|
|
|
|
333 |
}
|
334 |
}
|
335 |
}
|
340 |
{
|
341 |
$add_before_node = apply_filters('wp_all_export_add_before_node', array(), XmlExportEngine::$exportOptions, XmlExportEngine::$exportID, $pid);
|
342 |
|
343 |
+
if ( ! empty($add_before_node)) {
|
344 |
+
foreach ($add_before_node as $key => $value) {
|
345 |
+
self::addElement($xmlWriter, $key, $value);
|
|
|
|
|
|
|
|
|
346 |
}
|
347 |
}
|
348 |
}
|
351 |
{
|
352 |
$add_after_node = apply_filters('wp_all_export_add_after_node', array(), XmlExportEngine::$exportOptions, XmlExportEngine::$exportID, $pid);
|
353 |
|
354 |
+
if ( ! empty($add_after_node)) {
|
355 |
+
foreach ($add_after_node as $key => $value) {
|
356 |
+
self::addElement($xmlWriter, $key, $value);
|
|
|
|
|
|
|
|
|
357 |
}
|
358 |
}
|
359 |
}
|
360 |
|
361 |
private static function save_xml_to_file( $xmlWriter, $file_path, $is_cron, $exported_by_cron )
|
362 |
{
|
363 |
+
$is_custom_xml = in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants'));
|
364 |
+
|
365 |
if ($is_cron)
|
366 |
+
{
|
367 |
+
if ( ! $is_custom_xml ) {
|
368 |
+
$xml_header = apply_filters('wp_all_export_xml_header', '<?xml version="1.0" encoding="UTF-8"?>', XmlExportEngine::$exportID);
|
369 |
+
|
370 |
+
$xml = str_replace('<?xml version="1.0" encoding="UTF-8"?>', $xml_header, $xmlWriter->wpae_flush());
|
371 |
+
}
|
372 |
+
else {
|
373 |
+
$xml_header = XmlExportEngine::$exportOptions['custom_xml_template_header'];
|
374 |
+
|
375 |
+
$xml = ( ! $exported_by_cron ) ? PMXE_XMLWriter::preprocess_xml($xml_header) . $xmlWriter->wpae_flush() : $xmlWriter->wpae_flush();
|
376 |
+
}
|
377 |
|
378 |
+
if ( ! $exported_by_cron ) {
|
379 |
+
if ( ! $is_custom_xml ) $xml = substr($xml, 0, (strlen(self::$main_xml_tag) + 4) * (-1));
|
380 |
|
|
|
|
|
381 |
// The BOM will help some programs like Microsoft Excel read your export file if it includes non-English characters.
|
382 |
+
if (XmlExportEngine::$exportOptions['include_bom']) {
|
383 |
+
file_put_contents($file_path, chr(0xEF).chr(0xBB).chr(0xBF).$xml);
|
|
|
384 |
}
|
385 |
+
else {
|
386 |
+
file_put_contents($file_path, $xml);
|
|
|
387 |
}
|
388 |
}
|
389 |
+
else {
|
390 |
+
$xml = ( ! $is_custom_xml ) ? substr(substr($xml, 41 + strlen(self::$main_xml_tag)), 0, (strlen(self::$main_xml_tag) + 4) * (-1)) : $xml;
|
391 |
+
file_put_contents($file_path, $xml, FILE_APPEND);
|
392 |
}
|
393 |
|
394 |
return $file_path;
|
395 |
|
396 |
}
|
397 |
+
else {
|
|
|
398 |
|
399 |
if ( empty(PMXE_Plugin::$session->file) ){
|
400 |
|
401 |
// generate export file name
|
402 |
$export_file = wp_all_export_generate_export_file( XmlExportEngine::$exportID );
|
403 |
|
404 |
+
if ( ! $is_custom_xml ) {
|
405 |
+
$xml_header = apply_filters('wp_all_export_xml_header', '<?xml version="1.0" encoding="UTF-8"?>', XmlExportEngine::$exportID);
|
406 |
|
407 |
+
$xml = str_replace('<?xml version="1.0" encoding="UTF-8"?>', $xml_header, $xmlWriter->wpae_flush());
|
408 |
+
}
|
409 |
+
else {
|
410 |
+
$xml_header = XmlExportEngine::$exportOptions['custom_xml_template_header'];
|
411 |
|
412 |
+
$xml = PMXE_XMLWriter::preprocess_xml($xml_header) . $xmlWriter->wpae_flush();
|
|
|
|
|
|
|
413 |
}
|
414 |
+
|
415 |
+
if ( ! $is_custom_xml ) $xml = substr($xml, 0, (strlen(self::$main_xml_tag) + 4) * (-1));
|
416 |
+
|
417 |
+
// The BOM will help some programs like Microsoft Excel read your export file if it includes non-English characters.
|
418 |
+
if (XmlExportEngine::$exportOptions['include_bom']) {
|
419 |
+
file_put_contents($export_file, chr(0xEF).chr(0xBB).chr(0xBF).$xml);
|
420 |
}
|
421 |
+
else {
|
422 |
+
file_put_contents($export_file, $xml);
|
423 |
+
}
|
424 |
|
425 |
PMXE_Plugin::$session->set('file', $export_file);
|
|
|
426 |
PMXE_Plugin::$session->save_data();
|
427 |
|
428 |
}
|
429 |
+
else {
|
430 |
+
$xml = ( ! $is_custom_xml ) ? substr(substr($xmlWriter->wpae_flush(), 41 + strlen(self::$main_xml_tag)), 0, (strlen(self::$main_xml_tag) + 4) * (-1)) : $xmlWriter->wpae_flush();
|
431 |
+
|
432 |
+
file_put_contents(PMXE_Plugin::$session->file, $xml, FILE_APPEND);
|
433 |
}
|
434 |
|
435 |
return true;
|
439 |
// [ \XML Export Helpers ]
|
440 |
|
441 |
// [ CSV Export Helpers ]
|
442 |
+
public static function prepare_csv_headers( & $headers, $ID, &$acfs )
|
443 |
{
|
444 |
$element_name = ( ! empty(XmlExportEngine::$exportOptions['cc_name'][$ID]) ) ? XmlExportEngine::$exportOptions['cc_name'][$ID] : 'untitled_' . $ID;
|
445 |
|
446 |
+
if ( strpos(XmlExportEngine::$exportOptions['cc_label'][$ID], "item_data__") !== false ) {
|
|
|
447 |
XmlExportEngine::$woo_order_export->get_element_header( $headers, XmlExportEngine::$exportOptions, $ID );
|
448 |
return;
|
449 |
}
|
451 |
switch (XmlExportEngine::$exportOptions['cc_type'][$ID])
|
452 |
{
|
453 |
case 'woo':
|
454 |
+
XmlExportEngine::$woo_export->get_element_header( $headers, XmlExportEngine::$exportOptions, $ID );
|
|
|
|
|
455 |
break;
|
456 |
|
457 |
case 'woo_order':
|
458 |
+
XmlExportEngine::$woo_order_export->get_element_header( $headers, XmlExportEngine::$exportOptions, $ID );
|
|
|
|
|
459 |
break;
|
460 |
|
461 |
case 'acf':
|
462 |
+
if ( ! empty($acfs) ) {
|
|
|
|
|
463 |
$single_acf_field = array_shift($acfs);
|
464 |
|
465 |
+
if ( is_array($single_acf_field)) {
|
|
|
466 |
foreach ($single_acf_field as $acf_header) {
|
467 |
if ( ! in_array($acf_header, $headers)) $headers[] = $acf_header;
|
468 |
}
|
469 |
}
|
470 |
+
else {
|
|
|
471 |
if ( ! in_array($single_acf_field, $headers)) $headers[] = $single_acf_field;
|
472 |
}
|
473 |
}
|
|
|
474 |
break;
|
475 |
|
476 |
default:
|
477 |
|
478 |
if ($element_name == 'ID') $element_name = 'id';
|
479 |
|
480 |
+
if ( ! in_array($element_name, $headers)) {
|
|
|
481 |
$headers[] = $element_name;
|
482 |
}
|
483 |
+
else {
|
|
|
484 |
$is_added = false;
|
485 |
$i = 0;
|
486 |
+
do {
|
|
|
487 |
$new_element_name = $element_name . '_' . md5($i);
|
488 |
|
489 |
+
if ( ! in_array($new_element_name, $headers) ) {
|
|
|
490 |
$headers[] = $new_element_name;
|
491 |
$is_added = true;
|
492 |
}
|
496 |
while ( ! $is_added );
|
497 |
}
|
498 |
|
499 |
+
if ( XmlExportEngine::$exportOptions['cc_label'][$ID] == 'product_type' and ! in_array('parent_id', $headers)) {
|
500 |
+
$headers[] = 'parent_id';
|
501 |
+
}
|
502 |
+
|
503 |
break;
|
504 |
}
|
505 |
|
511 |
|
512 |
$elementIndex = array_pop($element_name_parts);
|
513 |
|
514 |
+
if (wp_all_export_isValidMd5($elementIndex)) {
|
|
|
515 |
$element_name_in_file = str_replace("_" . $elementIndex, "", $element_name);
|
516 |
}
|
517 |
+
else {
|
|
|
518 |
$element_name_in_file = $element_name;
|
519 |
}
|
520 |
|
533 |
|
534 |
$old_headers = array();
|
535 |
|
536 |
+
foreach ($clear_old_headers as $i => $header) {
|
|
|
537 |
$header = str_replace("'", "", str_replace('"', "", str_replace(chr(0xEF).chr(0xBB).chr(0xBF), "", $header)));
|
538 |
|
539 |
+
if ( ! in_array($header, $old_headers)) {
|
|
|
540 |
$old_headers[] = $header;
|
541 |
}
|
542 |
+
else {
|
|
|
543 |
$is_added = false;
|
544 |
$i = 0;
|
545 |
+
do {
|
|
|
546 |
$new_element_name = $header . '_' . md5($i);
|
547 |
|
548 |
+
if ( ! in_array($new_element_name, $old_headers) ) {
|
|
|
549 |
$old_headers[] = $new_element_name;
|
550 |
$is_added = true;
|
551 |
}
|
558 |
|
559 |
$is_update_headers = false;
|
560 |
|
561 |
+
foreach ($headers as $header) {
|
562 |
+
if ( ! in_array($header, $old_headers)) {
|
|
|
|
|
563 |
$is_update_headers = true;
|
564 |
break;
|
565 |
}
|
566 |
}
|
567 |
|
568 |
+
if ($is_update_headers) {
|
569 |
+
$headers = $old_headers + $headers;
|
|
|
|
|
|
|
570 |
$tmp_file = str_replace(basename($file), 'iteration_' . basename($file), $file);
|
571 |
+
copy($file, $tmp_file);
|
572 |
+
$in = fopen($tmp_file, 'r');
|
|
|
|
|
|
|
573 |
$out = fopen($file, 'w');
|
|
|
574 |
$headers = apply_filters('wp_all_export_csv_headers', $headers, XmlExportEngine::$exportID);
|
575 |
|
576 |
+
if ( XmlExportEngine::$exportOptions['include_bom'] ) {
|
|
|
577 |
fputcsv($out, chr(0xEF).chr(0xBB).chr(0xBF) . array_map(array('XmlCsvExport', '_get_valid_header_name'), $headers), XmlExportEngine::$exportOptions['delimiter']);
|
578 |
}
|
579 |
+
else {
|
|
|
580 |
fputcsv($out, array_map(array('XmlCsvExport', '_get_valid_header_name'), $headers), XmlExportEngine::$exportOptions['delimiter']);
|
581 |
}
|
582 |
|
583 |
+
apply_filters('wp_all_export_after_csv_line', $out, XmlExportEngine::$exportID);
|
584 |
+
|
585 |
$exclude_old_headers = fgetcsv($in);
|
586 |
|
587 |
+
if (is_resource($in)) {
|
|
|
588 |
while ( ! feof($in) ) {
|
589 |
$data = fgetcsv($in, 0, XmlExportEngine::$exportOptions['delimiter']);
|
590 |
if ( empty($data) ) continue;
|
594 |
$line[$header] = ( isset($data_assoc[$header]) ) ? $data_assoc[$header] : '';
|
595 |
}
|
596 |
fputcsv($out, $line, XmlExportEngine::$exportOptions['delimiter']);
|
597 |
+
apply_filters('wp_all_export_after_csv_line', $out, XmlExportEngine::$exportID);
|
598 |
}
|
599 |
fclose($in);
|
600 |
}
|
605 |
|
606 |
private static function save_csv_to_file( $file_path, $is_cron, $exported_by_cron )
|
607 |
{
|
608 |
+
if ($is_cron) {
|
609 |
+
if ( ! $exported_by_cron ) {
|
|
|
|
|
610 |
// The BOM will help some programs like Microsoft Excel read your export file if it includes non-English characters.
|
611 |
+
if (XmlExportEngine::$exportOptions['include_bom']) {
|
|
|
612 |
file_put_contents($file_path, chr(0xEF).chr(0xBB).chr(0xBF).ob_get_clean());
|
613 |
}
|
614 |
+
else {
|
|
|
615 |
file_put_contents($file_path, ob_get_clean());
|
616 |
}
|
617 |
}
|
618 |
+
else {
|
|
|
619 |
file_put_contents($file_path, ob_get_clean(), FILE_APPEND);
|
620 |
}
|
621 |
|
630 |
$export_file = wp_all_export_generate_export_file( XmlExportEngine::$exportID );
|
631 |
|
632 |
// The BOM will help some programs like Microsoft Excel read your export file if it includes non-English characters.
|
633 |
+
if (XmlExportEngine::$exportOptions['include_bom']) {
|
|
|
634 |
file_put_contents($export_file, chr(0xEF).chr(0xBB).chr(0xBF).ob_get_clean());
|
635 |
}
|
636 |
+
else {
|
|
|
637 |
file_put_contents($export_file, ob_get_clean());
|
638 |
}
|
639 |
|
640 |
PMXE_Plugin::$session->set('file', $export_file);
|
|
|
641 |
PMXE_Plugin::$session->save_data();
|
642 |
|
643 |
}
|
644 |
+
else {
|
|
|
645 |
file_put_contents(PMXE_Plugin::$session->file, ob_get_clean(), FILE_APPEND);
|
646 |
}
|
647 |
|
702 |
}
|
703 |
if ( ! empty($section['additional']) )
|
704 |
{
|
705 |
+
foreach ($section['additional'] as $sub_slug => $sub_section) {
|
706 |
+
foreach ($sub_section['meta'] as $field) {
|
|
|
|
|
707 |
$field_options = ( in_array($sub_slug, array('images', 'attachments')) ) ? esc_attr('{"is_export_featured":true,"is_export_attached":true,"image_separator":"|"}') : '0';
|
708 |
$field_name = '';
|
709 |
switch ($sub_slug) {
|
718 |
break;
|
719 |
}
|
720 |
|
721 |
+
if ( is_array($field) and isset($field['auto']) ) {
|
|
|
722 |
$auto_generate['ids'][] = 1;
|
723 |
$auto_generate['cc_label'][] = is_array($field) ? $field['label'] : $field;
|
724 |
$auto_generate['cc_php'][] = 0;
|
756 |
|
757 |
return $auto_generate;
|
758 |
}
|
759 |
+
|
760 |
+
/**
|
761 |
+
* @param $xmlWriter
|
762 |
+
* @param $key
|
763 |
+
* @param $value
|
764 |
+
*/
|
765 |
+
private static function addElement($xmlWriter, $key, $value)
|
766 |
+
{
|
767 |
+
$xmlWriter->startElement(preg_replace('/[^a-z0-9_-]/i', '', $key));
|
768 |
+
$xmlWriter->writeData($value, preg_replace('/[^a-z0-9_-]/i', '', $key));
|
769 |
+
$xmlWriter->closeElement();
|
770 |
+
}
|
771 |
+
}
|
libraries/XmlExportACF.php
CHANGED
@@ -36,10 +36,13 @@ if ( ! class_exists('XmlExportACF') )
|
|
36 |
|
37 |
if ( ! empty($saved_acfs) ){
|
38 |
foreach ($saved_acfs as $key => $obj) {
|
39 |
-
$
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
43 |
}
|
44 |
}
|
45 |
|
@@ -183,7 +186,7 @@ if ( ! class_exists('XmlExportACF') )
|
|
183 |
if ( ! empty($existing_meta_keys)){
|
184 |
foreach ($existing_meta_keys as $key => $meta_key) {
|
185 |
foreach ($this->_existing_acf_meta_keys as $acf_key => $acf_value) {
|
186 |
-
if (in_array($meta_key, array($acf_value, "_" . $acf_value))
|
187 |
unset($existing_meta_keys[$key]);
|
188 |
}
|
189 |
}
|
@@ -194,7 +197,9 @@ if ( ! class_exists('XmlExportACF') )
|
|
194 |
|
195 |
private static $additional_articles = array();
|
196 |
|
197 |
-
|
|
|
|
|
198 |
{
|
199 |
global $acf;
|
200 |
|
@@ -204,17 +209,24 @@ if ( ! class_exists('XmlExportACF') )
|
|
204 |
$field_options = ($ID) ? unserialize($exportOptions['cc_options'][$ID]) : $exportOptions;
|
205 |
$field_settings = ($ID) ? json_decode($exportOptions['cc_settings'][$ID], true) : false;
|
206 |
|
207 |
-
$is_xml_export =
|
|
|
|
|
|
|
|
|
208 |
|
209 |
if ( ! empty($field_value) )
|
210 |
{
|
211 |
$field_value = maybe_unserialize($field_value);
|
212 |
|
213 |
-
$implode_delimiter =
|
214 |
|
215 |
switch ($field_options['type'])
|
216 |
{
|
217 |
case 'date_time_picker':
|
|
|
|
|
|
|
218 |
case 'date_picker':
|
219 |
$field_value = date('Ymd', strtotime($field_value));
|
220 |
break;
|
@@ -227,17 +239,27 @@ if ( ! class_exists('XmlExportACF') )
|
|
227 |
}
|
228 |
elseif(is_array($field_value))
|
229 |
{
|
230 |
-
$field_value = $field_value['url'];
|
231 |
}
|
232 |
break;
|
233 |
|
234 |
case 'gallery':
|
235 |
-
$v = array();
|
|
|
236 |
foreach ($field_value as $key => $item)
|
237 |
-
{
|
238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
}
|
240 |
$field_value = implode($implode_delimiter, $v);
|
|
|
241 |
break;
|
242 |
case 'location-field':
|
243 |
$localion_parts = explode("|", $field_value);
|
@@ -249,20 +271,20 @@ if ( ! class_exists('XmlExportACF') )
|
|
249 |
$xmlWriter->beginElement($element_name_ns, $element_name, null);
|
250 |
$xmlWriter->startElement('address');
|
251 |
$xmlWriter->writeData($localion_parts[0], 'address');
|
252 |
-
$xmlWriter->
|
253 |
|
254 |
if (!empty($localion_parts[1])){
|
255 |
$coordinates = explode(",", $localion_parts[1]);
|
256 |
if (!empty($coordinates)){
|
257 |
$xmlWriter->startElement('lat');
|
258 |
$xmlWriter->writeData($coordinates[0], 'lat');
|
259 |
-
$xmlWriter->
|
260 |
$xmlWriter->startElement('lng');
|
261 |
$xmlWriter->writeData($coordinates[1], 'lng');
|
262 |
-
$xmlWriter->
|
263 |
}
|
264 |
}
|
265 |
-
$xmlWriter->
|
266 |
|
267 |
}
|
268 |
}
|
@@ -322,10 +344,10 @@ if ( ! class_exists('XmlExportACF') )
|
|
322 |
foreach ($field_value as $key => $value) {
|
323 |
$xmlWriter->beginElement($element_name_ns, $key, null);
|
324 |
$xmlWriter->writeData($value, $key);
|
325 |
-
$xmlWriter->
|
326 |
}
|
327 |
}
|
328 |
-
$xmlWriter->
|
329 |
}
|
330 |
else
|
331 |
{
|
@@ -354,14 +376,14 @@ if ( ! class_exists('XmlExportACF') )
|
|
354 |
$xmlWriter->beginElement($element_name_ns, $element_name, null);
|
355 |
$xmlWriter->startElement('address');
|
356 |
$xmlWriter->writeData($field_value['address'], 'address');
|
357 |
-
$xmlWriter->
|
358 |
$xmlWriter->startElement('lat');
|
359 |
$xmlWriter->writeData($field_value['lat'], 'lat');
|
360 |
-
$xmlWriter->
|
361 |
$xmlWriter->startElement('lng');
|
362 |
$xmlWriter->writeData($field_value['lng'], 'lng');
|
363 |
-
$xmlWriter->
|
364 |
-
$xmlWriter->
|
365 |
}
|
366 |
else
|
367 |
{
|
@@ -491,7 +513,7 @@ if ( ! class_exists('XmlExportACF') )
|
|
491 |
{
|
492 |
$xmlWriter->startElement('term');
|
493 |
$xmlWriter->writeData($entry->name, 'term');
|
494 |
-
$xmlWriter->
|
495 |
}
|
496 |
}
|
497 |
}
|
@@ -501,11 +523,11 @@ if ( ! class_exists('XmlExportACF') )
|
|
501 |
{
|
502 |
$xmlWriter->startElement('term');
|
503 |
$xmlWriter->writeData($entry->name, 'term');
|
504 |
-
$xmlWriter->
|
505 |
}
|
506 |
}
|
507 |
|
508 |
-
$xmlWriter->
|
509 |
|
510 |
$put_to_csv = false;
|
511 |
}
|
@@ -565,7 +587,7 @@ if ( ! class_exists('XmlExportACF') )
|
|
565 |
|
566 |
the_row();
|
567 |
|
568 |
-
$row = self::acf_get_row();
|
569 |
|
570 |
if ($is_xml_export) $xmlWriter->startElement('row');
|
571 |
|
@@ -581,7 +603,22 @@ if ( ! class_exists('XmlExportACF') )
|
|
581 |
else
|
582 |
{
|
583 |
$v = get_sub_field($sub_field['name']);
|
584 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
585 |
|
586 |
$sub_field['delimiter'] = $implode_delimiter;
|
587 |
|
@@ -598,7 +635,8 @@ if ( ! class_exists('XmlExportACF') )
|
|
598 |
$fieldSnipped,
|
599 |
'',
|
600 |
$preview,
|
601 |
-
$is_xml_export ? false : true
|
|
|
602 |
);
|
603 |
|
604 |
if ( ! $is_xml_export )
|
@@ -608,7 +646,7 @@ if ( ! class_exists('XmlExportACF') )
|
|
608 |
case 'google_map':
|
609 |
case 'paypal_item':
|
610 |
case 'location-field':
|
611 |
-
case 'repeater':
|
612 |
|
613 |
if ( ! empty($sub_field_value))
|
614 |
{
|
@@ -628,7 +666,7 @@ if ( ! class_exists('XmlExportACF') )
|
|
628 |
}
|
629 |
}
|
630 |
|
631 |
-
if ($is_xml_export) $xmlWriter->
|
632 |
|
633 |
endwhile;
|
634 |
|
@@ -712,7 +750,7 @@ if ( ! class_exists('XmlExportACF') )
|
|
712 |
|
713 |
endif;
|
714 |
|
715 |
-
if ($is_xml_export) $xmlWriter->
|
716 |
|
717 |
$put_to_csv = false;
|
718 |
|
@@ -720,23 +758,24 @@ if ( ! class_exists('XmlExportACF') )
|
|
720 |
|
721 |
case 'flexible_content':
|
722 |
|
723 |
-
$fc_sub_field_names = array();
|
724 |
|
725 |
if ($is_xml_export) $xmlWriter->beginElement($element_name_ns, $element_name, null);
|
726 |
|
727 |
// check if the flexible content field has rows of data
|
728 |
-
if( have_rows($field_name) ):
|
729 |
|
730 |
// loop through the rows of data
|
731 |
-
while ( have_rows($field_name) ) : the_row();
|
732 |
|
733 |
$row = self::acf_get_row();
|
734 |
|
735 |
-
foreach ($row['field']['layouts'] as $layout) {
|
736 |
|
737 |
if ($layout['name'] == $row['value'][ $row['i'] ]['acf_fc_layout']){
|
738 |
|
739 |
-
if ($is_xml_export) $xmlWriter->startElement($row['value'][ $row['i'] ]['acf_fc_layout'] . '_' . $row['i']);
|
|
|
740 |
foreach ($layout['sub_fields'] as $sub_field) {
|
741 |
|
742 |
$layout_field_name = $element_name . '_' . $layout['name'] . '_' . $row['i'];
|
@@ -747,11 +786,30 @@ if ( ! class_exists('XmlExportACF') )
|
|
747 |
{
|
748 |
$v = $row['value'][ $row['i'] ][ $sub_field['key'] ];
|
749 |
|
750 |
-
if ($is_xml_export)
|
751 |
{
|
752 |
-
|
|
|
|
|
|
|
|
|
753 |
}
|
754 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
755 |
|
756 |
$sub_field['delimiter'] = $implode_delimiter;
|
757 |
|
@@ -768,8 +826,9 @@ if ( ! class_exists('XmlExportACF') )
|
|
768 |
$fieldSnipped,
|
769 |
'',
|
770 |
$preview,
|
771 |
-
$is_xml_export ? false : true
|
772 |
-
|
|
|
773 |
|
774 |
if ( ! $is_xml_export )
|
775 |
{
|
@@ -781,24 +840,28 @@ if ( ! class_exists('XmlExportACF') )
|
|
781 |
{
|
782 |
foreach ($sub_field_values as $key => $values) {
|
783 |
$article[$layout_field_name . '_' . $key] = ($preview) ? trim(preg_replace('~[\r\n]+~', ' ', htmlspecialchars(implode($implode_delimiter, $values)))) : implode($implode_delimiter, $values);
|
784 |
-
if ( ! in_array($layout_field_name . '_' . $key,
|
785 |
}
|
786 |
}
|
787 |
|
788 |
break;
|
789 |
-
|
|
|
|
|
|
|
|
|
790 |
default:
|
791 |
-
|
792 |
-
$article[$layout_field_name . '_' . $sub_field['name']] = $v;
|
793 |
|
794 |
-
|
795 |
-
|
|
|
|
|
796 |
|
797 |
break;
|
798 |
}
|
799 |
}
|
800 |
}
|
801 |
-
if ($is_xml_export) $xmlWriter->
|
802 |
}
|
803 |
}
|
804 |
|
@@ -810,9 +873,7 @@ if ( ! class_exists('XmlExportACF') )
|
|
810 |
|
811 |
endif;
|
812 |
|
813 |
-
if ($is_xml_export) $xmlWriter->
|
814 |
-
|
815 |
-
if ( ! empty($fc_sub_field_names)) $acfs[$element_name] = $fc_sub_field_names;
|
816 |
|
817 |
$put_to_csv = false;
|
818 |
|
@@ -824,7 +885,9 @@ if ( ! class_exists('XmlExportACF') )
|
|
824 |
}
|
825 |
}
|
826 |
|
827 |
-
if ($return_value) return $field_value;
|
|
|
|
|
828 |
|
829 |
if ($put_to_csv)
|
830 |
{
|
@@ -834,7 +897,7 @@ if ( ! class_exists('XmlExportACF') )
|
|
834 |
{
|
835 |
$xmlWriter->beginElement($element_name_ns, $element_name, null);
|
836 |
$xmlWriter->writeData($val, $element_name);
|
837 |
-
$xmlWriter->
|
838 |
}
|
839 |
else
|
840 |
{
|
@@ -874,6 +937,36 @@ if ( ! class_exists('XmlExportACF') )
|
|
874 |
return $articles;
|
875 |
}
|
876 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
877 |
public function render( & $i ){
|
878 |
|
879 |
if ( ! empty($this->_acf_groups) )
|
@@ -985,7 +1078,7 @@ if ( ! class_exists('XmlExportACF') )
|
|
985 |
|
986 |
public static function prepare_import_template( $exportOptions, &$templateOptions, &$acf_list, $element_name, $field_options)
|
987 |
{
|
988 |
-
$field_tpl_key = $element_name . '[1]';
|
989 |
|
990 |
$acf_list[] = '[' . $field_options['name'] . '] ' . $field_options['label'];
|
991 |
|
@@ -997,7 +1090,7 @@ if ( ! class_exists('XmlExportACF') )
|
|
997 |
|
998 |
$xpath_separator = $is_xml_template ? '/' : '_';
|
999 |
|
1000 |
-
$implode_delimiter =
|
1001 |
|
1002 |
switch ($field_options['type'])
|
1003 |
{
|
@@ -1021,20 +1114,28 @@ if ( ! class_exists('XmlExportACF') )
|
|
1021 |
$field_template = '{' . $field_tpl_key . '}';
|
1022 |
break;
|
1023 |
case 'gallery':
|
1024 |
-
case 'relationship':
|
1025 |
|
1026 |
if ($is_xml_template)
|
1027 |
{
|
1028 |
-
$field_template =
|
|
|
|
|
1029 |
}
|
1030 |
else
|
1031 |
{
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1038 |
}
|
1039 |
break;
|
1040 |
case 'post_object':
|
@@ -1290,8 +1391,7 @@ if ( ! class_exists('XmlExportACF') )
|
|
1290 |
|
1291 |
break;
|
1292 |
|
1293 |
-
}
|
1294 |
-
|
1295 |
return $field_template;
|
1296 |
}
|
1297 |
|
36 |
|
37 |
if ( ! empty($saved_acfs) ){
|
38 |
foreach ($saved_acfs as $key => $obj) {
|
39 |
+
if ( ! isset($acfs[$obj->post_name]))
|
40 |
+
{
|
41 |
+
$this->_acf_groups[] = array(
|
42 |
+
'ID' => $obj->ID,
|
43 |
+
'title' => $obj->post_title
|
44 |
+
);
|
45 |
+
}
|
46 |
}
|
47 |
}
|
48 |
|
186 |
if ( ! empty($existing_meta_keys)){
|
187 |
foreach ($existing_meta_keys as $key => $meta_key) {
|
188 |
foreach ($this->_existing_acf_meta_keys as $acf_key => $acf_value) {
|
189 |
+
if (in_array($meta_key, array($acf_value, "_" . $acf_value))) {
|
190 |
unset($existing_meta_keys[$key]);
|
191 |
}
|
192 |
}
|
197 |
|
198 |
private static $additional_articles = array();
|
199 |
|
200 |
+
private static $fc_sub_field_names = array();
|
201 |
+
|
202 |
+
public static function export_acf_field($field_value = '', $exportOptions, $ID, $pid, &$article, $xmlWriter = false, &$acfs, $element_name = '', $element_name_ns = '', $fieldSnipped = '', $group_id = '', $preview = false, $return_value = false, $is_sub_field = false )
|
203 |
{
|
204 |
global $acf;
|
205 |
|
209 |
$field_options = ($ID) ? unserialize($exportOptions['cc_options'][$ID]) : $exportOptions;
|
210 |
$field_settings = ($ID) ? json_decode($exportOptions['cc_settings'][$ID], true) : false;
|
211 |
|
212 |
+
$is_xml_export = false;
|
213 |
+
|
214 |
+
if ( ! empty($xmlWriter) and XmlExportEngine::$exportOptions['export_to'] == 'xml' and ! in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ){
|
215 |
+
$is_xml_export = true;
|
216 |
+
}
|
217 |
|
218 |
if ( ! empty($field_value) )
|
219 |
{
|
220 |
$field_value = maybe_unserialize($field_value);
|
221 |
|
222 |
+
$implode_delimiter = XmlExportEngine::$implode;
|
223 |
|
224 |
switch ($field_options['type'])
|
225 |
{
|
226 |
case 'date_time_picker':
|
227 |
+
$format = empty($field_options['return_format']) ? 'Y-m-d H:i:s' : $field_options['return_format'];
|
228 |
+
$field_value = date($format, strtotime($field_value));
|
229 |
+
break;
|
230 |
case 'date_picker':
|
231 |
$field_value = date('Ymd', strtotime($field_value));
|
232 |
break;
|
239 |
}
|
240 |
elseif(is_array($field_value))
|
241 |
{
|
242 |
+
$field_value = empty($field_value['url']) ? '' : $field_value['url'];
|
243 |
}
|
244 |
break;
|
245 |
|
246 |
case 'gallery':
|
247 |
+
$v = array();
|
248 |
+
|
249 |
foreach ($field_value as $key => $item)
|
250 |
+
{
|
251 |
+
if (!empty($item['url'])){
|
252 |
+
$v[] = $item['url'];
|
253 |
+
}
|
254 |
+
elseif (is_numeric($item)){
|
255 |
+
$gallery_item_url = wp_get_attachment_url($item);
|
256 |
+
if (!empty($gallery_item_url)){
|
257 |
+
$v[] = $gallery_item_url;
|
258 |
+
}
|
259 |
+
}
|
260 |
}
|
261 |
$field_value = implode($implode_delimiter, $v);
|
262 |
+
|
263 |
break;
|
264 |
case 'location-field':
|
265 |
$localion_parts = explode("|", $field_value);
|
271 |
$xmlWriter->beginElement($element_name_ns, $element_name, null);
|
272 |
$xmlWriter->startElement('address');
|
273 |
$xmlWriter->writeData($localion_parts[0], 'address');
|
274 |
+
$xmlWriter->closeElement();
|
275 |
|
276 |
if (!empty($localion_parts[1])){
|
277 |
$coordinates = explode(",", $localion_parts[1]);
|
278 |
if (!empty($coordinates)){
|
279 |
$xmlWriter->startElement('lat');
|
280 |
$xmlWriter->writeData($coordinates[0], 'lat');
|
281 |
+
$xmlWriter->closeElement();
|
282 |
$xmlWriter->startElement('lng');
|
283 |
$xmlWriter->writeData($coordinates[1], 'lng');
|
284 |
+
$xmlWriter->closeElement();
|
285 |
}
|
286 |
}
|
287 |
+
$xmlWriter->closeElement();
|
288 |
|
289 |
}
|
290 |
}
|
344 |
foreach ($field_value as $key => $value) {
|
345 |
$xmlWriter->beginElement($element_name_ns, $key, null);
|
346 |
$xmlWriter->writeData($value, $key);
|
347 |
+
$xmlWriter->closeElement();
|
348 |
}
|
349 |
}
|
350 |
+
$xmlWriter->closeElement();
|
351 |
}
|
352 |
else
|
353 |
{
|
376 |
$xmlWriter->beginElement($element_name_ns, $element_name, null);
|
377 |
$xmlWriter->startElement('address');
|
378 |
$xmlWriter->writeData($field_value['address'], 'address');
|
379 |
+
$xmlWriter->closeElement();
|
380 |
$xmlWriter->startElement('lat');
|
381 |
$xmlWriter->writeData($field_value['lat'], 'lat');
|
382 |
+
$xmlWriter->closeElement();
|
383 |
$xmlWriter->startElement('lng');
|
384 |
$xmlWriter->writeData($field_value['lng'], 'lng');
|
385 |
+
$xmlWriter->closeElement();
|
386 |
+
$xmlWriter->closeElement();
|
387 |
}
|
388 |
else
|
389 |
{
|
513 |
{
|
514 |
$xmlWriter->startElement('term');
|
515 |
$xmlWriter->writeData($entry->name, 'term');
|
516 |
+
$xmlWriter->closeElement();
|
517 |
}
|
518 |
}
|
519 |
}
|
523 |
{
|
524 |
$xmlWriter->startElement('term');
|
525 |
$xmlWriter->writeData($entry->name, 'term');
|
526 |
+
$xmlWriter->closeElement();
|
527 |
}
|
528 |
}
|
529 |
|
530 |
+
$xmlWriter->closeElement();
|
531 |
|
532 |
$put_to_csv = false;
|
533 |
}
|
587 |
|
588 |
the_row();
|
589 |
|
590 |
+
$row = self::acf_get_row();
|
591 |
|
592 |
if ($is_xml_export) $xmlWriter->startElement('row');
|
593 |
|
603 |
else
|
604 |
{
|
605 |
$v = get_sub_field($sub_field['name']);
|
606 |
+
}
|
607 |
+
|
608 |
+
if ($preview && ! $is_xml_export){
|
609 |
+
switch ($sub_field['type']) {
|
610 |
+
case 'textarea':
|
611 |
+
case 'oembed':
|
612 |
+
case 'wysiwyg':
|
613 |
+
case 'wp_wysiwyg':
|
614 |
+
case 'date_time_picker':
|
615 |
+
case 'date_picker':
|
616 |
+
$v = preg_replace( "/\r|\n/", "", esc_html($v) );
|
617 |
+
break;
|
618 |
+
default:
|
619 |
+
break;
|
620 |
+
}
|
621 |
+
}
|
622 |
|
623 |
$sub_field['delimiter'] = $implode_delimiter;
|
624 |
|
635 |
$fieldSnipped,
|
636 |
'',
|
637 |
$preview,
|
638 |
+
$is_xml_export ? false : true,
|
639 |
+
true
|
640 |
);
|
641 |
|
642 |
if ( ! $is_xml_export )
|
646 |
case 'google_map':
|
647 |
case 'paypal_item':
|
648 |
case 'location-field':
|
649 |
+
case 'repeater':
|
650 |
|
651 |
if ( ! empty($sub_field_value))
|
652 |
{
|
666 |
}
|
667 |
}
|
668 |
|
669 |
+
if ($is_xml_export) $xmlWriter->closeElement();
|
670 |
|
671 |
endwhile;
|
672 |
|
750 |
|
751 |
endif;
|
752 |
|
753 |
+
if ($is_xml_export) $xmlWriter->closeElement();
|
754 |
|
755 |
$put_to_csv = false;
|
756 |
|
758 |
|
759 |
case 'flexible_content':
|
760 |
|
761 |
+
if ( ! $is_sub_field ) self::$fc_sub_field_names = array();
|
762 |
|
763 |
if ($is_xml_export) $xmlWriter->beginElement($element_name_ns, $element_name, null);
|
764 |
|
765 |
// check if the flexible content field has rows of data
|
766 |
+
if( have_rows($field_name, $pid) ):
|
767 |
|
768 |
// loop through the rows of data
|
769 |
+
while ( have_rows($field_name, $pid) ) : the_row();
|
770 |
|
771 |
$row = self::acf_get_row();
|
772 |
|
773 |
+
foreach ($row['field']['layouts'] as $layout) {
|
774 |
|
775 |
if ($layout['name'] == $row['value'][ $row['i'] ]['acf_fc_layout']){
|
776 |
|
777 |
+
if ($is_xml_export) $xmlWriter->startElement($row['value'][ $row['i'] ]['acf_fc_layout'] . '_' . $row['i']);
|
778 |
+
|
779 |
foreach ($layout['sub_fields'] as $sub_field) {
|
780 |
|
781 |
$layout_field_name = $element_name . '_' . $layout['name'] . '_' . $row['i'];
|
786 |
{
|
787 |
$v = $row['value'][ $row['i'] ][ $sub_field['key'] ];
|
788 |
|
789 |
+
if ($is_xml_export)
|
790 |
{
|
791 |
+
// apply filters
|
792 |
+
$v = apply_filters( "acf/format_value", $v, $pid, $sub_field );
|
793 |
+
$v = apply_filters( "acf/format_value/type={$sub_field['type']}", $v, $pid, $sub_field );
|
794 |
+
$v = apply_filters( "acf/format_value/name={$sub_field['_name']}", $v, $pid, $sub_field );
|
795 |
+
$v = apply_filters( "acf/format_value/key={$sub_field['key']}", $v, $pid, $sub_field );
|
796 |
}
|
797 |
+
}
|
798 |
+
|
799 |
+
if ($preview && ! $is_xml_export){
|
800 |
+
switch ($sub_field['type']) {
|
801 |
+
case 'textarea':
|
802 |
+
case 'oembed':
|
803 |
+
case 'wysiwyg':
|
804 |
+
case 'wp_wysiwyg':
|
805 |
+
case 'date_time_picker':
|
806 |
+
case 'date_picker':
|
807 |
+
$v = preg_replace( "/\r|\n/", "", esc_html($v) );
|
808 |
+
break;
|
809 |
+
default:
|
810 |
+
break;
|
811 |
+
}
|
812 |
+
}
|
813 |
|
814 |
$sub_field['delimiter'] = $implode_delimiter;
|
815 |
|
826 |
$fieldSnipped,
|
827 |
'',
|
828 |
$preview,
|
829 |
+
$is_xml_export ? false : true,
|
830 |
+
true
|
831 |
+
);
|
832 |
|
833 |
if ( ! $is_xml_export )
|
834 |
{
|
840 |
{
|
841 |
foreach ($sub_field_values as $key => $values) {
|
842 |
$article[$layout_field_name . '_' . $key] = ($preview) ? trim(preg_replace('~[\r\n]+~', ' ', htmlspecialchars(implode($implode_delimiter, $values)))) : implode($implode_delimiter, $values);
|
843 |
+
if ( ! in_array($layout_field_name . '_' . $key, self::$fc_sub_field_names)) self::$fc_sub_field_names[] = $layout_field_name . '_' . $key;
|
844 |
}
|
845 |
}
|
846 |
|
847 |
break;
|
848 |
+
case 'flexible_content':
|
849 |
+
|
850 |
+
|
851 |
+
break;
|
852 |
+
|
853 |
default:
|
|
|
|
|
854 |
|
855 |
+
$article[$layout_field_name . '_' . $sub_field['name']] = is_array($sub_field_values) ? implode($implode_delimiter, $sub_field_values) : $sub_field_values;
|
856 |
+
|
857 |
+
if ( ! in_array($layout_field_name . '_' . $sub_field['name'], self::$fc_sub_field_names))
|
858 |
+
self::$fc_sub_field_names[] = $layout_field_name . '_' . $sub_field['name'];
|
859 |
|
860 |
break;
|
861 |
}
|
862 |
}
|
863 |
}
|
864 |
+
if ($is_xml_export) $xmlWriter->closeElement();
|
865 |
}
|
866 |
}
|
867 |
|
873 |
|
874 |
endif;
|
875 |
|
876 |
+
if ($is_xml_export) $xmlWriter->closeElement();
|
|
|
|
|
877 |
|
878 |
$put_to_csv = false;
|
879 |
|
885 |
}
|
886 |
}
|
887 |
|
888 |
+
if ($return_value) return $field_value;
|
889 |
+
|
890 |
+
if ( ! empty(self::$fc_sub_field_names)) $acfs[$element_name] = self::$fc_sub_field_names;
|
891 |
|
892 |
if ($put_to_csv)
|
893 |
{
|
897 |
{
|
898 |
$xmlWriter->beginElement($element_name_ns, $element_name, null);
|
899 |
$xmlWriter->writeData($val, $element_name);
|
900 |
+
$xmlWriter->closeElement();
|
901 |
}
|
902 |
else
|
903 |
{
|
937 |
return $articles;
|
938 |
}
|
939 |
|
940 |
+
public function get_fields_options( &$fields, $field_keys = array() ){
|
941 |
+
|
942 |
+
if ( ! empty($this->_acf_groups) )
|
943 |
+
{
|
944 |
+
foreach ($this->_acf_groups as $key => $group)
|
945 |
+
{
|
946 |
+
if ( ! empty($group['fields']))
|
947 |
+
{
|
948 |
+
foreach ($group['fields'] as $field)
|
949 |
+
{
|
950 |
+
$field_key = $field['label'];
|
951 |
+
|
952 |
+
if ( ! in_array($field_key, $field_keys) ) continue;
|
953 |
+
|
954 |
+
$fields['ids'][] = 1;
|
955 |
+
$fields['cc_label'][] = $field['name'];
|
956 |
+
$fields['cc_php'][] = '';
|
957 |
+
$fields['cc_code'][] = '';
|
958 |
+
$fields['cc_sql'][] = '';
|
959 |
+
$fields['cc_options'][] = esc_html(serialize(array_merge($field, array('group_id' => ((!empty($group['ID'])) ? $group['ID'] : $group['id']) ))));
|
960 |
+
$fields['cc_type'][] = 'acf';
|
961 |
+
$fields['cc_value'][] = $field['name'];
|
962 |
+
$fields['cc_name'][] = $field_key;
|
963 |
+
$fields['cc_settings'][] = '';
|
964 |
+
}
|
965 |
+
}
|
966 |
+
}
|
967 |
+
}
|
968 |
+
}
|
969 |
+
|
970 |
public function render( & $i ){
|
971 |
|
972 |
if ( ! empty($this->_acf_groups) )
|
1078 |
|
1079 |
public static function prepare_import_template( $exportOptions, &$templateOptions, &$acf_list, $element_name, $field_options)
|
1080 |
{
|
1081 |
+
$field_tpl_key = $element_name . '[1]';
|
1082 |
|
1083 |
$acf_list[] = '[' . $field_options['name'] . '] ' . $field_options['label'];
|
1084 |
|
1090 |
|
1091 |
$xpath_separator = $is_xml_template ? '/' : '_';
|
1092 |
|
1093 |
+
$implode_delimiter = XmlExportEngine::$implode;
|
1094 |
|
1095 |
switch ($field_options['type'])
|
1096 |
{
|
1114 |
$field_template = '{' . $field_tpl_key . '}';
|
1115 |
break;
|
1116 |
case 'gallery':
|
|
|
1117 |
|
1118 |
if ($is_xml_template)
|
1119 |
{
|
1120 |
+
$field_template = array(
|
1121 |
+
'gallery' => '{' . $field_tpl_key . '}'
|
1122 |
+
);
|
1123 |
}
|
1124 |
else
|
1125 |
{
|
1126 |
+
$field_template = array(
|
1127 |
+
'search_in_media' => 1,
|
1128 |
+
'delim' => $implode_delimiter,
|
1129 |
+
'gallery' => '{' . $field_tpl_key . '}'
|
1130 |
+
);
|
1131 |
+
}
|
1132 |
+
break;
|
1133 |
+
case 'relationship':
|
1134 |
+
if ($implode_delimiter == "|") {
|
1135 |
+
$field_template = '[str_replace("|", ",",{' . $field_tpl_key . '})]';
|
1136 |
+
}
|
1137 |
+
else{
|
1138 |
+
$field_template = '{' . $field_tpl_key . '}';
|
1139 |
}
|
1140 |
break;
|
1141 |
case 'post_object':
|
1391 |
|
1392 |
break;
|
1393 |
|
1394 |
+
}
|
|
|
1395 |
return $field_template;
|
1396 |
}
|
1397 |
|
libraries/XmlExportComment.php
CHANGED
@@ -170,13 +170,15 @@ if ( ! class_exists('XmlExportComment') )
|
|
170 |
|
171 |
global $wp_version;
|
172 |
|
173 |
-
if (
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
|
|
|
|
180 |
}
|
181 |
|
182 |
if ( ! empty( $comments ) ) {
|
170 |
|
171 |
global $wp_version;
|
172 |
|
173 |
+
if ( ! empty(XmlExportEngine::$exportQuery)){
|
174 |
+
if ( version_compare($wp_version, '4.2.0', '>=') )
|
175 |
+
{
|
176 |
+
$comments = XmlExportEngine::$exportQuery->get_comments();
|
177 |
+
}
|
178 |
+
else
|
179 |
+
{
|
180 |
+
$comments = XmlExportEngine::$exportQuery;
|
181 |
+
}
|
182 |
}
|
183 |
|
184 |
if ( ! empty( $comments ) ) {
|
libraries/XmlExportCpt.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
|
|
|
3 |
final class XmlExportCpt
|
4 |
{
|
5 |
/**
|
@@ -46,6 +47,12 @@ final class XmlExportCpt
|
|
46 |
unset($postRecord);
|
47 |
}
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
foreach (XmlExportEngine::$exportOptions['ids'] as $ID => $value)
|
50 |
{
|
51 |
$pType = $entry->post_type;
|
@@ -64,13 +71,13 @@ final class XmlExportCpt
|
|
64 |
$fieldType = XmlExportEngine::$exportOptions['cc_type'][$ID];
|
65 |
$fieldOptions = XmlExportEngine::$exportOptions['cc_options'][$ID];
|
66 |
$fieldSettings = empty(XmlExportEngine::$exportOptions['cc_settings'][$ID]) ? $fieldOptions : XmlExportEngine::$exportOptions['cc_settings'][$ID];
|
67 |
-
|
68 |
if ( empty($fieldName) or empty($fieldType) or ! is_numeric($ID) ) continue;
|
69 |
|
70 |
$element_name = ( ! empty($fieldName) ) ? $fieldName : 'untitled_' . $ID;
|
71 |
$element_name_ns = '';
|
72 |
|
73 |
-
if (
|
74 |
{
|
75 |
$element_name = ( ! empty($fieldName) ) ? preg_replace('/[^a-z0-9_:-]/i', '', $fieldName) : 'untitled_' . $ID;
|
76 |
|
@@ -98,7 +105,8 @@ final class XmlExportCpt
|
|
98 |
wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_post_type', pmxe_filter($pType, $fieldSnipped), $entry->ID) );
|
99 |
break;
|
100 |
case 'title':
|
101 |
-
|
|
|
102 |
break;
|
103 |
case 'content':
|
104 |
$val = apply_filters('pmxe_post_content', pmxe_filter($entry->post_content, $fieldSnipped), $entry->ID);
|
@@ -241,7 +249,7 @@ final class XmlExportCpt
|
|
241 |
|
242 |
$field_options = unserialize($fieldOptions);
|
243 |
|
244 |
-
if (
|
245 |
{
|
246 |
switch ($field_options['type']) {
|
247 |
case 'textarea':
|
@@ -288,7 +296,7 @@ final class XmlExportCpt
|
|
288 |
|
289 |
case 'woo':
|
290 |
|
291 |
-
if ( $
|
292 |
{
|
293 |
XmlExportEngine::$woo_export->export_xml($xmlWriter, $entry, XmlExportEngine::$exportOptions, $ID);
|
294 |
}
|
@@ -301,13 +309,13 @@ final class XmlExportCpt
|
|
301 |
|
302 |
case 'woo_order':
|
303 |
|
304 |
-
if ( $
|
305 |
{
|
306 |
-
XmlExportEngine::$woo_order_export->export_xml($xmlWriter, $entry, XmlExportEngine::$exportOptions, $ID, $preview);
|
307 |
}
|
308 |
else
|
309 |
{
|
310 |
-
XmlExportEngine::$woo_order_export->export_csv($article, $woo_order, $entry, XmlExportEngine::$exportOptions, $ID, $preview);
|
311 |
}
|
312 |
|
313 |
break;
|
@@ -345,16 +353,21 @@ final class XmlExportCpt
|
|
345 |
|
346 |
if ( ! empty($fieldValue) )
|
347 |
{
|
348 |
-
|
349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
if ( ! is_wp_error($txes_list) and ! empty($txes_list) )
|
351 |
{
|
352 |
-
$txes_ids = array();
|
353 |
-
$hierarchy_groups = array();
|
354 |
|
355 |
foreach ($txes_list as $t) {
|
356 |
$txes_ids[] = $t->term_id;
|
357 |
-
}
|
358 |
|
359 |
foreach ($txes_list as $t) {
|
360 |
if ( wp_all_export_check_children_assign($t->term_id, $fieldValue, $txes_ids) ){
|
@@ -374,14 +387,13 @@ final class XmlExportCpt
|
|
374 |
$hierarchy_groups[] = $t->name;
|
375 |
}
|
376 |
}
|
377 |
-
}
|
378 |
|
379 |
-
if (
|
380 |
-
{
|
381 |
-
wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_post_taxonomy', pmxe_filter(implode($implode_delimiter, $hierarchy_groups), $fieldSnipped), $entry->ID) );
|
382 |
-
}
|
383 |
|
384 |
}
|
|
|
|
|
385 |
|
386 |
// if ( ! in_array($element_name, $taxes)) $taxes[] = $element_name;
|
387 |
|
@@ -391,11 +403,11 @@ final class XmlExportCpt
|
|
391 |
|
392 |
$article['parent_id'] = $entry->post_parent;
|
393 |
|
394 |
-
if ($
|
395 |
{
|
396 |
$xmlWriter->beginElement($element_name_ns, 'parent_id', null);
|
397 |
$xmlWriter->writeData($article['parent_id'], 'parent_id');
|
398 |
-
$xmlWriter->
|
399 |
}
|
400 |
}
|
401 |
}
|
@@ -468,8 +480,8 @@ final class XmlExportCpt
|
|
468 |
# code...
|
469 |
break;
|
470 |
}
|
471 |
-
|
472 |
-
if ( $
|
473 |
{
|
474 |
$element_name_in_file = XmlCsvExport::_get_valid_header_name( $element_name );
|
475 |
|
@@ -477,7 +489,7 @@ final class XmlExportCpt
|
|
477 |
|
478 |
$xmlWriter->beginElement($element_name_ns, $element_name_in_file, null);
|
479 |
$xmlWriter->writeData($article[$element_name], $element_name_in_file);
|
480 |
-
$xmlWriter->
|
481 |
|
482 |
$xmlWriter = apply_filters('wp_all_export_add_after_element', $xmlWriter, $element_name_in_file, XmlExportEngine::$exportID, $entry->ID);
|
483 |
}
|
@@ -493,7 +505,7 @@ final class XmlExportCpt
|
|
493 |
|
494 |
$is_xml_template = $options['export_to'] == 'xml';
|
495 |
|
496 |
-
$implode_delimiter =
|
497 |
|
498 |
switch ($element_type)
|
499 |
{
|
@@ -505,11 +517,15 @@ final class XmlExportCpt
|
|
505 |
break;
|
506 |
case 'title':
|
507 |
case 'content':
|
508 |
-
case 'author':
|
509 |
-
case 'parent':
|
510 |
case 'slug':
|
511 |
$templateOptions[$element_type] = '{'. $element_name .'[1]}';
|
512 |
$templateOptions['is_update_' . $options['cc_type'][$ID]] = 1;
|
|
|
|
|
|
|
|
|
|
|
513 |
break;
|
514 |
case 'excerpt':
|
515 |
$templateOptions['post_excerpt'] = '{'. $element_name .'[1]}';
|
1 |
<?php
|
2 |
|
3 |
+
|
4 |
final class XmlExportCpt
|
5 |
{
|
6 |
/**
|
47 |
unset($postRecord);
|
48 |
}
|
49 |
|
50 |
+
$is_xml_export = false;
|
51 |
+
|
52 |
+
if ( ! empty($xmlWriter) and XmlExportEngine::$exportOptions['export_to'] == 'xml' and ! in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ){
|
53 |
+
$is_xml_export = true;
|
54 |
+
}
|
55 |
+
|
56 |
foreach (XmlExportEngine::$exportOptions['ids'] as $ID => $value)
|
57 |
{
|
58 |
$pType = $entry->post_type;
|
71 |
$fieldType = XmlExportEngine::$exportOptions['cc_type'][$ID];
|
72 |
$fieldOptions = XmlExportEngine::$exportOptions['cc_options'][$ID];
|
73 |
$fieldSettings = empty(XmlExportEngine::$exportOptions['cc_settings'][$ID]) ? $fieldOptions : XmlExportEngine::$exportOptions['cc_settings'][$ID];
|
74 |
+
|
75 |
if ( empty($fieldName) or empty($fieldType) or ! is_numeric($ID) ) continue;
|
76 |
|
77 |
$element_name = ( ! empty($fieldName) ) ? $fieldName : 'untitled_' . $ID;
|
78 |
$element_name_ns = '';
|
79 |
|
80 |
+
if ( $is_xml_export )
|
81 |
{
|
82 |
$element_name = ( ! empty($fieldName) ) ? preg_replace('/[^a-z0-9_:-]/i', '', $fieldName) : 'untitled_' . $ID;
|
83 |
|
105 |
wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_post_type', pmxe_filter($pType, $fieldSnipped), $entry->ID) );
|
106 |
break;
|
107 |
case 'title':
|
108 |
+
$val = apply_filters('pmxe_post_title', pmxe_filter($entry->post_title, $fieldSnipped));
|
109 |
+
wp_all_export_write_article( $article, $element_name, ($preview) ? trim(preg_replace('~[\r\n]+~', ' ', htmlspecialchars($val))) : $val, $entry->ID) ;
|
110 |
break;
|
111 |
case 'content':
|
112 |
$val = apply_filters('pmxe_post_content', pmxe_filter($entry->post_content, $fieldSnipped), $entry->ID);
|
249 |
|
250 |
$field_options = unserialize($fieldOptions);
|
251 |
|
252 |
+
if ( ! $is_xml_export )
|
253 |
{
|
254 |
switch ($field_options['type']) {
|
255 |
case 'textarea':
|
296 |
|
297 |
case 'woo':
|
298 |
|
299 |
+
if ( $is_xml_export )
|
300 |
{
|
301 |
XmlExportEngine::$woo_export->export_xml($xmlWriter, $entry, XmlExportEngine::$exportOptions, $ID);
|
302 |
}
|
309 |
|
310 |
case 'woo_order':
|
311 |
|
312 |
+
if ( $is_xml_export )
|
313 |
{
|
314 |
+
XmlExportEngine::$woo_order_export->export_xml($xmlWriter, $entry, XmlExportEngine::$exportOptions, $ID, $preview);
|
315 |
}
|
316 |
else
|
317 |
{
|
318 |
+
XmlExportEngine::$woo_order_export->export_csv($article, $woo_order, $entry, XmlExportEngine::$exportOptions, $ID, $preview);
|
319 |
}
|
320 |
|
321 |
break;
|
353 |
|
354 |
if ( ! empty($fieldValue) )
|
355 |
{
|
356 |
+
|
357 |
+
// get categories from parent product in case when variation exported
|
358 |
+
$entry_id = ( $entry->post_type == 'product_variation' ) ? $entry->post_parent : $entry->ID;
|
359 |
+
|
360 |
+
$txes_list = get_the_terms($entry_id, $fieldValue);
|
361 |
+
|
362 |
+
$hierarchy_groups = array();
|
363 |
+
|
364 |
if ( ! is_wp_error($txes_list) and ! empty($txes_list) )
|
365 |
{
|
366 |
+
$txes_ids = array();
|
|
|
367 |
|
368 |
foreach ($txes_list as $t) {
|
369 |
$txes_ids[] = $t->term_id;
|
370 |
+
}
|
371 |
|
372 |
foreach ($txes_list as $t) {
|
373 |
if ( wp_all_export_check_children_assign($t->term_id, $fieldValue, $txes_ids) ){
|
387 |
$hierarchy_groups[] = $t->name;
|
388 |
}
|
389 |
}
|
390 |
+
}
|
391 |
|
392 |
+
// if ( empty($hierarchy_groups) ) $hierarchy_groups = '';
|
|
|
|
|
|
|
393 |
|
394 |
}
|
395 |
+
|
396 |
+
wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_post_taxonomy', pmxe_filter(implode($implode_delimiter, $hierarchy_groups), $fieldSnipped), $entry->ID) );
|
397 |
|
398 |
// if ( ! in_array($element_name, $taxes)) $taxes[] = $element_name;
|
399 |
|
403 |
|
404 |
$article['parent_id'] = $entry->post_parent;
|
405 |
|
406 |
+
if ( $is_xml_export )
|
407 |
{
|
408 |
$xmlWriter->beginElement($element_name_ns, 'parent_id', null);
|
409 |
$xmlWriter->writeData($article['parent_id'], 'parent_id');
|
410 |
+
$xmlWriter->closeElement();
|
411 |
}
|
412 |
}
|
413 |
}
|
480 |
# code...
|
481 |
break;
|
482 |
}
|
483 |
+
|
484 |
+
if ( $is_xml_export and isset($article[$element_name]) )
|
485 |
{
|
486 |
$element_name_in_file = XmlCsvExport::_get_valid_header_name( $element_name );
|
487 |
|
489 |
|
490 |
$xmlWriter->beginElement($element_name_ns, $element_name_in_file, null);
|
491 |
$xmlWriter->writeData($article[$element_name], $element_name_in_file);
|
492 |
+
$xmlWriter->closeElement();
|
493 |
|
494 |
$xmlWriter = apply_filters('wp_all_export_add_after_element', $xmlWriter, $element_name_in_file, XmlExportEngine::$exportID, $entry->ID);
|
495 |
}
|
505 |
|
506 |
$is_xml_template = $options['export_to'] == 'xml';
|
507 |
|
508 |
+
$implode_delimiter = XmlExportEngine::$implode;
|
509 |
|
510 |
switch ($element_type)
|
511 |
{
|
517 |
break;
|
518 |
case 'title':
|
519 |
case 'content':
|
520 |
+
case 'author':
|
|
|
521 |
case 'slug':
|
522 |
$templateOptions[$element_type] = '{'. $element_name .'[1]}';
|
523 |
$templateOptions['is_update_' . $options['cc_type'][$ID]] = 1;
|
524 |
+
break;
|
525 |
+
case 'parent':
|
526 |
+
$templateOptions['is_multiple_page_parent'] = 'no';
|
527 |
+
$templateOptions['single_page_parent'] = '{' . $element_name . '[1]}';
|
528 |
+
$templateOptions['is_update_' . $options['cc_type'][$ID]] = 1;
|
529 |
break;
|
530 |
case 'excerpt':
|
531 |
$templateOptions['post_excerpt'] = '{'. $element_name .'[1]}';
|
libraries/XmlExportEngine.php
CHANGED
@@ -7,11 +7,23 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
7 |
require_once dirname(__FILE__) . '/XmlExportWooCommerceOrder.php';
|
8 |
require_once dirname(__FILE__) . '/XmlExportUser.php';
|
9 |
require_once dirname(__FILE__) . '/XmlExportComment.php';
|
10 |
-
|
11 |
|
12 |
final class XmlExportEngine
|
13 |
{
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
public static $acf_export;
|
16 |
public static $woo_export;
|
17 |
public static $woo_order_export;
|
@@ -20,7 +32,11 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
20 |
public static $user_export;
|
21 |
public static $comment_export;
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
private $_existing_meta_keys = array();
|
25 |
private $_existing_taxonomies = array();
|
26 |
|
@@ -155,7 +171,7 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
155 |
public static $exportID = false;
|
156 |
public static $exportRecord = false;
|
157 |
|
158 |
-
public static $is_auto_generate_enabled =
|
159 |
|
160 |
public function __construct( $post, & $errors = false ){
|
161 |
|
@@ -313,8 +329,6 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
313 |
|
314 |
self::$is_comment_export = ( in_array('comments', self::$post_types) ) ? true : false;
|
315 |
|
316 |
-
self::$is_auto_generate_enabled = (class_exists('WooCommerce') and in_array(self::$post_types[0], array('product', 'shop_coupon', 'shop_customer')));
|
317 |
-
|
318 |
}
|
319 |
else
|
320 |
{
|
@@ -343,7 +357,7 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
343 |
}
|
344 |
}
|
345 |
|
346 |
-
self::$exportOptions = $post;
|
347 |
|
348 |
if ( ! empty(PMXE_Plugin::$session) and PMXE_Plugin::$session->has_session() )
|
349 |
{
|
@@ -355,7 +369,13 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
355 |
$this->filters = new XmlExportFiltering($filter_args);
|
356 |
|
357 |
$this->init();
|
358 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
|
360 |
self::$acf_export = new XmlExportACF();
|
361 |
self::$woo_export = new XmlExportWooCommerce();
|
@@ -388,88 +408,26 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
388 |
if ('advanced' == $this->post['export_type']) {
|
389 |
|
390 |
if( "" == $this->post['wp_query'] ){
|
391 |
-
$this->errors->add('form-validation', __('WP Query field is required', '
|
392 |
}
|
393 |
else
|
394 |
-
{
|
395 |
$this->filters->parseQuery();
|
396 |
|
397 |
PMXE_Plugin::$session->set('whereclause', $this->filters->get('queryWhere'));
|
398 |
PMXE_Plugin::$session->set('joinclause', $this->filters->get('queryJoin'));
|
399 |
-
PMXE_Plugin::$session->
|
400 |
-
|
401 |
-
if ( self::$is_user_export )
|
402 |
-
{
|
403 |
-
$this->errors->add('form-validation', __('Upgrade to the Pro edition of WP All Export to export users.', 'wp_all_export_plugin'));
|
404 |
-
}
|
405 |
-
elseif ( self::$is_comment_export )
|
406 |
-
{
|
407 |
-
$this->errors->add('form-validation', __('Upgrade to the Pro edition of WP All Export to export comments.', 'wp_all_export_plugin'));
|
408 |
-
}
|
409 |
-
else
|
410 |
-
{
|
411 |
-
remove_all_actions('parse_query');
|
412 |
-
remove_all_actions('pre_get_posts');
|
413 |
-
remove_all_filters('posts_clauses');
|
414 |
-
|
415 |
-
add_filter('posts_where', 'wp_all_export_posts_where', 10, 1);
|
416 |
-
add_filter('posts_join', 'wp_all_export_posts_join', 10, 1);
|
417 |
-
self::$exportQuery = eval('return new WP_Query(array(' . $this->post['wp_query'] . ', \'offset\' => 0, \'posts_per_page\' => 10));');
|
418 |
-
|
419 |
-
if ( empty(self::$exportQuery) ) {
|
420 |
-
$this->errors->add('form-validation', __('Invalid query', 'wp_all_export_plugin'));
|
421 |
-
}
|
422 |
-
elseif ( empty(self::$exportQuery->found_posts) ) {
|
423 |
-
$this->errors->add('count-validation', __('No matching posts found for WP_Query expression specified.', 'wp_all_export_plugin'));
|
424 |
-
PMXE_Plugin::$session->set('found_posts', 0);
|
425 |
-
}
|
426 |
-
else {
|
427 |
-
PMXE_Plugin::$session->set('wp_query', $this->post['wp_query']);
|
428 |
-
PMXE_Plugin::$session->set('found_posts', self::$exportQuery->found_posts);
|
429 |
-
}
|
430 |
-
remove_filter('posts_join', 'wp_all_export_posts_join');
|
431 |
-
remove_filter('posts_where', 'wp_all_export_posts_where');
|
432 |
-
}
|
433 |
-
|
434 |
}
|
435 |
}
|
436 |
else
|
437 |
-
{
|
438 |
$this->filters->parseQuery();
|
439 |
|
440 |
PMXE_Plugin::$session->set('cpt', self::$post_types);
|
441 |
PMXE_Plugin::$session->set('whereclause', $this->filters->get('queryWhere'));
|
442 |
PMXE_Plugin::$session->set('joinclause', $this->filters->get('queryJoin'));
|
443 |
-
PMXE_Plugin::$session->save_data();
|
444 |
-
|
445 |
-
if ( self::$is_user_export )
|
446 |
-
{
|
447 |
-
$this->errors->add('form-validation', __('Upgrade to the Pro edition of WP All Export to export users.', 'pmxe_plugin'));
|
448 |
-
}
|
449 |
-
elseif( self::$is_comment_export )
|
450 |
-
{
|
451 |
-
$this->errors->add('form-validation', __('Upgrade to the Pro edition of WP All Export to export comments.', 'pmxe_plugin'));
|
452 |
-
}
|
453 |
-
else
|
454 |
-
{
|
455 |
-
remove_all_actions('parse_query');
|
456 |
-
remove_all_actions('pre_get_posts');
|
457 |
-
remove_all_filters('posts_clauses');
|
458 |
-
|
459 |
-
add_filter('posts_where', 'wp_all_export_posts_where', 10, 1);
|
460 |
-
add_filter('posts_join', 'wp_all_export_posts_join', 10, 1);
|
461 |
-
self::$exportQuery = new WP_Query( array( 'post_type' => self::$post_types, 'post_status' => 'any', 'orderby' => 'ID', 'order' => 'ASC', 'posts_per_page' => 10 ));
|
462 |
-
|
463 |
-
if (empty(self::$exportQuery->found_posts)){
|
464 |
-
$this->errors->add('count-validation', __('No matching posts found for selected post types.', 'wp_all_export_plugin'));
|
465 |
-
PMXE_Plugin::$session->set('found_posts', 0);
|
466 |
-
}
|
467 |
-
else{
|
468 |
-
PMXE_Plugin::$session->set('found_posts', self::$exportQuery->found_posts);
|
469 |
-
}
|
470 |
-
remove_filter('posts_join', 'wp_all_export_posts_join');
|
471 |
-
remove_filter('posts_where', 'wp_all_export_posts_where');
|
472 |
-
}
|
473 |
}
|
474 |
|
475 |
PMXE_Plugin::$session->save_data();
|
@@ -512,10 +470,10 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
512 |
|
513 |
if (strpos($obj->name, "pa_") !== 0 and strlen($obj->name) > 3)
|
514 |
$this->_existing_taxonomies[] = array(
|
515 |
-
'name' => $obj->label,
|
516 |
'label' => $obj->name,
|
517 |
'type' => 'cats'
|
518 |
-
);
|
519 |
}
|
520 |
}
|
521 |
|
@@ -557,6 +515,89 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
557 |
|
558 |
}
|
559 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
560 |
public function render(){
|
561 |
|
562 |
$i = 0;
|
@@ -577,8 +618,7 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
577 |
<ul>
|
578 |
<?php if ( ! empty($this->available_data[$section['content']]) ): ?>
|
579 |
<li>
|
580 |
-
<div class="default_column" rel="">
|
581 |
-
<a href="javascript:void(0);" class="pmxe_remove_column">X</a>
|
582 |
<label class="wpallexport-element-label"><?php echo __("All", "wp_all_export_plugin") . ' ' . $section['title']; ?></label>
|
583 |
<input type="hidden" name="rules[]" value="pmxe_<?php echo $slug; ?>"/>
|
584 |
</div>
|
@@ -591,7 +631,7 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
591 |
|
592 |
if ( $field_type == 'cf' && $field_name == '_thumbnail_id' ) continue;
|
593 |
|
594 |
-
$is_auto_field = ( ! empty($field['auto']) or self::$is_auto_generate_enabled and 'specific' == $this->post['export_type'] and ! in_array(self::$post_types[0], array('product')));
|
595 |
|
596 |
?>
|
597 |
<li class="pmxe_<?php echo $slug; ?> <?php if ( $is_auto_field ) echo 'wp_all_export_auto_generate';?>">
|
@@ -607,7 +647,7 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
607 |
<input type="hidden" name="cc_value[]" value="<?php echo (is_array($field)) ? $field['label'] : $field; ?>"/>
|
608 |
<input type="hidden" name="cc_name[]" value="<?php echo (is_array($field)) ? $field['name'] : $field;?>"/>
|
609 |
<input type="hidden" name="cc_settings[]" value="0"/>
|
610 |
-
</div>
|
611 |
</li>
|
612 |
<?php
|
613 |
$i++;
|
@@ -631,9 +671,10 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
631 |
</li>
|
632 |
<?php
|
633 |
foreach ($sub_section['meta'] as $field) {
|
|
|
634 |
$field_options = ( in_array($sub_slug, array('images', 'attachments')) ) ? esc_attr('{"is_export_featured":true,"is_export_attached":true,"image_separator":"|"}') : '0';
|
635 |
?>
|
636 |
-
<li class="pmxe_<?php echo $slug; ?>_<?php echo $sub_slug;?>">
|
637 |
<div class="custom_column" rel="<?php echo ($i + 1);?>">
|
638 |
<label class="wpallexport-xml-element"><?php echo (is_array($field)) ? $field['name'] : $field; ?></label>
|
639 |
<input type="hidden" name="ids[]" value="1"/>
|
@@ -686,12 +727,12 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
686 |
|
687 |
foreach ($available_sections as $slug => $section)
|
688 |
{
|
689 |
-
if ( ! empty($this->available_data[$section['content']]) or ! empty($section['fields'])):
|
690 |
?>
|
691 |
|
692 |
<optgroup label="<?php echo $section['title']; ?>">
|
693 |
|
694 |
-
<?php if ( ! empty($this->available_data[$section['content']]) ): ?>
|
695 |
|
696 |
<?php foreach ($this->available_data[$section['content']] as $field) : ?>
|
697 |
|
@@ -873,7 +914,9 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
873 |
$field_label = is_array($field) ? $field['label'] : $field;
|
874 |
$field_type = is_array($field) ? $field['type'] : $slug;
|
875 |
$field_name = is_array($field) ? $field['name'] : $field;
|
876 |
-
$field_options = empty($field['options']) ? '' : $field['options'];
|
|
|
|
|
877 |
?>
|
878 |
<option
|
879 |
value="<?php echo $field_type;?>"
|
@@ -901,7 +944,7 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
901 |
$field_label = is_array($field) ? $field['label'] : $field;
|
902 |
$field_type = is_array($field) ? $field['type'] : $slug;
|
903 |
$field_name = is_array($field) ? $field['name'] : $field;
|
904 |
-
$field_options =
|
905 |
?>
|
906 |
<option
|
907 |
value="<?php echo $field_type;?>"
|
@@ -934,6 +977,83 @@ if ( ! class_exists('XmlExportEngine') ){
|
|
934 |
return ob_get_clean();
|
935 |
|
936 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
937 |
/**
|
938 |
* __get function.
|
939 |
*
|
7 |
require_once dirname(__FILE__) . '/XmlExportWooCommerceOrder.php';
|
8 |
require_once dirname(__FILE__) . '/XmlExportUser.php';
|
9 |
require_once dirname(__FILE__) . '/XmlExportComment.php';
|
10 |
+
require_once dirname(__FILE__) . '/XmlExportFiltering.php';
|
11 |
|
12 |
final class XmlExportEngine
|
13 |
{
|
14 |
|
15 |
+
/**
|
16 |
+
* Custom XML Loop begin statement
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
+
const XML_LOOP_START = '<!-- BEGIN LOOP -->';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Custom XML Loop end statement
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
const XML_LOOP_END = '<!-- END LOOP -->';
|
26 |
+
|
27 |
public static $acf_export;
|
28 |
public static $woo_export;
|
29 |
public static $woo_order_export;
|
32 |
public static $user_export;
|
33 |
public static $comment_export;
|
34 |
|
35 |
+
public static $is_preview = false;
|
36 |
+
|
37 |
+
public static $implode = ',';
|
38 |
+
|
39 |
+
private $post;
|
40 |
private $_existing_meta_keys = array();
|
41 |
private $_existing_taxonomies = array();
|
42 |
|
171 |
public static $exportID = false;
|
172 |
public static $exportRecord = false;
|
173 |
|
174 |
+
public static $is_auto_generate_enabled = true;
|
175 |
|
176 |
public function __construct( $post, & $errors = false ){
|
177 |
|
329 |
|
330 |
self::$is_comment_export = ( in_array('comments', self::$post_types) ) ? true : false;
|
331 |
|
|
|
|
|
332 |
}
|
333 |
else
|
334 |
{
|
357 |
}
|
358 |
}
|
359 |
|
360 |
+
self::$exportOptions = $post;
|
361 |
|
362 |
if ( ! empty(PMXE_Plugin::$session) and PMXE_Plugin::$session->has_session() )
|
363 |
{
|
369 |
$this->filters = new XmlExportFiltering($filter_args);
|
370 |
|
371 |
$this->init();
|
372 |
+
}
|
373 |
+
|
374 |
+
self::$implode = (self::$exportOptions['delimiter'] == ',') ? '|' : ',';
|
375 |
+
|
376 |
+
self::$implode = apply_filters('wp_all_export_implode_delimiter', self::$implode, self::$exportID);
|
377 |
+
|
378 |
+
if ( !empty(self::$exportOptions['xml_template_type']) && in_array(self::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ) self::$implode = '#delimiter#';
|
379 |
|
380 |
self::$acf_export = new XmlExportACF();
|
381 |
self::$woo_export = new XmlExportWooCommerce();
|
408 |
if ('advanced' == $this->post['export_type']) {
|
409 |
|
410 |
if( "" == $this->post['wp_query'] ){
|
411 |
+
$this->errors->add('form-validation', __('WP Query field is required', 'pmxe_plugin'));
|
412 |
}
|
413 |
else
|
414 |
+
{
|
415 |
$this->filters->parseQuery();
|
416 |
|
417 |
PMXE_Plugin::$session->set('whereclause', $this->filters->get('queryWhere'));
|
418 |
PMXE_Plugin::$session->set('joinclause', $this->filters->get('queryJoin'));
|
419 |
+
PMXE_Plugin::$session->set('wp_query', $this->post['wp_query']);
|
420 |
+
PMXE_Plugin::$session->save_data();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
421 |
}
|
422 |
}
|
423 |
else
|
424 |
+
{
|
425 |
$this->filters->parseQuery();
|
426 |
|
427 |
PMXE_Plugin::$session->set('cpt', self::$post_types);
|
428 |
PMXE_Plugin::$session->set('whereclause', $this->filters->get('queryWhere'));
|
429 |
PMXE_Plugin::$session->set('joinclause', $this->filters->get('queryJoin'));
|
430 |
+
PMXE_Plugin::$session->save_data();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
}
|
432 |
|
433 |
PMXE_Plugin::$session->save_data();
|
470 |
|
471 |
if (strpos($obj->name, "pa_") !== 0 and strlen($obj->name) > 3)
|
472 |
$this->_existing_taxonomies[] = array(
|
473 |
+
'name' => empty($obj->label) ? $obj->name : $obj->label,
|
474 |
'label' => $obj->name,
|
475 |
'type' => 'cats'
|
476 |
+
);
|
477 |
}
|
478 |
}
|
479 |
|
515 |
|
516 |
}
|
517 |
|
518 |
+
public function get_fields_options( $field_keys = array() ){
|
519 |
+
|
520 |
+
$fields = array(
|
521 |
+
'ids' => array(),
|
522 |
+
'cc_label' => array(),
|
523 |
+
'cc_php' => array(),
|
524 |
+
'cc_code' => array(),
|
525 |
+
'cc_sql' => array(),
|
526 |
+
'cc_options' => array(),
|
527 |
+
'cc_type' => array(),
|
528 |
+
'cc_value' => array(),
|
529 |
+
'cc_name' => array(),
|
530 |
+
'cc_settings' => array()
|
531 |
+
);
|
532 |
+
|
533 |
+
self::$woo_order_export->get_fields_options( $fields, $field_keys );
|
534 |
+
|
535 |
+
$available_sections = apply_filters("wp_all_export_available_sections", $this->available_sections);
|
536 |
+
|
537 |
+
foreach ($available_sections as $slug => $section)
|
538 |
+
{
|
539 |
+
if ( ! empty($this->available_data[$section['content']]) ):
|
540 |
+
|
541 |
+
foreach ($this->available_data[$section['content']] as $field)
|
542 |
+
{
|
543 |
+
|
544 |
+
$field_key = (is_array($field)) ? $field['name'] : $field;
|
545 |
+
|
546 |
+
if ( ! in_array($field_key, $field_keys) ) continue;
|
547 |
+
|
548 |
+
$fields['ids'][] = 1;
|
549 |
+
$fields['cc_label'][] = (is_array($field)) ? $field['label'] : $field;
|
550 |
+
$fields['cc_php'][] = '';
|
551 |
+
$fields['cc_code'][] = '';
|
552 |
+
$fields['cc_sql'][] = '';
|
553 |
+
$fields['cc_options'][] = '';
|
554 |
+
$fields['cc_type'][] = (is_array($field)) ? $field['type'] : $slug;
|
555 |
+
$fields['cc_value'][] = (is_array($field)) ? $field['label'] : $field;
|
556 |
+
$fields['cc_name'][] = $field_key;
|
557 |
+
$fields['cc_settings'][] = '';
|
558 |
+
}
|
559 |
+
endif;
|
560 |
+
|
561 |
+
if ( ! empty($section['additional']) )
|
562 |
+
{
|
563 |
+
foreach ($section['additional'] as $sub_slug => $sub_section)
|
564 |
+
{
|
565 |
+
|
566 |
+
foreach ($sub_section['meta'] as $field) {
|
567 |
+
$key_to_check = (is_array($field)) ? $field['name'] : $field;
|
568 |
+
|
569 |
+
if ( in_array($sub_slug, array('images', 'attachments')) ){
|
570 |
+
$key_to_check = preg_replace("%s$%","",ucfirst($sub_slug)) . ' ' . $key_to_check;
|
571 |
+
}
|
572 |
+
|
573 |
+
if ( ! in_array($key_to_check, $field_keys) ) continue;
|
574 |
+
|
575 |
+
$field_options = ( in_array($sub_slug, array('images', 'attachments')) ) ? esc_attr('{"is_export_featured":true,"is_export_attached":true,"image_separator":"|"}') : '0';
|
576 |
+
|
577 |
+
$fields['ids'][] = 1;
|
578 |
+
$fields['cc_label'][] = (is_array($field)) ? $field['label'] : $field;
|
579 |
+
$fields['cc_php'][] = '';
|
580 |
+
$fields['cc_code'][] = '';
|
581 |
+
$fields['cc_sql'][] = '';
|
582 |
+
$fields['cc_options'][] = $field_options;
|
583 |
+
$fields['cc_type'][] = (is_array($field)) ? $field['type'] : $sub_slug;
|
584 |
+
$fields['cc_value'][] = (is_array($field)) ? $field['label'] : $field;
|
585 |
+
$fields['cc_name'][] = $key_to_check;
|
586 |
+
$fields['cc_settings'][] = '';
|
587 |
+
}
|
588 |
+
}
|
589 |
+
}
|
590 |
+
}
|
591 |
+
|
592 |
+
if ( ! self::$is_comment_export )
|
593 |
+
{
|
594 |
+
self::$acf_export->get_fields_options( $fields, $field_keys );
|
595 |
+
}
|
596 |
+
|
597 |
+
return $fields;
|
598 |
+
|
599 |
+
}
|
600 |
+
|
601 |
public function render(){
|
602 |
|
603 |
$i = 0;
|
618 |
<ul>
|
619 |
<?php if ( ! empty($this->available_data[$section['content']]) ): ?>
|
620 |
<li>
|
621 |
+
<div class="default_column" rel="">
|
|
|
622 |
<label class="wpallexport-element-label"><?php echo __("All", "wp_all_export_plugin") . ' ' . $section['title']; ?></label>
|
623 |
<input type="hidden" name="rules[]" value="pmxe_<?php echo $slug; ?>"/>
|
624 |
</div>
|
631 |
|
632 |
if ( $field_type == 'cf' && $field_name == '_thumbnail_id' ) continue;
|
633 |
|
634 |
+
$is_auto_field = ( ! empty($field['auto']) or self::$is_auto_generate_enabled and ('specific' != $this->post['export_type'] or 'specific' == $this->post['export_type'] and ! in_array(self::$post_types[0], array('product'))));
|
635 |
|
636 |
?>
|
637 |
<li class="pmxe_<?php echo $slug; ?> <?php if ( $is_auto_field ) echo 'wp_all_export_auto_generate';?>">
|
647 |
<input type="hidden" name="cc_value[]" value="<?php echo (is_array($field)) ? $field['label'] : $field; ?>"/>
|
648 |
<input type="hidden" name="cc_name[]" value="<?php echo (is_array($field)) ? $field['name'] : $field;?>"/>
|
649 |
<input type="hidden" name="cc_settings[]" value="0"/>
|
650 |
+
</div>
|
651 |
</li>
|
652 |
<?php
|
653 |
$i++;
|
671 |
</li>
|
672 |
<?php
|
673 |
foreach ($sub_section['meta'] as $field) {
|
674 |
+
$is_auto_field = empty($field['auto']) ? false : true;
|
675 |
$field_options = ( in_array($sub_slug, array('images', 'attachments')) ) ? esc_attr('{"is_export_featured":true,"is_export_attached":true,"image_separator":"|"}') : '0';
|
676 |
?>
|
677 |
+
<li class="pmxe_<?php echo $slug; ?>_<?php echo $sub_slug;?> <?php if ( $is_auto_field ) echo 'wp_all_export_auto_generate';?>">
|
678 |
<div class="custom_column" rel="<?php echo ($i + 1);?>">
|
679 |
<label class="wpallexport-xml-element"><?php echo (is_array($field)) ? $field['name'] : $field; ?></label>
|
680 |
<input type="hidden" name="ids[]" value="1"/>
|
727 |
|
728 |
foreach ($available_sections as $slug => $section)
|
729 |
{
|
730 |
+
if ( ! empty($section['content']) and ! empty($this->available_data[$section['content']]) or ! empty($section['fields'])):
|
731 |
?>
|
732 |
|
733 |
<optgroup label="<?php echo $section['title']; ?>">
|
734 |
|
735 |
+
<?php if ( ! empty($section['content']) && ! empty($this->available_data[$section['content']]) ): ?>
|
736 |
|
737 |
<?php foreach ($this->available_data[$section['content']] as $field) : ?>
|
738 |
|
914 |
$field_label = is_array($field) ? $field['label'] : $field;
|
915 |
$field_type = is_array($field) ? $field['type'] : $slug;
|
916 |
$field_name = is_array($field) ? $field['name'] : $field;
|
917 |
+
$field_options = empty ($field['options']) ? '' : $field['options'];
|
918 |
+
|
919 |
+
if ( $field_type == 'cf' && $field_name == '_thumbnail_id' ) continue;
|
920 |
?>
|
921 |
<option
|
922 |
value="<?php echo $field_type;?>"
|
944 |
$field_label = is_array($field) ? $field['label'] : $field;
|
945 |
$field_type = is_array($field) ? $field['type'] : $slug;
|
946 |
$field_name = is_array($field) ? $field['name'] : $field;
|
947 |
+
$field_options = empty($field['options']) ? '{"is_export_featured":true,"is_export_attached":true,"image_separator":"|"}' : $field['options'];
|
948 |
?>
|
949 |
<option
|
950 |
value="<?php echo $field_type;?>"
|
977 |
return ob_get_clean();
|
978 |
|
979 |
}
|
980 |
+
|
981 |
+
public function parse_custom_xml_template(){
|
982 |
+
|
983 |
+
preg_match("%". self::XML_LOOP_START ."(.*)". self::XML_LOOP_END ."%", $this->post['custom_xml_template'], $matches);
|
984 |
+
$parts = explode(self::XML_LOOP_START, $this->post['custom_xml_template']);
|
985 |
+
$loopContent = $parts[1];
|
986 |
+
$parts = explode(self::XML_LOOP_END, $loopContent);
|
987 |
+
$loopContent = $parts[0];
|
988 |
+
$line_numbers = substr_count($loopContent, "\n") +1;
|
989 |
+
|
990 |
+
$result['original_post_loop'] = $loopContent;
|
991 |
+
$result['line_numbers'] = $line_numbers;
|
992 |
+
|
993 |
+
$custom_xml_template = str_replace("\n", "", $this->post['custom_xml_template']);
|
994 |
+
|
995 |
+
// retrieve XML header
|
996 |
+
preg_match("%(.*)". self::XML_LOOP_START ."%", $custom_xml_template, $matches);
|
997 |
+
$result['custom_xml_template_header'] = empty($matches[1]) ? '' : rtrim($matches[1]);
|
998 |
+
// retrieve XML POST LOOP
|
999 |
+
preg_match("%". self::XML_LOOP_START ."(.*)". self::XML_LOOP_END ."%", $custom_xml_template, $matches);
|
1000 |
+
$result['custom_xml_template_loop'] = empty($matches[1]) ? '' : rtrim($matches[1]);
|
1001 |
+
// retrieve XML footer
|
1002 |
+
preg_match("%". self::XML_LOOP_END ."(.*)%", $custom_xml_template, $matches);
|
1003 |
+
$result['custom_xml_template_footer'] = empty($matches[1]) ? '' : $matches[1];
|
1004 |
+
|
1005 |
+
// Validate Custom XML Template header
|
1006 |
+
if ( empty($result['custom_xml_template_header']) )
|
1007 |
+
{
|
1008 |
+
$this->errors->add('form-validation', __('Missing custom XML template header.', 'wp_all_export_plugin'));
|
1009 |
+
}
|
1010 |
+
// Validate Custom XML Template post LOOP
|
1011 |
+
if ( empty($result['custom_xml_template_loop']) )
|
1012 |
+
{
|
1013 |
+
$this->errors->add('form-validation', __('Missing custom XML template post loop.', 'wp_all_export_plugin'));
|
1014 |
+
}
|
1015 |
+
// Validate Custom XML Template footer
|
1016 |
+
if ( empty($result['custom_xml_template_footer']) )
|
1017 |
+
{
|
1018 |
+
$this->errors->add('form-validation', __('Missing custom XML template footer.', 'wp_all_export_plugin'));
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
if ( ! $this->errors->get_error_codes()) {
|
1022 |
+
|
1023 |
+
// retrieve all placeholders in the XML loop
|
1024 |
+
preg_match_all("%(\[[^\]\[]*\])%", $result['custom_xml_template_loop'], $matches);
|
1025 |
+
$loop_placeholders = empty($matches) ? array() : $matches[0];
|
1026 |
+
|
1027 |
+
$field_keys = array();
|
1028 |
+
// looking for placeholders e.q. {Post Type}, {Title}
|
1029 |
+
if ( ! empty($loop_placeholders) ){
|
1030 |
+
|
1031 |
+
foreach ($loop_placeholders as $snippet) {
|
1032 |
+
preg_match("%\{(.*)\}%", $snippet, $matches);
|
1033 |
+
if ( ! empty($matches[1]) ) $field_keys[] = $matches[1];
|
1034 |
+
}
|
1035 |
+
}
|
1036 |
+
|
1037 |
+
preg_match_all("%(\{[^\}\{]*\})%", $result['custom_xml_template_loop'], $matches);
|
1038 |
+
$loop_placeholders = empty($matches) ? array() : $matches[0];
|
1039 |
+
|
1040 |
+
$field_keys = array();
|
1041 |
+
// looking for placeholders e.q. {Post Type}, {Title}
|
1042 |
+
if ( ! empty($loop_placeholders) ){
|
1043 |
+
|
1044 |
+
foreach ($loop_placeholders as $snippet) {
|
1045 |
+
preg_match("%\{(.*)\}%", $snippet, $matches);
|
1046 |
+
if ( ! empty($matches[1]) and ! in_array($matches[1], $field_keys)) $field_keys[] = $matches[1];
|
1047 |
+
}
|
1048 |
+
}
|
1049 |
+
|
1050 |
+
if ( ! empty($field_keys)){
|
1051 |
+
$result['custom_xml_template_options'] = $this->get_fields_options( $field_keys );
|
1052 |
+
}
|
1053 |
+
}
|
1054 |
+
return $result;
|
1055 |
+
}
|
1056 |
+
|
1057 |
/**
|
1058 |
* __get function.
|
1059 |
*
|
libraries/XmlExportMediaGallery.php
CHANGED
@@ -230,7 +230,7 @@ final class XmlExportMediaGallery
|
|
230 |
|
231 |
$is_xml_template = $options['export_to'] == 'xml';
|
232 |
|
233 |
-
$implode_delimiter =
|
234 |
|
235 |
$element_type = $options['cc_type'][$ID];
|
236 |
|
230 |
|
231 |
$is_xml_template = $options['export_to'] == 'xml';
|
232 |
|
233 |
+
$implode_delimiter = XmlExportEngine::$implode;
|
234 |
|
235 |
$element_type = $options['cc_type'][$ID];
|
236 |
|
libraries/XmlExportUser.php
CHANGED
@@ -80,89 +80,31 @@ if ( ! class_exists('XmlExportUser') ){
|
|
80 |
)
|
81 |
);
|
82 |
|
83 |
-
private $advanced_fields = array(
|
84 |
-
array(
|
85 |
-
'label' => 'rich_editing',
|
86 |
-
'name' => 'rich_editing',
|
87 |
-
'type' => 'cf'
|
88 |
-
),
|
89 |
-
array(
|
90 |
-
'label' => 'comment_shortcuts',
|
91 |
-
'name' => 'comment_shortcuts',
|
92 |
-
'type' => 'cf'
|
93 |
-
),
|
94 |
-
array(
|
95 |
-
'label' => 'admin_color',
|
96 |
-
'name' => 'admin_color',
|
97 |
-
'type' => 'cf'
|
98 |
-
),
|
99 |
-
array(
|
100 |
-
'label' => 'use_ssl',
|
101 |
-
'name' => 'use_ssl',
|
102 |
-
'type' => 'cf'
|
103 |
-
),
|
104 |
-
array(
|
105 |
-
'label' => 'show_admin_bar_front',
|
106 |
-
'name' => 'show_admin_bar_front',
|
107 |
-
'type' => 'cf'
|
108 |
-
),
|
109 |
array(
|
110 |
'label' => 'wp_capabilities',
|
111 |
-
'name' => '
|
112 |
'type' => 'wp_capabilities'
|
113 |
-
),
|
114 |
-
array(
|
115 |
-
'label' => 'wp_user_level',
|
116 |
-
'name' => 'wp_user_level',
|
117 |
-
'type' => 'cf'
|
118 |
-
),
|
119 |
-
array(
|
120 |
-
'label' => 'show_welcome_panel',
|
121 |
-
'name' => 'show_welcome_panel',
|
122 |
-
'type' => 'cf'
|
123 |
-
),
|
124 |
array(
|
125 |
'label' => 'user_pass',
|
126 |
-
'name' => '
|
127 |
'type' => 'user_pass'
|
128 |
-
),
|
129 |
-
array(
|
130 |
-
'label' => 'dismissed_wp_pointers',
|
131 |
-
'name' => 'dismissed_wp_pointers',
|
132 |
-
'type' => 'cf'
|
133 |
-
),
|
134 |
-
array(
|
135 |
-
'label' => 'session_tokens',
|
136 |
-
'name' => 'session_tokens',
|
137 |
-
'type' => 'cf'
|
138 |
-
),
|
139 |
-
array(
|
140 |
-
'label' => 'wp_user-settings',
|
141 |
-
'name' => 'wp_user-settings',
|
142 |
-
'type' => 'cf'
|
143 |
-
),
|
144 |
-
array(
|
145 |
-
'label' => 'wp_user-settings-time',
|
146 |
-
'name' => 'wp_user-settings-time',
|
147 |
-
'type' => 'cf'
|
148 |
-
),
|
149 |
-
array(
|
150 |
-
'label' => 'wp_dashboard_quick_press_last_post_id',
|
151 |
-
'name' => 'wp_dashboard_quick_press_last_post_id',
|
152 |
-
'type' => 'cf'
|
153 |
-
),
|
154 |
array(
|
155 |
'label' => 'user_activation_key',
|
156 |
-
'name' => '
|
157 |
'type' => 'user_activation_key'
|
158 |
),
|
159 |
array(
|
160 |
'label' => 'user_status',
|
161 |
-
'name' => '
|
162 |
'type' => 'user_status'
|
163 |
-
)
|
164 |
);
|
165 |
|
|
|
|
|
166 |
public static $is_active = true;
|
167 |
|
168 |
public static $is_export_shop_customer = false;
|
@@ -170,6 +112,8 @@ if ( ! class_exists('XmlExportUser') ){
|
|
170 |
public function __construct()
|
171 |
{
|
172 |
|
|
|
|
|
173 |
if ( ( XmlExportEngine::$exportOptions['export_type'] == 'specific' and ! in_array('users', XmlExportEngine::$post_types) and ! in_array('shop_customer', XmlExportEngine::$post_types) )
|
174 |
or ( XmlExportEngine::$exportOptions['export_type'] == 'advanced' and XmlExportEngine::$exportOptions['wp_query_selector'] != 'wp_user_query' ) ){
|
175 |
self::$is_active = false;
|
@@ -214,7 +158,22 @@ if ( ! class_exists('XmlExportUser') ){
|
|
214 |
*
|
215 |
*/
|
216 |
public function filter_other_fields($other_fields){
|
217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
}
|
219 |
|
220 |
/**
|
@@ -261,14 +220,14 @@ if ( ! class_exists('XmlExportUser') ){
|
|
261 |
{
|
262 |
$customer_data = array(
|
263 |
'customer' => array(
|
264 |
-
'title' => __("
|
265 |
'content' => 'customer_fields'
|
266 |
)
|
267 |
);
|
268 |
$available_sections = array_merge(array_slice($available_sections, 0, 1), $customer_data, array_slice($available_sections, 1));
|
269 |
}
|
270 |
|
271 |
-
self::$is_export_shop_customer or $available_sections['other']['title'] = __("
|
272 |
|
273 |
return $available_sections;
|
274 |
}
|
@@ -284,15 +243,28 @@ if ( ! class_exists('XmlExportUser') ){
|
|
284 |
global $wpdb;
|
285 |
$table_prefix = $wpdb->prefix;
|
286 |
self::$meta_keys = $wpdb->get_results("SELECT DISTINCT {$table_prefix}usermeta.meta_key FROM {$table_prefix}usermeta, {$table_prefix}users WHERE {$table_prefix}usermeta.user_id = {$table_prefix}users.ID LIMIT 500");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
|
288 |
if ( ! empty(self::$meta_keys)){
|
289 |
|
290 |
$address_fields = $this->available_customer_data();
|
|
|
|
|
|
|
291 |
// detect if at least one filtered user is a WooCommerce customer
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
|
|
|
|
|
|
296 |
}
|
297 |
}
|
298 |
|
@@ -315,6 +287,14 @@ if ( ! class_exists('XmlExportUser') ){
|
|
315 |
}
|
316 |
}
|
317 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
if ( $to_add && ( self::$is_export_shop_customer || self::$is_woo_custom_founded ) )
|
319 |
{
|
320 |
foreach ($address_fields as $address_value) {
|
@@ -427,9 +407,9 @@ if ( ! class_exists('XmlExportUser') ){
|
|
427 |
*/
|
428 |
protected function fix_title($title)
|
429 |
{
|
430 |
-
$uc_title = ucwords(trim(str_replace("_", " ", $title)));
|
431 |
|
432 |
-
return stripos($uc_title, "width") === false ? str_ireplace(array('id', 'url', 'sku'), array('ID', 'URL', 'SKU'), $uc_title) : $uc_title;
|
433 |
}
|
434 |
|
435 |
/**
|
80 |
)
|
81 |
);
|
82 |
|
83 |
+
private $advanced_fields = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
array(
|
85 |
'label' => 'wp_capabilities',
|
86 |
+
'name' => 'User Role',
|
87 |
'type' => 'wp_capabilities'
|
88 |
+
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
array(
|
90 |
'label' => 'user_pass',
|
91 |
+
'name' => 'User Pass',
|
92 |
'type' => 'user_pass'
|
93 |
+
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
array(
|
95 |
'label' => 'user_activation_key',
|
96 |
+
'name' => 'User Activation Key',
|
97 |
'type' => 'user_activation_key'
|
98 |
),
|
99 |
array(
|
100 |
'label' => 'user_status',
|
101 |
+
'name' => 'User Status',
|
102 |
'type' => 'user_status'
|
103 |
+
)
|
104 |
);
|
105 |
|
106 |
+
private $user_core_fields = array();
|
107 |
+
|
108 |
public static $is_active = true;
|
109 |
|
110 |
public static $is_export_shop_customer = false;
|
112 |
public function __construct()
|
113 |
{
|
114 |
|
115 |
+
$this->user_core_fields = array('rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front', 'wp_user_level', 'show_welcome_panel', 'dismissed_wp_pointers', 'session_tokens', 'wp_user-settings', 'wp_user-settings-time', 'wp_dashboard_quick_press_last_post_id', 'metaboxhidden_dashboard', 'closedpostboxes_dashboard', 'wp_nav_menu_recently_edited', 'meta-box-order_dashboard', 'closedpostboxes_product', 'metaboxhidden_product', 'manageedit-shop_ordercolumnshidden', 'aim', 'yim', 'jabber', 'wp_media_library_mode');
|
116 |
+
|
117 |
if ( ( XmlExportEngine::$exportOptions['export_type'] == 'specific' and ! in_array('users', XmlExportEngine::$post_types) and ! in_array('shop_customer', XmlExportEngine::$post_types) )
|
118 |
or ( XmlExportEngine::$exportOptions['export_type'] == 'advanced' and XmlExportEngine::$exportOptions['wp_query_selector'] != 'wp_user_query' ) ){
|
119 |
self::$is_active = false;
|
158 |
*
|
159 |
*/
|
160 |
public function filter_other_fields($other_fields){
|
161 |
+
|
162 |
+
$other_fields = array();
|
163 |
+
|
164 |
+
foreach ( $this->advanced_fields as $key => $field ) {
|
165 |
+
$other_fields[] = $field;
|
166 |
+
}
|
167 |
+
|
168 |
+
foreach ( $this->user_core_fields as $field ) {
|
169 |
+
$other_fields[] = $this->fix_titles(array(
|
170 |
+
'label' => $field,
|
171 |
+
'name' => $field,
|
172 |
+
'type' => 'cf'
|
173 |
+
));
|
174 |
+
}
|
175 |
+
|
176 |
+
return $other_fields;
|
177 |
}
|
178 |
|
179 |
/**
|
220 |
{
|
221 |
$customer_data = array(
|
222 |
'customer' => array(
|
223 |
+
'title' => __("Address", "wp_all_export_plugin"),
|
224 |
'content' => 'customer_fields'
|
225 |
)
|
226 |
);
|
227 |
$available_sections = array_merge(array_slice($available_sections, 0, 1), $customer_data, array_slice($available_sections, 1));
|
228 |
}
|
229 |
|
230 |
+
self::$is_export_shop_customer or $available_sections['other']['title'] = __("Other", "wp_all_export_plugin");
|
231 |
|
232 |
return $available_sections;
|
233 |
}
|
243 |
global $wpdb;
|
244 |
$table_prefix = $wpdb->prefix;
|
245 |
self::$meta_keys = $wpdb->get_results("SELECT DISTINCT {$table_prefix}usermeta.meta_key FROM {$table_prefix}usermeta, {$table_prefix}users WHERE {$table_prefix}usermeta.user_id = {$table_prefix}users.ID LIMIT 500");
|
246 |
+
|
247 |
+
$user_ids = array();
|
248 |
+
if ( ! empty(XmlExportEngine::$exportQuery->results)) {
|
249 |
+
foreach ( XmlExportEngine::$exportQuery->results as $user ) :
|
250 |
+
$user_ids[] = $user->ID;
|
251 |
+
endforeach;
|
252 |
+
}
|
253 |
|
254 |
if ( ! empty(self::$meta_keys)){
|
255 |
|
256 |
$address_fields = $this->available_customer_data();
|
257 |
+
|
258 |
+
$customer_users = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta, $wpdb->users WHERE meta_key = %s AND meta_value != %s ", '_customer_user', '0'));
|
259 |
+
|
260 |
// detect if at least one filtered user is a WooCommerce customer
|
261 |
+
if ( ! empty($customer_users) ) {
|
262 |
+
foreach ($customer_users as $customer_user) {
|
263 |
+
if ( in_array($customer_user->meta_value, $user_ids) )
|
264 |
+
{
|
265 |
+
self::$is_woo_custom_founded = true;
|
266 |
+
break;
|
267 |
+
}
|
268 |
}
|
269 |
}
|
270 |
|
287 |
}
|
288 |
}
|
289 |
}
|
290 |
+
if ( $to_add ){
|
291 |
+
foreach ($this->user_core_fields as $core_field) {
|
292 |
+
if ( $meta_key->meta_key == $core_field ){
|
293 |
+
$to_add = false;
|
294 |
+
break;
|
295 |
+
}
|
296 |
+
}
|
297 |
+
}
|
298 |
if ( $to_add && ( self::$is_export_shop_customer || self::$is_woo_custom_founded ) )
|
299 |
{
|
300 |
foreach ($address_fields as $address_value) {
|
407 |
*/
|
408 |
protected function fix_title($title)
|
409 |
{
|
410 |
+
$uc_title = ucwords(trim(str_replace("-", " ", str_replace("_", " ", $title))));
|
411 |
|
412 |
+
return stripos($uc_title, "width") === false ? str_ireplace(array('id', 'url', 'sku', 'wp', 'ssl'), array('ID', 'URL', 'SKU', 'WP', 'SSL'), $uc_title) : $uc_title;
|
413 |
}
|
414 |
|
415 |
/**
|
libraries/XmlExportWooCommerce.php
CHANGED
@@ -268,7 +268,7 @@ if ( ! class_exists('XmlExportWooCommerce') )
|
|
268 |
else
|
269 |
{
|
270 |
$available_data['existing_taxonomies'][] = array(
|
271 |
-
'name' => ($taxonomy['label'] == 'product_type') ? 'Product Type' : $tx->label,
|
272 |
'label' => $taxonomy['label'],
|
273 |
'type' => 'cats',
|
274 |
'auto' => true
|
@@ -502,7 +502,7 @@ if ( ! class_exists('XmlExportWooCommerce') )
|
|
502 |
|
503 |
if ( ! empty($element_value) )
|
504 |
{
|
505 |
-
$implode_delimiter =
|
506 |
|
507 |
$element_name = ( ! empty($options['cc_name'][$elId]) ) ? $options['cc_name'][$elId] : 'untitled_' . $elId;
|
508 |
$fieldSnipped = ( ! empty($options['cc_php'][$elId]) and ! empty($options['cc_code'][$elId]) ) ? $options['cc_code'][$elId] : false;
|
@@ -590,8 +590,11 @@ if ( ! class_exists('XmlExportWooCommerce') )
|
|
590 |
if ( ! empty($cur_meta_values) and is_array($cur_meta_values) )
|
591 |
{
|
592 |
foreach ($cur_meta_values as $key => $cur_meta_value)
|
593 |
-
{
|
594 |
-
|
|
|
|
|
|
|
595 |
{
|
596 |
case '_downloadable_files':
|
597 |
|
@@ -645,7 +648,42 @@ if ( ! class_exists('XmlExportWooCommerce') )
|
|
645 |
}
|
646 |
$data[$element_name] = apply_filters('pmxe_woo_field', pmxe_filter(implode($implode_delimiter, $_values), $fieldSnipped), $element_value, $record->ID);
|
647 |
break;
|
648 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
649 |
default:
|
650 |
|
651 |
if ( empty($data[$element_name]) )
|
@@ -783,7 +821,7 @@ if ( ! class_exists('XmlExportWooCommerce') )
|
|
783 |
|
784 |
$xmlWriter->beginElement($element_name_ns, $element_name, null);
|
785 |
$xmlWriter->writeData($data, $element_name);
|
786 |
-
$xmlWriter->
|
787 |
|
788 |
$xmlWriter = apply_filters('wp_all_export_add_after_element', $xmlWriter, $element_name, XmlExportEngine::$exportID, $record->ID);
|
789 |
}
|
@@ -796,7 +834,7 @@ if ( ! class_exists('XmlExportWooCommerce') )
|
|
796 |
|
797 |
$is_xml_template = $exportOptions['export_to'] == 'xml';
|
798 |
|
799 |
-
$implode_delimiter =
|
800 |
|
801 |
switch ($element_key)
|
802 |
{
|
268 |
else
|
269 |
{
|
270 |
$available_data['existing_taxonomies'][] = array(
|
271 |
+
'name' => ($taxonomy['label'] == 'product_type') ? 'Product Type' : (empty($tx->label) ? $tx->name : $tx->label),
|
272 |
'label' => $taxonomy['label'],
|
273 |
'type' => 'cats',
|
274 |
'auto' => true
|
502 |
|
503 |
if ( ! empty($element_value) )
|
504 |
{
|
505 |
+
$implode_delimiter = XmlExportEngine::$implode;
|
506 |
|
507 |
$element_name = ( ! empty($options['cc_name'][$elId]) ) ? $options['cc_name'][$elId] : 'untitled_' . $elId;
|
508 |
$fieldSnipped = ( ! empty($options['cc_php'][$elId]) and ! empty($options['cc_code'][$elId]) ) ? $options['cc_code'][$elId] : false;
|
590 |
if ( ! empty($cur_meta_values) and is_array($cur_meta_values) )
|
591 |
{
|
592 |
foreach ($cur_meta_values as $key => $cur_meta_value)
|
593 |
+
{
|
594 |
+
$fieldOptions = $options['cc_options'][$elId];
|
595 |
+
$fieldSettings = empty($options['cc_settings'][$elId]) ? $fieldOptions : $options['cc_settings'][$elId];
|
596 |
+
|
597 |
+
switch ($element_value)
|
598 |
{
|
599 |
case '_downloadable_files':
|
600 |
|
648 |
}
|
649 |
$data[$element_name] = apply_filters('pmxe_woo_field', pmxe_filter(implode($implode_delimiter, $_values), $fieldSnipped), $element_value, $record->ID);
|
650 |
break;
|
651 |
+
|
652 |
+
case '_sale_price_dates_from':
|
653 |
+
case '_sale_price_dates_to':
|
654 |
+
|
655 |
+
if ( ! empty($fieldSettings))
|
656 |
+
{
|
657 |
+
switch ($fieldSettings)
|
658 |
+
{
|
659 |
+
case 'unix':
|
660 |
+
$post_date = $cur_meta_value;
|
661 |
+
break;
|
662 |
+
default:
|
663 |
+
$post_date = date($fieldSettings, $cur_meta_value);
|
664 |
+
break;
|
665 |
+
}
|
666 |
+
}
|
667 |
+
else
|
668 |
+
{
|
669 |
+
$post_date = $cur_meta_value;
|
670 |
+
}
|
671 |
+
$data[$element_name] = apply_filters('pmxe_woo_field', pmxe_filter($post_date, $fieldSnipped), $element_value, $record->ID);
|
672 |
+
|
673 |
+
// wp_all_export_write_article( $article, $element_name, apply_filters('pmxe_post_date', pmxe_filter($post_date, $fieldSnipped), $record->ID) );
|
674 |
+
break;
|
675 |
+
|
676 |
+
case '_tax_class':
|
677 |
+
|
678 |
+
if ( $cur_meta_value == '' ){
|
679 |
+
$tax_status = get_post_meta($record->ID, '_tax_status', true);
|
680 |
+
if ( 'taxable' == $tax_status ){
|
681 |
+
$cur_meta_value = 'standard';
|
682 |
+
}
|
683 |
+
}
|
684 |
+
$data[$element_name] = apply_filters('pmxe_woo_field', pmxe_filter($cur_meta_value, $fieldSnipped), $element_value, $record->ID);
|
685 |
+
break;
|
686 |
+
|
687 |
default:
|
688 |
|
689 |
if ( empty($data[$element_name]) )
|
821 |
|
822 |
$xmlWriter->beginElement($element_name_ns, $element_name, null);
|
823 |
$xmlWriter->writeData($data, $element_name);
|
824 |
+
$xmlWriter->closeElement();
|
825 |
|
826 |
$xmlWriter = apply_filters('wp_all_export_add_after_element', $xmlWriter, $element_name, XmlExportEngine::$exportID, $record->ID);
|
827 |
}
|
834 |
|
835 |
$is_xml_template = $exportOptions['export_to'] == 'xml';
|
836 |
|
837 |
+
$implode_delimiter = XmlExportEngine::$implode;
|
838 |
|
839 |
switch ($element_key)
|
840 |
{
|
libraries/XmlExportWooCommerceOrder.php
CHANGED
@@ -111,7 +111,7 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
111 |
}
|
112 |
}
|
113 |
|
114 |
-
endforeach;
|
115 |
|
116 |
foreach ( $this->order_core_fields as $core_field ):
|
117 |
|
@@ -124,7 +124,7 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
124 |
}
|
125 |
}
|
126 |
|
127 |
-
endforeach;
|
128 |
|
129 |
foreach ($existing_meta_keys as $key => $record_meta_key)
|
130 |
{
|
@@ -198,8 +198,50 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
198 |
|
199 |
public function init_additional_data(){
|
200 |
|
201 |
-
if ( ! self::$is_active ) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
}
|
204 |
|
205 |
private $order_items = null;
|
@@ -207,6 +249,7 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
207 |
private $order_shipping = null;
|
208 |
private $order_coupons = null;
|
209 |
private $order_surcharge = null;
|
|
|
210 |
private $__total_fee_amount = null;
|
211 |
private $__coupons_used = null;
|
212 |
private $order_id = null;
|
@@ -231,9 +274,113 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
231 |
);
|
232 |
|
233 |
global $wpdb;
|
234 |
-
$table_prefix = $wpdb->prefix;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
|
236 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
|
238 |
switch ($options['cc_options'][$elId]) {
|
239 |
|
@@ -245,13 +392,13 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
245 |
if ($options['cc_value'][$elId] == "post_title")
|
246 |
{
|
247 |
$data[$options['cc_name'][$elId]] = str_replace("–", '-', $data[$options['cc_name'][$elId]]);
|
248 |
-
}
|
249 |
|
250 |
$data[$options['cc_name'][$elId]] = pmxe_filter( $data[$options['cc_name'][$elId]], $fieldSnipped);
|
251 |
|
252 |
-
break;
|
|
|
253 |
}
|
254 |
-
|
255 |
}
|
256 |
|
257 |
return $data;
|
@@ -265,26 +412,81 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
265 |
|
266 |
$data_to_export = $this->prepare_export_data( $record, $options, $elId, $preview );
|
267 |
|
|
|
|
|
268 |
foreach ($data_to_export as $key => $data) {
|
269 |
|
270 |
-
if (
|
271 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
// $article[$key] = $data;
|
273 |
wp_all_export_write_article( $article, $key, $data );
|
274 |
-
// if ( ! in_array($key, $titles) ) $titles[] = $key;
|
275 |
-
}
|
276 |
-
}
|
277 |
}
|
278 |
|
279 |
public function filter_csv_rows($articles, $options){
|
280 |
-
|
281 |
-
if ( ! empty($this->additional_articles) and $options['order_item_per_row']
|
282 |
{
|
283 |
$base_article = $articles[count($articles) - 1];
|
284 |
array_shift($this->additional_articles);
|
285 |
if ( ! empty($this->additional_articles ) ){
|
286 |
foreach ($this->additional_articles as $article) {
|
287 |
-
if ($options['order_item_fill_empty_columns'])
|
288 |
{
|
289 |
foreach ($article as $key => $value) {
|
290 |
unset($base_article[$key]);
|
@@ -317,8 +519,10 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
317 |
if ( ! empty(self::$orders_data['taxes']))
|
318 |
{
|
319 |
foreach ( self::$orders_data['taxes'] as $tax) {
|
320 |
-
$friendly_name = str_replace("per tax", $this->get_rate_friendly_name($tax->order_item_id), $options['cc_name'][$element_key]);
|
|
|
321 |
if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
|
|
|
322 |
}
|
323 |
}
|
324 |
|
@@ -329,8 +533,10 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
329 |
if ( ! empty(self::$orders_data['coupons']))
|
330 |
{
|
331 |
foreach ( self::$orders_data['coupons'] as $coupon) {
|
332 |
-
$friendly_name = str_replace("per coupon", $coupon->order_item_name, $options['cc_name'][$element_key]);
|
|
|
333 |
if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
|
|
|
334 |
}
|
335 |
}
|
336 |
|
@@ -341,8 +547,10 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
341 |
if ( ! empty(self::$orders_data['fees']))
|
342 |
{
|
343 |
foreach ( self::$orders_data['fees'] as $fee) {
|
344 |
-
$friendly_name = str_replace("Amount (per surcharge)", "(" . $fee->order_item_name . ")", $options['cc_name'][$element_key]);
|
|
|
345 |
if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
|
|
|
346 |
}
|
347 |
}
|
348 |
|
@@ -353,7 +561,7 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
353 |
|
354 |
if ( ! empty(self::$orders_data['line_items_max_count']) and ! empty(self::$orders_data['variations']))
|
355 |
{
|
356 |
-
if ($options['order_item_per_row']){
|
357 |
foreach ( self::$orders_data['variations'] as $variation) {
|
358 |
$friendly_name = $options['cc_name'][$element_key] . " (" . sanitize_title(str_replace("pa_", "", $variation->meta_key)) . ")";
|
359 |
if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
|
@@ -378,7 +586,7 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
378 |
// Order's product basic data headers
|
379 |
case 'items':
|
380 |
|
381 |
-
if ($options['order_item_per_row'])
|
382 |
{
|
383 |
if ( ! in_array($options['cc_name'][$element_key], $headers)) $headers[] = $options['cc_name'][$element_key];
|
384 |
}
|
@@ -406,8 +614,7 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
406 |
$element_name = ( ! empty($options['cc_name'][$element_key]) ) ? $options['cc_name'][$element_key] : 'untitled_' . $element_key;
|
407 |
|
408 |
switch ($options['cc_type'][$element_key])
|
409 |
-
{
|
410 |
-
|
411 |
case 'woo':
|
412 |
|
413 |
XmlExportEngine::$woo_export->get_element_header( $element_headers, $options, $element_key );
|
@@ -466,7 +673,7 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
466 |
{
|
467 |
foreach ($element_headers as $header)
|
468 |
{
|
469 |
-
if ($options['order_item_per_row'])
|
470 |
{
|
471 |
if ( ! in_array($header, $headers)) $headers[] = $header;
|
472 |
}
|
@@ -544,23 +751,190 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
544 |
|
545 |
foreach ($data_to_export as $key => $data) {
|
546 |
|
547 |
-
$
|
548 |
-
$element_name = str_replace("-", "_", preg_replace('/[^a-z0-9:_]/i', '', $key));
|
549 |
-
if (strpos($element_name, ":") !== false)
|
550 |
{
|
551 |
-
|
552 |
-
|
553 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
554 |
}
|
555 |
-
|
556 |
-
|
557 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
558 |
}
|
559 |
}
|
560 |
|
561 |
public static function prepare_child_exports( $export, $is_cron = false )
|
562 |
{
|
563 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
564 |
}
|
565 |
|
566 |
public function render( & $i ){
|
@@ -574,7 +948,7 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
574 |
<div class="wpae-custom-field">
|
575 |
<?php if ( ! in_array($slug, array('order', 'customer', 'cf', 'other'))) : ?>
|
576 |
<div class="wpallexport-free-edition-notice">
|
577 |
-
<a class="upgrade_link" target="_blank" href="
|
578 |
</div>
|
579 |
<?php endif; ?>
|
580 |
<ul>
|
@@ -666,7 +1040,7 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
666 |
?>
|
667 |
<select class="wp-all-export-chosen-select" name="column_value_type" style="width:350px;">
|
668 |
<?php
|
669 |
-
foreach (self::$order_sections as $slug => $section) :
|
670 |
?>
|
671 |
<optgroup label="<?php echo $section['title']; ?>">
|
672 |
<?php
|
@@ -761,6 +1135,7 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
761 |
case 'items':
|
762 |
case 'taxes':
|
763 |
case 'fees':
|
|
|
764 |
break;
|
765 |
default:
|
766 |
switch ($field_type)
|
@@ -827,6 +1202,17 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
827 |
'comment_author_email' => __('Note User Email', 'wp_all_export_plugin')
|
828 |
)
|
829 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
830 |
'cf' => array(
|
831 |
'title' => __('Custom Fields', 'wp_all_export_plugin'),
|
832 |
'meta' => array()
|
@@ -854,8 +1240,8 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
854 |
'post_title' => __('Title', 'wp_all_export_plugin'),
|
855 |
'post_status' => __('Order Status', 'wp_all_export_plugin'),
|
856 |
'_order_currency' => __('Order Currency', 'wp_all_export_plugin'),
|
857 |
-
'_payment_method_title' => __('Payment Method', 'wp_all_export_plugin'),
|
858 |
-
'_order_total' => __('Order Total', 'wp_all_export_plugin')
|
859 |
);
|
860 |
|
861 |
return apply_filters('wp_all_export_available_order_data_filter', $data);
|
@@ -874,7 +1260,10 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
874 |
'__product_variation' => __('Product Variation Details', 'wp_all_export_plugin'),
|
875 |
'_qty' => __('Quantity', 'wp_all_export_plugin'),
|
876 |
'_line_subtotal' => __('Item Cost', 'wp_all_export_plugin'),
|
877 |
-
'_line_total' => __('Item Total', 'wp_all_export_plugin')
|
|
|
|
|
|
|
878 |
);
|
879 |
|
880 |
return apply_filters('wp_all_export_available_order_default_product_data_filter', $data);
|
@@ -990,7 +1379,7 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
990 |
|
991 |
$is_xml_template = $options['export_to'] == 'xml';
|
992 |
|
993 |
-
|
994 |
|
995 |
switch ($element_type)
|
996 |
{
|
@@ -999,6 +1388,11 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
999 |
$templateOptions['tmp_unique_key'] = '{'. $element_name .'[1]}';
|
1000 |
break;
|
1001 |
|
|
|
|
|
|
|
|
|
|
|
1002 |
case 'post_status':
|
1003 |
$templateOptions['is_update_status'] = 1;
|
1004 |
$templateOptions['pmwi_order']['status'] = 'xpath';
|
@@ -1040,13 +1434,36 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
1040 |
$templateOptions['pmwi_order']['products_repeater_mode_foreach'] = '{OrderItems[1]/Item}';
|
1041 |
$templateOptions['pmwi_order']['products'][0]['sku'] = '{'. $element_name .'[1]}';
|
1042 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1043 |
break;
|
1044 |
|
1045 |
case '_qty':
|
|
|
1046 |
if ($is_xml_template)
|
1047 |
{
|
1048 |
$templateOptions['pmwi_order']['products'][0]['qty'] = '{'. $element_name .'[1]}';
|
1049 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1050 |
break;
|
1051 |
|
1052 |
// prepare template for fee line items
|
@@ -1056,8 +1473,14 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
1056 |
if ($is_xml_template)
|
1057 |
{
|
1058 |
$templateOptions['pmwi_order']['fees_repeater_mode_foreach'] = '{OrderSurcharge[1]/Surcharge}';
|
1059 |
-
$templateOptions['pmwi_order']['fees'][0]['name'] = '{
|
1060 |
-
$templateOptions['pmwi_order']['fees'][0]['amount'] = '{
|
|
|
|
|
|
|
|
|
|
|
|
|
1061 |
}
|
1062 |
break;
|
1063 |
|
@@ -1065,28 +1488,39 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
1065 |
case 'discount_amount':
|
1066 |
$templateOptions['pmwi_order']['is_update_coupons'] = 1;
|
1067 |
$templateOptions['pmwi_order']['coupons_repeater_mode'] = $options['export_to'];
|
|
|
1068 |
if ($is_xml_template)
|
1069 |
{
|
1070 |
$templateOptions['pmwi_order']['coupons_repeater_mode_foreach'] = '{OrderCoupons[1]/Coupon}';
|
1071 |
-
$templateOptions['pmwi_order']['coupons'][0]['code'] = '{
|
1072 |
-
$templateOptions['pmwi_order']['coupons'][0]['amount'] = '{
|
1073 |
-
$templateOptions['pmwi_order']['coupons'][0]['amount_tax'] = '';
|
1074 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1075 |
break;
|
1076 |
|
1077 |
// prepare template for shipping line items
|
1078 |
case 'shipping_order_item_name':
|
1079 |
$templateOptions['pmwi_order']['is_update_shipping'] = 1;
|
1080 |
$templateOptions['pmwi_order']['shipping_repeater_mode'] = $options['export_to'];
|
|
|
|
|
|
|
|
|
1081 |
if ($is_xml_template)
|
1082 |
{
|
1083 |
-
$templateOptions['pmwi_order']['shipping_repeater_mode_foreach'] = '{OrderShipping[1]/Shipping}';
|
1084 |
-
$templateOptions['pmwi_order']['shipping'][0]['name'] = '{'. $element_name.'[1]}';
|
1085 |
-
$templateOptions['pmwi_order']['shipping'][0]['class'] = 'xpath';
|
1086 |
-
$templateOptions['pmwi_order']['shipping'][0]['class_xpath'] = '{'. $element_name .'}';
|
1087 |
}
|
|
|
|
|
|
|
|
|
1088 |
break;
|
1089 |
-
|
1090 |
case '_order_shipping':
|
1091 |
$templateOptions['pmwi_order']['shipping'][0]['amount'] = '{'. $element_name .'[1]}';
|
1092 |
break;
|
@@ -1095,47 +1529,79 @@ if ( ! class_exists('XmlExportWooCommerceOrder') )
|
|
1095 |
case 'tax_order_item_name':
|
1096 |
$templateOptions['pmwi_order']['is_update_taxes'] = 1;
|
1097 |
$templateOptions['pmwi_order']['taxes_repeater_mode'] = $options['export_to'];
|
|
|
|
|
|
|
|
|
1098 |
if ($is_xml_template)
|
1099 |
{
|
1100 |
-
$templateOptions['pmwi_order']['taxes_repeater_mode_foreach'] = '{OrderTaxes[1]/Tax}';
|
1101 |
-
$templateOptions['pmwi_order']['taxes'][0]['shipping_tax_amount'] = '';
|
1102 |
-
$templateOptions['pmwi_order']['taxes'][0]['code'] = 'xpath';
|
1103 |
-
$templateOptions['pmwi_order']['taxes'][0]['code_xpath'] = '{'. $element_name .'[1]}';
|
1104 |
}
|
1105 |
-
|
1106 |
-
|
|
|
|
|
1107 |
break;
|
1108 |
|
1109 |
case 'tax_rate':
|
1110 |
-
|
|
|
1111 |
break;
|
1112 |
|
1113 |
case 'tax_amount':
|
1114 |
-
$templateOptions['pmwi_order']['taxes'][0]['tax_amount'] = '{'. $element_name.'[1]}';
|
1115 |
break;
|
1116 |
|
1117 |
// order notes
|
1118 |
-
case 'comment_content':
|
|
|
1119 |
$templateOptions['pmwi_order']['is_update_notes'] = 1;
|
1120 |
-
$templateOptions['pmwi_order']['
|
|
|
|
|
1121 |
break;
|
1122 |
-
|
1123 |
-
case 'comment_date':
|
1124 |
-
$templateOptions['pmwi_order']['order_note_date'] = '{'. $element_name .'[1]}';
|
1125 |
-
break;
|
1126 |
-
|
1127 |
case 'visibility':
|
1128 |
-
$templateOptions['pmwi_order']['
|
1129 |
-
$templateOptions['pmwi_order']['
|
1130 |
break;
|
1131 |
-
|
1132 |
case 'comment_author':
|
1133 |
-
$templateOptions['pmwi_order']['
|
1134 |
break;
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
|
|
|
|
|
|
|
|
1138 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1139 |
}
|
1140 |
|
1141 |
}
|
111 |
}
|
112 |
}
|
113 |
|
114 |
+
endforeach;
|
115 |
|
116 |
foreach ( $this->order_core_fields as $core_field ):
|
117 |
|
124 |
}
|
125 |
}
|
126 |
|
127 |
+
endforeach;
|
128 |
|
129 |
foreach ($existing_meta_keys as $key => $record_meta_key)
|
130 |
{
|
198 |
|
199 |
public function init_additional_data(){
|
200 |
|
201 |
+
if ( ! self::$is_active || empty(XmlExportEngine::$exportQuery)) return;
|
202 |
+
|
203 |
+
$in_orders = preg_replace("%(SQL_CALC_FOUND_ROWS|LIMIT.*)%", "", XmlExportEngine::$exportQuery->request);
|
204 |
+
|
205 |
+
if ( ! empty($in_orders) ){
|
206 |
+
|
207 |
+
global $wpdb;
|
208 |
+
|
209 |
+
$table_prefix = $wpdb->prefix;
|
210 |
|
211 |
+
if ( empty(self::$orders_data['line_items_max_count']) ){
|
212 |
+
self::$orders_data['line_items_max_count'] = $wpdb->get_var($wpdb->prepare("SELECT max(cnt) as line_items_count FROM (
|
213 |
+
SELECT order_id, COUNT(*) as cnt FROM {$table_prefix}woocommerce_order_items
|
214 |
+
WHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (". $in_orders .") GROUP BY order_id) AS T3", 'line_item'));
|
215 |
+
}
|
216 |
+
|
217 |
+
if ( empty(self::$orders_data['taxes'])){
|
218 |
+
self::$orders_data['taxes'] = $wpdb->get_results($wpdb->prepare("SELECT order_item_id, order_id, order_item_name FROM {$table_prefix}woocommerce_order_items
|
219 |
+
WHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (". $in_orders .") GROUP BY order_item_name", 'tax'));
|
220 |
+
}
|
221 |
+
|
222 |
+
if ( empty(self::$orders_data['coupons'])){
|
223 |
+
self::$orders_data['coupons'] = $wpdb->get_results($wpdb->prepare("SELECT order_item_id, order_id, order_item_name FROM {$table_prefix}woocommerce_order_items
|
224 |
+
WHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (". $in_orders .") GROUP BY order_item_name", 'coupon'));
|
225 |
+
}
|
226 |
+
|
227 |
+
if ( empty(self::$orders_data['fees'])){
|
228 |
+
self::$orders_data['fees'] = $wpdb->get_results($wpdb->prepare("SELECT order_item_id, order_id, order_item_name FROM {$table_prefix}woocommerce_order_items
|
229 |
+
WHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (". $in_orders .") GROUP BY order_item_name", 'fee'));
|
230 |
+
}
|
231 |
+
|
232 |
+
if ( empty(self::$orders_data['variations'])){
|
233 |
+
self::$orders_data['variations'] = $wpdb->get_results($wpdb->prepare("SELECT meta_key FROM {$table_prefix}woocommerce_order_itemmeta
|
234 |
+
WHERE {$table_prefix}woocommerce_order_itemmeta.meta_key LIKE %s AND {$table_prefix}woocommerce_order_itemmeta.order_item_id IN (
|
235 |
+
SELECT {$table_prefix}woocommerce_order_items.order_item_id FROM {$table_prefix}woocommerce_order_items
|
236 |
+
WHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (". $in_orders .") ) GROUP BY meta_key", 'pa_%', 'line_item'));
|
237 |
+
}
|
238 |
+
|
239 |
+
if ( ! empty(PMXE_Plugin::$session) )
|
240 |
+
{
|
241 |
+
PMXE_Plugin::$session->set('orders_data', self::$orders_data);
|
242 |
+
PMXE_Plugin::$session->save_data();
|
243 |
+
}
|
244 |
+
}
|
245 |
}
|
246 |
|
247 |
private $order_items = null;
|
249 |
private $order_shipping = null;
|
250 |
private $order_coupons = null;
|
251 |
private $order_surcharge = null;
|
252 |
+
private $order_refunds = null;
|
253 |
private $__total_fee_amount = null;
|
254 |
private $__coupons_used = null;
|
255 |
private $order_id = null;
|
274 |
);
|
275 |
|
276 |
global $wpdb;
|
277 |
+
$table_prefix = $wpdb->prefix;
|
278 |
+
|
279 |
+
$implode_delimiter = XmlExportEngine::$implode;
|
280 |
+
|
281 |
+
if ( empty($this->order_id) or $this->order_id != $record->ID)
|
282 |
+
{
|
283 |
+
$this->order_id = $record->ID;
|
284 |
+
|
285 |
+
$all_order_items = $wpdb->get_results("SELECT * FROM {$table_prefix}woocommerce_order_items WHERE order_id = {$record->ID}");
|
286 |
+
|
287 |
+
if ( ! empty($all_order_items) )
|
288 |
+
{
|
289 |
+
foreach ($all_order_items as $item)
|
290 |
+
{
|
291 |
+
switch ($item->order_item_type)
|
292 |
+
{
|
293 |
+
case 'line_item':
|
294 |
+
$this->order_items[] = $item;
|
295 |
+
break;
|
296 |
+
case 'tax':
|
297 |
+
$this->order_taxes[] = $item;
|
298 |
+
break;
|
299 |
+
case 'shipping':
|
300 |
+
$this->order_shipping[] = $item;
|
301 |
+
break;
|
302 |
+
case 'coupon':
|
303 |
+
$this->order_coupons[] = $item;
|
304 |
+
break;
|
305 |
+
case 'fee':
|
306 |
+
$this->order_surcharge[] = $item;
|
307 |
+
break;
|
308 |
+
}
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
$this->order_refunds = $wpdb->get_results("SELECT * FROM {$table_prefix}posts WHERE post_parent = {$record->ID} AND post_type = 'shop_order_refund'");
|
313 |
+
}
|
314 |
+
|
315 |
+
if ( ! empty($options['cc_value'][$elId]) ){
|
316 |
+
|
317 |
+
$is_items_in_list = false;
|
318 |
+
$is_item_data_in_list = false;
|
319 |
+
foreach ($options['ids'] as $ID => $value)
|
320 |
+
{
|
321 |
+
if ($options['cc_options'][$ID] == 'items')
|
322 |
+
{
|
323 |
+
$is_items_in_list = true;
|
324 |
+
}
|
325 |
+
if ( strpos($options['cc_label'][$ID], "item_data__") !== false )
|
326 |
+
{
|
327 |
+
$is_item_data_in_list = true;
|
328 |
+
}
|
329 |
+
}
|
330 |
+
|
331 |
+
$fieldSnipped = ( ! empty($options['cc_php'][$elId]) and ! empty($options['cc_code'][$elId]) ) ? $options['cc_code'][$elId] : false;
|
332 |
+
|
333 |
+
if ( ! $is_items_in_list and $is_item_data_in_list )
|
334 |
+
{
|
335 |
+
if ( ! empty($this->order_items)){
|
336 |
+
|
337 |
+
foreach ($this->order_items as $n => $order_item) {
|
338 |
+
|
339 |
+
$meta_data = $wpdb->get_results("SELECT * FROM {$table_prefix}woocommerce_order_itemmeta WHERE order_item_id = {$order_item->order_item_id}", ARRAY_A);
|
340 |
+
|
341 |
+
$item_data = array();
|
342 |
+
|
343 |
+
foreach ($options['ids'] as $subID => $subvalue)
|
344 |
+
{
|
345 |
+
if ( strpos($options['cc_label'][$subID], 'item_data__') !== false )
|
346 |
+
{
|
347 |
+
$product_id = '';
|
348 |
+
$variation_id = '';
|
349 |
+
foreach ($meta_data as $meta) {
|
350 |
+
if ($meta['meta_key'] == '_variation_id' and ! empty($meta['meta_value'])){
|
351 |
+
$variation_id = $meta['meta_value'];
|
352 |
+
}
|
353 |
+
if ($meta['meta_key'] == '_product_id' and ! empty($meta['meta_value'])){
|
354 |
+
$product_id = $meta['meta_value'];
|
355 |
+
}
|
356 |
+
}
|
357 |
+
|
358 |
+
$_product_id = empty($variation_id) ? $product_id : $variation_id;
|
359 |
|
360 |
+
$_product = get_post($_product_id);
|
361 |
+
|
362 |
+
// do not export anything if product doesn't exist
|
363 |
+
if ( ! empty($_product) )
|
364 |
+
{
|
365 |
+
$item_add_data = XmlExportCpt::prepare_data( $_product, false, $this->acfs, $this->woo, $this->woo_order, ",", $preview, true, $subID );
|
366 |
+
|
367 |
+
if ( ! empty($item_add_data))
|
368 |
+
{
|
369 |
+
foreach ($item_add_data as $item_add_data_key => $item_add_data_value) {
|
370 |
+
if ( ! isset($item_data[$item_add_data_key])) $item_data[$item_add_data_key] = $item_add_data_value;
|
371 |
+
}
|
372 |
+
}
|
373 |
+
}
|
374 |
+
}
|
375 |
+
}
|
376 |
+
|
377 |
+
if ( ! empty($item_data)) $data['items'][] = $item_data;
|
378 |
+
|
379 |
+
}
|
380 |
+
|
381 |
+
$this->order_items = null;
|
382 |
+
}
|
383 |
+
}
|
384 |
|
385 |
switch ($options['cc_options'][$elId]) {
|
386 |
|
392 |
if ($options['cc_value'][$elId] == "post_title")
|
393 |
{
|
394 |
$data[$options['cc_name'][$elId]] = str_replace("–", '-', $data[$options['cc_name'][$elId]]);
|
395 |
+
}
|
396 |
|
397 |
$data[$options['cc_name'][$elId]] = pmxe_filter( $data[$options['cc_name'][$elId]], $fieldSnipped);
|
398 |
|
399 |
+
break;
|
400 |
+
|
401 |
}
|
|
|
402 |
}
|
403 |
|
404 |
return $data;
|
412 |
|
413 |
$data_to_export = $this->prepare_export_data( $record, $options, $elId, $preview );
|
414 |
|
415 |
+
$implode_delimiter = XmlExportEngine::$implode;
|
416 |
+
|
417 |
foreach ($data_to_export as $key => $data) {
|
418 |
|
419 |
+
if ( in_array($key, array('items', 'taxes', 'shipping', 'coupons', 'surcharge', 'refunds')) )
|
420 |
+
{
|
421 |
+
if ( ! empty($data))
|
422 |
+
{
|
423 |
+
if ( $key == 'items' and ( $options['order_item_per_row'] or $options['xml_template_type'] == 'custom'))
|
424 |
+
{
|
425 |
+
foreach ($data as $item) {
|
426 |
+
$additional_article = array();
|
427 |
+
if ( ! empty($item) ){
|
428 |
+
foreach ($item as $item_key => $item_value) {
|
429 |
+
$final_key = preg_replace("%\s#\d*%", "", $item_key);
|
430 |
+
$additional_article[$final_key] = $item_value;
|
431 |
+
// if ( ! in_array($final_key, $titles) ) $titles[] = $final_key;
|
432 |
+
}
|
433 |
+
}
|
434 |
+
|
435 |
+
if ( ! empty($additional_article) )
|
436 |
+
{
|
437 |
+
if ( empty($this->additional_articles) )
|
438 |
+
{
|
439 |
+
foreach ($additional_article as $item_key => $item_value) {
|
440 |
+
$article[$item_key] = $item_value;
|
441 |
+
}
|
442 |
+
}
|
443 |
+
$this->additional_articles[] = $additional_article;
|
444 |
+
}
|
445 |
+
}
|
446 |
+
}
|
447 |
+
else
|
448 |
+
{
|
449 |
+
foreach ($data as $n => $item)
|
450 |
+
{
|
451 |
+
if ( ! empty($item))
|
452 |
+
{
|
453 |
+
foreach ($item as $item_key => $item_value)
|
454 |
+
{
|
455 |
+
$final_key = (strpos($item_key, "#") === false and ! in_array($key, array('taxes', 'shipping', 'coupons', 'surcharge', 'refunds'))) ? $item_key . " #" . ($n + 1) : $item_key;
|
456 |
+
|
457 |
+
if ( ! isset($article[$final_key]))
|
458 |
+
{
|
459 |
+
$article[$final_key] = $item_value;
|
460 |
+
}
|
461 |
+
else
|
462 |
+
{
|
463 |
+
$article[$final_key] .= $implode_delimiter . $item_value;
|
464 |
+
}
|
465 |
+
// if ( ! in_array($final_key, $titles) ) $titles[] = $final_key;
|
466 |
+
}
|
467 |
+
}
|
468 |
+
}
|
469 |
+
}
|
470 |
+
}
|
471 |
+
}
|
472 |
+
else
|
473 |
+
{
|
474 |
// $article[$key] = $data;
|
475 |
wp_all_export_write_article( $article, $key, $data );
|
476 |
+
// if ( ! in_array($key, $titles) ) $titles[] = $key;
|
477 |
+
}
|
478 |
+
}
|
479 |
}
|
480 |
|
481 |
public function filter_csv_rows($articles, $options){
|
482 |
+
|
483 |
+
if ( ! empty($this->additional_articles) and ( $options['order_item_per_row'] or $options['xml_template_type'] == 'custom') )
|
484 |
{
|
485 |
$base_article = $articles[count($articles) - 1];
|
486 |
array_shift($this->additional_articles);
|
487 |
if ( ! empty($this->additional_articles ) ){
|
488 |
foreach ($this->additional_articles as $article) {
|
489 |
+
if ($options['order_item_fill_empty_columns'] and $options['export_to'] == 'csv')
|
490 |
{
|
491 |
foreach ($article as $key => $value) {
|
492 |
unset($base_article[$key]);
|
519 |
if ( ! empty(self::$orders_data['taxes']))
|
520 |
{
|
521 |
foreach ( self::$orders_data['taxes'] as $tax) {
|
522 |
+
// $friendly_name = str_replace("per tax", $this->get_rate_friendly_name($tax->order_item_id), $options['cc_name'][$element_key]);
|
523 |
+
$friendly_name = str_replace(" (per tax)", "", $options['cc_name'][$element_key]);
|
524 |
if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
|
525 |
+
if ( ! in_array("Rate Name", $headers)) $headers[] = "Rate Name";
|
526 |
}
|
527 |
}
|
528 |
|
533 |
if ( ! empty(self::$orders_data['coupons']))
|
534 |
{
|
535 |
foreach ( self::$orders_data['coupons'] as $coupon) {
|
536 |
+
// $friendly_name = str_replace("per coupon", $coupon->order_item_name, $options['cc_name'][$element_key]);
|
537 |
+
$friendly_name = str_replace("(per coupon)", "", $options['cc_name'][$element_key]);
|
538 |
if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
|
539 |
+
if ( ! in_array("Coupon Code", $headers)) $headers[] = "Coupon Code";
|
540 |
}
|
541 |
}
|
542 |
|
547 |
if ( ! empty(self::$orders_data['fees']))
|
548 |
{
|
549 |
foreach ( self::$orders_data['fees'] as $fee) {
|
550 |
+
// $friendly_name = str_replace("Amount (per surcharge)", "(" . $fee->order_item_name . ")", $options['cc_name'][$element_key]);
|
551 |
+
$friendly_name = str_replace(" (per surcharge)", "", $options['cc_name'][$element_key]);
|
552 |
if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
|
553 |
+
if ( ! in_array("Fee Name", $headers)) $headers[] = "Fee Name";
|
554 |
}
|
555 |
}
|
556 |
|
561 |
|
562 |
if ( ! empty(self::$orders_data['line_items_max_count']) and ! empty(self::$orders_data['variations']))
|
563 |
{
|
564 |
+
if ( $options['order_item_per_row'] or $options['xml_template_type'] == 'custom'){
|
565 |
foreach ( self::$orders_data['variations'] as $variation) {
|
566 |
$friendly_name = $options['cc_name'][$element_key] . " (" . sanitize_title(str_replace("pa_", "", $variation->meta_key)) . ")";
|
567 |
if ( ! in_array($friendly_name, $headers)) $headers[] = $friendly_name;
|
586 |
// Order's product basic data headers
|
587 |
case 'items':
|
588 |
|
589 |
+
if ( $options['order_item_per_row'] or $options['xml_template_type'] == 'custom')
|
590 |
{
|
591 |
if ( ! in_array($options['cc_name'][$element_key], $headers)) $headers[] = $options['cc_name'][$element_key];
|
592 |
}
|
614 |
$element_name = ( ! empty($options['cc_name'][$element_key]) ) ? $options['cc_name'][$element_key] : 'untitled_' . $element_key;
|
615 |
|
616 |
switch ($options['cc_type'][$element_key])
|
617 |
+
{
|
|
|
618 |
case 'woo':
|
619 |
|
620 |
XmlExportEngine::$woo_export->get_element_header( $element_headers, $options, $element_key );
|
673 |
{
|
674 |
foreach ($element_headers as $header)
|
675 |
{
|
676 |
+
if ( $options['order_item_per_row'] or $options['xml_template_type'] == 'custom')
|
677 |
{
|
678 |
if ( ! in_array($header, $headers)) $headers[] = $header;
|
679 |
}
|
751 |
|
752 |
foreach ($data_to_export as $key => $data) {
|
753 |
|
754 |
+
if ( in_array($key, array('items', 'taxes', 'shipping', 'coupons', 'surcharge', 'refunds')) )
|
|
|
|
|
755 |
{
|
756 |
+
if ( ! empty($data)){
|
757 |
+
$xmlWriter->startElement('Order' . ucfirst($key));
|
758 |
+
foreach ($data as $item) {
|
759 |
+
if ( ! empty($item)){
|
760 |
+
$xmlWriter->startElement(preg_replace("%(s|es)$%", "", ucfirst($key)));
|
761 |
+
foreach ($item as $item_key => $item_value) {
|
762 |
+
$element_name_ns = '';
|
763 |
+
$element_name = str_replace("-", "_", preg_replace('/[^a-z0-9:_]/i', '', preg_replace("%#\d%", "", $item_key)));
|
764 |
+
if (strpos($element_name, ":") !== false)
|
765 |
+
{
|
766 |
+
$element_name_parts = explode(":", $element_name);
|
767 |
+
$element_name_ns = (empty($element_name_parts[0])) ? '' : $element_name_parts[0];
|
768 |
+
$element_name = (empty($element_name_parts[1])) ? 'untitled_' . $ID : $element_name_parts[1];
|
769 |
+
}
|
770 |
+
$xmlWriter->beginElement($element_name_ns, $element_name, null);
|
771 |
+
$xmlWriter->writeData($item_value, $element_name);
|
772 |
+
$xmlWriter->closeElement();
|
773 |
+
// $xmlWriter->writeElement(str_replace("-", "_", sanitize_title(preg_replace("%#\d%", "", $item_key))), $item_value);
|
774 |
+
}
|
775 |
+
$xmlWriter->closeElement();
|
776 |
+
}
|
777 |
+
}
|
778 |
+
$xmlWriter->closeElement();
|
779 |
+
}
|
780 |
}
|
781 |
+
else
|
782 |
+
{
|
783 |
+
$element_name_ns = '';
|
784 |
+
$element_name = str_replace("-", "_", preg_replace('/[^a-z0-9:_]/i', '', $key));
|
785 |
+
if (strpos($element_name, ":") !== false)
|
786 |
+
{
|
787 |
+
$element_name_parts = explode(":", $element_name);
|
788 |
+
$element_name_ns = (empty($element_name_parts[0])) ? '' : $element_name_parts[0];
|
789 |
+
$element_name = (empty($element_name_parts[1])) ? 'untitled_' . $ID : $element_name_parts[1];
|
790 |
+
}
|
791 |
+
|
792 |
+
$xmlWriter = apply_filters('wp_all_export_add_before_element', $xmlWriter, $element_name, XmlExportEngine::$exportID, $record->ID);
|
793 |
+
|
794 |
+
$xmlWriter->beginElement($element_name_ns, $element_name, null);
|
795 |
+
$xmlWriter->writeData($data, $element_name);
|
796 |
+
$xmlWriter->closeElement();
|
797 |
+
|
798 |
+
$xmlWriter = apply_filters('wp_all_export_add_after_element', $xmlWriter, $element_name, XmlExportEngine::$exportID, $record->ID);
|
799 |
+
}
|
800 |
}
|
801 |
}
|
802 |
|
803 |
public static function prepare_child_exports( $export, $is_cron = false )
|
804 |
{
|
805 |
+
$queue_exports = array();
|
806 |
+
|
807 |
+
$exportList = new PMXE_Export_List();
|
808 |
+
|
809 |
+
global $wpdb;
|
810 |
+
|
811 |
+
$table_prefix = $wpdb->prefix;
|
812 |
+
$pmxe_prefix = PMXE_Plugin::getInstance()->getTablePrefix();
|
813 |
+
|
814 |
+
$in_orders = $wpdb->prepare("SELECT DISTINCT post_id FROM {$pmxe_prefix}posts WHERE export_id = %d AND iteration = %d", $export->id, $export->iteration - 1);
|
815 |
+
|
816 |
+
foreach ($exportList->getBy('parent_id', $export->id)->convertRecords() as $child_export)
|
817 |
+
{
|
818 |
+
|
819 |
+
$whereClause = "";
|
820 |
+
|
821 |
+
switch ($child_export->export_post_type)
|
822 |
+
{
|
823 |
+
case 'product':
|
824 |
+
|
825 |
+
if ( $export->options['order_include_poducts'])
|
826 |
+
{
|
827 |
+
$queue_exports[] = $child_export->id;
|
828 |
+
|
829 |
+
if ( ! $export->options['order_include_all_poducts'] )
|
830 |
+
{
|
831 |
+
|
832 |
+
$in_products = $wpdb->prepare("SELECT order_item_meta.meta_value as product_id FROM {$table_prefix}posts as posts INNER JOIN {$pmxe_prefix}posts AS order_export ON posts.ID = post_id INNER JOIN {$table_prefix}woocommerce_order_items AS order_items ON posts.ID = order_id INNER JOIN {$table_prefix}woocommerce_order_itemmeta AS order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id WHERE order_export.export_id = %d AND order_export.iteration = %d AND order_items.order_item_type = 'line_item' AND order_item_meta.meta_key = '_product_id' GROUP BY product_id", $export->id, $export->iteration - 1);
|
833 |
+
|
834 |
+
$whereClause = " AND ({$table_prefix}posts.ID IN (". $in_products .") OR {$table_prefix}posts.post_parent IN (". $in_products ."))";
|
835 |
+
|
836 |
+
}
|
837 |
+
}
|
838 |
+
|
839 |
+
break;
|
840 |
+
|
841 |
+
case 'shop_coupon':
|
842 |
+
|
843 |
+
if ( $export->options['order_include_coupons'])
|
844 |
+
{
|
845 |
+
$queue_exports[] = $child_export->id;
|
846 |
+
|
847 |
+
if ( ! $export->options['order_include_all_coupons'] )
|
848 |
+
{
|
849 |
+
$whereClause = " AND {$table_prefix}posts.post_title IN (". $wpdb->prepare("SELECT order_item_name FROM {$table_prefix}woocommerce_order_items
|
850 |
+
WHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (". $in_orders .") GROUP BY order_item_name", 'coupon') .")";
|
851 |
+
}
|
852 |
+
}
|
853 |
+
|
854 |
+
break;
|
855 |
+
|
856 |
+
case 'shop_customer':
|
857 |
+
|
858 |
+
if ( $export->options['order_include_customers'])
|
859 |
+
{
|
860 |
+
$queue_exports[] = $child_export->id;
|
861 |
+
|
862 |
+
if ( ! $export->options['order_include_all_customers'] )
|
863 |
+
{
|
864 |
+
$whereClause = " AND {$table_prefix}users.ID IN (" . $wpdb->prepare("SELECT meta_value FROM {$table_prefix}postmeta WHERE meta_key = %s AND post_id IN (". $in_orders .") GROUP BY meta_value", "_customer_user") . ")";
|
865 |
+
}
|
866 |
+
}
|
867 |
+
|
868 |
+
break;
|
869 |
+
|
870 |
+
default:
|
871 |
+
# code...
|
872 |
+
break;
|
873 |
+
}
|
874 |
+
$child_export_options = $child_export->options;
|
875 |
+
$child_export_options['whereclause'] = $whereClause;
|
876 |
+
$child_export->set(array(
|
877 |
+
'triggered' => $is_cron ? 1 : 0,
|
878 |
+
'processing' => 0,
|
879 |
+
'exported' => 0,
|
880 |
+
'executing' => $is_cron ? 0 : 1,
|
881 |
+
'canceled' => 0,
|
882 |
+
'options' => $child_export_options
|
883 |
+
))->save();
|
884 |
+
}
|
885 |
+
return $queue_exports;
|
886 |
+
}
|
887 |
+
|
888 |
+
public function get_fields_options( &$fields, $field_keys = array() ){
|
889 |
+
|
890 |
+
if ( ! self::$is_active ) return;
|
891 |
+
|
892 |
+
foreach (self::$order_sections as $slug => $section) :
|
893 |
+
if ( ! empty($section['meta'])):
|
894 |
+
foreach ($section['meta'] as $cur_meta_key => $field) {
|
895 |
+
|
896 |
+
$field_key = (is_array($field)) ? $field['name'] : $field;
|
897 |
+
|
898 |
+
if ( ! in_array($field_key, $field_keys) ) continue;
|
899 |
+
|
900 |
+
$fields['ids'][] = 1;
|
901 |
+
$fields['cc_label'][] = (is_array($field)) ? $field['label'] : $cur_meta_key;
|
902 |
+
$fields['cc_php'][] = '';
|
903 |
+
$fields['cc_code'][] = '';
|
904 |
+
$fields['cc_sql'][] = '';
|
905 |
+
$fields['cc_options'][] = (is_array($field)) ? $field['options'] : $slug;
|
906 |
+
$fields['cc_type'][] = (is_array($field)) ? $field['type'] : 'woo_order';
|
907 |
+
$fields['cc_value'][] = (is_array($field)) ? $field['label'] : $cur_meta_key;
|
908 |
+
$fields['cc_name'][] = $field_key;
|
909 |
+
$fields['cc_settings'][] = '';
|
910 |
+
}
|
911 |
+
|
912 |
+
endif;
|
913 |
+
if ( ! empty($section['additional']) )
|
914 |
+
{
|
915 |
+
foreach ($section['additional'] as $sub_slug => $sub_section)
|
916 |
+
{
|
917 |
+
foreach ($sub_section['meta'] as $field) {
|
918 |
+
|
919 |
+
$field_key = (is_array($field)) ? $field['name'] : $field;
|
920 |
+
|
921 |
+
if ( ! in_array($field_key, $field_keys) ) continue;
|
922 |
+
|
923 |
+
$fields['ids'][] = 1;
|
924 |
+
$fields['cc_label'][] = 'item_data__' . ((is_array($field)) ? $field['label'] : $field);
|
925 |
+
$fields['cc_php'][] = '';
|
926 |
+
$fields['cc_code'][] = '';
|
927 |
+
$fields['cc_sql'][] = '';
|
928 |
+
$fields['cc_options'][] = 'item_data';
|
929 |
+
$fields['cc_type'][] = (is_array($field)) ? $field['type'] : $sub_slug;
|
930 |
+
$fields['cc_value'][] = 'item_data__' . ((is_array($field)) ? $field['label'] : $field);
|
931 |
+
$fields['cc_name'][] = $field_key;
|
932 |
+
$fields['cc_settings'][] = '';
|
933 |
+
}
|
934 |
+
}
|
935 |
+
}
|
936 |
+
endforeach;
|
937 |
+
|
938 |
}
|
939 |
|
940 |
public function render( & $i ){
|
948 |
<div class="wpae-custom-field">
|
949 |
<?php if ( ! in_array($slug, array('order', 'customer', 'cf', 'other'))) : ?>
|
950 |
<div class="wpallexport-free-edition-notice">
|
951 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=wooco+orders&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export to Export Order Data','wp_all_export_plugin');?></a>
|
952 |
</div>
|
953 |
<?php endif; ?>
|
954 |
<ul>
|
1040 |
?>
|
1041 |
<select class="wp-all-export-chosen-select" name="column_value_type" style="width:350px;">
|
1042 |
<?php
|
1043 |
+
foreach (self::$order_sections as $slug => $section) : //if ( in_array($slug, array('taxes', 'fees', 'items', 'notes', 'refunds'))) continue;
|
1044 |
?>
|
1045 |
<optgroup label="<?php echo $section['title']; ?>">
|
1046 |
<?php
|
1135 |
case 'items':
|
1136 |
case 'taxes':
|
1137 |
case 'fees':
|
1138 |
+
case 'refunds':
|
1139 |
break;
|
1140 |
default:
|
1141 |
switch ($field_type)
|
1202 |
'comment_author_email' => __('Note User Email', 'wp_all_export_plugin')
|
1203 |
)
|
1204 |
),
|
1205 |
+
'refunds' => array(
|
1206 |
+
'title' => __('Refunds', 'wp_all_export_plugin'),
|
1207 |
+
'meta' => array(
|
1208 |
+
'_refund_total' => __('Refund Total', 'wp_all_export_plugin'),
|
1209 |
+
'refund_id' => __('Refund ID', 'wp_all_export_plugin'),
|
1210 |
+
'refund_amount' => __('Refund Amounts', 'wp_all_export_plugin'),
|
1211 |
+
'refund_reason' => __('Refund Reason', 'wp_all_export_plugin'),
|
1212 |
+
'refund_date' => __('Refund Date', 'wp_all_export_plugin'),
|
1213 |
+
'refund_author_email' => __('Refund Author Email', 'wp_all_export_plugin')
|
1214 |
+
)
|
1215 |
+
),
|
1216 |
'cf' => array(
|
1217 |
'title' => __('Custom Fields', 'wp_all_export_plugin'),
|
1218 |
'meta' => array()
|
1240 |
'post_title' => __('Title', 'wp_all_export_plugin'),
|
1241 |
'post_status' => __('Order Status', 'wp_all_export_plugin'),
|
1242 |
'_order_currency' => __('Order Currency', 'wp_all_export_plugin'),
|
1243 |
+
'_payment_method_title' => __('Payment Method Title', 'wp_all_export_plugin'),
|
1244 |
+
'_order_total' => __('Order Total', 'wp_all_export_plugin')
|
1245 |
);
|
1246 |
|
1247 |
return apply_filters('wp_all_export_available_order_data_filter', $data);
|
1260 |
'__product_variation' => __('Product Variation Details', 'wp_all_export_plugin'),
|
1261 |
'_qty' => __('Quantity', 'wp_all_export_plugin'),
|
1262 |
'_line_subtotal' => __('Item Cost', 'wp_all_export_plugin'),
|
1263 |
+
'_line_total' => __('Item Total', 'wp_all_export_plugin'),
|
1264 |
+
'_line_subtotal_tax' => __('Item Tax', 'wp_all_export_plugin'),
|
1265 |
+
'_line_tax' => __('Item Tax Total', 'wp_all_export_plugin'),
|
1266 |
+
'_line_tax_data' => __('Item Tax Data', 'wp_all_export_plugin')
|
1267 |
);
|
1268 |
|
1269 |
return apply_filters('wp_all_export_available_order_default_product_data_filter', $data);
|
1379 |
|
1380 |
$is_xml_template = $options['export_to'] == 'xml';
|
1381 |
|
1382 |
+
$implode_delimiter = XmlExportEngine::$implode;
|
1383 |
|
1384 |
switch ($element_type)
|
1385 |
{
|
1388 |
$templateOptions['tmp_unique_key'] = '{'. $element_name .'[1]}';
|
1389 |
break;
|
1390 |
|
1391 |
+
case 'post_title':
|
1392 |
+
$templateOptions['title'] = '{'. $element_name .'[1]}';
|
1393 |
+
$templateOptions['is_update_title'] = 1;
|
1394 |
+
break;
|
1395 |
+
|
1396 |
case 'post_status':
|
1397 |
$templateOptions['is_update_status'] = 1;
|
1398 |
$templateOptions['pmwi_order']['status'] = 'xpath';
|
1434 |
$templateOptions['pmwi_order']['products_repeater_mode_foreach'] = '{OrderItems[1]/Item}';
|
1435 |
$templateOptions['pmwi_order']['products'][0]['sku'] = '{'. $element_name .'[1]}';
|
1436 |
}
|
1437 |
+
else
|
1438 |
+
{
|
1439 |
+
$templateOptions['pmwi_order']['products_repeater_mode_separator'] = $implode_delimiter;
|
1440 |
+
|
1441 |
+
if ( $options['order_item_per_row'] or $options['xml_template_type'] == 'custom') {
|
1442 |
+
$templateOptions['pmwi_order']['products'][0]['sku'] = '{'. $element_name .'[1]}';
|
1443 |
+
}
|
1444 |
+
else{
|
1445 |
+
$templateOptions['pmwi_order']['products'][0]['sku'] = '{'. $element_name .'1[1]}';
|
1446 |
+
}
|
1447 |
+
}
|
1448 |
break;
|
1449 |
|
1450 |
case '_qty':
|
1451 |
+
|
1452 |
if ($is_xml_template)
|
1453 |
{
|
1454 |
$templateOptions['pmwi_order']['products'][0]['qty'] = '{'. $element_name .'[1]}';
|
1455 |
}
|
1456 |
+
else
|
1457 |
+
{
|
1458 |
+
$templateOptions['pmwi_order']['products_repeater_mode_separator'] = $implode_delimiter;
|
1459 |
+
|
1460 |
+
if ( $options['order_item_per_row'] or $options['xml_template_type'] == 'custom') {
|
1461 |
+
$templateOptions['pmwi_order']['products'][0]['qty'] = '{'. $element_name .'[1]}';
|
1462 |
+
}
|
1463 |
+
else{
|
1464 |
+
$templateOptions['pmwi_order']['products'][0]['qty'] = '{'. $element_name .'1[1]}';
|
1465 |
+
}
|
1466 |
+
}
|
1467 |
break;
|
1468 |
|
1469 |
// prepare template for fee line items
|
1473 |
if ($is_xml_template)
|
1474 |
{
|
1475 |
$templateOptions['pmwi_order']['fees_repeater_mode_foreach'] = '{OrderSurcharge[1]/Surcharge}';
|
1476 |
+
$templateOptions['pmwi_order']['fees'][0]['name'] = '{FeeName[1]}';
|
1477 |
+
$templateOptions['pmwi_order']['fees'][0]['amount'] = '{'.$element_name.'[1]}';
|
1478 |
+
}
|
1479 |
+
else
|
1480 |
+
{
|
1481 |
+
$templateOptions['pmwi_order']['fees_repeater_mode_separator'] = $implode_delimiter;
|
1482 |
+
$templateOptions['pmwi_order']['fees'][0]['name'] = '{feename[1]}';
|
1483 |
+
$templateOptions['pmwi_order']['fees'][0]['amount'] = '{'.$element_name.'[1]}';
|
1484 |
}
|
1485 |
break;
|
1486 |
|
1488 |
case 'discount_amount':
|
1489 |
$templateOptions['pmwi_order']['is_update_coupons'] = 1;
|
1490 |
$templateOptions['pmwi_order']['coupons_repeater_mode'] = $options['export_to'];
|
1491 |
+
$templateOptions['pmwi_order']['coupons'][0]['amount_tax'] = '';
|
1492 |
if ($is_xml_template)
|
1493 |
{
|
1494 |
$templateOptions['pmwi_order']['coupons_repeater_mode_foreach'] = '{OrderCoupons[1]/Coupon}';
|
1495 |
+
$templateOptions['pmwi_order']['coupons'][0]['code'] = '{CouponCode[1]}';
|
1496 |
+
$templateOptions['pmwi_order']['coupons'][0]['amount'] = '[str_replace("-","",{'.$element_name.'[1]})]';
|
|
|
1497 |
}
|
1498 |
+
else
|
1499 |
+
{
|
1500 |
+
$templateOptions['pmwi_order']['coupons_repeater_mode_separator'] = $implode_delimiter;
|
1501 |
+
$templateOptions['pmwi_order']['coupons'][0]['code'] = '{couponcode[1]}';
|
1502 |
+
$templateOptions['pmwi_order']['coupons'][0]['amount'] = '[str_replace("-","",{'.$element_name.'[1]})]';
|
1503 |
+
}
|
1504 |
break;
|
1505 |
|
1506 |
// prepare template for shipping line items
|
1507 |
case 'shipping_order_item_name':
|
1508 |
$templateOptions['pmwi_order']['is_update_shipping'] = 1;
|
1509 |
$templateOptions['pmwi_order']['shipping_repeater_mode'] = $options['export_to'];
|
1510 |
+
$templateOptions['pmwi_order']['shipping'][0]['name'] = '{'. $element_name.'[1]}';
|
1511 |
+
$templateOptions['pmwi_order']['shipping'][0]['class'] = 'xpath';
|
1512 |
+
$templateOptions['pmwi_order']['shipping'][0]['class_xpath'] = '{'. $element_name .'[1]}';
|
1513 |
+
|
1514 |
if ($is_xml_template)
|
1515 |
{
|
1516 |
+
$templateOptions['pmwi_order']['shipping_repeater_mode_foreach'] = '{OrderShipping[1]/Shipping}';
|
|
|
|
|
|
|
1517 |
}
|
1518 |
+
else
|
1519 |
+
{
|
1520 |
+
$templateOptions['pmwi_order']['shipping_repeater_mode_separator'] = $implode_delimiter;
|
1521 |
+
}
|
1522 |
break;
|
1523 |
+
// shipping cost
|
1524 |
case '_order_shipping':
|
1525 |
$templateOptions['pmwi_order']['shipping'][0]['amount'] = '{'. $element_name .'[1]}';
|
1526 |
break;
|
1529 |
case 'tax_order_item_name':
|
1530 |
$templateOptions['pmwi_order']['is_update_taxes'] = 1;
|
1531 |
$templateOptions['pmwi_order']['taxes_repeater_mode'] = $options['export_to'];
|
1532 |
+
$templateOptions['pmwi_order']['taxes'][0]['shipping_tax_amount'] = '';
|
1533 |
+
$templateOptions['pmwi_order']['taxes'][0]['code'] = 'xpath';
|
1534 |
+
$templateOptions['pmwi_order']['taxes'][0]['code_xpath'] = '{'. str_replace("pertax", "", $element_name) .'[1]}';
|
1535 |
+
|
1536 |
if ($is_xml_template)
|
1537 |
{
|
1538 |
+
$templateOptions['pmwi_order']['taxes_repeater_mode_foreach'] = '{OrderTaxes[1]/Tax}';
|
|
|
|
|
|
|
1539 |
}
|
1540 |
+
else
|
1541 |
+
{
|
1542 |
+
$templateOptions['pmwi_order']['taxes_repeater_mode_separator'] = $implode_delimiter;
|
1543 |
+
}
|
1544 |
break;
|
1545 |
|
1546 |
case 'tax_rate':
|
1547 |
+
$templateOptions['pmwi_order']['taxes'][0]['tax_code'] = 'xpath';
|
1548 |
+
$templateOptions['pmwi_order']['taxes'][0]['tax_code_xpath'] = '{ratename[1]}';
|
1549 |
break;
|
1550 |
|
1551 |
case 'tax_amount':
|
1552 |
+
$templateOptions['pmwi_order']['taxes'][0]['tax_amount'] = '{'. str_replace("pertax", "", $element_name).'[1]}';
|
1553 |
break;
|
1554 |
|
1555 |
// order notes
|
1556 |
+
case 'comment_content':
|
1557 |
+
case 'comment_date':
|
1558 |
$templateOptions['pmwi_order']['is_update_notes'] = 1;
|
1559 |
+
$templateOptions['pmwi_order']['notes_repeater_mode'] = 'csv';
|
1560 |
+
$templateOptions['pmwi_order']['notes_repeater_mode_separator'] = $implode_delimiter;
|
1561 |
+
$templateOptions['pmwi_order']['notes'][0][str_replace('comment_', '', $element_type)] = '{'. $element_name .'[1]}';
|
1562 |
break;
|
|
|
|
|
|
|
|
|
|
|
1563 |
case 'visibility':
|
1564 |
+
$templateOptions['pmwi_order']['notes'][0]['visibility'] = 'xpath';
|
1565 |
+
$templateOptions['pmwi_order']['notes'][0]['visibility_xpath'] = '{'. $element_name .'[1]}';
|
1566 |
break;
|
|
|
1567 |
case 'comment_author':
|
1568 |
+
$templateOptions['pmwi_order']['notes'][0]['username'] = '{'. $element_name .'[1]}';
|
1569 |
break;
|
1570 |
+
case 'comment_author_email':
|
1571 |
+
$templateOptions['pmwi_order']['notes'][0]['email'] = '{'. $element_name .'[1]}';
|
1572 |
+
break;
|
1573 |
+
// Order Total
|
1574 |
+
case '_order_total':
|
1575 |
+
$templateOptions['pmwi_order']['order_total_logic'] = 'manually';
|
1576 |
+
$templateOptions['pmwi_order']['order_total_xpath'] = '{'. $element_name .'[1]}';
|
1577 |
break;
|
1578 |
+
// Order Refunds
|
1579 |
+
case 'refund_amount':
|
1580 |
+
case 'refund_reason':
|
1581 |
+
case 'refund_date':
|
1582 |
+
$templateOptions['pmwi_order']['is_update_refunds'] = 1;
|
1583 |
+
if ($is_xml_template)
|
1584 |
+
{
|
1585 |
+
$templateOptions['pmwi_order']['order_' . $element_type] = '{OrderRefunds[1]/Refund/'.$element_name.'[1]}';
|
1586 |
+
}
|
1587 |
+
else
|
1588 |
+
{
|
1589 |
+
$templateOptions['pmwi_order']['order_' . $element_type] = '{'. $element_name .'[1]}';
|
1590 |
+
}
|
1591 |
+
break;
|
1592 |
+
case 'refund_author_email':
|
1593 |
+
$templateOptions['pmwi_order']['order_refund_issued_email'] = '{'. $element_name .'[1]}';
|
1594 |
+
$templateOptions['pmwi_order']['order_refund_issued_match_by'] = 'email';
|
1595 |
+
if ($is_xml_template)
|
1596 |
+
{
|
1597 |
+
$templateOptions['pmwi_order']['order_refund_issued_email'] = '{OrderRefunds[1]/Refund/'.$element_name.'[1]}';
|
1598 |
+
}
|
1599 |
+
else
|
1600 |
+
{
|
1601 |
+
$templateOptions['pmwi_order']['order_refund_issued_email'] = '{'. $element_name .'[1]}';
|
1602 |
+
}
|
1603 |
+
break;
|
1604 |
+
|
1605 |
}
|
1606 |
|
1607 |
}
|
libraries/XmlGoogleMerchants.php
CHANGED
@@ -1,59 +1,161 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
3 |
final class XmlGoogleMerchants
|
4 |
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Class XmlGoogleMerchants
|
5 |
+
*/
|
6 |
final class XmlGoogleMerchants
|
7 |
{
|
8 |
+
/**
|
9 |
+
* @var bool
|
10 |
+
*/
|
11 |
+
private $export_id = false;
|
12 |
+
/**
|
13 |
+
* @var array
|
14 |
+
*/
|
15 |
+
private $add_data = array();
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var array
|
19 |
+
*
|
20 |
+
* https://support.google.com/merchants/answer/160589?hl=en
|
21 |
+
*
|
22 |
+
*/
|
23 |
+
private $required_fields = array(
|
24 |
+
array(
|
25 |
+
'name' => 'g:id',
|
26 |
+
'type' => 'ID',
|
27 |
+
// 'label' => 'id'
|
28 |
+
),
|
29 |
+
array(
|
30 |
+
'name' => 'title',
|
31 |
+
'type' => 'Title',
|
32 |
+
// 'label' => 'title'
|
33 |
+
),
|
34 |
+
array(
|
35 |
+
'name' => 'link',
|
36 |
+
'type' => 'Permalink',
|
37 |
+
// 'label' => 'permalink'
|
38 |
+
),
|
39 |
+
array(
|
40 |
+
'name' => 'description',
|
41 |
+
'type' => 'Content',
|
42 |
+
// 'label' => 'content'
|
43 |
+
),
|
44 |
+
array(
|
45 |
+
'name' => 'g:image_link',
|
46 |
+
'type' => 'Image Url',
|
47 |
+
// 'options' => '{"is_export_featured":true,"is_export_attached":false,"image_separator":"|"}'
|
48 |
+
),
|
49 |
+
array(
|
50 |
+
'name' => 'g:price',
|
51 |
+
'type' => 'Regular Price',
|
52 |
+
),
|
53 |
+
// array(
|
54 |
+
// 'name' => 'g:condition',
|
55 |
+
// 'type' => 'woo',
|
56 |
+
// 'label' => '_regular_price'
|
57 |
+
// )
|
58 |
+
);
|
59 |
+
|
60 |
+
/**
|
61 |
+
* XmlGoogleMerchants constructor.
|
62 |
+
* @param $id
|
63 |
+
* @param array $additional_data
|
64 |
+
*/
|
65 |
+
public function __construct($id, $additional_data = array())
|
66 |
+
{
|
67 |
+
$this->export_id = $id;
|
68 |
+
$this->add_data = $additional_data;
|
69 |
+
|
70 |
+
if ( ! empty($this->export_id))
|
71 |
+
{
|
72 |
+
add_filter('wp_all_export_xml_header', array( &$this, 'wpae_xml_header'), 10, 2);
|
73 |
+
add_filter('wp_all_export_additional_data', array( &$this, 'wpae_additional_data'), 10, 3);
|
74 |
+
add_filter('wp_all_export_xml_footer', array( &$this, 'wpae_xml_footer'), 10, 2);
|
75 |
+
add_filter('wp_all_export_main_xml_tag', array( &$this, 'wpae_main_xml_tag'), 10, 2);
|
76 |
+
add_filter('wp_all_export_record_xml_tag', array( &$this, 'wpae_record_xml_tag'), 10, 2);
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @param $header
|
82 |
+
* @param $export_id
|
83 |
+
* @return string
|
84 |
+
*/
|
85 |
+
public function wpae_xml_header($header, $export_id)
|
86 |
+
{
|
87 |
+
if ( $export_id == $this->export_id )
|
88 |
+
{
|
89 |
+
$header .= "\n<rss version=\"2.0\" xmlns:g=\"http://base.google.com/ns/1.0\">";
|
90 |
+
}
|
91 |
+
return $header;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @param $add_data
|
96 |
+
* @param $options
|
97 |
+
* @param $export_id
|
98 |
+
* @return array
|
99 |
+
*/
|
100 |
+
public function wpae_additional_data($add_data, $options, $export_id)
|
101 |
+
{
|
102 |
+
if ( $export_id == $this->export_id && ! empty($this->add_data))
|
103 |
+
{
|
104 |
+
$add_data = array_merge($add_data, $this->add_data);
|
105 |
+
}
|
106 |
+
return $add_data;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* @param $footer
|
111 |
+
* @param $export_id
|
112 |
+
* @return string
|
113 |
+
*/
|
114 |
+
public function wpae_xml_footer($footer, $export_id)
|
115 |
+
{
|
116 |
+
if ( $export_id == $this->export_id )
|
117 |
+
{
|
118 |
+
$footer = "</rss>";
|
119 |
+
}
|
120 |
+
return $footer;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* @param $tag
|
125 |
+
* @param $export_id
|
126 |
+
* @return string
|
127 |
+
*/
|
128 |
+
public function wpae_main_xml_tag($tag, $export_id )
|
129 |
+
{
|
130 |
+
return ( $export_id == $this->export_id ) ? 'channel' : $tag;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* @param $tag
|
135 |
+
* @param $export_id
|
136 |
+
* @return string
|
137 |
+
*/
|
138 |
+
public function wpae_record_xml_tag($tag, $export_id )
|
139 |
+
{
|
140 |
+
return ( $export_id == $this->export_id ) ? 'item' : $tag;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
*
|
145 |
+
*/
|
146 |
+
public function get_required_fields()
|
147 |
+
{
|
148 |
+
$xml_template = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss version=\"2.0\" xmlns:g=\"http://base.google.com/ns/1.0\">\n";
|
149 |
+
$xml_template .= "\t<chanel>";
|
150 |
+
$xml_template .= "\n\t\t<!-- BEGIN LOOP -->";
|
151 |
+
$xml_template .= "\n\t\t<item>";
|
152 |
+
foreach ($this->required_fields as $field){
|
153 |
+
$xml_template .= "\n\t\t\t<" . $field['name'] . ">{" . $field['type'] . "}</" . $field['name'] . ">";
|
154 |
+
}
|
155 |
+
$xml_template .= "\n\t\t</item>";
|
156 |
+
$xml_template .= "\n\t\t<!-- END LOOP -->";
|
157 |
+
$xml_template .= "\n\t</chanel>";
|
158 |
+
$xml_template .= "\n</rss>";
|
159 |
+
return $xml_template;
|
160 |
+
}
|
161 |
}
|
libraries/XmlSpec.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once dirname(__FILE__) . '/XmlGoogleMerchants.php';
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class XmlSpec
|
7 |
+
*/
|
8 |
+
final class XmlSpec
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* @var bool
|
12 |
+
*/
|
13 |
+
public $xml = false;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* XmlSpec constructor.
|
17 |
+
* @param $spec
|
18 |
+
*/
|
19 |
+
public function __construct( $spec, $export_id = false )
|
20 |
+
{
|
21 |
+
$this->xml = class_exists($spec) ? new $spec( $export_id ) : false;
|
22 |
+
}
|
23 |
+
|
24 |
+
|
25 |
+
}
|
models/export/record.php
CHANGED
@@ -8,14 +8,14 @@ class PMXE_Export_Record extends PMXE_Model_Record {
|
|
8 |
*/
|
9 |
public function __construct($data = array()) {
|
10 |
parent::__construct($data);
|
11 |
-
$this->setTable(PMXE_Plugin::getInstance()->getTablePrefix() . 'exports');
|
12 |
-
}
|
13 |
|
14 |
public function set_html_content_type(){
|
15 |
return 'text/html';
|
16 |
}
|
17 |
|
18 |
-
|
19 |
{
|
20 |
// do not generate export bundle if not supported
|
21 |
if ( ! self::is_bundle_supported($this->options) ) return;
|
@@ -63,7 +63,53 @@ class PMXE_Export_Record extends PMXE_Model_Record {
|
|
63 |
$readme = __("The other two files in this zip are the export file containing all of your data and the import template for WP All Import. \n\nTo import this data, create a new import with WP All Import and upload this zip file.", "wp_all_export_plugin");
|
64 |
|
65 |
file_put_contents($bundle_dir . 'readme.txt', $readme);
|
66 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
file_put_contents($bundle_dir . $template, json_encode($templates));
|
69 |
|
@@ -74,9 +120,9 @@ class PMXE_Export_Record extends PMXE_Model_Record {
|
|
74 |
// else
|
75 |
// {
|
76 |
// $bundle_path = $export_dir . $friendly_name . '.zip';
|
77 |
-
// }
|
78 |
|
79 |
-
$bundle_path = $export_dir . $friendly_name . '.zip';
|
80 |
|
81 |
if ( @file_exists($bundle_path))
|
82 |
{
|
@@ -99,7 +145,7 @@ class PMXE_Export_Record extends PMXE_Model_Record {
|
|
99 |
|
100 |
public function fix_template_options()
|
101 |
{
|
102 |
-
// migrate media options since @version 1.
|
103 |
if ( empty($this->options['migration']) )
|
104 |
{
|
105 |
$options = $this->options;
|
@@ -137,7 +183,7 @@ class PMXE_Export_Record extends PMXE_Model_Record {
|
|
137 |
'cc_options' => empty($options['cc_options'][$ID]) ? '' : $options['cc_options'][$ID],
|
138 |
'cc_value' => empty($options['cc_value'][$ID]) ? '' : $options['cc_value'][$ID],
|
139 |
'cc_name' => empty($options['cc_name'][$ID]) ? '' : $options['cc_name'][$ID],
|
140 |
-
'cc_settings' => empty($options['cc_settings'][$ID]) ? '' : $options['cc_settings'][$ID]
|
141 |
);
|
142 |
|
143 |
switch ($field['cc_type'])
|
@@ -169,7 +215,7 @@ class PMXE_Export_Record extends PMXE_Model_Record {
|
|
169 |
}
|
170 |
|
171 |
$field_name = $field['cc_name'];
|
172 |
-
$field['cc_name'] .= '_images';
|
173 |
$field['cc_options'] = '{"is_export_featured":true,"is_export_attached":true,"image_separator":"|"}';
|
174 |
|
175 |
$fields[] = $field;
|
@@ -231,7 +277,7 @@ class PMXE_Export_Record extends PMXE_Model_Record {
|
|
231 |
$options['cc_value'][] = $field['cc_value'];
|
232 |
$options['cc_name'][] = $field['cc_name'];
|
233 |
$options['cc_settings'][] = $field['cc_settings'];
|
234 |
-
}
|
235 |
|
236 |
$this->set(array('options' => $options))->save();
|
237 |
}
|
@@ -241,7 +287,10 @@ class PMXE_Export_Record extends PMXE_Model_Record {
|
|
241 |
|
242 |
public static function is_bundle_supported( $options )
|
243 |
{
|
244 |
-
|
|
|
|
|
|
|
245 |
return ( empty($options['cpt']) and ! in_array($options['wp_query_selector'], array('wp_comment_query')) or ! empty($options['cpt']) and ! in_array($options['cpt'][0], $unsupported_post_types) ) ? true : false;
|
246 |
}
|
247 |
|
8 |
*/
|
9 |
public function __construct($data = array()) {
|
10 |
parent::__construct($data);
|
11 |
+
$this->setTable(PMXE_Plugin::getInstance()->getTablePrefix() . 'exports');
|
12 |
+
}
|
13 |
|
14 |
public function set_html_content_type(){
|
15 |
return 'text/html';
|
16 |
}
|
17 |
|
18 |
+
public function generate_bundle( $debug = false)
|
19 |
{
|
20 |
// do not generate export bundle if not supported
|
21 |
if ( ! self::is_bundle_supported($this->options) ) return;
|
63 |
$readme = __("The other two files in this zip are the export file containing all of your data and the import template for WP All Import. \n\nTo import this data, create a new import with WP All Import and upload this zip file.", "wp_all_export_plugin");
|
64 |
|
65 |
file_put_contents($bundle_dir . 'readme.txt', $readme);
|
66 |
+
}
|
67 |
+
|
68 |
+
// [ Add child exports to the bundle]
|
69 |
+
$exportList = new PMXE_Export_List();
|
70 |
+
|
71 |
+
foreach ($exportList->getBy('parent_id', $this->id)->convertRecords() as $child_export)
|
72 |
+
{
|
73 |
+
$is_generate_child_template = true;
|
74 |
+
|
75 |
+
switch ($child_export->export_post_type)
|
76 |
+
{
|
77 |
+
case 'product':
|
78 |
+
if ( ! $this->options['order_include_poducts'] ) $is_generate_child_template = false;
|
79 |
+
break;
|
80 |
+
case 'shop_coupon':
|
81 |
+
if ( ! $this->options['order_include_coupons'] ) $is_generate_child_template = false;
|
82 |
+
break;
|
83 |
+
case 'shop_customer':
|
84 |
+
if ( ! $this->options['order_include_customers'] ) $is_generate_child_template = false;
|
85 |
+
break;
|
86 |
+
}
|
87 |
+
|
88 |
+
if ( ! $is_generate_child_template ) continue;
|
89 |
+
|
90 |
+
if ( ! $is_secure_import)
|
91 |
+
{
|
92 |
+
$filepath = get_attached_file($child_export->attch_id);
|
93 |
+
}
|
94 |
+
else
|
95 |
+
{
|
96 |
+
$filepath = wp_all_export_get_absolute_path($child_export->options['filepath']);
|
97 |
+
}
|
98 |
+
|
99 |
+
if ( ! empty($child_export->options['tpl_data']))
|
100 |
+
{
|
101 |
+
$template_data = array($child_export->options['tpl_data']);
|
102 |
+
|
103 |
+
$template_data[0]['source_file_name'] = basename($filepath);
|
104 |
+
|
105 |
+
$template_key = ($child_export->export_post_type == 'shop_customer') ? 'import_users' : $child_export->export_post_type;
|
106 |
+
|
107 |
+
$templates[$template_key] = $template_data;
|
108 |
+
}
|
109 |
+
|
110 |
+
@copy( $filepath, $bundle_dir . basename($filepath) );
|
111 |
+
}
|
112 |
+
// \[ Add child exports to the bundle]
|
113 |
|
114 |
file_put_contents($bundle_dir . $template, json_encode($templates));
|
115 |
|
120 |
// else
|
121 |
// {
|
122 |
// $bundle_path = $export_dir . $friendly_name . '.zip';
|
123 |
+
// }
|
124 |
|
125 |
+
$bundle_path = $export_dir . $friendly_name . '.zip';
|
126 |
|
127 |
if ( @file_exists($bundle_path))
|
128 |
{
|
145 |
|
146 |
public function fix_template_options()
|
147 |
{
|
148 |
+
// migrate media options since @version 1.2.4
|
149 |
if ( empty($this->options['migration']) )
|
150 |
{
|
151 |
$options = $this->options;
|
183 |
'cc_options' => empty($options['cc_options'][$ID]) ? '' : $options['cc_options'][$ID],
|
184 |
'cc_value' => empty($options['cc_value'][$ID]) ? '' : $options['cc_value'][$ID],
|
185 |
'cc_name' => empty($options['cc_name'][$ID]) ? '' : $options['cc_name'][$ID],
|
186 |
+
'cc_settings' => empty($options['cc_settings'][$ID]) ? '' : $options['cc_settings'][$ID],
|
187 |
);
|
188 |
|
189 |
switch ($field['cc_type'])
|
215 |
}
|
216 |
|
217 |
$field_name = $field['cc_name'];
|
218 |
+
$field['cc_name'] .= '_images';
|
219 |
$field['cc_options'] = '{"is_export_featured":true,"is_export_attached":true,"image_separator":"|"}';
|
220 |
|
221 |
$fields[] = $field;
|
277 |
$options['cc_value'][] = $field['cc_value'];
|
278 |
$options['cc_name'][] = $field['cc_name'];
|
279 |
$options['cc_settings'][] = $field['cc_settings'];
|
280 |
+
}
|
281 |
|
282 |
$this->set(array('options' => $options))->save();
|
283 |
}
|
287 |
|
288 |
public static function is_bundle_supported( $options )
|
289 |
{
|
290 |
+
// custom XML template do not support import bundle
|
291 |
+
if ( $options['export_to'] == 'xml' && ! empty($options['xml_template_type']) && in_array($options['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ) return false;
|
292 |
+
|
293 |
+
$unsupported_post_types = array('comments');
|
294 |
return ( empty($options['cpt']) and ! in_array($options['wp_query_selector'], array('wp_comment_query')) or ! empty($options['cpt']) and ! in_array($options['cpt'][0], $unsupported_post_types) ) ? true : false;
|
295 |
}
|
296 |
|
readme.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
=== Export WordPress data to XML/CSV ===
|
2 |
Contributors: soflyy, wpallimport
|
3 |
Requires at least: 4.1
|
4 |
-
Tested up to: 4.6
|
5 |
-
Stable tag: 1.0.
|
6 |
Tags: wordpress csv export, wordpress xml export, xml, csv, datafeed, export, migrate, export csv from wordpress, export xml from wordpress, advanced xml export, advanced csv export, export data, bulk csv export, export custom post type, export woocommerce products, export woocommerce orders, migrate woocommerce, csv export, export csv, xml export, export xml, csv exporter, datafeed
|
7 |
|
8 |
WP All Export is an extremely powerful exporter that makes it easy to export any XML or CSV file from WordPress.
|
@@ -78,6 +78,19 @@ Either: -
|
|
78 |
|
79 |
== Changelog ==
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
= 1.0.7 =
|
82 |
* fixed db schema for multisite
|
83 |
* fixed export order items date
|
1 |
=== Export WordPress data to XML/CSV ===
|
2 |
Contributors: soflyy, wpallimport
|
3 |
Requires at least: 4.1
|
4 |
+
Tested up to: 4.6.1
|
5 |
+
Stable tag: 1.0.8
|
6 |
Tags: wordpress csv export, wordpress xml export, xml, csv, datafeed, export, migrate, export csv from wordpress, export xml from wordpress, advanced xml export, advanced csv export, export data, bulk csv export, export custom post type, export woocommerce products, export woocommerce orders, migrate woocommerce, csv export, export csv, xml export, export xml, csv exporter, datafeed
|
7 |
|
8 |
WP All Export is an extremely powerful exporter that makes it easy to export any XML or CSV file from WordPress.
|
78 |
|
79 |
== Changelog ==
|
80 |
|
81 |
+
= 1.0.8 =
|
82 |
+
* improvement: pull the parent taxonomy data when exporting variations
|
83 |
+
* improvement: remove spaces from export filename
|
84 |
+
* improvement: new filter wp_all_export_after_csv_line
|
85 |
+
* improvement: date options for sale price dates from/to
|
86 |
+
* improvement: possibility to use tab as csv delimiter
|
87 |
+
* improvement: new filter 'wp_all_export_csv_headers'
|
88 |
+
* bug fix: db schema on multisite
|
89 |
+
* bug fix: import template for media items
|
90 |
+
* bug fix: export ACF repeater in XML format
|
91 |
+
* bug fix: export in CSV format when 'Main XML Tag' & 'Record XML Tag' option are blank
|
92 |
+
* bug fix: export ACF date_time_picker
|
93 |
+
|
94 |
= 1.0.7 =
|
95 |
* fixed db schema for multisite
|
96 |
* fixed export order items date
|
schema.php
CHANGED
@@ -41,7 +41,7 @@ CREATE TABLE {$table_prefix}templates (
|
|
41 |
CREATE TABLE {$table_prefix}exports (
|
42 |
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
43 |
parent_id BIGINT(20) NOT NULL DEFAULT 0,
|
44 |
-
attch_id BIGINT(20)
|
45 |
options LONGTEXT,
|
46 |
scheduled VARCHAR(64) NOT NULL DEFAULT '',
|
47 |
registered_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
41 |
CREATE TABLE {$table_prefix}exports (
|
42 |
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
43 |
parent_id BIGINT(20) NOT NULL DEFAULT 0,
|
44 |
+
attch_id BIGINT(20) NOT NULL DEFAULT 0,
|
45 |
options LONGTEXT,
|
46 |
scheduled VARCHAR(64) NOT NULL DEFAULT '',
|
47 |
registered_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
static/codemirror/autorefresh.js
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"))
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod)
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror)
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict"
|
13 |
+
|
14 |
+
CodeMirror.defineOption("autoRefresh", false, function(cm, val) {
|
15 |
+
if (cm.state.autoRefresh) {
|
16 |
+
stopListening(cm, cm.state.autoRefresh)
|
17 |
+
cm.state.autoRefresh = null
|
18 |
+
}
|
19 |
+
if (val && cm.display.wrapper.offsetHeight == 0)
|
20 |
+
startListening(cm, cm.state.autoRefresh = {delay: val.delay || 250})
|
21 |
+
})
|
22 |
+
|
23 |
+
function startListening(cm, state) {
|
24 |
+
function check() {
|
25 |
+
if (cm.display.wrapper.offsetHeight) {
|
26 |
+
stopListening(cm, state)
|
27 |
+
if (cm.display.lastWrapHeight != cm.display.wrapper.clientHeight)
|
28 |
+
cm.refresh()
|
29 |
+
} else {
|
30 |
+
state.timeout = setTimeout(check, state.delay)
|
31 |
+
}
|
32 |
+
}
|
33 |
+
state.timeout = setTimeout(check, state.delay)
|
34 |
+
state.hurry = function() {
|
35 |
+
clearTimeout(state.timeout)
|
36 |
+
state.timeout = setTimeout(check, 50)
|
37 |
+
}
|
38 |
+
CodeMirror.on(window, "mouseup", state.hurry)
|
39 |
+
CodeMirror.on(window, "keyup", state.hurry)
|
40 |
+
}
|
41 |
+
|
42 |
+
function stopListening(_cm, state) {
|
43 |
+
clearTimeout(state.timeout)
|
44 |
+
CodeMirror.off(window, "mouseup", state.hurry)
|
45 |
+
CodeMirror.off(window, "keyup", state.hurry)
|
46 |
+
}
|
47 |
+
});
|
static/codemirror/codemirror.css
CHANGED
@@ -42,7 +42,7 @@
|
|
42 |
/* CURSOR */
|
43 |
|
44 |
.CodeMirror-cursor {
|
45 |
-
border-left:
|
46 |
border-right: none;
|
47 |
width: 0;
|
48 |
}
|
@@ -105,7 +105,7 @@
|
|
105 |
.cm-strikethrough {text-decoration: line-through;}
|
106 |
|
107 |
.cm-s-default .cm-keyword {color: #708;}
|
108 |
-
.cm-s-default .cm-atom {color: #
|
109 |
.cm-s-default .cm-number {color: #164;}
|
110 |
.cm-s-default .cm-def {color: #00f;}
|
111 |
.cm-s-default .cm-variable,
|
@@ -318,8 +318,11 @@ div.CodeMirror-dragcursors {
|
|
318 |
}
|
319 |
|
320 |
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
|
321 |
-
.CodeMirror span { *vertical-align: text-bottom; }
|
322 |
-
|
|
|
|
|
|
|
323 |
/* Used to force a border model for a node */
|
324 |
.cm-force-border { padding-right: .1px; }
|
325 |
|
42 |
/* CURSOR */
|
43 |
|
44 |
.CodeMirror-cursor {
|
45 |
+
border-left: 2px solid black;
|
46 |
border-right: none;
|
47 |
width: 0;
|
48 |
}
|
105 |
.cm-strikethrough {text-decoration: line-through;}
|
106 |
|
107 |
.cm-s-default .cm-keyword {color: #708;}
|
108 |
+
.cm-s-default .cm-atom {color: #000;}
|
109 |
.cm-s-default .cm-number {color: #164;}
|
110 |
.cm-s-default .cm-def {color: #00f;}
|
111 |
.cm-s-default .cm-variable,
|
318 |
}
|
319 |
|
320 |
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
|
321 |
+
.CodeMirror span { *vertical-align: text-bottom; font-weight: bold;}
|
322 |
+
.CodeMirror span span { font-weight: normal; }
|
323 |
+
.CodeMirror span span.cm-string, .CodeMirror span span.cm-atom{
|
324 |
+
font-weight: bold;
|
325 |
+
}
|
326 |
/* Used to force a border model for a node */
|
327 |
.cm-force-border { padding-right: .1px; }
|
328 |
|
static/codemirror/codemirror.js
CHANGED
@@ -7609,7 +7609,14 @@
|
|
7609 |
});
|
7610 |
return index;
|
7611 |
},
|
7612 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7613 |
copy: function(copyHistory) {
|
7614 |
var doc = new Doc(getLines(this, this.first, this.first + this.size),
|
7615 |
this.modeOption, this.first, this.lineSep);
|
@@ -8838,3 +8845,53 @@
|
|
8838 |
|
8839 |
return CodeMirror;
|
8840 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7609 |
});
|
7610 |
return index;
|
7611 |
},
|
7612 |
+
removeLine: function(line) {
|
7613 |
+
if (isLine(this, line))
|
7614 |
+
if (line === this.lastLine() && line > this.firstLine()) {
|
7615 |
+
replaceRange(this, "", Pos(line - 1, getLine(this, line - 1).text.length), Pos(line, getLine(this, line).text.length));
|
7616 |
+
} else {
|
7617 |
+
replaceRange(this, "", Pos(line, 0), clipPos(this, Pos(line + 1, 0)));
|
7618 |
+
}
|
7619 |
+
},
|
7620 |
copy: function(copyHistory) {
|
7621 |
var doc = new Doc(getLines(this, this.first, this.first + this.size),
|
7622 |
this.modeOption, this.first, this.lineSep);
|
8845 |
|
8846 |
return CodeMirror;
|
8847 |
});
|
8848 |
+
|
8849 |
+
// Applies automatic formatting to the specified range
|
8850 |
+
CodeMirror.defineExtension("autoFormatRange", function (from, to) {
|
8851 |
+
var cm = this;
|
8852 |
+
var outer = cm.getMode(), text = cm.getRange(from, to).split("\n");
|
8853 |
+
var state = CodeMirror.copyState(outer, cm.getTokenAt(from).state);
|
8854 |
+
var tabSize = cm.getOption("tabSize");
|
8855 |
+
|
8856 |
+
var out = "", lines = 0, atSol = from.ch == 0;
|
8857 |
+
function newline() {
|
8858 |
+
out += "\n";
|
8859 |
+
atSol = true;
|
8860 |
+
++lines;
|
8861 |
+
}
|
8862 |
+
|
8863 |
+
for (var i = 0; i < text.length; ++i) {
|
8864 |
+
var stream = new CodeMirror.StringStream(text[i], tabSize);
|
8865 |
+
while (!stream.eol()) {
|
8866 |
+
var inner = CodeMirror.innerMode(outer, state);
|
8867 |
+
var style = outer.token(stream, state), cur = stream.current();
|
8868 |
+
stream.start = stream.pos;
|
8869 |
+
if (!atSol || /\S/.test(cur)) {
|
8870 |
+
out += cur;
|
8871 |
+
atSol = false;
|
8872 |
+
}
|
8873 |
+
if (!atSol && inner.mode.newlineAfterToken &&
|
8874 |
+
inner.mode.newlineAfterToken(style, cur, stream.string.slice(stream.pos) || text[i+1] || "", inner.state))
|
8875 |
+
newline();
|
8876 |
+
}
|
8877 |
+
if (!stream.pos && outer.blankLine) outer.blankLine(state);
|
8878 |
+
if (!atSol) newline();
|
8879 |
+
}
|
8880 |
+
|
8881 |
+
cm.operation(function () {
|
8882 |
+
cm.replaceRange(out, from, to);
|
8883 |
+
for (var cur = from.line + 1, end = from.line + lines; cur <= end; ++cur)
|
8884 |
+
cm.indentLine(cur, "smart");
|
8885 |
+
cm.setSelection(from, cm.getCursor(false));
|
8886 |
+
});
|
8887 |
+
});
|
8888 |
+
|
8889 |
+
// Applies automatic mode-aware indentation to the specified range
|
8890 |
+
CodeMirror.defineExtension("autoIndentRange", function (from, to) {
|
8891 |
+
var cmInstance = this;
|
8892 |
+
this.operation(function () {
|
8893 |
+
for (var i = from.line; i <= to.line; i++) {
|
8894 |
+
cmInstance.indentLine(i, "smart");
|
8895 |
+
}
|
8896 |
+
});
|
8897 |
+
});
|
static/css/admin.css
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
-
.wpallexport-plugin .
|
|
|
|
|
2 |
.wpallexport-plugin .add_column,
|
3 |
.wpallexport-plugin .wp_all_export_auto_generate_data,
|
4 |
.wpallexport-plugin .wp_all_export_clear_all_data{
|
@@ -16,6 +18,90 @@
|
|
16 |
border: none;
|
17 |
cursor: pointer;
|
18 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
.wpallexport-plugin .wp_all_export_auto_generate_data,
|
20 |
.wpallexport-plugin .wp_all_export_clear_all_data{
|
21 |
clear: none;
|
@@ -49,7 +135,7 @@
|
|
49 |
.wpallexport-plugin .wpallexport-free-edition-notice{
|
50 |
display: block;
|
51 |
margin: 5px;
|
52 |
-
padding:
|
53 |
text-align: center;
|
54 |
background-color: #FFB8B8;
|
55 |
border: 1px solid #FF8383;
|
@@ -86,7 +172,7 @@
|
|
86 |
list-style-type: none;
|
87 |
margin: 0;
|
88 |
padding: 0;
|
89 |
-
height: 250px;
|
90 |
/*width: 450px; */
|
91 |
}
|
92 |
.wpallexport-plugin #columns_to_export li {
|
@@ -112,6 +198,13 @@
|
|
112 |
margin-left: 0;
|
113 |
overflow: auto;
|
114 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
.wpallexport-plugin .av-state-default{
|
116 |
overflow: hidden;
|
117 |
height: 100%;
|
@@ -138,7 +231,8 @@
|
|
138 |
overflow: hidden;
|
139 |
}
|
140 |
.wpallexport-plugin #available_data .title,
|
141 |
-
.wpallexport-plugin .wp-all-export-edit-column .title
|
|
|
142 |
font-weight: bold;
|
143 |
padding: 12px 8px;
|
144 |
color: #464646;
|
@@ -153,7 +247,18 @@
|
|
153 |
-webkit-border-top-right-radius: 4px;
|
154 |
border-top-right-radius: 4px;
|
155 |
}
|
156 |
-
.wpallexport-plugin .wp-all-export-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
|
158 |
position: fixed;
|
159 |
top: 8%;
|
@@ -164,7 +269,8 @@
|
|
164 |
margin-bottom: 20px;
|
165 |
padding: 0 !important;
|
166 |
}
|
167 |
-
.wpallexport-plugin .wp-all-export-edit-column form
|
|
|
168 |
/*padding: 10px;*/
|
169 |
background: #fff;
|
170 |
}
|
@@ -183,17 +289,20 @@
|
|
183 |
.wpallexport-plugin .wp-all-export-sku-warning,
|
184 |
.wpallexport-plugin .wp-all-export-advanced-query-warning,
|
185 |
.wpallexport-plugin .wp-all-export-product-type-warning{
|
186 |
-
|
187 |
-
padding: 3px 6px;
|
188 |
-
background: #fef7f1;
|
189 |
-
margin-top: 10px;*/
|
190 |
clear: both;
|
191 |
background: none repeat scroll 0 0 #fff;
|
192 |
-
border-left: 4px solid #
|
193 |
box-shadow: 0 0 2px 1px rgba(0, 0, 0, 0.1);
|
194 |
margin: 0;
|
195 |
padding: 1px 12px;
|
196 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
.wpallexport-plugin .wpallexport-csv-delimiter{
|
198 |
float: right;
|
199 |
position: relative;
|
@@ -349,6 +458,22 @@
|
|
349 |
height: auto;
|
350 |
/*max-height: 500px; */
|
351 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
/*--------------------------------------------------------------------------
|
353 |
*
|
354 |
* Basic rules
|
@@ -786,7 +911,7 @@
|
|
786 |
height:25px;
|
787 |
padding-left: 20px;
|
788 |
color:#21759B;
|
789 |
-
font-family: "Open Sans",sans-serif
|
790 |
padding-top: 2px;
|
791 |
text-decoration: underline;
|
792 |
display: block;
|
@@ -2514,7 +2639,7 @@
|
|
2514 |
}
|
2515 |
.wpallexport-plugin .wpallexport-cf-menu li a{
|
2516 |
padding: 0;
|
2517 |
-
font-family: "Open Sans",sans-serif
|
2518 |
font-size: 12px;
|
2519 |
display: inline;
|
2520 |
color: #777;
|
@@ -3056,6 +3181,9 @@
|
|
3056 |
padding-left: 0px;
|
3057 |
display: inline;
|
3058 |
}
|
|
|
|
|
|
|
3059 |
.wpallexport-plugin .xml-tag {
|
3060 |
display: inline;
|
3061 |
}
|
1 |
+
.wpallexport-plugin .help_custom_xml,
|
2 |
+
.wpallexport-plugin .preview_a_custom_xml_row,
|
3 |
+
.wpallexport-plugin .preview_a_row,
|
4 |
.wpallexport-plugin .add_column,
|
5 |
.wpallexport-plugin .wp_all_export_auto_generate_data,
|
6 |
.wpallexport-plugin .wp_all_export_clear_all_data{
|
18 |
border: none;
|
19 |
cursor: pointer;
|
20 |
}
|
21 |
+
.wpallexport-plugin .custom_xml_upgrade_notice,
|
22 |
+
.wpallexport-plugin .disabled_fields_upgrade_notice{
|
23 |
+
display: none;
|
24 |
+
}
|
25 |
+
.wpallexport-plugin .wp_all_export_disabled_button{
|
26 |
+
background: #e4e6e6 !important;
|
27 |
+
color: #777 !important;
|
28 |
+
cursor: default !important;
|
29 |
+
}
|
30 |
+
.wpallexport-plugin .wp_all_export_custom_xml_help{
|
31 |
+
padding: 15px;
|
32 |
+
background: #fff;
|
33 |
+
font-size: 12px;
|
34 |
+
/*max-height: 600px;*/
|
35 |
+
overflow: auto;
|
36 |
+
}
|
37 |
+
.wpallexport-plugin .wp_all_export_custom_xml_help p{
|
38 |
+
font-size: 12px;
|
39 |
+
padding-left: 11px;
|
40 |
+
}
|
41 |
+
.wpallexport-plugin .wp_all_export_custom_xml_help ul{
|
42 |
+
list-style: inside;
|
43 |
+
padding-left: 12px;
|
44 |
+
}
|
45 |
+
.wpallexport-plugin .wp_all_export_custom_xml_help h2{
|
46 |
+
margin: 0;
|
47 |
+
}
|
48 |
+
.wpallexport-plugin .wp_all_export_custom_xml_help h3{
|
49 |
+
color: #40acad;
|
50 |
+
cursor: pointer;
|
51 |
+
/*font-family: "Open Sans",sans-serif;*/
|
52 |
+
font-size: 14px;
|
53 |
+
font-weight: normal;
|
54 |
+
margin: 5px 0;
|
55 |
+
}
|
56 |
+
|
57 |
+
.wpallexport-plugin .code-block {
|
58 |
+
border-radius: 2px 2px 2px 2px;
|
59 |
+
-moz-border-radius: 2px 2px 2px 2px;
|
60 |
+
-webkit-border-radius: 2px 2px 2px 2px;
|
61 |
+
border: 0px solid #000000;
|
62 |
+
background-color: #F1F1F1;
|
63 |
+
padding-top: 10px;
|
64 |
+
padding-bottom: 10px;
|
65 |
+
}
|
66 |
+
|
67 |
+
.wpallexport-plugin .wp_all_export_code{
|
68 |
+
font-family: monospace;
|
69 |
+
font-size: 12px;
|
70 |
+
}
|
71 |
+
.wpallexport-plugin .wp_all_export_code .wp_all_export_code_comment{
|
72 |
+
color:#a50;
|
73 |
+
}
|
74 |
+
.wpallexport-plugin .wp_all_export_code .wp_all_export_code_tag{
|
75 |
+
color:#170;
|
76 |
+
}
|
77 |
+
.wpallexport-plugin .wp_all_export_code p.wp_all_export_code_comment,
|
78 |
+
.wpallexport-plugin .wp_all_export_code p.wp_all_export_code_tag{
|
79 |
+
margin: 0;
|
80 |
+
}
|
81 |
+
.wpallexport-plugin .wp_all_export_code .wp_all_export_code_tag.lv1,
|
82 |
+
.wpallexport-plugin .wp_all_export_code .wp_all_export_code_comment.lv1{
|
83 |
+
padding-left: 15px;
|
84 |
+
}
|
85 |
+
.wpallexport-plugin .wp_all_export_code .wp_all_export_code_tag.lv2,
|
86 |
+
.wpallexport-plugin .wp_all_export_code .wp_all_export_code_comment.lv2{
|
87 |
+
padding-left: 30px;
|
88 |
+
}
|
89 |
+
.wpallexport-plugin .wp_all_export_code .wp_all_export_code_tag.lv3,
|
90 |
+
.wpallexport-plugin .wp_all_export_code .wp_all_export_code_comment.lv3{
|
91 |
+
padding-left: 45px;
|
92 |
+
}
|
93 |
+
.wpallexport-plugin .wp_all_export_code .wp_all_export_code_tag .wp_all_export_code_text{
|
94 |
+
color:#000;
|
95 |
+
font-weight: bold;
|
96 |
+
}
|
97 |
+
.wpallexport-plugin .wp_all_export_code .wp_all_export_code_text{
|
98 |
+
color:#000;
|
99 |
+
font-weight: bold;
|
100 |
+
}
|
101 |
+
.wpallexport-plugin .wp_all_export_help_tab{
|
102 |
+
display: none;
|
103 |
+
padding-bottom: 15px;
|
104 |
+
}
|
105 |
.wpallexport-plugin .wp_all_export_auto_generate_data,
|
106 |
.wpallexport-plugin .wp_all_export_clear_all_data{
|
107 |
clear: none;
|
135 |
.wpallexport-plugin .wpallexport-free-edition-notice{
|
136 |
display: block;
|
137 |
margin: 5px;
|
138 |
+
padding: 20px;
|
139 |
text-align: center;
|
140 |
background-color: #FFB8B8;
|
141 |
border: 1px solid #FF8383;
|
172 |
list-style-type: none;
|
173 |
margin: 0;
|
174 |
padding: 0;
|
175 |
+
/*height: 250px; */
|
176 |
/*width: 450px; */
|
177 |
}
|
178 |
.wpallexport-plugin #columns_to_export li {
|
198 |
margin-left: 0;
|
199 |
overflow: auto;
|
200 |
}
|
201 |
+
.wpallexport-plugin .CodeMirror-line.pmxe-state-hover,
|
202 |
+
.wpallexport-plugin .CodeMirror-line.pmxe-state-default{
|
203 |
+
width: 100%;
|
204 |
+
height: 18px;
|
205 |
+
margin-left: 0;
|
206 |
+
overflow: auto;
|
207 |
+
}
|
208 |
.wpallexport-plugin .av-state-default{
|
209 |
overflow: hidden;
|
210 |
height: 100%;
|
231 |
overflow: hidden;
|
232 |
}
|
233 |
.wpallexport-plugin #available_data .title,
|
234 |
+
.wpallexport-plugin .wp-all-export-edit-column .title,
|
235 |
+
.wpallexport-plugin .wp-all-export-custom-xml-help .title{
|
236 |
font-weight: bold;
|
237 |
padding: 12px 8px;
|
238 |
color: #464646;
|
247 |
-webkit-border-top-right-radius: 4px;
|
248 |
border-top-right-radius: 4px;
|
249 |
}
|
250 |
+
.wpallexport-plugin .wp-all-export-custom-xml-help{
|
251 |
+
position: fixed;
|
252 |
+
top: 8%;
|
253 |
+
width: 515px;
|
254 |
+
z-index: 999999;
|
255 |
+
border: 1px solid #ccc;
|
256 |
+
display: none;
|
257 |
+
margin-bottom: 20px;
|
258 |
+
padding: 0 !important;
|
259 |
+
}
|
260 |
+
|
261 |
+
.wpallexport-plugin .wp-all-export-edit-column{
|
262 |
|
263 |
position: fixed;
|
264 |
top: 8%;
|
269 |
margin-bottom: 20px;
|
270 |
padding: 0 !important;
|
271 |
}
|
272 |
+
.wpallexport-plugin .wp-all-export-edit-column form,
|
273 |
+
.wpallexport-plugin .wp-all-export-custom-xml-help form{
|
274 |
/*padding: 10px;*/
|
275 |
background: #fff;
|
276 |
}
|
289 |
.wpallexport-plugin .wp-all-export-sku-warning,
|
290 |
.wpallexport-plugin .wp-all-export-advanced-query-warning,
|
291 |
.wpallexport-plugin .wp-all-export-product-type-warning{
|
292 |
+
position: relative;
|
|
|
|
|
|
|
293 |
clear: both;
|
294 |
background: none repeat scroll 0 0 #fff;
|
295 |
+
border-left: 4px solid #ffa500;
|
296 |
box-shadow: 0 0 2px 1px rgba(0, 0, 0, 0.1);
|
297 |
margin: 0;
|
298 |
padding: 1px 12px;
|
299 |
}
|
300 |
+
.wpallexport-plugin .wp-all-export-warning{
|
301 |
+
margin-top: 20px;
|
302 |
+
}
|
303 |
+
.wpallexport-plugin .wp-all-export-warning .notice-dismiss{
|
304 |
+
margin-top: 5px;
|
305 |
+
}
|
306 |
.wpallexport-plugin .wpallexport-csv-delimiter{
|
307 |
float: right;
|
308 |
position: relative;
|
458 |
height: auto;
|
459 |
/*max-height: 500px; */
|
460 |
}
|
461 |
+
|
462 |
+
.wp-all-export-custom-xml-drag-over{
|
463 |
+
border: none !important;
|
464 |
+
margin: 0;
|
465 |
+
padding: 0;
|
466 |
+
width: auto !important;
|
467 |
+
min-width: 350px;
|
468 |
+
text-align: left;
|
469 |
+
background: none !important;
|
470 |
+
}
|
471 |
+
|
472 |
+
.wp-all-export-custom-xml-drag-over .wpallexport-xml-element span{
|
473 |
+
color: #000;
|
474 |
+
font-weight: bold;
|
475 |
+
}
|
476 |
+
|
477 |
/*--------------------------------------------------------------------------
|
478 |
*
|
479 |
* Basic rules
|
911 |
height:25px;
|
912 |
padding-left: 20px;
|
913 |
color:#21759B;
|
914 |
+
/*font-family: "Open Sans",sans-serif;*/
|
915 |
padding-top: 2px;
|
916 |
text-decoration: underline;
|
917 |
display: block;
|
2639 |
}
|
2640 |
.wpallexport-plugin .wpallexport-cf-menu li a{
|
2641 |
padding: 0;
|
2642 |
+
/*font-family: "Open Sans",sans-serif;*/
|
2643 |
font-size: 12px;
|
2644 |
display: inline;
|
2645 |
color: #777;
|
3181 |
padding-left: 0px;
|
3182 |
display: inline;
|
3183 |
}
|
3184 |
+
.wpallexport-plugin .xml-content.textonly.cdata{
|
3185 |
+
color: #a50;
|
3186 |
+
}
|
3187 |
.wpallexport-plugin .xml-tag {
|
3188 |
display: inline;
|
3189 |
}
|
static/img/preloader.gif
ADDED
Binary file
|
static/js/admin.js
CHANGED
@@ -3,6 +3,24 @@
|
|
3 |
*/
|
4 |
(function($){$(function () {
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
if ( ! $('body.wpallexport-plugin').length) return; // do not execute any code if we are not on plugin page
|
7 |
|
8 |
// fix layout position
|
@@ -52,6 +70,48 @@
|
|
52 |
});
|
53 |
}
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
// swither show/hide logic
|
56 |
$('input.switcher').live('change', function (e) {
|
57 |
|
@@ -116,12 +176,19 @@
|
|
116 |
$('.wpallexport-collapsed').find('.wpallexport-collapsed-header').live('click', function(){
|
117 |
var $parent = $(this).parents('.wpallexport-collapsed:first');
|
118 |
if ($parent.hasClass('closed')){
|
|
|
119 |
$parent.removeClass('closed');
|
120 |
-
$parent.find('.wpallexport-collapsed-content:first').slideDown()
|
|
|
|
|
|
|
|
|
|
|
121 |
}
|
122 |
else{
|
123 |
$parent.addClass('closed');
|
124 |
$parent.find('.wpallexport-collapsed-content:first').slideUp();
|
|
|
125 |
}
|
126 |
});
|
127 |
|
@@ -201,8 +268,12 @@
|
|
201 |
|
202 |
var warning_template = $('#warning_template').length ? $('#warning_template').val().replace("%s", fields) : '';
|
203 |
|
204 |
-
|
205 |
-
|
|
|
|
|
|
|
|
|
206 |
}
|
207 |
else
|
208 |
{
|
@@ -449,7 +520,8 @@
|
|
449 |
},
|
450 |
dataType: "json"
|
451 |
}).fail(function(xhr, textStatus, error) {
|
452 |
-
$('.
|
|
|
453 |
});
|
454 |
|
455 |
}
|
@@ -691,9 +763,67 @@
|
|
691 |
|
692 |
var $sortable = $( "#columns" );
|
693 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
694 |
$( "#available_data li:not(.available_sub_section, .wpallexport_disabled)" ).draggable({
|
695 |
appendTo: "body",
|
696 |
-
helper: "clone"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
697 |
});
|
698 |
|
699 |
var outsideContainer = 0;
|
@@ -808,6 +938,64 @@
|
|
808 |
}
|
809 |
});
|
810 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
811 |
var $this = $(this);
|
812 |
var $addAnother = $this.find('input.add_column');
|
813 |
var $addAnotherForm = $('fieldset.wp-all-export-edit-column');
|
@@ -891,6 +1079,8 @@
|
|
891 |
var $elementType = $addAnotherForm.find('select[name=column_value_type]');
|
892 |
// element label, options and other stuff
|
893 |
var $elementDetails = $elementType.find('option:selected');
|
|
|
|
|
894 |
|
895 |
var $clone = ( $elementIndex ) ? $('#columns').find('.custom_column[rel='+ $elementIndex +']') : $template.clone(true);
|
896 |
|
@@ -928,8 +1118,12 @@
|
|
928 |
$sortable.find('li:last').append($clone.removeClass('template').fadeIn());
|
929 |
}
|
930 |
|
|
|
|
|
|
|
|
|
931 |
// set up additional element settings by element type
|
932 |
-
switch ( $
|
933 |
{
|
934 |
// save post date field format
|
935 |
case 'date':
|
@@ -1036,7 +1230,11 @@
|
|
1036 |
var $options = $(this).find('input[name^=cc_options]').val();
|
1037 |
var $settings = $(this).find('input[name^=cc_settings]').val();
|
1038 |
|
1039 |
-
|
|
|
|
|
|
|
|
|
1040 |
case 'sql':
|
1041 |
$addAnotherForm.find('textarea.column_value').val($(this).find('input[name^=cc_sql]').val());
|
1042 |
$addAnotherForm.find('.sql_field_type').show();
|
@@ -1081,11 +1279,12 @@
|
|
1081 |
});
|
1082 |
|
1083 |
if ($settings != 'php' && $settings != 'unix'){
|
1084 |
-
$('.pmxe_date_format').val($settings);
|
1085 |
$('.pmxe_date_format_wrapper').show();
|
1086 |
}
|
1087 |
-
else
|
1088 |
$('.pmxe_date_format').val('');
|
|
|
1089 |
$addAnotherForm.find('.date_field_type').show();
|
1090 |
break;
|
1091 |
default:
|
@@ -1120,15 +1319,15 @@
|
|
1120 |
});
|
1121 |
|
1122 |
// Preview export file
|
1123 |
-
var doPreview = function( ths, tagno ){
|
1124 |
|
1125 |
-
$('.wpallexport-overlay').show();
|
1126 |
|
1127 |
ths.pointer({
|
1128 |
content: '<div class="wpallexport-preview-preload wpallexport-pointer-preview"></div>',
|
1129 |
position: {
|
1130 |
edge: 'right',
|
1131 |
-
align: 'center'
|
1132 |
},
|
1133 |
pointerWidth: 715,
|
1134 |
close: function() {
|
@@ -1140,45 +1339,69 @@
|
|
1140 |
}
|
1141 |
}).pointer('open');
|
1142 |
|
1143 |
-
var $pointer = $('.wpallexport-pointer-preview').parents('.wp-pointer').first();
|
1144 |
|
1145 |
var $leftOffset = ($(window).width() - 715)/2;
|
1146 |
|
1147 |
-
$pointer.css({'position':'fixed', 'top' : '15%', 'left' : $leftOffset + 'px'});
|
1148 |
|
1149 |
var request = {
|
1150 |
-
action: 'wpae_preview',
|
1151 |
data: $('form.wpallexport-step-3').serialize(),
|
|
|
1152 |
tagno: tagno,
|
1153 |
-
security: wp_all_export_security
|
1154 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1155 |
|
1156 |
$.ajax({
|
1157 |
type: 'POST',
|
1158 |
-
url:
|
1159 |
data: request,
|
1160 |
-
success: function(response) {
|
1161 |
|
1162 |
ths.pointer({'content' : response.html});
|
1163 |
|
1164 |
$pointer.css({'position':'fixed', 'top' : '15%', 'left' : $leftOffset + 'px'});
|
1165 |
-
|
1166 |
-
var $preview = $('.wpallexport-preview');
|
1167 |
|
1168 |
$preview.parent('.wp-pointer-content').removeClass('wp-pointer-content').addClass('wpallexport-pointer-content');
|
1169 |
|
1170 |
$preview.find('.navigation a').unbind('click').die('click').live('click', function () {
|
1171 |
|
1172 |
-
tagno += '#prev' == $(this).attr('href') ? -1 : 1;
|
1173 |
|
1174 |
doPreview(ths, tagno);
|
1175 |
|
1176 |
});
|
1177 |
|
1178 |
},
|
1179 |
-
error: function( jqXHR, textStatus ) {
|
1180 |
-
|
1181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1182 |
|
1183 |
},
|
1184 |
dataType: "json"
|
@@ -1190,6 +1413,34 @@
|
|
1190 |
doPreview($(this), 1);
|
1191 |
});
|
1192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1193 |
$('.wpae-available-fields-group').click(function(){
|
1194 |
var $mode = $(this).find('.wpae-expander').text();
|
1195 |
$(this).next('div').slideToggle();
|
@@ -1232,7 +1483,7 @@
|
|
1232 |
|
1233 |
var wp_all_export_config = {
|
1234 |
'.wp-all-export-chosen-select' : {width:"50%"}
|
1235 |
-
}
|
1236 |
|
1237 |
for (var selector in wp_all_export_config) {
|
1238 |
$(selector).chosen(wp_all_export_config[selector]);
|
@@ -1340,35 +1591,139 @@
|
|
1340 |
// }
|
1341 |
|
1342 |
$('form.wpallexport-template').find('input[type=submit]').click(function(e){
|
1343 |
-
e.preventDefault();
|
1344 |
-
|
1345 |
-
$('
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1351 |
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1355 |
|
1356 |
$('.wpallexport-import-to-format').click(function(){
|
1357 |
|
|
|
|
|
1358 |
$('.wpallexport-import-to-format').removeClass('selected');
|
1359 |
$(this).addClass('selected');
|
1360 |
|
1361 |
if ($(this).hasClass('wpallexport-csv-type'))
|
1362 |
{
|
|
|
|
|
1363 |
$('.wpallexport-csv-options').show();
|
1364 |
$('.wpallexport-xml-options').hide();
|
|
|
|
|
|
|
|
|
1365 |
$('input[name=export_to]').val('csv');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1366 |
}
|
1367 |
else
|
1368 |
{
|
1369 |
$('.wpallexport-csv-options').hide();
|
1370 |
$('.wpallexport-xml-options').show();
|
1371 |
$('input[name=export_to]').val('xml');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1372 |
}
|
1373 |
});
|
1374 |
|
@@ -1380,7 +1735,39 @@
|
|
1380 |
var height = $(window).height();
|
1381 |
$('#available_data').find('.wpallexport-xml').css({'max-height': height - 125});
|
1382 |
|
1383 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1384 |
// [ \Step 2 ( export template ) ]
|
1385 |
|
1386 |
|
@@ -1520,44 +1907,7 @@
|
|
1520 |
else
|
1521 |
$('#wp_all_export_value').show();
|
1522 |
});
|
1523 |
-
|
1524 |
-
$('.wp_all_export_save_functions').click(function(){
|
1525 |
-
var request = {
|
1526 |
-
action: 'save_functions',
|
1527 |
-
data: editor.getValue(),
|
1528 |
-
security: wp_all_export_security
|
1529 |
-
};
|
1530 |
-
$('.wp_all_export_functions_preloader').show();
|
1531 |
-
$('.wp_all_export_saving_status').html('');
|
1532 |
-
|
1533 |
-
$.ajax({
|
1534 |
-
type: 'POST',
|
1535 |
-
url: get_valid_ajaxurl(),
|
1536 |
-
data: request,
|
1537 |
-
success: function(response) {
|
1538 |
-
$('.wp_all_export_functions_preloader').hide();
|
1539 |
-
|
1540 |
-
if (response.result)
|
1541 |
-
{
|
1542 |
-
$('.wp_all_export_saving_status').css({'color':'green'});
|
1543 |
-
setTimeout(function() {
|
1544 |
-
$('.wp_all_export_saving_status').html('').fadeOut();
|
1545 |
-
}, 3000);
|
1546 |
-
}
|
1547 |
-
else
|
1548 |
-
{
|
1549 |
-
$('.wp_all_export_saving_status').css({'color':'red'});
|
1550 |
-
}
|
1551 |
-
|
1552 |
-
$('.wp_all_export_saving_status').html(response.msg).show();
|
1553 |
-
|
1554 |
-
},
|
1555 |
-
error: function( jqXHR, textStatus ) {
|
1556 |
-
$('.wp_all_export_functions_preloader').hide();
|
1557 |
-
},
|
1558 |
-
dataType: "json"
|
1559 |
-
});
|
1560 |
-
});
|
1561 |
// auot-generate zapier API key
|
1562 |
$('input[name=pmxe_generate_zapier_api_key]').click(function(e){
|
1563 |
|
@@ -1582,11 +1932,83 @@
|
|
1582 |
});
|
1583 |
});
|
1584 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1585 |
$('.wpallexport-overlay').click(function(){
|
1586 |
$('.wp-pointer').hide();
|
1587 |
$('#columns').find('div.active').removeClass('active');
|
1588 |
$('fieldset.wp-all-export-edit-column').hide();
|
1589 |
-
|
|
|
1590 |
});
|
1591 |
|
1592 |
if ( $('.wpallexport-template').length )
|
@@ -1597,4 +2019,76 @@
|
|
1597 |
}
|
1598 |
// [ \Additional functionality ]
|
1599 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1600 |
});})(jQuery);
|
3 |
*/
|
4 |
(function($){$(function () {
|
5 |
|
6 |
+
var vm = {
|
7 |
+
'isWoocommerceOrderExport' : function(){
|
8 |
+
return $('#woo_commerce_order').length;
|
9 |
+
}
|
10 |
+
};
|
11 |
+
|
12 |
+
var helpers = {
|
13 |
+
'sanitizeElementName' : function($elementName) {
|
14 |
+
if($elementName.indexOf('(per tax)') !== false ){
|
15 |
+
$elementName = $elementName.replace('(per tax)','PerTax');
|
16 |
+
$elementName = $elementName.replace('(per coupon)','PerCoupon');
|
17 |
+
$elementName = $elementName.replace('(per surcharge)','PerSurcharge');
|
18 |
+
}
|
19 |
+
|
20 |
+
return $elementName;
|
21 |
+
}
|
22 |
+
};
|
23 |
+
|
24 |
if ( ! $('body.wpallexport-plugin').length) return; // do not execute any code if we are not on plugin page
|
25 |
|
26 |
// fix layout position
|
70 |
});
|
71 |
}
|
72 |
|
73 |
+
if ($('#wp_all_export_custom_xml_template').length)
|
74 |
+
{
|
75 |
+
var xml_editor = CodeMirror.fromTextArea(document.getElementById("wp_all_export_custom_xml_template"), {
|
76 |
+
lineNumbers: true,
|
77 |
+
matchBrackets: true,
|
78 |
+
mode: "xml",
|
79 |
+
indentUnit: 4,
|
80 |
+
indentWithTabs: true,
|
81 |
+
lineWrapping: true,
|
82 |
+
autoRefresh: true,
|
83 |
+
// dragDrop: true,
|
84 |
+
// handleMouseEvents: true
|
85 |
+
});
|
86 |
+
|
87 |
+
xml_editor.setCursor(1);
|
88 |
+
$('.CodeMirror').resizable({
|
89 |
+
resize: function() {
|
90 |
+
xml_editor.setSize("100%", $(this).height());
|
91 |
+
}
|
92 |
+
});
|
93 |
+
|
94 |
+
var xml_editor_doc = xml_editor.getDoc();
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
if ($('#wp_all_export_main_code').length){
|
99 |
+
var main_editor = CodeMirror.fromTextArea(document.getElementById("wp_all_export_main_code"), {
|
100 |
+
lineNumbers: true,
|
101 |
+
matchBrackets: true,
|
102 |
+
mode: "application/x-httpd-php",
|
103 |
+
indentUnit: 4,
|
104 |
+
indentWithTabs: true,
|
105 |
+
lineWrapping: true
|
106 |
+
});
|
107 |
+
main_editor.setCursor(1);
|
108 |
+
$('.CodeMirror').resizable({
|
109 |
+
resize: function() {
|
110 |
+
main_editor.setSize("100%", $(this).height());
|
111 |
+
}
|
112 |
+
});
|
113 |
+
}
|
114 |
+
|
115 |
// swither show/hide logic
|
116 |
$('input.switcher').live('change', function (e) {
|
117 |
|
176 |
$('.wpallexport-collapsed').find('.wpallexport-collapsed-header').live('click', function(){
|
177 |
var $parent = $(this).parents('.wpallexport-collapsed:first');
|
178 |
if ($parent.hasClass('closed')){
|
179 |
+
$parent.find('hr').show();
|
180 |
$parent.removeClass('closed');
|
181 |
+
$parent.find('.wpallexport-collapsed-content:first').slideDown(400, function(){
|
182 |
+
if ($('#wp_all_export_main_code').length) main_editor.setCursor(1);
|
183 |
+
if ($('#wp_all_export_custom_xml_template').length){
|
184 |
+
xml_editor.setCursor(1);
|
185 |
+
}
|
186 |
+
});
|
187 |
}
|
188 |
else{
|
189 |
$parent.addClass('closed');
|
190 |
$parent.find('.wpallexport-collapsed-content:first').slideUp();
|
191 |
+
$parent.find('hr').hide();
|
192 |
}
|
193 |
});
|
194 |
|
268 |
|
269 |
var warning_template = $('#warning_template').length ? $('#warning_template').val().replace("%s", fields) : '';
|
270 |
|
271 |
+
var is_dismiss_warnings = parseInt($('#dismiss_warnings').val());
|
272 |
+
|
273 |
+
if ( ! is_dismiss_warnings ) {
|
274 |
+
$('.wp-all-export-warning').find('p').html(warning_template);
|
275 |
+
$('.wp-all-export-warning').show();
|
276 |
+
}
|
277 |
}
|
278 |
else
|
279 |
{
|
520 |
},
|
521 |
dataType: "json"
|
522 |
}).fail(function(xhr, textStatus, error) {
|
523 |
+
$('div.error.inline').remove();
|
524 |
+
$('.wpallexport-header').next('.clear').after("<div class='error inline'><p>" + textStatus + " " + error + "</p></div>");
|
525 |
});
|
526 |
|
527 |
}
|
763 |
|
764 |
var $sortable = $( "#columns" );
|
765 |
|
766 |
+
var currentLine = -1;
|
767 |
+
|
768 |
+
function isDraggingOverTextEditor(event) {
|
769 |
+
var e = event.originalEvent.originalEvent.target;
|
770 |
+
return $.contains(xml_editor.display.scroller, e)
|
771 |
+
}
|
772 |
+
|
773 |
+
function addLine(str, line, ch) {
|
774 |
+
if(typeof ch === 'undefined') {
|
775 |
+
ch = 0;
|
776 |
+
}
|
777 |
+
xml_editor.replaceRange(str, {line: line, ch:0}, {line:line, ch:0});
|
778 |
+
}
|
779 |
+
|
780 |
+
function removeLine(line) {
|
781 |
+
xml_editor.removeLine(line);
|
782 |
+
}
|
783 |
+
|
784 |
$( "#available_data li:not(.available_sub_section, .wpallexport_disabled)" ).draggable({
|
785 |
appendTo: "body",
|
786 |
+
helper: "clone",
|
787 |
+
drag: function(e, ui)
|
788 |
+
{
|
789 |
+
if ( $('select.xml_template_type').val() == 'custom' && isDraggingOverTextEditor(e))
|
790 |
+
{
|
791 |
+
xml_editor.focus();
|
792 |
+
|
793 |
+
if ( ui.helper.find('.custom_column').length )
|
794 |
+
{
|
795 |
+
var $elementName = ui.helper.find('.custom_column').find('input[name^=cc_name]').val();
|
796 |
+
|
797 |
+
var $elementValue = $elementName;
|
798 |
+
$elementName = helpers.sanitizeElementName($elementName);
|
799 |
+
|
800 |
+
if ( ! ui.helper.find('.custom_column').hasClass('wp-all-export-custom-xml-drag-over') ) ui.helper.find('.custom_column').addClass('wp-all-export-custom-xml-drag-over');
|
801 |
+
ui.helper.find('.custom_column').find('.wpallexport-xml-element').html("<" + $elementName.replace(/ /g,'') + "><span>{" + $elementValue + "}</span></" + $elementName.replace(/ /g,'') + ">");
|
802 |
+
}
|
803 |
+
if ( ui.helper.find('.default_column').length )
|
804 |
+
{
|
805 |
+
var $elementName = ui.helper.find('.default_column').find('.wpallexport-element-label').html();
|
806 |
+
if ( ! ui.helper.find('.default_column').hasClass('wp-all-export-custom-xml-drag-over') ) ui.helper.find('.default_column').addClass('wp-all-export-custom-xml-drag-over');
|
807 |
+
}
|
808 |
+
|
809 |
+
var line = xml_editor.lineAtHeight(ui.position.top, 'page');
|
810 |
+
var ch = xml_editor.coordsChar(ui.position, 'page');
|
811 |
+
|
812 |
+
if( line == currentLine ) {
|
813 |
+
return;
|
814 |
+
}
|
815 |
+
|
816 |
+
if (currentLine != -1) {
|
817 |
+
removeLine(currentLine);
|
818 |
+
}
|
819 |
+
|
820 |
+
currentLine = line;
|
821 |
+
|
822 |
+
addLine("\n", line);
|
823 |
+
|
824 |
+
xml_editor_doc.setCursor({line:line, ch:ch.ch});
|
825 |
+
}
|
826 |
+
}
|
827 |
});
|
828 |
|
829 |
var outsideContainer = 0;
|
938 |
}
|
939 |
});
|
940 |
|
941 |
+
$( ".CodeMirror-code" ).droppable({
|
942 |
+
activeClass: "pmxe-template-state-default",
|
943 |
+
hoverClass: "pmxe-template-state-hover",
|
944 |
+
accept: ":not(.ui-sortable-helper)",
|
945 |
+
drag: function( event, ui ){
|
946 |
+
console.log(event);
|
947 |
+
},
|
948 |
+
drop: function( event, ui ) {
|
949 |
+
|
950 |
+
function getCodeToPlace($elementName) {
|
951 |
+
var $elementValue = $elementName;
|
952 |
+
$elementName = helpers.sanitizeElementName($elementName);
|
953 |
+
return "<" + $elementName.replace(/ /g,'') + ">{" + $elementValue+ "}</" + $elementName.replace(/ /g,'') + ">\n"
|
954 |
+
}
|
955 |
+
|
956 |
+
|
957 |
+
function replaceLineWithElements(content){
|
958 |
+
removeLine(currentLine);
|
959 |
+
|
960 |
+
addLine( content, currentLine, currentLine);
|
961 |
+
currentLine = -1;
|
962 |
+
|
963 |
+
var totalLines = xml_editor.lineCount();
|
964 |
+
xml_editor.autoIndentRange({line:0, ch:0}, {line:totalLines,ch:100});
|
965 |
+
}
|
966 |
+
|
967 |
+
function processElementName($element, $elementName){
|
968 |
+
if ( $element.find('input[name^=cc_type]').val().indexOf('image_') !== -1 )
|
969 |
+
{
|
970 |
+
$elementName = 'Image ' + $elementName;
|
971 |
+
}
|
972 |
+
if ( $element.find('input[name^=cc_type]').val().indexOf('attachment_') !== -1 )
|
973 |
+
{
|
974 |
+
$elementName = 'Attachment ' + $elementName;
|
975 |
+
}
|
976 |
+
return $elementName;
|
977 |
+
}
|
978 |
+
|
979 |
+
if (ui.draggable.find('input[name^=rules]').length){
|
980 |
+
var content = "";
|
981 |
+
$('li.' + ui.draggable.find('input[name^=rules]').val()).each(function(){
|
982 |
+
var $elementName = $(this).find('input[name^=cc_name]').val();
|
983 |
+
$elementName = processElementName($(this),$elementName);
|
984 |
+
content = content + getCodeToPlace($elementName);
|
985 |
+
});
|
986 |
+
|
987 |
+
replaceLineWithElements(content);
|
988 |
+
}
|
989 |
+
else{
|
990 |
+
var $elementName = ui.draggable.find('.custom_column').find('input[name^=cc_name]').val();
|
991 |
+
var $element = ui.draggable.find('.custom_column');
|
992 |
+
$elementName = processElementName($element, $elementName);
|
993 |
+
|
994 |
+
replaceLineWithElements(getCodeToPlace($elementName));
|
995 |
+
}
|
996 |
+
}
|
997 |
+
});
|
998 |
+
|
999 |
var $this = $(this);
|
1000 |
var $addAnother = $this.find('input.add_column');
|
1001 |
var $addAnotherForm = $('fieldset.wp-all-export-edit-column');
|
1079 |
var $elementType = $addAnotherForm.find('select[name=column_value_type]');
|
1080 |
// element label, options and other stuff
|
1081 |
var $elementDetails = $elementType.find('option:selected');
|
1082 |
+
// element labeel
|
1083 |
+
var $elementLabel = $elementDetails.attr('label');
|
1084 |
|
1085 |
var $clone = ( $elementIndex ) ? $('#columns').find('.custom_column[rel='+ $elementIndex +']') : $template.clone(true);
|
1086 |
|
1118 |
$sortable.find('li:last').append($clone.removeClass('template').fadeIn());
|
1119 |
}
|
1120 |
|
1121 |
+
var $fieldType = $elementType.val();
|
1122 |
+
|
1123 |
+
if ($elementLabel == '_sale_price_dates_from' || $elementLabel == '_sale_price_dates_to') $fieldType = 'date';
|
1124 |
+
|
1125 |
// set up additional element settings by element type
|
1126 |
+
switch ( $fieldType )
|
1127 |
{
|
1128 |
// save post date field format
|
1129 |
case 'date':
|
1230 |
var $options = $(this).find('input[name^=cc_options]').val();
|
1231 |
var $settings = $(this).find('input[name^=cc_settings]').val();
|
1232 |
|
1233 |
+
var $fieldType = $elementType.val();
|
1234 |
+
|
1235 |
+
if ($elementLabel.val() == '_sale_price_dates_from' || $elementLabel.val() == '_sale_price_dates_to') $fieldType = 'date';
|
1236 |
+
|
1237 |
+
switch ( $fieldType ){
|
1238 |
case 'sql':
|
1239 |
$addAnotherForm.find('textarea.column_value').val($(this).find('input[name^=cc_sql]').val());
|
1240 |
$addAnotherForm.find('.sql_field_type').show();
|
1279 |
});
|
1280 |
|
1281 |
if ($settings != 'php' && $settings != 'unix'){
|
1282 |
+
if ($settings != '0') $('.pmxe_date_format').val($settings); else $('.pmxe_date_format').val('');
|
1283 |
$('.pmxe_date_format_wrapper').show();
|
1284 |
}
|
1285 |
+
else{
|
1286 |
$('.pmxe_date_format').val('');
|
1287 |
+
}
|
1288 |
$addAnotherForm.find('.date_field_type').show();
|
1289 |
break;
|
1290 |
default:
|
1319 |
});
|
1320 |
|
1321 |
// Preview export file
|
1322 |
+
var doPreview = function( ths, tagno ){
|
1323 |
|
1324 |
+
$('.wpallexport-overlay').show();
|
1325 |
|
1326 |
ths.pointer({
|
1327 |
content: '<div class="wpallexport-preview-preload wpallexport-pointer-preview"></div>',
|
1328 |
position: {
|
1329 |
edge: 'right',
|
1330 |
+
align: 'center'
|
1331 |
},
|
1332 |
pointerWidth: 715,
|
1333 |
close: function() {
|
1339 |
}
|
1340 |
}).pointer('open');
|
1341 |
|
1342 |
+
var $pointer = $('.wpallexport-pointer-preview').parents('.wp-pointer').first();
|
1343 |
|
1344 |
var $leftOffset = ($(window).width() - 715)/2;
|
1345 |
|
1346 |
+
$pointer.css({'position':'fixed', 'top' : '15%', 'left' : $leftOffset + 'px'});
|
1347 |
|
1348 |
var request = {
|
1349 |
+
action: 'wpae_preview',
|
1350 |
data: $('form.wpallexport-step-3').serialize(),
|
1351 |
+
custom_xml: xml_editor.getValue(),
|
1352 |
tagno: tagno,
|
1353 |
+
security: wp_all_export_security
|
1354 |
+
};
|
1355 |
+
|
1356 |
+
var url = get_valid_ajaxurl();
|
1357 |
+
var show_cdata = $('#show_cdata_in_preview').val();
|
1358 |
+
|
1359 |
+
if (url.indexOf("?") == -1) {
|
1360 |
+
url += '?show_cdata=' + show_cdata;
|
1361 |
+
} else {
|
1362 |
+
url += '&show_cdata=' + show_cdata;
|
1363 |
+
}
|
1364 |
|
1365 |
$.ajax({
|
1366 |
type: 'POST',
|
1367 |
+
url: url,
|
1368 |
data: request,
|
1369 |
+
success: function(response) {
|
1370 |
|
1371 |
ths.pointer({'content' : response.html});
|
1372 |
|
1373 |
$pointer.css({'position':'fixed', 'top' : '15%', 'left' : $leftOffset + 'px'});
|
1374 |
+
|
1375 |
+
var $preview = $('.wpallexport-preview');
|
1376 |
|
1377 |
$preview.parent('.wp-pointer-content').removeClass('wp-pointer-content').addClass('wpallexport-pointer-content');
|
1378 |
|
1379 |
$preview.find('.navigation a').unbind('click').die('click').live('click', function () {
|
1380 |
|
1381 |
+
tagno += '#prev' == $(this).attr('href') ? -1 : 1;
|
1382 |
|
1383 |
doPreview(ths, tagno);
|
1384 |
|
1385 |
});
|
1386 |
|
1387 |
},
|
1388 |
+
error: function( jqXHR, textStatus ) {
|
1389 |
+
// Handle an eval error
|
1390 |
+
if(jqXHR.responseText.indexOf('[[ERROR]]') !== -1) {
|
1391 |
+
var json = jqXHR.responseText.split('[[ERROR]]')[1];
|
1392 |
+
json = $.parseJSON(json);
|
1393 |
+
ths.pointer({'content' : '<div id="post-preview" class="wpallexport-preview">' +
|
1394 |
+
'<p class="wpallexport-preview-title">' + json.title + '</p>\
|
1395 |
+
<div class="wpallexport-preview-content">'+json.error+'</div></div></div>'});
|
1396 |
+
|
1397 |
+
$pointer.css({'position':'fixed', 'top' : '15%', 'left' : $leftOffset + 'px'});
|
1398 |
+
|
1399 |
+
} else {
|
1400 |
+
ths.pointer({'content' : '<div id="post-preview" class="wpallexport-preview">' +
|
1401 |
+
'<p class="wpallexport-preview-title">An error occured</p>\
|
1402 |
+
<div class="wpallexport-preview-content">An unknown error occured</div></div></div>'});
|
1403 |
+
$pointer.css({'position':'fixed', 'top' : '15%', 'left' : $leftOffset + 'px'});
|
1404 |
+
}
|
1405 |
|
1406 |
},
|
1407 |
dataType: "json"
|
1413 |
doPreview($(this), 1);
|
1414 |
});
|
1415 |
|
1416 |
+
// preview custom XML template
|
1417 |
+
$(this).find('.preview_a_custom_xml_row').click(function(){
|
1418 |
+
doPreview($(this), 1);
|
1419 |
+
});
|
1420 |
+
|
1421 |
+
// help custom XML template
|
1422 |
+
$(this).find('.help_custom_xml').click(function(){
|
1423 |
+
$('.wp-all-export-custom-xml-help').css('left', ($( document ).width()/2) - 255 ).show();
|
1424 |
+
$('#wp-all-export-custom-xml-help-inner').css('max-height', $( window ).height()-150).show();
|
1425 |
+
$('.wpallexport-overlay').show();
|
1426 |
+
});
|
1427 |
+
|
1428 |
+
$('.wp_all_export_custom_xml_help').find('h3').click(function(){
|
1429 |
+
var $action = $(this).find('span').html();
|
1430 |
+
$('.wp_all_export_custom_xml_help').find('h3').each(function(){
|
1431 |
+
$(this).find('span').html("+");
|
1432 |
+
});
|
1433 |
+
if ( $action == "+" ) {
|
1434 |
+
$('.wp_all_export_help_tab').slideUp();
|
1435 |
+
$('.wp_all_export_help_tab[rel=' + $(this).attr('id') + ']').slideDown();
|
1436 |
+
$(this).find('span').html("-");
|
1437 |
+
}
|
1438 |
+
else{
|
1439 |
+
$('.wp_all_export_help_tab[rel=' + $(this).attr('id') + ']').slideUp();
|
1440 |
+
$(this).find('span').html("+");
|
1441 |
+
}
|
1442 |
+
});
|
1443 |
+
|
1444 |
$('.wpae-available-fields-group').click(function(){
|
1445 |
var $mode = $(this).find('.wpae-expander').text();
|
1446 |
$(this).next('div').slideToggle();
|
1483 |
|
1484 |
var wp_all_export_config = {
|
1485 |
'.wp-all-export-chosen-select' : {width:"50%"}
|
1486 |
+
};
|
1487 |
|
1488 |
for (var selector in wp_all_export_config) {
|
1489 |
$(selector).chosen(wp_all_export_config[selector]);
|
1591 |
// }
|
1592 |
|
1593 |
$('form.wpallexport-template').find('input[type=submit]').click(function(e){
|
1594 |
+
e.preventDefault();
|
1595 |
+
|
1596 |
+
$('#validationError').fadeOut();
|
1597 |
+
$('#validationError p').find('*').remove();
|
1598 |
+
|
1599 |
+
var submitButton = $(this);
|
1600 |
+
|
1601 |
+
// Validate the form by sending it to preview before submitting it
|
1602 |
+
var request = {
|
1603 |
+
action: 'wpae_preview',
|
1604 |
+
data: $('form.wpallexport-step-3').serialize(),
|
1605 |
+
custom_xml: xml_editor.getValue(),
|
1606 |
+
security: wp_all_export_security
|
1607 |
+
};
|
1608 |
+
|
1609 |
+
$.ajax({
|
1610 |
+
type: 'POST',
|
1611 |
+
url: get_valid_ajaxurl(),
|
1612 |
+
data: request,
|
1613 |
+
success: function(response) {
|
1614 |
+
|
1615 |
+
// Look for errors
|
1616 |
+
var tempDom = $('<div>').append($.parseHTML(response.html));
|
1617 |
+
var errorMessage = $('.error', tempDom);
|
1618 |
+
|
1619 |
+
// If we have error messages
|
1620 |
+
if(errorMessage.length) {
|
1621 |
+
// Display the error messages
|
1622 |
+
errorMessage.each(function(){
|
1623 |
+
$('#validationError').find('p').append($(this));
|
1624 |
+
});
|
1625 |
|
1626 |
+
$('#validationError').fadeIn();
|
1627 |
+
$('html, body').animate({scrollTop: $("#validationError").offset().top - 50});
|
1628 |
+
} else {
|
1629 |
+
// Else submit the form
|
1630 |
+
$('.hierarhy-output').each(function(){
|
1631 |
+
var sortable = $('.wp_all_export_filtering_rules.ui-sortable');
|
1632 |
+
if (sortable.length){
|
1633 |
+
$(this).val(window.JSON.stringify(sortable.pmxe_nestedSortable('toArray', {startDepthCount: 0})));
|
1634 |
+
}
|
1635 |
+
});
|
1636 |
+
submitButton.parents('form:first').submit();
|
1637 |
+
}
|
1638 |
+
},
|
1639 |
+
error: function( jqXHR, textStatus ) {
|
1640 |
+
$('#validationError p').html('');
|
1641 |
+
|
1642 |
+
// Handle an eval error
|
1643 |
+
if(jqXHR.responseText.indexOf('[[ERROR]]') != -1) {
|
1644 |
+
var json = jqXHR.responseText.split('[[ERROR]]')[1];
|
1645 |
+
json = $.parseJSON(json);
|
1646 |
+
|
1647 |
+
$('#validationError').find('p').append(json.error);
|
1648 |
+
$('#validationError').fadeIn();
|
1649 |
+
$('html, body').animate({scrollTop: $("#validationError").offset().top - 50});
|
1650 |
+
|
1651 |
+
} else {
|
1652 |
+
// We don't know the error
|
1653 |
+
$('#validationError').find('p').html('An unknown error occured');
|
1654 |
+
$('#validationError').fadeIn();
|
1655 |
+
$('html, body').animate({scrollTop: $("#validationError").offset().top - 50});
|
1656 |
+
}
|
1657 |
+
|
1658 |
+
},
|
1659 |
+
dataType: "json"
|
1660 |
+
});
|
1661 |
+
});
|
1662 |
+
}
|
1663 |
+
|
1664 |
+
if ( $('input[name=export_to]').val() == 'csv' && $('#export_to_sheet').val() == 'xls'){
|
1665 |
+
$('.export_to_xls_upgrade_notice').show();
|
1666 |
+
$('.wpallexport-submit-template').attr('disabled', 'disabled');
|
1667 |
+
}
|
1668 |
+
else{
|
1669 |
+
$('.export_to_xls_upgrade_notice').hide();
|
1670 |
+
$('.wpallexport-submit-template').removeAttr('disabled');
|
1671 |
+
}
|
1672 |
|
1673 |
$('.wpallexport-import-to-format').click(function(){
|
1674 |
|
1675 |
+
var isWooCommerceOrder = vm.isWoocommerceOrderExport();
|
1676 |
+
|
1677 |
$('.wpallexport-import-to-format').removeClass('selected');
|
1678 |
$(this).addClass('selected');
|
1679 |
|
1680 |
if ($(this).hasClass('wpallexport-csv-type'))
|
1681 |
{
|
1682 |
+
$('.wpallexport-custom-xml-template').slideUp();
|
1683 |
+
$('.wpallexport-simple-xml-template').slideDown();
|
1684 |
$('.wpallexport-csv-options').show();
|
1685 |
$('.wpallexport-xml-options').hide();
|
1686 |
+
|
1687 |
+
$('.wpallexport-csv-advanced-options').css('display', 'block');
|
1688 |
+
$('.wpallexport-xml-advanced-options').css('display', 'none');
|
1689 |
+
|
1690 |
$('input[name=export_to]').val('csv');
|
1691 |
+
|
1692 |
+
if($('#export_to_sheet').val() === 'csv') {
|
1693 |
+
if(!isWooCommerceOrder){
|
1694 |
+
$('.export_to_csv').show();
|
1695 |
+
$('.csv_delimiter').show();
|
1696 |
+
} else {
|
1697 |
+
$('.export_to_csv').show();
|
1698 |
+
}
|
1699 |
+
$('.export_to_xls_upgrade_notice').hide();
|
1700 |
+
$('.wpallexport-submit-template').removeAttr('disabled');
|
1701 |
+
} else {
|
1702 |
+
if(isWooCommerceOrder){
|
1703 |
+
$('.csv_delimiter').hide();
|
1704 |
+
$('.export_to_csv').show();
|
1705 |
+
} else {
|
1706 |
+
$('.export_to_csv').hide();
|
1707 |
+
}
|
1708 |
+
$('.export_to_xls_upgrade_notice').show();
|
1709 |
+
$('.wpallexport-submit-template').attr('disabled', 'disabled');
|
1710 |
+
}
|
1711 |
+
$('.custom_xml_upgrade_notice').hide();
|
1712 |
}
|
1713 |
else
|
1714 |
{
|
1715 |
$('.wpallexport-csv-options').hide();
|
1716 |
$('.wpallexport-xml-options').show();
|
1717 |
$('input[name=export_to]').val('xml');
|
1718 |
+
$('.xml_template_type').change();
|
1719 |
+
|
1720 |
+
$('.wpallexport-csv-advanced-options').css('display', 'none');
|
1721 |
+
$('.wpallexport-xml-advanced-options').css('display', 'block');
|
1722 |
+
var $xml_export_format = $('.xml_template_type').val();
|
1723 |
+
if ( $xml_export_format == 'custom' || $xml_export_format == 'XmlGoogleMerchants'){
|
1724 |
+
$('.wpallexport-submit-template').attr('disabled', 'disabled');
|
1725 |
+
$('.custom_xml_upgrade_notice').show();
|
1726 |
+
}
|
1727 |
}
|
1728 |
});
|
1729 |
|
1735 |
var height = $(window).height();
|
1736 |
$('#available_data').find('.wpallexport-xml').css({'max-height': height - 125});
|
1737 |
|
1738 |
+
// dismiss export template warnings
|
1739 |
+
$('.wp-all-export-warning').find('.notice-dismiss').click(function(){
|
1740 |
+
|
1741 |
+
var $parent = $(this).parent('.wp-all-export-warning');
|
1742 |
+
|
1743 |
+
$('#dismiss_warnings').val('1');
|
1744 |
+
|
1745 |
+
if ( typeof export_id == 'undefined') {
|
1746 |
+
$parent.slideUp();
|
1747 |
+
return true;
|
1748 |
+
}
|
1749 |
+
|
1750 |
+
var request = {
|
1751 |
+
action: 'dismiss_export_warnings',
|
1752 |
+
data: {
|
1753 |
+
export_id: export_id,
|
1754 |
+
warning: $parent.find('p:first').html()
|
1755 |
+
},
|
1756 |
+
security: wp_all_export_security
|
1757 |
+
};
|
1758 |
+
|
1759 |
+
$parent.slideUp();
|
1760 |
+
|
1761 |
+
$.ajax({
|
1762 |
+
type: 'POST',
|
1763 |
+
url: get_valid_ajaxurl(),
|
1764 |
+
data: request,
|
1765 |
+
success: function(response) {},
|
1766 |
+
dataType: "json"
|
1767 |
+
});
|
1768 |
+
});
|
1769 |
+
|
1770 |
+
});
|
1771 |
// [ \Step 2 ( export template ) ]
|
1772 |
|
1773 |
|
1907 |
else
|
1908 |
$('#wp_all_export_value').show();
|
1909 |
});
|
1910 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1911 |
// auot-generate zapier API key
|
1912 |
$('input[name=pmxe_generate_zapier_api_key]').click(function(e){
|
1913 |
|
1932 |
});
|
1933 |
});
|
1934 |
|
1935 |
+
var $tmp_xml_template = '';
|
1936 |
+
var $xml_template_first_load = true;
|
1937 |
+
|
1938 |
+
$('.xml_template_type').change(function(e){
|
1939 |
+
|
1940 |
+
switch ($(this).find('option:selected').val()){
|
1941 |
+
case 'simple':
|
1942 |
+
$('.simple_xml_template_options').slideDown();
|
1943 |
+
$('.wpallexport-simple-xml-template').slideDown();
|
1944 |
+
$('.wpallexport-custom-xml-template').slideUp();
|
1945 |
+
$('.pmxe_product_data').find(".wpallexport-xml-element:contains('Attributes')").parents('li:first').show();
|
1946 |
+
$('.wpallexport-submit-template').removeAttr('disabled');
|
1947 |
+
$('.custom_xml_upgrade_notice').hide();
|
1948 |
+
break;
|
1949 |
+
case 'custom':
|
1950 |
+
case 'XmlGoogleMerchants':
|
1951 |
+
$('.simple_xml_template_options').slideUp();
|
1952 |
+
$('.wpallexport-simple-xml-template').slideUp();
|
1953 |
+
if ( ! $('.wpallexport-file-options').hasClass('closed')) $('.wpallexport-file-options').find('.wpallexport-collapsed-header').click();
|
1954 |
+
$('.wpallexport-custom-xml-template').slideDown(400, function(){
|
1955 |
+
xml_editor.setCursor(1);
|
1956 |
+
});
|
1957 |
+
$('.pmxe_product_data').find(".wpallexport-xml-element:contains('Attributes')").parents('li:first').hide();
|
1958 |
+
|
1959 |
+
if ( $(this).find('option:selected').val() == 'XmlGoogleMerchants' ){
|
1960 |
+
if ( ! $xml_template_first_load ) {
|
1961 |
+
$tmp_xml_template = xml_editor.getValue();
|
1962 |
+
// Get all necessary data according to the spec
|
1963 |
+
var request = {
|
1964 |
+
action: 'get_xml_spec',
|
1965 |
+
security: wp_all_export_security,
|
1966 |
+
spec_class: $(this).find('option:selected').val()
|
1967 |
+
};
|
1968 |
+
xml_editor.setValue("Loading...");
|
1969 |
+
$.ajax({
|
1970 |
+
type: 'POST',
|
1971 |
+
url: get_valid_ajaxurl(),
|
1972 |
+
data: request,
|
1973 |
+
success: function (response) {
|
1974 |
+
if (response.result) {
|
1975 |
+
xml_editor.setValue(response.fields);
|
1976 |
+
}
|
1977 |
+
},
|
1978 |
+
error: function (jqXHR, textStatus) {
|
1979 |
+
|
1980 |
+
},
|
1981 |
+
dataType: "json"
|
1982 |
+
});
|
1983 |
+
}
|
1984 |
+
}
|
1985 |
+
else{
|
1986 |
+
if ( $tmp_xml_template != '' ){
|
1987 |
+
xml_editor.setValue($tmp_xml_template);
|
1988 |
+
$tmp_xml_template = '';
|
1989 |
+
}
|
1990 |
+
}
|
1991 |
+
$('.wpallexport-submit-template').attr('disabled', 'disabled');
|
1992 |
+
$('.custom_xml_upgrade_notice').show();
|
1993 |
+
break;
|
1994 |
+
default:
|
1995 |
+
$('.simple_xml_template_options').slideUp();
|
1996 |
+
$('.wpallexport-simple-xml-template').slideDown();
|
1997 |
+
$('.wpallexport-custom-xml-template').slideUp();
|
1998 |
+
$('.pmxe_product_data').find(".wpallexport-xml-element:contains('Attributes')").parents('li:first').show();
|
1999 |
+
$('.wpallexport-submit-template').removeAttr('disabled');
|
2000 |
+
$('.custom_xml_upgrade_notice').hide();
|
2001 |
+
break;
|
2002 |
+
}
|
2003 |
+
$xml_template_first_load = false;
|
2004 |
+
}).change();
|
2005 |
+
|
2006 |
$('.wpallexport-overlay').click(function(){
|
2007 |
$('.wp-pointer').hide();
|
2008 |
$('#columns').find('div.active').removeClass('active');
|
2009 |
$('fieldset.wp-all-export-edit-column').hide();
|
2010 |
+
$('fieldset.wp-all-export-custom-xml-help').hide();
|
2011 |
+
$(this).hide();
|
2012 |
});
|
2013 |
|
2014 |
if ( $('.wpallexport-template').length )
|
2019 |
}
|
2020 |
// [ \Additional functionality ]
|
2021 |
|
2022 |
+
// Logic for radio boxes (CDATA settings)
|
2023 |
+
$('input[name=simple_custom_xml_cdata_logic]').change(function(){
|
2024 |
+
var value = $('input[name=simple_custom_xml_cdata_logic]:checked').val();
|
2025 |
+
$('#custom_custom_xml_cdata_logic_'+value).prop('checked', true);
|
2026 |
+
$('#custom_xml_cdata_logic').val(value);
|
2027 |
+
});
|
2028 |
+
|
2029 |
+
|
2030 |
+
$('input[name=custom_custom_xml_cdata_logic]').change(function(event) {
|
2031 |
+
event.stopImmediatePropagation();
|
2032 |
+
var value = $('input[name=custom_custom_xml_cdata_logic]:checked').val();
|
2033 |
+
$('#simple_custom_xml_cdata_logic_'+value).prop('checked', true);
|
2034 |
+
$('input[name=simple_custom_xml_cdata_logic]').trigger('change');
|
2035 |
+
|
2036 |
+
});
|
2037 |
+
|
2038 |
+
// Logic for show CDATA tags in preview
|
2039 |
+
$('.show_cdata_in_preview').change(function(){
|
2040 |
+
if($(this).is(':checked')) {
|
2041 |
+
$('#show_cdata_in_preview').val(1);
|
2042 |
+
$('.show_cdata_in_preview').prop('checked', true);
|
2043 |
+
} else {
|
2044 |
+
$('#show_cdata_in_preview').val(0);
|
2045 |
+
$('.show_cdata_in_preview').prop('checked', false);
|
2046 |
+
}
|
2047 |
+
});
|
2048 |
+
|
2049 |
+
// Logic to show CSV advanced options
|
2050 |
+
$('#export_to_sheet').change(function(){
|
2051 |
+
|
2052 |
+
//Todo: Cache this value in vm
|
2053 |
+
var isWooCommerceOrder = vm.isWoocommerceOrderExport();
|
2054 |
+
var value = $(this).val();
|
2055 |
+
if(value === 'xls') {
|
2056 |
+
if(isWooCommerceOrder) {
|
2057 |
+
$('.csv_delimiter').hide();
|
2058 |
+
} else {
|
2059 |
+
$('.export_to_csv').slideUp();
|
2060 |
+
}
|
2061 |
+
$('.export_to_xls_upgrade_notice').show();
|
2062 |
+
$('.wpallexport-submit-template').attr('disabled', 'disabled');
|
2063 |
+
} else {
|
2064 |
+
if(isWooCommerceOrder) {
|
2065 |
+
$('.csv_delimiter').show();
|
2066 |
+
} else {
|
2067 |
+
$('.export_to_csv').slideDown();
|
2068 |
+
}
|
2069 |
+
$('.export_to_xls_upgrade_notice').hide();
|
2070 |
+
$('.wpallexport-submit-template').removeAttr('disabled');
|
2071 |
+
}
|
2072 |
+
});
|
2073 |
+
|
2074 |
+
$('select[name=column_value_type]').change(function(){
|
2075 |
+
var disabledFields = ['fees', 'notes', 'refunds', 'taxes', 'item_data', 'items'];
|
2076 |
+
var selectedField = $(this).find('option:selected').attr('options');
|
2077 |
+
var isShowWarning = false;
|
2078 |
+
for (var i = 0; i < disabledFields.length; i++) {
|
2079 |
+
if (disabledFields[i] == selectedField){
|
2080 |
+
isShowWarning = true;
|
2081 |
+
break;
|
2082 |
+
}
|
2083 |
+
};
|
2084 |
+
if (isShowWarning){
|
2085 |
+
$('.disabled_fields_upgrade_notice').show();
|
2086 |
+
$('.save_action').addClass('wp_all_export_disabled_button').attr('disabled', 'disabled');
|
2087 |
+
}
|
2088 |
+
else {
|
2089 |
+
$('.disabled_fields_upgrade_notice').hide();
|
2090 |
+
$('.save_action').removeClass('wp_all_export_disabled_button').removeAttr('disabled');
|
2091 |
+
}
|
2092 |
+
});
|
2093 |
+
|
2094 |
});})(jQuery);
|
static/js/jquery/jquery.mjs.pmxe_nestedSortable.js
CHANGED
@@ -346,7 +346,7 @@
|
|
346 |
|
347 |
if (id) {
|
348 |
|
349 |
-
var clause = ($(item).find('.condition').
|
350 |
|
351 |
ret.push({"item_id": id[2], "left": left, "right": right, "parent_id": pid, "element":$(item).find('input.wp_all_export_xml_element').val(), "title" : $(item).find('input.wp_all_export_xml_element_title').val(), "condition" : $(item).find('input.wp_all_export_rule').val(), "value" : $(item).find('input.wp_all_export_value').val(), "clause" : clause });
|
352 |
}
|
346 |
|
347 |
if (id) {
|
348 |
|
349 |
+
var clause = ($(item).find('.condition:first').hasClass('last_condition')) ? false : $(item).find('input.rule_condition:checked').val().toUpperCase();
|
350 |
|
351 |
ret.push({"item_id": id[2], "left": left, "right": right, "parent_id": pid, "element":$(item).find('input.wp_all_export_xml_element').val(), "title" : $(item).find('input.wp_all_export_xml_element_title').val(), "condition" : $(item).find('input.wp_all_export_rule').val(), "value" : $(item).find('input.wp_all_export_value').val(), "clause" : clause });
|
352 |
}
|
views/admin/export/blocks/filters.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<div class="wpallexport-free-edition-notice" style="padding: 20px; margin-bottom: 10px;">
|
2 |
-
<a class="upgrade_link" target="_blank" href="
|
|
|
3 |
</div>
|
4 |
<div class="wp_all_export_rule_inputs">
|
5 |
<table>
|
1 |
<div class="wpallexport-free-edition-notice" style="padding: 20px; margin-bottom: 10px;">
|
2 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=free-plugin&utm_medium=in-plugin&utm_campaign=download-from-url"><?php _e('Upgrade to the Pro edition of WP All Export to Add Filters','wp_all_export_plugin');?></a>
|
3 |
+
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.','wp_all_export_plugin');?></p>
|
4 |
</div>
|
5 |
<div class="wp_all_export_rule_inputs">
|
6 |
<table>
|
views/admin/export/index.php
CHANGED
@@ -90,15 +90,15 @@
|
|
90 |
</div>
|
91 |
|
92 |
<div class="wpallexport-free-edition-notice wpallexport-user-export-notice">
|
93 |
-
<a class="upgrade_link" target="_blank" href="
|
94 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
95 |
</div>
|
96 |
<div class="wpallexport-free-edition-notice wpallexport-shop_customer-export-notice">
|
97 |
-
<a class="upgrade_link" target="_blank" href="
|
98 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
99 |
</div>
|
100 |
<div class="wpallexport-free-edition-notice wpallexport-comments-export-notice">
|
101 |
-
<a class="upgrade_link" target="_blank" href="
|
102 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
103 |
</div>
|
104 |
</div>
|
@@ -113,12 +113,12 @@
|
|
113 |
</select>
|
114 |
|
115 |
<div class="wpallexport-free-edition-notice wpallexport-user-export-notice" style="margin-bottom: 20px;">
|
116 |
-
<a class="upgrade_link" target="_blank" href="
|
117 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
118 |
</div>
|
119 |
|
120 |
<div class="wpallexport-free-edition-notice wpallexport-comments-export-notice" style="margin-bottom: 20px;">
|
121 |
-
<a class="upgrade_link" target="_blank" href="
|
122 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
123 |
</div>
|
124 |
|
90 |
</div>
|
91 |
|
92 |
<div class="wpallexport-free-edition-notice wpallexport-user-export-notice">
|
93 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=export-users&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export to Export Users','wp_all_export_plugin');?></a>
|
94 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
95 |
</div>
|
96 |
<div class="wpallexport-free-edition-notice wpallexport-shop_customer-export-notice">
|
97 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=export-users&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export to Export Customers','wp_all_export_plugin');?></a>
|
98 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
99 |
</div>
|
100 |
<div class="wpallexport-free-edition-notice wpallexport-comments-export-notice">
|
101 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=export-users&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export to Export Comments','wp_all_export_plugin');?></a>
|
102 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
103 |
</div>
|
104 |
</div>
|
113 |
</select>
|
114 |
|
115 |
<div class="wpallexport-free-edition-notice wpallexport-user-export-notice" style="margin-bottom: 20px;">
|
116 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=export-users&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export to Export Users','wp_all_export_plugin');?></a>
|
117 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
118 |
</div>
|
119 |
|
120 |
<div class="wpallexport-free-edition-notice wpallexport-comments-export-notice" style="margin-bottom: 20px;">
|
121 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=export-users&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export to Export Comments','wp_all_export_plugin');?></a>
|
122 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
123 |
</div>
|
124 |
|
views/admin/export/template.php
CHANGED
@@ -39,6 +39,8 @@
|
|
39 |
|
40 |
<form class="wpallexport-template <?php echo ! $this->isWizard ? 'edit' : '' ?> wpallexport-step-3" method="post" style="display:none;">
|
41 |
|
|
|
|
|
42 |
<?php
|
43 |
$selected_post_type = '';
|
44 |
if (XmlExportUser::$is_active):
|
@@ -56,13 +58,13 @@
|
|
56 |
<input type="hidden" name="selected_post_type" value="<?php echo $selected_post_type; ?>"/>
|
57 |
<input type="hidden" name="export_type" value="<?php echo $post['export_type']; ?>"/>
|
58 |
|
59 |
-
<div class="wpallexport-collapsed wpallexport-section">
|
60 |
-
<div class="wpallexport-content-section">
|
61 |
-
<div class="wpallexport-collapsed-content"
|
62 |
-
<fieldset class="optionsset" style="padding: 10px 20px;">
|
63 |
<div id="columns_to_export">
|
64 |
<div class="columns-to-export-content" style="padding-right: 8px;">
|
65 |
-
<ol id="columns" class="rad4">
|
66 |
<?php
|
67 |
$i = 0;
|
68 |
$new_export = false;
|
@@ -85,12 +87,12 @@
|
|
85 |
<input type="hidden" name="cc_label[]" value="<?php echo (!empty($post['cc_label'][$ID])) ? $post['cc_label'][$ID] : ''; ?>"/>
|
86 |
<input type="hidden" name="cc_php[]" value="<?php echo (!empty($post['cc_php'][$ID])) ? $post['cc_php'][$ID] : 0; ?>"/>
|
87 |
<input type="hidden" name="cc_code[]" value="<?php echo (!empty($post['cc_code'][$ID])) ? $post['cc_code'][$ID] : ''; ?>"/>
|
88 |
-
<input type="hidden" name="cc_sql[]" value="<?php echo (!empty($post['cc_sql'][$ID])) ? $post['cc_sql'][$ID] :
|
89 |
<input type="hidden" name="cc_type[]" value="<?php echo $field_type; ?>"/>
|
90 |
-
<input type="hidden" name="cc_options[]" value="<?php echo $field_options; ?>"/>
|
91 |
<input type="hidden" name="cc_value[]" value="<?php echo esc_attr($post['cc_value'][$ID]); ?>"/>
|
92 |
<input type="hidden" name="cc_name[]" value="<?php echo (strtoupper($field_name) == "ID") ? "id" : $field_name; ?>"/>
|
93 |
-
<input type="hidden" name="cc_settings[]" value="<?php echo (!empty($post['cc_settings'][$ID])) ? esc_attr($post['cc_settings'][$ID]) :
|
94 |
</div>
|
95 |
</li>
|
96 |
<?php
|
@@ -116,14 +118,14 @@
|
|
116 |
<label class="wpallexport-xml-element"><?php echo $field['name']; ?></label>
|
117 |
<input type="hidden" name="ids[]" value="1"/>
|
118 |
<input type="hidden" name="cc_label[]" value="<?php echo $field['label']; ?>"/>
|
119 |
-
<input type="hidden" name="cc_php[]" value=""/>
|
120 |
<input type="hidden" name="cc_code[]" value=""/>
|
121 |
-
<input type="hidden" name="cc_sql[]" value=""/>
|
122 |
-
<input type="hidden" name="cc_options[]" value="<?php echo (empty($field['options'])) ?
|
123 |
<input type="hidden" name="cc_type[]" value="<?php echo $field['type']; ?>"/>
|
124 |
<input type="hidden" name="cc_value[]" value="<?php echo $field['label']; ?>"/>
|
125 |
<input type="hidden" name="cc_name[]" value="<?php echo (strtoupper($field['name']) == 'ID') ? 'id' : $field['name'];?>"/>
|
126 |
-
<input type="hidden" name="cc_settings[]" value=""/>
|
127 |
</div>
|
128 |
</li>
|
129 |
<?php
|
@@ -142,14 +144,14 @@
|
|
142 |
<label class="wpallexport-xml-element"></label>
|
143 |
<input type="hidden" name="ids[]" value="1"/>
|
144 |
<input type="hidden" name="cc_label[]" value=""/>
|
145 |
-
<input type="hidden" name="cc_php[]" value=""/>
|
146 |
<input type="hidden" name="cc_code[]" value=""/>
|
147 |
-
<input type="hidden" name="cc_sql[]" value=""/>
|
148 |
<input type="hidden" name="cc_type[]" value=""/>
|
149 |
-
<input type="hidden" name="cc_options[]" value=""/>
|
150 |
<input type="hidden" name="cc_value[]" value=""/>
|
151 |
<input type="hidden" name="cc_name[]" value=""/>
|
152 |
-
<input type="hidden" name="cc_settings[]" value=""/>
|
153 |
</div>
|
154 |
|
155 |
<!-- Warning Messages -->
|
@@ -157,6 +159,7 @@
|
|
157 |
<div class="wp-all-export-warning" <?php if ( empty($post['ids']) or count($post['ids']) > 1 ) echo 'style="display:none;"'; ?>>
|
158 |
<p></p>
|
159 |
<input type="hidden" id="warning_template" value="<?php _e("Warning: without %s you won't be able to re-import this data back to this site using WP All Import.", "wp_all_export_plugin"); ?>"/>
|
|
|
160 |
</div>
|
161 |
<?php endif; ?>
|
162 |
|
@@ -171,26 +174,118 @@
|
|
171 |
</fieldset>
|
172 |
|
173 |
<!-- Add New Field Button -->
|
174 |
-
<div class="input" style="
|
175 |
<input type="button" value="<?php _e('Add Field', 'wp_all_export_plugin');?>" class="add_column" style="float:left;">
|
176 |
<input type="button" value="<?php _e('Add All', 'wp_all_export_plugin'); ?>" class="wp_all_export_auto_generate_data">
|
177 |
<input type="button" value="<?php _e('Clear All', 'wp_all_export_plugin'); ?>" class="wp_all_export_clear_all_data">
|
178 |
</div>
|
179 |
|
180 |
<!-- Preview a Row Button -->
|
181 |
-
<div class="input" style="float:right; margin:
|
182 |
<input type="button" value="<?php _e('Preview', 'wp_all_export_plugin');?>" class="preview_a_row">
|
183 |
</div>
|
184 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
</div>
|
186 |
</div>
|
187 |
|
188 |
-
<div class="wpallexport-collapsed wpallexport-section wpallexport-file-options closed" style="margin-top:
|
189 |
<div class="wpallexport-content-section" style="padding-bottom: 15px; margin-bottom: 10px;">
|
190 |
<div class="wpallexport-collapsed-header" style="padding-left: 25px;">
|
191 |
-
<h3><?php _e('Export File
|
192 |
</div>
|
193 |
-
<div class="wpallexport-collapsed-content" style="padding: 0; overflow: hidden;
|
194 |
<div class="wpallexport-collapsed-content-inner">
|
195 |
<div class="wpallexport-choose-data-type">
|
196 |
<h3 style="margin-top: 10px; margin-bottom: 40px;"><?php _e('Choose your export file type', 'wp_all_export_plugin'); ?></h3>
|
@@ -208,67 +303,36 @@
|
|
208 |
|
209 |
<input type="hidden" name="export_to" value="<?php echo $post['export_to']; ?>"/>
|
210 |
|
211 |
-
<div class="wpallexport-file-format-options">
|
212 |
|
213 |
-
<div class="wpallexport-csv-options" <?php if ($post['export_to'] == 'xml') echo '
|
214 |
<!-- Export File Format -->
|
215 |
-
<div class="input
|
216 |
-
<
|
217 |
-
<
|
218 |
-
|
219 |
-
|
220 |
-
<label for="export_to_xls"><?php _e('XLS', 'wp_all_export_plugin' )?></label>
|
221 |
-
</div>
|
222 |
-
<div class="input" style="float:left; height: 35px; vertical-align: middle;">
|
223 |
-
<input type="radio" id="export_to_csv" class="switcher" name="export_to_sheet" value="csv" <?php echo 'csv' == $post['export_to_sheet'] ? 'checked="checked"': '' ?>/>
|
224 |
-
<label for="export_to_csv"><?php _e('CSV', 'wp_all_export_plugin' )?></label>
|
225 |
-
</div>
|
226 |
-
<div class="input switcher-target-export_to_csv" style="float: left; vertical-align:middle; height: 35px; position: relative; top: -6px;">
|
227 |
-
<label style="width: 80px; margin-left: 20px;"><?php _e('Separator:','wp_all_export_plugin');?></label>
|
228 |
-
<input type="text" name="delimiter" value="<?php echo esc_attr($post['delimiter']) ?>" style="width: 40px; height: 30px; top: 0px; text-align: center;"/>
|
229 |
-
</div>
|
230 |
-
<div class="wpallexport-clear"></div>
|
231 |
-
<div class="input switcher-target-export_to_xls" style="vertical-align:middle; position: relative; top: -13px;">
|
232 |
-
<span class="wpallexport-free-edition-notice">
|
233 |
-
<a class="upgrade_link" target="_blank" href="http://www.wpallimport.com/upgrade-to-wp-all-export-pro/?utm_source=wordpress.org&utm_medium=wooco+orders&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export to export to Excel. <br>If you already own it, remove the free edition and install the Pro edition.','wp_all_export_plugin');?></a>
|
234 |
-
</span>
|
235 |
-
</div>
|
236 |
-
</div>
|
237 |
-
<div class="clear"></div>
|
238 |
</div>
|
239 |
-
|
240 |
-
|
241 |
-
<div class="input" style="
|
242 |
-
<
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
<div class="input switcher-target-order_item_per_row" style="margin-top: 10px; padding-left: 15px;">
|
247 |
-
<input type="hidden" name="order_item_fill_empty_columns" value="0"/>
|
248 |
-
<input type="checkbox" id="order_item_fill_empty_columns" name="order_item_fill_empty_columns" value="1" <?php if ($post['order_item_fill_empty_columns']):?>checked="checked"<?php endif; ?>/>
|
249 |
-
<label for="order_item_fill_empty_columns"><?php _e("Fill in empty columns", "wp_all_export_plugin"); ?></label>
|
250 |
-
<a href="#help" class="wpallexport-help" style="position: relative; top: 0px;" title="<?php _e('If enabled, each order item will appear as its own row with all order info filled in for every column. If disabled, order info will only display on one row with only the order item info displaying in additional rows.', 'wp_all_export_plugin'); ?>">?</a>
|
251 |
-
</div>
|
252 |
</div>
|
253 |
-
<?php endif; ?>
|
254 |
</div>
|
255 |
|
256 |
<div class="wpallexport-xml-options" <?php if ($post['export_to'] != 'xml') echo 'style="display:none;"'; ?>>
|
257 |
|
258 |
-
<div class="input" style="
|
259 |
-
<
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
$post_type_details = ( ! empty($post['cpt'])) ? get_post_type_object( $post['cpt'][0] ) : '';
|
267 |
-
?>
|
268 |
-
<label for="record_xml_tag" style="float: left;"><?php printf(__('Single %s XML Element','wp_all_export_plugin'), empty($post_type_details) ? 'Record' : $post_type_details->labels->singular_name); ?></label>
|
269 |
-
<div class="input">
|
270 |
-
<input type="text" name="record_xml_tag" style="vertical-align:middle; background:#fff !important; width: 100%;" value="<?php echo esc_attr($post['record_xml_tag']) ?>" />
|
271 |
-
</div>
|
272 |
</div>
|
273 |
</div>
|
274 |
</div>
|
@@ -278,6 +342,108 @@
|
|
278 |
</div>
|
279 |
</div>
|
280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
<hr>
|
282 |
|
283 |
<div class="input wpallexport-section" style="padding-bottom: 8px; padding-left: 8px;">
|
@@ -308,18 +474,25 @@
|
|
308 |
|
309 |
<hr>
|
310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
<div class="wpallexport-submit-buttons">
|
312 |
|
313 |
<div style="text-align:center; width:100%;">
|
314 |
<?php wp_nonce_field('template', '_wpnonce_template'); ?>
|
315 |
-
<input type="hidden" name="is_submitted" value="1" />
|
316 |
-
|
317 |
<?php if ( ! $this->isWizard ): ?>
|
318 |
<a href="<?php echo remove_query_arg('id', remove_query_arg('action', $this->baseUrl)); ?>" class="back rad3" style="float:none;"><?php _e('Back to Manage Exports', 'wp_all_export_plugin') ?></a>
|
319 |
<?php else: ?>
|
320 |
<a href="<?php echo add_query_arg('action', 'index', $this->baseUrl); ?>" class="back rad3"><?php _e('Back', 'wp_all_export_plugin') ?></a>
|
321 |
<?php endif; ?>
|
322 |
-
<input type="submit" class="button button-primary button-hero wpallexport-large-button" value="<?php _e( ($this->isWizard) ? 'Continue' : 'Update Template', 'wp_all_export_plugin') ?>" />
|
323 |
</div>
|
324 |
|
325 |
</div>
|
@@ -360,4 +533,12 @@
|
|
360 |
|
361 |
</fieldset>
|
362 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
<div class="wpallexport-overlay"></div>
|
39 |
|
40 |
<form class="wpallexport-template <?php echo ! $this->isWizard ? 'edit' : '' ?> wpallexport-step-3" method="post" style="display:none;">
|
41 |
|
42 |
+
<input type="hidden" class="hierarhy-output" name="filter_rules_hierarhy" value="<?php echo esc_html($post['filter_rules_hierarhy']);?>"/>
|
43 |
+
|
44 |
<?php
|
45 |
$selected_post_type = '';
|
46 |
if (XmlExportUser::$is_active):
|
58 |
<input type="hidden" name="selected_post_type" value="<?php echo $selected_post_type; ?>"/>
|
59 |
<input type="hidden" name="export_type" value="<?php echo $post['export_type']; ?>"/>
|
60 |
|
61 |
+
<div class="wpallexport-collapsed wpallexport-section wpallexport-simple-xml-template">
|
62 |
+
<div class="wpallexport-content-section" style="margin-bottom: 10px;">
|
63 |
+
<div class="wpallexport-collapsed-content">
|
64 |
+
<fieldset class="optionsset" style="padding: 10px 20px 0px;">
|
65 |
<div id="columns_to_export">
|
66 |
<div class="columns-to-export-content" style="padding-right: 8px;">
|
67 |
+
<ol id="columns" class="rad4" style="margin-bottom:0;">
|
68 |
<?php
|
69 |
$i = 0;
|
70 |
$new_export = false;
|
87 |
<input type="hidden" name="cc_label[]" value="<?php echo (!empty($post['cc_label'][$ID])) ? $post['cc_label'][$ID] : ''; ?>"/>
|
88 |
<input type="hidden" name="cc_php[]" value="<?php echo (!empty($post['cc_php'][$ID])) ? $post['cc_php'][$ID] : 0; ?>"/>
|
89 |
<input type="hidden" name="cc_code[]" value="<?php echo (!empty($post['cc_code'][$ID])) ? $post['cc_code'][$ID] : ''; ?>"/>
|
90 |
+
<input type="hidden" name="cc_sql[]" value="<?php echo (!empty($post['cc_sql'][$ID])) ? $post['cc_sql'][$ID] : 0; ?>"/>
|
91 |
<input type="hidden" name="cc_type[]" value="<?php echo $field_type; ?>"/>
|
92 |
+
<input type="hidden" name="cc_options[]" value="<?php echo (!empty($field_options)) ? $field_options : 0; ?>"/>
|
93 |
<input type="hidden" name="cc_value[]" value="<?php echo esc_attr($post['cc_value'][$ID]); ?>"/>
|
94 |
<input type="hidden" name="cc_name[]" value="<?php echo (strtoupper($field_name) == "ID") ? "id" : $field_name; ?>"/>
|
95 |
+
<input type="hidden" name="cc_settings[]" value="<?php echo (!empty($post['cc_settings'][$ID])) ? esc_attr($post['cc_settings'][$ID]) : 0; ?>"/>
|
96 |
</div>
|
97 |
</li>
|
98 |
<?php
|
118 |
<label class="wpallexport-xml-element"><?php echo $field['name']; ?></label>
|
119 |
<input type="hidden" name="ids[]" value="1"/>
|
120 |
<input type="hidden" name="cc_label[]" value="<?php echo $field['label']; ?>"/>
|
121 |
+
<input type="hidden" name="cc_php[]" value="0"/>
|
122 |
<input type="hidden" name="cc_code[]" value=""/>
|
123 |
+
<input type="hidden" name="cc_sql[]" value="0"/>
|
124 |
+
<input type="hidden" name="cc_options[]" value="<?php echo (empty($field['options'])) ? 0 : $field['options']; ?>"/>
|
125 |
<input type="hidden" name="cc_type[]" value="<?php echo $field['type']; ?>"/>
|
126 |
<input type="hidden" name="cc_value[]" value="<?php echo $field['label']; ?>"/>
|
127 |
<input type="hidden" name="cc_name[]" value="<?php echo (strtoupper($field['name']) == 'ID') ? 'id' : $field['name'];?>"/>
|
128 |
+
<input type="hidden" name="cc_settings[]" value="0"/>
|
129 |
</div>
|
130 |
</li>
|
131 |
<?php
|
144 |
<label class="wpallexport-xml-element"></label>
|
145 |
<input type="hidden" name="ids[]" value="1"/>
|
146 |
<input type="hidden" name="cc_label[]" value=""/>
|
147 |
+
<input type="hidden" name="cc_php[]" value="0"/>
|
148 |
<input type="hidden" name="cc_code[]" value=""/>
|
149 |
+
<input type="hidden" name="cc_sql[]" value="0"/>
|
150 |
<input type="hidden" name="cc_type[]" value=""/>
|
151 |
+
<input type="hidden" name="cc_options[]" value="0"/>
|
152 |
<input type="hidden" name="cc_value[]" value=""/>
|
153 |
<input type="hidden" name="cc_name[]" value=""/>
|
154 |
+
<input type="hidden" name="cc_settings[]" value="0"/>
|
155 |
</div>
|
156 |
|
157 |
<!-- Warning Messages -->
|
159 |
<div class="wp-all-export-warning" <?php if ( empty($post['ids']) or count($post['ids']) > 1 ) echo 'style="display:none;"'; ?>>
|
160 |
<p></p>
|
161 |
<input type="hidden" id="warning_template" value="<?php _e("Warning: without %s you won't be able to re-import this data back to this site using WP All Import.", "wp_all_export_plugin"); ?>"/>
|
162 |
+
<button class="notice-dismiss" type="button"><span class="screen-reader-text">Dismiss this notice.</span></button>
|
163 |
</div>
|
164 |
<?php endif; ?>
|
165 |
|
174 |
</fieldset>
|
175 |
|
176 |
<!-- Add New Field Button -->
|
177 |
+
<div class="input" style="display:inline-block; margin: 20px 0 10px 20px;">
|
178 |
<input type="button" value="<?php _e('Add Field', 'wp_all_export_plugin');?>" class="add_column" style="float:left;">
|
179 |
<input type="button" value="<?php _e('Add All', 'wp_all_export_plugin'); ?>" class="wp_all_export_auto_generate_data">
|
180 |
<input type="button" value="<?php _e('Clear All', 'wp_all_export_plugin'); ?>" class="wp_all_export_clear_all_data">
|
181 |
</div>
|
182 |
|
183 |
<!-- Preview a Row Button -->
|
184 |
+
<div class="input" style="float:right; margin: 20px 20px 10px 0;">
|
185 |
<input type="button" value="<?php _e('Preview', 'wp_all_export_plugin');?>" class="preview_a_row">
|
186 |
</div>
|
187 |
</div>
|
188 |
+
<div class="wpallexport-collapsed closed wpallexport-section wpallexport-xml-advanced-options" <?php if ($post['export_to'] !== 'xml') { ?> style="display: none;" <?php }?> >
|
189 |
+
<div class="wpallexport-content-section rad0" style="margin:0; border-top:1px solid #ddd; border-bottom: none; border-right: none; border-left: none; background: #f1f2f2; padding-bottom: 15px; margin-top: 5px;">
|
190 |
+
<div class="wpallexport-collapsed-header">
|
191 |
+
<h3 style="color:#40acad;"><?php _e('Advanced Options','wp_all_export_plugin');?></h3>
|
192 |
+
<hr style="display:none; margin-right:25px;"/>
|
193 |
+
</div>
|
194 |
+
<div class="wpallexport-collapsed-content" style="padding:0 0 0 5px;">
|
195 |
+
<div class="wpallexport-collapsed-content-inner">
|
196 |
+
<div class="simple_xml_template_options" style="margin-top:20px;">
|
197 |
+
<div class="input" style="display: inline-block; max-width: 360px; width: 40%; margin-right: 10px;">
|
198 |
+
<label for="main_xml_tag" style="float: left;"><?php _e('Root XML Element','wp_all_export_plugin');?></label>
|
199 |
+
<div class="input">
|
200 |
+
<input type="text" name="main_xml_tag" style="vertical-align:middle; background:#fff !important; width: 100%; margin-left:0;" value="<?php echo esc_attr($post['main_xml_tag']) ?>" />
|
201 |
+
</div>
|
202 |
+
</div>
|
203 |
+
<div class="input" style="display: inline-block; max-width: 360px; width: 40%; ">
|
204 |
+
<?php
|
205 |
+
$post_type_details = ( ! empty($post['cpt'])) ? get_post_type_object( $post['cpt'][0] ) : '';
|
206 |
+
?>
|
207 |
+
<label for="record_xml_tag" style="float: left;"><?php printf(__('Single %s XML Element','wp_all_export_plugin'), empty($post_type_details) ? 'Record' : $post_type_details->labels->singular_name); ?></label>
|
208 |
+
<div class="input">
|
209 |
+
<input type="text" name="record_xml_tag" style="vertical-align:middle; background:#fff !important; width: 100%; margin-left:0;" value="<?php echo esc_attr($post['record_xml_tag']) ?>" />
|
210 |
+
</div>
|
211 |
+
</div>
|
212 |
+
</div>
|
213 |
+
<input type="hidden" id="custom_xml_cdata_logic" value="<?php echo $post['custom_xml_cdata_logic']; ?>" name="custom_xml_cdata_logic" />
|
214 |
+
<input type="hidden" id="show_cdata_in_preview" value="<?php echo $post['show_cdata_in_preview']; ?>" name="show_cdata_in_preview" />
|
215 |
+
<div class="input">
|
216 |
+
<h4>CDATA</h4>
|
217 |
+
<p style="font-style: italic;"><?php echo sprintf(__("There are certain characters that cannot be included in an XML file unless they are wrapped in CDATA tags.<br/><a target='_blank' href='%s'>Click here to read more about CDATA tags.</a>", 'wp_all_export_plugin'), 'https://en.wikipedia.org/wiki/CDATA'); ?></p>
|
218 |
+
<div class="input" style="margin: 3px 0;">
|
219 |
+
<input type="radio" id="simple_custom_xml_cdata_logic_auto" name="simple_custom_xml_cdata_logic" value="auto" checked="checked" <?php echo ( "auto" == $post['custom_xml_cdata_logic'] ) ? 'checked="checked"': '' ?> class="switcher cdata"/>
|
220 |
+
<label for="simple_custom_xml_cdata_logic_auto"><?php _e('Automatically wrap data in CDATA tags when it contains illegal characters', 'wp_all_export_plugin') ?></label>
|
221 |
+
</div>
|
222 |
+
<div class="input" style="margin: 3px 0;">
|
223 |
+
<input type="radio" id="simple_custom_xml_cdata_logic_all" name="simple_custom_xml_cdata_logic" value="all" <?php echo ( "all" == $post['custom_xml_cdata_logic'] ) ? 'checked="checked"': '' ?> class="switcher cdata" />
|
224 |
+
<label for="simple_custom_xml_cdata_logic_all"><?php _e('Always wrap data in CDATA tags', 'wp_all_export_plugin') ?></label>
|
225 |
+
</div>
|
226 |
+
<div class="input" style="margin: 3px 0;">
|
227 |
+
<input type="radio" id="simple_custom_xml_cdata_logic_never" name="simple_custom_xml_cdata_logic" value="never" <?php echo ( "never" == $post['custom_xml_cdata_logic'] ) ? 'checked="checked"': '' ?> class="switcher cdata"/>
|
228 |
+
<label for="simple_custom_xml_cdata_logic_never"><?php _e('Never wrap data in CDATA tags', 'wp_all_export_plugin') ?></label>
|
229 |
+
<div class="switcher-target-simple_custom_xml_cdata_logic_never" style="padding-left:17px;">
|
230 |
+
<p style="font-style: italic;"><?php _e('Warning: This may result in an invalid XML file', 'wp_all_export_plugin');?></p>
|
231 |
+
</div>
|
232 |
+
</div>
|
233 |
+
<div class="input" style="margin: 10px 4px;">
|
234 |
+
<input type="checkbox" value="1" id="simple_show_cdata_in_preview" <?php echo ( 1 == $post['show_cdata_in_preview'] ) ? 'checked="checked"': '' ?> class="show_cdata_in_preview" />
|
235 |
+
<label for="simple_show_cdata_in_preview">Show CDATA tags in XML preview</label>
|
236 |
+
</div>
|
237 |
+
</div>
|
238 |
+
</div>
|
239 |
+
</div>
|
240 |
+
</div>
|
241 |
+
</div>
|
242 |
+
|
243 |
+
<!-- ExportToCsvBegin -->
|
244 |
+
<div class="wpallexport-collapsed closed wpallexport-section wpallexport-csv-advanced-options export_to_csv" <?php if ($post['export_to'] != 'csv' || ($post['export_to'] == 'csv' && $post['export_to_sheet'] ==='xls')) { ?> style="display: none;" <?php }?> >
|
245 |
+
|
246 |
+
<div class="wpallexport-content-section rad0" style="margin:0; border-top:1px solid #ddd; border-bottom: none; border-right: none; border-left: none; background: #f1f2f2; padding-bottom: 15px; margin-top: 5px;">
|
247 |
+
<div class="wpallexport-collapsed-header">
|
248 |
+
<h3 style="color:#40acad;"><?php _e('Advanced Options','wp_all_export_plugin');?></h3>
|
249 |
+
<hr style="display:none; margin-right:25px;"/>
|
250 |
+
</div>
|
251 |
+
<div class="wpallexport-collapsed-content" style="padding:0 0 0 5px;">
|
252 |
+
<div class="wpallexport-collapsed-content-inner" style="padding-left: 5px;">
|
253 |
+
<div class="simple_xml_template_options csv_delimiter" style="margin-top:20px;">
|
254 |
+
<div class="input" style="display: inline-block; max-width: 360px; width: 40%; margin-right: 10px;">
|
255 |
+
<label style="width: 80px; margin-left: 20px;"><?php _e('Separator:','wp_all_export_plugin');?></label>
|
256 |
+
<input type="text" name="delimiter" value="<?php echo esc_attr($post['delimiter']) ?>" style="width: 40px; height: 30px; top: 0px; text-align: center;"/>
|
257 |
+
</div>
|
258 |
+
</div>
|
259 |
+
<!-- Display each product in its own row -->
|
260 |
+
<?php if ( XmlExportWooCommerceOrder::$is_active ): ?>
|
261 |
+
<div class="input" style="float: left; margin-top: 15px; margin-left:20px;" id="woo_commerce_order">
|
262 |
+
<input type="hidden" name="order_item_per_row" value="0"/>
|
263 |
+
<input type="checkbox" id="order_item_per_row" name="order_item_per_row" value="1" <?php if ($post['order_item_per_row']):?>checked="checked"<?php endif; ?> class="switcher"/>
|
264 |
+
<label for="order_item_per_row"><?php _e("Display each product in its own row", "wp_all_export_plugin"); ?></label>
|
265 |
+
<a href="#help" class="wpallexport-help" style="position: relative; top: 0px;" title="<?php _e('If an order contains multiple products, each product will have its own row. If disabled, each product will have its own column.', 'wp_all_export_plugin'); ?>">?</a>
|
266 |
+
<div class="input switcher-target-order_item_per_row" style="margin-top: 10px; text-align:left;">
|
267 |
+
<input type="hidden" name="order_item_fill_empty_columns" value="0"/>
|
268 |
+
<input type="checkbox" id="order_item_fill_empty_columns" name="order_item_fill_empty_columns" value="1" <?php if ($post['order_item_fill_empty_columns']):?>checked="checked"<?php endif; ?>/>
|
269 |
+
<label for="order_item_fill_empty_columns"><?php _e("Fill in empty columns", "wp_all_export_plugin"); ?></label>
|
270 |
+
<a href="#help" class="wpallexport-help" style="position: relative; top: 0px;" title="<?php _e('If enabled, each order item will appear as its own row with all order info filled in for every column. If disabled, order info will only display on one row with only the order item info displaying in additional rows.', 'wp_all_export_plugin'); ?>">?</a>
|
271 |
+
</div>
|
272 |
+
</div>
|
273 |
+
<div class="clear"></div>
|
274 |
+
<?php endif; ?>
|
275 |
+
</div>
|
276 |
+
</div>
|
277 |
+
</div>
|
278 |
+
</div>
|
279 |
+
<!-- ExporToCsvEnd -->
|
280 |
</div>
|
281 |
</div>
|
282 |
|
283 |
+
<div class="wpallexport-collapsed wpallexport-section wpallexport-file-options closed" style="margin-top: 0px;">
|
284 |
<div class="wpallexport-content-section" style="padding-bottom: 15px; margin-bottom: 10px;">
|
285 |
<div class="wpallexport-collapsed-header" style="padding-left: 25px;">
|
286 |
+
<h3><?php _e('Export File Type','wp_all_export_plugin');?></h3>
|
287 |
</div>
|
288 |
+
<div class="wpallexport-collapsed-content" style="padding: 0; overflow: hidden;">
|
289 |
<div class="wpallexport-collapsed-content-inner">
|
290 |
<div class="wpallexport-choose-data-type">
|
291 |
<h3 style="margin-top: 10px; margin-bottom: 40px;"><?php _e('Choose your export file type', 'wp_all_export_plugin'); ?></h3>
|
303 |
|
304 |
<input type="hidden" name="export_to" value="<?php echo $post['export_to']; ?>"/>
|
305 |
|
306 |
+
<div class="wpallexport-file-format-options" style="width:100%;">
|
307 |
|
308 |
+
<div class="wpallexport-csv-options" style="<?php if ($post['export_to'] == 'xml') echo 'display:none;'; ?> width:100%;">
|
309 |
<!-- Export File Format -->
|
310 |
+
<div class="input" style="width:83%; margin: 0 auto 5px;">
|
311 |
+
<select name="export_to_sheet" id="export_to_sheet">
|
312 |
+
<option value="csv" <?php if ($post['export_to_sheet'] == 'csv') echo 'selected="selected"';?>><?php _e('CSV File', 'wp_all_export_plugin'); ?></option>
|
313 |
+
<option value="xls" <?php if ($post['export_to_sheet'] == 'xls') echo 'selected="selected"';?>><?php _e('Excel File', 'wp_all_export_plugin'); ?></option>
|
314 |
+
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
</div>
|
316 |
+
<div class="clear"></div>
|
317 |
+
<div class="wpallexport-clear"></div>
|
318 |
+
<div class="input export_to_xls_upgrade_notice" style="vertical-align:middle; position: relative; margin-top: 48px;">
|
319 |
+
<span class="wpallexport-free-edition-notice">
|
320 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=wooco+orders&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export to Export to Excel','wp_all_export_plugin');?></a>
|
321 |
+
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.','wp_all_export_plugin');?></p>
|
322 |
+
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
</div>
|
|
|
324 |
</div>
|
325 |
|
326 |
<div class="wpallexport-xml-options" <?php if ($post['export_to'] != 'xml') echo 'style="display:none;"'; ?>>
|
327 |
|
328 |
+
<div class="input" style="width:83%; margin: 0 auto 5px;">
|
329 |
+
<select name="xml_template_type" class="xml_template_type">
|
330 |
+
<option value="simple" <?php if ($post['xml_template_type'] == 'simple') echo 'selected="selected"';?>><?php _e('Simple XML Feed', 'wp_all_export_plugin'); ?></option>
|
331 |
+
<?php if ( XmlExportWooCommerce::$is_active ): ?>
|
332 |
+
<option value="XmlGoogleMerchants" <?php if ($post['xml_template_type'] == 'XmlGoogleMerchants') echo 'selected="selected"';?>><?php _e('Google Merchants Feed', 'wp_all_export_plugin'); ?></option>
|
333 |
+
<?php endif; ?>
|
334 |
+
<option value="custom" <?php if ($post['xml_template_type'] == 'custom') echo 'selected="selected"';?>><?php _e('Custom XML Feed', 'wp_all_export_plugin'); ?></option>
|
335 |
+
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
</div>
|
337 |
</div>
|
338 |
</div>
|
342 |
</div>
|
343 |
</div>
|
344 |
|
345 |
+
<div class="error inline" id="validationError" style="display: none;">
|
346 |
+
<p>
|
347 |
+
|
348 |
+
</p>
|
349 |
+
</div>
|
350 |
+
|
351 |
+
<div class="wpallexport-collapsed wpallexport-section wpallexport-custom-xml-template">
|
352 |
+
<div class="wpallexport-content-section" style="padding-bottom: 0; margin-bottom: 10px;">
|
353 |
+
<div class="wpallexport-collapsed-header" style="margin-bottom: 15px;">
|
354 |
+
<h3><?php _e('XML Editor', 'wp_all_export_plugin'); ?></h3>
|
355 |
+
</div>
|
356 |
+
<div class="wpallexport-collapsed-content" style="padding: 0;">
|
357 |
+
<div class="wpallexport-collapsed-content-inner" style="padding-top: 5px;">
|
358 |
+
|
359 |
+
<?php $default_template = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data>\n\t<!-- BEGIN LOOP -->\n\t<post>\n\n\t</post>\n\t<!-- END LOOP -->\n</data>";?>
|
360 |
+
|
361 |
+
<textarea id="wp_all_export_custom_xml_template" name="custom_xml_template"><?php echo (empty($post['custom_xml_template'])) ? $default_template : esc_textarea($post['custom_xml_template']);?></textarea>
|
362 |
+
|
363 |
+
<div class="input" style="overflow: hidden; margin-top: 10px; margin-bottom: -20px;">
|
364 |
+
<!-- Help Button -->
|
365 |
+
<div class="input" style="float: left;">
|
366 |
+
<input type="button" value="<?php _e('Help', 'wp_all_export_plugin');?>" class="help_custom_xml">
|
367 |
+
</div>
|
368 |
+
<!-- Preview a Row Button -->
|
369 |
+
<div class="input" style="float: right;">
|
370 |
+
<input type="button" value="<?php _e('Preview', 'wp_all_export_plugin');?>" class="preview_a_custom_xml_row">
|
371 |
+
</div>
|
372 |
+
</div>
|
373 |
+
</div>
|
374 |
+
<div class="wpallexport-collapsed closed wpallexport-section">
|
375 |
+
<div class="wpallexport-content-section rad0" style="margin:0; border-top:1px solid #ddd; border-bottom: none; border-right: none; border-left: none; background: #f1f2f2; padding-bottom: 15px; margin-top: 5px;">
|
376 |
+
<div class="wpallexport-collapsed-header">
|
377 |
+
<h3 style="color:#40acad;"><?php _e('Advanced Options','wp_all_export_plugin');?></h3>
|
378 |
+
<hr style="display: none; margin-right: 25px;"/>
|
379 |
+
</div>
|
380 |
+
<div class="wpallexport-collapsed-content" style="padding: 0 0 0 5px;">
|
381 |
+
<div class="wpallexport-collapsed-content-inner">
|
382 |
+
<div class="input">
|
383 |
+
<h4>CDATA</h4>
|
384 |
+
<p style="font-style: italic;"><?php echo sprintf(__("There are certain characters that cannot be included in an XML file unless they are wrapped in CDATA tags.<br/><a target='_blank' href='%s'>Click here to read more about CDATA tags.</a>", 'wp_all_export_plugin'), 'https://en.wikipedia.org/wiki/CDATA'); ?></p>
|
385 |
+
<div class="input" style="margin: 3px 0;">
|
386 |
+
<input type="radio" id="custom_xml_cdata_logic_auto" name="custom_custom_xml_cdata_logic" value="auto" <?php echo ( "auto" == $post['custom_xml_cdata_logic'] ) ? 'checked="checked"': '' ?> class="switcher"/>
|
387 |
+
<label for="custom_xml_cdata_logic_auto"><?php _e('Automatically wrap data in CDATA tags when it contains illegal characters', 'wp_all_export_plugin') ?></label>
|
388 |
+
</div>
|
389 |
+
<div class="input" style="margin: 3px 0;">
|
390 |
+
<input type="radio" id="custom_custom_xml_cdata_logic_all" name="custom_custom_xml_cdata_logic" value="all" <?php echo ( "all" == $post['custom_xml_cdata_logic'] ) ? 'checked="checked"': '' ?> class="switcher cdata"/>
|
391 |
+
<label for="custom_custom_xml_cdata_logic_all"><?php _e('Always wrap data in CDATA tags', 'wp_all_export_plugin') ?></label>
|
392 |
+
</div>
|
393 |
+
<div class="input" style="margin: 3px 0;">
|
394 |
+
<input type="radio" id="custom_custom_xml_cdata_logic_never" name="custom_custom_xml_cdata_logic" value="never" <?php echo ( "never" == $post['custom_xml_cdata_logic'] ) ? 'checked="checked"': '' ?> class="switcher cdata"/>
|
395 |
+
<label for="custom_custom_xml_cdata_logic_never"><?php _e('Never wrap data in CDATA tags', 'wp_all_export_plugin') ?></label>
|
396 |
+
<div class="switcher-target-simple_custom_xml_cdata_logic_never" style="padding-left:17px;">
|
397 |
+
<p style="font-style: italic;"><?php _e('Warning: This may result in an invalid XML file', 'wp_all_export_plugin');?></p>
|
398 |
+
</div>
|
399 |
+
</div>
|
400 |
+
<div class="input" style="margin: 10px 3px;">
|
401 |
+
<input type="checkbox" value="1" name="custom_show_cdata_in_preview" id="custom_show_cdata_in_preview" <?php echo ( 1 == $post['show_cdata_in_preview'] ) ? 'checked="checked"': '' ?> class="show_cdata_in_preview" />
|
402 |
+
<label for="custom_show_cdata_in_preview">Show CDATA tags in XML preview</label>
|
403 |
+
</div>
|
404 |
+
</div>
|
405 |
+
</div>
|
406 |
+
</div>
|
407 |
+
</div>
|
408 |
+
</div>
|
409 |
+
</div>
|
410 |
+
</div>
|
411 |
+
</div>
|
412 |
+
|
413 |
+
<?php
|
414 |
+
|
415 |
+
$uploads = wp_upload_dir();
|
416 |
+
$functions = $uploads['basedir'] . DIRECTORY_SEPARATOR . WP_ALL_EXPORT_UPLOADS_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'functions.php';
|
417 |
+
|
418 |
+
?>
|
419 |
+
|
420 |
+
<div class="wpallexport-collapsed closed wpallexport-section wpallexport-custom-xml-template">
|
421 |
+
<div class="wpallexport-content-section" style="padding-bottom: 15px; margin-bottom: 10px;">
|
422 |
+
<div class="wpallexport-collapsed-header">
|
423 |
+
<h3><?php _e('Function Editor', 'wp_all_export_plugin'); ?></h3>
|
424 |
+
</div>
|
425 |
+
<div class="wpallexport-collapsed-content" style="padding: 0;">
|
426 |
+
<div class="wpallexport-collapsed-content-inner">
|
427 |
+
|
428 |
+
<textarea id="wp_all_export_main_code" name="wp_all_export_main_code"><?php echo "<?php\n\n?>";?></textarea>
|
429 |
+
<div class="wpallexport-free-edition-notice" style="margin: 15px 0;">
|
430 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=custom-php&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export to use Custom PHP Functions','wp_all_export_plugin');?></a>
|
431 |
+
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.','wp_all_export_plugin');?></p>
|
432 |
+
</div>
|
433 |
+
<div class="input" style="margin-top: 10px;">
|
434 |
+
|
435 |
+
<div class="input" style="display:inline-block; margin-right: 20px;">
|
436 |
+
<input type="button" class="button-primary wp_all_export_save_functions wp_all_export_save_main_code" value="<?php _e("Save Functions", 'wp_all_export_plugin'); ?>" disabled="disabled"/>
|
437 |
+
<a href="#help" class="wpallexport-help" title="<?php printf(__("Add functions here for use during your export. You can access this file at %s", "wp_all_export_plugin"), preg_replace("%.*wp-content%", "wp-content", $functions));?>" style="top: 0;">?</a>
|
438 |
+
<div class="wp_all_export_functions_preloader"></div>
|
439 |
+
</div>
|
440 |
+
<div class="input wp_all_export_saving_status" style="display:inline-block;"></div>
|
441 |
+
</div>
|
442 |
+
</div>
|
443 |
+
</div>
|
444 |
+
</div>
|
445 |
+
</div>
|
446 |
+
|
447 |
<hr>
|
448 |
|
449 |
<div class="input wpallexport-section" style="padding-bottom: 8px; padding-left: 8px;">
|
474 |
|
475 |
<hr>
|
476 |
|
477 |
+
<div class="input custom_xml_upgrade_notice wpallexport-custom-xml-template" style="vertical-align:middle; position: relative; top: -5px;">
|
478 |
+
<span class="wpallexport-free-edition-notice" style="margin: 0 0 10px;">
|
479 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=wooco+orders&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export to Export Custom XML','wp_all_export_plugin');?></a>
|
480 |
+
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.','wp_all_export_plugin');?></p>
|
481 |
+
</span>
|
482 |
+
</div>
|
483 |
+
|
484 |
<div class="wpallexport-submit-buttons">
|
485 |
|
486 |
<div style="text-align:center; width:100%;">
|
487 |
<?php wp_nonce_field('template', '_wpnonce_template'); ?>
|
488 |
+
<input type="hidden" name="is_submitted" value="1" />
|
489 |
+
<input type="hidden" id="dismiss_warnings" value="<?php echo esc_attr($dismiss_warnings); ?>"/>
|
490 |
<?php if ( ! $this->isWizard ): ?>
|
491 |
<a href="<?php echo remove_query_arg('id', remove_query_arg('action', $this->baseUrl)); ?>" class="back rad3" style="float:none;"><?php _e('Back to Manage Exports', 'wp_all_export_plugin') ?></a>
|
492 |
<?php else: ?>
|
493 |
<a href="<?php echo add_query_arg('action', 'index', $this->baseUrl); ?>" class="back rad3"><?php _e('Back', 'wp_all_export_plugin') ?></a>
|
494 |
<?php endif; ?>
|
495 |
+
<input type="submit" class="button button-primary button-hero wpallexport-large-button wpallexport-submit-template" value="<?php _e( ($this->isWizard) ? 'Continue' : 'Update Template', 'wp_all_export_plugin') ?>" />
|
496 |
</div>
|
497 |
|
498 |
</div>
|
533 |
|
534 |
</fieldset>
|
535 |
|
536 |
+
<fieldset class="optionsset column rad4 wp-all-export-custom-xml-help">
|
537 |
+
|
538 |
+
<div class="title"><span style="font-size:1.5em;" class="wpallexport-add-row-title"><?php _e('Custom XML Feeds','wp_all_export_plugin');?></span><span class="wpallexport-edit-row-title"><?php _e('Edit Export Field','wp_all_export_plugin');?></span></div>
|
539 |
+
|
540 |
+
<?php include_once 'template/custom_xml_help.php'; ?>
|
541 |
+
|
542 |
+
</fieldset>
|
543 |
+
|
544 |
<div class="wpallexport-overlay"></div>
|
views/admin/export/template/add_new_field.php
CHANGED
@@ -18,6 +18,13 @@
|
|
18 |
|
19 |
<?php include_once 'advanced_field_options.php'; ?>
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
</div>
|
22 |
<div class="input wp-all-export-edit-column-buttons">
|
23 |
<input type="button" class="delete_action" value="<?php _e("Delete", "wp_all_export_plugin"); ?>" style="border: none;"/>
|
18 |
|
19 |
<?php include_once 'advanced_field_options.php'; ?>
|
20 |
|
21 |
+
<div class="input disabled_fields_upgrade_notice" style="vertical-align:middle; position: relative;">
|
22 |
+
<span class="wpallexport-free-edition-notice">
|
23 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=wooco+orders&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export to Export Order Data','wp_all_export_plugin');?></a>
|
24 |
+
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.','wp_all_export_plugin');?></p>
|
25 |
+
</span>
|
26 |
+
</div>
|
27 |
+
|
28 |
</div>
|
29 |
<div class="input wp-all-export-edit-column-buttons">
|
30 |
<input type="button" class="delete_action" value="<?php _e("Delete", "wp_all_export_plugin"); ?>" style="border: none;"/>
|
views/admin/export/template/advanced_field_options.php
CHANGED
@@ -60,7 +60,8 @@
|
|
60 |
<a href="#help" class="wpallexport-help" title="<?php _e('The value of the field chosen for export will be passed to the PHP function.', 'wp_all_export_plugin'); ?>" style="top: 0;">?</a>
|
61 |
<div class="switcher-target-coperate_php" style="margin-top:5px;">
|
62 |
<div class="wpallexport-free-edition-notice" style="margin: 15px 0;">
|
63 |
-
<a class="upgrade_link" target="_blank" href="
|
|
|
64 |
</div>
|
65 |
<?php echo "<?php ";?>
|
66 |
<input type="text" class="php_code" value="" style="width:50%;" placeholder='your_function_name'/>
|
60 |
<a href="#help" class="wpallexport-help" title="<?php _e('The value of the field chosen for export will be passed to the PHP function.', 'wp_all_export_plugin'); ?>" style="top: 0;">?</a>
|
61 |
<div class="switcher-target-coperate_php" style="margin-top:5px;">
|
62 |
<div class="wpallexport-free-edition-notice" style="margin: 15px 0;">
|
63 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=custom-php&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export to use Custom PHP Functions','wp_all_export_plugin');?></a>
|
64 |
+
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.','wp_all_export_plugin');?></p>
|
65 |
</div>
|
66 |
<?php echo "<?php ";?>
|
67 |
<input type="text" class="php_code" value="" style="width:50%;" placeholder='your_function_name'/>
|
views/admin/export/template/custom_xml_help.php
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div id="wp-all-export-custom-xml-help-inner" class="wp_all_export_custom_xml_help">
|
2 |
+
|
3 |
+
<p style="margin-top:5px;"><?php _e('The custom XML editor makes it easy to create an XML file with the exact structure you need. The syntax is simple and straightforward, yet powerful enough to allow you to pass your data through custom PHP functions.', 'wp_all_export_plugin'); ?></p>
|
4 |
+
|
5 |
+
<h3 id="wpae_help_custom_xml_editor_tab"><span>+</span> <?php _e('Custom XML Editor', 'wp_all_export_plugin'); ?></h3>
|
6 |
+
|
7 |
+
<div rel="wpae_help_custom_xml_editor_tab" class="wp_all_export_help_tab">
|
8 |
+
<p><?php _e('The custom XML editor is a template for your custom XML feed. Everything between the <span class="wp_all_export_code"><span class="wp_all_export_code_comment"><!-- BEGIN LOOP --></span> and <span class="wp_all_export_code_comment"><!-- END LOOP --></span></span> tags will be repeated for each exported post.','wp_all_export_plugin');?></p>
|
9 |
+
<p><?php _e('You can drag and drop elements from Available Data on the right into the editor on the left. You can also manually enter data into the export template.','wp_all_export_plugin');?></p>
|
10 |
+
<p><?php _e('For example, to add the post title to your export, you can either drag the title element into the editor, or you can manually edit the export template in editor to add it like this: <span class="wp_all_export_code"><span class="wp_all_export_code_tag"><my_custom_title><span class="wp_all_export_code_text">{Title}</span></my_custom_title></span></span>', 'wp_all_export_plugin');?></p>
|
11 |
+
</div>
|
12 |
+
|
13 |
+
<h3 id="wpae_help_php_functions_tab"><span>+</span> <?php _e('PHP Functions', 'wp_all_export_plugin'); ?></h3>
|
14 |
+
|
15 |
+
<div rel="wpae_help_php_functions_tab" class="wp_all_export_help_tab">
|
16 |
+
<p><?php _e('To add a PHP function to your XML template wrap it in brackets: <span class="wp_all_export_code"><span class="wp_all_export_code_text">[my_function({Content})]','wp_all_export_plugin');?></span></span></p>
|
17 |
+
<p><?php _e('Whatever your function returns will appear in your exported XML file. You can pass as many elements as you like to your function so that they can be combined and processed in any way.','wp_all_export_plugin');?></p>
|
18 |
+
</div>
|
19 |
+
|
20 |
+
<h3 id="wpae_help_repeating_fields_tab"><span>+</span> <?php _e('Repeating Fields and Arrays', 'wp_all_export_plugin'); ?></h3>
|
21 |
+
|
22 |
+
<div rel="wpae_help_repeating_fields_tab" class="wp_all_export_help_tab">
|
23 |
+
<p><?php _e('Some fields, like images, may have multiple values per post. When WP All Export encounters an indexed array in the content of an XML element it will repeat that element once for every value in the array.', 'wp_all_export_plugin');?></p>
|
24 |
+
<p><?php _e('For example, let\'s assume a post as two images attached to it - image1.jpg and image2.jpg - and we want to have one XML element for every image URL. Here\'s what our XML template will look like:', 'wp_all_export_plugin');?></p>
|
25 |
+
|
26 |
+
<div class="wp_all_export_code code-block">
|
27 |
+
<p class="wp_all_export_code_tag"><images></p>
|
28 |
+
<p class="wp_all_export_code_tag lv2"><image_url><span class="wp_all_export_code_text">{Image URL}</span></image_url></p>
|
29 |
+
<p class="wp_all_export_code_tag"></images></p>
|
30 |
+
</div>
|
31 |
+
|
32 |
+
<p><?php _e('And here\'s how our exported XML file will look:', 'wp_all_export_plugin');?></p>
|
33 |
+
|
34 |
+
<div class="wp_all_export_code code-block">
|
35 |
+
<p class="wp_all_export_code_tag"><images></p>
|
36 |
+
<p class="wp_all_export_code_tag lv2"><image_url><span class="wp_all_export_code_text">http://example.com/image1.jpg</span></image_url></p>
|
37 |
+
<p class="wp_all_export_code_tag lv2"><image_url><span class="wp_all_export_code_text">http://example.com/image2.jpg</span></image_url></p>
|
38 |
+
<p class="wp_all_export_code_tag"></images></p>
|
39 |
+
</div>
|
40 |
+
</div>
|
41 |
+
|
42 |
+
<h3 id="wpae_help_example_template_tab"><span>+</span> <?php _e('Example Template', 'wp_all_export_plugin');?></h3>
|
43 |
+
|
44 |
+
<div rel="wpae_help_example_template_tab" class="wp_all_export_help_tab">
|
45 |
+
|
46 |
+
<p><?php _e('Let\'s say we want to make an XML feed of our WooCommerce products with these requirements:', 'wp_all_export_plugin'); ?></p>
|
47 |
+
<ul>
|
48 |
+
<li><?php _e('Site name below the header, before the <span class="wp_all_export_code"><span class="wp_all_export_code_tag"><products></span></span> element', 'wp_all_export_plugin');?></li>
|
49 |
+
<li><?php _e('Product SKU', 'wp_all_export_plugin');?></li>
|
50 |
+
<li><?php _e('Product Title', 'wp_all_export_plugin');?></li>
|
51 |
+
<li><?php _e('Product Price (processed via a PHP function so that they end in .99)', 'wp_all_export_plugin');?></li>
|
52 |
+
<li><?php _e('Product image URLs wrapped in an <span class="wp_all_export_code"><span class="wp_all_export_code_tag"><images></span></span> element', 'wp_all_export_plugin');?></li>
|
53 |
+
</ul>
|
54 |
+
<p><?php _e('Here\'s what our XML template will look like in the editor:', 'wp_all_export_plugin'); ?></p>
|
55 |
+
<div class="wp_all_export_code code-block">
|
56 |
+
<p class="wp_all_export_code_tag cm-s-default"><span class="cm-meta"><?xml version="1.0" encoding="UTF-8"?></span></p>
|
57 |
+
<p class="wp_all_export_code_tag"><site_name><span class="wp_all_export_code_text">My Soda Store</span></site_name></p>
|
58 |
+
<p class="wp_all_export_code_tag"><products></p>
|
59 |
+
<p class="wp_all_export_code_comment lv1"><!-- BEGIN POST LOOP --></p>
|
60 |
+
<p class="wp_all_export_code_tag lv1"><product></p>
|
61 |
+
<p class="wp_all_export_code_tag lv2"><sku><span class="wp_all_export_code_text">{SKU}</span></sku></p>
|
62 |
+
<p class="wp_all_export_code_tag lv2"><title><span class="wp_all_export_code_text">{Title}</span></title></p>
|
63 |
+
<p class="wp_all_export_code_tag lv2"><price><span class="wp_all_export_code_text">[my_price_function({Price})]</span></price></p>
|
64 |
+
<p class="wp_all_export_code_tag lv2"><images></p>
|
65 |
+
<p class="wp_all_export_code_tag lv3"><image_url><span class="wp_all_export_code_text">{Image URL}</span></image_url></p>
|
66 |
+
<p class="wp_all_export_code_tag lv2"></images></p>
|
67 |
+
<p class="wp_all_export_code_tag lv1"></product></p>
|
68 |
+
<p class="wp_all_export_code_comment lv1"><!-- END POST LOOP --></p>
|
69 |
+
<p class="wp_all_export_code_tag"></products></p>
|
70 |
+
</div>
|
71 |
+
|
72 |
+
<p><?php _e('Then in the Function Editor we\'d define my_price_function() like so:', 'wp_all_export_plugin');?></p>
|
73 |
+
|
74 |
+
<p class="cm-s-default code-block">
|
75 |
+
<span class="cm-keyword">function</span> <span class="cm-def">my_price_function</span>( <span class="cm-variable-2">$price</span> ) {<br/>
|
76 |
+
<span class="cm-keyword">return</span> <span class="cm-builtin">number_format</span>(<span class="cm-builtin">round</span>(<span class="cm-variable-2">$price</span>,0)-0.01,2);<br/>
|
77 |
+
}
|
78 |
+
</p>
|
79 |
+
|
80 |
+
<p><?php _e('If we had two products, each with two images, here\'s what our XML file would look like:', 'wp_all_export_plugin');?></p>
|
81 |
+
|
82 |
+
<div class="wp_all_export_code code-block">
|
83 |
+
<p class="wp_all_export_code_tag cm-s-default"><span class="cm-meta"><?xml version="1.0" encoding="UTF-8"?></span></p>
|
84 |
+
<p class="wp_all_export_code_tag"><site_name><span class="wp_all_export_code_text">My Soda Store</span></site_name></p>
|
85 |
+
<p class="wp_all_export_code_tag"><products></p>
|
86 |
+
<p class="wp_all_export_code_tag lv1"><product></p>
|
87 |
+
<p class="wp_all_export_code_tag lv2"><sku><span class="wp_all_export_code_text">pepsi_cola</span></sku></p>
|
88 |
+
<p class="wp_all_export_code_tag lv2"><title><span class="wp_all_export_code_text">Pepsi</span></title></p>
|
89 |
+
<p class="wp_all_export_code_tag lv2"><price><span class="wp_all_export_code_text">1.99</span></price></p>
|
90 |
+
<p class="wp_all_export_code_tag lv2"><images></p>
|
91 |
+
<p class="wp_all_export_code_tag lv3"><image_url><span class="wp_all_export_code_text">http://example.com/pepsi_1.jpg</span></image_url></p>
|
92 |
+
<p class="wp_all_export_code_tag lv3"><image_url><span class="wp_all_export_code_text">http://example.com/pepsi_2.jpg</span></image_url></p>
|
93 |
+
<p class="wp_all_export_code_tag lv2"></images></p>
|
94 |
+
<p class="wp_all_export_code_tag lv1"></product></p>
|
95 |
+
<p class="wp_all_export_code_tag lv1"><product></p>
|
96 |
+
<p class="wp_all_export_code_tag lv2"><sku><span class="wp_all_export_code_text">coca_cola</span></sku></p>
|
97 |
+
<p class="wp_all_export_code_tag lv2"><title><span class="wp_all_export_code_text">Coke</span></title></p>
|
98 |
+
<p class="wp_all_export_code_tag lv2"><price><span class="wp_all_export_code_text">1.99</span></price></p>
|
99 |
+
<p class="wp_all_export_code_tag lv2"><images></p>
|
100 |
+
<p class="wp_all_export_code_tag lv3"><image_url><span class="wp_all_export_code_text">http://example.com/coke_1.jpg</span></image_url></p>
|
101 |
+
<p class="wp_all_export_code_tag lv3"><image_url><span class="wp_all_export_code_text">http://example.com/coke_2.jpg</span></image_url></p>
|
102 |
+
<p class="wp_all_export_code_tag lv2"></images></p>
|
103 |
+
<p class="wp_all_export_code_tag lv1"></product></p>
|
104 |
+
<p class="wp_all_export_code_tag"></products></p>
|
105 |
+
</div>
|
106 |
+
</div>
|
107 |
+
</div>
|
views/admin/help/index.php
CHANGED
@@ -7,15 +7,14 @@
|
|
7 |
<tr>
|
8 |
<td class="left">
|
9 |
<p style="font-size: 1.3em !important;">
|
10 |
-
<b>E-mail</b> - <a href="mailto:support@wpallimport.com?Subject=WP%20All%20Export">support@wpallimport.com</a><br>
|
11 |
<b>Support Form </b> - <a target="_blank" href="http://www.wpallimport.com/support/?utm_source=wordpress.org&utm_medium=support-page&utm_campaign=free+wp+all+export+plugin">http://www.wpallimport.com/support</a>
|
12 |
</p>
|
13 |
|
14 |
-
<p style="font-size: 1.3em !important;"><?php _e('
|
15 |
|
16 |
-
<p style="font-size: 1.3em !important;"><?php _e('While we do our best to provide technical support to users of the free version, we must prioritize requests from
|
17 |
|
18 |
-
<p style="font-size: 1.3em !important;"><a href="
|
19 |
|
20 |
</td>
|
21 |
<td class="right"> </td>
|
7 |
<tr>
|
8 |
<td class="left">
|
9 |
<p style="font-size: 1.3em !important;">
|
|
|
10 |
<b>Support Form </b> - <a target="_blank" href="http://www.wpallimport.com/support/?utm_source=wordpress.org&utm_medium=support-page&utm_campaign=free+wp+all+export+plugin">http://www.wpallimport.com/support</a>
|
11 |
</p>
|
12 |
|
13 |
+
<p style="font-size: 1.3em !important;"><?php _e('Thank you for using WP All Export.', 'wp_all_export_plugin');?></p>
|
14 |
|
15 |
+
<p style="font-size: 1.3em !important;"><?php _e('While we do our best to provide technical support to users of the free version, we must prioritize requests from Pro users. If you need help with WP All Export please submit a ticket through the support form.', 'wp_all_export_plugin');?></p>
|
16 |
|
17 |
+
<p style="font-size: 1.3em !important;"><a href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=support-page&utm_campaign=free+wp+all+export+plugin" target="_blank"><?php _e('Upgrade to the Pro edition of WP All Export for Premium Support', 'wp_all_export_plugin');?></a></p>
|
18 |
|
19 |
</td>
|
20 |
<td class="right"> </td>
|
views/admin/manage/index.php
CHANGED
@@ -165,7 +165,12 @@ $columns = apply_filters('pmxe_manage_imports_columns', $columns);
|
|
165 |
$is_re_import_allowed = true;
|
166 |
if ( ! empty($item['options']['ids']) )
|
167 |
{
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
169 |
// re-import products
|
170 |
if ((in_array('product', $item['options']['cpt']) or $item['options']['export_type'] == 'advanced') and class_exists('WooCommerce') and (empty($item['options']['wp_query_selector']) or $item['options']['wp_query_selector'] == 'wp_query')) {
|
171 |
$required_fields['woo'] = '_sku';
|
@@ -206,22 +211,23 @@ $columns = apply_filters('pmxe_manage_imports_columns', $columns);
|
|
206 |
}
|
207 |
|
208 |
?>
|
209 |
-
<?php if (
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
|
|
222 |
}
|
223 |
-
|
224 |
-
?>
|
225 |
</td>
|
226 |
<?php
|
227 |
break;
|
165 |
$is_re_import_allowed = true;
|
166 |
if ( ! empty($item['options']['ids']) )
|
167 |
{
|
168 |
+
if (in_array('shop_order', $item['options']['cpt']) and class_exists('WooCommerce')) {
|
169 |
+
$required_fields = array('woo_order' => 'id');
|
170 |
+
}
|
171 |
+
else {
|
172 |
+
$required_fields = array('id' => 'id');
|
173 |
+
}
|
174 |
// re-import products
|
175 |
if ((in_array('product', $item['options']['cpt']) or $item['options']['export_type'] == 'advanced') and class_exists('WooCommerce') and (empty($item['options']['wp_query_selector']) or $item['options']['wp_query_selector'] == 'wp_query')) {
|
176 |
$required_fields['woo'] = '_sku';
|
211 |
}
|
212 |
|
213 |
?>
|
214 |
+
<?php if ( $item['options']['export_to'] == 'csv' || ( empty($item['options']['xml_template_type']) || ! in_array($item['options']['xml_template_type'], array('custom', 'XmlGoogleMerchants'))) ): ?>
|
215 |
+
<?php if ( wp_all_export_is_compatible() and !empty($item['options']['import_id']) and $is_re_import_allowed): ?>
|
216 |
+
<a href="<?php echo add_query_arg(array('page' => 'pmxi-admin-import', 'id' => $item['options']['import_id'], 'deligate' => 'wpallexport'), remove_query_arg('page', $this->baseUrl)); ?>"><?php _e("Import with WP All Import", "wp_all_export_plugin"); ?></a><br/>
|
217 |
+
<?php endif;?>
|
218 |
+
<?php
|
219 |
+
if ( !in_array($item['options']['wp_query_selector'], array('wp_comment_query')) and (empty($item['options']['cpt']) or ! in_array('comments', $item['options']['cpt']))) {
|
220 |
+
if ( ! empty($item['options']['tpl_data'])) {
|
221 |
+
//$template->getByName($item['options']['template_name']);
|
222 |
+
//if ( ! $template->isEmpty() ){
|
223 |
+
?>
|
224 |
+
<a href="<?php echo add_query_arg(array('id' => $item['id'], 'action' => 'templates'), $this->baseUrl)?>"><?php _e('Download Import Templates', 'wp_all_export_plugin'); ?></a>
|
225 |
+
<?php
|
226 |
+
//}
|
227 |
+
}
|
228 |
}
|
229 |
+
?>
|
230 |
+
<?php endif; ?>
|
231 |
</td>
|
232 |
<?php
|
233 |
break;
|
views/admin/manage/scheduling.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
</h2>
|
4 |
|
5 |
<div class="wpallexport-free-edition-notice" style="padding: 20px; margin-left: 0px;">
|
6 |
-
<a class="upgrade_link" target="_blank" href="
|
7 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
8 |
</div>
|
9 |
|
3 |
</h2>
|
4 |
|
5 |
<div class="wpallexport-free-edition-notice" style="padding: 20px; margin-left: 0px;">
|
6 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=cron&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export for Scheduled Exports', 'wp_all_export_plugin');?></a>
|
7 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
8 |
</div>
|
9 |
|
views/admin/manage/update.php
CHANGED
@@ -42,12 +42,8 @@
|
|
42 |
|
43 |
<div class="wpallexport-content-section" style="padding: 0 30px 0 0; overflow: hidden; margin-bottom: 0;">
|
44 |
|
45 |
-
<div id="filtering_result" class="wpallexport-ready-to-go
|
46 |
-
|
47 |
-
<h3><?php _e('Nothing to export.', 'wp_all_export_plugin'); ?></h3>
|
48 |
-
<?php else: ?>
|
49 |
-
<h3><?php _e('Your export is ready to run.', 'wp_all_export_plugin'); ?></h3>
|
50 |
-
<?php endif; ?>
|
51 |
<div class="wp_all_export_preloader"></div>
|
52 |
</div>
|
53 |
|
42 |
|
43 |
<div class="wpallexport-content-section" style="padding: 0 30px 0 0; overflow: hidden; margin-bottom: 0;">
|
44 |
|
45 |
+
<div id="filtering_result" class="wpallexport-ready-to-go">
|
46 |
+
<h3> </h3>
|
|
|
|
|
|
|
|
|
47 |
<div class="wp_all_export_preloader"></div>
|
48 |
</div>
|
49 |
|
views/admin/settings/index.php
CHANGED
@@ -107,7 +107,7 @@
|
|
107 |
</table>
|
108 |
|
109 |
<div class="wpallexport-free-edition-notice" style="margin: 15px 0; padding: 20px;">
|
110 |
-
<a class="upgrade_link" target="_blank" href="
|
111 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
112 |
</div>
|
113 |
|
@@ -129,13 +129,12 @@
|
|
129 |
<br>
|
130 |
<h3><?php _e('Function Editor', 'pmxe_plugin') ?></h3>
|
131 |
|
|
|
132 |
<div class="wpallexport-free-edition-notice" style="margin: 15px 0; padding: 20px;">
|
133 |
-
<a class="upgrade_link" target="_blank" href="
|
134 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
135 |
</div>
|
136 |
|
137 |
-
<textarea id="wp_all_export_code" name="wp_all_export_code"><?php echo "<?php\n\n?>";?></textarea>
|
138 |
-
|
139 |
<div class="input" style="margin-top: 10px;">
|
140 |
|
141 |
<div class="input" style="display:inline-block; margin-right: 20px;">
|
@@ -146,7 +145,6 @@
|
|
146 |
<div class="input wp_all_export_saving_status" style="display:inline-block;">
|
147 |
|
148 |
</div>
|
149 |
-
|
150 |
</div>
|
151 |
|
152 |
<a href="http://soflyy.com/" target="_blank" class="wpallexport-created-by"><?php _e('Created by', 'wp_all_export_plugin'); ?> <span></span></a>
|
107 |
</table>
|
108 |
|
109 |
<div class="wpallexport-free-edition-notice" style="margin: 15px 0; padding: 20px;">
|
110 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=custom-php&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export for Zapier Integration','wp_all_export_plugin');?></a>
|
111 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
112 |
</div>
|
113 |
|
129 |
<br>
|
130 |
<h3><?php _e('Function Editor', 'pmxe_plugin') ?></h3>
|
131 |
|
132 |
+
<textarea id="wp_all_export_code" name="wp_all_export_code"><?php echo "<?php\n\n?>";?></textarea>
|
133 |
<div class="wpallexport-free-edition-notice" style="margin: 15px 0; padding: 20px;">
|
134 |
+
<a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=118611&edd_options%5Bprice_id%5D=1&utm_source=wordpress.org&utm_medium=custom-php&utm_campaign=free+wp+all+export+plugin"><?php _e('Upgrade to the Pro edition of WP All Export to enable the Function Editor','wp_all_export_plugin');?></a>
|
135 |
<p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_export_plugin'); ?></p>
|
136 |
</div>
|
137 |
|
|
|
|
|
138 |
<div class="input" style="margin-top: 10px;">
|
139 |
|
140 |
<div class="input" style="display:inline-block; margin-right: 20px;">
|
145 |
<div class="input wp_all_export_saving_status" style="display:inline-block;">
|
146 |
|
147 |
</div>
|
|
|
148 |
</div>
|
149 |
|
150 |
<a href="http://soflyy.com/" target="_blank" class="wpallexport-created-by"><?php _e('Created by', 'wp_all_export_plugin'); ?> <span></span></a>
|
wp-all-export.php
CHANGED
@@ -3,10 +3,12 @@
|
|
3 |
Plugin Name: WP All Export
|
4 |
Plugin URI: http://www.wpallimport.com/export/
|
5 |
Description: Export any post type to a CSV or XML file. Edit the exported data, and then re-import it later using WP All Import.
|
6 |
-
Version: 1.0.
|
7 |
Author: Soflyy
|
8 |
*/
|
9 |
|
|
|
|
|
10 |
if( ! defined( 'PMXE_SESSION_COOKIE' ) )
|
11 |
define( 'PMXE_SESSION_COOKIE', '_pmxe_session' );
|
12 |
|
@@ -50,7 +52,7 @@ else {
|
|
50 |
*/
|
51 |
define('PMXE_PREFIX', 'pmxe_');
|
52 |
|
53 |
-
define('PMXE_VERSION', '1.0.
|
54 |
|
55 |
define('PMXE_EDITION', 'free');
|
56 |
|
@@ -621,7 +623,7 @@ else {
|
|
621 |
'filter_rules_hierarhy' => '',
|
622 |
'product_matching_mode' => 'parent',
|
623 |
'order_item_per_row' => 1,
|
624 |
-
'order_item_fill_empty_columns' =>
|
625 |
'filepath' => '',
|
626 |
'current_filepath' => '',
|
627 |
'bundlepath' => '',
|
@@ -672,7 +674,16 @@ else {
|
|
672 |
'order_include_coupons' => 0,
|
673 |
'order_include_all_coupons' => 0,
|
674 |
'order_include_customers' => 0,
|
675 |
-
'order_include_all_customers' => 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
676 |
);
|
677 |
}
|
678 |
|
3 |
Plugin Name: WP All Export
|
4 |
Plugin URI: http://www.wpallimport.com/export/
|
5 |
Description: Export any post type to a CSV or XML file. Edit the exported data, and then re-import it later using WP All Import.
|
6 |
+
Version: 1.0.8
|
7 |
Author: Soflyy
|
8 |
*/
|
9 |
|
10 |
+
require_once(__DIR__.'/classes/CdataStrategyFactory.php');
|
11 |
+
|
12 |
if( ! defined( 'PMXE_SESSION_COOKIE' ) )
|
13 |
define( 'PMXE_SESSION_COOKIE', '_pmxe_session' );
|
14 |
|
52 |
*/
|
53 |
define('PMXE_PREFIX', 'pmxe_');
|
54 |
|
55 |
+
define('PMXE_VERSION', '1.0.8');
|
56 |
|
57 |
define('PMXE_EDITION', 'free');
|
58 |
|
623 |
'filter_rules_hierarhy' => '',
|
624 |
'product_matching_mode' => 'parent',
|
625 |
'order_item_per_row' => 1,
|
626 |
+
'order_item_fill_empty_columns' => 1,
|
627 |
'filepath' => '',
|
628 |
'current_filepath' => '',
|
629 |
'bundlepath' => '',
|
674 |
'order_include_coupons' => 0,
|
675 |
'order_include_all_coupons' => 0,
|
676 |
'order_include_customers' => 0,
|
677 |
+
'order_include_all_customers' => 0,
|
678 |
+
'migration' => '',
|
679 |
+
'xml_template_type' => 'simple',
|
680 |
+
'custom_xml_template' => '',
|
681 |
+
'custom_xml_template_header' => '',
|
682 |
+
'custom_xml_template_loop' => '',
|
683 |
+
'custom_xml_template_footer' => '',
|
684 |
+
'custom_xml_template_options' => array(),
|
685 |
+
'custom_xml_cdata_logic' => 'auto',
|
686 |
+
'show_cdata_in_preview' => 0
|
687 |
);
|
688 |
}
|
689 |
|