'Displays your latest twitter.com updates' ) );
}
function form($instance) {
// outputs the options form on admin
if ( !function_exists('quot') ){
function quot($txt){
return str_replace( "\"", """, $txt );
}
}
// format some of the options as valid html
@$username = htmlspecialchars($instance['user'], ENT_QUOTES);
@$updateCount = htmlspecialchars($instance['count'], ENT_QUOTES);
@$showTwitterIconTF = $instance['showTwitterIconTF'];
@$showProfilePicTF = $instance['showProfilePicTF'];
@$showTweetTimeTF = $instance['showTweetTimeTF'];
@$widgetTitle = stripslashes(quot($instance['widgetTitle']));
@$includeRepliesTF = $instance['includeRepliesTF'];
?>
checked="checked">
checked="checked">
checked="checked">
checked="checked">
checked="checked">
To style the output of the widget, modify this CSS stylesheet. You should also back this file up before updating the plugin.
file_missing_or_old( $jsonFileName, .5 )){
//get new data from twitter
$jsonData = $this->save_remote_file( $jsonURL, $jsonFileName );
} else{
//already have file, get the data out of it
$jsonData = $this->get_json_data_from_file( $jsonFileName );
}
// check for errors--rate limit or curl not installed
// data returned will be: {"error":"Rate limit exceeded. Clients may not make more than 150 requests per hour.","request":"\/1\/statuses\/user_timeline.json?screen_name=salzano&include_entities=true"}
if( @$jsonData == "" || @iconv_strlen( $tweets->error, "UTF-8" )){
//delete the json file so it will surely be downloaded on next page view
if( file_exists( dirname(__FILE__) ."/". $jsonFileName )){
unlink( dirname(__FILE__) ."/". $jsonFileName );
}
//get the backup data
$jsonData = $this->get_json_data_from_file( $jsonTempFileName );
} else{
//good file, create a backup
if( file_exists( dirname(__FILE__) . "/" . $jsonFileName )){
copy( dirname(__FILE__) . "/" . $jsonFileName, dirname(__FILE__) . "/" . $jsonTempFileName );
}
}
if( $tweets = json_decode( $jsonData )){
$haveTwitterData = true;
} else{
//tweets is null
$haveTwitterData = false;
}
// $tweets has been json_decoded
if( $haveTwitterData && $showProfilePicTF ){
//make sure we have the profile picture saved locally
$twitterUserData = $tweets[0]->user;
$profilePicURL = $twitterUserData->profile_image_url;
$profilePicPieces = explode( ".", $profilePicURL );
$profilePicExt = end( $profilePicPieces );
$profilePicFileName = $username . "." . $profilePicExt;
if( $this->file_missing_or_old( $profilePicFileName, .5 )){
$this->save_remote_file( $profilePicURL, $profilePicFileName );
}
}
// output the widget
$title = empty($title) ? ' ' : apply_filters('widget_title', $title);
echo $before_widget;
if( !empty( $title ) && $title != " " ) { echo $before_title . $title . $after_title; };
if( $haveTwitterData ){
$linkHTML = "";
$pluginURL = home_url()."/wp-content/plugins/latest-twitter-sidebar-widget/";
$icon = $pluginURL . "twitter.png";
@$pic = $pluginURL . $profilePicFileName;
if( $showTwitterIconTF ){
echo $linkHTML . "";
} else{
if( $showProfilePicTF ){
echo $linkHTML . "";
}
}
$i=1;
foreach( $tweets as $tweet ){
//exit this loop if we have reached updateCount
if( $i > $updateCount ){ break; }
//skip this iteration of the loop if this is a reply and we are not showing replies
if( !$includeRepliesTF && strlen( $tweet->in_reply_to_screen_name )){ continue; }
echo "