RamblingRoss
The blog of Ross Fruen, a .NET consultant Changes to sitemap plugin for FlatPress
Currently the sitemap plugin for FlatPress only pings google with changes.
To add additional ping targets two steps are required.
First generate a new class in the /class folder of the sitemap plugin to represent the ping target. For example to ping bing create a file called pingbingsitemaps.php and copy the following code into it...
<?php
function pingBingSitemaps( $url_xml )
{
$status = 0;
$bing = 'www.bing.com';
if( $fp=@fsockopen($bing, 80) )
{
$req = 'GET /webmaster/ping.aspx?sitemap=' .
urlencode( $url_xml ) . " HTTP/1.1\r\n" .
"Host: $bing\r\n" .
"User-Agent: Mozilla/5.0 (compatible; " .
PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" .
"Connection: Close\r\n\r\n";
fwrite( $fp, $req );
while( !feof($fp) )
{
if( @preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m) )
{
$status = intval( $m[1] );
break;
}
}
fclose( $fp );
}
return( $status );
}
?>
Second, update the plugin.sitemap.php file in the sitemap folder. Two changes are required. The first is to load the class just created.
...
// PHP google_sitemap Generator
require_once( "class/pingbingsitemaps.php" );
require_once( "class/pinggooglesitemaps.php" );
require_once( "class/google_sitemap.class.php" );
require_once("defaults.php");
...
Whilst the second is to call the new class.
...
// Once the sitemaps are ready, we ping Google...
if( 200 === ($status=pingGoogleSitemaps($website_url.$sitemap_name)) ) $status = "OK";
// print( "Ping to Google Sitemaps successful.\r\n\r\nStatus code: $status." );
else
// print( "Cannot ping/connect to Google Sitemaps.\r\n\r\nStatus code: $status." );
$status = "KO";
if( 200 === ($status=pingBingSitemaps($website_url.$sitemap_name)) )
if( "OK" === $status )
$status = "OK";
else
$status = "KO";
// end the script.
...
Comments
-
Hi,
Would you please kindly send me the original sitemap generator zip file for flattpress?
I went to download it from the original developer site (http://www.vincentlecluse.com/flatpress-sitemap-generator/) but the site does not come up. Please help. -
Hi Markus,
A modified version of the sitemap generator can be found at www.gsys.biz/blog/availability-of-sitemap-plugin-for-flatpress/ -
I have pinged the bing for my sitemap, but there is no crawling of pages, even after so many tries
-
Hi Sawyer,
The crawling schedule is down to the Bing search engine. Not something this plugin can influence!