Add Bing to Wordpress XML Sitemap Generator
- June 4th, 2009
- By nukeit
- Write comment
**UPDATE**
MSN has been replaced by Bing in the latest version:
New in Version 3.1.3 (2009-06-07):
* Changed MSN Live Search to Bing
* Exclude categories also now exludes the category itself and not only the posts
* Pings now use the new WordPress HTTP API instead of Snoopy
* Fixed bug that in localized WP installations priorities could not be saved
* The sitemap cron job is now cleared after a manual rebuild or after changing the config
* Adjusted style of admin area for WP 2.8 and refreshed icons
* Disabled the “Exclude categories” feature for WP 2.5.1, since it doesn’t have the required functions yet
Like many WP users, I have Google XML Sitemaps installed to automatically generate new sitemaps and ping major search engines after every new post. I wanted to add Bing to the list so i dug around the code a bit and figured out that Bing’s sitemap ping service is almost exactly the same as MSN’s. It doesn’t take much to get Bing added to the list of search engines:
sitemap-core.php:382
var $_usedBing = false; var $_bingUrl = ''; var $_bingSuccess = false; var $_bingStartTime = 0; var $_bingEndTime = 0; function StartBingPing($url) { $this->_usedBing = true; $this->_bingUrl = $url; $this->_bingStartTime = $this->GetMicrotimeFloat(); $this->Save(); } function EndBingPing($success) { $this->_bingEndTime = $this->GetMicrotimeFloat(); $this->_bingSuccess = $success; $this->Save(); } function GetBingTime() { return round($this->_bingEndTime - $this->_bingStartTime,2); }
sitemap-core.php:1047
$this->_options["sm_b_pingbing"]=true; //Auto ping Bing
sitemap-core.php:2254
//Ping Bing if($this->GetOption("b_pingbing") && !empty($pingUrl)) { $sPingUrl="http://www.bing.com/webmaster/ping.aspx?siteMap=" . urlencode($pingUrl); $status->StartBingPing($sPingUrl); $pingres=$this->RemoteOpen($sPingUrl); if($pingres==NULL || $pingres===false || strpos($pingres,"Thanks for submitting your sitemap")===false) { $status->EndBingPing(false,$this->_lastError); } else { $status->EndBingPing(true); } }
sitemap-ui.php:650
if($status->_usedBing) { if($status->_bingSuccess) { echo "<li>" .__("BING was <b>successfully notified</b> about changes.",'sitemap'). "</li>"; $at = $status->GetBingTime(); if($at>4) { echo "<li class=\sm_optimize\">" . str_replace("%time%",$at,__("It took %time% seconds to notify BING.com, maybe you want to disable this feature to reduce the building time.",'sitemap')) . "</li>"; } } else { echo "<li class=\"sm_error\">" . str_replace("%s",$status->_bingUrl,__('There was a problem while notifying BING.com. View result','sitemap')) . "</li>"; } }
sitemap-ui.php:767
<li> <input type="checkbox" id="sm_b_pingbing" name="sm_b_pingbing" <?php echo ($this-/>sg->GetOption("b_pingbing")==true?"checked=\"checked\"":"") ?> /> <label for="sm_b_pingbing">< ?php _e('Notify BING about updates of your Blog', 'sitemap') ?></label><br /> <small>< ?php echo str_replace("%s",$this->sg->GetRedirectLink('sitemap-lwt'),__('No registration required, but you can join the BING Webmaster Tools to check crawling statistics.','sitemap')); ?></small> </li>
After you’ve modified the files, check go to your admin section > Settings > XML-Sitemap and regenerate your sitemap manually. You should see “BING was successfully notified about changes.” right under the MSN entry. Way to go!