예제 #1
0
 function wptouch_wordtwit_get_recent_tweets()
 {
     $recent_tweets = array();
     $enabled_accounts = wptouch_wordtwit_get_enabled_accounts();
     if (count($enabled_accounts)) {
         $hash_string = '';
         foreach ($enabled_accounts as $name => $account) {
             $hash_string = $hash_string . $name;
         }
         $hash = md5($hash_string);
         $account_info = get_option('wordtwit_pro_tweet_cache');
         if ($account_info) {
             if (time() < $account_info->last_time + 300) {
                 if ($account_info->hash == $hash) {
                     return $account_info->cached_data;
                 }
             }
         }
         foreach ($enabled_accounts as $name => $account) {
             $tweets = wordtwit_wptouch_get_tweets_for_account($name);
             foreach ($tweets as $num => $one_tweet) {
                 $tweet = new stdClass();
                 $tweet->screen_name = $account->screen_name;
                 $tweet->profile_image_url = $account->profile_image_url;
                 $tweet->created_at = strtotime($one_tweet['created_at']);
                 $tweet->text = $one_tweet['text'];
                 $tweet->id = $one_tweet['id'];
                 $tweet->url = 'https://mobile.twitter.com/#!/' . $account->screen_name . '/status/' . $one_tweet['id'];
                 $recent_tweets[$tweet->created_at] = $tweet;
             }
         }
         if (count($recent_tweets)) {
             krsort($recent_tweets);
         }
         if (count($recent_tweets) > 10) {
             $recent_tweets = array_slice($recent_tweets, 0, 10);
         }
         $account_info = new stdClass();
         $account_info->cached_data = $recent_tweets;
         $account_info->last_time = time();
         $account_info->hash = $hash;
         update_option('wordtwit_pro_tweet_cache', $account_info);
     }
     return $recent_tweets;
 }
예제 #2
0
</span>
								<p><?php 
            wptouch_wordtwit_recent_tweet_the_text();
            ?>
</p>
								</a>
							</li>
						<?php 
        }
        ?>
					<?php 
    }
    ?>
					
					<?php 
    $accounts = wptouch_wordtwit_get_enabled_accounts();
    ?>
					<?php 
    if (count($accounts)) {
        ?>
						<?php 
        foreach ($accounts as $name => $account) {
            ?>
						<li class="twitter-link"><a href="http://www.twitter.com/<?php 
            echo $name;
            ?>
"><?php 
            echo sprintf(__('Follow @%s on Twitter', 'wptouch-pro'), $name);
            ?>
</a></li>
						<?php