/** * Product Specials Widget content function * * Displays the latest products. * * @todo Remove marketplace theme specific code and maybe replce with a filter for the image output? (not required if themeable as above) * * Changes made in 3.8 that may affect users: * * 1. The product title link text does now not have a bold tag, it should be styled via css. * 2. <br /> tags have been ommitted. Padding and margins should be applied via css. * 3. Each product is enclosed in a <div> with a 'wpec-special-product' class. * 4. The product list is enclosed in a <div> with a 'wpec-special-products' class. * 5. Function now expect a single paramter with an array of options (used to be a string which prepended the output). */ function wpsc_specials($args = null, $instance) { global $wpdb; $args = wp_parse_args((array) $args, array('number' => 5)); $siteurl = get_option('siteurl'); if (!($number = (int) $instance['number'])) { $number = 5; } $show_thumbnails = isset($instance['show_thumbnails']) ? (bool) $instance['show_thumbnails'] : FALSE; $show_description = isset($instance['show_description']) ? (bool) $instance['show_description'] : FALSE; $excludes = wpsc_specials_excludes(); $args = array('post_type' => 'wpsc-product', 'caller_get_posts' => 1, 'post_status' => 'publish', 'post_parent' => 0, 'post__not_in' => $excludes, 'posts_per_page' => $number); $special_products = query_posts($args); $output = ''; $product_ids[] = array(); if (count($special_products) > 0) { list($wp_query, $special_products) = array($special_products, $wp_query); // swap the wpsc_query object while (wpsc_have_products()) { wpsc_the_product(); if (!in_array(wpsc_the_product_id(), $product_ids)) { $product_ids[] = wpsc_the_product_id(); if ($show_thumbnails) { if (wpsc_the_product_thumbnail()) { ?> <a rel="<?php echo str_replace(array(" ", '"', "'", '"', '''), array("_", "", "", "", ''), wpsc_the_product_title()); ?> " href="<?php echo wpsc_the_product_permalink(); ?> "> <img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?> " alt="<?php echo wpsc_the_product_title(); ?> " title="<?php echo wpsc_the_product_title(); ?> " src="<?php echo wpsc_the_product_thumbnail(); ?> "/> </a> <?php } else { ?> <a href="<?php echo wpsc_the_product_permalink(); ?> "> <img class="no-image" id="product_image_<?php echo wpsc_the_product_id(); ?> " alt="No Image" title="<?php echo wpsc_the_product_title(); ?> " src="<?php echo WPSC_URL; ?> /wpsc-theme/wpsc-images/noimage.png" width="<?php esc_attr_e(get_option('product_image_width')); ?> " height="<?php esc_attr_e(get_option('product_image_height')); ?> " /> </a> <?php } ?> <?php } // close show thumbnails ?> <br /> <span id="special_product_price_<?php echo wpsc_the_product_id(); ?> "> <!-- price display --> <?php if (wpsc_have_variation_groups()) { while (wpsc_have_variation_groups()) { wpsc_the_variation_group(); ?> <?php /** the variation HTML and loop */ ?> <?php $variation_outputs = array(); ?> <?php while (wpsc_have_variations()) { wpsc_the_variation(); ?> <?php $variation_outputs[] = ''; $variation_prices[] = wpsc_the_variation_price(true); } // Sort the variations into price order before outputting $data[] = $variation_outputs; $data[] = $variation_prices; array_multisort($data[1], SORT_ASC, SORT_NUMERIC, $data[0], SORT_ASC, SORT_STRING); ?> <?php } echo __('From', 'wpsc') . ' : ' . wpsc_currency_display($data[1][0]); ?> <?php } else { ?> <?php echo wpsc_currency_display(wpsc_calculate_price(wpsc_the_product_id(), null, true)); ?> <?php } ?> </span><br /> <strong><a class="wpsc_product_title" href="<?php echo wpsc_product_url(wpsc_the_product_id(), false); ?> "><?php echo wpsc_the_product_title(); ?> </a></strong><br /> <?php if ($show_description) { ?> <div class="wpsc-special-description"> <?php echo wpsc_the_product_description(); ?> </div> <?php } // close show description ?> <?php } } list($wp_query, $special_products) = array($special_products, $wp_query); // swap the wpsc_query object wp_reset_query(); } }
/** * Product Specials Widget content function * * Displays the latest products. * * @todo Remove marketplace theme specific code and maybe replce with a filter for the image output? (not required if themeable as above) * * Changes made in 3.8 that may affect users: * * 1. The product title link text does now not have a bold tag, it should be styled via css. * 2. <br /> tags have been ommitted. Padding and margins should be applied via css. * 3. Each product is enclosed in a <div> with a 'wpec-special-product' class. * 4. The product list is enclosed in a <div> with a 'wpec-special-products' class. * 5. Function now expect a single paramter with an array of options (used to be a string which prepended the output). */ function wpsc_specials($args = null, $instance) { global $wpdb; $args = wp_parse_args((array) $args, array('number' => 5)); $siteurl = get_option('siteurl'); if (!($number = (int) $instance['number'])) { $number = 5; } $show_thumbnails = isset($instance['show_thumbnails']) ? (bool) $instance['show_thumbnails'] : FALSE; $show_description = isset($instance['show_description']) ? (bool) $instance['show_description'] : FALSE; $excludes = wpsc_specials_excludes(); $args = array('post_type' => 'wpsc-product', 'caller_get_posts' => 1, 'post_status' => 'publish', 'post_parent' => 0, 'post__not_in' => $excludes, 'posts_per_page' => $number); $special_products = query_posts($args); $output = ''; $product_ids[] = array(); if (count($special_products) > 0) { list($wp_query, $special_products) = array($special_products, $wp_query); // swap the wpsc_query object while (wpsc_have_products()) { wpsc_the_product(); if (!in_array(wpsc_the_product_id(), $product_ids)) { $product_ids[] = wpsc_the_product_id(); if ($show_thumbnails) { if (wpsc_the_product_thumbnail()) { ?> <a rel="<?php echo str_replace(array(" ", '"', "'", '"', '''), array("_", "", "", "", ''), wpsc_the_product_title()); ?> " href="<?php echo wpsc_the_product_permalink(); ?> "> <img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?> " alt="<?php echo wpsc_the_product_title(); ?> " title="<?php echo wpsc_the_product_title(); ?> " src="<?php echo wpsc_the_product_thumbnail(); ?> "/> </a> <?php } else { ?> <a href="<?php echo wpsc_the_product_permalink(); ?> "> <img class="no-image" id="product_image_<?php echo wpsc_the_product_id(); ?> " alt="No Image" title="<?php echo wpsc_the_product_title(); ?> " src="<?php echo WPSC_URL; ?> /wpsc-theme/wpsc-images/noimage.png" width="<?php esc_attr_e(get_option('product_image_width')); ?> " height="<?php esc_attr_e(get_option('product_image_height')); ?> " /> </a> <?php } ?> <?php } // close show thumbnails ?> <br /> <span id="special_product_price_<?php echo wpsc_the_product_id(); ?> "> <!-- price display --> <?php echo wpsc_the_product_price(); ?> </span><br /> <strong><a class="wpsc_product_title" href="<?php echo wpsc_product_url(wpsc_the_product_id(), false); ?> "><?php echo wpsc_the_product_title(); ?> </a></strong><br /> <?php if ($show_description) { ?> <div class="wpsc-special-description"> <?php echo wpsc_the_product_description(); ?> </div> <?php } // close show description ?> <?php } } list($wp_query, $special_products) = array($special_products, $wp_query); // swap the wpsc_query object wp_reset_query(); } }