flush_rules(); $generatorObject = &GoogleSitemapGenerator::GetInstance(); //Please note the "&" sign! if($generatorObject!=null) { $sql = $wpdb->prepare('SELECT c.id, UNIX_TIMESTAMP(MAX(p.date_added)) as dt FROM wp_wpsc_product_categories c, wp_wpsc_item_category_assoc cp, wp_wpsc_product_list p WHERE c.id = cp.category_id AND cp.product_id = p.id'); $results = $wpdb->get_results($sql); foreach ($results as $category) { $generatorObject->AddUrl(wpsc_category_url($category->id), $category->dt, "weekly",0.25); } } } function ses_wpsc_generate_product_entries (){ global $wpdb,$wp_rewrite; $wp_rewrite->flush_rules(); $generatorObject = &GoogleSitemapGenerator::GetInstance(); //Please note the "&" sign! if($generatorObject!=null) { $sql = $wpdb->prepare('SELECT id,UNIX_TIMESTAMP(date_added) as dt FROM wp_wpsc_product_list'); $results = $wpdb->get_results($sql); foreach ($results as $product) { $generatorObject->AddUrl(wpsc_product_url($product->id), $product->dt, "weekly", 0.25); } } } function ses_wpsc_rebuild_sitemap ($id) { global $wpdb; if(class_exists(GoogleSitemapGeneratorLoader) && GoogleSitemapGeneratorLoader::LoadPlugin()) { $gs = GoogleSitemapGenerator::GetInstance(); $shop_page = $wpdb->get_row("SELECT * FROM `".$wpdb->posts."` WHERE `post_content` LIKE '%[shoppingcart]%' AND `post_type` NOT IN('revision') LIMIT 1",ARRAY_A); $gs->CheckForAutoBuild($shop_page['ID']); } } add_action('sm_buildmap', 'ses_wpsc_generate_product_entries'); add_action('sm_buildmap', 'ses_wpsc_generate_category_entries'); add_action('wpsc_edit_product', 'ses_wpsc_rebuild_sitemap'); ?>