$unix_date) { $difference = $now - $unix_date; $tense = "ago"; } else { $difference = $unix_date - $now; $tense = "from now"; } for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { $difference /= $lengths[$j]; } $difference = round($difference); if($difference != 1) { $periods[$j].= "s"; } return "$difference $periods[$j] {$tense}"; } function widget_facebook($args) { extract($args); $fb_widget_options = unserialize(get_option('fb_widget_options')); $title = stripslashes($fb_widget_options['title']); $dispname = stripslashes($fb_widget_options['dispname']); $dformat=$fb_widget_options['df']; echo $before_widget . $before_title . $title . $after_title; global $wpdb; // We need to get the user_id from the userdata table for this blog. $sql="Select user_id from ".WORDBOOK_USERDATA; $result = $wpdb->get_results($sql); $wbuser = wordbook_get_userdata($result[0]->user_id); $fbclient = wordbook_fbclient($wbuser); list($fbuid, $users, $error_code, $error_msg) = wordbook_fbclient_getinfo($fbclient, array( 'is_app_user', 'first_name', 'name', 'status', 'pic', )); $profile_url = "http://www.facebook.com/profile.php?id=$fbuid"; if ($fbuid) { if (is_array($users)) { $user = $users[0]; if ($user['pic']) { echo '
'; echo ''; echo ''; echo '
'; } if (!($name = $user['first_name'])) $name = $user['name']; if (strlen($dispname)>0) $name=$dispname; if ($user['status']['message']) { echo '

'.$name.''; echo ' '.$user['status']['message'].'
'; if ($dformat=='fbt') { echo '('.nicetime($user['status']['time']).').'; } else {echo '('.date($dformat, $user['status']['time']).').';} echo '

'; } } } echo $after_widget; } function fb_widget_control() { // Check if the option for this widget exists - if it doesnt, set some default values // and create the option. if(!get_option('fb_widget_options')) { add_option('fb_widget_options', serialize(array('title'=>'Facebook Status', 'dispname'=>'', 'df'=>'D M j, g:i a'))); } $fb_widget_options = $fb_widget_newoptions = unserialize(get_option('fb_widget_options')); // Check if new widget options have been posted from the form below - // if they have, we'll update the option values. if ($_POST['fb_widget_title']){ $fb_widget_newoptions['title'] = $_POST['fb_widget_title']; } if ($_POST['fb_widget_dispname']){ $fb_widget_newoptions['dispname'] = $_POST['fb_widget_dispname']; } if ($_POST['fb_widget_dformat']){ $fb_widget_newoptions['df'] = $_POST['fb_widget_dformat']; } if($fb_widget_options != $fb_widget_newoptions){ $fb_widget_options = $fb_widget_newoptions; update_option('fb_widget_options', serialize($fb_widget_options)); } // Display html for widget form ?>