function tweetable_menu_twitter_timeline() { $user_key = get_option('tweetable_access_token'); $user_key_secret = get_option('tweetable_access_token_secret'); $twitter = new Twitter_API(get_option('tweetable_app_key'), get_option('tweetable_app_key_secret')); $friend_tweets = get_option('tweetable_menu_timeline'); if ($friend_tweets['cache_time'] < mktime() - 120) { /*if ($rate_limit['remaining'] > 4) {*/ $friend_tweets_get = $twitter->friends_timeline($user_key, $user_key_secret, '50'); //echo '<pre>'; print_r($friend_tweets_get); echo '</pre>'; $count = 0; foreach ($friend_tweets_get as $tweet) { $friend_tweets_new[$count]['created_at'] = (string) $tweet['created_at']; $friend_tweets_new[$count]['id'] = (string) $tweet['id']; //$friend_tweets_new[$count]['text'] = (string)$tweet->text; $friend_tweets_new[$count]['text'] = preg_replace('/\\#([a-zA-Z0-9_]+)/', '<a href="' . tweetable_get_plugin_dir('url') . '/dialog.php?show=hashtag&hashtag=\\1&KeepThis=true&TB_iframe=true&height=450&width=680" class="thickbox hashtag" title="Hashtag Search">#\\1</a>', (string) $tweet['text']); $friend_tweets_new[$count]['source'] = (string) $tweet['source']; $friend_tweets_new[$count]['in_reply_to_status_id'] = (string) $tweet['in_reply_to_status_id']; $friend_tweets_new[$count]['in_reply_to_user_id'] = (string) $tweet['in_reply_to_user_id']; $friend_tweets_new[$count]['favorited'] = (string) $tweet['favorited']; $friend_tweets_new[$count]['in_reply_to_screen_name'] = (string) $tweet['in_reply_to_screen_name']; $friend_tweets_new[$count]['user']['id'] = (string) $tweet['user']['id']; $friend_tweets_new[$count]['user']['name'] = (string) $tweet['user']['name']; $friend_tweets_new[$count]['user']['screen_name'] = (string) $tweet['user']['screen_name']; $friend_tweets_new[$count]['user']['profile_image_url'] = (string) $tweet['user']['profile_image_url']; $friend_tweets_new[$count]['user']['url'] = (string) $tweet['user']['url']; $friend_tweets_new[$count]['user']['followers_count'] = (string) $tweet['user']['followers_count']; $friend_tweets_new[$count]['user']['friends_count'] = (string) $tweet['user']['friends_count']; $friend_tweets_new[$count]['user']['created_at'] = (string) $tweet['user']['created_at']; $count++; } $friend_tweets = array('tweets' => $friend_tweets_new, 'cache_time' => mktime()); update_option('tweetable_menu_timeline', $friend_tweets); /*}*/ } /*if ($rate_limit['remaining'] < 6) { echo '<div style="width:650px"><strong>Warning:</strong> Your Twitter account has made more than 95 requests to the Twitter API in this hour. To prevent you from running out of requests, the latest tweets have not been fetched.</div>'; }*/ echo '<ol id="tweetable-timeline">'; foreach ($friend_tweets['tweets'] as $tweet) { echo '<li class="status" id="' . $tweet['id'] . '">'; echo '<span class="twitter_thumb"><img src="' . $tweet['user']['profile_image_url'] . '" width="48" height="48" alt="" /></span>'; echo '<span class="twitter_status">'; echo '<strong><a class="user" href="http://twitter.com/' . $tweet['user']['screen_name'] . '">' . $tweet['user']['screen_name'] . '</a></strong> '; echo '<span class="status-text">' . make_clickable($tweet['text']) . '</span>'; $date = date('F j, Y g:i', strtotime($tweet['created_at'])); echo '<span class="twitter_meta">' . $date . ' from ' . $tweet['source'] . '</span>'; echo '</span>'; echo '<span class="twitter_functions">'; echo '<a class="reply" href="#"><img src="' . tweetable_get_plugin_dir('url') . '/images/reply.png" alt="Reply" title="Reply" /></a> '; echo '<a class="retweet" href="#"><img src="' . tweetable_get_plugin_dir('url') . '/images/retweet.png" alt="Retweet" title="Retweet" /></a>'; echo '</span>'; echo '<br style="clear:both" />'; echo '</li>'; } echo '</ol>'; }
function hashtag($title, $hashtag) { if (!defined('WP_CONTENT_URL')) { define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title><?php echo $title; ?> </title> <link rel='stylesheet' href='http://wp.ntugo.com/wp-admin/load-styles.php?c=1&dir=ltr&load=global' type='text/css' media='all' /> <link rel='stylesheet' id='colors-css' href='http://wp.ntugo.com/wp-admin/css/colors-fresh.css?ver=20090610' type='text/css' media='all' /> <link rel="stylesheet" href="<?php echo tweetable_get_plugin_dir('url'); ?> /admin_css.css" type="text/css" /> <style> .search-div { margin-left: 15px; } </style> </head> <body> <?php $twitter = new Twitter_API(); echo '<div class="search-div">'; echo '<h3>#' . $hashtag . '</h3>'; echo '<div class="twitter_timeline">'; echo '<ol id="tweetable-timeline">'; $results = $twitter->search($hashtag, 'en', '30'); foreach ($results->entry as $tweet) { $tweet->content = preg_replace('/<a\\shref=\\"([^\\"]*)\\">\\#<b>(.*)<\\/b><\\/a>/siU', '<a href="' . tweetable_get_plugin_dir('url') . '/dialog.php?show=hashtag&hashtag=\\2&KeepThis=true&TB_iframe=true&height=450&width=680" class="thickbox hashtag" title="Hashtag Search">#\\2</a>', $tweet->content); $status_id = explode(':', $tweet->id); $status_id = $status_id[2]; $status_user = explode(' (', $tweet->author->name); $status_user = $status_user[0]; echo '<li class="status" id="' . $status_id . '">'; echo '<span class="twitter_thumb"><img src="' . $tweet->link[1]['href'] . '" width="48" height="48" alt="" /></span>'; echo '<span class="twitter_status">'; echo '<strong><a class="user" href="' . $tweet->link[0]['href'] . '">' . $status_user . '</a></strong> '; echo '<span class="status-text">' . make_clickable($tweet->content) . '</span>'; $date = date('F j, Y g:i', strtotime($tweet->published)); echo '<span class="twitter_meta">' . $date . '</span>'; echo '</span>'; echo '</span>'; echo '<br style="clear:both" />'; echo '</li>'; } echo '</ol>'; echo '</div>'; echo '</div>'; echo '</body></html>'; }