function wpsc_ajax_load_product()
{
    global $wpdb;
    $product_id = absint($_REQUEST['product_id']);
    check_admin_referer('edit_product_' . $product_id);
    wpsc_display_product_form($product_id);
    exit;
}
示例#2
0
/**
 * WP eCommerce edit and add product page functions
 *
 * These are the main WPSC Admin functions
 *
 * @package wp-e-commerce
 * @since 3.7
 */
function wpsc_display_edit_products_page()
{
    global $wpdb;
    $category_id = absint($_GET['category_id']);
    $columns = array('cb' => '<input type="checkbox" />', 'image' => 'Name', 'title' => '', 'price' => 'Price', 'categories' => 'Categories');
    register_column_headers('display-product-list', $columns);
    $baseurl = includes_url('js/tinymce');
    ?>
	<div class="wrap">
		<?php 
    // screen_icon();
    ?>
		<h2><?php 
    echo wp_specialchars(__('Display Products', 'wpsc'));
    ?>
 </h2>
		
		<?php 
    if (isset($_GET['ErrMessage']) && is_array($_SESSION['product_error_messages'])) {
        ?>
				<div id="message" class="error fade">
					<p>
						<?php 
        foreach ($_SESSION['product_error_messages'] as $error) {
            echo $error;
        }
        ?>
					</p>
				</div>
				<?php 
        unset($_GET['ErrMessage']);
        ?>
				<?php 
        $_SESSION['product_error_messages'] = '';
        ?>
		<?php 
    }
    ?>
			
		<?php 
    if (isset($_GET['flipped']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['message']) || isset($_GET['duplicated'])) {
        ?>
			<div id="message" class="updated fade">
				<p>
				<?php 
        if (isset($_GET['updated'])) {
            printf(__ngettext('%s product updated.', '%s products updated.', $_GET['updated']), number_format_i18n($_GET['updated']));
            unset($_GET['updated']);
        }
        if (isset($_GET['flipped'])) {
            printf(__ngettext('%s product updated.', '%s products updated.', $_GET['flipped']), number_format_i18n($_GET['flipped']));
            unset($_GET['flipped']);
        }
        if (isset($_GET['skipped'])) {
            unset($_GET['skipped']);
        }
        if (isset($_GET['deleted'])) {
            printf(__ngettext('Product deleted.', '%s products deleted.', $_GET['deleted']), number_format_i18n($_GET['deleted']));
            unset($_GET['deleted']);
        }
        if (isset($_GET['duplicated'])) {
            printf(__ngettext('Product duplicated.', '%s products duplicated.', $_GET['duplicated']), number_format_i18n($_GET['duplicated']));
            unset($_GET['duplicated']);
        }
        if (isset($_GET['message'])) {
            $message = absint($_GET['message']);
            $messages[1] = __('Product updated.');
            echo $messages[$message];
            unset($_GET['message']);
        }
        $_SERVER['REQUEST_URI'] = remove_query_arg(array('locked', 'skipped', 'updated', 'deleted', 'message', 'duplicated'), $_SERVER['REQUEST_URI']);
        ?>
			</p>
		</div>
		<?php 
    }
    ?>
		
		<?php 
    $unwriteable_directories = array();
    if (!is_writable(WPSC_FILE_DIR)) {
        $unwriteable_directories[] = WPSC_FILE_DIR;
    }
    if (!is_writable(WPSC_PREVIEW_DIR)) {
        $unwriteable_directories[] = WPSC_PREVIEW_DIR;
    }
    if (!is_writable(WPSC_IMAGE_DIR)) {
        $unwriteable_directories[] = WPSC_IMAGE_DIR;
    }
    if (!is_writable(WPSC_THUMBNAIL_DIR)) {
        $unwriteable_directories[] = WPSC_THUMBNAIL_DIR;
    }
    if (!is_writable(WPSC_CATEGORY_DIR)) {
        $unwriteable_directories[] = WPSC_CATEGORY_DIR;
    }
    if (!is_writable(WPSC_UPGRADES_DIR)) {
        $unwriteable_directories[] = WPSC_UPGRADES_DIR;
    }
    if (count($unwriteable_directories) > 0) {
        echo "<div class='error fade'>" . str_replace(":directory:", "<ul><li>" . implode($unwriteable_directories, "</li><li>") . "</li></ul>", __('The following directories are not writable: :directory: You won&#39;t be able to upload any images or files here. You will need to change the permissions on these directories to make them writable.', 'wpsc')) . "</div>";
    }
    // class='stuffbox'
    ?>
		
		<div id="col-container">
			<div id="wpsc-col-right">			
				<div id='poststuff' class="col-wrap">
					<form id="modify-products" method="post" action="" enctype="multipart/form-data" >
					<?php 
    $product_id = absint($_GET['product_id']);
    wpsc_display_product_form($product_id);
    ?>
					</form>
				</div>
			</div>
			
			<div id="wpsc-col-left">
				<div class="col-wrap">		
					<?php 
    wpsc_admin_products_list($category_id);
    ?>
				</div>
			</div>
		</div>

	</div>
	<script type="text/javascript">
	/* <![CDATA[ */
	(function($){
		$(document).ready(function(){
			$('#doaction, #doaction2').click(function(){
				if ( $('select[name^="action"]').val() == 'delete' ) {
					var m = '<?php 
    echo js_escape(__("You are about to delete the selected products.\n  'Cancel' to stop, 'OK' to delete."));
    ?>
';
					return showNotice.warn(m);
				}
			});
		});
	})(jQuery);
	/* ]]> */
	</script>
	<?php 
}