sidebar (w/twitter)

Send Snippet To: Save this snippet to Code Collector Pro -- view all maeghan's snippets
language: PHP
license: GPL 2

Code for Snippet:

                
<div class="span-8 box last"id="sidebar">
<ul id="sidebar">
<?php if ( !function_exists('dynamic_sidebar')
        || !dynamic_sidebar(sidebar) ) : ?>
<?php endif; ?>
<div id="twitter">
<ul class="tweet">
<?php  
 
// Your twitter username.  
$username = "maeghandonovan";  
 
// Prefix - some text you want displayed before your latest tweet.  
// (HTML is OK, but be sure to escape quotes with backslashes: for example href=\"link.html\")  
$prefix = "<h2></h2>";  
 
// Suffix - some text you want display after your latest tweet. (Same rules as the prefix.)  
$suffix = "";  
 
$feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";  
 
function parse_feed($feed) {  
    $stepOne = explode("<content type=\"html\">", $feed);  
    $stepTwo = explode("</content>", $stepOne[1]);  
    $tweet = $stepTwo[0];  
    $tweet = str_replace("&lt;", "<", $tweet);  
    $tweet = str_replace("&gt;", ">", $tweet);  
    return $tweet;  
}  
 
$twitterFeed = file_get_contents($feed);  
echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);  
?>  
 
</ul>
  </div>
</ul>
</div>
 
 
comments powered by Disqus

Info

Tags: SocialMe Wordpress

Link to this snippet:


Download to Code Collector

To use the direct link to your snippet on CodeCollector.net either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 716
Date Added: 2009-03-26 00:34:50
Last Modified: 0000-00-00 00:00:00

Web Analytics