Example #1
0
function woo_st_tab_template($tab = '')
{
    if (!$tab) {
        $tab = 'overview';
    }
    switch ($tab) {
        case 'nuke':
            // Check if a previous nuke failed mid-drop
            $in_progress = woo_st_get_option('in_progress', '');
            if (!empty($in_progress)) {
                $message = sprintf(__('It looks like a previous nuke failed to clear that dataset, this is common in large catalogues and is likely due to WordPress hitting a memory limit or server timeout. Don\'t stress, <a href="%s">retry %s nuke?</a>', 'woo_st'), add_query_arg(array('action' => 'nuke', 'dataset' => $in_progress)), ucfirst($in_progress));
                woo_st_admin_notice_html($message, 'error');
                woo_st_update_option('in_progress', '');
            }
            $products = woo_st_return_count('product');
            $images = woo_st_return_count('product_image');
            $tags = woo_st_return_count('product_tag');
            $categories = woo_st_return_count('product_category');
            if ($categories) {
                $term_taxonomy = 'product_cat';
                $args = array('hide_empty' => 0);
                $categories_data = get_terms($term_taxonomy, $args);
            }
            $orders = woo_st_return_count('order');
            if ($orders) {
                // Check if this is a WooCommerce 2.2+ instance
                $woocommerce_version = woo_get_woo_version();
                $orders_data = false;
                if (version_compare($woocommerce_version, '2.2', '<')) {
                    $term_taxonomy = 'shop_order_status';
                    $args = array('hide_empty' => 0);
                    $orders_data = get_terms($term_taxonomy, $args);
                }
            }
            $tax_rates = woo_st_return_count('tax_rate');
            $download_permissions = woo_st_return_count('download_permission');
            $coupons = woo_st_return_count('coupon');
            $attributes = woo_st_return_count('attribute');
            $brands = woo_st_return_count('product_brand');
            $vendors = woo_st_return_count('product_vendor');
            $credit_cards = woo_st_return_count('credit_card');
            $posts = woo_st_return_count('post');
            $post_categories = woo_st_return_count('post_category');
            $post_tags = woo_st_return_count('post_tag');
            $links = woo_st_return_count('link');
            $comments = woo_st_return_count('comment');
            $media_images = woo_st_return_count('media_image');
            $show_table = false;
            if ($products || $images || $tags || $categories || $orders || $credit_cards || $attributes) {
                $show_table = true;
            }
            break;
    }
    if ($tab) {
        if (file_exists(WOO_ST_PATH . 'templates/admin/tabs-' . $tab . '.php')) {
            include_once WOO_ST_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_st'), 'tabs-' . $tab . '.php', WOO_CD_PATH . 'templates/admin/...');
            woo_st_admin_notice_html($message, 'error');
            ob_start();
            ?>
<p><?php 
            _e('You can see this error for one of a few common reasons', 'woo_st');
            ?>
:</p>
<ul class="ul-disc">
	<li><?php 
            _e('WordPress was unable to create this file when the Plugin was installed or updated', 'woo_st');
            ?>
</li>
	<li><?php 
            _e('The Plugin files have been recently changed and there has been a file conflict', 'woo_st');
            ?>
</li>
	<li><?php 
            _e('The Plugin file has been locked and cannot be opened by WordPress', 'woo_st');
            ?>
</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_st');
            ?>
</p>
<?php 
            ob_end_flush();
        }
    }
}
Example #2
0
 function woo_st_admin_init()
 {
     $action = woo_get_action();
     switch ($action) {
         case 'nuke':
             if (!ini_get('safe_mode')) {
                 set_time_limit(0);
             }
             // List of supported datasets
             $datasets = array('product', 'product_category', 'product_tag', 'product_brand', 'product_vendor', 'product_image', 'coupon', 'attribute', 'order', 'tax_rate', 'download_permission', 'credit_card', 'post', 'post_category', 'post_tag', 'link', 'comment', 'media_image');
             // Check if the re-commence nuke notice has been enabled
             $in_progress = woo_st_get_option('in_progress', '');
             if (isset($_GET['dataset']) && !empty($in_progress)) {
                 $dataset = strtolower(sanitize_text_field($_GET['dataset']));
                 if (in_array($dataset, $datasets)) {
                     woo_st_clear_dataset($dataset);
                 }
                 return;
             }
             // WooCommerce
             if (isset($_POST['woo_st_products'])) {
                 woo_st_clear_dataset('product');
             }
             if (isset($_POST['woo_st_categories'])) {
                 $categories = $_POST['woo_st_categories'];
                 woo_st_clear_dataset('product_category', $categories);
             } else {
                 if (isset($_POST['woo_st_product_categories'])) {
                     woo_st_clear_dataset('product_category');
                 }
             }
             if (isset($_POST['woo_st_product_tags'])) {
                 woo_st_clear_dataset('product_tag');
             }
             if (isset($_POST['woo_st_product_brands'])) {
                 woo_st_clear_dataset('product_brand');
             }
             if (isset($_POST['woo_st_product_vendors'])) {
                 woo_st_clear_dataset('product_vendor');
             }
             if (isset($_POST['woo_st_product_images'])) {
                 woo_st_clear_dataset('product_image');
             }
             if (isset($_POST['woo_st_coupons'])) {
                 woo_st_clear_dataset('coupon');
             }
             if (isset($_POST['woo_st_attributes'])) {
                 woo_st_clear_dataset('attribute');
             }
             if (isset($_POST['woo_st_orders'])) {
                 $orders = $_POST['woo_st_orders'];
                 woo_st_clear_dataset('order', $orders);
             } else {
                 if (isset($_POST['woo_st_sales_orders'])) {
                     woo_st_clear_dataset('order');
                 }
             }
             if (isset($_POST['woo_st_tax_rates'])) {
                 woo_st_clear_dataset('tax_rate');
             }
             if (isset($_POST['woo_st_download_permissions'])) {
                 woo_st_clear_dataset('download_permission');
             }
             // 3rd Party
             if (isset($_POST['woo_st_creditcards'])) {
                 woo_st_clear_dataset('credit_card');
             }
             // WordPress
             if (isset($_POST['woo_st_posts'])) {
                 woo_st_clear_dataset('post');
             }
             if (isset($_POST['woo_st_post_categories'])) {
                 woo_st_clear_dataset('post_category');
             }
             if (isset($_POST['woo_st_post_tags'])) {
                 woo_st_clear_dataset('post_tag');
             }
             if (isset($_POST['woo_st_links'])) {
                 woo_st_clear_dataset('link');
             }
             if (isset($_POST['woo_st_comments'])) {
                 woo_st_clear_dataset('comment');
             }
             if (isset($_POST['woo_st_media_images'])) {
                 woo_st_clear_dataset('media_image');
             }
             break;
         case 'relink-rogue-simple-type':
             woo_st_relink_rogue_simple_type();
             $url = esc_url(add_query_arg('action', null));
             wp_redirect($url);
             exit;
             break;
         default:
             if (current_user_can('manage_options')) {
                 // Category
                 $term_taxonomy = 'product_cat';
                 add_action($term_taxonomy . '_edit_form_fields', 'woo_st_category_data_meta_box', 11);
                 // Tag
                 $term_taxonomy = 'product_tag';
                 add_action($term_taxonomy . '_edit_form_fields', 'woo_st_tag_data_meta_box', 11);
                 // Brand
                 $term_taxonomy = 'product_brand';
                 add_action($term_taxonomy . '_edit_form_fields', 'woo_st_brand_data_meta_box', 11);
                 add_action('show_user_profile', 'woo_st_user_data_meta_box', 11);
                 add_action('edit_user_profile', 'woo_st_user_data_meta_box', 11);
                 add_action('add_meta_boxes', 'add_data_meta_boxes', 10, 2);
             }
             break;
     }
 }