Ejemplo n.º 1
0
 /**
  * Step #1: Choose File
  */
 public function index()
 {
     $default = PMWI_Plugin::get_default_import_options();
     $this->data['id'] = $id = $this->input->get('id');
     $this->data['import'] = $import = new PMXI_Import_Record();
     if (!$id or $import->getById($id)->isEmpty()) {
         // specified import is not found
         $DefaultOptions = (!empty(PMXI_Plugin::$session->options) ? PMXI_Plugin::$session->options : array()) + $default;
         $post = $this->input->post(apply_filters('pmxi_options_options', $DefaultOptions, true));
     } else {
         $post = $this->input->post($this->data['import']->options + $default);
     }
     $this->data['is_loaded_template'] = !empty(PMXI_Plugin::$session->is_loaded_template) ? PMXI_Plugin::$session->is_loaded_template : false;
     $load_options = $this->input->post('load_template');
     if ($load_options) {
         // init form with template selected
         $template = new PMXI_Template_Record();
         if (!$template->getById($this->data['is_loaded_template'])->isEmpty()) {
             $post = (!empty($template->options) ? $template->options : array()) + $default;
         }
     } elseif ($load_options == -1) {
         $post = $default;
     }
     $this->data['post'] =& $post;
     $this->render();
 }
Ejemplo n.º 2
0
 /**
  * Return singletone instance
  * @return PMWI_Plugin
  */
 public static function getInstance()
 {
     if (self::$instance == NULL) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Ejemplo n.º 3
0
function pmxi_admin_notices()
{
    // notify user if history folder is not writable
    $uploads = wp_upload_dir();
    if (!@is_dir($uploads['basedir'] . '/wpallimport_history') or !@is_writable($uploads['basedir'] . '/wpallimport_history')) {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: History folder %s must be writable for the plugin to function properly. Please deactivate the plugin, set proper permissions to the folder and activate the plugin again.', 'pmxi_plugin'), PMXI_Plugin::getInstance()->getName(), $uploads['basedir'] . '/wpallimport_history');
        ?>
		</p></div>
		<?php 
    }
    // notify user
    if (!PMXI_Plugin::getInstance()->getOption('dismiss') and strpos($_SERVER['REQUEST_URI'], 'pmxi-admin') !== false) {
        ?>
		<div class="updated"><p>
			<?php 
        printf(__('Welcome to WP All Import. We hope you like it. Please send all support requests and feedback to <a href="mailto:support@soflyy.com">support@soflyy.com</a>.<br/><br/><a href="javascript:void(0);" id="dismiss">dismiss</a>', 'pmxi_plugin'));
        ?>
		</p></div>
		<?php 
    }
    if (class_exists('PMWI_Plugin') and (defined('PMWI_VERSION') and version_compare(PMWI_VERSION, '1.2.8') <= 0 and PMWI_EDITION == 'paid' or defined('PMWI_FREE_VERSION') and version_compare(PMWI_FREE_VERSION, '1.1.1') <= 0 and PMWI_EDITION == 'free')) {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: Please update your WP All Import WooCommerce add-on to the latest version</a>', 'pmwi_plugin'), PMWI_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        if (defined('PMWI_EDITION') and PMWI_EDITION == 'paid') {
            deactivate_plugins(PMWI_ROOT_DIR . '/plugin.php');
        } else {
            deactivate_plugins(PMWI_FREE_ROOT_DIR . '/plugin.php');
        }
    }
    $input = new PMXI_Input();
    $messages = $input->get('pmxi_nt', array());
    if ($messages) {
        is_array($messages) or $messages = array($messages);
        foreach ($messages as $type => $m) {
            in_array((string) $type, array('updated', 'error')) or $type = 'updated';
            ?>
			<div class="<?php 
            echo $type;
            ?>
"><p><?php 
            echo $m;
            ?>
</p></div>
			<?php 
        }
    }
}
Ejemplo n.º 4
0
function pmwi_admin_notices()
{
    // notify user if history folder is not writable
    if (!class_exists('Woocommerce')) {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: WooCommerce must be installed.', 'pmwi_plugin'), PMWI_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        deactivate_plugins(PMWI_FREE_ROOT_DIR . '/plugin.php');
    }
    if (!class_exists('PMXI_Plugin')) {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: WP All Import must be installed. Free edition of WP All Import at <a href="http://wordpress.org/plugins/wp-all-import/" target="_blank">http://wordpress.org/plugins/wp-all-import/</a> and the paid edition at <a href="http://www.wpallimport.com/">http://www.wpallimport.com/</a>', 'pmwi_plugin'), PMWI_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        deactivate_plugins(PMWI_FREE_ROOT_DIR . '/plugin.php');
    }
    if (class_exists('PMXI_Plugin') and ((version_compare(PMXI_VERSION, '3.3.6') <= 0 or version_compare(PMXI_VERSION, '4.0.0') >= 0) and PMXI_EDITION == 'paid' or version_compare(PMXI_VERSION, '3.1.1') <= 0 and PMXI_EDITION == 'free')) {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: Please update your WP All Import to the latest version', 'pmwi_plugin'), PMWI_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        deactivate_plugins(PMWI_FREE_ROOT_DIR . '/plugin.php');
    }
    $input = new PMWI_Input();
    $messages = $input->get('PMWI_nt', array());
    if ($messages) {
        is_array($messages) or $messages = array($messages);
        foreach ($messages as $type => $m) {
            in_array((string) $type, array('updated', 'error')) or $type = 'updated';
            ?>
			<div class="<?php 
            echo $type;
            ?>
"><p><?php 
            echo $m;
            ?>
</p></div>
			<?php 
        }
    }
}
 /**
  * @see Controller::render()
  */
 protected function render($viewPath = NULL)
 {
     // assume template file name depending on calling function
     if (is_null($viewPath)) {
         $trace = debug_backtrace();
         $viewPath = str_replace('_', '/', preg_replace('%^' . preg_quote(PMWI_Plugin::PREFIX, '%') . '%', '', strtolower($trace[1]['class']))) . '/' . $trace[1]['function'];
     }
     // render contextual help automatically
     $viewHelpPath = $viewPath;
     // append file extension if not specified
     if (!preg_match('%\\.php$%', $viewHelpPath)) {
         $viewHelpPath .= '.php';
     }
     $viewHelpPath = preg_replace('%\\.php$%', '-help.php', $viewHelpPath);
     $fileHelpPath = PMWI_Plugin::ROOT_DIR . '/views/' . $viewHelpPath;
     if (is_file($fileHelpPath)) {
         // there is help file defined
         ob_start();
         include $fileHelpPath;
         add_contextual_help(PMWI_Plugin::getInstance()->getAdminCurrentScreen()->id, ob_get_clean());
     }
     parent::render($viewPath);
 }
Ejemplo n.º 6
0
function pmxi_admin_notices()
{
    // notify user if history folder is not writable
    $uploads = wp_upload_dir();
    // compare woocommerce add-on version
    if (class_exists('PMWI_Plugin') and (defined('PMWI_VERSION') and version_compare(PMWI_VERSION, '2.1.4') < 0 and PMWI_EDITION == 'paid' or defined('PMWI_FREE_VERSION') and version_compare(PMWI_FREE_VERSION, '1.2.2') < 0 and PMWI_EDITION == 'free')) {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: Please update your WP All Import WooCommerce add-on to the latest version', 'pmwi_plugin'), PMWI_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        if (defined('PMWI_EDITION') and PMWI_EDITION == 'paid') {
            deactivate_plugins(PMWI_ROOT_DIR . '/wpai-woocommerce-add-on.php');
        } else {
            if (defined('PMWI_FREE_ROOT_DIR')) {
                deactivate_plugins(PMWI_FREE_ROOT_DIR . '/plugin.php');
            } else {
                deactivate_plugins(PMWI_ROOT_DIR . '/plugin.php');
            }
        }
    }
    // compare ACF add-on
    if (class_exists('PMAI_Plugin') and defined('PMAI_VERSION') and version_compare(PMAI_VERSION, '3.0.0-beta1') < 0 and PMAI_EDITION == 'paid') {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: Please update your WP All Import ACF add-on to the latest version', 'pmwi_plugin'), PMAI_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        if (defined('PMAI_EDITION') and PMAI_EDITION == 'paid') {
            deactivate_plugins(PMAI_ROOT_DIR . '/wpai-acf-add-on.php');
        }
    }
    // compare Linkcloak add-on
    if (class_exists('PMLCA_Plugin') and defined('PMLCA_VERSION') and version_compare(PMLCA_VERSION, '1.0.0-beta1') < 0 and PMLCA_EDITION == 'paid') {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: Please update your WP All Import Linkcloak add-on to the latest version', 'pmwi_plugin'), PMLCA_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        if (defined('PMLCA_EDITION') and PMLCA_EDITION == 'paid') {
            deactivate_plugins(PMLCA_ROOT_DIR . '/wpai-linkcloak-add-on.php');
        }
    }
    // compare User add-on
    if (class_exists('PMUI_Plugin') and defined('PMUI_VERSION') and version_compare(PMUI_VERSION, '1.0.0-beta1') < 0 and PMUI_EDITION == 'paid') {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: Please update your WP All Import User add-on to the latest version', 'pmwi_plugin'), PMUI_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        if (defined('PMUI_EDITION') and PMUI_EDITION == 'paid') {
            deactivate_plugins(PMUI_ROOT_DIR . '/wpai-user-add-on.php');
        }
    }
    // compare WPML add-on
    if (class_exists('PMLI_Plugin') and defined('PMLI_VERSION') and version_compare(PMLI_VERSION, '1.0.0-beta1') < 0 and PMLI_EDITION == 'paid') {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: Please update your WP All Import WPML add-on to the latest version', 'pmwi_plugin'), PMLI_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        if (defined('PMLI_EDITION') and PMLI_EDITION == 'paid') {
            deactivate_plugins(PMLI_ROOT_DIR . '/plugin.php');
        }
    }
    $input = new PMXI_Input();
    $messages = $input->get('pmxi_nt', array());
    if ($messages) {
        is_array($messages) or $messages = array($messages);
        foreach ($messages as $type => $m) {
            in_array((string) $type, array('updated', 'error')) or $type = 'updated';
            ?>
			<div class="<?php 
            echo $type;
            ?>
"><p><?php 
            echo $m;
            ?>
</p></div>
			<?php 
        }
    }
    $warnings = $input->get('warnings', array());
    if ($warnings) {
        is_array($warnings) or $warnings = explode(',', $warnings);
        foreach ($warnings as $code) {
            switch ($code) {
                case 1:
                    $m = __('<strong>Warning:</strong> your title is blank.', 'pmxi_plugin');
                    break;
                case 2:
                    $m = __('<strong>Warning:</strong> your content is blank.', 'pmxi_plugin');
                    break;
                case 3:
                    $m = __('<strong>Warning:</strong> You must <a href="http://www.wpallimport.com/upgrade-to-pro/?utm_source=free-plugin&utm_medium=in-plugin&utm_campaign=images" target="_blank">upgrade to the Pro edition of WP All Import</a> to import images. The settings you configured in the images section will be ignored.', 'pmxi_plugin');
                    break;
                case 4:
                    $m = __('<strong>Warning:</strong> You must <a href="http://www.wpallimport.com/upgrade-to-pro/?utm_source=free-plugin&utm_medium=in-plugin&utm_campaign=custom-fields" target="_blank">upgrade to the Pro edition of WP All Import</a> to import data to Custom Fields. The settings you configured in the Custom Fields section will be ignored.', 'pmxi_plugin');
                    break;
                default:
                    $m = false;
                    break;
            }
            if ($m) {
                ?>
			<div class="error"><p><?php 
                echo $m;
                ?>
</p></div>
			<?php 
            }
        }
    }
    wp_all_import_addon_notifications();
}
Ejemplo n.º 7
0
Archivo: list.php Proyecto: hikaram/wee
 public function __construct()
 {
     parent::__construct();
     $this->setTable(PMWI_Plugin::getInstance()->getTablePrefix() . 'imports');
 }
Ejemplo n.º 8
0
function pmxi_admin_notices()
{
    // notify user if history folder is not writable
    $uploads = wp_upload_dir();
    // compare woocommerce add-on version
    if (class_exists('PMWI_Plugin') and (defined('PMWI_VERSION') and version_compare(PMWI_VERSION, '2.1.3 RC5') < 0 and PMWI_EDITION == 'paid' or defined('PMWI_FREE_VERSION') and version_compare(PMWI_FREE_VERSION, '1.2.1') <= 0 and PMWI_EDITION == 'free')) {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: Please update your WP All Import WooCommerce add-on to the latest version', 'pmwi_plugin'), PMWI_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        if (defined('PMWI_EDITION') and PMWI_EDITION == 'paid') {
            deactivate_plugins(PMWI_ROOT_DIR . '/wpai-woocommerce-add-on.php');
        } else {
            if (defined('PMWI_FREE_ROOT_DIR')) {
                deactivate_plugins(PMWI_FREE_ROOT_DIR . '/plugin.php');
            } else {
                deactivate_plugins(PMWI_ROOT_DIR . '/plugin.php');
            }
        }
    }
    // compare ACF add-on
    if (class_exists('PMAI_Plugin') and defined('PMAI_VERSION') and version_compare(PMAI_VERSION, '3.0.0-beta1') < 0 and PMAI_EDITION == 'paid') {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: Please update your WP All Import ACF add-on to the latest version', 'pmwi_plugin'), PMAI_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        if (defined('PMAI_EDITION') and PMAI_EDITION == 'paid') {
            deactivate_plugins(PMAI_ROOT_DIR . '/wpai-acf-add-on.php');
        }
    }
    // compare Linkcloak add-on
    if (class_exists('PMLCA_Plugin') and defined('PMLCA_VERSION') and version_compare(PMLCA_VERSION, '1.0.0-beta1') < 0 and PMLCA_EDITION == 'paid') {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: Please update your WP All Import Linkcloak add-on to the latest version', 'pmwi_plugin'), PMLCA_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        if (defined('PMLCA_EDITION') and PMLCA_EDITION == 'paid') {
            deactivate_plugins(PMLCA_ROOT_DIR . '/wpai-linkcloak-add-on.php');
        }
    }
    // compare User add-on
    if (class_exists('PMUI_Plugin') and defined('PMUI_VERSION') and version_compare(PMUI_VERSION, '1.0.0-beta1') < 0 and PMUI_EDITION == 'paid') {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: Please update your WP All Import User add-on to the latest version', 'pmwi_plugin'), PMUI_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        if (defined('PMUI_EDITION') and PMUI_EDITION == 'paid') {
            deactivate_plugins(PMUI_ROOT_DIR . '/wpai-user-add-on.php');
        }
    }
    // compare WPML add-on
    if (class_exists('PMLI_Plugin') and defined('PMLI_VERSION') and version_compare(PMLI_VERSION, '1.0.0-beta1') < 0 and PMLI_EDITION == 'paid') {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: The WPML Add-On Plugin is no longer compatible with this version of WP All Import - please contact support@wpallimport.com and we will supply the latest version of WP All Import that is compatible with the WPML Add-On.', 'pmwi_plugin'), PMLI_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        if (defined('PMLI_EDITION') and PMLI_EDITION == 'paid') {
            deactivate_plugins(PMLI_ROOT_DIR . '/plugin.php');
        }
    }
    $input = new PMXI_Input();
    $messages = $input->get('pmxi_nt', array());
    if ($messages) {
        is_array($messages) or $messages = array($messages);
        foreach ($messages as $type => $m) {
            in_array((string) $type, array('updated', 'error')) or $type = 'updated';
            ?>
			<div class="<?php 
            echo $type;
            ?>
"><p><?php 
            echo $m;
            ?>
</p></div>
			<?php 
        }
    }
    $warnings = $input->get('warnings', array());
    if ($warnings) {
        is_array($warnings) or $warnings = explode(',', $warnings);
        foreach ($warnings as $code) {
            switch ($code) {
                case 1:
                    $m = __('<strong>Warning:</strong> your title is blank.', 'wp_all_import_plugin');
                    break;
                case 2:
                    $m = __('<strong>Warning:</strong> your content is blank.', 'wp_all_import_plugin');
                    break;
                default:
                    $m = false;
                    break;
            }
            if ($m) {
                ?>
			<div class="error"><p><?php 
                echo $m;
                ?>
</p></div>
			<?php 
            }
        }
    }
    wp_all_import_addon_notifications();
}
Ejemplo n.º 9
0
 public static function generateImportTemplate(&$export, $file_path = '', $foundPosts = 0, $link_to_import = true)
 {
     $exportOptions = $export->options;
     $custom_type = empty($exportOptions['cpt']) ? 'post' : $exportOptions['cpt'][0];
     // Do not create an import template for WooCommerce Refunds
     // if ( empty($export->parent_id) and in_array($custom_type, array('shop_order_refund'))) return false;
     // Generate template for WP All Import
     if ($exportOptions['is_generate_templates']) {
         self::$templateOptions = array('type' => (!empty($exportOptions['cpt']) and $exportOptions['cpt'][0] == 'page') ? 'page' : 'post', 'wizard_type' => 'new', 'deligate' => 'wpallexport', 'custom_type' => XmlExportEngine::$is_user_export ? 'import_users' : $custom_type, 'status' => 'xpath', 'is_multiple_page_parent' => 'no', 'unique_key' => '', 'acf' => array(), 'fields' => array(), 'is_multiple_field_value' => array(), 'multiple_value' => array(), 'fields_delimiter' => array(), 'update_all_data' => 'no', 'is_update_status' => 0, 'is_update_title' => 0, 'is_update_author' => 0, 'is_update_slug' => 0, 'is_update_content' => 0, 'is_update_excerpt' => 0, 'is_update_dates' => 0, 'is_update_menu_order' => 0, 'is_update_parent' => 0, 'is_update_attachments' => 0, 'is_update_acf' => 0, 'update_acf_logic' => 'only', 'acf_list' => '', 'is_update_product_type' => 1, 'is_update_attributes' => 0, 'update_attributes_logic' => 'only', 'attributes_list' => '', 'is_update_images' => 0, 'is_update_custom_fields' => 0, 'update_custom_fields_logic' => 'only', 'custom_fields_list' => '', 'is_update_categories' => 0, 'update_categories_logic' => 'only', 'taxonomies_list' => '', 'export_id' => $export->id);
         if (in_array('product', $exportOptions['cpt']) and class_exists('PMWI_Plugin')) {
             $default = PMWI_Plugin::get_default_import_options();
             self::$templateOptions = array_replace_recursive(self::$templateOptions, $default);
             self::$templateOptions['_virtual'] = 1;
             self::$templateOptions['_downloadable'] = 1;
             self::$templateOptions['put_variation_image_to_gallery'] = 1;
             self::$templateOptions['disable_auto_sku_generation'] = 1;
         }
         if (in_array('shop_order', $exportOptions['cpt']) and class_exists('PMWI_Plugin')) {
             self::$templateOptions['update_all_data'] = 'no';
             self::$templateOptions['is_update_status'] = 0;
             self::$templateOptions['is_update_dates'] = 0;
             self::$templateOptions['is_update_excerpt'] = 0;
             $default = PMWI_Plugin::get_default_import_options();
             self::$templateOptions['pmwi_order'] = $default['pmwi_order'];
             self::$templateOptions['pmwi_order']['is_update_billing_details'] = 0;
             self::$templateOptions['pmwi_order']['is_update_shipping_details'] = 0;
             self::$templateOptions['pmwi_order']['is_update_payment'] = 0;
             self::$templateOptions['pmwi_order']['is_update_notes'] = 0;
             self::$templateOptions['pmwi_order']['is_update_products'] = 0;
             self::$templateOptions['pmwi_order']['is_update_fees'] = 0;
             self::$templateOptions['pmwi_order']['is_update_coupons'] = 0;
             self::$templateOptions['pmwi_order']['is_update_shipping'] = 0;
             self::$templateOptions['pmwi_order']['is_update_taxes'] = 0;
             self::$templateOptions['pmwi_order']['is_update_refunds'] = 0;
             self::$templateOptions['pmwi_order']['is_update_total'] = 0;
         }
         if (XmlExportEngine::$is_user_export) {
             self::$templateOptions['is_update_first_name'] = 0;
             self::$templateOptions['is_update_last_name'] = 0;
             self::$templateOptions['is_update_role'] = 0;
             self::$templateOptions['is_update_nickname'] = 0;
             self::$templateOptions['is_update_description'] = 0;
             self::$templateOptions['is_update_login'] = 0;
             self::$templateOptions['is_update_password'] = 0;
             self::$templateOptions['is_update_nicename'] = 0;
             self::$templateOptions['is_update_email'] = 0;
             self::$templateOptions['is_update_registered'] = 0;
             self::$templateOptions['is_update_display_name'] = 0;
             self::$templateOptions['is_update_url'] = 0;
         }
         self::prepare_import_template($exportOptions);
         $tpl_options = self::$templateOptions;
         if ('csv' == $exportOptions['export_to']) {
             $tpl_options['delimiter'] = $exportOptions['delimiter'];
             $tpl_options['root_element'] = 'node';
         } else {
             $tpl_options['root_element'] = $exportOptions['record_xml_tag'];
         }
         $tpl_options['update_all_data'] = 'yes';
         $tpl_options['is_update_status'] = 1;
         $tpl_options['is_update_title'] = 1;
         $tpl_options['is_update_author'] = 1;
         $tpl_options['is_update_slug'] = 1;
         $tpl_options['is_update_content'] = 1;
         $tpl_options['is_update_excerpt'] = 1;
         $tpl_options['is_update_dates'] = 1;
         $tpl_options['is_update_menu_order'] = 1;
         $tpl_options['is_update_parent'] = 1;
         $tpl_options['is_update_attachments'] = 1;
         $tpl_options['is_update_acf'] = 1;
         $tpl_options['update_acf_logic'] = 'full_update';
         $tpl_options['acf_list'] = '';
         $tpl_options['is_update_product_type'] = 1;
         $tpl_options['is_update_attributes'] = 1;
         $tpl_options['update_attributes_logic'] = 'full_update';
         $tpl_options['attributes_list'] = '';
         $tpl_options['is_update_images'] = 1;
         $tpl_options['is_update_custom_fields'] = 1;
         $tpl_options['update_custom_fields_logic'] = 'full_update';
         $tpl_options['custom_fields_list'] = '';
         $tpl_options['is_update_categories'] = 1;
         $tpl_options['update_categories_logic'] = 'full_update';
         $tpl_options['taxonomies_list'] = '';
         $tpl_data = array('name' => $exportOptions['template_name'], 'is_keep_linebreaks' => 0, 'is_leave_html' => 0, 'fix_characters' => 0, 'options' => $tpl_options);
         $exportOptions['tpl_data'] = $tpl_data;
         $export->set(array('options' => $exportOptions))->save();
     }
     $link_to_import and $export->options['is_generate_import'] and self::link_template_to_import($export, $file_path, $foundPosts);
 }
 public function parse()
 {
     $cxpath = $this->xpath . $this->import->xpath;
     $this->data = array();
     $records = array();
     $tmp_files = array();
     $this->chunk == 1 and $this->logger and call_user_func($this->logger, __('Composing shop order data...', 'wpai_woocommerce_addon_plugin'));
     $default = PMWI_Plugin::get_default_import_options();
     foreach ($default['pmwi_order'] as $option => $default_value) {
         if (in_array($option, array('status_xpath', 'payment_method_xpath', 'order_note_visibility_xpath', 'billing_source', 'billing_source_match_by', 'shipping_source', 'products_source', 'order_taxes_logic', 'order_refund_issued_source', 'order_refund_issued_match_by', 'order_total_logic', 'order_note_separate_logic', 'order_note_separator')) or strpos($option, 'is_update_') !== false or strpos($option, '_repeater_mode') !== false) {
             continue;
         }
         switch ($option) {
             case 'date':
             case 'order_refund_date':
                 if (!empty($this->import->options['pmwi_order'][$option])) {
                     $dates = XmlImportParser::factory($this->xml, $cxpath, $this->import->options['pmwi_order'][$option], $file)->parse($records);
                     $tmp_files[] = $file;
                     $warned = array();
                     // used to prevent the same notice displaying several times
                     foreach ($dates as $i => $d) {
                         if ($d == 'now') {
                             $d = current_time('mysql');
                         }
                         // Replace 'now' with the WordPress local time to account for timezone offsets (WordPress references its local time during publishing rather than the server’s time so it should use that)
                         $time = strtotime($d);
                         if (FALSE === $time) {
                             $time = time();
                         }
                         $this->data['pmwi_order'][$option][$i] = date('Y-m-d H:i:s', $time);
                     }
                 } else {
                     $this->count and $this->data['pmwi_order'][$option] = array_fill(0, $this->count, date('Y-m-d H:i:s'));
                 }
                 break;
             case 'status':
             case 'payment_method':
             case 'order_note_visibility':
                 if ($this->import->options['pmwi_order'][$option] == 'xpath' && $this->import->options['pmwi_order'][$option . '_xpath'] != "") {
                     $this->data['pmwi_order'][$option] = XmlImportParser::factory($this->xml, $cxpath, $this->import->options['pmwi_order'][$option . '_xpath'], $file)->parse($records);
                     $tmp_files[] = $file;
                 } else {
                     $this->count and $this->data['pmwi_order'][$option] = array_fill(0, $this->count, $this->import->options['pmwi_order'][$option]);
                 }
                 break;
             case 'products':
             case 'manual_products':
                 $this->data['pmwi_order'][$option] = array();
                 switch ($this->import->options['pmwi_order']['products_repeater_mode']) {
                     case 'xml':
                         foreach ($this->import->options['pmwi_order'][$option] as $key => $row) {
                             for ($k = 0; $k < $this->count; $k++) {
                                 $base_xpath = '[' . ($k + 1) . ']/' . ltrim(trim($this->import->options['pmwi_order']['products_repeater_mode_foreach'], '{}!'), '/');
                                 $rows = XmlImportParser::factory($this->xml, $cxpath . $base_xpath, "{.}", $file)->parse();
                                 $tmp_files[] = $file;
                                 $row_data = $this->parse_item_row($row, $cxpath . $base_xpath, count($rows));
                                 $products = array();
                                 if (!empty($row_data)) {
                                     for ($j = 0; $j < count($rows); $j++) {
                                         $products[] = array('sku' => $row_data['sku'][$j], 'qty' => $row_data['qty'][$j], 'price_per_unit' => isset($row_data['price_per_unit'][$j]) ? $row_data['price_per_unit'][$j] : 0, 'tax_rates' => array());
                                         if (!empty($row_data['tax_rates'])) {
                                             foreach ($row_data['tax_rates'] as $tax_rate) {
                                                 $products[$j]['tax_rates'][] = array('code' => $tax_rate['code'][$j], 'calculate_logic' => $tax_rate['calculate_logic'][$j], 'percentage_value' => $tax_rate['percentage_value'][$j], 'amount_per_unit' => $tax_rate['amount_per_unit'][$j]);
                                             }
                                         }
                                         if (!empty($row_data['meta_name'])) {
                                             foreach ($row_data['meta_name'] as $meta_name) {
                                                 $products[$j]['meta_name'][] = $meta_name[$j];
                                             }
                                         }
                                         if (!empty($row_data['meta_value'])) {
                                             foreach ($row_data['meta_value'] as $meta_value) {
                                                 $products[$j]['meta_value'][] = $meta_value[$j];
                                             }
                                         }
                                     }
                                 }
                                 $this->data['pmwi_order'][$option][] = $products;
                             }
                             break;
                         }
                         break;
                     case 'csv':
                         foreach ($this->import->options['pmwi_order'][$option] as $key => $row) {
                             if (empty($this->import->options['pmwi_order']['products_repeater_mode_separator'])) {
                                 break;
                             }
                             $row_data = $this->parse_item_row($row, $cxpath, $this->count);
                             for ($k = 0; $k < $this->count; $k++) {
                                 $products = array();
                                 $skus = explode($this->import->options['pmwi_order']['products_repeater_mode_separator'], $row_data['sku'][$k]);
                                 $qtys = explode($this->import->options['pmwi_order']['products_repeater_mode_separator'], $row_data['qty'][$k]);
                                 $prices = isset($row_data['price_per_unit'][$k]) ? explode($this->import->options['pmwi_order']['products_repeater_mode_separator'], $row_data['price_per_unit'][$k]) : array();
                                 if (!empty($skus)) {
                                     for ($j = 0; $j < count($skus); $j++) {
                                         $products[] = array('sku' => $skus[$j], 'qty' => $qtys[$j], 'price_per_unit' => isset($prices[$j]) ? $prices[$j] : 0, 'tax_rates' => array());
                                         if (!empty($row_data['tax_rates'])) {
                                             foreach ($row_data['tax_rates'] as $tax_rate) {
                                                 $products[$j]['tax_rates'][] = array('code' => $tax_rate['code'][$k], 'calculate_logic' => $tax_rate['calculate_logic'][$k], 'percentage_value' => $tax_rate['percentage_value'][$k], 'amount_per_unit' => $tax_rate['amount_per_unit'][$k]);
                                             }
                                         }
                                         if (!empty($row_data['meta_name'])) {
                                             foreach ($row_data['meta_name'] as $meta_name) {
                                                 $products[$j]['meta_name'][] = $meta_name[$j];
                                             }
                                         }
                                         if (!empty($row_data['meta_value'])) {
                                             foreach ($row_data['meta_value'] as $meta_value) {
                                                 $products[$j]['meta_value'][] = $meta_value[$j];
                                             }
                                         }
                                     }
                                 }
                                 $this->data['pmwi_order'][$option][] = $products;
                             }
                             break;
                         }
                         break;
                     default:
                         $row_data = array();
                         foreach ($this->import->options['pmwi_order'][$option] as $key => $row) {
                             $row_data[] = $this->parse_item_row($row, $cxpath, $this->count);
                         }
                         for ($j = 0; $j < $this->count; $j++) {
                             $products = array();
                             foreach ($row_data as $k => $product) {
                                 $products[] = array('sku' => $product['sku'][$j], 'qty' => $product['qty'][$j], 'price_per_unit' => isset($product['price_per_unit'][$j]) ? $product['price_per_unit'][$j] : 0, 'tax_rates' => array());
                                 if (!empty($product['tax_rates'])) {
                                     foreach ($product['tax_rates'] as $tax_rate) {
                                         $products[$k]['tax_rates'][] = array('code' => $tax_rate['code'][$j], 'calculate_logic' => $tax_rate['calculate_logic'][$j], 'percentage_value' => $tax_rate['percentage_value'][$j], 'amount_per_unit' => $tax_rate['amount_per_unit'][$j]);
                                     }
                                 }
                                 if (!empty($product['meta_name'])) {
                                     foreach ($product['meta_name'] as $meta_name) {
                                         $products[$k]['meta_name'][] = $meta_name[$j];
                                     }
                                 }
                                 if (!empty($product['meta_value'])) {
                                     foreach ($product['meta_value'] as $meta_value) {
                                         $products[$k]['meta_value'][] = $meta_value[$j];
                                     }
                                 }
                             }
                             $this->data['pmwi_order'][$option][] = $products;
                         }
                         break;
                 }
                 break;
             case 'fees':
             case 'coupons':
             case 'shipping':
             case 'taxes':
             case 'notes':
                 $this->data['pmwi_order'][$option] = array();
                 switch ($this->import->options['pmwi_order'][$option . '_repeater_mode']) {
                     case 'xml':
                         foreach ($this->import->options['pmwi_order'][$option] as $key => $row) {
                             for ($k = 0; $k < $this->count; $k++) {
                                 $base_xpath = '[' . ($k + 1) . ']/' . ltrim(trim($this->import->options['pmwi_order'][$option . '_repeater_mode_foreach'], '{}!'), '/');
                                 $rows = XmlImportParser::factory($this->xml, $cxpath . $base_xpath, "{.}", $file)->parse();
                                 $tmp_files[] = $file;
                                 $row_data = $this->parse_item_row($row, $cxpath . $base_xpath, count($rows));
                                 $items = array();
                                 if (!empty($row_data)) {
                                     for ($j = 0; $j < count($rows); $j++) {
                                         foreach ($row_data as $itemkey => $values) {
                                             $items[$j][$itemkey] = $values[$j];
                                         }
                                     }
                                 }
                                 $this->data['pmwi_order'][$option][] = $items;
                             }
                             break;
                         }
                         break;
                     case 'csv':
                         $separator = $this->import->options['pmwi_order'][$option . '_repeater_mode_separator'];
                         foreach ($this->import->options['pmwi_order'][$option] as $key => $row) {
                             if (empty($separator)) {
                                 break;
                             }
                             $row_data = $this->parse_item_row($row, $cxpath, $this->count);
                             for ($k = 0; $k < $this->count; $k++) {
                                 $items = array();
                                 $maxCountRows = 0;
                                 foreach ($row_data as $itemkey => $values) {
                                     $itemIndex = 0;
                                     $rows = explode($separator, $values[$k]);
                                     if (!empty($rows)) {
                                         if (count($rows) > $maxCountRows) {
                                             $maxCountRows = count($rows);
                                         }
                                         if (count($rows) == 1) {
                                             for ($j = 0; $j < $maxCountRows; $j++) {
                                                 $items[$itemIndex][$itemkey] = trim($rows[0]);
                                                 $itemIndex++;
                                             }
                                         } else {
                                             foreach ($rows as $val) {
                                                 $items[$itemIndex][$itemkey] = trim($val);
                                                 $itemIndex++;
                                             }
                                         }
                                     }
                                     // else
                                     // {
                                     // 	for ($j = 0; $j < $maxCountRows; $j++)
                                     // 	{
                                     // 		$items[$itemIndex][$itemkey] = '';
                                     // 		$itemIndex++;
                                     // 	}
                                     // }
                                 }
                                 $this->data['pmwi_order'][$option][] = $items;
                             }
                             break;
                         }
                         break;
                     default:
                         $row_data = array();
                         foreach ($this->import->options['pmwi_order'][$option] as $key => $row) {
                             $row_data[] = $this->parse_item_row($row, $cxpath, $this->count);
                         }
                         for ($j = 0; $j < $this->count; $j++) {
                             $items = array();
                             $itemIndex = 0;
                             foreach ($row_data as $k => $item) {
                                 foreach ($item as $itemkey => $values) {
                                     $items[$itemIndex][$itemkey] = $values[$j];
                                 }
                                 $itemIndex++;
                             }
                             $this->data['pmwi_order'][$option][] = $items;
                         }
                         break;
                 }
                 break;
             default:
                 if (!empty($this->import->options['pmwi_order'][$option])) {
                     $this->data['pmwi_order'][$option] = XmlImportParser::factory($this->xml, $cxpath, $this->import->options['pmwi_order'][$option], $file)->parse($records);
                     $tmp_files[] = $file;
                 } else {
                     $this->count and $this->data['pmwi_order'][$option] = array_fill(0, $this->count, $default_value);
                 }
                 break;
         }
     }
     foreach ($tmp_files as $file) {
         // remove all temporary files created
         unlink($file);
     }
     // file_put_contents(PMWI_ROOT_DIR . '/order_parse.txt', json_encode($this->data));
     return $this->data;
 }