Esempio n. 1
0
 function woo_ce_admin_notice($message = '', $priority = 'updated', $screen = '')
 {
     if (empty($priority)) {
         $priority = 'updated';
     }
     if (!empty($message)) {
         add_action('admin_notices', woo_ce_admin_notice_html($message, $priority, $screen));
     }
 }
Esempio n. 2
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();
        }
    }
}
Esempio n. 3
0
 function woo_ce_fail_notices()
 {
     $troubleshooting_url = 'http://www.visser.com.au/documentation/store-exporter/usage/';
     // If the failed flag is set then prepare for an error notice
     if (isset($_GET['failed'])) {
         $message = '';
         if (isset($_GET['message'])) {
             $message = urldecode($_GET['message']);
         }
         if ($message) {
             $message = sprintf(__('A WordPress or server error caused the exporter to fail, the exporter was provided with a reason: <em>%s</em>', 'woo_ce'), $message) . ' (<a href="' . $troubleshooting_url . '" target="_blank">' . __('Need help?', 'woo_ce') . '</a>)';
         } else {
             $message = __('A WordPress or server error caused the exporter to fail, no reason was provided, please get in touch so we can reproduce and resolve this.', 'woo_ce') . ' (<a href="' . $troubleshooting_url . '" target="_blank">' . __('Need help?', 'woo_ce') . '</a>)';
         }
         woo_ce_admin_notice_html($message, 'error');
     }
     // Displays a HTML notice where the memory allocated to WordPress falls below 64MB
     if (!woo_ce_get_option('dismiss_execution_time_prompt', 0)) {
         $max_execution_time = absint(ini_get('max_execution_time'));
         $response = ini_set('max_execution_time', 120);
         if ($response == false || $response != $max_execution_time) {
             $dismiss_url = add_query_arg('action', 'dismiss_execution_time_prompt');
             $message = sprintf(__('We could not override the PHP configuration option <code>max_execution_time</code>, this will limit the size of possible exports. See: <a href="%s" target="_blank">Increasing PHP max_execution_time configuration option</a>', 'woo_ce'), $troubleshooting_url) . '<span style="float:right;"><a href="' . $dismiss_url . '">' . __('Dismiss', 'woo_ce') . '</a></span>';
             woo_ce_admin_notice_html($message, 'error');
         }
         ini_set('max_execution_time', $max_execution_time);
     }
     // Displays a HTML notice where the memory allocated to WordPress falls below 64MB
     if (!woo_ce_get_option('dismiss_memory_prompt', 0)) {
         $memory_limit = absint(ini_get('memory_limit'));
         $minimum_memory_limit = 64;
         if ($memory_limit < $minimum_memory_limit) {
             $dismiss_url = add_query_arg('action', 'dismiss_memory_prompt');
             $message = sprintf(__('We recommend setting memory to at least %dMB, your site has only %dMB allocated to it. See: <a href="%s" target="_blank">Increasing memory allocated to PHP</a>', 'woo_ce'), $minimum_memory_limit, $memory_limit, $troubleshooting_url) . '<span style="float:right;"><a href="' . $dismiss_url . '">' . __('Dismiss', 'woo_ce') . '</a></span>';
             woo_ce_admin_notice_html($message, 'error');
         }
     }
     // Displays a HTML notice if PHP 5.2 is installed
     if (version_compare(phpversion(), '5.3', '<') && !woo_ce_get_option('dismiss_php_legacy', 0)) {
         $dismiss_url = add_query_arg('action', 'dismiss_php_legacy');
         $message = sprintf(__('Your PHP version (%s) is not supported and is very much out of date, since 2010 all users are strongly encouraged to upgrade to PHP 5.3+ and above. Contact your hosting provider to make this happen. See: <a href="%s" target="_blank">Migrating from PHP 5.2 to 5.3</a>', 'woo_ce'), phpversion(), $troubleshooting_url) . '<span style="float:right;"><a href="' . $dismiss_url . '">' . __('Dismiss', 'woo_ce') . '</a></span>';
         woo_ce_admin_notice_html($message, 'error');
     }
     // Displays HTML notice if there are more than 2500 Subscriptions
     if (!woo_ce_get_option('dismiss_subscription_prompt', 0)) {
         if (class_exists('WC_Subscriptions')) {
             if (method_exists('WC_Subscriptions', 'is_large_site')) {
                 // Does this store have roughly more than 3000 Subscriptions
                 if (WC_Subscriptions::is_large_site()) {
                     $dismiss_url = add_query_arg('action', 'dismiss_subscription_prompt');
                     $message = __('We\'ve detected the <em>is_large_site</em> flag has been set within WooCommerce Subscriptions. Please get in touch if exports are incomplete as we need to spin up an alternative export process to export Subscriptions from large stores.', 'woo_ce') . ' (<a href="' . $troubleshooting_url . '" target="_blank">' . __('Need help?', 'woo_ce') . '</a>)' . '<span style="float:right;"><a href="' . $dismiss_url . '">' . __('Dismiss', 'woo_ce') . '</a></span>';
                     woo_ce_admin_notice_html($message, 'error');
                 }
             }
         }
     }
     // If the export failed the WordPress Transient will still exist
     if (get_transient(WOO_CE_PREFIX . '_running')) {
         $message = __('A WordPress or server error caused the exporter to fail with a blank screen, this is either a memory or timeout issue, please get in touch so we can reproduce and resolve this.', 'woo_ce') . ' (<a href="' . $troubleshooting_url . '" target="_blank">' . __('Need help?', 'woo_ce') . '</a>)';
         woo_ce_admin_notice_html($message, 'error');
         delete_transient(WOO_CE_PREFIX . '_running');
     }
 }
Esempio n. 4
0
    function woo_ce_html_page()
    {
        global $wpdb, $export;
        $title = apply_filters('woo_ce_template_header', __('Store Exporter', 'woocommerce-exporter'));
        woo_ce_template_header($title);
        woo_ce_support_donate();
        $action = woo_get_action();
        switch ($action) {
            case 'export':
                if (WOO_CE_DEBUG) {
                    if (false === ($export_log = get_transient(WOO_CE_PREFIX . '_debug_log'))) {
                        $export_log = __('No export entries were found, please try again with different export filters.', 'woocommerce-exporter');
                    } else {
                        $export_log = base64_decode($export_log);
                    }
                    delete_transient(WOO_CE_PREFIX . '_debug_log');
                    $output = '
<h3>' . sprintf(__('Export Details: %s', 'woocommerce-exporter'), esc_attr($export->filename)) . '</h3>
<p>' . __('This prints the $export global that contains the different export options and filters to help reproduce this on another instance of WordPress. Very useful for debugging blank or unexpected exports.', 'woocommerce-exporter') . '</p>
<textarea id="export_log">' . esc_textarea(print_r($export, true)) . '</textarea>
<hr />';
                    if (in_array($export->export_format, array('csv'))) {
                        $output .= '
<script>
	$j(function() {
		$j(\'#export_sheet\').CSVToTable(\'\', { startLine: 0 });
	});
</script>
<h3>' . __('Export', 'woocommerce-exporter') . '</h3>
<p>' . __('We use the <a href="http://code.google.com/p/jquerycsvtotable/" target="_blank"><em>CSV to Table plugin</em></a> to see first hand formatting errors or unexpected values within the export file.', 'woocommerce-exporter') . '</p>
<div id="export_sheet">' . esc_textarea($export_log) . '</div>
<p class="description">' . __('This jQuery plugin can fail with <code>\'Item count (#) does not match header count\'</code> notices which simply mean the number of headers detected does not match the number of cell contents.', 'woocommerce-exporter') . '</p>
<hr />';
                    }
                    $output .= '
<h3>' . __('Export Log', 'woocommerce-exporter') . '</h3>
<p>' . __('This prints the raw export contents and is helpful when the jQuery plugin above fails due to major formatting errors.', 'woocommerce-exporter') . '</p>
<textarea id="export_log" wrap="off">' . esc_textarea($export_log) . '</textarea>
<hr />
';
                    echo $output;
                }
                woo_ce_manage_form();
                break;
            case 'update':
                // Save Custom Product Meta
                if (isset($_POST['custom_products'])) {
                    $custom_products = $_POST['custom_products'];
                    $custom_products = explode("\n", trim($custom_products));
                    $size = count($custom_products);
                    if ($size) {
                        for ($i = 0; $i < $size; $i++) {
                            $custom_products[$i] = sanitize_text_field(trim($custom_products[$i]));
                        }
                        woo_ce_update_option('custom_products', $custom_products);
                    }
                }
                $message = __('Custom Fields saved.', 'woocommerce-exporter');
                woo_ce_admin_notice_html($message);
                woo_ce_manage_form();
                break;
            default:
                woo_ce_manage_form();
                break;
        }
        woo_ce_template_footer();
    }