Hi guys,

another modification for the fotobook plugin for facebook is the ability to automatically update albums based on a timer, which is great if you casually add photos to the facebook albums, but don’t remember to update them in wordpress, you can actually get the system to update itself.

Firstly, it’ll only work on albums you have already selected to show in the wordpress blog, so if you add a new album, you’ll still have to manually add that through the wordpress blog administration panel.

Secondly, open the fotobook.php file from the fotobook plugin in your favourite text editor and search for the this function

“function fb_display_main”

You’ll find it around line 930.

above it, add the following NEW function

function fb_periodic_update()
{
@session_start();

$current = time();
$timeout = 300;

if(!isset($_SESSION["fb_update_timeout"]))
{
$_SESSION["fb_update_timeout"] = $current - $timeout;
}

if(isset($_SESSION["fb_update_timeout"]))
{
if(($_SESSION["fb_update_timeout"] + $timeout) <= $current) { $_SESSION["fb_update_timeout"] = $current; $facebook = new FacebookAPI; if($facebook->link_active()) $facebook->update_albums();
}
}
}

Then at the top of the function fb_display_main(), do this



function fb_display_main($content) {
remove_filter('the_content','wpautop');
fb_periodic_update();

....the rest of the function don't touch it......

now whenever you open the fotobook albums page, every 500 seconds, it’ll refresh from facebook the photos you have in all the albums.  I tried it myself and it works beautifully!

So, I hope you have fun modifying wordpress plugins! Keep the flame burning!