Example #1
0
function woo_ce_tab_template($tab = '')
{
    if (!$tab) {
        $tab = 'overview';
    }
    // Store Exporter Deluxe
    $woo_cd_url = 'http://www.visser.com.au/woocommerce/plugins/exporter-deluxe/';
    $woo_cd_link = sprintf('<a href="%s" target="_blank">' . __('Store Exporter Deluxe', 'woo_ce') . '</a>', $woo_cd_url);
    $troubleshooting_url = 'http://www.visser.com.au/documentation/store-exporter-deluxe/';
    switch ($tab) {
        case 'overview':
            $skip_overview = woo_ce_get_option('skip_overview', false);
            break;
        case 'export':
            $export_type = sanitize_text_field(isset($_POST['dataset']) ? $_POST['dataset'] : woo_ce_get_option('last_export', 'product'));
            $types = array_keys(woo_ce_return_export_types());
            // Check if the default export type exists
            if (!in_array($export_type, $types)) {
                $export_type = 'product';
            }
            $products = woo_ce_return_count('product');
            $categories = woo_ce_return_count('category');
            $tags = woo_ce_return_count('tag');
            $brands = '999';
            $orders = '999';
            $customers = '999';
            $users = woo_ce_return_count('user');
            $coupons = '999';
            $attributes = '999';
            $subscriptions = '999';
            $product_vendors = '999';
            $commissions = '999';
            $shipping_classes = '999';
            add_action('woo_ce_export_options', 'woo_ce_export_options_export_format');
            if ($product_fields = woo_ce_get_product_fields()) {
                foreach ($product_fields as $key => $product_field) {
                    $product_fields[$key]['disabled'] = isset($product_field['disabled']) ? $product_field['disabled'] : 0;
                }
                add_action('woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_category');
                add_action('woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_tag');
                add_action('woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_brand');
                add_action('woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_vendor');
                add_action('woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_status');
                add_action('woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_product_type');
                add_action('woo_ce_export_product_options_before_table', 'woo_ce_products_filter_by_stock_status');
                add_action('woo_ce_export_product_options_after_table', 'woo_ce_product_sorting');
                add_action('woo_ce_export_options', 'woo_ce_products_upsells_formatting');
                add_action('woo_ce_export_options', 'woo_ce_products_crosssells_formatting');
                add_action('woo_ce_export_options', 'woo_ce_export_options_gallery_format');
                add_action('woo_ce_export_after_form', 'woo_ce_products_custom_fields');
            }
            if ($category_fields = woo_ce_get_category_fields()) {
                foreach ($category_fields as $key => $category_field) {
                    $category_fields[$key]['disabled'] = isset($category_field['disabled']) ? $category_field['disabled'] : 0;
                }
                add_action('woo_ce_export_category_options_after_table', 'woo_ce_category_sorting');
            }
            if ($tag_fields = woo_ce_get_tag_fields()) {
                foreach ($tag_fields as $key => $tag_field) {
                    $tag_fields[$key]['disabled'] = isset($tag_field['disabled']) ? $tag_field['disabled'] : 0;
                }
                add_action('woo_ce_export_tag_options_after_table', 'woo_ce_tag_sorting');
            }
            if ($brand_fields = woo_ce_get_brand_fields()) {
                foreach ($brand_fields as $key => $brand_field) {
                    $brand_fields[$key]['disabled'] = isset($brand_field['disabled']) ? $brand_field['disabled'] : 0;
                }
                add_action('woo_ce_export_brand_options_before_table', 'woo_ce_brand_sorting');
            }
            if ($order_fields = woo_ce_get_order_fields()) {
                add_action('woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_date');
                add_action('woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_status');
                add_action('woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_customer');
                add_action('woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_billing_country');
                add_action('woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_shipping_country');
                add_action('woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_user_role');
                add_action('woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_coupon');
                add_action('woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product');
                add_action('woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product_category');
                add_action('woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product_tag');
                add_action('woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_product_brand');
                add_action('woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_order_id');
                add_action('woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_payment_gateway');
                add_action('woo_ce_export_order_options_before_table', 'woo_ce_orders_filter_by_shipping_method');
                add_action('woo_ce_export_order_options_after_table', 'woo_ce_order_sorting');
                add_action('woo_ce_export_options', 'woo_ce_orders_items_formatting');
                add_action('woo_ce_export_options', 'woo_ce_orders_max_order_items');
                add_action('woo_ce_export_options', 'woo_ce_orders_items_types');
                add_action('woo_ce_export_after_form', 'woo_ce_orders_custom_fields');
            }
            if ($customer_fields = woo_ce_get_customer_fields()) {
                add_action('woo_ce_export_customer_options_before_table', 'woo_ce_customers_filter_by_status');
                add_action('woo_ce_export_customer_options_before_table', 'woo_ce_customers_filter_by_user_role');
                add_action('woo_ce_export_after_form', 'woo_ce_customers_custom_fields');
            }
            if ($user_fields = woo_ce_get_user_fields()) {
                foreach ($user_fields as $key => $user_field) {
                    $user_fields[$key]['disabled'] = isset($user_field['disabled']) ? $user_field['disabled'] : 0;
                }
                add_action('woo_ce_export_user_options_after_table', 'woo_ce_user_sorting');
                add_action('woo_ce_export_after_form', 'woo_ce_users_custom_fields');
            }
            if ($coupon_fields = woo_ce_get_coupon_fields()) {
                add_action('woo_ce_export_coupon_options_before_table', 'woo_ce_coupon_sorting');
            }
            if ($subscription_fields = woo_ce_get_subscription_fields()) {
                add_action('woo_ce_export_subscription_options_before_table', 'woo_ce_subscriptions_filter_by_subscription_status');
                add_action('woo_ce_export_subscription_options_before_table', 'woo_ce_subscriptions_filter_by_subscription_product');
            }
            $product_vendor_fields = woo_ce_get_product_vendor_fields();
            if ($commission_fields = woo_ce_get_commission_fields()) {
                add_action('woo_ce_export_commission_options_before_table', 'woo_ce_commissions_filter_by_date');
                add_action('woo_ce_export_commission_options_before_table', 'woo_ce_commissions_filter_by_product_vendor');
                add_action('woo_ce_export_commission_options_before_table', 'woo_ce_commissions_filter_by_commission_status');
                add_action('woo_ce_export_commission_options_before_table', 'woo_ce_commission_sorting');
            }
            if ($shipping_class_fields = woo_ce_get_shipping_class_fields()) {
                add_action('woo_ce_export_shipping_class_options_after_table', 'woo_ce_shipping_class_sorting');
            }
            $attribute_fields = false;
            // Export modules
            $modules = woo_ce_modules_list();
            // Export options
            $limit_volume = woo_ce_get_option('limit_volume');
            $offset = woo_ce_get_option('offset');
            break;
        case 'fields':
            $export_type = isset($_GET['type']) ? sanitize_text_field($_GET['type']) : '';
            $types = array_keys(woo_ce_return_export_types());
            $fields = array();
            if (in_array($export_type, $types)) {
                if (has_filter('woo_ce_' . $export_type . '_fields', 'woo_ce_override_' . $export_type . '_field_labels')) {
                    remove_filter('woo_ce_' . $export_type . '_fields', 'woo_ce_override_' . $export_type . '_field_labels', 11);
                }
                if (function_exists(sprintf('woo_ce_get_%s_fields', $export_type))) {
                    $fields = call_user_func('woo_ce_get_' . $export_type . '_fields');
                }
                $labels = woo_ce_get_option($export_type . '_labels', array());
            }
            break;
        case 'archive':
            if (isset($_GET['deleted'])) {
                $message = __('Archived export has been deleted.', 'woo_ce');
                woo_ce_admin_notice($message);
            }
            if ($files = woo_ce_get_archive_files()) {
                foreach ($files as $key => $file) {
                    $files[$key] = woo_ce_get_archive_file($file);
                }
            }
            break;
        case 'settings':
            $export_filename = woo_ce_get_option('export_filename', '');
            // Default export filename
            if (empty($export_filename)) {
                $export_filename = 'woo-export_%dataset%-%date%.csv';
            }
            $delete_file = woo_ce_get_option('delete_file', 0);
            $timeout = woo_ce_get_option('timeout', 0);
            $encoding = woo_ce_get_option('encoding', 'UTF-8');
            $bom = woo_ce_get_option('bom', 1);
            $delimiter = woo_ce_get_option('delimiter', ',');
            $category_separator = woo_ce_get_option('category_separator', '|');
            $escape_formatting = woo_ce_get_option('escape_formatting', 'all');
            $date_format = woo_ce_get_option('date_format', 'd/m/Y');
            if ($date_format == 1 || $date_format == '') {
                $date_format = 'd/m/Y';
            }
            $file_encodings = function_exists('mb_list_encodings') ? mb_list_encodings() : false;
            add_action('woo_ce_export_settings_top', 'woo_ce_export_settings_quicklinks');
            add_action('woo_ce_export_settings_after', 'woo_ce_export_settings_csv');
            add_action('woo_ce_export_settings_after', 'woo_ce_export_settings_cron');
            break;
        case 'tools':
            // Product Importer Deluxe
            $woo_pd_url = 'http://www.visser.com.au/woocommerce/plugins/product-importer-deluxe/';
            $woo_pd_target = ' target="_blank"';
            if (function_exists('woo_pd_init')) {
                $woo_pd_url = add_query_arg(array('page' => 'woo_pd', 'tab' => null));
                $woo_pd_target = false;
            }
            // Store Toolkit
            $woo_st_url = 'http://www.visser.com.au/woocommerce/plugins/store-toolkit/';
            $woo_st_target = ' target="_blank"';
            if (function_exists('woo_st_admin_init')) {
                $woo_st_url = add_query_arg(array('page' => 'woo_st', 'tab' => null));
                $woo_st_target = false;
            }
            break;
    }
    if ($tab) {
        if (file_exists(WOO_CE_PATH . 'templates/admin/tabs-' . $tab . '.php')) {
            include_once WOO_CE_PATH . 'templates/admin/tabs-' . $tab . '.php';
        } else {
            $message = sprintf(__('We couldn\'t load the export template file <code>%s</code> within <code>%s</code>, this file should be present.', 'woo_ce'), 'tabs-' . $tab . '.php', WOO_CE_PATH . 'templates/admin/...');
            woo_ce_admin_notice_html($message, 'error');
            ob_start();
            ?>
<p><?php 
            _e('You can see this error for one of a few common reasons', 'woo_ce');
            ?>
:</p>
<ul class="ul-disc">
	<li><?php 
            _e('WordPress was unable to create this file when the Plugin was installed or updated', 'woo_ce');
            ?>
</li>
	<li><?php 
            _e('The Plugin files have been recently changed and there has been a file conflict', 'woo_ce');
            ?>
</li>
	<li><?php 
            _e('The Plugin file has been locked and cannot be opened by WordPress', 'woo_ce');
            ?>
</li>
</ul>
<p><?php 
            _e('Jump onto our website and download a fresh copy of this Plugin as it might be enough to fix this issue. If this persists get in touch with us.', 'woo_ce');
            ?>
</p>
<?php 
            ob_end_flush();
        }
    }
}
Example #2
0
 function woo_ce_tab_template($tab = '')
 {
     global $woo_ce;
     if (!$tab) {
         $tab = 'overview';
     }
     /* Store Exporter Deluxe */
     $woo_cd_exists = false;
     if (!function_exists('woo_cd_admin_init')) {
         $woo_cd_url = 'http://www.visser.com.au/woocommerce/plugins/exporter-deluxe/';
         $woo_cd_link = sprintf('<a href="%s" target="_blank">' . __('Store Exporter Deluxe', 'woo_ce') . '</a>', $woo_cd_url);
     } else {
         $woo_cd_exists = true;
     }
     $troubleshooting_url = 'http://www.visser.com.au/documentation/store-exporter-deluxe/';
     switch ($tab) {
         case 'export':
             $dataset = 'products';
             if (isset($_POST['dataset'])) {
                 $dataset = $_POST['dataset'];
             }
             $products = woo_ce_return_count('products');
             $categories = woo_ce_return_count('categories');
             $tags = woo_ce_return_count('tags');
             $orders = woo_ce_return_count('orders');
             $coupons = woo_ce_return_count('coupons');
             $customers = woo_ce_return_count('customers');
             $product_fields = woo_ce_get_product_fields();
             if ($product_fields) {
                 foreach ($product_fields as $key => $product_field) {
                     if (!isset($product_fields[$key]['disabled'])) {
                         $product_fields[$key]['disabled'] = 0;
                     }
                 }
                 $product_categories = woo_ce_get_product_categories();
                 $product_tags = woo_ce_get_product_tags();
                 $product_statuses = get_post_statuses();
                 $product_statuses['trash'] = __('Trash', 'woo_ce');
                 $product_types = woo_ce_get_product_types();
             }
             $order_fields = woo_ce_get_order_fields();
             $customer_fields = woo_ce_get_customer_fields();
             $coupon_fields = woo_ce_get_coupon_fields();
             $delimiter = woo_ce_get_option('delimiter', ',');
             $category_separator = woo_ce_get_option('category_separator', '|');
             $bom = woo_ce_get_option('bom', 1);
             $escape_formatting = woo_ce_get_option('escape_formatting', 'all');
             $limit_volume = woo_ce_get_option('limit_volume');
             $offset = woo_ce_get_option('offset');
             $timeout = woo_ce_get_option('timeout', 0);
             $delete_csv = woo_ce_get_option('delete_csv', 0);
             $file_encodings = mb_list_encodings();
             break;
         case 'tools':
             /* Product Importer Deluxe */
             if (function_exists('woo_pd_init')) {
                 $woo_pd_url = add_query_arg('page', 'woo_pd');
                 $woo_pd_target = false;
             } else {
                 $woo_pd_url = 'http://www.visser.com.au/woocommerce/plugins/product-importer-deluxe/';
                 $woo_pd_target = ' target="_blank"';
             }
             break;
         case 'archive':
             $files = woo_ce_get_archive_files();
             if ($files) {
                 foreach ($files as $key => $file) {
                     $files[$key] = woo_ce_get_archive_file($file);
                 }
             }
             break;
     }
     if ($tab) {
         include_once $woo_ce['abspath'] . '/templates/admin/woo-admin_ce-export_' . $tab . '.php';
     }
 }