예제 #1
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&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 
}
/**
 * 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()
{
    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>
	  <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=download_links'>Update Download Links</a>
			</li>
			<li>
				<a href='?page=wpsc-debug&amp;wpsc_debug_action=images_reupload'>Image reassociate</a>
			</li>
			<li>
				<a href='?page=wpsc-debug&amp;wpsc_debug_action=product_url_names'>Clean Duplicate Product URL names</a>
			</li>
			
			<li>
				<a href='?page=wpsc-debug&amp;wpsc_debug_action=redo_product_url_names'>Redo Product URL names</a>
			</li>
			
			<li>
				<a href='?page=wpsc-debug&amp;wpsc_debug_action=test_copying_themes'>Copy Themes to New Theme Directory</a>
			</li>
			
			<li>
				<a href='?page=wpsc-debug&amp;wpsc_debug_action=resize_thumbnails'>Resize all Thumbnails and Clean Empty Image Records</a>
			</li>
			<li>
				<a href='?page=wpsc-debug&amp;wpsc_debug_action=filters'>Display filters</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=wp-cron'>Display wp-cron tasks</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>
		</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=test_making_product_url_names'>Test Making Product URL Names</a>
				</li>-->
				<li>
					<a href='?page=wpsc-debug&amp;wpsc_debug_action=test_variation_grid'>Test Variation Grid</a>
				</li>

				<li>
					<a href='?page=wpsc-debug&amp;wpsc_debug_action=wp_get_object_terms'>Test wp_get_object_terms</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 '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;
            //register_taxonomy('product_tag', 'product');
            //print_r($wp_taxonomies);
            $tags = wp_get_object_terms(108, 'product_tag', array('fields' => 'names'));
            //  			 wp_set_object_terms(103, $tags, 'product_tag');
            print_r($tags);
            break;
        case 'create_also_bought_list':
            //  wpsc_populate_also_bought_list();
            break;
        case 'test_variation_grid':
            $variations_processor = new nzshpcrt_variations();
            $product_data['id'] = 106;
            $output = $variations_processor->variations_grid_view($product_data['id']);
            echo "</pre>";
            echo $output;
            echo "<pre style='font-family:\"Lucida Grande\",Verdana,Arial,\"Bitstream Vera Sans\",sans-serif; font-size:8px;'>";
            break;
    }
    ?>
</pre>
	</div>
	<?php 
}