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...

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] );
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" );

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." );
// 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";
$status = "KO";

// end the script.


  1. 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.

    - Written on 5th August 2011 by Markus
  2. Hi Markus,

    A modified version of the sitemap generator can be found at www.gsys.biz/blog/availability-of-sitemap-plugin-for-flatpress/

    - Written on 5th August 2011 by Ross
  3. I have pinged the bing for my sitemap, but there is no crawling of pages, even after so many tries

    - Written on 26th June 2012 by Sawyer
  4. Hi Sawyer,

    The crawling schedule is down to the Bing search engine. Not something this plugin can influence!

    - Written on 26th June 2012 by Ross

Add a comment

If you want your comment to appear on this page please complete the form below. Your name and email address are optional, although the latter will be required if you want a response. Your email address will not appear against your comment and will only be used to correspond with yourself (where appropriate).


Thank you for submitting your comment, it will appear here after moderation is complete.


There was a problem sending your comment, please try again.