Exemple #1
0
 /**
  * Step #1: Choose CPT
  */
 public function index()
 {
     $action = $this->input->get('action');
     $DefaultOptions = array('cpt' => '', 'export_to' => 'xml', 'export_type' => 'specific', 'wp_query' => '', 'filter_rules_hierarhy' => '', 'product_matching_mode' => 'strict', 'wp_query_selector' => 'wp_query', 'auto_generate' => 0);
     if (!in_array($action, array('index'))) {
         PMXE_Plugin::$session->clean_session();
         $this->data['preload'] = false;
     } else {
         $DefaultOptions = (PMXE_Plugin::$session->has_session() ? PMXE_Plugin::$session->get_clear_session_data() : array()) + $DefaultOptions;
         $this->data['preload'] = true;
     }
     $wp_uploads = wp_upload_dir();
     $this->data['post'] = $post = $this->input->post($DefaultOptions);
     if (is_array($this->data['post']['cpt'])) {
         $this->data['post']['cpt'] = $this->data['post']['cpt'][0];
     }
     // Delete history
     $history_files = PMXE_Helper::safe_glob(PMXE_ROOT_DIR . '/history/*', PMXE_Helper::GLOB_RECURSE | PMXE_Helper::GLOB_PATH);
     if (!empty($history_files)) {
         foreach ($history_files as $filePath) {
             @file_exists($filePath) and @unlink($filePath);
         }
     }
     if (!class_exists('ZipArchive')) {
         $this->errors->add('form-validation', __('ZipArchive class is missing on your server.<br/>Please contact your web hosting provider and ask them to install and activate ZipArchive.', 'wp_all_export_plugin'));
     }
     if (!class_exists('XMLReader') or !class_exists('XMLWriter')) {
         $this->errors->add('form-validation', __('Required PHP components are missing.<br/><br/>WP All Export requires XMLReader, and XMLWriter PHP modules to be installed.<br/>These are standard features of PHP, and are necessary for WP All Export to write the files you are trying to export.<br/>Please contact your web hosting provider and ask them to install and activate the DOMDocument, XMLReader, and XMLWriter PHP modules.', 'wp_all_export_plugin'));
     }
     if ($this->input->post('is_submitted')) {
         PMXE_Plugin::$session->set('export_type', $post['export_type']);
         PMXE_Plugin::$session->set('filter_rules_hierarhy', $post['filter_rules_hierarhy']);
         PMXE_Plugin::$session->set('product_matching_mode', $post['product_matching_mode']);
         PMXE_Plugin::$session->set('wp_query_selector', $post['wp_query_selector']);
         if (!empty($post['auto_generate'])) {
             $auto_generate = XmlCsvExport::auto_genetate_export_fields($post, $this->errors);
             foreach ($auto_generate as $key => $value) {
                 PMXE_Plugin::$session->set($key, $value);
             }
             PMXE_Plugin::$session->save_data();
         } else {
             $engine = new XmlExportEngine($post, $this->errors);
             $engine->init_additional_data();
         }
     }
     if ($this->input->post('is_submitted') and !$this->errors->get_error_codes()) {
         check_admin_referer('choose-cpt', '_wpnonce_choose-cpt');
         PMXE_Plugin::$session->save_data();
         if (!empty($post['auto_generate'])) {
             wp_redirect(add_query_arg('action', 'options', $this->baseUrl));
             die;
         } else {
             wp_redirect(add_query_arg('action', 'template', $this->baseUrl));
             die;
         }
     }
     $this->render();
 }