Example #1
0
function wpsc_display_update_page()
{
    ?>

	<div class="wrap">
		<h2><?php 
    echo esc_html(__('Update WP e-Commerce', 'wpsc'));
    ?>
 </h2>
		<br />

	<?php 
    if (isset($_POST['run_updates'])) {
        echo __('Updating Categories...', 'wpsc');
        wpsc_convert_category_groups();
        echo '<br />' . __('Updating Variations...', 'wpsc');
        wpsc_convert_variation_sets();
        echo '<br />' . __('Updating Products...', 'wpsc');
        wpsc_convert_products_to_posts();
        echo '<br />' . __('Updating Child Products...', 'wpsc');
        wpsc_convert_variation_combinations();
        echo '<br />' . __('Updating Product Files...', 'wpsc');
        wpsc_update_files();
        echo '<br />' . __('Updating Database...', 'wpsc');
        wpsc_create_or_update_tables();
        wpsc_update_database();
        echo '<br /><br /><strong>' . __('WP e-Commerce updated successfully!', 'wpsc') . '</strong><br />';
        if ('' != get_option('permalink_structure')) {
            ?>
				<em><?php 
            printf(__('Note: It looks like you have custom permalinks, you will need to refresh your permalinks <a href="%s">here</a>', 'wpsc'), admin_url('options-permalink.php'));
            ?>
</em>
			<?php 
        }
        update_option('wpsc_version', 3.8);
        update_option('wpsc_hide_update', true);
    } else {
        _e('Your WP e-Commerce database needs to be updated for WP e-Commerce 3.8.  To perform this update, press the button below.  It is highly recommended that you back up your database before performing this update.', 'wpsc');
        ?>
		<br />
		<br />
		<em><?php 
        _e('Note: If the server times out or runs out of memory, just reload this page, the server will pick up where it left off.', 'wpsc');
        ?>
</em>
		<br />
		
		<form action="" method="post" id="setup">
			<input type="hidden" name="run_updates" value="true" id="run_updates">
			<p class="step"><input type="submit" class="button" value="Update WP e-Commerce" name="Submit"></p>
		</form>
	<?php 
    }
    ?>
	</div>

<?php 
}
Example #2
0
/**
 * WP eCommerce Debug page and functions
 *
 * This is debugging and unsafe updating code to debug or fix specific problems on some sites that is either not safe to run automatically or not usually needed
 * It is unwise to use anything on this page unless you know exactly what it will do and why you need to run it.
 *
 * @package wp-e-commerce
 * @since 3.7
 */
function wpsc_debug_page()
{
    if (!current_user_can('manage_options')) {
        wp_die("You don't look like an administrator.");
    }
    global $wpdb;
    $fixpage = get_option('siteurl') . '/wp-admin/admin.php?page=wpsc-sales-logs&amp;subpage=upgrade-purchase-logs';
    ?>
	<div class="wrap">
		<h2>Debugging Page</h2>
	<?php 
    if (!isset($_GET['wpsc_debug_action'])) {
        ?>
		<p>
				This is debugging and unsafe updating code to debug or fix specific problems on some sites that is either not safe to run automatically or not usually needed<br />
				It is unwise to use anything on this page unless you know exactly what it will do and why you need to run it.
		</p>
		<h4>Action List</h4>
		<ul>
			<li>
				<a href='?page=wpsc-debug&amp;wpsc_debug_action=convert_products_to_posts'>Convert Products to Posts</a>
			</li>
			<li>
				<a href='?page=wpsc-debug&amp;wpsc_debug_action=phpinfo'>Display phpinfo</a>
			</li>
			<li>
				<a href='?page=wpsc-debug&amp;wpsc_debug_action=wpsc_expire_subscriptions'>Expire Subscriptions</a>
			</li>
			<li>
				<a href='<?php 
        echo $fixpage;
        ?>
'>Fix Purchaselogs</a>
			</li>
			<li>
				<a href='<?php 
        echo wp_nonce_url("?wpsc_admin_action=update_page_urls");
        ?>
' ><?php 
        _e('Update Page URLs', 'wpsc');
        ?>
</a> 
			</li>
			<li>
					<a href='<?php 
        echo wp_nonce_url("?wpsc_admin_action=clean_categories");
        ?>
'><?php 
        _e('Fix Product Group Permalinks', 'wpsc');
        ?>
</a>
			</li>		
	</ul>
	<?php 
        if (defined('WPSC_ADD_DEBUG_PAGE') && constant('WPSC_ADD_DEBUG_PAGE') == true) {
            ?>
			<h4>Development Code List</h4>
			<p> And this code is probably useless for anything other than working out how to write better code to do the same thing,  unless you want to do that, leave it alone</p>
			<ul>
				<li>
					<a href='?page=wpsc-debug&amp;wpsc_debug_action=unicode_permalinks'>Test Unicode Category permalinks</a>
				</li>

				<li>
					<a href='?page=wpsc-debug&amp;wpsc_debug_action=create_also_bought_list'>Create also bought list</a>
				</li>
			</ul>
	<?php 
        }
    }
    ?>
	<pre style='font-family:\"Lucida Grande\",Verdana,Arial,\"Bitstream Vera Sans\",sans-serif; font-size:8px;'><?php 
    switch ($_GET['wpsc_debug_action']) {
        case 'convert_products_to_posts':
            wpsc_convert_products_to_posts();
            break;
        case 'download_links':
            wpsc_group_and_update_download_links();
            break;
        case 'product_url_names':
            wpsc_clean_product_url_names();
            break;
        case 'redo_product_url_names':
            wpsc_redo_product_url_names();
            break;
        case 'test_copying_themes':
            wpsc_test_copying_themes();
            break;
        case 'test_making_product_url_names':
            wpsc_test_making_product_url_names();
            break;
        case 'resize_thumbnails':
            wpsc_mass_resize_thumbnails_and_clean_images();
            break;
        case 'images_reupload':
            wpsc_update_image_records(true);
            break;
        case 'filters':
            global $wp_filter, $merged_filters;
            print_r($wp_filter);
            break;
        case 'wpsc_expire_subscriptions':
            if (function_exists('wpsc_expire_subscriptions')) {
                wpsc_expire_subscriptions();
            }
            break;
        case 'phpinfo':
            echo "</pre>";
            phpinfo();
            echo "<pre style='font-family:\"Lucida Grande\",Verdana,Arial,\"Bitstream Vera Sans\",sans-serif; font-size:8px;'>";
            break;
        case 'wp-cron':
            $cron = get_option('cron');
            print_r($cron);
            break;
        case 'wp_get_object_terms':
            global $wp_taxonomies;
            $tags = wp_get_object_terms(108, 'product_tag', array('fields' => 'names'));
            print_r($tags);
            break;
        case 'unicode_permalinks':
            $original_string = "バンプ・オブ・チキン";
            $sanitized_string = sanitize_title($original_string);
            $string_regex = str_replace("%", "\\x", $sanitized_string);
            $full_regex = "/^({$string_regex}){1}\$/";
            echo "Original String: {$original_string} \n";
            echo "Sanitized String: {$sanitized_string} \n";
            echo "String regex: {$string_regex} \n";
            echo "Full regex: {$full_regex} \n";
            if (preg_match($full_regex, $original_string)) {
                echo "<strong>Matches</strong>";
            } else {
                echo "<strong>Does Not Match</strong>";
            }
            break;
    }
    ?>
</pre>
</div>
	<?php 
}