Adding FAlbum URLs to XML-Sitemap WordPress Plugin

As I mentioned on my previous post yesterday about Fixing FAlbum Plugin that I’m trying to add support for Google XML Sitemaps Plugin to FAlbum so that all URLs including albums, photos and tags would be added to Blog’s Sitemap which would be crawled by Google, Yahoo and MSN .
Actually, Google XML Sitemaps Plugin made the job much easier by providing simple WordPress add_action() to add the URLs, so you only need to add one function inside ‘wp-content/plugins/falbum/wordpress-falbum-plugin.php’ to accomplish the job !

Edit file wp-content/plugins/falbum/wordpress-falbum-plugin.php and add these lines before the add_action lines

function addto_sitemaps(){
	global $falbum;
	#add FAlbum url to Sitemaps
	function FA_xml_url($pfx=''){
		if( ($FA_xml_go=&GoogleSitemapGenerator::GetInstance()) == null) return;
		$FA_xml_go->AddUrl( get_option('siteurl').$GLOBALS['falbum']->create_url($pfx) , time() , "always", 0.8);
	#creates extra pages depending on the limit you set for 
	#photos and albums per page
	function FA_xml_pages($tot, $limit , $pfx = '' ){
	   $pages = ceil( $tot / $limit);
	   for($i=1; $i <= $pages; $i++)
			FA_xml_url(   $pfx.'page/'.$i.'/' );
	#creates photos urls
	function FA_xml_get_photos(  &$photos , $pfx , $type = 'photoset'){
		global $falbum;
		$photo_title_array = array();
		for( $i=0, $max=count($photos[$type]['photo']); $i < $max ; $i++){
			$photo = $photos[$type]['photo'][$i];
			$photo_id = $photo['id'];
			$photo_title = $photo['title'];
			$photo_link = $falbum->_get_link_title($photo_title, $photo_id, $photo_title_array);
			$p = ceil(($i+1)/$falbum->options['photos_per_page']);
			FA_xml_url(  "{$pfx}page/{$p}/photo/{$photo_link}/");
	#disable administrator user_level to hide secret sets
	$GLOBALS['user_level'] = 0;

	#getting Flickr albums
	$albums = $falbum->_call_flickr_php('flickr.photosets.getList', array ("user_id" => $falbum->options['nsid']));
	#creating main album extra pages
	FA_xml_pages(  count($albums['photosets']['photoset']), $falbum->options['albums_per_page'] );
	#inserting recent photos pages
	$pfx = "show/recent/";
	FA_xml_url( $pfx);
	$photos = $falbum->_call_flickr_php('', array ('user_id' => $falbum->options['nsid'], 'sort' => 'date-taken-desc'));
	$num = count($photos);
	#get recent pages
	FA_xml_pages(   ($falbum->options['number_recent'] == -1 ? $num : $falbum->options['number_recent']) , $falbum->options['photos_per_page'] , $pfx);
	#get recent photos
	FA_xml_get_photos(   $photos , $pfx , 'photos');

	#to avoid creating duplicates when creating urls
	$photo_title_array = array();
	#creating albums urls
	foreach($albums['photosets']['photoset'] as $album){
		$id = $album['id'];
		$title = $falbum->_unhtmlentities($album['title']['_content']);
		$link_title = $falbum->_get_link_title($title, $id, $photo_title_array);
		$pfx = "album/{$link_title}/";
		FA_xml_url(  $pfx);
		#creating album extra pages
		FA_xml_pages(   $album['photos'] , $falbum->options['photos_per_page'] , $pfx);
		#getting album photos
		$photos = $falbum->_call_flickr_php('flickr.photosets.getPhotos', array ("photoset_id" => $album['id']));
		FA_xml_get_photos(   $photos , $pfx);
	#inserting tags pages
	FA_xml_url(  "show/tags/");
	$tags = $falbum->_call_flickr_php('flickr.tags.getListUserPopular', array ('count' => '500', user_id => $falbum->options['nsid']));
	foreach( $tags['who']['tags']['tag'] as $tag ){
		$pfx = "tags/{$tag['_content']}/";
		FA_xml_url(  $pfx);
		#getting tag photos
		$photos = $falbum->_call_flickr_php('', array ('user_id' => $falbum->options['nsid'], 'tags' => $tag['_content'], 'tag_mode' => 'all'));
		$num = count($photos);
		#tag pages
		FA_xml_pages(   $num,  $falbum->options['photos_per_page'], $pfx);
		FA_xml_get_photos(   $photos , $pfx, 'photos');

you see a working preview of my Sitemap

*update 10Dec2007 : fixed photo links 302 redirection*

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.