示例#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;
 }
            ?>
</h4>
					<p class="author-link">
						<img src="<?php 
            echo $accounts[$twitter_account]->profile_image_url;
            ?>
" alt="twitter avatar">
						<span>
							<?php 
            echo sprintf(__('Follow %s on Twitter', 'wptouch-pro'), '<a href="https://twitter.com/' . $twitter_account . '" target="_blank">@' . $twitter_account . '</a>');
            ?>
							</span>
					</p>
					<ul>
						<?php 
            $tweets = wordtwit_wptouch_get_tweets_for_account($twitter_account);
            ?>
						<?php 
            foreach ($tweets as $tweet) {
                ?>
							<li>
							<a href="<?php 
                echo 'https://twitter.com/' . $twitter_account . '/status/' . $tweet['id'];
                ?>
" rel="external-tweet-link" target="_blank" class="no-ajax">
							<p class="tweet-time"><?php 
                foundation_twitter_pretty_time(foundation_twitter_get_tweet_time($tweet['created_at']));
                ?>
</p>
							<p class="tweet-text"><?php 
                echo foundation_twitter_pretty_text($tweet['text']);