コード例 #1
0
 public static function get_instance()
 {
     if (empty(self::$instance)) {
         self::$instance = new WPSC_Update();
     }
     return self::$instance;
 }
コード例 #2
0
/**
 * Display the "Update WP e-Commerce page"
 */
function wpsc_display_update_page()
{
    global $wpdb;
    ?>

	<div class="wrap">
		<h2><?php 
    esc_html_e('Update WP eCommerce', 'wpsc');
    ?>
 </h2>
		<br />
	<?php 
    if (isset($_REQUEST['run_updates'])) {
        ob_implicit_flush(true);
        $wpsc_update = WPSC_Update::get_instance();
        $update_stages = array('convert_category_groups' => __('Updating Categories...', 'wpsc'), 'convert_variation_sets' => __('Updating Variations...', 'wpsc'), 'convert_products_to_posts' => __('Updating Products ...', 'wpsc'), 'convert_variation_combinations' => __('Updating Child Products...', 'wpsc'), 'update_files' => __('Updating Product Files...', 'wpsc'), 'update_purchase_logs' => __('Updating Purchase Logs... ', 'wpsc'), 'create_or_update_tables' => __('Updating Database...', 'wpsc'), 'update_database' => '');
        foreach ($update_stages as $function => $message) {
            $wpsc_update->run($function, $message);
        }
        echo '<br /><br /><strong>' . esc_html__('WP eCommerce updated successfully!', 'wpsc') . '</strong><br />';
        if ('' != get_option('permalink_structure')) {
            ?>
				<em><?php 
            echo esc_html(sprintf(__('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);
        update_option('wpsc_needs_update', false);
        $wpsc_update->clean_up();
        ob_implicit_flush(false);
    } else {
        esc_html_e('Your WP eCommerce database needs to be updated for WP eCommerce 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 
        esc_html_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="<?php 
        esc_attr_e('Update WP eCommerce', 'wpsc');
        ?>
" name="Submit"></p>
		</form>
	<?php 
    }
    ?>
	</div>

<?php 
}