"; $full_title = $before_title . $title . $after_title; echo $full_title."
"; nzshpcrt_latest_product(); echo $after_widget; } function nzshpcrt_latest_product($input = null) { global $wpdb; $image_width = get_option('product_image_width'); $image_height = get_option('product_image_height'); $siteurl = get_option('siteurl'); $options = get_option("wpsc-widget_latest_products"); $number = ($options["number"]==0)?5:$options["number"]; $latest_product = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `active` IN ('1') AND `publish` IN ('1') ORDER BY `id` DESC LIMIT ".$number, ARRAY_A); if($latest_product != null) { $output = "
"; foreach($latest_product as $special) { $output.="
"; $output .= " "; $output.=" "; $output .= " ".stripslashes($special['name'])."
"; $output .= "
"; $output .= "
"; } $output .= "
"; } else { $output = ''; } echo $input.$output; } function widget_latest_products_control() { $option_name = 'wpsc-widget_latest_products'; // because I want to only change this to reuse the code. $options = $newoptions = get_option($option_name); if ( isset($_POST[$option_name]) ) { $newoptions['title'] = strip_tags(stripslashes($_POST[$option_name])); $newoptions['number'] = (absint($_POST['wpsc_lpwn']) == 0)? 5:absint($_POST['wpsc_lpwn']); } if ( $options != $newoptions ) { $options = $newoptions; update_option($option_name, $options); } $title = htmlspecialchars($options['title'], ENT_QUOTES); echo "

\n\r"; echo " \n\r"; echo " \n\r"; echo "

\n\r"; } function widget_latest_products_init() { if(function_exists('register_sidebar_widget')) { register_sidebar_widget(__('Latest Products', 'wpsc'), 'widget_latest_products'); register_widget_control(__('Latest Products', 'wpsc'), 'widget_latest_products_control'); } return; } add_action('plugins_loaded', 'widget_latest_products_init'); ?>