wccs_ping_sitemap_with_product_update

Function to Ping generated sitemap whenever product is published since version 1.0.0.

Description

wccs_ping_sitemap_with_product_update(); 

Usage

  1. if ( !function_exists( 'wccs_ping_sitemap_with_product_update' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-category-based-sitemaps/includes/wccs-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wccs_ping_sitemap_with_product_update(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/wccs-functions.php  
  1. function wccs_ping_sitemap_with_product_update() { 
  2.  
  3.  
  4. $wccssitemapurl = get_option('wccs_sitemap_url'); 
  5.  
  6. function pingSE($wccssitemapurl, $searchengine) { 
  7.  
  8. switch ($searchengine) { 
  9. case 'bing': 
  10. $pingurl = "http://www.bing.com/webmaster/ping.aspx?siteMap=$wccssitemapurl"; 
  11. break; 
  12.  
  13. case 'google': 
  14. $pingurl = "http://www.google.com/webmasters/sitemaps/ping?sitemap=$wccssitemapurl"; 
  15. break; 
  16.  
  17. default: 
  18. return false; 
  19.  
  20. $curl_handle=curl_init(); 
  21. curl_setopt($curl_handle, CURLOPT_URL, $pingurl); 
  22. curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); 
  23. curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); 
  24. $buffer = curl_exec($curl_handle); 
  25. curl_close($curl_handle); 
  26.  
  27. if (empty($buffer)) 
  28.  
  29. $currenttime = 'unsuccessfull ping at '.current_time( 'mysql' ).' '; 
  30. update_option('wccs_ping_time', $currenttime); 
  31. else 
  32.  
  33. $currenttime = current_time( 'mysql' ); 
  34. update_option('wccs_ping_time', $currenttime); 
  35.  
  36. pingSE($wccssitemapurl, 'google'); 
  37.  
  38. pingSE($wccssitemapurl, 'bing'); 
  39.  
  40.  
  41.  
  42.