/ Published in: PHP
Expand |
Embed | Plain Text
function jorbin_firestream_search($atts){ 'phrase' => false, 'lang' => 'en', 'max_id' => false, 'since_id' => false, 'number' => '20' ), $atts)); if ('phrase' == false){ return false; } //*/ Build our search url and transient name $transient = 'tweet-'. esc_sql($phrase) . '&l=' . esc_sql($lang); if ($max_id != false){ $url .= '&max_id=' . (int) $max_id; $transient .= '&m=' . (int) $max_id; } if ($since_id != false){ $url .= '&since_id=' . (int) $since_id; $transient .= '&s=' . (int) $since_id; } if ( $tweet_display = get_transient($transient) ){ // It's allready been brought } else { if ($search = wp_remote_get( $url ) ){ $results = json_decode($search['body']); $tweets = $results->results; //*/ $tweetcontent = $tweet->text; $newcontent = preg_replace('%@([^\s]*)%', "<a href="http://twitter.com/\\1">@\\1</a>", $tweetcontent); <img class="twitter_shortcode_image" src="".esc_url($tweet->profile_image_url).""><span class="twitter_shotcode_username"><a href="http://twitter.com/".$tweet->from_user."">".$tweet->from_user."</a> — </span>". $newcontent ."</p> </div>"; } $tweet_display = ob_get_clean(); set_transient($transient, $tweet_display, 300); } else { $tweet_display = "I'm sorry, no tweets are availailable at this time"; } } return apply_filters('jorbin_tweet_content', $tweet_display) ; } add_filter('jorbin_tweet_content', 'make_clickable' ); add_shortcode('twitter-search', 'jorbin_firestream_search');
Comments
Subscribe to comments
You need to login to post a comment.

does this use some pre-existing framework?
Just wordpress...