PluginProbe ʕ •ᴥ•ʔ
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel / trunk
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel vtrunk
trunk 0.9.0 0.9.1 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0
wp-all-export / libraries / XmlExportEngine.php
wp-all-export / libraries Last commit date
VariableProductTitle 4 weeks ago .gitkeep 10 years ago WpaeInvalidPhpException.php 9 years ago WpaeInvalidStringException.php 9 years ago WpaeMethodNotFoundException.php 9 years ago WpaePhpInterpreterErrorHandler.php 4 weeks ago WpaeString.php 8 years ago WpaeTooMuchRecursionException.php 9 years ago XmlCsvExport.php 4 weeks ago XmlExportCpt.php 4 weeks ago XmlExportCustomRecord.php 4 weeks ago XmlExportEngine.php 4 weeks ago XmlExportFiltering.php 4 weeks ago XmlExportMediaGallery.php 4 weeks ago XmlExportTaxonomy.php 4 weeks ago
XmlExportEngine.php
1377 lines
1 <?php
2
3 // phpcs:ignoreFile WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound,WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound,WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- legitimate plugin prefixes (pmxe/PMXE/wpae/Wpae/wp_all_export/wpallexport/XmlExport/CdataStrategy/VariableProductTitle/Soflyy/GF_Export); Plugin Check does not honor phpcs.xml prefix declaration
4 defined( 'ABSPATH' ) || exit;
5
6
7 if ( ! class_exists('XmlExportEngine') ){
8
9 require_once dirname(__FILE__) . '/XmlExportTaxonomy.php';
10
11 final class XmlExportEngine
12 {
13
14 const VARIABLE_PRODUCTS_EXPORT_PARENT_AND_VARIATION = 1;
15 const VARIABLE_PRODUCTS_EXPORT_VARIATION = 2;
16 const VARIABLE_PRODUCTS_EXPORT_PARENT = 3;
17
18 const VARIATION_USE_PARENT_TITLE = 1;
19 const VARIATION_USE_DEFAULT_TITLE = 2;
20
21 /**
22 * Custom XML Loop begin statement
23 * @var string
24 */
25 const XML_LOOP_START = '<!-- BEGIN LOOP -->';
26
27 /**
28 * Custom XML Loop end statement
29 * @var string
30 */
31 const XML_LOOP_END = '<!-- END LOOP -->';
32
33 const EXPORT_TYPE_GOOLE_MERCHANTS = 'XmlGoogleMerchants';
34 const EXPORT_TYPE_XML = 'xml';
35 const EXPORT_TYPE_CSV = 'csv';
36
37 public static $acf_export;
38 public static $woo_export = false;
39 public static $woo_order_export;
40 public static $woo_coupon_export;
41 public static $woo_refund_export;
42 public static $woo_review_export;
43 public static $user_export = false;
44 public static $taxonomy_export;
45 public static $custom_record_export;
46
47 public static $is_woo_order_export = false;
48
49 public static $is_preview = false;
50
51 public static $implode = ',';
52
53 private $post;
54 private $_existing_meta_keys = array();
55 private $_existing_taxonomies = array();
56
57 private static $addons_service = false;
58
59 private $init_fields = array(
60 array(
61 'label' => 'id',
62 'name' => 'ID',
63 'type' => 'id'
64 ),
65 array(
66 'label' => 'title',
67 'name' => 'Title',
68 'type' => 'title'
69 ),
70 array(
71 'label' => 'content',
72 'name' => 'Content',
73 'type' => 'content'
74 )
75 );
76
77 public static $default_fields = array(
78 array(
79 'label' => 'id',
80 'name' => 'ID',
81 'type' => 'id'
82 ),
83 array(
84 'label' => 'title',
85 'name' => 'Title',
86 'type' => 'title'
87 ),
88 array(
89 'label' => 'content',
90 'name' => 'Content',
91 'type' => 'content'
92 ),
93 array(
94 'label' => 'excerpt',
95 'name' => 'Excerpt',
96 'type' => 'excerpt'
97 ),
98 array(
99 'label' => 'date',
100 'name' => 'Date',
101 'type' => 'date'
102 ),
103 array(
104 'label' => 'post_type',
105 'name' => 'Post Type',
106 'type' => 'post_type'
107 ),
108 array(
109 'label' => 'permalink',
110 'name' => 'Permalink',
111 'type' => 'permalink'
112 )
113 );
114
115 private $other_fields = array(
116 array(
117 'label' => 'status',
118 'name' => 'Status',
119 'type' => 'status'
120 ),
121
122 array(
123 'label' => 'author',
124 'name' => 'Author ID',
125 'type' => 'author'
126 ),
127
128 array(
129 'label' => 'author_username',
130 'name' => 'Author Username',
131 'type' => 'author_username'
132 ),
133
134 array(
135 'label' => 'author_email',
136 'name' => 'Author Email',
137 'type' => 'author_email'
138 ),
139
140 array(
141 'label' => 'author_first_name',
142 'name' => 'Author First Name',
143 'type' => 'author_first_name'
144 ),
145
146 array(
147 'label' => 'author_last_name',
148 'name' => 'Author Last Name',
149 'type' => 'author_last_name'
150 ),
151
152 array(
153 'label' => 'slug',
154 'name' => 'Slug',
155 'type' => 'slug'
156 ),
157 array(
158 'label' => 'format',
159 'name' => 'Format',
160 'type' => 'format'
161 ),
162 array(
163 'label' => 'template',
164 'name' => 'Template',
165 'type' => 'template'
166 ),
167 array(
168 'label' => 'parent',
169 'name' => 'Parent',
170 'type' => 'parent'
171 ),
172 array(
173 'label' => 'parent_slug',
174 'name' => 'Parent Slug',
175 'type' => 'parent_slug'
176 ),
177 array(
178 'label' => 'order',
179 'name' => 'Order',
180 'type' => 'order'
181 ),
182 array(
183 'label' => 'comment_status',
184 'name' => 'Comment Status',
185 'type' => 'comment_status'
186 ),
187 array(
188 'label' => 'ping_status',
189 'name' => 'Ping Status',
190 'type' => 'ping_status'
191 ),
192 array(
193 'label' => 'post_modified',
194 'name' => 'Post Modified Date',
195 'type' => 'post_modified'
196 )
197 );
198
199 private $available_sections = array();
200 private $filter_sections = array();
201
202 private $errors;
203
204 private $available_data = array(
205 'acf_groups' => array(),
206 'existing_acf_meta_keys' => array(),
207 'existing_meta_keys' => array(),
208 'init_fields' => array(),
209 'default_fields' => array(),
210 'other_fields' => array(),
211 'woo_data' => array(),
212 'existing_attributes' => array(),
213 'existing_taxonomies' => array()
214 );
215
216 private $filters;
217
218 public static $is_user_export = false;
219 public static $is_comment_export = false;
220 public static $is_taxonomy_export = false;
221 public static $is_custom_addon_export = false;
222 public static $post_types = array();
223 public static $exportOptions = array();
224 public static $exportQuery;
225 public static $exportID = false;
226 public static $exportRecord = false;
227 public static $globalAvailableSections;
228
229 public static $is_auto_generate_enabled = true;
230
231 public function __construct( $post, & $errors = false ){
232
233 $this->post = $post;
234 $this->errors = $errors;
235
236 $this->available_sections = array(
237 'default' => array(
238 'title' => __("Standard", "wp-all-export"),
239 'content' => 'default_fields'
240 ),
241 'media' => array(
242 'title' => __("Media", "wp-all-export"),
243 'content' => '',
244 'additional' => array(
245 'images' => array(
246 'title' => __("Images", "wp-all-export"),
247 'meta' => array(
248 array(
249 'name' => 'URL',
250 'label' => 'url',
251 'type' => 'image_url',
252 'auto' => 1
253 ),
254 array(
255 'name' => 'Filename',
256 'label' => 'filename',
257 'type' => 'image_filename'
258 ),
259 array(
260 'name' => 'Path',
261 'label' => 'path',
262 'type' => 'image_path'
263 ),
264 array(
265 'name' => 'ID',
266 'label' => 'image_id',
267 'type' => 'image_id'
268 ),
269 array(
270 'name' => 'Title',
271 'label' => 'title',
272 'type' => 'image_title',
273 'auto' => 1
274 ),
275 array(
276 'name' => 'Caption',
277 'label' => 'caption',
278 'type' => 'image_caption',
279 'auto' => 1
280 ),
281 array(
282 'name' => 'Description',
283 'label' => 'description',
284 'type' => 'image_description',
285 'auto' => 1
286 ),
287 array(
288 'name' => 'Alt Text',
289 'label' => 'alt',
290 'type' => 'image_alt',
291 'auto' => 1
292 ),
293 array(
294 'name' => 'Featured',
295 'label' => 'featured',
296 'type' => 'image_featured',
297 'auto' => 1
298 ),
299 )
300 ),
301 'attachments' => array(
302 'title' => __("Attachments", "wp-all-export"),
303 'meta' => array(
304 array(
305 'name' => 'URL',
306 'label' => 'url',
307 'type' => 'attachment_url',
308 'auto' => 1
309 ),
310 array(
311 'name' => 'Filename',
312 'label' => 'filename',
313 'type' => 'attachment_filename'
314 ),
315 array(
316 'name' => 'Path',
317 'label' => 'path',
318 'type' => 'attachment_path'
319 ),
320 array(
321 'name' => 'ID',
322 'label' => 'attachment_id',
323 'type' => 'attachment_id'
324 ),
325 array(
326 'name' => 'Title',
327 'label' => 'title',
328 'type' => 'attachment_title'
329 ),
330 array(
331 'name' => 'Caption',
332 'label' => 'caption',
333 'type' => 'attachment_caption'
334 ),
335 array(
336 'name' => 'Description',
337 'label' => 'description',
338 'type' => 'attachment_description'
339 ),
340 array(
341 'name' => 'Alt Text',
342 'label' => 'alt',
343 'type' => 'attachment_alt'
344 ),
345 )
346 )
347 )
348 ),
349 'cats' => array(
350 'title' => __("Taxonomies", "wp-all-export"),
351 'content' => 'existing_taxonomies'
352 ),
353 'cf' => array(
354 'title' => __("Custom Fields", "wp-all-export"),
355 'content' => 'existing_meta_keys'
356 ),
357 'other' => array(
358 'title' => __("Other", "wp-all-export"),
359 'content' => 'other_fields'
360 )
361 );
362
363 $this->available_sections = apply_filters('pmxe_available_sections', $this->available_sections);
364
365 $this->filter_sections = array(
366 'author' => array(
367 'title' => __("Author", "wp-all-export"),
368 'fields' => array(
369 'user_ID' => 'User ID',
370 'user_login' => 'User Login',
371 'user_nicename' => 'Nicename',
372 'user_email' => 'Email',
373 'user_registered' => 'Date Registered (Y-m-d H:i:s)',
374 'display_name' => 'Display Name',
375 'cf_first_name' => 'First Name',
376 'cf_last_name' => 'Last Name',
377 'nickname' => 'Nickname',
378 'description' => 'User Description',
379 'wp_capabilities' => 'User Role'
380 )
381 )
382 );
383
384 if ( 'specific' == $this->post['export_type'] || 'wp_query' == $this->post['wp_query_selector']) {
385
386 $postTypes = [];
387 $exportqueryPostType = [];
388
389 if (!empty($this->post['cpt'])) {
390 $postTypes = is_array( $this->post['cpt'] )
391 ? $this->post['cpt']
392 : array( $this->post['cpt'] );
393 }
394
395 if (isset($this->post['exportquery']) && !empty($this->post['exportquery']->query['post_type'])) {
396 $exportqueryPostType = [$this->post['exportquery']->query['post_type']];
397 }
398
399 if (empty($postTypes)) {
400 $postTypes = $exportqueryPostType;
401 }
402
403 self::$post_types = $postTypes;
404
405 if( \class_exists('WooCommerce') && XmlExportEngine::get_addons_service()->isWooCommerceAddonActive()) {
406 if (in_array('product', self::$post_types) and !in_array('product_variation', self::$post_types)) self::$post_types[] = 'product_variation';
407 } else if(\class_exists('WooCommerce') && in_array('product', self::$post_types) && XmlExportEngine::get_addons_service()->isWooCommerceProductAddonActive()) {
408 self::$post_types = ['product'];
409 }
410
411 self::$is_user_export = ( in_array('users', self::$post_types) or in_array('shop_customer', self::$post_types) ) ? true : false;
412
413 self::$is_comment_export = ( in_array('comments', self::$post_types) ) ? true : false;
414
415 self::$is_taxonomy_export = ( in_array('taxonomies', self::$post_types) ) ? true : false;
416
417 if(count(self::$post_types) === 1) {
418 if(strpos(self::$post_types[0], 'custom_') === 0 ) {
419 self::$is_custom_addon_export = true;
420 }
421 }
422 }
423 else
424 {
425 self::$is_user_export = ( 'wp_user_query' == $this->post['wp_query_selector'] );
426 self::$is_comment_export = ( 'wp_comment_query' == $this->post['wp_query_selector'] );
427 }
428
429 if ( ! self::$is_user_export && ! self::$is_comment_export && ! self::$is_taxonomy_export)
430 {
431 add_filter("wp_all_export_filters", array( &$this, "filter_export_filters"), 10, 1);
432
433 // When WPML is active and at least one post in the export has a trid
434 if (class_exists('SitePress'))
435 {
436 self::$default_fields[] = array(
437 'label' => 'wpml_trid',
438 'name' => 'WPML Translation ID',
439 'type' => 'wpml_trid'
440 );
441
442 self::$default_fields[] = array(
443 'label' => 'wpml_lang',
444 'name' => 'WPML Language Code',
445 'type' => 'wpml_lang'
446 );
447 }
448 }
449
450 self::$exportOptions = $post;
451
452 if ( ! empty(PMXE_Plugin::$session) and PMXE_Plugin::$session->has_session() )
453 {
454 $filter_args = array(
455 'filter_rules_hierarhy' => $this->post['filter_rules_hierarhy'],
456 'product_matching_mode' => $this->post['product_matching_mode'],
457 'taxonomy_to_export' => empty($this->post['taxonomy_to_export']) ? '' : $this->post['taxonomy_to_export']
458 );
459
460 $this->filters = \Wpae\Pro\Filtering\FilteringFactory::getFilterEngine();
461 $this->filters->init($filter_args);
462
463 $this->init();
464 }
465
466 if (empty(self::$exportOptions['delimiter'])) self::$exportOptions['delimiter'] = ',';
467
468 self::$implode = (self::$exportOptions['delimiter'] == ',') ? '|' : ',';
469
470 self::$implode = apply_filters('wp_all_export_implode_delimiter', self::$implode, self::$exportID);
471
472 if ( !empty(self::$exportOptions['xml_template_type']) && in_array(self::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ) self::$implode = '#delimiter#';
473
474 self::$taxonomy_export = new XmlExportTaxonomy();
475 self::$custom_record_export = new XmlExportCustomRecord();
476 self::$is_woo_order_export = in_array('shop_order', self::$post_types);
477
478 do_action('pmxe_init_addons');
479 }
480
481 // [FILTERS]
482
483 /**
484 *
485 * Filter data for advanced filtering
486 *
487 */
488 public function filter_export_filters($filters){
489 return array_merge($filters, $this->filter_sections);
490 }
491
492 // [\FILTERS]
493
494 protected function init(){
495
496 PMXE_Plugin::$session->set('is_user_export', self::$is_user_export);
497 PMXE_Plugin::$session->set('is_comment_export', self::$is_comment_export);
498 PMXE_Plugin::$session->set('is_taxonomy_export', self::$is_taxonomy_export);
499 PMXE_Plugin::$session->save_data();
500
501 if ('advanced' == $this->post['export_type']) {
502
503 if( "" == $this->post['wp_query'] ){
504 $this->errors->add('form-validation', __('WP Query field is required', 'wp-all-export'));
505 }
506 else if(!XmlExportEngine::get_addons_service()->isWooCommerceAddonActive() && strpos($this->post['wp_query'], 'product') !== false && \class_exists('WooCommerce')) {
507 $this->errors->add('form-validation', __('The WooCommerce Export Add-On Pro is required to Export WooCommerce Products', 'wp-all-export'));
508 }
509 else if(!XmlExportEngine::get_addons_service()->isWooCommerceAddonActive() && !XmlExportEngine::get_addons_service()->isWooCommerceOrderAddonActive() && strpos($this->post['wp_query'], 'shop_order') !== false) {
510 $this->errors->add('form-validation', __('The WooCommerce Export Add-On Pro is required to Export WooCommerce Orders', 'wp-all-export'));
511 }
512 else if(!XmlExportEngine::get_addons_service()->isWooCommerceAddonActive() && strpos($this->post['wp_query'], 'shop_coupon') !== false) {
513 $this->errors->add('form-validation', __('The WooCommerce Export Add-On Pro is required to Export WooCommerce Coupons', 'wp-all-export'));
514 }
515 else
516 {
517 $this->filters->parse();
518
519 PMXE_Plugin::$session->set('whereclause', $this->filters->get('queryWhere'));
520 PMXE_Plugin::$session->set('joinclause', $this->filters->get('queryJoin'));
521 PMXE_Plugin::$session->set('wp_query', $this->post['wp_query']);
522 PMXE_Plugin::$session->save_data();
523 }
524 }
525 else
526 {
527 $this->filters->parse();
528
529 PMXE_Plugin::$session->set('cpt', self::$post_types);
530 PMXE_Plugin::$session->set('whereclause', $this->filters->get('queryWhere'));
531 PMXE_Plugin::$session->set('joinclause', $this->filters->get('queryJoin'));
532 PMXE_Plugin::$session->save_data();
533 }
534
535 PMXE_Plugin::$session->save_data();
536
537 }
538
539 public function init_additional_data(){
540
541 if(self::$woo_export) {
542 self::$woo_export->init_additional_data();
543 }
544
545 if(self::$woo_order_export) {
546 self::$woo_order_export->init_additional_data();
547 }
548 }
549
550 public function init_available_data(){
551
552 global $wpdb;
553 $table_prefix = $wpdb->prefix;
554
555 // Prepare existing taxonomies
556 if ( 'specific' == $this->post['export_type'] and ! self::$is_user_export and ! self::$is_comment_export and ! self::$is_taxonomy_export )
557 {
558 $this->_existing_taxonomies = wp_all_export_get_existing_taxonomies_by_cpt( self::$post_types[0] );
559
560 $this->_existing_meta_keys = wp_all_export_get_existing_meta_by_cpt( self::$post_types[0] );
561 }
562 if ( 'advanced' == $this->post['export_type'] and ! self::$is_user_export and ! self::$is_comment_export and ! self::$is_taxonomy_export )
563 {
564 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,PluginCheck.Security.DirectDB.UnescapedDBParameter -- $table_prefix from $wpdb->prefix; no user input; meta_key LIKE clauses are static
565 $meta_keys = $wpdb->get_results("SELECT DISTINCT meta_key FROM {$table_prefix}postmeta WHERE {$table_prefix}postmeta.meta_key NOT LIKE '_edit%' AND {$table_prefix}postmeta.meta_key NOT LIKE '_oembed_%' LIMIT 1000");
566 if ( ! empty($meta_keys)){
567 $exclude_keys = array('_first_variation_attributes', '_is_first_variation_created');
568 foreach ($meta_keys as $meta_key) {
569 if ( strpos($meta_key->meta_key, "_tmp") === false && strpos($meta_key->meta_key, "_v_") === false && ! in_array($meta_key->meta_key, $exclude_keys))
570 $this->_existing_meta_keys[] = $meta_key->meta_key;
571 }
572 }
573
574 global $wp_taxonomies;
575
576 foreach ($wp_taxonomies as $key => $obj) { if (in_array($obj->name, array('nav_menu'))) continue;
577
578 if (strpos($obj->name, "pa_") !== 0 and strlen($obj->name) > 3)
579 $this->_existing_taxonomies[] = array(
580 'name' => empty($obj->label) ? $obj->name : $obj->label,
581 'label' => $obj->name,
582 'type' => 'cats'
583 );
584 }
585 }
586
587 if(self::$acf_export) {
588 // Prepare existing ACF groups & fields
589 self::$acf_export->init($this->_existing_meta_keys);
590 }
591
592 if(XmlExportEngine::$woo_export) {
593 // Prepare existing WooCommerce data
594 self::$woo_export->init($this->_existing_meta_keys);
595
596 if(self::get_addons_service()->isWooCommerceAddonActive()) {
597 // Prepare existing WooCommerce Coupon data
598 self::$woo_coupon_export->init($this->_existing_meta_keys);
599 }
600 }
601 if(XmlExportEngine::$woo_order_export) {
602 // Prepare existing WooCommerce Order data
603 self::$woo_order_export->init($this->_existing_meta_keys);
604
605
606 }
607
608 foreach (self::get_addons() as $addon) {
609 $this->_existing_meta_keys = apply_filters("pmxe_get_{$addon}_addon_meta_keys", $this->_existing_meta_keys, 10, 1);
610 }
611
612 if(XmlExportEngine::$user_export) {
613 // Prepare existing Users data
614 self::$user_export->init($this->_existing_meta_keys);
615 }
616
617 // Prepare existing Taxonomy data
618 self::$taxonomy_export->init($this->_existing_meta_keys);
619
620 return $this->get_available_data();
621 }
622
623 public function get_available_data(){
624
625 if(self::$acf_export) {
626 $this->available_data['acf_groups'] = self::$acf_export->get('_acf_groups');
627 $this->available_data['existing_acf_meta_keys'] = self::$acf_export->get('_existing_acf_meta_keys');
628 }
629
630 foreach (self::get_addons() as $addon) {
631 $this->available_data = apply_filters("pmxe_get_{$addon}_addon_available_data", $this->available_data);
632 }
633
634 $this->available_data['existing_meta_keys'] = $this->_existing_meta_keys;
635 $this->available_data['existing_taxonomies'] = $this->_existing_taxonomies;
636
637 $this->available_data['init_fields'] = apply_filters('wp_all_export_init_fields', $this->init_fields);
638 $this->available_data['default_fields'] = apply_filters('wp_all_export_default_fields', self::$default_fields);
639 $this->available_data['other_fields'] = apply_filters('wp_all_export_other_fields', $this->other_fields);
640
641 $this->available_data = apply_filters("wp_all_export_available_data", $this->available_data);
642
643 return $this->available_data;
644
645 }
646
647 public function get_fields_options( $field_keys = array() ){
648
649 $fields = array(
650 'ids' => array(),
651 'cc_label' => array(),
652 'cc_php' => array(),
653 'cc_code' => array(),
654 'cc_sql' => array(),
655 'cc_options' => array(),
656 'cc_type' => array(),
657 'cc_value' => array(),
658 'cc_name' => array(),
659 'cc_settings' => array()
660 );
661
662 self::$woo_order_export->get_fields_options( $fields, $field_keys );
663
664 $available_sections = apply_filters("wp_all_export_available_sections", $this->available_sections);
665
666 foreach ($available_sections as $slug => $section)
667 {
668 if ( ! empty($this->available_data[$section['content']]) ):
669
670 foreach ($this->available_data[$section['content']] as $field)
671 {
672
673 $field_key = (is_array($field)) ? $field['name'] : $field;
674
675 if ( ! in_array($field_key, $field_keys) ) continue;
676
677 $fields['ids'][] = 1;
678 $fields['cc_label'][] = (is_array($field)) ? $field['label'] : $field;
679 $fields['cc_php'][] = '';
680 $fields['cc_code'][] = '';
681 $fields['cc_sql'][] = '';
682 $fields['cc_options'][] = '';
683 $fields['cc_type'][] = (is_array($field)) ? $field['type'] : $slug;
684 $fields['cc_value'][] = (is_array($field)) ? $field['label'] : $field;
685 $fields['cc_name'][] = $field_key;
686 $fields['cc_settings'][] = '';
687 }
688 endif;
689
690 if ( ! empty($section['additional']) )
691 {
692 foreach ($section['additional'] as $sub_slug => $sub_section)
693 {
694
695 foreach ($sub_section['meta'] as $field) {
696 $key_to_check = (is_array($field)) ? $field['name'] : $field;
697
698 if ( in_array($sub_slug, array('images', 'attachments')) ){
699 $key_to_check = preg_replace("%s$%","",ucfirst($sub_slug)) . ' ' . $key_to_check;
700 }
701
702 if ( ! in_array($key_to_check, $field_keys) ) continue;
703
704 $field_options = ( in_array($sub_slug, array('images', 'attachments')) ) ? esc_attr('{"is_export_featured":true,"is_export_attached":true,"image_separator":"|"}') : '0';
705
706 $fields['ids'][] = 1;
707 $fields['cc_label'][] = (is_array($field)) ? $field['label'] : $field;
708 $fields['cc_php'][] = '';
709 $fields['cc_code'][] = '';
710 $fields['cc_sql'][] = '';
711 $fields['cc_options'][] = $field_options;
712 $fields['cc_type'][] = (is_array($field)) ? $field['type'] : $sub_slug;
713 $fields['cc_value'][] = (is_array($field)) ? $field['label'] : $field;
714 $fields['cc_name'][] = $key_to_check;
715 $fields['cc_settings'][] = '';
716 }
717 }
718 }
719 }
720
721 if ( ! self::$is_comment_export )
722 {
723 if(self::$acf_export) {
724 self::$acf_export->get_fields_options( $fields, $field_keys );
725 }
726 }
727
728 $sort_fields = array();
729 foreach ($field_keys as $i => $field_key){
730 foreach ($fields['cc_name'] as $j => $cc_name){
731 if (!empty($cc_name) && $cc_name == $field_key){
732 $sort_fields['ids'][] = 1;
733 $sort_fields['cc_label'][] = $fields['cc_label'][$j];
734 $sort_fields['cc_php'][] = $fields['cc_php'][$j];
735 $sort_fields['cc_code'][] = $fields['cc_code'][$j];
736 $sort_fields['cc_sql'][] = $fields['cc_sql'][$j];
737 $sort_fields['cc_options'][] = $fields['cc_options'][$j];
738 $sort_fields['cc_type'][] = $fields['cc_type'][$j];
739 $sort_fields['cc_value'][] = $fields['cc_value'][$j];
740 $sort_fields['cc_name'][] = $fields['cc_name'][$j];
741 $sort_fields['cc_settings'][] = $fields['cc_settings'][$j];
742 break;
743 }
744 }
745 }
746
747 return $sort_fields;
748
749 }
750
751 public function render(){
752
753 $i = 0;
754
755 ob_start();
756
757 $available_sections = apply_filters("wp_all_export_available_sections", $this->available_sections);
758 self::$globalAvailableSections = $available_sections;
759
760 $reordered_sections = array();
761 foreach ($available_sections as $key => $value) {
762 if ($key === "cf") {
763 $reordered_sections["addons"] = true;
764 }
765 $reordered_sections[$key] = $value;
766 }
767
768 if(self::$woo_order_export) {
769 // Render Available WooCommerce Orders Data
770 self::$woo_order_export->render($i);
771 }
772
773 foreach ($reordered_sections as $slug => $section)
774 {
775 if ($slug === 'addons') {
776 foreach (self::get_addons() as $addon) {
777 do_action("pmxe_render_{$addon}_addon", $i);
778 }
779 continue;
780 }
781
782 if ( ! empty($this->available_data[$section['content']]) or ! empty($section['additional']) ):
783 ?>
784 <p class="wpae-available-fields-group"><?php echo esc_html($section['title']); ?><span class="wpae-expander">+</span></p>
785 <div class="wpae-custom-field">
786 <?php
787 if($slug == 'cf' && XmlExportEngine::$is_user_export) {
788 ?>
789 <div class="wpallexport-free-edition-notice">
790 <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=5839967&discount=welcome-upgrade-99&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-user-meta">Upgrade to the Pro edition of WP All Export to Export User Meta</a>
791 </div>
792 <?php
793 }
794 ?>
795 <?php
796 if($slug == 'other' && XmlExportEngine::$is_user_export) {
797 ?>
798 <div class="wpallexport-free-edition-notice">
799 <a class="upgrade_link" target="_blank" href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=5839967&discount=welcome-upgrade-99&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-advanced-user-data">Upgrade to the Pro edition of WP All Export to Export Advanced Fields</a>
800 </div>
801 <?php
802 }
803 $elementClass = "";
804 if(($slug == 'cf' || $slug == 'other') && XmlExportEngine::$is_user_export){
805 $elementClass = 'wpallexport_disabled';
806 }
807 ?>
808 <ul>
809 <?php if ( ! empty($this->available_data[$section['content']]) ): ?>
810 <li class="<?php echo esc_attr($elementClass); ?>">
811 <div class="default_column" rel="">
812 <label class="wpallexport-element-label"><?php echo esc_html__("All", "wp-all-export") . ' ' . esc_html($section['title']); ?></label>
813 <input type="hidden" name="rules[]" value="<?php echo esc_attr("pmxe_" . $slug); ?>"/>
814 </div>
815 </li>
816 <?php
817 foreach ($this->available_data[$section['content']] as $field)
818 {
819 $field_type = is_array($field) ? $field['type'] : $slug;
820 $field_name = is_array($field) ? $field['name'] : $field;
821
822 if ( $field_type == 'cf' && $field_name == '_thumbnail_id' ) continue;
823
824 $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')) || !\class_exists('WooCommerce'))));
825
826 ?>
827 <li class="pmxe_<?php echo esc_attr($slug); ?> <?php if ( $is_auto_field ) echo 'wp_all_export_auto_generate';?> <?php echo esc_attr($elementClass);?>">
828 <div class="custom_column" rel="<?php echo esc_attr($i + 1);?>">
829 <label class="wpallexport-xml-element"><?php echo esc_html(is_array($field) ? $field['name'] : $field); ?></label>
830 <input type="hidden" name="ids[]" value="1"/>
831 <input type="hidden" name="cc_label[]" value="<?php echo esc_attr(is_array($field) ? $field['label'] : $field); ?>"/>
832 <input type="hidden" name="cc_php[]" value="0"/>
833 <input type="hidden" name="cc_code[]" value=""/>
834 <input type="hidden" name="cc_sql[]" value="0"/>
835 <input type="hidden" name="cc_options[]" value="0"/>
836 <input type="hidden" name="cc_type[]" value="<?php echo esc_attr(is_array($field) ? $field['type'] : $slug); ?>"/>
837 <input type="hidden" name="cc_value[]" value="<?php echo esc_attr(is_array($field) ? $field['label'] : $field); ?>"/>
838 <input type="hidden" name="cc_name[]" value="<?php echo esc_attr(is_array($field) ? $field['name'] : $field); ?>"/>
839 <input type="hidden" name="cc_settings[]" value="0"/>
840 </div>
841 </li>
842 <?php
843 $i++;
844 }
845 endif;
846
847 if ( ! empty($section['additional']) )
848 {
849 foreach ($section['additional'] as $sub_slug => $sub_section)
850 {
851
852 ?>
853 <li class="available_sub_section">
854 <p class="wpae-available-fields-group"><?php echo esc_html($sub_section['title']); ?><span
855 class="wpae-expander">+</span></p>
856 <div class="wpae-custom-field">
857 <?php
858 $show_additional_subsection = apply_filters("wp_all_export_show_additional_subsection", true, $sub_slug, $sub_section);
859 do_action("wp_all_export_before_available_subsection", $sub_slug, $sub_section);
860
861
862 if($show_additional_subsection) { ?>
863
864 <ul>
865 <li>
866 <div class="default_column" rel="">
867 <label class="wpallexport-element-label"><?php echo esc_html__("All", "wp-all-export") . ' ' . esc_html($sub_section['title']); ?></label>
868 <input type="hidden" name="rules[]"
869 value="<?php echo esc_attr("pmxe_" . $slug . "_" . $sub_slug); ?>"/>
870 </div>
871 </li>
872 <?php
873 foreach ($sub_section['meta'] as $field) {
874 $is_auto_field = empty($field['auto']) ? false : true;
875 $field_options = (in_array($sub_slug, array('images', 'attachments'))) ? esc_attr('{"is_export_featured":true,"is_export_attached":true,"image_separator":"|"}') : '0';
876 ?>
877 <li class="<?php echo esc_attr("pmxe_" . $slug . "_" . $sub_slug); ?> <?php if ($is_auto_field) echo 'wp_all_export_auto_generate'; ?>">
878 <div class="custom_column" rel="<?php echo esc_attr($i + 1); ?>">
879 <label class="wpallexport-xml-element"><?php echo (is_array($field)) ? esc_html(XmlExportEngine::sanitizeFieldName($field['name'])) : esc_html($field); ?></label>
880 <input type="hidden" name="ids[]" value="1"/>
881 <input type="hidden" name="cc_label[]"
882 value="<?php echo (is_array($field)) ? esc_attr($field['label']) : esc_attr($field); ?>"/>
883 <input type="hidden" name="cc_php[]" value="0"/>
884 <input type="hidden" name="cc_code[]" value="0"/>
885 <input type="hidden" name="cc_sql[]" value="0"/>
886 <input type="hidden" name="cc_options[]"
887 value="<?php echo esc_attr($field_options); ?>"/>
888 <input type="hidden" name="cc_type[]"
889 value="<?php echo (is_array($field)) ? esc_attr($field['type']) : esc_attr($sub_slug); ?>"/>
890 <input type="hidden" name="cc_value[]"
891 value="<?php echo (is_array($field)) ? esc_attr($field['label']) : esc_attr($field); ?>"/>
892 <input type="hidden" name="cc_name[]"
893 value="<?php echo (is_array($field)) ? esc_attr(XmlExportEngine::sanitizeFieldName($field['name'])) : esc_attr($field); ?>"/>
894 <input type="hidden" name="cc_settings[]" value=""/>
895 </div>
896 </li>
897 <?php
898 $i++;
899
900 }
901 ?>
902 </ul>
903 <?php
904 }
905 ?>
906 </div>
907 </li>
908 <?php
909
910 }
911 }
912 ?>
913 </ul>
914 </div>
915 <?php
916 endif;
917 }
918
919 if ( ! self::$is_comment_export )
920 {
921 if(self::$acf_export) {
922 // Render Available ACF
923 self::$acf_export->render($i);
924 } else {
925 if(!self::get_addons_service()->isAcfAddonActive()) {
926 ?>
927 <p class="wpae-available-fields-group">ACF<span class="wpae-expander">+</span></p>
928 <div class="wpae-custom-field">
929
930 <div class="wpallexport-free-edition-notice">
931 <a class="upgrade_link" target="_blank"
932 href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=5839953&discount=welcome-upgrade-169&edd_options%5Bprice_id%5D=1&utm_source=export-plugin-free&utm_medium=upgrade-notice&utm_campaign=export-advanced-custom-fields">Upgrade to the ACF Export Package to Export Advanced Custom Fields</a>
933 </div>
934 </div>
935 <?php
936 }
937
938 }
939 }
940
941 return ob_get_clean();
942
943 }
944
945 public function render_filters(){
946
947 $available_sections = apply_filters("wp_all_export_available_sections", apply_filters('wp_all_export_filters', $this->available_sections) );
948
949 if(self::$woo_order_export) {
950 // Render Filters for WooCommerce Orders
951 self::$woo_order_export->render_filters();
952 }
953
954 if(self::$is_custom_addon_export) {
955 if(class_exists('GF_Export_Add_On')) {
956 $addon = GF_Export_Add_On::get_instance();
957 $addon->render_filters();
958 unset($available_sections);
959 }
960
961 }
962
963 if ( ! empty($available_sections) )
964 {
965 $exclude = array('wpml_lang', 'wpml_trid');
966
967 foreach ($available_sections as $slug => $section)
968 {
969 if ( ! empty($section['content']) and ! empty($this->available_data[$section['content']]) or ! empty($section['fields'])):
970 ?>
971
972 <optgroup label="<?php echo esc_attr($section['title']); ?>">
973
974 <?php if ( ! empty($section['content']) && ! empty($this->available_data[$section['content']]) ): ?>
975
976 <?php foreach ($this->available_data[$section['content']] as $field) : ?>
977
978 <?php
979
980 $field_label = is_array($field) ? $field['label'] : $field;
981 $field_type = is_array($field) ? $field['type'] : $slug;
982 $field_name = is_array($field) ? $field['name'] : $field;
983
984 if ( in_array($field_label, $exclude) ) continue;
985
986 switch ($field_type)
987 {
988 case 'woo':
989 $exclude_fields = array('attributes');
990 if ( ! in_array($field_label, $exclude_fields)):
991 ?>
992 <option value="<?php echo esc_attr('cf_' . $field_label); ?>"><?php echo esc_html($field_name); ?></option>
993 <?php
994 endif;
995 break;
996 case 'cf':
997 ?>
998 <option value="<?php echo esc_attr('cf_' . $field_label); ?>"><?php echo esc_html($field_name); ?></option>
999 <?php
1000 break;
1001 case 'cats':
1002 case 'attr':
1003 ?>
1004 <option value="<?php echo esc_attr('tx_' . $field_label); ?>"><?php echo esc_html($field_name); ?></option>
1005 <?php
1006 break;
1007 default:
1008
1009 if (self::$is_user_export)
1010 {
1011 switch ($field_label)
1012 {
1013 case 'id':
1014 $field_label = strtoupper($field_label);
1015 break;
1016 case 'user_nicename':
1017 ?>
1018 <option value="user_role"><?php esc_html_e('User Role', 'wp-all-export'); ?></option>
1019 <?php
1020 break;
1021 }
1022 }
1023 else
1024 {
1025 switch ($field_label) {
1026 case 'id':
1027 $field_label = strtoupper($field_label);
1028 break;
1029 case 'parent':
1030 case 'author':
1031 case 'author_username':
1032 case 'author_email':
1033 case 'author_first_name':
1034 case 'author_last_name':
1035 case 'status':
1036 case 'title':
1037 case 'content':
1038 case 'date':
1039 case 'excerpt':
1040 $field_label = 'post_' . $field_label;
1041 break;
1042 case 'permalink':
1043 $field_label = 'guid';
1044 break;
1045 case 'slug':
1046 $field_label = 'post_name';
1047 break;
1048 case 'order':
1049 $field_label = 'menu_order';
1050 break;
1051 case 'template':
1052 $field_label = 'cf__wp_page_template';
1053 break;
1054 case 'format':
1055 $field_label = 'tx_post_format';
1056 break;
1057 default:
1058 # code...
1059 break;
1060 }
1061 }
1062 ?>
1063 <option value="<?php echo esc_attr($field_label); ?>"><?php echo esc_html($field_name); ?></option>
1064 <?php
1065 break;
1066 }
1067 ?>
1068
1069 <?php endforeach; ?>
1070
1071 <?php endif; ?>
1072
1073 <?php if ( ! empty($section['fields'])): ?>
1074
1075 <?php foreach ($section['fields'] as $key => $title) : ?>
1076
1077 <option value="<?php echo esc_attr($key); ?>"><?php echo esc_html($title); ?></option>
1078
1079 <?php endforeach; ?>
1080
1081 <?php endif; ?>
1082
1083 </optgroup>
1084
1085 <?php
1086
1087 endif;
1088
1089 if ( ! empty($section['additional']) )
1090 {
1091 foreach ($section['additional'] as $sub_slug => $sub_section)
1092 {
1093 if ( $sub_slug == 'attributes' ) {
1094 ?>
1095 <optgroup label="<?php echo esc_attr($sub_section['title']); ?>">
1096 <?php
1097 foreach ($sub_section['meta'] as $field) :
1098 if ( isset( $field['type'] ) ) {
1099 switch ( $field['type'] ) {
1100 case 'attr':
1101 ?>
1102 <option value="<?php echo esc_attr('tx_' . $field['label']); ?>"><?php echo esc_html($field['name']); ?></option>
1103 <?php
1104 break;
1105 case 'cf':
1106 ?>
1107 <option value="<?php echo esc_attr('cf_' . $field['label']); ?>"><?php echo esc_html($field['name']); ?></option>
1108 <?php
1109 break;
1110 default:
1111 # code...
1112 break;
1113 }
1114 }
1115
1116 endforeach;
1117 ?>
1118 </optgroup>
1119 <?php
1120 }
1121 }
1122 }
1123 }
1124 }
1125
1126 if ( ! self::$is_comment_export )
1127 {
1128 if(self::$acf_export) {
1129 // Render Available ACF
1130 self::$acf_export->render_filters();
1131 }
1132 }
1133
1134 }
1135
1136 public function render_new_field(){
1137
1138 ob_start();
1139
1140 $available_sections = apply_filters("wp_all_export_available_sections", $this->available_sections);
1141
1142 if(self::$woo_order_export) {
1143 // Render Available WooCommerce Orders Data
1144 self::$woo_order_export->render_new_field();
1145 }
1146
1147 if ( ! empty($available_sections) ):?>
1148
1149 <select class="wp-all-export-chosen-select" name="column_value_type" style="width:350px;">
1150
1151 <?php
1152 foreach ($available_sections as $slug => $section)
1153 {
1154 if($slug === 'product_data' && !self::get_addons_service()->isWooCommerceAddonActive()) {
1155 unset($section['additional']);
1156 }
1157
1158 if ( ! empty($this->available_data[$section['content']]) or ! empty($section['additional']) ):
1159 ?>
1160 <optgroup label="<?php echo esc_attr($section['title']); ?>">
1161
1162 <?php
1163 if ( ! empty($this->available_data[$section['content']]) )
1164 {
1165 foreach ($this->available_data[$section['content']] as $field)
1166 {
1167 $field_label = is_array($field) ? $field['label'] : $field;
1168 $field_type = is_array($field) ? $field['type'] : $slug;
1169 $field_name = is_array($field) ? $field['name'] : $field;
1170 $field_options = empty ($field['options']) ? '' : $field['options'];
1171
1172 if ( $field_type == 'cf' && $field_name == '_thumbnail_id' || ($field_type=='other')) continue;
1173 $elementDisabled = ( ( $section['title'] == 'Custom Fields' || $section['title'] == 'Other' ) && XmlExportEngine::$is_user_export );
1174 ?>
1175 <option
1176 value="<?php echo esc_attr($field_type);?>"
1177 label="<?php echo esc_attr($field_label);?>"
1178 <?php if ( $elementDisabled ) echo 'disabled'; ?>
1179 options="<?php echo esc_attr($field_options); ?>"><?php echo esc_html($field_name);?></option>
1180 <?php
1181 }
1182 }
1183 ?>
1184
1185 </optgroup>
1186
1187 <?php
1188
1189 if ( ! empty($section['additional']) )
1190 {
1191 foreach ($section['additional'] as $sub_slug => $sub_section)
1192 {
1193 ?>
1194 <optgroup label="<?php echo esc_attr($sub_section['title']); ?>">
1195
1196 <?php
1197 foreach ($sub_section['meta'] as $field)
1198 {
1199 $field_label = is_array($field) ? $field['label'] : $field;
1200 $field_type = is_array($field) ? $field['type'] : $slug;
1201 $field_name = is_array($field) ? $field['name'] : $field;
1202 $field_options = empty($field['options']) ? '{"is_export_featured":true,"is_export_attached":true,"image_separator":"|"}' : $field['options'];
1203 ?>
1204 <option
1205 value="<?php echo esc_attr($field_type);?>"
1206 label="<?php echo esc_attr($field_label);?>"
1207 options="<?php echo esc_attr($field_options); ?>"><?php echo esc_html($field_name);?></option>
1208 <?php
1209 }
1210 ?>
1211 </optgroup>
1212 <?php
1213 }
1214 }
1215 endif;
1216 }
1217
1218 if ( ! self::$is_comment_export )
1219 {
1220 if(self::$acf_export) {
1221 // Render Available ACF
1222 self::$acf_export->render_new_field();
1223 }
1224 }
1225
1226 ?>
1227 <optgroup label="Advanced">
1228 <option value="sql" label="sql"><?php esc_html_e("SQL Query", "wp-all-export"); ?></option>
1229 </optgroup>
1230 </select>
1231 <?php
1232 endif;
1233
1234 return ob_get_clean();
1235
1236 }
1237
1238 public function parse_custom_xml_template(){
1239
1240 preg_match("%". self::XML_LOOP_START ."(.*)". self::XML_LOOP_END ."%", $this->post['custom_xml_template'], $matches);
1241 $parts = explode(self::XML_LOOP_START, $this->post['custom_xml_template']);
1242 $loopContent = $parts[1];
1243 $parts = explode(self::XML_LOOP_END, $loopContent);
1244 $loopContent = $parts[0];
1245 $line_numbers = substr_count($loopContent, "\n") +1;
1246
1247 $result['original_post_loop'] = $loopContent;
1248 $result['line_numbers'] = $line_numbers;
1249
1250 $custom_xml_template = str_replace("\n", "", $this->post['custom_xml_template']);
1251 // retrieve XML header
1252 preg_match("%(.*)". self::XML_LOOP_START ."%", $custom_xml_template, $matches);
1253 $result['custom_xml_template_header'] = empty($matches[1]) ? '' : rtrim($matches[1]);
1254 // retrieve XML POST LOOP
1255 preg_match("%". self::XML_LOOP_START ."(.*)". self::XML_LOOP_END ."%", $custom_xml_template, $matches);
1256 $result['custom_xml_template_loop'] = empty($matches[1]) ? '' : rtrim($matches[1]);
1257 // retrieve XML footer
1258 preg_match("%". self::XML_LOOP_END ."(.*)%", $custom_xml_template, $matches);
1259 $result['custom_xml_template_footer'] = empty($matches[1]) ? '' : $matches[1];
1260
1261 // Validate Custom XML Template header
1262 if ( empty($result['custom_xml_template_header']) )
1263 {
1264 $this->errors->add('form-validation', __('Missing custom XML template header.', 'wp-all-export'));
1265 }
1266 // Validate Custom XML Template post LOOP
1267 if ( empty($result['custom_xml_template_loop']) )
1268 {
1269 $this->errors->add('form-validation', __('Missing custom XML template post loop.', 'wp-all-export'));
1270 }
1271 // Validate Custom XML Template footer
1272 if ( empty($result['custom_xml_template_footer']) )
1273 {
1274 $this->errors->add('form-validation', __('Missing custom XML template footer.', 'wp-all-export'));
1275 }
1276
1277 if ( ! $this->errors->get_error_codes()) {
1278
1279 // retrieve all placeholders in the XML loop
1280 preg_match_all("%(\[[^\]\[]*\])%", $result['custom_xml_template_loop'], $matches);
1281 $loop_placeholders = empty($matches) ? array() : $matches[0];
1282
1283 $field_keys = array();
1284 // looking for placeholders e.q. {Post Type}, {Title}
1285 if ( ! empty($loop_placeholders) ){
1286
1287 foreach ($loop_placeholders as $snippet) {
1288 preg_match("%\{(.*)\}%", $snippet, $matches);
1289 if ( ! empty($matches[1]) ) $field_keys[] = $matches[1];
1290 }
1291 }
1292
1293 preg_match_all("%(\{[^\}\{]*\})%", $result['custom_xml_template_loop'], $matches);
1294 $loop_placeholders = empty($matches) ? array() : $matches[0];
1295
1296 $field_keys = array();
1297 // looking for placeholders e.q. {Post Type}, {Title}
1298 if ( ! empty($loop_placeholders) ){
1299
1300 foreach ($loop_placeholders as $snippet) {
1301 preg_match("%\{(.*)\}%", $snippet, $matches);
1302 if ( ! empty($matches[1]) and ! in_array($matches[1], $field_keys)) $field_keys[] = $matches[1];
1303 }
1304 }
1305
1306 if (!empty($field_keys)){
1307 $result['custom_xml_template_options'] = $this->get_fields_options( $field_keys );
1308 }
1309 }
1310 return $result;
1311 }
1312
1313 /**
1314 * __get function.
1315 *
1316 * @access public
1317 * @param mixed $key
1318 * @return mixed
1319 */
1320 public function __get( $key ) {
1321 return $this->get( $key );
1322 }
1323
1324 /**
1325 * Get a session variable
1326 *
1327 * @param string $key
1328 * @param mixed $default used if the session variable isn't set
1329 * @return mixed value of session variable
1330 */
1331 public function get( $key, $default = null ) {
1332 return isset( $this->{$key} ) ? $this->{$key} : $default;
1333 }
1334
1335 public static function getProductVariationMode()
1336 {
1337 if(!isset(self::$exportOptions['export_variations'])) {
1338 self::$exportOptions['export_variations'] = self::VARIABLE_PRODUCTS_EXPORT_PARENT_AND_VARIATION;
1339 }
1340
1341 return apply_filters('wp_all_export_product_variation_mode', self::$exportOptions['export_variations'], self::$exportID);
1342 }
1343
1344 public static function getProductVariationTitleMode()
1345 {
1346 if(!isset(self::$exportOptions['export_variations_title'])) {
1347 self::$exportOptions['export_variations_title'] = self::VARIATION_USE_PARENT_TITLE;
1348 }
1349
1350 return self::$exportOptions['export_variations_title'];
1351 }
1352
1353 public static function sanitizeFieldName($fieldName)
1354 {
1355 if (class_exists('XmlExportWooCommerce') && XmlExportWooCommerce::$is_active) {
1356 return urldecode($fieldName);
1357 }
1358
1359 return $fieldName;
1360 }
1361
1362 public static function get_addons() {
1363 return apply_filters('pmxe_addons', []);
1364 }
1365
1366 public static function get_addons_service()
1367 {
1368 if(!self::$addons_service) {
1369 self::$addons_service = new Wpae\App\Service\Addons\AddonService();
1370 }
1371
1372 return self::$addons_service;
1373 }
1374 }
1375
1376 }
1377