</li>
			<li><?php 
_e('All directories within Uploads (/wp-content/uploads/...) created by WP e-Commerce', 'wpsc_st');
?>
</li>
			<li><?php 
_e('The \'wp-e-commerce\' directory within Plugins (/wp-content/plugins/...)', 'wpsc_st');
?>
</li>
		</ul>
		<p><?php 
_e('Put bluntly, anything related to WP e-Commerce that existed before this point will not survive.', 'wpsc_st');
?>
		<p class="submit">
<?php 
if (function_exists('wpsc_find_purchlog_status_name') && wpsc_get_major_version() == '3.8') {
    ?>
 
			<input type="button" class="button button-disabled" value="<?php 
    _e('Uninstall WP e-Commerce', 'wpsc_st');
    ?>
" />
<?php 
} else {
    ?>
			<input type="submit" value="<?php 
    _e('Uninstall WP e-Commerce', 'wpsc_st');
    ?>
" class="button-primary" />
			<input type="hidden" name="action" value="uninstall" />
<?php 
?>
		</td>
	</tr>

	<tr>
		<th><?php 
_e('Visser Labs', 'wpsc_st');
?>
:</th>
		<td>
			<ul>
<?php 
if (function_exists('wpsc_get_major_version')) {
    ?>
				<li><code>wpsc_get_major_version(): <?php 
    echo wpsc_get_major_version();
    ?>
</code></li>
<?php 
}
if (function_exists('wpsc_get_minor_version')) {
    ?>
				<li><code>wpsc_get_minor_version(): <?php 
    echo wpsc_get_minor_version();
    ?>
</code></li>
<?php 
}
?>
			</ul>
		</td>
Example #3
0
 function wpsc_st_sale_action_reset_downloads()
 {
     global $wpsc_st;
     if (version_compare(wpsc_get_minor_version(), '3.8.8', '>=')) {
         $purchase_id = (int) $_GET['id'];
     } else {
         $purchase_id = (int) $_GET['purchaselog_id'];
     }
     $url = '';
     switch (wpsc_get_major_version()) {
         case '3.8':
             $url = add_query_arg('wpsc_admin_action', 'reset-file-downloads-sale');
             break;
     }
     $output = '<img src="' . plugins_url('templates/admin/images/pencil.png', $wpsc_st['relpath']) . '" alt="pencil icon" />&ensp;<a href="' . $url . '">' . __("Reset File Downloads Counter", "wpsc_st") . '</a><br /><br class="small" />';
     echo $output;
 }
Example #4
0
 function wpsc_st_admin_init()
 {
     global $wpdb, $wpsc_st;
     $action = wpsc_get_action();
     if (!$action && isset($_POST['wpsc_admin_action'])) {
         $action = $_POST['wpsc_admin_action'];
     }
     if (!$action && isset($_GET['wpsc_admin_action'])) {
         $action = $_GET['wpsc_admin_action'];
     }
     switch ($action) {
         case 'tools':
             if (isset($_POST['maximum_cart_quantity'])) {
                 $maximum_cart_quantity = $_POST['maximum_cart_quantity'];
                 wpsc_st_update_option('maximum_cart_quantity', $maximum_cart_quantity);
                 $message = __('Settings saved.', 'wpsc_st');
                 wpsc_st_admin_notice($message);
             }
             break;
         case 'relink-pages':
             $product_page = wpsc_st_get_page_by_shortcode('[productspage]');
             $checkout = wpsc_st_get_page_by_shortcode('[shoppingcart]');
             $transaction_results = wpsc_st_get_page_by_shortcode('[transactionresults]');
             $my_account = wpsc_st_get_page_by_shortcode('[userlog]');
             if ($product_page) {
                 update_option('product_list_url', get_bloginfo('url') . "/?page_id=" . $product_page);
             }
             if ($checkout) {
                 update_option('shopping_cart_url', get_bloginfo('url') . "/?page_id=" . $checkout);
             }
             if ($checkout) {
                 update_option('checkout_url', get_bloginfo('url') . "/?page_id=" . $checkout);
             }
             if ($transaction_results) {
                 update_option('transact_url', get_bloginfo('url') . "/?page_id=" . $transaction_results);
             }
             if ($my_account) {
                 update_option('user_account_url', get_bloginfo('url') . "/?page_id=" . $my_account);
             }
             $message = __('Default WP e-Commerce Pages have been restored.', 'wpsc_st');
             wpsc_st_admin_notice($message);
             break;
         case 'relink-existing-preregistered-sales':
             $sales = wpsc_st_get_unlinked_sales();
             $size = count($sales);
             if ($sales) {
                 $adjusted_sales = 0;
                 foreach ($sales as $sale) {
                     $sale_email = wpsc_st_get_email_from_sale($sale->ID);
                     if ($sale_email) {
                         $sale_user = get_user_by('email', $sale_email);
                         if ($sale_user) {
                             $wpdb->update($wpdb->prefix . 'wpsc_purchase_logs', array('user_ID' => $sale_user->ID), array('id' => $sale->ID));
                         }
                         $adjusted_sales++;
                     }
                 }
             }
             $notice_status = '';
             if ($adjusted_sales > 0) {
                 $message = sprintf(__('%s of %s unlinked Sale\'s from pre-registered Users have been re-linked.', 'wpsc_st'), '<strong>' . $adjusted_sales . '</strong>', '<strong>' . $size . '</strong>');
             } else {
                 $message = __('No existing Sales from pre-registered Users have been re-linked.', 'wpsc_st');
                 $notice_status = 'error';
             }
             wpsc_st_admin_notice($message, $notice_status);
             break;
         case 'reset-file-downloads-sale':
             if (version_compare(wpsc_get_minor_version(), '3.8.8', '>=')) {
                 $purchase_id = (int) $_GET['id'];
             } else {
                 $purchase_id = (int) $_GET['purchaselog_id'];
             }
             $file_downloads_sql = $wpdb->prepare("SELECT `id`, `downloads` FROM `" . $wpdb->prefix . "wpsc_download_status` WHERE `purchid` = %d", $purchase_id);
             $file_downloads = $wpdb->get_results($file_downloads_sql);
             $notice_status = '';
             if ($file_downloads) {
                 $max_downloads = get_option('wpsc_max_downloads');
                 if ($max_downloads) {
                     foreach ($file_downloads as $file_download) {
                         if ($file_download->downloads < $max_downloads) {
                             $wpdb->update($wpdb->prefix . 'wpsc_download_status', array('downloads' => $max_downloads), array('id' => $file_download->id));
                         }
                     }
                     $message = __('File Downloads have been reset for this Sale.', 'wpsc_st');
                 } else {
                     $message = __('Max downloads per file has not been set - or is set to 0 - within Settings > Store > Admin screen.', 'wpsc_st');
                     $notice_status = 'error';
                 }
             } else {
                 $message = __('No File Downloads are assigned to this Sale.', 'wpsc_st');
                 $notice_status = 'error';
             }
             wpsc_st_admin_notice($message, $notice_status);
             break;
         case 'demo':
             $options = false;
             if (isset($_POST['options'])) {
                 $options = $_POST['options'];
                 if (isset($options['demo_store'])) {
                     $options['demo_store'] = 1;
                 } else {
                     $options['demo_store'] = 0;
                 }
                 if ($options) {
                     foreach ($options as $key => $option) {
                         wpsc_st_update_option($key, $option);
                     }
                 }
             }
             $message = __('Settings saved.', 'wpsc_st');
             wpsc_st_admin_notice($message);
             break;
         case 'nuke':
             if (!ini_get('safe_mode')) {
                 set_time_limit(0);
             }
             // WP e-Commerce
             if (isset($_POST['wpsc_st_products'])) {
                 wpsc_st_clear_dataset('products');
             }
             if (isset($_POST['wpsc_st_product_variations'])) {
                 wpsc_st_clear_dataset('variations');
             }
             if (isset($_POST['wpsc_st_product_tags'])) {
                 wpsc_st_clear_dataset('tags');
             }
             if (isset($_POST['wpsc_st_categories'])) {
                 $categories = $_POST['wpsc_st_categories'];
                 wpsc_st_clear_dataset('categories', $categories);
             } else {
                 if (isset($_POST['wpsc_st_product_categories'])) {
                     wpsc_st_clear_dataset('categories');
                 }
             }
             if (isset($_POST['wpsc_st_product_images'])) {
                 wpsc_st_clear_dataset('images');
             }
             if (isset($_POST['wpsc_st_product_files'])) {
                 wpsc_st_clear_dataset('files');
             }
             if (isset($_POST['wpsc_st_sales_orders'])) {
                 wpsc_st_clear_dataset('orders');
             }
             if (isset($_POST['wpsc_st_coupons'])) {
                 wpsc_st_clear_dataset('coupons');
             }
             // 3rd Party
             if (isset($_POST['wpsc_st_wishlist'])) {
                 wpsc_st_clear_dataset('wishlist');
             }
             if (isset($_POST['wpsc_st_enquiries'])) {
                 wpsc_st_clear_dataset('enquiries');
             }
             if (isset($_POST['wpsc_st_creditcards'])) {
                 wpsc_st_clear_dataset('credit-cards');
             }
             if (isset($_POST['wpsc_st_customfields'])) {
                 wpsc_st_clear_dataset('custom-fields');
             }
             if (isset($_POST['wpsc_st_previewfiles'])) {
                 wpsc_st_clear_dataset('preview-files');
             }
             // WordPress
             if (isset($_POST['wpsc_st_posts'])) {
                 wpsc_st_clear_dataset('posts');
             }
             if (isset($_POST['wpsc_st_post_categories'])) {
                 wpsc_st_clear_dataset('post_categories');
             }
             if (isset($_POST['wpsc_st_post_tags'])) {
                 wpsc_st_clear_dataset('post_tags');
             }
             if (isset($_POST['wpsc_st_links'])) {
                 wpsc_st_clear_dataset('links');
             }
             if (isset($_POST['wpsc_st_comments'])) {
                 wpsc_st_clear_dataset('comments');
             }
             $message = __('Chosen WP e-Commerce details have been permanently erased from your store.', 'wpsc_st');
             wpsc_st_admin_notice($message);
             break;
         case 'uninstall':
             global $uninstall;
             $uninstall = new stdClass();
             $uninstall->log = '';
             $uninstall->log .= "<br />" . __('Removing WP e-Commerce tables...', 'wpsc_st');
             $wpsc_tables = array();
             $wpsc_tables[] = array('label' => __('Also Bought', 'wpsc_st'), 'table' => 'wpsc_also_bought');
             $wpsc_tables[] = array('label' => __('Cart Contents', 'wpsc_st'), 'table' => 'wpsc_cart_contents');
             $wpsc_tables[] = array('label' => __('Checkout Forms', 'wpsc_st'), 'table' => 'wpsc_checkout_forms');
             $wpsc_tables[] = array('label' => __('Claimed Stock', 'wpsc_st'), 'table' => 'wpsc_claimed_stock');
             $wpsc_tables[] = array('label' => __('Coupons', 'wpsc_st'), 'table' => 'wpsc_coupon_codes');
             $wpsc_tables[] = array('label' => __('Currency List', 'wpsc_st'), 'table' => 'wpsc_currency_list');
             $wpsc_tables[] = array('label' => __('Download Status', 'wpsc_st'), 'table' => 'wpsc_download_status');
             $wpsc_tables[] = array('label' => __('Meta', 'wpsc_st'), 'table' => 'wpsc_meta');
             $wpsc_tables[] = array('label' => __('Product Rating', 'wpsc_st'), 'table' => 'wpsc_product_rating');
             $wpsc_tables[] = array('label' => __('Purchase Logs', 'wpsc_st'), 'table' => 'wpsc_purchase_logs');
             $wpsc_tables[] = array('label' => __('Tax Regions', 'wpsc_st'), 'table' => 'wpsc_region_tax');
             $wpsc_tables[] = array('label' => __('Submited Form Data', 'wpsc_st'), 'table' => 'wpsc_submited_form_data');
             $size = count($wpsc_tables);
             for ($i = 0; $i < $size; $i++) {
                 // Check that the WP e-Commerce table exists
                 if (wpsc_st_check_table_exists($wpsc_tables[$i]['table'])) {
                     // $wpdb->query( "DROP TABLE `" . $wpdb->prefix . $wpsc_tables[$i]['table'] . "`" );
                     $uninstall->log .= "<br />>>> " . sprintf(__('Removed %s (%s)', 'wpsc_st'), $wpsc_tables[$i]['label'], $wpdb->prefix . $wpsc_tables[$i]['table']);
                 }
             }
             $uninstall->log .= "<br /><br />" . __('Removing WP e-Commerce details...', 'wpsc_st');
             $wpsc_dataset = array();
             $wpsc_dataset[] = array('label' => __('Products', 'wpsc_st'), 'dataset' => 'products');
             $wpsc_dataset[] = array('label' => __('Product Variations', 'wpsc_st'), 'dataset' => 'variations');
             $wpsc_dataset[] = array('label' => __('Product Tags', 'wpsc_st'), 'dataset' => 'tags');
             $wpsc_dataset[] = array('label' => __('Product Categories', 'wpsc_st'), 'dataset' => 'categories');
             $wpsc_dataset[] = array('label' => __('Product Images', 'wpsc_st'), 'dataset' => 'images');
             $wpsc_dataset[] = array('label' => __('Product Files', 'wpsc_st'), 'dataset' => 'files');
             $wpsc_dataset[] = array('label' => __('Sales', 'wpsc_st'), 'dataset' => 'orders');
             $wpsc_dataset[] = array('label' => __('Coupons', 'wpsc_st'), 'dataset' => 'coupons');
             $wpsc_dataset[] = array('label' => __('Add to Wishlist', 'wpsc_st'), 'dataset' => 'wishlist');
             $wpsc_dataset[] = array('label' => __('Enquiries', 'wpsc_st'), 'dataset' => 'enquiries');
             $wpsc_dataset[] = array('label' => __('Offline Payments', 'wpsc_st'), 'dataset' => 'credit-cards');
             $wpsc_dataset[] = array('label' => __('Custom Fields', 'wpsc_st'), 'dataset' => 'custom-fields');
             $wpsc_dataset[] = array('label' => __('Preview Files', 'wpsc_st'), 'dataset' => 'preview-files');
             $wpsc_dataset[] = array('label' => __('Plugin Pages', 'wpsc_st'), 'dataset' => 'wpsc_pages');
             $wpsc_dataset[] = array('label' => __('Plugin Options', 'wpsc_st'), 'dataset' => 'wpsc_options');
             $size = count($wpsc_dataset);
             for ($i = 0; $i < $size; $i++) {
                 if ($wpsc_dataset[$i]['dataset']) {
                     // wpsc_st_clear_dataset( $wpsc_dataset[$i] );
                     $uninstall->log .= "<br />>>> " . sprintf(__('Removed %s', 'wpsc_st'), $wpsc_dataset[$i]['label']);
                 }
             }
             break;
         case 'wpsc_update_session_id':
             global $wpdb;
             $session_id = $_POST['session_id'];
             $purchase_id = $_POST['purchase_id'];
             if (isset($session_id) && $purchase_id) {
                 $wpdb->update($wpdb->prefix . 'wpsc_purchase_logs', array('sessionid' => $session_id), array('id' => $purchase_id));
             }
             break;
         case 'update':
             $options = false;
             if (isset($_POST['options'])) {
                 $options = $_POST['options'];
             }
             if ($options) {
                 foreach ($options as $key => $option) {
                     wpsc_st_update_option($key, $option);
                 }
             }
             $message = __('Settings saved.', 'wpsc_st');
             wpsc_st_admin_notice($message);
             break;
         case 'uninstall':
             $message = __('Uninstall complete.', 'wpsc_st');
             wpsc_st_admin_notice($message);
             break;
         case 'clear-claimed_stock':
             global $wpdb;
             $wpdb->query("TRUNCATE TABLE `" . $wpdb->prefix . "wpsc_claimed_stock`");
             $message = __('The \'claimed stock\' table has been emptied.', 'wpsc_st');
             wpsc_st_admin_notice($message);
             break;
         case 'fix-wpsc_version':
             $notice_status = '';
             if (wpsc_get_major_version() == '3.8' && WPSC_VERSION == '3.7') {
                 update_option('wpsc_version', '3.7');
                 $message = __('WordPress option \'wpsc_version\' has been repaired.', 'wpsc_st');
             } else {
                 $notice_status = 'error';
                 $message = __('WordPress option \'wpsc_version\' did not require attention.', 'wpsc_st');
             }
             wpsc_st_admin_notice($message, $notice_status);
             break;
     }
 }