Ejemplo n.º 1
0
 public function __construct()
 {
     if (XmlExportEngine::$exportOptions['export_type'] == 'specific' and !in_array('comments', XmlExportEngine::$post_types) or XmlExportEngine::$exportOptions['export_type'] == 'advanced' and XmlExportEngine::$exportOptions['wp_query_selector'] != 'wp_comment_query') {
         self::$is_active = false;
         return;
     }
     add_filter("wp_all_export_available_sections", array(&$this, "filter_available_sections"), 10, 1);
     add_filter("wp_all_export_init_fields", array(&$this, "filter_init_fields"), 10, 1);
     add_filter("wp_all_export_default_fields", array(&$this, "filter_default_fields"), 10, 1);
     add_filter("wp_all_export_other_fields", array(&$this, "filter_other_fields"), 10, 1);
 }
Ejemplo n.º 2
0
 public static function export_xml($preview = false, $is_cron = false, $file_path = false, $exported_by_cron = 0)
 {
     $is_custom_xml = !empty(XmlExportEngine::$exportOptions['xml_template_type']) && in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ? true : false;
     if (!empty(XmlExportEngine::$exportOptions['xml_template_type'])) {
         switch (XmlExportEngine::$exportOptions['xml_template_type']) {
             case 'custom':
             case 'XmlGoogleMerchants':
                 XmlExportEngine::$exportOptions['ids'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['ids'];
                 XmlExportEngine::$exportOptions['cc_label'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_label'];
                 XmlExportEngine::$exportOptions['cc_type'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_type'];
                 XmlExportEngine::$exportOptions['cc_value'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_value'];
                 XmlExportEngine::$exportOptions['cc_name'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_name'];
                 XmlExportEngine::$exportOptions['cc_php'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_php'];
                 XmlExportEngine::$exportOptions['cc_code'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_code'];
                 XmlExportEngine::$exportOptions['cc_sql'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_sql'];
                 XmlExportEngine::$exportOptions['cc_options'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_options'];
                 XmlExportEngine::$exportOptions['cc_settings'] = XmlExportEngine::$exportOptions['custom_xml_template_options']['cc_settings'];
                 break;
             default:
                 # code...
                 break;
         }
     }
     if (XmlExportEngine::$exportOptions['delimiter'] == '\\t') {
         XmlExportEngine::$exportOptions['delimiter'] = "\t";
     }
     require_once PMXE_ROOT_DIR . '/classes/XMLWriter.php';
     $woo = array();
     $woo_order = array();
     $acfs = array();
     self::$main_xml_tag = apply_filters('wp_all_export_main_xml_tag', XmlExportEngine::$exportOptions['main_xml_tag'], XmlExportEngine::$exportID);
     self::$node_xml_tag = apply_filters('wp_all_export_record_xml_tag', XmlExportEngine::$exportOptions['record_xml_tag'], XmlExportEngine::$exportID);
     //        self::$implode = (XmlExportEngine::$exportOptions['delimiter'] == ',') ? '|' : ',';
     //
     //        if ( $is_custom_xml ) self::$implode = '#delimiter#';
     $xmlWriter = new PMXE_XMLWriter();
     if (!$is_custom_xml) {
         $xmlWriter->openMemory();
         $xmlWriter->setIndent(true);
         $xmlWriter->setIndentString("\t");
         $xmlWriter->startDocument('1.0', XmlExportEngine::$exportOptions['encoding']);
         $xmlWriter->startElement(self::$main_xml_tag);
         // add additional data after XML root element
         self::xml_header($xmlWriter, $is_cron, $exported_by_cron);
     }
     // [ Exporting requested data ]
     if (XmlExportEngine::$is_user_export) {
         foreach (XmlExportEngine::$exportQuery->results as $user) {
             $is_export_record = apply_filters('wp_all_export_xml_rows', true, $user, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
             if (!$is_export_record) {
                 continue;
             }
             if (!$is_custom_xml) {
                 // add additional information before each node
                 self::before_xml_node($xmlWriter, $user->ID);
                 $xmlWriter->startElement(self::$node_xml_tag);
                 XmlExportUser::prepare_data($user, $xmlWriter, $acfs, XmlExportEngine::$implode, $preview);
                 $xmlWriter->closeElement();
                 // end post
                 // add additional information after each node
                 self::after_xml_node($xmlWriter, $user->ID);
             } else {
                 $articles = array();
                 $articles[] = XmlExportUser::prepare_data($user, $xmlWriter, $acfs, XmlExportEngine::$implode, $preview);
                 $articles = apply_filters('wp_all_export_csv_rows', $articles, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
                 $xmlWriter->writeArticle($articles);
             }
             if (!$preview) {
                 do_action('pmxe_exported_post', $user->ID, XmlExportEngine::$exportRecord);
             }
         }
     } elseif (XmlExportEngine::$is_comment_export) {
         global $wp_version;
         if (version_compare($wp_version, '4.2.0', '>=')) {
             $comments = XmlExportEngine::$exportQuery->get_comments();
         } else {
             $comments = XmlExportEngine::$exportQuery;
         }
         foreach ($comments as $comment) {
             $is_export_record = apply_filters('wp_all_export_xml_rows', true, $comment, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
             if (!$is_export_record) {
                 continue;
             }
             if (!$is_custom_xml) {
                 // add additional information before each node
                 self::before_xml_node($xmlWriter, $comment->comment_ID);
                 $xmlWriter->startElement(self::$node_xml_tag);
                 XmlExportComment::prepare_data($comment, $xmlWriter, XmlExportEngine::$implode, $preview);
                 $xmlWriter->closeElement();
                 // end post
                 // add additional information after each node
                 self::after_xml_node($xmlWriter, $comment->comment_ID);
             } else {
                 $articles = array();
                 $articles[] = XmlExportComment::prepare_data($comment, $xmlWriter, XmlExportEngine::$implode, $preview);
                 $articles = apply_filters('wp_all_export_csv_rows', $articles, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
                 $xmlWriter->writeArticle($articles);
             }
             if (!$preview) {
                 do_action('pmxe_exported_post', $comment->comment_ID, XmlExportEngine::$exportRecord);
             }
         }
     } else {
         // exporting custom post types
         while (XmlExportEngine::$exportQuery->have_posts()) {
             XmlExportEngine::$exportQuery->the_post();
             $record = get_post(get_the_ID());
             $is_export_record = apply_filters('wp_all_export_xml_rows', true, $record, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
             if (!$is_export_record) {
                 continue;
             }
             if (!$is_custom_xml) {
                 // add additional information before each node
                 self::before_xml_node($xmlWriter, $record->ID);
                 $xmlWriter->startElement(self::$node_xml_tag);
                 XmlExportCpt::prepare_data($record, $xmlWriter, $acfs, $woo, $woo_order, XmlExportEngine::$implode, $preview);
                 $xmlWriter->closeElement();
                 // end post
                 // add additional information after each node
                 self::after_xml_node($xmlWriter, $record->ID);
             } else {
                 $articles = array();
                 $articles[] = XmlExportCpt::prepare_data($record, $xmlWriter, $acfs, $woo, $woo_order, XmlExportEngine::$implode, $preview);
                 $articles = apply_filters('wp_all_export_csv_rows', $articles, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
                 $xmlWriter->writeArticle($articles);
             }
             if (!$preview) {
                 do_action('pmxe_exported_post', $record->ID, XmlExportEngine::$exportRecord);
             }
         }
         wp_reset_postdata();
     }
     // [ \Exporting requested data ]
     if (!$is_custom_xml) {
         $xmlWriter->closeElement();
     }
     // close root XML element
     if ($preview) {
         return $xmlWriter->wpae_flush();
     }
     return self::save_xml_to_file($xmlWriter, $file_path, $is_cron, $exported_by_cron);
 }
Ejemplo n.º 3
0
 public static function export_xml($preview = false, $is_cron = false, $file_path = false, $exported_by_cron = 0)
 {
     require_once PMXE_ROOT_DIR . '/classes/XMLWriter.php';
     $woo = array();
     $woo_order = array();
     $acfs = array();
     $taxes = array();
     $attributes = array();
     self::$main_xml_tag = apply_filters('wp_all_export_main_xml_tag', XmlExportEngine::$exportOptions['main_xml_tag'], XmlExportEngine::$exportID);
     self::$node_xml_tag = apply_filters('wp_all_export_record_xml_tag', XmlExportEngine::$exportOptions['record_xml_tag'], XmlExportEngine::$exportID);
     $implode_delimiter = XmlExportEngine::$exportOptions['delimiter'] == ',' ? '|' : ',';
     $xmlWriter = new PMXE_XMLWriter();
     $xmlWriter->openMemory();
     $xmlWriter->setIndent(true);
     $xmlWriter->setIndentString("\t");
     $xmlWriter->startDocument('1.0', XmlExportEngine::$exportOptions['encoding']);
     $xmlWriter->startElement(self::$main_xml_tag);
     // add additional data after XML root element
     self::xml_header($xmlWriter, $is_cron, $exported_by_cron);
     // [ Exporting requested data ]
     if (XmlExportEngine::$is_user_export) {
         foreach (XmlExportEngine::$exportQuery->results as $user) {
             $is_export_record = apply_filters('wp_all_export_xml_rows', true, $user, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
             if (!$is_export_record) {
                 continue;
             }
             // add additional information before each node
             self::before_xml_node($xmlWriter, $user->ID);
             $xmlWriter->startElement(self::$node_xml_tag);
             XmlExportUser::prepare_data($user, $xmlWriter, $acfs, $implode_delimiter, $preview);
             $xmlWriter->endElement();
             // end post
             // add additional information after each node
             self::after_xml_node($xmlWriter, $user->ID);
             if ($preview) {
                 break;
             }
             do_action('pmxe_exported_post', $user->ID, XmlExportEngine::$exportRecord);
         }
     } elseif (XmlExportEngine::$is_comment_export) {
         global $wp_version;
         if (version_compare($wp_version, '4.2.0', '>=')) {
             $comments = XmlExportEngine::$exportQuery->get_comments();
         } else {
             $comments = XmlExportEngine::$exportQuery;
         }
         foreach ($comments as $comment) {
             $is_export_record = apply_filters('wp_all_export_xml_rows', true, $comment, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
             if (!$is_export_record) {
                 continue;
             }
             // add additional information before each node
             self::before_xml_node($xmlWriter, $comment->comment_ID);
             $xmlWriter->startElement(self::$node_xml_tag);
             XmlExportComment::prepare_data($comment, $xmlWriter, $implode_delimiter, $preview);
             $xmlWriter->endElement();
             // end post
             // add additional information after each node
             self::after_xml_node($xmlWriter, $comment->comment_ID);
             if ($preview) {
                 break;
             }
             do_action('pmxe_exported_post', $comment->comment_ID, XmlExportEngine::$exportRecord);
         }
     } else {
         while (XmlExportEngine::$exportQuery->have_posts()) {
             XmlExportEngine::$exportQuery->the_post();
             $record = get_post(get_the_ID());
             $is_export_record = apply_filters('wp_all_export_xml_rows', true, $record, XmlExportEngine::$exportOptions, XmlExportEngine::$exportID);
             if (!$is_export_record) {
                 continue;
             }
             // add additional information before each node
             self::before_xml_node($xmlWriter, $record->ID);
             $xmlWriter->startElement(self::$node_xml_tag);
             XmlExportCpt::prepare_data($record, $xmlWriter, $acfs, $woo, $woo_order, $implode_delimiter, $preview);
             $xmlWriter->endElement();
             // end post
             // add additional information after each node
             self::after_xml_node($xmlWriter, $record->ID);
             if ($preview) {
                 break;
             }
             do_action('pmxe_exported_post', $record->ID, XmlExportEngine::$exportRecord);
         }
         wp_reset_postdata();
     }
     // [ \Exporting requested data ]
     $xmlWriter->endElement();
     // close root XML element
     if ($preview) {
         return $xmlWriter->flush(true);
     }
     return self::save_xml_to_file($xmlWriter, $file_path, $is_cron, $exported_by_cron);
 }