wccs_ping_sitemap_function

Function to Ping generated sitemap since version 1.0.0.

Description

wccs_ping_sitemap_function(); 

Usage

  1. if ( !function_exists( 'wccs_ping_sitemap_function' ) ) { 
  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_function(); 
  7.  

Defined (1)

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

/includes/wccs-functions.php  
  1. function wccs_ping_sitemap_function() { 
  2. $wccssitemapurl=get_option('wccs_sitemap_url'); 
  3. function pingSE($wccssitemapurl, $searchengine) { 
  4.  
  5. switch ($searchengine) { 
  6. case 'bing': 
  7. $pingurl = "http://www.bing.com/webmaster/ping.aspx?siteMap=$wccssitemapurl"; 
  8. break; 
  9.  
  10. case 'google': 
  11. $pingurl = "http://www.google.com/webmasters/sitemaps/ping?sitemap=$wccssitemapurl"; 
  12. break; 
  13.  
  14. default: 
  15. return false; 
  16.  
  17. $curl_handle=curl_init(); 
  18. curl_setopt($curl_handle, CURLOPT_URL, $pingurl); 
  19. curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); 
  20. curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); 
  21. $buffer = curl_exec($curl_handle); 
  22. curl_close($curl_handle); 
  23.  
  24. if (empty($buffer)) 
  25. echo '<tr><td><font size="02" color="black">'.__('Ping to ', 'wccs').'<a href="'.$pingurl.'"><font size="02" color="green">'.$searchengine.'</font></a> '.__('was unsuccessful.Please try again later', 'wccs').'.</font></td></tr><br />'; 
  26. $currenttime = 'unsuccessfull ping at '.current_time( 'mysql' ).' '; 
  27. update_option('wccs_ping_time', $currenttime); 
  28. else 
  29. echo '<tr><td><font size="02" color="black">'.__('Your sitemap is successfully notified to ', 'wccs').' <a href="'.$pingurl.'"><font size="02" color="green">'.$searchengine.'</font></a>.</font></td></tr><br />'; 
  30. $currenttime = current_time( 'mysql' ); 
  31. update_option('wccs_ping_time', $currenttime); 
  32.  
  33. pingSE($wccssitemapurl, 'google'); 
  34.  
  35. pingSE($wccssitemapurl, 'bing'); 
  36.  
  37.  
  38.  
  39.