예제 #1
0
/**
*	AJAX action export processing
*/
function pmxe_wp_ajax_wpallexport()
{
    if (!check_ajax_referer('wp_all_export_secure', 'security', false)) {
        exit(__('Security check', 'wp_all_export_plugin'));
    }
    if (!current_user_can(PMXE_Plugin::$capabilities)) {
        exit(__('Security check', 'wp_all_export_plugin'));
    }
    $input = new PMXE_Input();
    $export_id = $input->get('id', 0);
    if (empty($export_id)) {
        $export_id = !empty(PMXE_Plugin::$session->update_previous) ? PMXE_Plugin::$session->update_previous : 0;
    }
    $wp_uploads = wp_upload_dir();
    $export = new PMXE_Export_Record();
    $export->getById($export_id);
    if ($export->isEmpty()) {
        exit(__('Export is not defined.', 'wp_all_export_plugin'));
    }
    $exportOptions = $export->options + PMXE_Plugin::get_default_import_options();
    wp_reset_postdata();
    XmlExportEngine::$exportOptions = $exportOptions;
    XmlExportEngine::$is_user_export = $exportOptions['is_user_export'];
    XmlExportEngine::$is_comment_export = $exportOptions['is_comment_export'];
    XmlExportEngine::$exportID = $export_id;
    XmlExportEngine::$exportRecord = $export;
    $errors = new WP_Error();
    $engine = new XmlExportEngine($exportOptions, $errors);
    $posts_per_page = $exportOptions['records_per_iteration'];
    if ('advanced' == $exportOptions['export_type']) {
        if (XmlExportEngine::$is_user_export) {
            exit(json_encode(array('html' => __('Upgrade to the Pro edition of WP All Export to Export Users', 'wp_all_export_plugin'))));
        } elseif (XmlExportEngine::$is_comment_export) {
            exit(json_encode(array('html' => __('Upgrade to the Pro edition of WP All Export to Export Comments', 'wp_all_export_plugin'))));
        } else {
            remove_all_actions('parse_query');
            remove_all_actions('pre_get_posts');
            remove_all_filters('posts_clauses');
            add_filter('posts_join', 'wp_all_export_posts_join', 10, 1);
            add_filter('posts_where', 'wp_all_export_posts_where', 10, 1);
            $exportQuery = eval('return new WP_Query(array(' . $exportOptions['wp_query'] . ', \'offset\' => ' . $export->exported . ', \'posts_per_page\' => ' . $posts_per_page . ' ));');
            remove_filter('posts_where', 'wp_all_export_posts_where');
            remove_filter('posts_join', 'wp_all_export_posts_join');
        }
    } else {
        XmlExportEngine::$post_types = $exportOptions['cpt'];
        // $is_products_export = ($exportOptions['cpt'] == 'product' and class_exists('WooCommerce'));
        if (in_array('users', $exportOptions['cpt']) or in_array('shop_customer', $exportOptions['cpt'])) {
            exit(json_encode(array('html' => __('Upgrade to the Pro edition of WP All Export to Export Users', 'wp_all_export_plugin'))));
        } elseif (in_array('comments', $exportOptions['cpt'])) {
            exit(json_encode(array('html' => __('Upgrade to the Pro edition of WP All Export to Export Comments', 'wp_all_export_plugin'))));
        } else {
            remove_all_actions('parse_query');
            remove_all_actions('pre_get_posts');
            remove_all_filters('posts_clauses');
            add_filter('posts_join', 'wp_all_export_posts_join', 10, 1);
            add_filter('posts_where', 'wp_all_export_posts_where', 10, 1);
            $exportQuery = new WP_Query(array('post_type' => $exportOptions['cpt'], 'post_status' => 'any', 'orderby' => 'ID', 'order' => 'ASC', 'offset' => $export->exported, 'posts_per_page' => $posts_per_page));
            remove_filter('posts_where', 'wp_all_export_posts_where');
            remove_filter('posts_join', 'wp_all_export_posts_join');
        }
    }
    XmlExportEngine::$exportQuery = $exportQuery;
    $engine->init_additional_data();
    // get total founded records
    if (XmlExportEngine::$is_comment_export) {
    } else {
        $foundPosts = !XmlExportEngine::$is_user_export ? $exportQuery->found_posts : $exportQuery->get_total();
        $postCount = !XmlExportEngine::$is_user_export ? $exportQuery->post_count : count($exportQuery->get_results());
    }
    // [ \get total founded records ]
    if (!$export->exported) {
        $attachment_list = $export->options['attachment_list'];
        if (!empty($attachment_list)) {
            foreach ($attachment_list as $attachment) {
                if (!is_numeric($attachment)) {
                    @unlink($attachment);
                }
            }
        }
        $exportOptions['attachment_list'] = array();
        $export->set(array('options' => $exportOptions))->save();
        $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
        if ($is_secure_import and !empty($exportOptions['filepath'])) {
            $exportOptions['filepath'] = '';
        }
        PMXE_Plugin::$session->set('count', $foundPosts);
        PMXE_Plugin::$session->save_data();
    }
    // if posts still exists then export them
    if ($postCount) {
        XmlCsvExport::export();
        $export->set(array('exported' => $export->exported + $postCount, 'last_activity' => date('Y-m-d H:i:s')))->save();
    }
    if ($posts_per_page != -1 and $postCount) {
        wp_send_json(array('export_id' => $export->id, 'queue_export' => false, 'exported' => $export->exported, 'percentage' => ceil($export->exported / $foundPosts * 100), 'done' => false, 'records_per_request' => $exportOptions['records_per_iteration']));
    } else {
        if (file_exists(PMXE_Plugin::$session->file)) {
            if ($exportOptions['export_to'] == 'xml') {
                $main_xml_tag = apply_filters('wp_all_export_main_xml_tag', $exportOptions['main_xml_tag'], $export->id);
                file_put_contents(PMXE_Plugin::$session->file, '</' . $main_xml_tag . '>', FILE_APPEND);
                $xml_footer = apply_filters('wp_all_export_xml_footer', '', $export->id);
                if (!empty($xml_footer)) {
                    file_put_contents(PMXE_Plugin::$session->file, $xml_footer, FILE_APPEND);
                }
            }
            $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
            if (!$is_secure_import) {
                if (!$export->isEmpty()) {
                    $wp_filetype = wp_check_filetype(basename(PMXE_Plugin::$session->file), null);
                    $attachment_data = array('guid' => $wp_uploads['baseurl'] . '/' . _wp_relative_upload_path(PMXE_Plugin::$session->file), 'post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename(PMXE_Plugin::$session->file)), 'post_content' => '', 'post_status' => 'inherit');
                    if (empty($export->attch_id)) {
                        $attach_id = wp_insert_attachment($attachment_data, PMXE_Plugin::$session->file);
                    } elseif ($export->options['creata_a_new_export_file']) {
                        $attach_id = wp_insert_attachment($attachment_data, PMXE_Plugin::$session->file);
                    } else {
                        $attach_id = $export->attch_id;
                        $attachment = get_post($attach_id);
                        if ($attachment) {
                            update_attached_file($attach_id, PMXE_Plugin::$session->file);
                            wp_update_attachment_metadata($attach_id, $attachment_data);
                        } else {
                            $attach_id = wp_insert_attachment($attachment_data, PMXE_Plugin::$session->file);
                        }
                    }
                    if (!in_array($attach_id, $exportOptions['attachment_list'])) {
                        $exportOptions['attachment_list'][] = $attach_id;
                    }
                    $export->set(array('attch_id' => $attach_id, 'options' => $exportOptions))->save();
                }
            } else {
                $exportOptions['filepath'] = wp_all_export_get_relative_path(PMXE_Plugin::$session->file);
                if (!$export->isEmpty()) {
                    $export->set(array('options' => $exportOptions))->save();
                }
            }
            PMXE_Wpallimport::generateImportTemplate($export, PMXE_Plugin::$session->file, PMXE_Plugin::$session->count);
        }
        $export->set(array('executing' => 0, 'canceled' => 0, 'iteration' => ++$export->iteration))->save();
        do_action('pmxe_after_export', $export->id, $export);
        $queue_exports = empty($export->parent_id) ? array() : get_option('wp_all_export_queue_' . $export->parent_id);
        if (!empty($queue_exports) and !empty($export->parent_id)) {
            array_shift($queue_exports);
        }
        if (empty($queue_exports)) {
            delete_option('wp_all_export_queue_' . (empty($export->parent_id) ? $export->id : $export->parent_id));
        } else {
            update_option('wp_all_export_queue_' . (empty($export->parent_id) ? $export->id : $export->parent_id), $queue_exports);
        }
        wp_send_json(array('export_id' => $export->id, 'queue_export' => empty($queue_exports) ? false : $queue_exports[0], 'exported' => $export->exported, 'percentage' => 100, 'done' => true, 'records_per_request' => $exportOptions['records_per_iteration']));
    }
}
예제 #2
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);
 }
예제 #3
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'])) {
             $default = array('is_multiple_product_type' => 'yes', 'multiple_product_type' => 'simple', 'is_product_virtual' => 'no', 'is_product_downloadable' => 'no', 'is_product_enabled' => 'yes', 'is_variation_enabled' => 'yes', 'is_product_featured' => 'no', 'is_product_visibility' => 'visible', 'is_multiple_product_tax_status' => 'yes', 'multiple_product_tax_status' => 'none', 'is_multiple_product_tax_class' => 'yes', 'is_product_manage_stock' => 'no', 'product_stock_status' => 'auto', 'product_allow_backorders' => 'no', 'product_sold_individually' => 'no', 'is_multiple_product_shipping_class' => 'yes', 'is_multiple_grouping_product' => 'yes', 'is_product_enable_reviews' => 'no', 'single_sale_price_dates_from' => 'now', 'single_sale_price_dates_to' => 'now', 'product_files_delim' => ',', 'product_files_names_delim' => ',', 'matching_parent' => 'auto', 'parent_indicator' => 'custom field', 'missing_records_stock_status' => 0, 'is_variable_sale_price_shedule' => 0, 'is_variable_product_virtual' => 'no', 'is_variable_product_manage_stock' => 'no', 'is_multiple_variable_product_shipping_class' => 'yes', 'is_multiple_variable_product_tax_class' => 'yes', 'multiple_variable_product_tax_class' => 'parent', 'variable_stock_status' => 'instock', 'variable_allow_backorders' => 'no', 'is_variable_product_downloadable' => 'no', 'variable_product_files_delim' => ',', 'variable_product_files_names_delim' => ',', 'is_variable_product_enabled' => 'yes', 'first_is_parent' => 'yes', 'default_attributes_type' => 'first', 'disable_sku_matching' => 1, 'disable_prepare_price' => 1, 'convert_decimal_separator' => 1, 'grouping_indicator' => 'xpath', 'is_update_product_type' => 1, 'make_simple_product' => 1, 'single_product_regular_price_adjust_type' => '%', 'single_product_sale_price_adjust_type' => '%', 'is_variation_product_manage_stock' => 'no', 'variation_stock_status' => 'auto');
             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'])) {
             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'] = array();
             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;
             self::$templateOptions['pmwi_order']['status'] = 'wc-pending';
             self::$templateOptions['pmwi_order']['billing_source'] = 'existing';
             self::$templateOptions['pmwi_order']['billing_source_match_by'] = 'username';
             self::$templateOptions['pmwi_order']['shipping_source'] = 'copy';
             self::$templateOptions['pmwi_order']['products_repeater_mode'] = 'csv';
             self::$templateOptions['pmwi_order']['products_repeater_mode_separator'] = '|';
             self::$templateOptions['pmwi_order']['products_source'] = 'existing';
             self::$templateOptions['pmwi_order']['fees_repeater_mode'] = 'csv';
             self::$templateOptions['pmwi_order']['fees_repeater_mode_separator'] = '|';
             self::$templateOptions['pmwi_order']['coupons_repeater_mode'] = 'csv';
             self::$templateOptions['pmwi_order']['coupons_repeater_mode_separator'] = '|';
             self::$templateOptions['pmwi_order']['shipping_repeater_mode'] = 'csv';
             self::$templateOptions['pmwi_order']['shipping_repeater_mode_separator'] = '|';
             self::$templateOptions['pmwi_order']['taxes_repeater_mode'] = 'csv';
             self::$templateOptions['pmwi_order']['taxes_repeater_mode_separator'] = '|';
             self::$templateOptions['pmwi_order']['order_total_logic'] = 'auto';
             self::$templateOptions['pmwi_order']['order_refund_date'] = 'now';
             self::$templateOptions['pmwi_order']['order_refund_issued_source'] = 'existing';
             self::$templateOptions['pmwi_order']['order_refund_issued_match_by'] = 'username';
             self::$templateOptions['pmwi_order']['notes_repeater_mode'] = 'csv';
             self::$templateOptions['pmwi_order']['notes_repeater_mode_separator'] = '|';
         }
         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' => 1, '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);
 }
예제 #4
0
 /**
  * Step #4: Export Processing
  */
 public function process()
 {
     @set_time_limit(0);
     $export = $this->data['update_previous'];
     if (!PMXE_Plugin::is_ajax()) {
         if ("" == PMXE_Plugin::$session->friendly_name) {
             $friendly_name = '';
             $post_types = PMXE_Plugin::$session->get('cpt');
             if (!empty($post_types)) {
                 if (in_array('users', $post_types)) {
                     $friendly_name = 'Users Export - ' . date("Y F d H:i");
                 } elseif (in_array('shop_customer', $post_types)) {
                     $friendly_name = 'Customers Export - ' . date("Y F d H:i");
                 } elseif (in_array('comments', $post_types)) {
                     $friendly_name = 'Comments Export - ' . date("Y F d H:i");
                 } else {
                     $post_type_details = get_post_type_object(array_shift($post_types));
                     $friendly_name = $post_type_details->labels->name . ' Export - ' . date("Y F d H:i");
                 }
             } else {
                 $friendly_name = 'WP_Query Export - ' . date("Y F d H:i");
             }
             PMXE_Plugin::$session->set('friendly_name', $friendly_name);
         }
         PMXE_Plugin::$session->set('file', '');
         PMXE_Plugin::$session->save_data();
         $export->set(array('triggered' => 0, 'processing' => 0, 'exported' => 0, 'executing' => 1, 'canceled' => 0, 'options' => PMXE_Plugin::$session->get_clear_session_data(), 'friendly_name' => PMXE_Plugin::$session->friendly_name, 'scheduled' => PMXE_Plugin::$session->is_scheduled ? PMXE_Plugin::$session->scheduled_period : '', 'registered_on' => date('Y-m-d H:i:s'), 'last_activity' => date('Y-m-d H:i:s')))->save();
         // create an import for this export
         PMXE_Wpallimport::create_an_import($export);
         PMXE_Plugin::$session->set('update_previous', $export->id);
         PMXE_Plugin::$session->save_data();
         do_action('pmxe_before_export', $export->id);
     }
     $this->render();
 }