'widget_wpsc_categorisation', 'description' => __('Product Grouping Widget', 'wpsc')); $this->WP_Widget('wpsc_categorisation', __('Product Categories','wpsc'), $widget_ops); } function widget( $args, $instance ) { global $wpdb, $wpsc_theme_path; extract( $args ); $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Product Categories' ) : $instance['title']); echo $before_widget; if ( $title ) { echo $before_title . $title . $after_title; } $selected_categorisations = array_keys((array)$instance['categorisation'], true); if($selected_categorisations != null) { foreach($selected_categorisations as $key => $selected_categorisation) { $selected_categorisations[$key] = (int)$selected_categorisation; } $selected_values = implode(',',$selected_categorisations); } else { $selected_values = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1') AND `default` IN ('1') LIMIT 1 "); } $categorisation_groups = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `id` IN ({$selected_values}) AND `active` IN ('1')", ARRAY_A); foreach($categorisation_groups as $categorisation_group) { $category_settings = array(); $category_settings['category_group'] = $categorisation_group['id']; $category_settings['show_thumbnails'] = $instance['image']; $category_settings['order_by'] = array("column" => 'name', "direction" =>'asc'); $provided_classes = array(); if($category_settings['show_thumbnails'] == 1) { $provided_classes[] = "category_images"; } //echo wpsc_get_theme_file_path("category_widget.php"); include(wpsc_get_theme_file_path("category_widget.php")); } echo $after_widget; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['categorisation'] = $new_instance['categorisation']; $instance['image'] = $new_instance['image'] ? 1 : 0; return $instance; } function form( $instance ) { global $wpdb; //Defaults $instance = wp_parse_args((array) $instance, array( 'title' => '')); $title = esc_attr( $instance['title'] ); $image = (bool) $instance['image']; ?>

get_results("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1')", ARRAY_A); foreach($categorisation_groups as $cat_group) { $category_state = false; $category_count = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `group_id` IN ('{$cat_group['id']}')"); $category_state = (bool)$instance['categorisation'][$cat_group['id']]; ?> " name="get_field_name('categorisation')."[{$cat_group['id']}]"; ?>" />

/>